diff --git a/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java b/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java index bb0c8f99a..f6715be65 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoCodeTempController.java @@ -274,95 +274,18 @@ public class IoCodeTempController extends BaseController { code = originCode + addEnterCodeRequest.getCode(); String newCode = addEnterCodeRequest.getCode(); - //重复判断 if (StrUtil.isNotEmpty(addEnterCodeRequest.getOriginCode())) { - String tempOriginCode = addEnterCodeRequest.getOriginCode(); - if (tempOriginCode.endsWith("\u001D")) { - tempOriginCode = tempOriginCode.replace("\u001D", ""); - } - UdiEntity originUdiEntity = FilterUdiUtils.getUdi(tempOriginCode); - if (StrUtil.isNotEmpty(newCode)) { - if (newCode.startsWith("10")) { - if (StrUtil.isNotEmpty(originUdiEntity.getBatchNo())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "批次号重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("17")) { - if (StrUtil.isNotEmpty(originUdiEntity.getExpireDate())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "失效日期重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("11")) { - if (StrUtil.isNotEmpty(originUdiEntity.getProduceDate())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "生产日期重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else if (newCode.startsWith("21")) { - if (StrUtil.isNotEmpty(originUdiEntity.getSerialNo())) { - BaseResponse baseResponse = ResultVOUtils.error(501, "序列号重复添加"); - baseResponse.setData(originCode); - return baseResponse; - } else { - String msg = checkNewCode(originUdiEntity, newCode); - if (msg != null) { - BaseResponse baseResponse = ResultVOUtils.error(501, msg); - baseResponse.setData(originCode); - return baseResponse; - } - } - } else { - BaseResponse baseResponse = ResultVOUtils.error(501, "格式错误"); - baseResponse.setData(originCode); - return baseResponse; - } + BaseResponse baseResponse = codeTempService.checkRedundant(addEnterCodeRequest,newCode,originCode); + if (baseResponse.getCode() != 20000){ + return baseResponse; } } - - - // TODO: 2024/9/13 首次无单进入的时候报错提示,不需要执行校验 - UdiEntity udiEntity = FilterUdiUtils.getUdi(code); - if (udiEntity == null) { - String sptmtodi = systemParamConfigService.selectValueByParamKey(Constant.SPTM_TO_DI); - if (sptmtodi.equals("1")) { - if (code.length() == 13) { - UdiProductEntity udiProductEntity = udiProductService.findBySptm(code); - if (udiProductEntity != null) { - BaseResponse baseResponse = ResultVOUtils.error(508, "UDI码格式错误"); - baseResponse.setData(udiProductEntity); - return baseResponse; - } - } - } - BaseResponse baseResponse = ResultVOUtils.error(501, "UDI码格式错误"); - baseResponse.setData(originCode); - return baseResponse; + BaseResponse checkFormatResponse = codeTempService.checkFormat(code,originCode); + if (checkFormatResponse.getCode() != 20000){ + return checkFormatResponse; } - + UdiEntity udiEntity = (UdiEntity) checkFormatResponse.getData(); UdiRelevanceResponse checkUdi = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); if (checkUdi == null) { return ResultVOUtils.error(500, "耗材字典不存在此产品!"); @@ -380,61 +303,7 @@ public class IoCodeTempController extends BaseController { code = code + "\u001D"; } } - - - boolean checkSuccess = true; - String lostMsg = ""; - //校验条码完整性 - if ("是".equals(checkUdi.getScbssfbhph()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { - checkSuccess = false; - lostMsg = lostMsg + ",批次号"; - } - if ("是".equals(checkUdi.getScbssfbhscrq()) && StrUtil.isEmpty(udiEntity.getProduceDate())) { - checkSuccess = false; - lostMsg = lostMsg + ",生产日期"; - } - - if ("是".equals(checkUdi.getScbssfbhsxrq()) && StrUtil.isEmpty(udiEntity.getExpireDate())) { - checkSuccess = false; - lostMsg = lostMsg + ",失效日期"; - } - if (checkUdi.getAllowNoSerial() != null && !checkUdi.getAllowNoSerial() && StrUtil.isEmpty(udiEntity.getSerialNo()) - ) { - checkSuccess = false; - lostMsg = lostMsg + ",序列号"; - } - if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) { - return ResultVOUtils.error(504, "序列号超出20位!"); - } - if (StrUtil.isNotEmpty(udiEntity.getBatchNo()) && udiEntity.getBatchNo().length() > 20) { - return ResultVOUtils.error(504, "批次号超出20位!"); - } - if (StrUtil.isEmpty(udiEntity.getSerialNo()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { - checkSuccess = false; - } - if (checkSuccess) { - if (code.endsWith("\u001D")) { - code = code.substring(0, code.length() - "\u001D".length()); - } - udiEntity.setCode(code); - AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); - return ResultVOUtils.success(addEnterCodeResponse); - } else { - if (newCode.startsWith("21") || (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && newCode.contains("21" + udiEntity.getSerialNo()))) { - if (StrUtil.isEmpty(lostMsg)) { - lostMsg = ","; - } - BaseResponse baseResponse = ResultVOUtils.error(503, "条码完整性错误,缺少" + lostMsg.substring(1) + "是否继续添加?"); - udiEntity.setCode(code); - AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); - baseResponse.setData(addEnterCodeResponse); - return baseResponse; - } - } - BaseResponse baseResponse = ResultVOUtils.error(502, "校验未完成,缺少" + lostMsg.substring(1)); - udiEntity.setCode(code); - AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); - baseResponse.setData(addEnterCodeResponse); + BaseResponse baseResponse = codeTempService.checkCode(udiEntity,code,checkUdi,newCode); return baseResponse; } @@ -622,25 +491,7 @@ public class IoCodeTempController extends BaseController { } - public String checkNewCode(UdiEntity originEnity, String newCode) { - UdiEntity newEntity = FilterUdiUtils.getUdi(originEnity.getUdi() + newCode); - if (newEntity == null || originEnity == null) { - return null; - } - if (StrUtil.isNotEmpty(originEnity.getBatchNo()) && StrUtil.isNotEmpty(newEntity.getBatchNo())) { - return "批次号重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getProduceDate()) && StrUtil.isNotEmpty(newEntity.getProduceDate())) { - return "生产日期重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getExpireDate()) && StrUtil.isNotEmpty(newEntity.getExpireDate())) { - return "失效日期重复添加!"; - } - if (StrUtil.isNotEmpty(originEnity.getSerialNo()) && StrUtil.isNotEmpty(newEntity.getSerialNo())) { - return "序列号重复添加!"; - } - return null; - } + //前端扫码提交(耗材器械) @RepeatSubmit() diff --git a/src/main/java/com/glxp/api/service/inout/IoCodeTempService.java b/src/main/java/com/glxp/api/service/inout/IoCodeTempService.java index 5fb6c18ee..0d91e6983 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCodeTempService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCodeTempService.java @@ -9,27 +9,37 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.constant.Constant; import com.glxp.api.dao.inout.IoCodeTempDao; import com.glxp.api.entity.basic.BasicBussinessTypeEntity; +import com.glxp.api.entity.basic.UdiEntity; +import com.glxp.api.entity.basic.UdiProductEntity; import com.glxp.api.entity.inout.IoCodeTempEntity; import com.glxp.api.entity.inout.IoOrderDetailCodeEntity; import com.glxp.api.entity.inout.IoOrderEntity; +import com.glxp.api.req.inout.AddEnterCodeRequest; import com.glxp.api.req.inout.FilterCodeRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.basic.UdiRelevanceResponse; import com.glxp.api.res.collect.RelCodeDetailResponse; +import com.glxp.api.res.inout.AddEnterCodeResponse; import com.glxp.api.res.inout.IoCodeResponse; import com.glxp.api.res.inout.IoCodeTempResponse; import com.glxp.api.service.basic.IBasicBussinessTypeService; +import com.glxp.api.service.basic.UdiProductService; import com.glxp.api.service.basic.UdiRelevanceService; import com.glxp.api.service.collect.RelCodeDetailService; import com.glxp.api.service.inout.impl.IoCodeService; +import com.glxp.api.service.system.SystemParamConfigService; import com.glxp.api.util.BeanCopyUtils; import com.glxp.api.util.IntUtil; import com.glxp.api.util.page.PageQuery; import com.glxp.api.util.page.TableDataInfo; +import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.util.udi.UdiCalCountUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -314,4 +324,189 @@ public class IoCodeTempService { .eq(IoCodeTempEntity::getGroupNumber,groupNumber) ); } + + public BaseResponse checkRedundant(AddEnterCodeRequest addEnterCodeRequest,String newCode,String originCode) { + String tempOriginCode = addEnterCodeRequest.getOriginCode(); + if (tempOriginCode.endsWith("\u001D")) { + tempOriginCode = tempOriginCode.replace("\u001D", ""); + } + UdiEntity originUdiEntity = FilterUdiUtils.getUdi(tempOriginCode); + if (StrUtil.isNotEmpty(newCode)) { + if (newCode.startsWith("10")) { + if (StrUtil.isNotEmpty(originUdiEntity.getBatchNo())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "批次号重复添加"); + baseResponse.setData(originCode); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(originCode); + return baseResponse; + } + } + } else if (newCode.startsWith("17")) { + if (StrUtil.isNotEmpty(originUdiEntity.getExpireDate())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "失效日期重复添加"); + baseResponse.setData(originCode); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(originCode); + return baseResponse; + } + } + } else if (newCode.startsWith("11")) { + if (StrUtil.isNotEmpty(originUdiEntity.getProduceDate())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "生产日期重复添加"); + baseResponse.setData(originCode); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(originCode); + return baseResponse; + } + } + } else if (newCode.startsWith("21")) { + if (StrUtil.isNotEmpty(originUdiEntity.getSerialNo())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "序列号重复添加"); + baseResponse.setData(originCode); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(originCode); + return baseResponse; + } + } + } else { + BaseResponse baseResponse = ResultVOUtils.error(501, "格式错误"); + baseResponse.setData(originCode); + return baseResponse; + } + } + return ResultVOUtils.success(); + } + + public String checkNewCode(UdiEntity originEnity, String newCode) { + UdiEntity newEntity = FilterUdiUtils.getUdi(originEnity.getUdi() + newCode); + if (newEntity == null || originEnity == null) { + return null; + } + if (StrUtil.isNotEmpty(originEnity.getBatchNo()) && StrUtil.isNotEmpty(newEntity.getBatchNo())) { + return "批次号重复添加!"; + } + if (StrUtil.isNotEmpty(originEnity.getProduceDate()) && StrUtil.isNotEmpty(newEntity.getProduceDate())) { + return "生产日期重复添加!"; + } + if (StrUtil.isNotEmpty(originEnity.getExpireDate()) && StrUtil.isNotEmpty(newEntity.getExpireDate())) { + return "失效日期重复添加!"; + } + if (StrUtil.isNotEmpty(originEnity.getSerialNo()) && StrUtil.isNotEmpty(newEntity.getSerialNo())) { + return "序列号重复添加!"; + } + return null; + } + + + @Autowired + private SystemParamConfigService systemParamConfigService; + + @Autowired + UdiProductService udiProductService; + public BaseResponse checkFormat(String code,String originCode) { + // TODO: 2024/9/13 首次无单进入的时候报错提示,不需要执行校验 + UdiEntity udiEntity = FilterUdiUtils.getUdi(code); + if (udiEntity == null) { + String sptmtodi = systemParamConfigService.selectValueByParamKey(Constant.SPTM_TO_DI); + if (sptmtodi.equals("1")) { + if (code.length() == 13) { + UdiProductEntity udiProductEntity = udiProductService.findBySptm(code); + if (udiProductEntity != null) { + BaseResponse baseResponse = ResultVOUtils.error(508, "UDI码格式错误"); + baseResponse.setData(udiProductEntity); + return baseResponse; + } + } + } + BaseResponse baseResponse = ResultVOUtils.error(501, "UDI码格式错误"); + baseResponse.setData(originCode); + return baseResponse; + } + return ResultVOUtils.success(udiEntity); + } + + public BaseResponse checkCode(UdiEntity udiEntity,String code,UdiRelevanceResponse checkUdi,String newCode) { + boolean checkSuccess = true; + String lostMsg = ""; + //校验条码完整性 + if ("是".equals(checkUdi.getScbssfbhph()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { + checkSuccess = false; + lostMsg = lostMsg + ",批次号"; + } + if ("是".equals(checkUdi.getScbssfbhscrq()) && StrUtil.isEmpty(udiEntity.getProduceDate())) { + checkSuccess = false; + lostMsg = lostMsg + ",生产日期"; + } + + if ("是".equals(checkUdi.getScbssfbhsxrq()) && StrUtil.isEmpty(udiEntity.getExpireDate())) { + checkSuccess = false; + lostMsg = lostMsg + ",失效日期"; + } + if (checkUdi.getAllowNoSerial() != null && !checkUdi.getAllowNoSerial() && StrUtil.isEmpty(udiEntity.getSerialNo()) + ) { + checkSuccess = false; + lostMsg = lostMsg + ",序列号"; + } + if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && udiEntity.getSerialNo().length() > 20) { + return ResultVOUtils.error(504, "序列号超出20位!"); + } + if (StrUtil.isNotEmpty(udiEntity.getBatchNo()) && udiEntity.getBatchNo().length() > 20) { + return ResultVOUtils.error(504, "批次号超出20位!"); + } + if (StrUtil.isEmpty(udiEntity.getSerialNo()) && StrUtil.isEmpty(udiEntity.getBatchNo())) { + checkSuccess = false; + } + if (checkSuccess) { + if (code.endsWith("\u001D")) { + code = code.substring(0, code.length() - "\u001D".length()); + } + udiEntity.setCode(code); + AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); + return ResultVOUtils.success(addEnterCodeResponse); + } else { + if (newCode.startsWith("21") || (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && newCode.contains("21" + udiEntity.getSerialNo()))) { + if (StrUtil.isEmpty(lostMsg)) { + lostMsg = ","; + } + BaseResponse baseResponse = ResultVOUtils.error(503, "条码完整性错误,缺少" + lostMsg.substring(1) + "是否继续添加?"); + udiEntity.setCode(code); + AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); + baseResponse.setData(addEnterCodeResponse); + return baseResponse; + } + } + BaseResponse baseResponse = ResultVOUtils.error(502, "校验未完成,缺少" + lostMsg.substring(1)); + udiEntity.setCode(code); + AddEnterCodeResponse addEnterCodeResponse = setAddEnterCodeResponse(udiEntity, checkUdi); + baseResponse.setData(addEnterCodeResponse); + return baseResponse; + } + + public AddEnterCodeResponse setAddEnterCodeResponse(UdiEntity udiEntity, UdiRelevanceResponse checkUdi) { + AddEnterCodeResponse addEnterCodeResponse = new AddEnterCodeResponse(); + BeanUtils.copyProperties(udiEntity, addEnterCodeResponse); + addEnterCodeResponse.setBzgg(checkUdi.getBzgg()); + addEnterCodeResponse.setCpmctymc(checkUdi.getCpmctymc()); + addEnterCodeResponse.setPrepnSpec(checkUdi.getPrepnSpec()); + addEnterCodeResponse.setPrepnUnit(checkUdi.getPrepnUnit()); + addEnterCodeResponse.setPackUnit(checkUdi.getPackUnit()); + addEnterCodeResponse.setGgxh(checkUdi.getGgxh()); + return addEnterCodeResponse; + } }