|  |  | @ -51,16 +51,34 @@ public class InvProductsTrService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         orderFilterRequest.setId(orderId); |  |  |  |         orderFilterRequest.setId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest); |  |  |  |         List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |         OrderEntity orderEntity = orderEntities.get(0); |  |  |  |         OrderEntity orderEntity = orderEntities.get(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |         String customerId = orderEntity.getCustomerId() + ""; |  |  |  |         String customerId = String.valueOf(orderEntity.getCustomerId()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { |  |  |  |         if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); |  |  |  |             FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             filterOrderDetailRequest.setOrderId(orderId); |  |  |  |             filterOrderDetailRequest.setOrderId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |             List<OrderDetailEntity> erpOrderEntities = myErpOrderService.filterOrderDetails(filterOrderDetailRequest); |  |  |  |             List<OrderDetailEntity> erpOrderEntities = myErpOrderService.filterOrderDetails(filterOrderDetailRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (erpOrderEntities != null && erpOrderEntities.size() > 0) { |  |  |  |             if (erpOrderEntities != null && erpOrderEntities.size() > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { |  |  |  |                 for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //生成或更新库存数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvProductEntity invProductEntity = getInvProductEntity(orderEntity, customerId, orderDetailEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //生成库存详情数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     genInvProductDetail(orderId, invProductEntity, customerId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 添加 / 更新库存数据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param orderEntity       单据数据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param customerId        客户ID | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param orderDetailEntity 单据详情数据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private InvProductEntity getInvProductEntity(OrderEntity orderEntity, String customerId, OrderDetailEntity orderDetailEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         String nameCode = orderDetailEntity.getNameCode(); |  |  |  |         String nameCode = orderDetailEntity.getNameCode(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId); |  |  |  |         UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     InvProductEntity invProductEntity = invProductService.selectByUuid(udiInfoEntity.getUuid(), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); |  |  |  |         InvProductEntity invProductEntity = invProductService.selectByRelIdFk(String.valueOf(udiInfoEntity.getId()), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if (invProductEntity == null) { |  |  |  |         if (invProductEntity == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             invProductEntity = new InvProductEntity(); |  |  |  |             invProductEntity = new InvProductEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId())); |  |  |  |             invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId())); | 
			
		
	
	
		
		
			
				
					|  |  | @ -82,26 +100,41 @@ public class InvProductsTrService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductEntity.setInCount(orderDetailEntity.getCount()); |  |  |  |                 invProductEntity.setInCount(orderDetailEntity.getCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductEntity.setOutCount(0); |  |  |  |                 invProductEntity.setOutCount(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //生成库存数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             invProductService.insertInvProduct(invProductEntity); |  |  |  |             invProductService.insertInvProduct(invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                         invProductEntity = invProductService.selectByUuid(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); |  |  |  |             invProductEntity = invProductService.selectByRelIdFk(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { |  |  |  |             if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount()); |  |  |  |                 invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { |  |  |  |             } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount()); |  |  |  |                 invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount()); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //库存存在,更新库存数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             invProductService.updateInvProduct(invProductEntity); |  |  |  |             invProductService.updateInvProduct(invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return invProductEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 生成库存详情 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param orderId          单据号 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param invProductEntity 库存信息 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param customerId       客户ID | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private void genInvProductDetail(String orderId, InvProductEntity invProductEntity, String customerId) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         //查询码详情数据,用于生成库存
 |  |  |  |         //查询码详情数据,用于生成库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); |  |  |  |         WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         warehouseQueryRequest.setOrderId(orderId); |  |  |  |         warehouseQueryRequest.setOrderId(orderId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         warehouseQueryRequest.setNameCode(invProductEntity.getNameCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         warehouseQueryRequest.setRelId(invProductEntity.getRelIdFk()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         warehouseQueryRequest.setBatchNo(invProductEntity.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         List<WarehouseEntity> warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); |  |  |  |         List<WarehouseEntity> warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (CollUtil.isNotEmpty(warehouseEntities)) { |  |  |  |         if (CollUtil.isNotEmpty(warehouseEntities)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             for (WarehouseEntity warehouseEntity : warehouseEntities) { |  |  |  |             for (WarehouseEntity warehouseEntity : warehouseEntities) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); |  |  |  |                 UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); |  |  |  |                 InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                             invProductDetailEntity.setProductIdFk(invProductEntity.getRelIdFk() + ""); |  |  |  |                 invProductDetailEntity.setProductIdFk(String.valueOf(invProductEntity.getRelIdFk())); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId())); |  |  |  |                 invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId())); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setCode(warehouseEntity.getCode()); |  |  |  |                 invProductDetailEntity.setCode(warehouseEntity.getCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId()); |  |  |  |                 invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId()); | 
			
		
	
	
		
		
			
				
					|  |  | @ -113,15 +146,12 @@ public class InvProductsTrService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate()); |  |  |  |                 invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate()); |  |  |  |                 invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setUpdateTime(new Date()); |  |  |  |                 invProductDetailEntity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                             invProductDetailEntity.setCustomerId(orderEntity.getCustomerId() + ""); |  |  |  |                 invProductDetailEntity.setCustomerId(customerId); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode()); |  |  |  |                 invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invProductDetailService.insertInvProduct(invProductDetailEntity); |  |  |  |                 invProductDetailService.insertInvProduct(invProductDetailEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } |