|  | @@ -38,6 +38,7 @@ import com.kmall.admin.utils.data.response.ResponseMessageData;
 | 
	
		
			
				|  |  |  import com.kmall.admin.utils.oms.OmsSign;
 | 
	
		
			
				|  |  |  import com.kmall.admin.utils.pdf.BarcodeUtil;
 | 
	
		
			
				|  |  |  import com.kmall.admin.websocket.WebSocketServer;
 | 
	
		
			
				|  |  | +import com.kmall.api.entity.OrderGoodsRestoreVo;
 | 
	
		
			
				|  |  |  import com.kmall.api.entity.OrderGoodsVo;
 | 
	
		
			
				|  |  |  import com.kmall.api.entity.OrderVo;
 | 
	
		
			
				|  |  |  import com.kmall.api.util.CommonUtil;
 | 
	
	
		
			
				|  | @@ -83,6 +84,8 @@ import java.text.ParseException;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.concurrent.*;
 | 
	
		
			
				|  |  | +import java.util.concurrent.atomic.AtomicInteger;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service("orderService")
 | 
	
	
		
			
				|  | @@ -100,6 +103,10 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private OrderGoodsDao orderGoodsDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | +    private OrderGoodsService orderGoodsService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ProductStoreRelaService productStoreRelaService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  |      private SysPrinterDao printerDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private UserDao userDao;
 | 
	
	
		
			
				|  | @@ -1627,6 +1634,78 @@ public class OrderServiceImpl implements OrderService {
 | 
	
		
			
				|  |  |          return orderDao.queryOffilineOrderList(map);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 还原查验单库存方法
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param orderSns  查验单订单编号
 | 
	
		
			
				|  |  | +     * @return          是否还原成功, true: 成功,false: 失败
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public Boolean restore(String orderSns) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (org.springframework.util.StringUtils.isEmpty(orderSns)) {
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<String> orderIdStrList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if (orderSns.contains(",")) {
 | 
	
		
			
				|  |  | +            String[] split = orderSns.split(",");
 | 
	
		
			
				|  |  | +            orderIdStrList.addAll(Arrays.asList(split));
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            orderIdStrList.add(orderSns);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Integer> orderIdList = orderIdStrList.parallelStream().map(Integer::valueOf).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        // 查询订单详细信息
 | 
	
		
			
				|  |  | +        List<OrderGoodsRestoreVo> orderGoodsRestoreVos = orderGoodsService.queryListByOrderIds(orderIdList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 需要更新门店商品库存(mall_product_store_rela)和园区库存(mall_goods)
 | 
	
		
			
				|  |  | +        // 园区库存, 无门店概念
 | 
	
		
			
				|  |  | +        List<GoodsEntity> goodsEntities = new ArrayList<>();
 | 
	
		
			
				|  |  | +        // 门店商品库存
 | 
	
		
			
				|  |  | +        List<ProductStoreRelaEntity> productStoreRelaEntities = new ArrayList<>();
 | 
	
		
			
				|  |  | +        // 组装数据
 | 
	
		
			
				|  |  | +        orderGoodsRestoreVos.forEach(orderGoodsRestoreVo -> {
 | 
	
		
			
				|  |  | +            goodsEntities.add(wrapGoods(orderGoodsRestoreVo));
 | 
	
		
			
				|  |  | +            productStoreRelaEntities.add(wrapProductStoreRela(orderGoodsRestoreVo));
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            // 还原园区库存
 | 
	
		
			
				|  |  | +            goodsService.restoreBatch(goodsEntities);
 | 
	
		
			
				|  |  | +            // 还原门店库存
 | 
	
		
			
				|  |  | +            productStoreRelaService.restoreBatch(productStoreRelaEntities);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 组装成ProductStoreRelaEntity, 还原操作
 | 
	
		
			
				|  |  | +     * @param orderGoodsRestoreVo   订单详细数据
 | 
	
		
			
				|  |  | +     * @return  门店库存
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private ProductStoreRelaEntity wrapProductStoreRela(OrderGoodsRestoreVo orderGoodsRestoreVo) {
 | 
	
		
			
				|  |  | +        ProductStoreRelaEntity productStoreRelaEntity = new ProductStoreRelaEntity();
 | 
	
		
			
				|  |  | +        productStoreRelaEntity.setStoreId(orderGoodsRestoreVo.getStoreId().longValue());
 | 
	
		
			
				|  |  | +        productStoreRelaEntity.setSku(orderGoodsRestoreVo.getSku());
 | 
	
		
			
				|  |  | +        productStoreRelaEntity.setStockNum(orderGoodsRestoreVo.getNumber());
 | 
	
		
			
				|  |  | +        return productStoreRelaEntity;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 组装成GoodsEntity, 还原操作
 | 
	
		
			
				|  |  | +     * @param orderGoodsRestoreVo   订单详细数据
 | 
	
		
			
				|  |  | +     * @return  库存
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private GoodsEntity wrapGoods(OrderGoodsRestoreVo orderGoodsRestoreVo) {
 | 
	
		
			
				|  |  | +        GoodsEntity goodsEntity = new GoodsEntity();
 | 
	
		
			
				|  |  | +        goodsEntity.setGoodsNumber(orderGoodsRestoreVo.getNumber());
 | 
	
		
			
				|  |  | +        goodsEntity.setSku(orderGoodsRestoreVo.getSku());
 | 
	
		
			
				|  |  | +        return goodsEntity;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<OrderEntity> queryPickUpCodeList(Map<String, Object> map) {
 | 
	
		
			
				|  |  |          return orderDao.queryPickUpCodeList(map);
 |