|  |  |  | @ -174,16 +174,16 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |         //拿到 产品库存
 | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitFifoInv splitFifoInv = ioSplitFifoInvService.getById(addInvDesDetaiRequest.getSplitFifoInv().getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         int count = splitFifoInv.getReCount() - addInvDesDetaiRequest.getOutCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count < 0){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500,"库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count < 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //修改产品 库存 出库数量 可用数量 剩余数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         //入库数量是否需要更改?
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setOutCount(splitFifoInv.getOutCount() + addInvDesDetaiRequest.getOutCount());//出库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setReCount(splitFifoInv.getInCount() - addInvDesDetaiRequest.getOutCount());//剩余数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         int availableCount = splitFifoInv.getInCount() - addInvDesDetaiRequest.getOutCount() - splitFifoInv.getLockCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (availableCount <= -1){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500,"可用数量库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (availableCount <= -1) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "可用数量库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //可用数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setAvailableCount(availableCount); | 
			
		
	
	
		
			
				
					|  |  |  | @ -196,16 +196,16 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //todo 码明细删减库存
 | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitFifoCodeEntity splitFifoCodeEntity = splitFifoCodeService.getOne(new LambdaQueryWrapper<IoSplitFifoCodeEntity>() | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getWorkPlaceCode,splitFifoInv.getWorkPlaceCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getBatchNo,splitFifoInv.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getRelId,splitFifoInv.getRelId())); | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getWorkPlaceCode, splitFifoInv.getWorkPlaceCode()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getBatchNo, splitFifoInv.getBatchNo()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoCodeEntity::getRelId, splitFifoInv.getRelId())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (splitFifoCodeEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException("该工位不存在,请检查后重试!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoCodeEntity.setTotalCount(splitFifoCodeEntity.getTotalCount() - addInvDesDetaiRequest.getOutCount()); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean b = splitFifoCodeService.updateById(splitFifoCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!b){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw  new JsonException(500,"追溯码库存删减失败"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!b) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "追溯码库存删减失败"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | //        IoSplitFifoInv splitFifoInv = addInvDesDetaiRequest.getSplitFifoInv();
 | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitDesOrderDetail splitDesOrderDetail = IoSplitDesOrderDetail.builder() | 
			
		
	
	
		
			
				
					|  |  |  | @ -224,7 +224,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |                 .updateTime(new Date()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .remark("").build(); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean save1 = splitDesOrderDetailService.save(splitDesOrderDetail); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!save1){ | 
			
		
	
		
			
				
					|  |  |  |  |         if (!save1) { | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return true; | 
			
		
	
	
		
			
				
					|  |  |  | @ -252,33 +252,33 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |                 .updateUser(addInvDesDetaiRequest.getUpdateUser()) | 
			
		
	
		
			
				
					|  |  |  |  |                 .build(); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean save = save(collectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |         if(!save){ | 
			
		
	
		
			
				
					|  |  |  |  |         if (!save) { | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoCodeEntity.setTotalCount(splitFifoCodeEntity.getTotalCount() - addInvDesDetaiRequest.getOutCount()); | 
			
		
	
		
			
				
					|  |  |  |  |         //是否在增加一个码字段 记录可用数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoCodeEntity.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         boolean b = splitFifoCodeService.updateById(splitFifoCodeEntity); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!b){ | 
			
		
	
		
			
				
					|  |  |  |  |         if (!b) { | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //拿到 产品库存
 | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitFifoInv splitFifoInv = ioSplitFifoInvService.getOne(new LambdaQueryWrapper<IoSplitFifoInv>() | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoInv::getId,splitFifoCodeEntity.getInvIdFk())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (splitFifoInv == null){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw  new JsonException(500,"未找到该产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 .eq(IoSplitFifoInv::getId, splitFifoCodeEntity.getInvIdFk())); | 
			
		
	
		
			
				
					|  |  |  |  |         if (splitFifoInv == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "未找到该产品!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         int count = splitFifoInv.getReCount() - addInvDesDetaiRequest.getOutCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count < 0){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500,"库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count < 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         //修改产品 库存 入库数
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setOutCount(splitFifoInv.getOutCount() + addInvDesDetaiRequest.getOutCount());//出库数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setReCount(splitFifoInv.getInCount() - addInvDesDetaiRequest.getOutCount());//剩余数量
 | 
			
		
	
		
			
				
					|  |  |  |  |         int availableCount = splitFifoInv.getInCount() - addInvDesDetaiRequest.getOutCount() - splitFifoInv.getLockCount(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (availableCount <= -1){ | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500,"可用数量库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (availableCount <= -1) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "可用数量库存不足"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | //        int newAvailableCount  = splitFifoInv.getAvailableCount() - availableCount;
 | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setAvailableCount(availableCount);//可用数量
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -286,7 +286,7 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |         splitFifoInv.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         //更改 库存
 | 
			
		
	
		
			
				
					|  |  |  |  |         boolean update = ioSplitFifoInvService.updateById(splitFifoInv); | 
			
		
	
		
			
				
					|  |  |  |  |         if (!update){ | 
			
		
	
		
			
				
					|  |  |  |  |         if (!update) { | 
			
		
	
		
			
				
					|  |  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitDesOrderDetail splitDesOrderDetail = IoSplitDesOrderDetail.builder() | 
			
		
	
	
		
			
				
					|  |  |  | @ -332,13 +332,14 @@ public class IoSplitDesOrderService extends ServiceImpl<IoSplitDesOrderMapper, I | 
			
		
	
		
			
				
					|  |  |  |  |         save(collectOrder); | 
			
		
	
		
			
				
					|  |  |  |  |         IoSplitCodeEntity splitCodeEntity = splitCodeService.findByCode(addInvDesDetaiRequest.getCode(), addInvDesDetaiRequest.getSplitFifoInv().getWorkPlaceCode(), null); | 
			
		
	
		
			
				
					|  |  |  |  |         if (splitCodeEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500,"该追溯码不存在!"); | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException(500, "该追溯码不存在!"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         int count = IntUtil.value(splitCodeEntity.getRemainCount()) - IntUtil.value(addInvDesDetaiRequest.getOutCount()); | 
			
		
	
		
			
				
					|  |  |  |  |         if (count < 0) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (splitCodeEntity == null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new RuntimeException("存量不足!"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         splitCodeEntity.setRemainCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |         splitCodeService.updateById(splitCodeEntity); | 
			
		
	
	
		
			
				
					|  |  |  | 
 |