|  |  | @ -2,6 +2,7 @@ package com.glxp.api.admin.service.inout.impl; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.bean.BeanUtil; |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.collection.CollUtil; |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.core.util.ReflectUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import cn.hutool.core.util.StrUtil; |  |  |  | import cn.hutool.core.util.StrUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.github.pagehelper.PageHelper; |  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.constant.Constant; |  |  |  | import com.glxp.api.admin.constant.Constant; | 
			
		
	
	
		
		
			
				
					|  |  | @ -31,6 +32,7 @@ import com.glxp.api.admin.req.inout.OrderFilterRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.req.inout.OrderQueryRequest; |  |  |  | import com.glxp.api.admin.req.inout.OrderQueryRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.req.inventory.FilterInvProductDetailRequest; |  |  |  | import com.glxp.api.admin.req.inventory.FilterInvProductDetailRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.req.inventory.FilterInvProductRequest; |  |  |  | import com.glxp.api.admin.req.inventory.FilterInvProductRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.admin.res.inout.OrderNoResult; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.res.inout.StockOrderResponse; |  |  |  | import com.glxp.api.admin.res.inout.StockOrderResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.service.info.SystemParamConfigService; |  |  |  | import com.glxp.api.admin.service.info.SystemParamConfigService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.admin.service.inout.OrderService; |  |  |  | import com.glxp.api.admin.service.inout.OrderService; | 
			
		
	
	
		
		
			
				
					|  |  | @ -43,6 +45,7 @@ import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.transaction.annotation.Transactional; |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.lang.reflect.Field; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.*; |  |  |  | import java.util.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.stream.Collectors; |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -168,7 +171,7 @@ public class OrderServiceImpl implements OrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (orderFilterRequest == null) { |  |  |  |         if (orderFilterRequest == null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             return Collections.emptyList(); |  |  |  |             return Collections.emptyList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         if(orderFilterRequest.getPage()!=null){ |  |  |  |         if (orderFilterRequest.getPage() != null) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             int offset = (orderFilterRequest.getPage() - 1) * orderFilterRequest.getLimit(); |  |  |  |             int offset = (orderFilterRequest.getPage() - 1) * orderFilterRequest.getLimit(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             PageHelper.offsetPage(offset, orderFilterRequest.getLimit()); |  |  |  |             PageHelper.offsetPage(offset, orderFilterRequest.getLimit()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
	
		
		
			
				
					|  |  | @ -356,6 +359,10 @@ public class OrderServiceImpl implements OrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return stockOrderDao.selectWaitSubmitOrders(); |  |  |  |         return stockOrderDao.selectWaitSubmitOrders(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public boolean updateReplicateNo(String orderId, String replicateNo) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return orderDao.updateReplicateNo(orderId, replicateNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public List<OrderEntity> filterOrderForDelete(String billNo) { |  |  |  |     public List<OrderEntity> filterOrderForDelete(String billNo) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -363,11 +370,44 @@ public class OrderServiceImpl implements OrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (null == orderEntity) { |  |  |  |         if (null == orderEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             return Collections.emptyList(); |  |  |  |             return Collections.emptyList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         //查询码表中所有的单据号
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         List<OrderEntity> orders = new ArrayList<>(); |  |  |  |         return getAllOrder(orderEntity); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         orders.add(orderEntity); |  |  |  |     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         getAllOrder(orderEntity, orders); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         return orders; |  |  |  |     //通过源单据查询所有关联的单据数据
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public void getLinkedOrderId(String id, List<String> orderIds) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<String> list = getOneOrderById(id); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (!orderIds.containsAll(list)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //找出不包含在原有集合中的单据号,回调方法
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String orderId = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             for (String item : list) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (!orderIds.contains(item)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     orderId = item; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             orderIds.addAll(list); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             getLinkedOrderId(orderId, orderIds); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //通过单号查询一个单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public List<String> getOneOrderById(String id) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         List<String> orderIds = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         OrderNoResult orderNo = orderDao.selectOrderNos(id); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Field[] fields = ReflectUtil.getFields(OrderNoResult.class); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         for (Field field : fields) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             String value = String.valueOf(ReflectUtil.getFieldValue(orderNo, field)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (StrUtil.isNotBlank(value) && !"null".equals(value)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (field.getName().equals("replicateNo")) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     String[] ids = value.split(","); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     orderIds.addAll(Arrays.asList(ids)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     orderIds.add(value); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return orderIds; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
	
		
		
			
				
					|  |  | @ -377,40 +417,30 @@ public class OrderServiceImpl implements OrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @param orders |  |  |  |      * @param orders | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void getAllOrder(OrderEntity orderEntity, List<OrderEntity> orders) { |  |  |  |     public List<OrderEntity> getAllOrder(OrderEntity orderEntity) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         OrderFilterRequest orderFilterRequest = new OrderFilterRequest(); |  |  |  |         List<String> orderIds = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         //补单单号
 |  |  |  |         orderIds.add(orderEntity.getId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (StrUtil.isNotBlank(orderEntity.getSupplementNo())) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             //补单单号不为空,查询补单数据
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             orderFilterRequest.setId(orderEntity.getSupplementNo()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             OrderEntity order = orderDao.findOne(orderFilterRequest); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (null != order && !orders.contains(order)) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 orders.add(order); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 getAllOrder(order, orders); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         //缺量补单上级单号
 |  |  |  |         getLinkedOrderId(orderEntity.getId(), orderIds); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (StrUtil.isNotBlank(orderEntity.getOriginUllageSupNo())) { |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             //缺量补单上级单号不为空,查询单据数据
 |  |  |  |         //去除本单的单据号
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             orderFilterRequest.setId(orderEntity.getOriginUllageSupNo()); |  |  |  |         Iterator<String> iterator = orderIds.iterator(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             OrderEntity order = orderDao.findOne(orderFilterRequest); |  |  |  |         while (iterator.hasNext()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if (null != order && !orders.contains(order)) { |  |  |  |             if (iterator.next().equals(orderEntity.getId())) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 orders.add(order); |  |  |  |                 iterator.remove(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 getAllOrder(order, orders); |  |  |  |                 break; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         //缺量补单
 |  |  |  |         List<OrderEntity> orders = new ArrayList<>(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (StrUtil.isNotBlank(orderEntity.getUllageSupNo())) { |  |  |  |         orders.add(orderEntity); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             //缺量补单单号不为空,查询单据数据
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             orderFilterRequest.setId(orderEntity.getUllageSupNo()); |  |  |  |         //查询除本单以外的所有的单据
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             OrderEntity order = orderDao.findOne(orderFilterRequest); |  |  |  |         if (CollUtil.isNotEmpty(orderIds)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if (null != order && !orders.contains(order)) { |  |  |  |             List<OrderEntity> orderEntities = orderDao.selectByIds(orderIds); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 orders.add(order); |  |  |  |             orders.addAll(orderEntities); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 getAllOrder(order, orders); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return orders; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Transactional(rollbackFor = Exception.class) |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |