|
@@ -1,6 +1,7 @@
|
|
|
package com.fjhx.service.stock.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -8,13 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.abnormal.AbnormalInfo;
|
|
|
-import com.fjhx.entity.order.OrderInfo;
|
|
|
import com.fjhx.entity.product.ProductInfo;
|
|
|
import com.fjhx.entity.stock.StockTransfer;
|
|
|
import com.fjhx.entity.warehouse.Warehouse;
|
|
|
import com.fjhx.enums.stock.InTypeEnum;
|
|
|
import com.fjhx.mapper.stock.StockTransferMapper;
|
|
|
-import com.fjhx.params.order.OrderInfoVo;
|
|
|
+import com.fjhx.params.order.OrderInfoEx;
|
|
|
import com.fjhx.params.stock.*;
|
|
|
import com.fjhx.service.abnormal.AbnormalInfoService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
@@ -22,6 +22,7 @@ import com.fjhx.service.stock.StockService;
|
|
|
import com.fjhx.service.stock.StockTransferService;
|
|
|
import com.fjhx.service.warehouse.WarehouseService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.RegionClientUtil;
|
|
|
import com.fjhx.utils.UserClientUtil;
|
|
|
import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
import com.fjhx.utils.wrapperUtil.KeywordData;
|
|
@@ -99,34 +100,45 @@ public class StockTransferServiceImpl extends ServiceImpl<StockTransferMapper, S
|
|
|
}
|
|
|
//过滤出京东订单
|
|
|
@Override
|
|
|
- public Page<StockTransferVo> getPage1(Condition condition) {
|
|
|
- IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
|
|
|
- wrapper.eq("st", StockTransfer::getInWarehouseId);
|
|
|
- wrapper.eq("st", StockTransfer::getOutWarehouseId);
|
|
|
- wrapper.eq("st", StockTransfer::getInStatus);
|
|
|
- wrapper.keyword(new KeywordData("pi", ProductInfo::getName), new KeywordData("pi", ProductInfo::getCode));
|
|
|
- wrapper.orderByDesc("st", StockTransfer::getId);
|
|
|
- wrapper.isNotNull("st.jd_order_info_id");
|
|
|
-
|
|
|
-
|
|
|
- Page<StockTransferVo> page = baseMapper.getPage1(condition.getPage(), wrapper);
|
|
|
- List<StockTransferVo> records = page.getRecords();
|
|
|
+ public Page<OrderInfoEx> getPage1(Condition condition) {
|
|
|
+ QueryWrapper<StockTransfer> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("in_warehouse_id",condition.getStr("inWarehouseId"));
|
|
|
+ queryWrapper.eq("out_warehouse_id",condition.getStr("outWarehouseId"));
|
|
|
+ queryWrapper.eq("in_status",condition.getStr("inStatus"));
|
|
|
+ queryWrapper.isNotNull("jd_order_info_id");
|
|
|
+ List<StockTransfer> stockTransferList = list(queryWrapper);
|
|
|
+ List<Long> jdinfoids = stockTransferList.stream().map(StockTransfer::getJdOrderInfoId).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ IWrapper<Object> wrapper1 = IWrapper.getWrapper(condition);
|
|
|
+ wrapper1.eq(OrderInfoEx::getCode,condition.getStr("keyword"));
|
|
|
+ wrapper1.in(OrderInfoEx::getId,jdinfoids);
|
|
|
+ Page<OrderInfoEx> page = baseMapper.getPage1(condition.getPage(), wrapper1);
|
|
|
+ List<OrderInfoEx> records = page.getRecords();
|
|
|
if (records.size() == 0) {
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
-// List<Long> userIdList = new ArrayList<>();
|
|
|
-// records.forEach(item -> {
|
|
|
-// userIdList.add(Convert.toLong(item.getInUser()));
|
|
|
-// userIdList.add(Convert.toLong(item.getCreateUser()));
|
|
|
-// });
|
|
|
-//
|
|
|
-// Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(userIdList);
|
|
|
-//
|
|
|
-// for (StockTransferVo item : records) {
|
|
|
-// item.setInUserName(userNameMap.get(Convert.toLong(item.getInUser())));
|
|
|
-// item.setOutUserName(userNameMap.get(Convert.toLong(item.getCreateUser())));
|
|
|
-// }
|
|
|
+ //获取订单id列表
|
|
|
+ List<Long> orids = records.stream().map(OrderInfoEx::getId).collect(Collectors.toList());
|
|
|
+ List<StockTransfer> list = list(q -> q.in(StockTransfer::getJdOrderInfoId, orids));
|
|
|
+ List<StockTransferVo> copy = BeanUtil.copy(list, StockTransferVo.class);
|
|
|
+ Map<Long, List<StockTransferVo>> stockTransferListMap = copy.stream().collect(Collectors.groupingBy(StockTransfer::getJdOrderInfoId));
|
|
|
+
|
|
|
+ List<Long> pids = copy.stream().map(StockTransferVo::getProductId).collect(Collectors.toList());
|
|
|
+ List<ProductInfo> productInfoList = productInfoService.listByIds(pids);
|
|
|
+ Map<Long, String> productMap = productInfoList.stream().collect(Collectors.toMap(ProductInfo::getId, ProductInfo::getName));
|
|
|
+ for (StockTransferVo stockTransferVo:copy){
|
|
|
+ stockTransferVo.setProductName(productMap.get(stockTransferVo.getProductId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderInfoEx orderInfoEx :records){
|
|
|
+ List<StockTransferVo> stockTransfers = stockTransferListMap.get(orderInfoEx.getId());
|
|
|
+ orderInfoEx.setStockTransferList(stockTransfers);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 赋值国省市
|
|
|
+ RegionClientUtil.setEntityRegionName(page.getRecords());
|
|
|
|
|
|
return page;
|
|
|
}
|