优化首页的统计接口,提高查询速度

This commit is contained in:
jishenghua
2024-04-27 00:58:11 +08:00
parent 4fe3408a25
commit a6334c7345
9 changed files with 233 additions and 212 deletions

View File

@@ -1086,26 +1086,12 @@
and ifnull(delete_flag,'0') !='1'
</select>
<select id="getBuyAndSaleBasicStatistics" resultType="java.math.BigDecimal">
select
ifnull(sum(discount_last_money),0) from
(select distinct dh.id, dh.discount_last_money
<select id="getBuyAndSaleStatisticsList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
from jsh_depot_head dh
left join jsh_depot_item di on dh.id = di.header_id
where 1=1
and di.id is not null
<if test="type != null">
and dh.type=#{type}
</if>
<if test="subType != null">
and dh.sub_type=#{subType}
</if>
<if test="hasSupplier == 1">
and dh.organ_id is not null
</if>
<if test="hasSupplier == 0">
and dh.organ_id is null
</if>
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') !='1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
<if test="beginTime != null">
and dh.oper_time >= #{beginTime}
</if>
@@ -1123,41 +1109,6 @@
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1') tb
</select>
<select id="getBuyAndSaleRetailStatistics" resultType="java.math.BigDecimal">
select
ifnull(sum(total_price),0) from
(select distinct dh.id, dh.total_price
from jsh_depot_head dh
left join jsh_depot_item di on dh.id = di.header_id
where 1=1
and di.id is not null
<if test="type != null">
and dh.type=#{type}
</if>
<if test="subType != null">
and dh.sub_type=#{subType}
</if>
<if test="beginTime != null">
and dh.oper_time >= #{beginTime}
</if>
<if test="endTime != null">
and dh.oper_time &lt;= #{endTime}
</if>
<if test="forceFlag">
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1') tb
</select>
<select id="debtList" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="ResultMapEx">

View File

@@ -631,14 +631,12 @@
</if>
</select>
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
select ifnull(sum(discount_last_money),0) as allMoney from
(select distinct dh.id, dh.discount_last_money
<select id="inOrOutPriceList" resultType="com.jsh.erp.datasource.vo.InOutPriceVo">
select distinct dh.id, dh.discount_last_money, dh.total_price, dh.type, dh.sub_type, dh.oper_time
from jsh_depot_head dh
left join jsh_depot_item di on dh.id = di.header_id
where 1=1
and di.id is not null
and dh.type=#{type} and dh.sub_type=#{subType}
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') != '1'
where di.id is not null
and (dh.type='入库' or dh.type='出库')
and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime}
<if test="forceFlag">
@@ -651,32 +649,7 @@
</foreach>
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag, '0') != '1') tb
</select>
<select id="inOrOutRetailPrice" resultType="java.math.BigDecimal">
select ifnull(sum(total_price),0) as allMoney from
(select distinct dh.id, dh.total_price
from jsh_depot_head dh
left join jsh_depot_item di on dh.id = di.header_id
where 1=1
and di.id is not null
and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime}
<if test="forceFlag">
and (dh.status = '1' or dh.status = '2' or dh.status = '3')
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag, '0') != '1') tb
and ifnull(dh.delete_flag,'0') != '1'
</select>
<select id="getSkuStockCheckSumByDepotList" resultType="java.math.BigDecimal">
@@ -1102,4 +1075,5 @@
order by dh.id desc, di.id desc
limit 0,1
</select>
</mapper>