优化商品库存报表的查询逻辑
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialInitialStockWithMaterial;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import com.jsh.erp.datasource.entities.Unit;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
@@ -591,6 +592,11 @@ public class MaterialController {
|
||||
depotList.add(object.getLong("id"));
|
||||
}
|
||||
}
|
||||
Map<Long, BigDecimal> initialStockMap = new HashMap<>();
|
||||
List<MaterialInitialStockWithMaterial> initialStockList = materialService.getInitialStockWithMaterial(depotList);
|
||||
for (MaterialInitialStockWithMaterial mism: initialStockList) {
|
||||
initialStockMap.put(mism.getMaterialId(), mism.getNumber());
|
||||
}
|
||||
List<MaterialVo4Unit> dataList = materialService.getListWithStock(depotList, idList, StringUtil.toNull(materialParam), zeroStock,
|
||||
StringUtil.safeSqlParse(column), StringUtil.safeSqlParse(order), (currentPage-1)*pageSize, pageSize);
|
||||
int total = materialService.getListWithStockCount(depotList, idList, StringUtil.toNull(materialParam), zeroStock);
|
||||
@@ -598,7 +604,9 @@ public class MaterialController {
|
||||
map.put("total", total);
|
||||
map.put("currentStock", materialVo4Unit.getCurrentStock());
|
||||
map.put("currentStockPrice", materialVo4Unit.getCurrentStockPrice());
|
||||
//存放数据json数组
|
||||
for(MaterialVo4Unit item: dataList) {
|
||||
item.setInitialStock(initialStockMap.get(item.getId()));
|
||||
}
|
||||
map.put("rows", dataList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.jsh.erp.datasource.entities;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class MaterialInitialStockWithMaterial {
|
||||
|
||||
private Long materialId;
|
||||
|
||||
private BigDecimal number;
|
||||
|
||||
public Long getMaterialId() {
|
||||
return materialId;
|
||||
}
|
||||
|
||||
public void setMaterialId(Long materialId) {
|
||||
this.materialId = materialId;
|
||||
}
|
||||
|
||||
public BigDecimal getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(BigDecimal number) {
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.jsh.erp.datasource.mappers;
|
||||
|
||||
import com.jsh.erp.datasource.entities.AccountHead;
|
||||
import com.jsh.erp.datasource.entities.Material;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import com.jsh.erp.datasource.entities.Unit;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -110,6 +108,9 @@ public interface MaterialMapperEx {
|
||||
@Param("barCodeArray") String [] barCodeArray,
|
||||
@Param("mId") Long mId);
|
||||
|
||||
List<MaterialInitialStockWithMaterial> getInitialStockWithMaterial(
|
||||
@Param("depotList") List<Long> depotList);
|
||||
|
||||
List<MaterialVo4Unit> getListWithStock(
|
||||
@Param("depotList") List<Long> depotList,
|
||||
@Param("idList") List<Long> idList,
|
||||
|
||||
@@ -1034,6 +1034,10 @@ public class MaterialService {
|
||||
return materialMapperEx.getMaterialByBarCodeAndWithOutMId(barCodeArray, mId);
|
||||
}
|
||||
|
||||
public List<MaterialInitialStockWithMaterial> getInitialStockWithMaterial(List<Long> depotList) {
|
||||
return materialMapperEx.getInitialStockWithMaterial(depotList);
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> getListWithStock(List<Long> depotList, List<Long> idList, String materialParam, Integer zeroStock,
|
||||
String column, String order, Integer offset, Integer rows) {
|
||||
return materialMapperEx.getListWithStock(depotList, idList, materialParam, zeroStock, column, order, offset, rows);
|
||||
|
||||
Reference in New Issue
Block a user