|  |  | @ -17,6 +17,7 @@ import com.glxp.api.entity.inout.IoSplitFifoInv; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.exception.JsonException; |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; |  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.collect.AddInvDesDetaiRequest; |  |  |  | import com.glxp.api.req.collect.AddInvDesDetaiRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.collect.CollectOrderRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inout.IoSplitCodeRequest; |  |  |  | import com.glxp.api.req.inout.IoSplitCodeRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
	
		
		
			
				
					|  |  | @ -147,6 +148,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //再次执行赋码
 |  |  |  |                 //再次执行赋码
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode); |  |  |  |                 ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) { |  |  |  |                 for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (IntUtil.value(ioSplitCodeEntity.getRemainCount()) > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount; |  |  |  |                         count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |                         collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder() |  |  |  |                         collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder() | 
			
		
	
		
		
			
				
					
					|  |  |  |                                 .codeIdFk(ioSplitCodeEntity.getId()) |  |  |  |                                 .codeIdFk(ioSplitCodeEntity.getId()) | 
			
		
	
	
		
		
			
				
					|  |  | @ -164,14 +166,18 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
		
			
				
					
					|  |  |  |                                 .build()); |  |  |  |                                 .build()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                         if (count > 0) { |  |  |  |                         if (count > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                             ioSplitCodeEntity.setRemainCount(count); |  |  |  |                             ioSplitCodeEntity.setRemainCount(count); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             splitCodeMapper.updateById(ioSplitCodeEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                             break; |  |  |  |                             break; | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } else if (count == 0) { |  |  |  |                         } else if (count == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                             ioSplitCodeEntity.setRemainCount(0); |  |  |  |                             ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             splitCodeMapper.updateById(ioSplitCodeEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } else { |  |  |  |                         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                             ioSplitCodeEntity.setRemainCount(0); |  |  |  |                             ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             splitCodeMapper.updateById(ioSplitCodeEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                             unCount = -count; |  |  |  |                             unCount = -count; | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (unCount > 0) { |  |  |  |                 if (unCount > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     collectOrderBiz.setTagStatus(2); |  |  |  |                     collectOrderBiz.setTagStatus(2); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!"); |  |  |  |                     collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!"); | 
			
		
	
	
		
		
			
				
					|  |  | @ -368,7 +374,72 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
		
			
				
					
					|  |  |  |             ioCollectOrderBizBackups.add(ioCollectOrderBizBackup); |  |  |  |             ioCollectOrderBizBackups.add(ioCollectOrderBizBackup); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         ioCollectOrderBizBackupService.saveBatch(ioCollectOrderBizBackups); |  |  |  |         ioCollectOrderBizBackupService.saveBatch(ioCollectOrderBizBackups); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     IoCollectOrderService collectOrderService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public void confirmBizAutiTagCode(CollectOrderRequest collectOrderRequest) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCollectOrder collectOrder = collectOrderService.getById(collectOrderRequest.getBillNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(collectOrder.getWorkPlaceCode(), collectOrder.getBusType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Long putWorkPlaceCode = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (sysWorkplacePutRel != null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             putWorkPlaceCode = sysWorkplacePutRel.getWorkPlaceCode(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         IoCollectOrderBiz collectOrderBiz = collectOrderBizService.getById(collectOrderRequest.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         filterUdiRelRequest.setId(collectOrderBiz.getRelId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         filterUdiRelRequest.setPackLevel("1"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //todo  后面可以 没有搜索到层级为1的
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectOneUdi(filterUdiRelRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //去除掉已经手动扫码的数据,找出需要自动扫码的明细,执行上述的拆零或整取
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int unTagCount = collectOrderBiz.getCount() - IntUtil.value(collectOrderBiz.getScanActCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (unTagCount > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             collectOrderBiz.setUnTagCount(unTagCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int quotient = collectOrderBiz.getUnTagCount() / IntUtil.value(udiRelevanceResponse.getBhxjsl()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         int remainder = collectOrderBiz.getUnTagCount() % IntUtil.value(udiRelevanceResponse.getBhxjsl()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //2.如果整盒,从工位队列扣除   默认最后一个追溯码拆零
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (quotient > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<IoSplitFifoCodeEntity> ioSplitFifoCodeEntities = splitFifoCodeService.findByRelId(putWorkPlaceCode, collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (ioSplitFifoCodeEntities.size() < quotient) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 throw new JsonException(500, "确认失败,工位库存数量不足!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             for (int i = 0; i < quotient; i++) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 IoSplitFifoCodeEntity splitFifoCodeEntity = ioSplitFifoCodeEntities.get(i); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 collectOrderBiz.setUnTagCount(IntUtil.value(collectOrderBiz.getUnTagCount()) - IntUtil.value(udiRelevanceResponse.getBhxjsl())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .codeIdFk(splitFifoCodeEntity.getId()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .udiCode(splitFifoCodeEntity.getCode()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .orderIdFk(collectOrder.getBillNo()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .batchNo(splitFifoCodeEntity.getBatchNo()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .productDate(splitFifoCodeEntity.getProduceDate()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .expireDate(splitFifoCodeEntity.getExpireDate()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .serialNo(splitFifoCodeEntity.getSerialNo()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .relId(collectOrderBiz.getRelId()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .bizIdFk(collectOrderBiz.getId()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .fifoSplit(splitFifoCodeEntity.getFifoSplit()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .createTime(new Date()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .updateTime(new Date()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .build()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 splitFifoCodeService.removeById(splitFifoCodeEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 IoSplitFifoInv splitFifoInv = splitFifoInvService.findByFifoCode(splitFifoCodeEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (splitFifoInv != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     splitFifoInv.setOutCount(IntUtil.value(splitFifoInv.getOutCount()) + IntUtil.value(splitFifoCodeEntity.getTotalCount())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     int lockCount = IntUtil.value(splitFifoInv.getLockCount()) - IntUtil.value(splitFifoCodeEntity.getTotalCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     splitFifoInv.setLockCount(lockCount > 0 ? lockCount : 0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     splitFifoInv.setReCount(IntUtil.value(splitFifoInv.getInCount()) - IntUtil.value(splitFifoInv.getOutCount())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     splitFifoInv.setAvailableCount(IntUtil.value(splitFifoInv.getInCount()) - IntUtil.value(splitFifoInv.getLockCount()) - IntUtil.value(splitFifoInv.getOutCount())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     splitFifoInvService.updateById(splitFifoInv); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //.如果拆零,拆零表扣除
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (remainder > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             splitRemove(collectOrderBiz, collectOrder, putWorkPlaceCode); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |