优化账户统计的查询逻辑

This commit is contained in:
季圣华
2023-10-20 00:53:38 +08:00
parent f98406ab04
commit 7bc3ccd183
4 changed files with 97 additions and 110 deletions

View File

@@ -74,6 +74,42 @@
and ifnull(delete_flag,'0') !='1'
</select>
<select id="getAccountSum" resultType="java.math.BigDecimal">
select ifnull(sum(dh.change_amount),0) from jsh_depot_head dh
where 1=1 and dh.pay_type != '预付款'
<if test="accountId != null">
and dh.account_id = #{accountId}
</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'
</if>
and ifnull(dh.delete_flag,'0') !='1'
</select>
<select id="getAccountSumByHead" resultType="java.math.BigDecimal">
select ifnull(sum(ah.change_amount),0) from jsh_account_head ah
where 1=1
<if test="accountId != null">
and ah.account_id = #{accountId}
</if>
<if test="beginTime != null">
and ah.bill_time >= #{beginTime}
</if>
<if test="endTime != null">
and ah.bill_time &lt;= #{endTime}
</if>
<if test="forceFlag">
and ah.status = '1'
</if>
and ifnull(ah.delete_flag,'0') !='1'
</select>
<select id="findAccountInOutList" parameterType="com.jsh.erp.datasource.entities.AccountExample" resultMap="ResultInOutList">
<!--主表出入库涉及的账户 -->
select dh.number,concat(dh.sub_type,dh.type) as newType, 'bill' as fromType, s.supplier,dh.change_amount,date_format(dh.oper_time,'%Y-%m-%d %H:%i:%S') as oTime,'' as AList,'' as AMList