优化进销存统计接口

This commit is contained in:
季圣华
2021-12-07 00:26:08 +08:00
parent f7014987b2
commit e7d7666b3d
5 changed files with 68 additions and 72 deletions

View File

@@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -581,7 +582,7 @@ public class DepotItemService {
}
/**
* 库存统计
* 库存统计-单仓库
* @param depotId
* @param mId
* @param beginTime
@@ -589,11 +590,27 @@ public class DepotItemService {
* @return
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime){
List<Long> depotList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
}
return getStockByParamWithDepotList(depotList, mId, beginTime, endTime);
}
/**
* 库存统计-多仓库
* @param depotList
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getStockByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime){
//初始库存
BigDecimal initStock = materialService.getInitStockByMid(depotId, mId);
BigDecimal initStock = materialService.getInitStockByMidAndDepotList(depotList, mId);
//盘点复盘后数量的变动
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSum(depotId, mId, beginTime, endTime);
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime);
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSumByDepotList(depotList, mId, beginTime, endTime);
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, beginTime, endTime);
BigDecimal stockSum = BigDecimal.ZERO;
if(stockObj!=null) {
BigDecimal inTotal = stockObj.getInTotal();
@@ -611,15 +628,15 @@ public class DepotItemService {
}
/**
* 入库统计
* @param depotId
* 入库统计-多仓库
* @param depotList
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getInNumByParam(Long depotId, Long mId, String beginTime, String endTime){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime);
public BigDecimal getInNumByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, beginTime, endTime);
BigDecimal stockSum = BigDecimal.ZERO;
if(stockObj!=null) {
BigDecimal inTotal = stockObj.getInTotal();
@@ -632,15 +649,15 @@ public class DepotItemService {
}
/**
* 出库统计
* @param depotId
* 出库统计-多仓库
* @param depotList
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getOutNumByParam(Long depotId, Long mId, String beginTime, String endTime){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime);
public BigDecimal getOutNumByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, beginTime, endTime);
BigDecimal stockSum = BigDecimal.ZERO;
if(stockObj!=null) {
BigDecimal outTotal = stockObj.getOutTotal();

View File

@@ -762,15 +762,16 @@ public class MaterialService {
}
/**
* 根据商品获取初始库存,仓库为空的时候查全部库存
* 根据商品获取初始库存-多仓库
* @param depotList
* @param materialId
* @return
*/
public BigDecimal getInitStockByMid(Long depotId, Long materialId) {
public BigDecimal getInitStockByMidAndDepotList(List<Long> depotList, Long materialId) {
BigDecimal stock = BigDecimal.ZERO;
MaterialInitialStockExample example = new MaterialInitialStockExample();
if(depotId!=null) {
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId)
if(depotList!=null && depotList.size()>0) {
example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdIn(depotList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else {
example.createCriteria().andMaterialIdEqualTo(materialId)