bugfix:对账对平

This commit is contained in:
Yuan
2025-11-27 20:48:57 +08:00
parent 10ca4fae06
commit 3f931c2e29
14 changed files with 3072 additions and 30 deletions

View File

@@ -247,22 +247,37 @@
</where>
</select>
<!-- 医保对账:按险种和清算类别分组统计(不限制PayType -->
<!-- 医保对账:按险种和清算类别分组统计(按ReceiptNO去重即HisTransId
1. 医疗总金额MEDFEE_SUMAMT统计同一收据号HisTransId下的自费总额取该收据号的ZFAmount并按组求和
2. 统筹金额FUND_PAY_SUMAMT和账户金额ACCT_PAY只统计PayType为9和10的记录按收据号合并
3. 按HisTransId去重合并统计金额 -->
<select id="findMedicalInsuranceGroupData" parameterType="HashMap" resultType="HashMap">
select
insutype as INSUTYPE,
clr_type as CLR_TYPE,
count(1) as FIXMEDINS_SETL_CNT,
cast(IFNULL(sum(Amount),0) as decimal(19,2)) as MEDFEE_SUMAMT,
cast(IFNULL(sum(ybtcAmount),0) as decimal(19,2)) as FUND_PAY_SUMAMT,
cast(IFNULL(sum(ybzhAmount),0) as decimal(19,2)) as ACCT_PAY
from hisbill_history
where trade_date = #{trade_date}
and insutype is not null
and insutype != ''
and clr_type is not null
and clr_type != ''
group by insutype, clr_type
order by insutype, clr_type
select
t.insutype as INSUTYPE,
t.clr_type as CLR_TYPE,
count(distinct t.HisTransId) as FIXMEDINS_SETL_CNT,
cast(IFNULL(sum(t.ybtc),0) + IFNULL(sum(t.ybzh),0) + IFNULL(sum(t.zf),0) as decimal(19,2)) as MEDFEE_SUMAMT,
cast(IFNULL(sum(t.ybtc),0) as decimal(19,2)) as FUND_PAY_SUMAMT,
cast(IFNULL(sum(t.ybzh),0) as decimal(19,2)) as ACCT_PAY
from (
select
insutype,
clr_type,
HisTransId,
max(cast(IFNULL(ybtcAmount,0) as decimal(19,2))) as ybtc,
max(cast(IFNULL(ybzhAmount,0) as decimal(19,2))) as ybzh,
max(cast(IFNULL(zfAmount,0) as decimal(19,2))) as zf
from hisbill_history
where trade_date = #{trade_date}
and insutype is not null
and insutype != ''
and clr_type is not null
and clr_type != ''
and HisTransId is not null
and HisTransId != ''
group by insutype, clr_type, HisTransId
) as t
group by t.insutype, t.clr_type
order by t.insutype, t.clr_type
</select>
</mapper>
</mapper>