解决出入库统计报表计算的bug
This commit is contained in:
@@ -531,8 +531,8 @@ public class DepotItemController {
|
|||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BigDecimal inSumPriceTotal = depotItemService.buyOrSale("入库", "采购", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal inSumPriceTotal = depotItemService.buyOrSalePriceTotal("入库", "采购", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal outSumPriceTotal = depotItemService.buyOrSale("出库", "采购退货", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal outSumPriceTotal = depotItemService.buyOrSalePriceTotal("出库", "采购退货", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal realityPriceTotal = inSumPriceTotal.subtract(outSumPriceTotal);
|
BigDecimal realityPriceTotal = inSumPriceTotal.subtract(outSumPriceTotal);
|
||||||
map.put("rows", dataArray);
|
map.put("rows", dataArray);
|
||||||
map.put("realityPriceTotal", realityPriceTotal);
|
map.put("realityPriceTotal", realityPriceTotal);
|
||||||
@@ -615,8 +615,8 @@ public class DepotItemController {
|
|||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BigDecimal outSumPriceTotal = depotItemService.buyOrSale("出库", "零售", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal outSumPriceTotal = depotItemService.buyOrSalePriceTotal("出库", "零售", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal inSumPriceTotal = depotItemService.buyOrSale("入库", "零售退货", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal inSumPriceTotal = depotItemService.buyOrSalePriceTotal("入库", "零售退货", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal realityPriceTotal = outSumPriceTotal.subtract(inSumPriceTotal);
|
BigDecimal realityPriceTotal = outSumPriceTotal.subtract(inSumPriceTotal);
|
||||||
map.put("rows", dataArray);
|
map.put("rows", dataArray);
|
||||||
map.put("realityPriceTotal", realityPriceTotal);
|
map.put("realityPriceTotal", realityPriceTotal);
|
||||||
@@ -700,8 +700,8 @@ public class DepotItemController {
|
|||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BigDecimal outSumPriceTotal = depotItemService.buyOrSale("出库", "销售", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal outSumPriceTotal = depotItemService.buyOrSalePriceTotal("出库", "销售", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal inSumPriceTotal = depotItemService.buyOrSale("入库", "销售退货", null, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag, "price");
|
BigDecimal inSumPriceTotal = depotItemService.buyOrSalePriceTotal("入库", "销售退货", StringUtil.toNull(materialParam), beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
BigDecimal realityPriceTotal = outSumPriceTotal.subtract(inSumPriceTotal);
|
BigDecimal realityPriceTotal = outSumPriceTotal.subtract(inSumPriceTotal);
|
||||||
map.put("rows", dataArray);
|
map.put("rows", dataArray);
|
||||||
map.put("realityPriceTotal", realityPriceTotal);
|
map.put("realityPriceTotal", realityPriceTotal);
|
||||||
|
|||||||
@@ -121,6 +121,18 @@ public interface DepotItemMapperEx {
|
|||||||
@Param("forceFlag") Boolean forceFlag,
|
@Param("forceFlag") Boolean forceFlag,
|
||||||
@Param("sumType") String sumType);
|
@Param("sumType") String sumType);
|
||||||
|
|
||||||
|
BigDecimal buyOrSalePriceTotal(
|
||||||
|
@Param("type") String type,
|
||||||
|
@Param("subType") String subType,
|
||||||
|
@Param("materialParam") String materialParam,
|
||||||
|
@Param("beginTime") String beginTime,
|
||||||
|
@Param("endTime") String endTime,
|
||||||
|
@Param("creatorArray") String[] creatorArray,
|
||||||
|
@Param("organId") Long organId,
|
||||||
|
@Param("organArray") String [] organArray,
|
||||||
|
@Param("depotList") List<Long> depotList,
|
||||||
|
@Param("forceFlag") Boolean forceFlag);
|
||||||
|
|
||||||
BigDecimal inOrOutPrice(
|
BigDecimal inOrOutPrice(
|
||||||
@Param("type") String type,
|
@Param("type") String type,
|
||||||
@Param("subType") String subType,
|
@Param("subType") String subType,
|
||||||
|
|||||||
@@ -354,6 +354,17 @@ public class DepotItemService {
|
|||||||
JshException.readFail(logger, e);
|
JshException.readFail(logger, e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal buyOrSalePriceTotal(String type, String subType, String materialParam, String beginTime, String endTime,
|
||||||
|
String[] creatorArray, Long organId, String [] organArray, List<Long> depotList, Boolean forceFlag) throws Exception{
|
||||||
|
BigDecimal result= BigDecimal.ZERO;
|
||||||
|
try{
|
||||||
|
result= depotItemMapperEx.buyOrSalePriceTotal(type, subType, materialParam, beginTime, endTime, creatorArray, organId, organArray, depotList, forceFlag);
|
||||||
|
}catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -417,7 +417,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findInOutDetailStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
<select id="findInOutDetailStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
||||||
select sum(di.oper_number) operNumber, sum(di.all_price) allPrice
|
select ifnull(sum(di.oper_number),0) operNumber, ifnull(sum(di.all_price),0) allPrice
|
||||||
from jsh_depot_head dh
|
from jsh_depot_head dh
|
||||||
left join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
|
left join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
|
||||||
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
||||||
@@ -610,7 +610,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findInOutMaterialCountStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultInOutMaterialCount">
|
<select id="findInOutMaterialCountStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultInOutMaterialCount">
|
||||||
select sum(di.basic_number) numSum, sum(di.all_price) priceSum
|
select ifnull(sum(di.basic_number),0) numSum, ifnull(sum(di.all_price),0) priceSum
|
||||||
from jsh_depot_head dh
|
from jsh_depot_head dh
|
||||||
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
||||||
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
||||||
@@ -780,7 +780,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findAllocationStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
<select id="findAllocationStatistic" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
||||||
select sum(di.oper_number) operNumber, sum(di.all_price) allPrice
|
select ifnull(sum(di.oper_number),0) operNumber, ifnull(sum(di.all_price),0) allPrice
|
||||||
from jsh_depot_head dh
|
from jsh_depot_head dh
|
||||||
left join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
|
left join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
|
||||||
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
|||||||
@@ -589,6 +589,48 @@
|
|||||||
and ifnull(di.delete_flag,'0') !='1'
|
and ifnull(di.delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="buyOrSalePriceTotal" resultType="java.math.BigDecimal">
|
||||||
|
select ifnull(sum(di.all_price),0) as AllPrice
|
||||||
|
from jsh_depot_item di
|
||||||
|
left join jsh_depot_head dh on dh.id=di.header_id and ifnull(dh.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_Flag,'0') !='1'
|
||||||
|
where ifnull(di.delete_flag,'0') !='1'
|
||||||
|
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||||
|
and dh.oper_time >= #{beginTime}
|
||||||
|
and dh.oper_time <= #{endTime}
|
||||||
|
<if test="materialParam != null and materialParam !=''">
|
||||||
|
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||||
|
</if>
|
||||||
|
<if test="creatorArray != null">
|
||||||
|
and dh.creator in (
|
||||||
|
<foreach collection="creatorArray" item="creator" separator=",">
|
||||||
|
#{creator}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="organId != null">
|
||||||
|
and dh.organ_id = #{organId}
|
||||||
|
</if>
|
||||||
|
<if test="organArray != null and organArray !=''">
|
||||||
|
and dh.organ_id in (
|
||||||
|
<foreach collection="organArray" item="organId" separator=",">
|
||||||
|
#{organId}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="depotList.size()>0">
|
||||||
|
and di.depot_id in
|
||||||
|
<foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="forceFlag">
|
||||||
|
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
|
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
|
||||||
select ifnull(sum(discount_last_money),0) as allMoney from
|
select ifnull(sum(discount_last_money),0) as allMoney from
|
||||||
(select distinct dh.id, dh.discount_last_money
|
(select distinct dh.id, dh.discount_last_money
|
||||||
|
|||||||
Reference in New Issue
Block a user