|  |  |  | @ -8,27 +8,34 @@ import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.inout.IoSplitCodeMapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeDiEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.BasicSkPrescribeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.UdiRelevanceEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrder; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderBiz; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderCodeAuto; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectOrderCodeMan; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.IoSplitCodeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.IoSplitFifoCodeEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.IoSplitFifoInv; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.inout.IoSplitCodeRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.BasicSkPrescribeDiService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.BasicSkPrescribeService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.basic.UdiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.IoCollectOrderBizService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.IoCollectOrderCodeAutoService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.IoCollectOrderCodeManService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.IoCollectOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.IntUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Collections; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Date; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  |  | public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCodeEntity> { | 
			
		
	
	
		
			
				
					|  |  |  | @ -263,6 +270,223 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void splitRemove(IoCollectOrderBiz collectOrderBiz, IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         //1.按照先进先出原则,查询拆零表,获取拆零表ID
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), collectOrder.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //2.如果拆零表为空,则自动从预出库队列中获拉取数据
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isEmpty(ioSplitCodeEntities)) { | 
			
		
	
		
			
				
					|  |  |  |  |             addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), IntUtil.value(collectOrderBiz.getCount())); | 
			
		
	
		
			
				
					|  |  |  |  |             ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), collectOrder.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //3.如果拆零表不为空,则开始扣除数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         int count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         int unCount = 0;  //剩余未扣减数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         unCount = IntUtil.value(collectOrderBiz.getUnTagCount()); | 
			
		
	
		
			
				
					|  |  |  |  |         for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |             count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount; | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder() | 
			
		
	
		
			
				
					|  |  |  |  |                     .codeIdFk(ioSplitCodeEntity.getId()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .udiCode(ioSplitCodeEntity.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .orderIdFk(collectOrder.getBillNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .batchNo(ioSplitCodeEntity.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .productDate(ioSplitCodeEntity.getProduceDate()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .expireDate(ioSplitCodeEntity.getExpireDate()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .serialNo(ioSplitCodeEntity.getSerialNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .relId(collectOrderBiz.getRelId()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .bizIdFk(collectOrderBiz.getId()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .fifoSplit(ioSplitCodeEntity.getFifoSplit()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .createTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .updateTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                     .build()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (count > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 ioSplitCodeEntity.setRemainCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                 unCount = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                 splitCodeMapper.updateById(ioSplitCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                 break; | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                 unCount = 0; | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                 unCount = -count; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             splitCodeMapper.updateById(ioSplitCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (unCount > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             //4.拆零表数量不足,则从预出库队列中获取数据
 | 
			
		
	
		
			
				
					|  |  |  |  |             Integer fifoCount = addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), unCount); | 
			
		
	
		
			
				
					|  |  |  |  |             if (fifoCount == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 //预出库队列数量不足
 | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setTagStatus(2); | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new JsonException(500, "提交失败,工位库存数量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 //再次执行赋码
 | 
			
		
	
		
			
				
					|  |  |  |  |                 ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), collectOrder.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |                     count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount; | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder() | 
			
		
	
		
			
				
					|  |  |  |  |                             .codeIdFk(ioSplitCodeEntity.getId()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .udiCode(ioSplitCodeEntity.getCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .orderIdFk(collectOrder.getBillNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .batchNo(ioSplitCodeEntity.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .productDate(ioSplitCodeEntity.getProduceDate()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .expireDate(ioSplitCodeEntity.getExpireDate()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .serialNo(ioSplitCodeEntity.getSerialNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .relId(collectOrderBiz.getRelId()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .bizIdFk(collectOrderBiz.getId()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .fifoSplit(ioSplitCodeEntity.getFifoSplit()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .createTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .updateTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .build()); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (count > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         ioSplitCodeEntity.setRemainCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                         break; | 
			
		
	
		
			
				
					|  |  |  |  |                     } else if (count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                         ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         ioSplitCodeEntity.setRemainCount(0); | 
			
		
	
		
			
				
					|  |  |  |  |                         unCount = -count; | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 if (unCount > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setTagStatus(2); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!"); | 
			
		
	
		
			
				
					|  |  |  |  |                     throw new JsonException(500, "提交失败,工位库存数量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setTagStatus(3); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setTagMsg("赋码完成!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderBiz.setTagStatus(3); | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderBiz.setTagMsg("赋码完成!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         collectOrderBiz.setUnTagCount(unCount); | 
			
		
	
		
			
				
					|  |  |  |  |         collectOrderBizService.updateById(collectOrderBiz); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     UdiRelevanceService udiRelevanceService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectOrderCodeManService collectOrderCodeManService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |  |     public void finishAutoTagCode(IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrderBiz> collectOrderBizs = collectOrderBizService.listByBillNo(collectOrder.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //如果手动扫码判断该码是否在队列里,如果已在队列,则队列里剔除
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrderCodeMan> collectOrderCodeMEN = collectOrderCodeManService.listByBillNo(collectOrder.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isNotEmpty(collectOrderCodeMEN)) { | 
			
		
	
		
			
				
					|  |  |  |  |             for (IoCollectOrderCodeMan collectOrderCodeMan : collectOrderCodeMEN) { | 
			
		
	
		
			
				
					|  |  |  |  |                 IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService.findByCode(collectOrderCodeMan.getUdiCode(), collectOrder.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (IntUtil.value(splitFifoCodeEntity.getScanCount()) - IntUtil.value(collectOrderCodeMan.getScanCount()) <= 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     splitFifoCodeService.removeById(splitFifoCodeEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     IoSplitFifoInv splitFifoInv = splitFifoInvService.findByFifoCode(splitFifoCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (splitFifoInv != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setOutCount(IntUtil.value(splitFifoInv.getOutCount()) + IntUtil.value(splitFifoCodeEntity.getTotalCount())); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setLockCount(IntUtil.value(splitFifoInv.getLockCount()) - IntUtil.value(splitFifoCodeEntity.getTotalCount())); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setReCount(IntUtil.value(splitFifoInv.getInCount() - IntUtil.value(splitFifoInv.getOutCount()))); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setAvailableCount(IntUtil.value(splitFifoInv.getInCount() - IntUtil.value(splitFifoInv.getLockCount()) - IntUtil.value(splitFifoInv.getOutCount()))); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(collectOrderCodeMan.getRelId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     int removeCount = IntUtil.value(collectOrderCodeMan.getScanCount()) * udiRelevanceEntity.getUseLeverCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                     splitFifoCodeService.updateById(IoSplitFifoCodeEntity.builder() | 
			
		
	
		
			
				
					|  |  |  |  |                             .id(splitFifoCodeEntity.getId()) | 
			
		
	
		
			
				
					|  |  |  |  |                             .scanCount(IntUtil.value(splitFifoCodeEntity.getScanCount()) - IntUtil.value(collectOrderCodeMan.getScanCount())) | 
			
		
	
		
			
				
					|  |  |  |  |                             .totalCount(IntUtil.value(splitFifoCodeEntity.getTotalCount()) - removeCount) | 
			
		
	
		
			
				
					|  |  |  |  |                             .build()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     IoSplitFifoInv splitFifoInv = splitFifoInvService.findByFifoCode(splitFifoCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (splitFifoInv != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setOutCount(IntUtil.value(splitFifoInv.getOutCount()) + removeCount); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setLockCount(IntUtil.value(splitFifoInv.getLockCount()) - removeCount); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setReCount(IntUtil.value(splitFifoInv.getInCount() - IntUtil.value(splitFifoInv.getOutCount()))); | 
			
		
	
		
			
				
					|  |  |  |  |                         splitFifoInv.setAvailableCount(IntUtil.value(splitFifoInv.getInCount() - IntUtil.value(splitFifoInv.getLockCount()) - IntUtil.value(splitFifoInv.getOutCount()))); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         List<Integer> removeIds = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         for (IoCollectOrderBiz collectOrderBiz : collectOrderBizs) { | 
			
		
	
		
			
				
					|  |  |  |  |             int unTagCount = collectOrderBiz.getCount() - IntUtil.value(collectOrderBiz.getScanActCount()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (unTagCount > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setUnTagCount(unTagCount); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setTagStatus(3); | 
			
		
	
		
			
				
					|  |  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectById(collectOrderBiz.getRelId()); | 
			
		
	
		
			
				
					|  |  |  |  |             int quotient = collectOrderBiz.getUnTagCount() / IntUtil.value(udiRelevanceEntity.getUseLeverCount()); | 
			
		
	
		
			
				
					|  |  |  |  |             int remainder = collectOrderBiz.getUnTagCount() % IntUtil.value(udiRelevanceEntity.getUseLeverCount()); | 
			
		
	
		
			
				
					|  |  |  |  |             //2.如果整盒,从工位队列扣除
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (quotient > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 List<IoSplitFifoCodeEntity> ioSplitFifoCodeEntities = splitFifoCodeService.findByRelId(collectOrder.getWorkPlaceCode(), collectOrder.getBusType(), collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (ioSplitFifoCodeEntities.size() < quotient) { | 
			
		
	
		
			
				
					|  |  |  |  |                     throw new JsonException(500, "提交失败,工位库存数量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 for (int i = 0; i < quotient; i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                     IoSplitFifoCodeEntity splitFifoCodeEntity = ioSplitFifoCodeEntities.get(i); | 
			
		
	
		
			
				
					|  |  |  |  |                     removeIds.add(splitFifoCodeEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderBiz.setUnTagCount(IntUtil.value(collectOrderBiz.getUnTagCount()) - IntUtil.value(udiRelevanceEntity.getUseLeverCount())); | 
			
		
	
		
			
				
					|  |  |  |  |                     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()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             //.如果拆零,拆零表扣除
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (remainder > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 splitRemove(collectOrderBiz, collectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 单据预赋码 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param collectOrder | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     public void preAutoTagCode(IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrderBiz> collectOrderBizs = collectOrderBizService.listByBillNo(collectOrder.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |         for (IoCollectOrderBiz collectOrderBiz : collectOrderBizs) { | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoSplitFifoCodeEntity> splitFifoCodeEntities = | 
			
		
	
		
			
				
					|  |  |  |  |                     splitFifoCodeService.findByRelId(collectOrder.getWorkPlaceCode(), collectOrder.getBusType(), | 
			
		
	
		
			
				
					|  |  |  |  |                             collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             int total = splitFifoCodeEntities.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                     .mapToInt(IoSplitFifoCodeEntity::getTotalCount) | 
			
		
	
		
			
				
					|  |  |  |  |                     .sum(); | 
			
		
	
		
			
				
					|  |  |  |  |             //todo 拆零表里取数据
 | 
			
		
	
		
			
				
					|  |  |  |  |             if (total > IntUtil.value(collectOrderBiz.getCount())) { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setAutoTagStatus(2); | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (total > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setAutoTagStatus(3); | 
			
		
	
		
			
				
					|  |  |  |  |             } else | 
			
		
	
		
			
				
					|  |  |  |  |                 collectOrderBiz.setAutoTagStatus(1); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 拆零单据撤回,则将拆零表剩余数量加回预出库队列 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  |  | 
 |