|  |  |  | @ -554,59 +554,63 @@ public class OrderServiceImpl implements OrderService { | 
			
		
	
		
			
				
					|  |  |  |  |                 try { | 
			
		
	
		
			
				
					|  |  |  |  |                     //判断单据是否是预验收单据,如果是预验收单据,则删除预验收库库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                     if (isPreInOrder(orderEntity)) { | 
			
		
	
		
			
				
					|  |  |  |  |                         //查询预验收库详情
 | 
			
		
	
		
			
				
					|  |  |  |  |                         FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |                         filterInvProductDetailRequest.setOrderIdFk(id); | 
			
		
	
		
			
				
					|  |  |  |  |                         List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest); | 
			
		
	
		
			
				
					|  |  |  |  |                         Map<String, List<InvProductDetailEntity>> invPreInProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk)); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         List<InvProductEntity> invPreInProductList = new ArrayList<>(invPreInProductDetailMap.keySet().size()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) { | 
			
		
	
		
			
				
					|  |  |  |  |                             FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |                             filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |                             filterInvProductRequest.setSupId(invProductDetailEntity.getSupId()); | 
			
		
	
		
			
				
					|  |  |  |  |                             filterInvProductRequest.setInvStorageCode(invProductDetailEntity.getInvStorageCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             filterInvProductRequest.setInvWarehouseCode(invProductDetailEntity.getInvWarehouseCode()); | 
			
		
	
		
			
				
					|  |  |  |  |                             if (StrUtil.isBlank(invProductDetailEntity.getBatchNo())) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 filterInvProductRequest.setBatchNo("empty"); | 
			
		
	
		
			
				
					|  |  |  |  |                             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                 filterInvProductRequest.setBatchNo(invProductDetailEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  |                             List<InvProductEntity> invPerInProductEntities = invPreInProductDao.filterInvProduct(filterInvProductRequest); | 
			
		
	
		
			
				
					|  |  |  |  |                             InvProductEntity invProductEntity = invPerInProductEntities.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |                             if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 //入库,在原有库存基础上减库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                                 int count = invProductEntity.getInCount() - invProductDetailEntity.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                 invProductEntity.setInCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                             } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 //出库,在原有库存上增加库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                                 int count = invProductEntity.getOutCount() - invProductDetailEntity.getCount(); | 
			
		
	
		
			
				
					|  |  |  |  |                                 invProductEntity.setOutCount(count); | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                             invPreInProductList.add(invProductEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         //删除库存详情
 | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailDao.deleteByOrderId(id); | 
			
		
	
		
			
				
					|  |  |  |  |                         //删除码详情
 | 
			
		
	
		
			
				
					|  |  |  |  |                         codesDao.deleteByOrderId(id); | 
			
		
	
		
			
				
					|  |  |  |  |                         //更新库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                         for (InvProductEntity invProductEntity : invPreInProductList) { | 
			
		
	
		
			
				
					|  |  |  |  |                             //查询库存码详情,如果库存码详情为空,则删除此库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                             FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |                             detailParams.setBatchNo(invProductEntity.getBatchNo()); | 
			
		
	
		
			
				
					|  |  |  |  |                             detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode())); | 
			
		
	
		
			
				
					|  |  |  |  |                             detailParams.setProductIdFk(invProductEntity.getRelIdFk()); | 
			
		
	
		
			
				
					|  |  |  |  |                             int count = invPreInProductDetailDao.statCount(detailParams); | 
			
		
	
		
			
				
					|  |  |  |  |                             if (count == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                                 //如果库存码详情为空,则删除此库存
 | 
			
		
	
		
			
				
					|  |  |  |  |                                 invPreInProductDao.deleteById(String.valueOf(invProductEntity.getId())); | 
			
		
	
		
			
				
					|  |  |  |  |                             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                                 invPreInProductDao.updateInvProduct(invProductEntity); | 
			
		
	
		
			
				
					|  |  |  |  |                             } | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDetailDao.deleteByOrderId(orderEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                         invPreInProductDao.deleteByOrderIdFk(orderEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        //查询预验收库详情
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        filterInvProductDetailRequest.setOrderIdFk(id);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        List<InvProductDetailEntity> invProductDetailEntities = invPreInProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        Map<String, List<InvProductDetailEntity>> invPreInProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        List<InvProductEntity> invPreInProductList = new ArrayList<>(invPreInProductDetailMap.keySet().size());
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            filterInvProductRequest.setRelIdFk(invProductDetailEntity.getProductIdFk());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            filterInvProductRequest.setSupId(invProductDetailEntity.getSupId());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            filterInvProductRequest.setInvStorageCode(invProductDetailEntity.getInvStorageCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            filterInvProductRequest.setInvWarehouseCode(invProductDetailEntity.getInvWarehouseCode());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            if (StrUtil.isBlank(invProductDetailEntity.getBatchNo())) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                filterInvProductRequest.setBatchNo("empty");
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                filterInvProductRequest.setBatchNo(invProductDetailEntity.getBatchNo());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            List<InvProductEntity> invPerInProductEntities = invPreInProductDao.filterInvProduct(filterInvProductRequest);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            InvProductEntity invProductEntity = invPerInProductEntities.get(0);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                //入库,在原有库存基础上减库存
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                int count = invProductEntity.getInCount() - invProductDetailEntity.getCount();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                invProductEntity.setInCount(count);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                //出库,在原有库存上增加库存
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                int count = invProductEntity.getOutCount() - invProductDetailEntity.getCount();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                invProductEntity.setOutCount(count);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            invPreInProductList.add(invProductEntity);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        }
 | 
			
		
	
		
			
				
					|  |  |  |  | //
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        //删除库存详情
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        invPreInProductDetailDao.deleteByOrderId(id);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        //删除码详情
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        codesDao.deleteByOrderId(id);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        //更新库存
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        for (InvProductEntity invProductEntity : invPreInProductList) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            //查询库存码详情,如果库存码详情为空,则删除此库存
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest();
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            detailParams.setBatchNo(invProductEntity.getBatchNo());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode()));
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            detailParams.setProductIdFk(invProductEntity.getRelIdFk());
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            int count = invPreInProductDetailDao.statCount(detailParams);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            if (count == 0) {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                //如果库存码详情为空,则删除此库存
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                invPreInProductDao.deleteById(String.valueOf(invProductEntity.getId()));
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            } else {
 | 
			
		
	
		
			
				
					|  |  |  |  | //                                invPreInProductDao.updateInvProduct(invProductEntity);
 | 
			
		
	
		
			
				
					|  |  |  |  | //                            }
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        }
 | 
			
		
	
		
			
				
					|  |  |  |  |                     } else { | 
			
		
	
		
			
				
					|  |  |  |  |                         //查询库存详情
 | 
			
		
	
		
			
				
					|  |  |  |  |                         FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); | 
			
		
	
	
		
			
				
					|  |  |  | 
 |