修改库存统计的计算逻辑,根据出入库管理开关进行判断
This commit is contained in:
@@ -153,6 +153,7 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("depotList") List<Long> depotList,
|
@Param("depotList") List<Long> depotList,
|
||||||
@Param("meId") Long meId,
|
@Param("meId") Long meId,
|
||||||
@Param("forceFlag") Boolean forceFlag,
|
@Param("forceFlag") Boolean forceFlag,
|
||||||
|
@Param("inOutManageFlag") Boolean inOutManageFlag,
|
||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime);
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
@@ -160,6 +161,7 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("depotList") List<Long> depotList,
|
@Param("depotList") List<Long> depotList,
|
||||||
@Param("mId") Long mId,
|
@Param("mId") Long mId,
|
||||||
@Param("forceFlag") Boolean forceFlag,
|
@Param("forceFlag") Boolean forceFlag,
|
||||||
|
@Param("inOutManageFlag") Boolean inOutManageFlag,
|
||||||
@Param("beginTime") String beginTime,
|
@Param("beginTime") String beginTime,
|
||||||
@Param("endTime") String endTime);
|
@Param("endTime") String endTime);
|
||||||
|
|
||||||
|
|||||||
@@ -914,10 +914,11 @@ public class DepotItemService {
|
|||||||
*/
|
*/
|
||||||
public BigDecimal getSkuStockByParam(Long depotId, Long meId, String beginTime, String endTime) throws Exception {
|
public BigDecimal getSkuStockByParam(Long depotId, Long meId, String beginTime, String endTime) throws Exception {
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||||
|
Boolean inOutManageFlag = systemConfigService.getInOutManageFlag();
|
||||||
List<Long> depotList = depotService.parseDepotList(depotId);
|
List<Long> depotList = depotService.parseDepotList(depotId);
|
||||||
//盘点复盘后数量的变动
|
//盘点复盘后数量的变动
|
||||||
BigDecimal stockCheckSum = depotItemMapperEx.getSkuStockCheckSumByDepotList(depotList, meId, forceFlag, beginTime, endTime);
|
BigDecimal stockCheckSum = depotItemMapperEx.getSkuStockCheckSumByDepotList(depotList, meId, forceFlag, beginTime, endTime);
|
||||||
DepotItemVo4Stock stockObj = depotItemMapperEx.getSkuStockByParamWithDepotList(depotList, meId, forceFlag, beginTime, endTime);
|
DepotItemVo4Stock stockObj = depotItemMapperEx.getSkuStockByParamWithDepotList(depotList, meId, forceFlag, inOutManageFlag, beginTime, endTime);
|
||||||
BigDecimal stockSum = BigDecimal.ZERO;
|
BigDecimal stockSum = BigDecimal.ZERO;
|
||||||
if(stockObj!=null) {
|
if(stockObj!=null) {
|
||||||
BigDecimal inTotal = stockObj.getInTotal();
|
BigDecimal inTotal = stockObj.getInTotal();
|
||||||
@@ -957,11 +958,12 @@ public class DepotItemService {
|
|||||||
*/
|
*/
|
||||||
public BigDecimal getStockByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime) throws Exception {
|
public BigDecimal getStockByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime) throws Exception {
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||||
|
Boolean inOutManageFlag = systemConfigService.getInOutManageFlag();
|
||||||
//初始库存
|
//初始库存
|
||||||
BigDecimal initStock = materialService.getInitStockByMidAndDepotList(depotList, mId);
|
BigDecimal initStock = materialService.getInitStockByMidAndDepotList(depotList, mId);
|
||||||
//盘点复盘后数量的变动
|
//盘点复盘后数量的变动
|
||||||
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSumByDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSumByDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
||||||
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, forceFlag, inOutManageFlag, beginTime, endTime);
|
||||||
BigDecimal stockSum = BigDecimal.ZERO;
|
BigDecimal stockSum = BigDecimal.ZERO;
|
||||||
if(stockObj!=null) {
|
if(stockObj!=null) {
|
||||||
BigDecimal inTotal = stockObj.getInTotal();
|
BigDecimal inTotal = stockObj.getInTotal();
|
||||||
@@ -988,12 +990,13 @@ public class DepotItemService {
|
|||||||
*/
|
*/
|
||||||
public Map<String, BigDecimal> getIntervalMapByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime) throws Exception {
|
public Map<String, BigDecimal> getIntervalMapByParamWithDepotList(List<Long> depotList, Long mId, String beginTime, String endTime) throws Exception {
|
||||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||||
|
Boolean inOutManageFlag = systemConfigService.getInOutManageFlag();
|
||||||
Map<String,BigDecimal> intervalMap = new HashMap<>();
|
Map<String,BigDecimal> intervalMap = new HashMap<>();
|
||||||
BigDecimal inSum = BigDecimal.ZERO;
|
BigDecimal inSum = BigDecimal.ZERO;
|
||||||
BigDecimal outSum = BigDecimal.ZERO;
|
BigDecimal outSum = BigDecimal.ZERO;
|
||||||
//盘点复盘后数量的变动
|
//盘点复盘后数量的变动
|
||||||
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSumByDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
BigDecimal stockCheckSum = depotItemMapperEx.getStockCheckSumByDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
||||||
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, forceFlag, beginTime, endTime);
|
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParamWithDepotList(depotList, mId, forceFlag, inOutManageFlag, beginTime, endTime);
|
||||||
if(stockObj!=null) {
|
if(stockObj!=null) {
|
||||||
BigDecimal inTotal = stockObj.getInTotal();
|
BigDecimal inTotal = stockObj.getInTotal();
|
||||||
BigDecimal transfInTotal = stockObj.getTransfInTotal();
|
BigDecimal transfInTotal = stockObj.getTransfInTotal();
|
||||||
|
|||||||
@@ -680,8 +680,8 @@
|
|||||||
|
|
||||||
<select id="getSkuStockByParamWithDepotList" resultMap="stockMap">
|
<select id="getSkuStockByParamWithDepotList" resultMap="stockMap">
|
||||||
select
|
select
|
||||||
sum(case when dh.type='入库' <include refid="depotParam" /> then di.basic_number else 0 end) as inTotal,
|
sum(case when dh.type='入库' <include refid="inOutManageParam" /> <include refid="depotParam" /> then di.basic_number else 0 end) as inTotal,
|
||||||
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as outTotal,
|
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid="inOutManageParam" /> <include refid="depotParam" /> then di.basic_number else 0 end) as outTotal,
|
||||||
sum(case when dh.sub_type='调拨' <include refid="anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
|
sum(case when dh.sub_type='调拨' <include refid="anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
|
||||||
sum(case when dh.sub_type='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
|
sum(case when dh.sub_type='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
|
||||||
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid="depotParam" /> then di.basic_number else 0 end) as assemInTotal,
|
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid="depotParam" /> then di.basic_number else 0 end) as assemInTotal,
|
||||||
@@ -708,8 +708,8 @@
|
|||||||
|
|
||||||
<select id="getStockByParamWithDepotList" resultMap="stockMap">
|
<select id="getStockByParamWithDepotList" resultMap="stockMap">
|
||||||
select
|
select
|
||||||
sum(case when dh.type='入库' <include refid="depotParam" /> then di.basic_number else 0 end) as inTotal,
|
sum(case when dh.type='入库' <include refid="inOutManageParam" /> <include refid="depotParam" /> then di.basic_number else 0 end) as inTotal,
|
||||||
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as outTotal,
|
sum(case when dh.type='出库' and dh.sub_type!='调拨' <include refid="inOutManageParam" /> <include refid="depotParam" /> then di.basic_number else 0 end) as outTotal,
|
||||||
sum(case when dh.sub_type='调拨' <include refid="anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
|
sum(case when dh.sub_type='调拨' <include refid="anotherDepotParam" /> then di.basic_number else 0 end) as transfInTotal,
|
||||||
sum(case when dh.sub_type='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
|
sum(case when dh.sub_type='调拨' <include refid="depotParam" /> then di.basic_number else 0 end) as transfOutTotal,
|
||||||
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid="depotParam" /> then di.basic_number else 0 end) as assemInTotal,
|
sum(case when dh.sub_type='组装单' and di.material_type='组合件' <include refid="depotParam" /> then di.basic_number else 0 end) as assemInTotal,
|
||||||
@@ -733,6 +733,12 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="inOutManageParam">
|
||||||
|
<if test="inOutManageFlag">
|
||||||
|
and (dh.sub_type!='采购' and dh.sub_type!='采购退货' and dh.sub_type!='销售' and dh.sub_type!='销售退货')
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<sql id="depotParam">
|
<sql id="depotParam">
|
||||||
<if test="depotList.size()>0">
|
<if test="depotList.size()>0">
|
||||||
and di.depot_id in <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">#{item}</foreach>
|
and di.depot_id in <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">#{item}</foreach>
|
||||||
|
|||||||
Reference in New Issue
Block a user