Commit 9f57bb6c zshaohui

1.增加扫码出库功能

2.批量禁限用报错重试3次
1 个父辈 71fc31c5
...@@ -1231,66 +1231,87 @@ public class LuxsanApi extends DefaultSmfApiListener { ...@@ -1231,66 +1231,87 @@ public class LuxsanApi extends DefaultSmfApiListener {
public static List<String> batchCheckReel(List<Barcode> barcodeList,String pickingId,String model) { public static List<String> batchCheckReel(List<Barcode> barcodeList,String pickingId,String model) {
List<Map<String,Object>> paramList = new ArrayList<>(); List<Map<String, Object>> paramList = new ArrayList<>();
for (Barcode barcode : barcodeList) { for (Barcode barcode : barcodeList) {
Map<String,Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn",barcode.getPartNumber()); paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId",barcode.getBarcode()); paramMap.put("reelId", barcode.getBarcode());
paramMap.put("wo",""); paramMap.put("wo", "");
paramMap.put("datecode",barcode.getDateCode()); paramMap.put("datecode", barcode.getDateCode());
paramMap.put("lot",barcode.getBatch()); paramMap.put("lot", barcode.getBatch());
paramMap.put("vendor",barcode.getProvider()); paramMap.put("vendor", barcode.getProvider());
paramMap.put("remark","ALL"); paramMap.put("remark", "ALL");
paramMap.put("werks","ALL"); paramMap.put("werks", "ALL");
paramMap.put("model","ALL"); paramMap.put("model", "ALL");
if (StringUtils.isNotEmpty(model)){ if (StringUtils.isNotEmpty(model)) {
paramMap.put("model",model); paramMap.put("model", model);
} }
paramMap.put("picking","ALL"); paramMap.put("picking", "ALL");
if (StringUtils.isNotEmpty(pickingId)){ if (StringUtils.isNotEmpty(pickingId)) {
paramMap.put("picking",pickingId); paramMap.put("picking", pickingId);
} }
paramList.add(paramMap); paramList.add(paramMap);
} }
log.info("批量禁用入参为:"+JSON.toJSONString(paramList)); log.info("批量禁用入参为:" + JSON.toJSONString(paramList));
Map<String,String> resultMap = new HashMap<>();
Map<String, String> resultMap = new HashMap<>();
List<String> reelList = new ArrayList<>(); List<String> reelList = new ArrayList<>();
int maxRetries = 3;
int retryCount = 0;
boolean isSuccess = false;
// 重试机制:最多请求3次
while (retryCount < maxRetries && !isSuccess) {
retryCount++;
try { try {
String resultStr = HttpHelper.postJson(batchCheckReelUrl, paramList); String resultStr = HttpHelper.postJson(batchCheckReelUrl, paramList);
log.info("批量禁用接口返回结果为:"+resultStr); log.info("第" + retryCount + "次批量禁用接口返回结果为:" + resultStr);
JSONObject resultObj = JSONObject.parseObject(resultStr); JSONObject resultObj = JSONObject.parseObject(resultStr);
String status = resultObj.getString("status"); String status = resultObj.getString("status");
if ("200".equals(status)){ // 只有返回200才认为成功
if ("200".equals(status)) {
isSuccess = true;
JSONArray dataArr = resultObj.getJSONArray("data"); JSONArray dataArr = resultObj.getJSONArray("data");
if (dataArr != null && !dataArr.isEmpty()){ if (dataArr != null && !dataArr.isEmpty()) {
for (int i = 0; i < dataArr.size(); i++) { for (int i = 0; i < dataArr.size(); i++) {
JSONObject data = dataArr.getJSONObject(i); JSONObject data = dataArr.getJSONObject(i);
JSONArray resultList = data.getJSONArray("resultList"); JSONArray resultList = data.getJSONArray("resultList");
if (resultList != null && !resultList.isEmpty()){ if (resultList != null && !resultList.isEmpty()) {
for (int j = 0; j < resultList.size(); j++) { for (int j = 0; j < resultList.size(); j++) {
JSONObject result = resultList.getJSONObject(j); JSONObject result = resultList.getJSONObject(j);
String reelId = result.getString("reelId"); String reelId = result.getString("reelId");
String message = result.getString("message"); String message = result.getString("message");
if (StringUtils.isNotBlank(reelId)){ if (StringUtils.isNotBlank(reelId)) {
reelList.add(reelId); reelList.add(reelId);
resultMap.put(reelId,message); resultMap.put(reelId, message);
}
}
}
} }
} }
} else {
log.info("第" + retryCount + "次调用返回非200状态: " + status);
} }
} catch (Exception e) {
log.error("第" + retryCount + "次批量禁用接口调用失败: " + e.getMessage(), e);
} }
} }
// 如果3次都失败,将所有barcode加入reelList
if (!isSuccess) {
log.info("经过" + maxRetries + "次重试后仍失败,将所有条码加入结果列表");
for (Barcode barcode : barcodeList) {
String reelId = barcode.getBarcode();
reelList.add(reelId);
resultMap.put(reelId, "接口调用失败,默认禁用");
} }
} catch (Exception e){
log.info("批量禁用接口调用失败:"+e.getMessage());
} }
// 更新条码状态
for (Barcode barcode : barcodeList) { for (Barcode barcode : barcodeList) {
if(reelList.contains(barcode.getBarcode())) { if (reelList.contains(barcode.getBarcode())) {
String message = resultMap.get(barcode.getBarcode()); String message = resultMap.get(barcode.getBarcode());
barcode.setDisableMsg(message); barcode.setDisableMsg(message);
barcodeManager.save(barcode); barcodeManager.save(barcode);
......
...@@ -49,7 +49,7 @@ lizhen: ...@@ -49,7 +49,7 @@ lizhen:
differenceUrl: http://10.68.27.104/smf-core/api/Mes/differenceReel differenceUrl: http://10.68.27.104/smf-core/api/Mes/differenceReel
storageC12F: storageC12F:
name: storageC12F name: storageC12F
line: BG02T,BG02B,CG20B1,CG02B2,CG02T1,CG02T2,AS02T1,AS02T2,AS02T3,AS02B1,AS02B2 line: BG02T,BG02B,CG20B1,CG02B2,CG02T1,CG02T2,AS02T1,AS02T2,AS02T3,AS02B1,AS02B2,BG03T1,BG03T2,BG03B1,BG03B2,BG04B,BG04T,CG03T1,CG03T2,CG03B
url: http://10.68.27.105/smf-core/api/Mes/machineCallMaterial url: http://10.68.27.105/smf-core/api/Mes/machineCallMaterial
differenceUrl: http://10.68.27.105/smf-core/api/Mes/differenceReel differenceUrl: http://10.68.27.105/smf-core/api/Mes/differenceReel
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!