|  |  |  | @ -602,49 +602,53 @@ public class IoCheckInoutService { | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if (preInOrder.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                 String preInBillNo = ""; | 
			
		
	
		
			
				
					|  |  |  |  |                 boolean isBreak = false; | 
			
		
	
		
			
				
					|  |  |  |  |                 for (String key : preInOrder.keySet()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     preInBillNo = preInBillNo + "," + key; | 
			
		
	
		
			
				
					|  |  |  |  |                     IoOrderEntity preInEntity = orderService.findByBillNo(key); | 
			
		
	
		
			
				
					|  |  |  |  |                     preInEntity.setPreOutBillNo(orderEntity.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                     orderService.update(preInEntity); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                     //预验收不删除单号,方便后续查询
 | 
			
		
	
		
			
				
					|  |  |  |  |                     if (bussinessTypeEntity.isPreInBack()) {            //预验收如果带回,则清空相关预验收库存;
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreinDetailService.deleteByOrderId(preInEntity.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                     } else {            //预验收如果不带回,则清除已出库相关库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         for (IoCodeEntity codeEntity : codeList) { | 
			
		
	
		
			
				
					|  |  |  |  |                             if (StrUtil.isEmpty(codeEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 InvPreinDetailEntity invPreinDetailEntity = invPreinDetailService.findByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                 if (invPreinDetailEntity != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                                     int count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                                     if (invPreinDetailEntity.getCount() < codeEntity.getCount()) { | 
			
		
	
		
			
				
					|  |  |  |  |                                         count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                         count = invPreinDetailEntity.getCount() - codeEntity.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                     } | 
			
		
	
		
			
				
					|  |  |  |  |                                     if (count >= 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                         if (count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (!isBreak) { | 
			
		
	
		
			
				
					|  |  |  |  |                         preInBillNo = preInBillNo + "," + key; | 
			
		
	
		
			
				
					|  |  |  |  |                         IoOrderEntity preInEntity = orderService.findByBillNo(key); | 
			
		
	
		
			
				
					|  |  |  |  |                         preInEntity.setPreOutBillNo(orderEntity.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                         orderService.update(preInEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                         BasicBussinessTypeEntity preBusType = basicBussinessTypeService.findByAction(preInEntity.getAction()); | 
			
		
	
		
			
				
					|  |  |  |  |                         //预验收不删除单号,方便后续查询
 | 
			
		
	
		
			
				
					|  |  |  |  |                         if (preBusType.isPreInBack()) {            //预验收如果带回,则清空相关预验收库存;
 | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreinDetailService.deleteByOrderId(preInEntity.getBillNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                         } else {            //预验收如果不带回,则清除已出库相关库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                             for (IoCodeEntity codeEntity : codeList) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 if (StrUtil.isEmpty(codeEntity.getSerialNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                                     InvPreinDetailEntity invPreinDetailEntity = invPreinDetailService.findByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                     if (invPreinDetailEntity != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                                         int count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                                         if (invPreinDetailEntity.getCount() < codeEntity.getCount()) { | 
			
		
	
		
			
				
					|  |  |  |  |                                             count = 0; | 
			
		
	
		
			
				
					|  |  |  |  |                                         } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailEntity.setCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailService.update(invPreinDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                             count = invPreinDetailEntity.getCount() - codeEntity.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                         } | 
			
		
	
		
			
				
					|  |  |  |  |                                         int reCount = invPreinDetailEntity.getReCount() - codeEntity.getMyReCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                         if (reCount == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                         } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailEntity.setReCount(reCount); | 
			
		
	
		
			
				
					|  |  |  |  |                                             invPreinDetailService.update(invPreinDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                         if (count >= 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                             isBreak = true; | 
			
		
	
		
			
				
					|  |  |  |  |                                             if (count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailEntity.setCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailService.update(invPreinDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                             } | 
			
		
	
		
			
				
					|  |  |  |  |                                             int reCount = invPreinDetailEntity.getReCount() - codeEntity.getMyReCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                             if (reCount == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailEntity.setReCount(reCount); | 
			
		
	
		
			
				
					|  |  |  |  |                                                 invPreinDetailService.update(invPreinDetailEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                                             } | 
			
		
	
		
			
				
					|  |  |  |  |                                         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                                     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                     invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                 invPreinDetailService.deleteByCode(key, codeEntity.getCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |