|  |  | @ -2,23 +2,57 @@ package com.glxp.sale.admin.service.inout.impl; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 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.sale.admin.constant.ConstantStatus; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.constant.ConstantType; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.basic.BussinessLocalTypeDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inout.CodesDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inout.OrderDao; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.dao.inout.StockOrderDao; |  |  |  | import com.glxp.sale.admin.dao.inout.StockOrderDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inventory.InvPreInProductDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inventory.InvPreInProductDetailDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inventory.InvProductDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.dao.inventory.InvProductDetailDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.entity.inout.OrderEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.entity.inout.StockOrderEntity; |  |  |  | import com.glxp.sale.admin.entity.inout.StockOrderEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.entity.inout.StockOrderPrintEntity; |  |  |  | import com.glxp.sale.admin.entity.inout.StockOrderPrintEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.entity.inventory.InvProductEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.req.inout.StockOrderFilterRequest; |  |  |  | import com.glxp.sale.admin.req.inout.StockOrderFilterRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.req.inout.StockOrderQueryRequest; |  |  |  | import com.glxp.sale.admin.req.inout.StockOrderQueryRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.sale.admin.req.inventory.FilterInvProductRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.sale.admin.service.inout.StockOrderService; |  |  |  | import com.glxp.sale.admin.service.inout.StockOrderService; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Collections; |  |  |  | import java.util.Collections; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.Map; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | @Transactional | 
			
		
	
		
		
			
				
					
					|  |  |  | @Service |  |  |  | @Service | 
			
		
	
		
		
			
				
					
					|  |  |  | public class StockOrderServiceImpl implements StockOrderService { |  |  |  | public class StockOrderServiceImpl implements StockOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Resource |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |     StockOrderDao stockOrderDao; |  |  |  |     private StockOrderDao stockOrderDao; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private InvProductDao invProductDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private InvProductDetailDao invProductDetailDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private OrderDao orderDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private BussinessLocalTypeDao bussinessLocalTypeDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private InvPreInProductDetailDao invPreInProductDetailDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private InvPreInProductDao invPreInProductDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private CodesDao codesDao; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Override |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |     public List<StockOrderEntity> listStockOrders(StockOrderQueryRequest stockOrderQueryRequest) { |  |  |  |     public List<StockOrderEntity> listStockOrders(StockOrderQueryRequest stockOrderQueryRequest) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -127,4 +161,178 @@ public class StockOrderServiceImpl implements StockOrderService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return stockOrderDao.selectSupplementOrderList(); |  |  |  |         return stockOrderDao.selectSupplementOrderList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public boolean rollbackOrder(String billNo) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //查询业务单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         StockOrderEntity stockOrderEntity = stockOrderDao.selectByBillNo(billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //查询扫码单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         OrderEntity orderEntity = orderDao.selectByBillNo(billNo); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (stockOrderEntity.getStatus().equals(ConstantStatus.SORDER_CHECKED)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //回退未验收单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             /* | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             业务逻辑: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 回滚扫码单据状态到等待校验,并置空业务单据关联的扫码单据号,将此业务单据与扫码单据脱离关联,恢复可以被选择的状态 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             stockOrderEntity.setOrderIdFk(null); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             stockOrderEntity.setStatus(ConstantStatus.SORDER_CHECK); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //更新单据状态
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             stockOrderDao.updateById(stockOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             orderDao.updateOrder(orderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //回退已完成单据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             /* | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             业务逻辑: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 查询此业务单据对应的扫码单据,判断是否是预验收单据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     如果是预验收单据,则扣减预验收库的库存 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     不是预验收单据,则正常扣减库存,回滚业务单据状态 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (isPreInOrder(orderEntity)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //查询预验收库库存详情
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 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 (String productId : invPreInProductDetailMap.keySet()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     List<InvProductDetailEntity> detailList = invPreInProductDetailMap.get(productId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setRelIdFk(productId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setSupId(detailList.get(0).getSupId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setInvWarehouseCode(detailList.get(0).getInvWarehouseCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setInvStorageCode(detailList.get(0).getInvStorageCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (StrUtil.isBlank(detailList.get(0).getBatchNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         filterInvProductRequest.setBatchNo("empty"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         filterInvProductRequest.setBatchNo(detailList.get(0).getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     List<InvProductEntity> invProductEntities = invPreInProductDao.filterInvProduct(filterInvProductRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvProductEntity invProductEntity = invProductEntities.get(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     detailList.forEach(invProductDetailEntity -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         calculateInvCount(invProductEntity, invProductDetailEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     invPreInProductList.add(invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //删除库存详情
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 invPreInProductDetailDao.deleteByOrderId(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //删除码详情
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 codesDao.deleteByOrderId(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //更新库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 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(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 filterInvProductDetailRequest.setOrderIdFk(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //合并各个产品集合数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 Map<String, List<InvProductDetailEntity>> invProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 List<InvProductEntity> invProductList = new ArrayList<>(invProductDetailMap.keySet().size()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 for (String productId : invProductDetailMap.keySet()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     List<InvProductDetailEntity> detailList = invProductDetailMap.get(productId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //查询库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setRelIdFk(productId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setSupId(detailList.get(0).getSupId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setInvWarehouseCode(detailList.get(0).getInvWarehouseCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     filterInvProductRequest.setInvStorageCode(detailList.get(0).getInvStorageCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (StrUtil.isNotBlank(detailList.get(0).getBatchNo())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         filterInvProductRequest.setBatchNo("empty"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         filterInvProductRequest.setBatchNo(detailList.get(0).getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     List<InvProductEntity> invProductEntities = invProductDao.filterInvProduct(filterInvProductRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvProductEntity invProductEntity = invProductEntities.get(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     detailList.forEach(invProductDetailEntity -> calculateInvCount(invProductEntity, invProductDetailEntity)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     invProductList.add(invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //删除库存详情
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 invProductDetailDao.deleteByOrderId(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //删除码详情
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 codesDao.deleteByOrderId(orderEntity.getId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //更新库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 for (InvProductEntity invProductEntity : invProductList) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //查询库存码详情,如果库存码详情为空,则删除此库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     FilterInvProductDetailRequest detailParams = new FilterInvProductDetailRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     detailParams.setBatchNo(invProductEntity.getBatchNo()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     detailParams.setInvCodes(Collections.singletonList(invProductEntity.getInvStorageCode())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     detailParams.setProductIdFk(invProductEntity.getRelIdFk()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     int count = invProductDetailDao.statCount(detailParams); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (count == 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //如果库存码详情为空,则删除此库存
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         invProductDao.deleteById(String.valueOf(invProductEntity.getId())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         invProductDao.updateInvProduct(invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //修改单据状态到未验收
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             stockOrderEntity.setStatus(ConstantStatus.SORDER_CHECKED); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //更新业务单据数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         stockOrderDao.updateById(stockOrderEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 计算库存数量 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param invProductEntity | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param invProductDetailEntity | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private void calculateInvCount(InvProductEntity invProductEntity, InvProductDetailEntity invProductDetailEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         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); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 判断单据是否是预验收单据 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param orderEntity | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private boolean isPreInOrder(OrderEntity orderEntity) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Boolean isTrue = bussinessLocalTypeDao.selectPreInByOrderType(orderEntity.getAction()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (isTrue == null) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return isTrue; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |