解决库存计算的bug

This commit is contained in:
季圣华
2021-12-08 01:10:15 +08:00
parent 37d526b6bb
commit 0e82eac967
2 changed files with 9 additions and 1 deletions

View File

@@ -650,6 +650,8 @@ public class DepotItemService {
BigDecimal assemOutTotal = stockObj.getAssemOutTotal();
BigDecimal disAssemOutTotal = stockObj.getDisAssemOutTotal();
outSum = outTotal.subtract(transfOutTotal).subtract(assemOutTotal).subtract(disAssemOutTotal);
//取绝对值
outSum = outSum.abs();
}
if(stockCheckSum.compareTo(BigDecimal.ZERO)>0) {
inSum = inSum.add(stockCheckSum);

View File

@@ -328,11 +328,17 @@
</if>
</sql>
<sql id="anotherDepotParam">
<if test="depotList.size()>0">
and di.another_depot_id in <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">#{item}</foreach>
</if>
</sql>
<select id="getStockByParamWithDepotList" resultMap="stockMap">
select
sum(case when dh.type='入库' <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.sub_type='调拨' <include refid="depotParam" /> 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='组装单' 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 assemOutTotal,