diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java b/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java index ccf7c82..3bfc945 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java @@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo; import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; import com.glxp.udidl.admin.entity.udi.ProductInfoEntity; import com.glxp.udidl.admin.entity.udid.UdiEntity; +import com.glxp.udidl.admin.exception.JsonException; import com.glxp.udidl.admin.req.FilterUdiInfoRequest; import com.glxp.udidl.admin.req.MutiAppScanRequest; import com.glxp.udidl.admin.req.MutiScanRequest; @@ -33,6 +34,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; + @Slf4j @RestController public class UdiInfoController { @@ -73,14 +75,14 @@ public class UdiInfoController { } List results = productInfoService.selectByUuid(productInfoEntityList.get(0).getUuid()); - boolean checkSuccess = true; + Boolean checkSuccess = true; String lostMsg = ""; if (udiEntity == null) { return ResultVOUtils.error(500, "UDI码格式错误!"); } else { if (StrUtil.isNotEmpty(udiEntity.getUdi())) { ProductInfoEntity productInfoEntity = productInfoEntityList.get(0); - lostMsg = getErrMsg(productInfoEntity, udiEntity, lostMsg); + lostMsg = getErrMsg(productInfoEntity, udiEntity, lostMsg, checkSuccess); //缺少GS1强行添加分隔符进行判断 processUdiEntity(udiEntity, lostMsg); for (ProductInfoEntity temp : results) { @@ -89,9 +91,12 @@ public class UdiInfoController { temp.setProduceDate(udiEntity.getProduceDate()); temp.setSerialNo(udiEntity.getSerialNo()); } - lostMsg = getErrMsg(productInfoEntity, udiEntity, "扫码识别格式错误,已进行AI自动校正"); + lostMsg = getErrMsg(productInfoEntity, udiEntity, "", checkSuccess); } } + if (lostMsg.contains("校验成功")) { + checkSuccess = true; + } else checkSuccess = false; UdiAppResponse udiAppResponse = new UdiAppResponse(); udiAppResponse.setVailResult(checkSuccess); udiAppResponse.setVailMsg(lostMsg); @@ -149,21 +154,22 @@ public class UdiInfoController { } private boolean extractSerialNumber(UdiEntity udiEntity, String batchNo, String serialNumberCode) { - int index = batchNo.indexOf(serialNumberCode)+2; - if (index != -1 && index + 2 <= batchNo.length()) { + int index = batchNo.indexOf(serialNumberCode) + 2; + if (index != -1 && index + 2 <= batchNo.length() && batchNo.contains(serialNumberCode)) { // 假设序列号是6位数字,此处可以根据实际需求进行调整 - String serialNumber = batchNo.substring(index); + String serialNumber = batchNo.substring(index + 2); // 对序列号进行一些合法性校验,如果需要 // ... - udiEntity.setSerialNo(serialNumber); // 假设存在此方法,用于设置序列号 - udiEntity.setBatchNo(batchNo.substring(0, index-2)); + if (serialNumber.length() > 5) { + udiEntity.setSerialNo(serialNumber); // 假设存在此方法,用于设置序列号 + udiEntity.setBatchNo(batchNo.substring(0, index - 2)); + } return true; } return false; } - public String getErrMsg(ProductInfoEntity productInfoEntity, UdiEntity udiEntity, String lostMsg) { - boolean checkSuccess = true; + public String getErrMsg(ProductInfoEntity productInfoEntity, UdiEntity udiEntity, String lostMsg, Boolean checkSuccess) { if ("是".equals(productInfoEntity.getScbssfbhph()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { checkSuccess = false; lostMsg = lostMsg + ",批次号"; diff --git a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceDownloadService.java b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceDownloadService.java index 869b71c..85f192c 100644 --- a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceDownloadService.java +++ b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceDownloadService.java @@ -428,7 +428,7 @@ public class DeviceDownloadService { try { Thread.sleep(3 * 1000); String json = JSONUtil.toJsonStr(deviceHistoryRequest); - response = okHttpCli.doPostJson(historyUrl, json, getHeaders()); + response = okHttpCli.doPostJson(UdidConfig.apiUrl + historyUrl, json, getHeaders()); } catch (InterruptedException e) { log.error(e.getMessage(), e); results.setCode(-1);