|
@@ -8,15 +8,18 @@ import com.fjhx.base.Condition;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.product.ProductCombination;
|
|
|
import com.fjhx.entity.product.ProductInfo;
|
|
|
+import com.fjhx.entity.stock.Stock;
|
|
|
import com.fjhx.mapper.product.ProductInfoMapper;
|
|
|
import com.fjhx.params.product.ProductCombinationEx;
|
|
|
import com.fjhx.params.product.ProductInfoVo;
|
|
|
import com.fjhx.service.product.ProductCombinationService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
|
+import com.fjhx.service.stock.StockService;
|
|
|
import com.fjhx.uitl.code.CodeEnum;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
import com.fjhx.utils.wrapperUtil.KeywordData;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -26,8 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -47,6 +52,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
@Autowired
|
|
|
private ProductCombinationService productCombinationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StockService stockService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<Map<String, Object>> getPage(Map<String, Object> condition) {
|
|
|
IWrapper<ProductInfo> wrapper = IWrapper.getWrapper(condition);
|
|
@@ -93,9 +101,26 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
List<Long> deptIdList = records.stream().map(item -> Convert.toLong(item.get("deptId"))).collect(Collectors.toList());
|
|
|
Map<Long, Dept> deptMap = iSysClient.getDeptByIdsToMap(deptIdList);
|
|
|
|
|
|
+ //查询产品库存
|
|
|
+ Map<Long, Stock> stockMap = new HashMap<>();
|
|
|
+ //查询库存量
|
|
|
+ if (Func.isNotEmpty(condition.get("warehouseId"))) {
|
|
|
+ //产品ID集合
|
|
|
+ List<Long> ids = page.getRecords().stream().map(item -> Convert.toLong(item.get("id"))).distinct().collect(Collectors.toList());
|
|
|
+ List<Stock> stocks = stockService.lambdaQuery().eq(Stock::getWarehouseId, condition.get("warehouseId")).in(Stock::getGoodsId, ids).list();
|
|
|
+ if (Func.isNotEmpty(stocks)) {
|
|
|
+ stockMap = stocks.stream().collect(Collectors.toMap(Stock::getGoodsId, Function.identity(), (key1, key2) -> key2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for (Map<String, Object> record : records) {
|
|
|
Dept dept = deptMap.get(Convert.toLong(record.get("deptId")));
|
|
|
record.put("deptName", dept == null ? "" : dept.getDeptName());
|
|
|
+
|
|
|
+ if (Func.isNotEmpty(stockMap) && Func.isNotEmpty(stockMap.get(Convert.toLong(record.get("id"))))) {
|
|
|
+ Stock stock = stockMap.get(Convert.toLong(record.get("id")));
|
|
|
+ record.put("stockQuantity", stock.getQuantity());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return page;
|