|  |  |  | @ -6,8 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
			
		
	
		
			
				
					|  |  |  |  | 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.SysWorkplacePutRel; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.basic.UdiRelevanceEntity; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.inout.IoSplitCodeEntity; | 
			
		
	
	
		
			
				
					|  |  |  | @ -15,10 +14,9 @@ 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.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.thrsys.SysWorkplacePutRelService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.IntUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
	
		
			
				
					|  |  |  | @ -31,17 +29,11 @@ import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | @Service | 
			
		
	
		
			
				
					|  |  |  |  | public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCodeEntity> { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     BasicSkPrescribeDiService basicSkPrescribeDiService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoSplitCodeMapper splitCodeMapper; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoSplitFifoCodeService splitFifoCodeService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     BasicSkPrescribeService basicSkPrescribeService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectOrderService collectOrderService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectOrderBizService collectOrderBizService; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectOrderCodeAutoService collectOrderCodeAutoService; | 
			
		
	
	
		
			
				
					|  |  |  | @ -77,190 +69,6 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //    /**
 | 
			
		
	
		
			
				
					|  |  |  |  | //     * 处方自动赋码
 | 
			
		
	
		
			
				
					|  |  |  |  | //     */
 | 
			
		
	
		
			
				
					|  |  |  |  | //    public void prescribeAutoTagCode(BasicSkPrescribeEntity basicSkPrescribeEntity) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //        List<BasicSkPrescribeDiEntity> basicSkPrescribeDiEntities = basicSkPrescribeDiService.findByPrescribe(basicSkPrescribeEntity.getAdNum());
 | 
			
		
	
		
			
				
					|  |  |  |  | //        //处方赋码状态 1:未赋码,2:部分赋码,3:全部赋码
 | 
			
		
	
		
			
				
					|  |  |  |  | //        for (BasicSkPrescribeDiEntity basicSkPrescribeDiEntity : basicSkPrescribeDiEntities) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            //1.按照先进先出原则,查询拆零表,获取拆零表ID
 | 
			
		
	
		
			
				
					|  |  |  |  | //            List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(basicSkPrescribeDiEntity.getRelId(), basicSkPrescribeDiEntity.getBatchNo(), basicSkPrescribeEntity.getWorkPlaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            //2.如果拆零表为空,则自动从预出库队列中获拉取数据
 | 
			
		
	
		
			
				
					|  |  |  |  | //            if (CollUtil.isEmpty(ioSplitCodeEntities)) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                addFifoCode(basicSkPrescribeDiEntity.getRelId(), basicSkPrescribeDiEntity.getBatchNo(), IntUtil.value(basicSkPrescribeDiEntity.getMeasureCount()));
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            ioSplitCodeEntities = findSplitCodes(basicSkPrescribeDiEntity.getRelId(), basicSkPrescribeDiEntity.getBatchNo(), basicSkPrescribeEntity.getWorkPlaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            //3.如果拆零表不为空,则开始扣除数量
 | 
			
		
	
		
			
				
					|  |  |  |  | //            int count = 0;
 | 
			
		
	
		
			
				
					|  |  |  |  | //            int unCount = 0;  //剩余未扣减数量
 | 
			
		
	
		
			
				
					|  |  |  |  | //            unCount = IntUtil.value(basicSkPrescribeDiEntity.getMeasureCount());
 | 
			
		
	
		
			
				
					|  |  |  |  | //            for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                if (count > 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    ioSplitCodeEntity.setRemainCount(count);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    break;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                } else if (count == 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    ioSplitCodeEntity.setRemainCount(0);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    ioSplitCodeEntity.setRemainCount(0);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    unCount = -count;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //            if (unCount > 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                //4.拆零表数量不足,则从预出库队列中获取数据
 | 
			
		
	
		
			
				
					|  |  |  |  | //                Integer fifoCount = addFifoCode(basicSkPrescribeDiEntity.getRelId(), basicSkPrescribeDiEntity.getBatchNo(), unCount);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                if (fifoCount == 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    //预出库队列数量不足
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    basicSkPrescribeDiEntity.setTagStatus(2);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    basicSkPrescribeDiEntity.setTagMsg("预出库队列码数量不足,赋码失败!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    //再次执行赋码
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    ioSplitCodeEntities = findSplitCodes(basicSkPrescribeDiEntity.getRelId(), basicSkPrescribeDiEntity.getBatchNo(), basicSkPrescribeEntity.getWorkPlaceCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        if (count > 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            ioSplitCodeEntity.setRemainCount(count);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            break;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        } else if (count == 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            ioSplitCodeEntity.setRemainCount(0);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            ioSplitCodeEntity.setRemainCount(0);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            unCount = -count;
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    if (unCount > 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        basicSkPrescribeDiEntity.setTagStatus(2);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        basicSkPrescribeDiEntity.setTagMsg("预出库队列码数量不足,赋码失败!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        basicSkPrescribeDiEntity.setTagStatus(3);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        basicSkPrescribeDiEntity.setTagMsg("赋码完成!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            basicSkPrescribeDiService.updateById(basicSkPrescribeDiEntity);
 | 
			
		
	
		
			
				
					|  |  |  |  | //        }
 | 
			
		
	
		
			
				
					|  |  |  |  | //        basicSkPrescribeEntity.setTagStatus(checkStatus1(basicSkPrescribeDiEntities));
 | 
			
		
	
		
			
				
					|  |  |  |  | //        basicSkPrescribeService.updateById(basicSkPrescribeEntity);
 | 
			
		
	
		
			
				
					|  |  |  |  | //    }
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //    /**
 | 
			
		
	
		
			
				
					|  |  |  |  | //     * 单据自动赋码
 | 
			
		
	
		
			
				
					|  |  |  |  | //     */
 | 
			
		
	
		
			
				
					|  |  |  |  | //    public void orderAutoTagCode(IoCollectOrder collectOrder) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //        List<IoCollectOrderBiz> collectOrderBizs = collectOrderBizService.listByBillNo(collectOrder.getBillNo());
 | 
			
		
	
		
			
				
					|  |  |  |  | //        //处方赋码状态 1:未赋码,2:部分赋码,3:全部赋码
 | 
			
		
	
		
			
				
					|  |  |  |  | //        for (IoCollectOrderBiz collectOrderBiz : collectOrderBizs) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //            if (IntUtil.value(collectOrderBiz.getTagStatus()) == 3) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                continue;
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            //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("预出库队列码数量不足,赋码失败!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                } 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("预出库队列码数量不足,赋码失败!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        collectOrderBiz.setTagStatus(3);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        collectOrderBiz.setTagMsg("赋码完成!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                    }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                collectOrderBiz.setTagStatus(3);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                collectOrderBiz.setTagMsg("赋码完成!");
 | 
			
		
	
		
			
				
					|  |  |  |  | //            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //            collectOrderBiz.setUnTagCount(unCount);
 | 
			
		
	
		
			
				
					|  |  |  |  | //            collectOrderBizService.updateById(collectOrderBiz);
 | 
			
		
	
		
			
				
					|  |  |  |  | //        }
 | 
			
		
	
		
			
				
					|  |  |  |  | //        collectOrder.setSplitStatus(checkStatus(collectOrderBizs));
 | 
			
		
	
		
			
				
					|  |  |  |  | //        collectOrderService.updateById(collectOrder);
 | 
			
		
	
		
			
				
					|  |  |  |  | //    }
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void splitRemove(IoCollectOrderBiz collectOrderBiz, IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         //1.按照先进先出原则,查询拆零表,获取拆零表ID
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), collectOrder.getWorkPlaceCode()); | 
			
		
	
	
		
			
				
					|  |  |  | @ -372,13 +180,18 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |  |     public void finishAutoTagCode(IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(collectOrder.getWorkPlaceCode(), collectOrder.getBusType()); | 
			
		
	
		
			
				
					|  |  |  |  |         Long putWorkPlaceCode = null; | 
			
		
	
		
			
				
					|  |  |  |  |         if (sysWorkplacePutRel != null) | 
			
		
	
		
			
				
					|  |  |  |  |             putWorkPlaceCode = sysWorkplacePutRel.getWorkPlaceCode(); | 
			
		
	
		
			
				
					|  |  |  |  |         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()); | 
			
		
	
		
			
				
					|  |  |  |  |                 IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService.findByCode(collectOrderCodeMan.getUdiCode(), putWorkPlaceCode); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (splitFifoCodeEntity != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                     collectOrderCodeMan.setRemoveFlag(true); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (IntUtil.value(splitFifoCodeEntity.getScanCount()) - IntUtil.value(collectOrderCodeMan.getScanCount()) <= 0) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -447,7 +260,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  |                                     .serialNo(result.getSerialNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .scanCount(result.getScanCount()) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .totalCount(result.getScanCount()) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .workPlaceCode(collectOrder.getWorkPlaceCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .workPlaceCode(putWorkPlaceCode) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .status(2) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .fifoSplit(1) | 
			
		
	
		
			
				
					|  |  |  |  |                                     .createTime(new Date()).updateTime(new Date()) | 
			
		
	
	
		
			
				
					|  |  |  | @ -464,7 +277,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  |             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()); | 
			
		
	
		
			
				
					|  |  |  |  |                 List<IoSplitFifoCodeEntity> ioSplitFifoCodeEntities = splitFifoCodeService.findByRelId(putWorkPlaceCode, collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (ioSplitFifoCodeEntities.size() < quotient) { | 
			
		
	
		
			
				
					|  |  |  |  |                     return; | 
			
		
	
		
			
				
					|  |  |  |  | //                    throw new JsonException(500, "提交失败,工位库存数量不足!");
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -504,23 +317,48 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoSplitFifoInvRelService splitFifoInvRelService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public List<Long> findInvIdFk(IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoSplitFifoInvRel> ioSplitFifoInvRels = splitFifoInvRelService.findInvIdFk(collectOrder.getWorkPlaceCode(), collectOrder.getBusType()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isNotEmpty(ioSplitFifoInvRels)) { | 
			
		
	
		
			
				
					|  |  |  |  |             return ioSplitFifoInvRels.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                     .map(IoSplitFifoInvRel::getInvIdFk) | 
			
		
	
		
			
				
					|  |  |  |  |                     .collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |  |         } else | 
			
		
	
		
			
				
					|  |  |  |  |             return null; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     SysWorkplacePutRelService workplacePutRelService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 单据预赋码 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param collectOrder | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     public void preAutoTagCode(IoCollectOrder collectOrder) { | 
			
		
	
		
			
				
					|  |  |  |  |         Long putWorkPlaceCode = null; | 
			
		
	
		
			
				
					|  |  |  |  |         //获取上货工位
 | 
			
		
	
		
			
				
					|  |  |  |  |         SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(collectOrder.getWorkPlaceCode(), collectOrder.getBusType()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (sysWorkplacePutRel == null) | 
			
		
	
		
			
				
					|  |  |  |  |             putWorkPlaceCode = sysWorkplacePutRel.getCollectWorkCode(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectOrderBiz> collectOrderBizs = collectOrderBizService.listByBillNo(collectOrder.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |         for (IoCollectOrderBiz collectOrderBiz : collectOrderBizs) { | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoSplitFifoCodeEntity> splitFifoCodeEntities = | 
			
		
	
		
			
				
					|  |  |  |  |                     splitFifoCodeService.findByRelId(collectOrder.getWorkPlaceCode(), collectOrder.getBusType(), | 
			
		
	
		
			
				
					|  |  |  |  |                     splitFifoCodeService.findByRelId(putWorkPlaceCode, | 
			
		
	
		
			
				
					|  |  |  |  |                             collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |             int total = splitFifoCodeEntities.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                     .mapToInt(IoSplitFifoCodeEntity::getTotalCount) | 
			
		
	
		
			
				
					|  |  |  |  |                     .sum(); | 
			
		
	
		
			
				
					|  |  |  |  |             collectOrderBiz.setTempWorkPlaceCount(total); | 
			
		
	
		
			
				
					|  |  |  |  |             List<IoSplitCodeEntity> splitCodeEntities = splitCodeService.findSplitCodes(collectOrderBiz.getRelId() | 
			
		
	
		
			
				
					|  |  |  |  |                     , collectOrderBiz.getBatchNo(), collectOrder.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     , collectOrderBiz.getBatchNo(), sysWorkplacePutRel.getWorkPlaceCode()); | 
			
		
	
		
			
				
					|  |  |  |  |             int splitTotal = splitCodeEntities.stream() | 
			
		
	
		
			
				
					|  |  |  |  |                     .mapToInt(IoSplitCodeEntity::getRemainCount) | 
			
		
	
		
			
				
					|  |  |  |  |                     .sum(); | 
			
		
	
	
		
			
				
					|  |  |  | @ -614,28 +452,6 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public int checkStatus1(List<BasicSkPrescribeDiEntity> list) { | 
			
		
	
		
			
				
					|  |  |  |  |         boolean hasTwo = false; | 
			
		
	
		
			
				
					|  |  |  |  |         boolean hasOne = false; | 
			
		
	
		
			
				
					|  |  |  |  |         for (BasicSkPrescribeDiEntity di : list) { | 
			
		
	
		
			
				
					|  |  |  |  |             int tagStatus = di.getTagStatus(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (tagStatus == 2) { | 
			
		
	
		
			
				
					|  |  |  |  |                 hasTwo = true; | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (tagStatus == 1) { | 
			
		
	
		
			
				
					|  |  |  |  |                 hasOne = true; | 
			
		
	
		
			
				
					|  |  |  |  |             } else if (tagStatus != 3) { | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new IllegalArgumentException("Invalid tagStatus value: " + tagStatus); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         if (hasTwo) { | 
			
		
	
		
			
				
					|  |  |  |  |             return 2; | 
			
		
	
		
			
				
					|  |  |  |  |         } else if (hasOne) { | 
			
		
	
		
			
				
					|  |  |  |  |             return 1; | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return 3; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     public int checkStatus(List<IoCollectOrderBiz> list) { | 
			
		
	
		
			
				
					|  |  |  |  |         boolean hasTwo = false; | 
			
		
	
		
			
				
					|  |  |  |  |         boolean hasOne = false; | 
			
		
	
	
		
			
				
					|  |  |  | 
 |