|  |  |  | @ -48,6 +48,7 @@ import com.glxp.api.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.udi.FilterUdiUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.udi.UdiCalCountUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.vo.basic.InvProductNewVo; | 
			
		
	
		
			
				
					|  |  |  |  | import groovy.util.logging.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
	
		
			
				
					|  |  |  | @ -57,8 +58,13 @@ import org.springframework.web.bind.annotation.*; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.concurrent.CompletableFuture; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.concurrent.ExecutorService; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.concurrent.Executors; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @lombok.extern.slf4j.Slf4j | 
			
		
	
		
			
				
					|  |  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  |  | @RestController | 
			
		
	
		
			
				
					|  |  |  |  | public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -407,6 +413,9 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     AddCoodeService addCoodeService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @RepeatSubmit() | 
			
		
	
		
			
				
					|  |  |  |  |     @AuthRuleAnnotation("") | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("warehouse/inout/batchAddCode") | 
			
		
	
	
		
			
				
					|  |  |  | @ -417,10 +426,27 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |         if (bindingResult.hasErrors()) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin authAdmin = getUser(); | 
			
		
	
		
			
				
					|  |  |  |  |         AddCodeResult addCodeResult = new AddCodeResult(); | 
			
		
	
		
			
				
					|  |  |  |  |         List<String> codeList = addOrderCodeRequest.getCodeList(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isEmpty(codeList)) | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "追溯码不能为空"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 获取第一个码判断类型,如果是药品类型则使用批量处理方法
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (!codeList.isEmpty()) { | 
			
		
	
		
			
				
					|  |  |  |  |             String firstCode = codeList.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |             if (firstCode.endsWith("\u001D")) { | 
			
		
	
		
			
				
					|  |  |  |  |                 firstCode = firstCode.replace("\u001D", ""); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             UdiEntity firstUdiEntity = FilterUdiUtils.getUdi(firstCode); | 
			
		
	
		
			
				
					|  |  |  |  |             if (firstUdiEntity != null && IntUtil.value(firstUdiEntity.getProductType()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                 // 药品类型,使用批量处理方法
 | 
			
		
	
		
			
				
					|  |  |  |  |                 return addCoodeService.batchProcessDrugCodes(addOrderCodeRequest, authAdmin); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 原有处理逻辑,处理非药品或空列表情况
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<VailCodeResultResponse> vailCodeResultResponses = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         Integer groupNumber = getMaxGroupNumber() == null ? 1 : getMaxGroupNumber() + 1; | 
			
		
	
		
			
				
					|  |  |  |  |         for (String code : codeList) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -451,8 +477,6 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |             if (StrUtil.isNotEmpty(addOrderRequest.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 udiEntity.setSerialNo(addOrderRequest.getSerialNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             AuthAdmin authAdmin = getUser(); | 
			
		
	
		
			
				
					|  |  |  |  |             addOrderRequest.setInvCode(authAdmin.getLocInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (IntUtil.value(addOrderCodeRequest.getInoutType()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                 addOrderRequest.setAction(ConstantType.SPLIT_RETURN); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1232,15 +1256,22 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     //    @Transactional(rollbackFor = Exception.class)
 | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse addDrugOrder(AddOrderRequest addOrderRequest, UdiEntity udiEntity, String code, Integer groupNumber) { | 
			
		
	
		
			
				
					|  |  |  |  |         long startTime = System.currentTimeMillis(); | 
			
		
	
		
			
				
					|  |  |  |  |         AddCodeResult addCodeResult = new AddCodeResult(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(addOrderRequest.getInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); | 
			
		
	
		
			
				
					|  |  |  |  |         // 检查码是否空
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (udiEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "无效条码"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //批次号校验
 | 
			
		
	
		
			
				
					|  |  |  |  |         //判断此产品是否开启允许无批次号
 | 
			
		
	
		
			
				
					|  |  |  |  |         UdiProductEntity udiInfoEntity = udiProductService.findByNameCode(udiEntity.getUdi()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (udiInfoEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |         // 1. 批量查询业务类型和药品信息,减少数据库查询次数
 | 
			
		
	
		
			
				
					|  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (bussinessTypeEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "业务类型不存在"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (udiRelevanceResponse == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "药品字典不存在此产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -1248,7 +1279,7 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "当前为无码类型产品,无需扫码!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 2. 将批次号查询移至此处统一处理
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (StrUtil.isEmpty(udiEntity.getBatchNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |             IoCodeLostEntity codeLostEntity = codeLostService.findByCode(addOrderRequest.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (codeLostEntity != null) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -1257,27 +1288,34 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |                 udiEntity.setExpireDate(codeLostEntity.getExpireDate()); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         String orderId = addOrderRequest.getBillNo(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //过期提醒:
 | 
			
		
	
		
			
				
					|  |  |  |  |         BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(addOrderRequest.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |         // 3. 合并校验流程,减少方法调用
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 过期校验
 | 
			
		
	
		
			
				
					|  |  |  |  |         int checkExpire = IntUtil.value(bussinessTypeEntity.getCheckExpire()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (checkExpire > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             BaseResponse response = checkExpireDate(checkExpire, udiEntity, addOrderRequest); | 
			
		
	
		
			
				
					|  |  |  |  |             if (response.getCode() != 20000) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return response; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //判断层级标识是否正确
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 层级标识校验
 | 
			
		
	
		
			
				
					|  |  |  |  |         boolean packLevelValid; | 
			
		
	
		
			
				
					|  |  |  |  |         if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (!isPackLevelValid(udiRelevanceResponse.getUseMaxLevel(), IntUtil.value(udiRelevanceResponse.getPackLevel()), udiRelevanceResponse.getUseLevel())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(500, "当前产品不支持采集该包装层级追溯码!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             packLevelValid = isPackLevelValid(udiRelevanceResponse.getUseMaxLevel(), | 
			
		
	
		
			
				
					|  |  |  |  |                     IntUtil.value(udiRelevanceResponse.getPackLevel()), | 
			
		
	
		
			
				
					|  |  |  |  |                     udiRelevanceResponse.getUseLevel()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             if (!isPackLevelValid(udiRelevanceResponse.getDistributeMaxLevel(), IntUtil.value(udiRelevanceResponse.getPackLevel()), udiRelevanceResponse.getDistributeLevel())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(500, "当前产品不支持采集该包装层级追溯码!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             packLevelValid = isPackLevelValid(udiRelevanceResponse.getDistributeMaxLevel(), | 
			
		
	
		
			
				
					|  |  |  |  |                     IntUtil.value(udiRelevanceResponse.getPackLevel()), | 
			
		
	
		
			
				
					|  |  |  |  |                     udiRelevanceResponse.getDistributeLevel()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (!packLevelValid) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(500, "当前产品不支持采集该包装层级追溯码!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 近效期提醒
 | 
			
		
	
		
			
				
					|  |  |  |  |         BaseResponse checkResponse = checkIsExpired(udiRelevanceResponse, udiEntity, addOrderRequest, bussinessTypeEntity); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1285,35 +1323,39 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |             return checkResponse; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //------工位上货相关-----校验工位存量是否存在----
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 工位上货相关校验
 | 
			
		
	
		
			
				
					|  |  |  |  |         BaseResponse handleSplitOutAndSplitReturnResponse = handleSplitOutAndSplitReturn(code, udiEntity, bussinessTypeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         if (handleSplitOutAndSplitReturnResponse.getCode() != 20000) { | 
			
		
	
		
			
				
					|  |  |  |  |             return handleSplitOutAndSplitReturnResponse; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (addOrderRequest.getFromCorp() == null || StrUtil.isNotEmpty(addOrderRequest.getSickerAdNum())) { | 
			
		
	
		
			
				
					|  |  |  |  |             String fromCorp = ioAddInoutService.updateCorp(bussinessTypeEntity, addOrderRequest.getFromCorp(), addOrderRequest.getSickerAdNum()); | 
			
		
	
		
			
				
					|  |  |  |  |             addOrderRequest.setFromCorp(fromCorp); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //先生成扫码单据
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 4. 优化订单处理流程
 | 
			
		
	
		
			
				
					|  |  |  |  |         InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(addOrderRequest.getInvCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         IoOrderEntity orderEntity = orderService.findByBillNo(orderId); | 
			
		
	
		
			
				
					|  |  |  |  |         String inBatch = ""; | 
			
		
	
		
			
				
					|  |  |  |  |         if (StringUtils.isBlank(orderId) || orderEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd")); | 
			
		
	
		
			
				
					|  |  |  |  |             orderId = orderNo; | 
			
		
	
		
			
				
					|  |  |  |  |             inBatch = orderId.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             inBatch = orderId.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         inBatch = orderId.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length()); | 
			
		
	
		
			
				
					|  |  |  |  |         // 5. 提前获取码信息,减少重复查询
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCodeTempEntity> codeEnttitys = codeTempService.findByOrderId(orderId); | 
			
		
	
		
			
				
					|  |  |  |  |         IoCodeTempEntity exitLocalEntity = null; | 
			
		
	
		
			
				
					|  |  |  |  |         IoCodeTempEntity genDetaiEntity = new IoCodeTempEntity(); | 
			
		
	
		
			
				
					|  |  |  |  |         List<UdiRelevanceResponse> udiRelevanceResponses = null; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (codeEnttitys.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |         // 6. 优化已存在码的处理逻辑
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (!codeEnttitys.isEmpty()) { | 
			
		
	
		
			
				
					|  |  |  |  |             exitLocalEntity = isExitLocal(code, codeEnttitys); | 
			
		
	
		
			
				
					|  |  |  |  |             if (exitLocalEntity != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 // 处理已存在码的情况
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (StrUtil.isEmpty(exitLocalEntity.getSupId()) || exitLocalEntity.getRelId() == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "当前药品追溯码已存在,且存在异常未处理!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
	
		
			
				
					|  |  |  | @ -1322,95 +1364,40 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "重复扫码!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(exitLocalEntity.getNameCode(), null); | 
			
		
	
		
			
				
					|  |  |  |  |                 // 获取udiRelevanceResponses数据,共用前面查询的udiRelevanceResponse
 | 
			
		
	
		
			
				
					|  |  |  |  |                 List<UdiRelevanceResponse> udiRelevanceResponses = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |                 udiRelevanceResponses.add(udiRelevanceResponse); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 BeanUtils.copyProperties(exitLocalEntity, genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 genDetaiEntity.setCount(1); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 // 处理数量计算
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getUseActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setCount(exitLocalEntity.getMyCount() + 1); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getUseActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                     genDetaiEntity.setReCount(udiCalCountUtil.getCirActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setCount(exitLocalEntity.getMyCount() + 1); | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setReCount(exitLocalEntity.getMyReCount() * udiCalCountUtil.getCirActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //匹配biz
 | 
			
		
	
		
			
				
					|  |  |  |  |                 // 匹配biz并缓存结果
 | 
			
		
	
		
			
				
					|  |  |  |  |                 IoOrderDetailCodeEntity byRelId = ioOrderDetailCodeService.findByRelNameCode(addOrderRequest.getBillNo(), udiEntity.getUdi(), udiEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (byRelId != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     exitLocalEntity.setBizId(byRelId.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //校验库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse invRes = null; | 
			
		
	
		
			
				
					|  |  |  |  |                 if (IntUtil.value(bussinessTypeEntity.getUseDyCount()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.isScanPreIn() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 2)) {    //校验预验收库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkPreInInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.isAdvancePreIn() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 3)) {  //校验寄售库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkPreInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.isVailInv() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 1)) { | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.isScanPreIn()) {    //校验预验收库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkPreInInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else if (bussinessTypeEntity.isAdvancePreIn()) {  //校验寄售库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkPreInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         invRes = checkInvService.checkInv(bussinessTypeEntity, genDetaiEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 // 优化库存校验流程
 | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse invRes = checkInventory(bussinessTypeEntity, udiRelevanceResponse, genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (invRes != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return invRes; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (bussinessTypeEntity.getCheckWebNew() == 1 && bussinessTypeEntity.isCheckEnable()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     String errMsg = ioCheckInoutService.checkCode(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (errMsg != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                         return ResultVOUtils.error(500, errMsg); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else | 
			
		
	
		
			
				
					|  |  |  |  |                         codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (bussinessTypeEntity.getCheckWebNew() == 2 && bussinessTypeEntity.isCheckEnable()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     String errMsg = ioCheckInoutService.checkNoPiCode(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (errMsg != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                         return ResultVOUtils.error(500, errMsg); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else | 
			
		
	
		
			
				
					|  |  |  |  |                         codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     boolean update = true; | 
			
		
	
		
			
				
					|  |  |  |  |                     String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo"); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (IntUtil.value(priceFifo) > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { | 
			
		
	
		
			
				
					|  |  |  |  |                             //1.获取当前批次已出库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                             Integer outCount = invProductServiceNew.selectCountByInBatch(exitLocalEntity.getRelId() + "", exitLocalEntity.getBatchNo(), bussinessTypeEntity, exitLocalEntity.getInBatchNo(), exitLocalEntity.getInvCode(), ConstantType.TYPE_OUT); | 
			
		
	
		
			
				
					|  |  |  |  |                             //2.获取当前批次入库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                             Integer inCount = invProductServiceNew.selectCountByInBatch(exitLocalEntity.getRelId() + "", exitLocalEntity.getBatchNo(), bussinessTypeEntity, exitLocalEntity.getInBatchNo(), exitLocalEntity.getInvCode(), ConstantType.TYPE_PUT); | 
			
		
	
		
			
				
					|  |  |  |  |                             if ((IntUtil.value(inCount) - IntUtil.value(outCount) - IntUtil.value(exitLocalEntity.getReCount())) < 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 InvProductNewVo nextInvProduct = invProductServiceNew.selectNextInBatch(bussinessTypeEntity, exitLocalEntity.getRelId() + "", exitLocalEntity.getBatchNo(), exitLocalEntity.getInvCode(), ConstantType.TYPE_PUT, exitLocalEntity.getInBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                                 if (nextInvProduct != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                                     genDetaiEntity.setPrice(nextInvProduct.getPrice()); | 
			
		
	
		
			
				
					|  |  |  |  |                                     genDetaiEntity.setInBatchNo(nextInvProduct.getInBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                                     codeTempService.insert(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                     update = false; | 
			
		
	
		
			
				
					|  |  |  |  |                                 } | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (update) { | 
			
		
	
		
			
				
					|  |  |  |  |                         codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 // 优化校验和更新流程
 | 
			
		
	
		
			
				
					|  |  |  |  |                 boolean updated = handleCodeCheckAndUpdate(bussinessTypeEntity, genDetaiEntity, exitLocalEntity, inBatch, codeEnttitys); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (!updated) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "更新码信息失败"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -1494,11 +1481,11 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (StrUtil.isNotEmpty(addOrderRequest.getSelectSupId())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 unitFk = addOrderRequest.getSelectSupId(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             //产品是否禁用
 | 
			
		
	
		
			
				
					|  |  |  |  |             udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(codeEnttity.getNameCode(), false); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             // 获取产品列表 - 使用前面查询的单个产品
 | 
			
		
	
		
			
				
					|  |  |  |  |             List<UdiRelevanceResponse> productList = Collections.singletonList(udiRelevanceResponse); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (udiRelevanceResponses.size() >= 1) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (productList.size() >= 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (udiRelevanceResponse == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "该产品信息未维护!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (!udiRelevanceResponse.getUseDy() && udiRelevanceResponse.getDiType() == ConstantStatus.DITYPE_SYDY) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -1517,18 +1504,19 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, bussinessTypeEntity.getName() + "单只允许录入非集采产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 //计算实际数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                 // 直接使用传入的udiRelevanceResponse计算数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                 if (bussinessTypeEntity.isUse()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getUseActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getUseActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getCirActCount(udiRelevanceResponses.get(0))); | 
			
		
	
		
			
				
					|  |  |  |  |                     codeEnttity.setReCount(codeEnttity.getMyReCount() + udiCalCountUtil.getCirActCount(udiRelevanceResponse)); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (udiRelevanceResponses.size() == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (unitFk == null) | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "耗材字典不存在此产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 else | 
			
		
	
		
			
				
					|  |  |  |  |                     return ResultVOUtils.error(500, "当前供应商不存在此配送产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (!(bussinessTypeEntity.getAction().equals(ConstantType.SPLIT_RETURN) || bussinessTypeEntity.getAction().equals(ConstantType.SPLIT_OUT))) { | 
			
		
	
		
			
				
					|  |  |  |  |                 //校验供应商是否配送此产品
 | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse corpResponse = checkCorp(codeEnttity, bussinessTypeEntity, unitFk); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1835,12 +1823,6 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public Integer getMaxGroupNumber() { | 
			
		
	
		
			
				
					|  |  |  |  |         Integer groupNumber = codeTempService.selectMaxGroupNumber(); | 
			
		
	
		
			
				
					|  |  |  |  |         return groupNumber; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void updateRelCode(BasicBussinessTypeEntity bussinessTypeEntity, String code) { | 
			
		
	
		
			
				
					|  |  |  |  |         if (!(bussinessTypeEntity.getAction().equals(ConstantType.SPLIT_OUT) || bussinessTypeEntity.getAction().equals(ConstantType.SPLIT_RETURN))) | 
			
		
	
		
			
				
					|  |  |  |  |             relCodeBatchService.threadUpdateIoCodeTempEntity(code); | 
			
		
	
	
		
			
				
					|  |  |  | @ -3106,5 +3088,111 @@ public class IoCodeTempController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 校验库存情况 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param bussinessTypeEntity  业务类型 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param udiRelevanceResponse UDI关联响应 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param codeEntity           码实体 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 校验结果 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private BaseResponse checkInventory(BasicBussinessTypeEntity bussinessTypeEntity, UdiRelevanceResponse udiRelevanceResponse, IoCodeTempEntity codeEntity) { | 
			
		
	
		
			
				
					|  |  |  |  |         BaseResponse invRes = null; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (IntUtil.value(bussinessTypeEntity.getUseDyCount()) == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (bussinessTypeEntity.isScanPreIn() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 2)) {    //校验预验收库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkPreInInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if (bussinessTypeEntity.isAdvancePreIn() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 3)) {  //校验寄售库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkPreInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if (bussinessTypeEntity.isVailInv() && checkDiAttribute(bussinessTypeEntity, udiRelevanceResponse, 1)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             if (bussinessTypeEntity.isScanPreIn()) {    //校验预验收库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkPreInInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (bussinessTypeEntity.isAdvancePreIn()) {  //校验寄售库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkPreInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 invRes = checkInvService.checkInv(bussinessTypeEntity, codeEntity, false); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return invRes; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public Integer getMaxGroupNumber() { | 
			
		
	
		
			
				
					|  |  |  |  |         Integer groupNumber = codeTempService.selectMaxGroupNumber(); | 
			
		
	
		
			
				
					|  |  |  |  |         return groupNumber; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 处理码校验和更新 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param bussinessTypeEntity 业务类型 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param genDetaiEntity      生成的明细实体 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param exitLocalEntity     已存在的实体 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param inBatch             批次号 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param codeEnttitys        码实体列表 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 是否处理成功 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private boolean handleCodeCheckAndUpdate(BasicBussinessTypeEntity bussinessTypeEntity, | 
			
		
	
		
			
				
					|  |  |  |  |                                              IoCodeTempEntity genDetaiEntity, | 
			
		
	
		
			
				
					|  |  |  |  |                                              IoCodeTempEntity exitLocalEntity, | 
			
		
	
		
			
				
					|  |  |  |  |                                              String inBatch, | 
			
		
	
		
			
				
					|  |  |  |  |                                              List<IoCodeTempEntity> codeEnttitys) { | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             if (bussinessTypeEntity.getCheckWebNew() == 1 && bussinessTypeEntity.isCheckEnable()) { | 
			
		
	
		
			
				
					|  |  |  |  |                 String errMsg = ioCheckInoutService.checkCode(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (errMsg != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return false; | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (bussinessTypeEntity.getCheckWebNew() == 2 && bussinessTypeEntity.isCheckEnable()) { | 
			
		
	
		
			
				
					|  |  |  |  |                 String errMsg = ioCheckInoutService.checkNoPiCode(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (errMsg != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return false; | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 boolean update = true; | 
			
		
	
		
			
				
					|  |  |  |  |                 String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo"); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (IntUtil.value(priceFifo) > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { | 
			
		
	
		
			
				
					|  |  |  |  |                         //1.获取当前批次已出库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                         Integer outCount = invProductServiceNew.selectCountByInBatch(exitLocalEntity.getRelId() + "", | 
			
		
	
		
			
				
					|  |  |  |  |                                 exitLocalEntity.getBatchNo(), bussinessTypeEntity, exitLocalEntity.getInBatchNo(), | 
			
		
	
		
			
				
					|  |  |  |  |                                 exitLocalEntity.getInvCode(), ConstantType.TYPE_OUT); | 
			
		
	
		
			
				
					|  |  |  |  |                         //2.获取当前批次入库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |                         Integer inCount = invProductServiceNew.selectCountByInBatch(exitLocalEntity.getRelId() + "", | 
			
		
	
		
			
				
					|  |  |  |  |                                 exitLocalEntity.getBatchNo(), bussinessTypeEntity, exitLocalEntity.getInBatchNo(), | 
			
		
	
		
			
				
					|  |  |  |  |                                 exitLocalEntity.getInvCode(), ConstantType.TYPE_PUT); | 
			
		
	
		
			
				
					|  |  |  |  |                         if ((IntUtil.value(inCount) - IntUtil.value(outCount) - IntUtil.value(exitLocalEntity.getReCount())) < 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                             InvProductNewVo nextInvProduct = invProductServiceNew.selectNextInBatch(bussinessTypeEntity, | 
			
		
	
		
			
				
					|  |  |  |  |                                     exitLocalEntity.getRelId() + "", exitLocalEntity.getBatchNo(), exitLocalEntity.getInvCode(), | 
			
		
	
		
			
				
					|  |  |  |  |                                     ConstantType.TYPE_PUT, exitLocalEntity.getInBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                             if (nextInvProduct != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 genDetaiEntity.setPrice(nextInvProduct.getPrice()); | 
			
		
	
		
			
				
					|  |  |  |  |                                 genDetaiEntity.setInBatchNo(nextInvProduct.getInBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                                 codeTempService.insert(genDetaiEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                 update = false; | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (update) { | 
			
		
	
		
			
				
					|  |  |  |  |                     codeTempService.updateById(exitLocalEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             return true; | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |             log.error("处理码校验和更新异常:{}", e.getMessage(), e); | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |