From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml |   58 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
index d1c40f9..4f3b5c3 100755
--- a/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -956,7 +956,7 @@
      and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0
      -->
     <select id="queryFeeBreakdown" parameterType="Map" resultType="Map">
-        select t.fee_name feeName,td.name feeTypeCd,pfc.fee_type_cd,SUM(t.his_owe_amount)
+        select t.fee_name feeName,td.name feeTypeCd,pfc.fee_type_cd,t.config_id configId,SUM(t.his_owe_amount)
         hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
         SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
         hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
@@ -1440,6 +1440,7 @@
         <if test="endTime !=null and endTime != ''">
             and t.create_time &lt;= #{endTime}
         </if>
+        and t.amount_owed > 0
         group by t.fee_name,t.payer_obj_id,t.payer_obj_name
         HAVING oweAmount > 0
         ) t
@@ -1491,6 +1492,7 @@
         <if test="endTime !=null and endTime != ''">
             and t.create_time &lt;= #{endTime}
         </if>
+        and t.amount_owed > 0
         group by t.fee_name,t.payer_obj_id,t.payer_obj_name,pfa.`value`,br.built_up_area
         HAVING oweAmount > 0
         order by t.payer_obj_name
@@ -2270,33 +2272,61 @@
     </select>
 
     <select id="getReceivableInformation" parameterType="Map" resultType="Map">
-        select sum(t.receivable_amount) receivableAmount,SUM(t.received_amount) receivedAmount,SUM(t.owe_amount)
-        oweAmount
+        select a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
+        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
+        from (
+        select sum(t.his_owe_amount+t.cur_receivable_amount)
+        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
+        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
         from report_fee_month_statistics t
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        where t.community_id = #{communityId}
+        where 1=1
+        and t.fee_year= #{feeYear}
+        and t.fee_month= #{feeMonth}
+        and t.community_id = #{communityId}
+        ) a
     </select>
 
     <select id="getFloorReceivableInformation" parameterType="Map" resultType="Map">
-        select f.floor_num floorNum,f.`name`,sum(t.receivable_amount) receivableAmount,SUM(t.received_amount)
-        receivedAmount,SUM(t.owe_amount) oweAmount
+        select a.floorNum,a.`name`,a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
+        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
+        from (
+        select f.floor_num floorNum,f.`name`,sum(t.his_owe_amount+t.cur_receivable_amount)
+        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
+        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
         from report_fee_month_statistics t
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
         inner join building_room br on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
         t.community_id and br.status_cd = '0'
         inner join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
         inner join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
-        where t.community_id = #{communityId}
+        where 1=1
+        and t.fee_year= #{feeYear}
+        and t.fee_month= #{feeMonth}
+        and t.community_id = #{communityId}
         group by f.floor_num ,f.`name`
+        ) a
     </select>
 
     <select id="getFeeConfigReceivableInformation" parameterType="Map" resultType="Map">
-        select t.fee_name feeName,sum(t.receivable_amount) receivableAmount,SUM(t.received_amount)
-        receivedAmount,SUM(t.owe_amount) oweAmount
+        select a.feeName,a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
+        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
+        from (
+        select t.fee_name feeName,sum(t.his_owe_amount+t.cur_receivable_amount)
+        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
+        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
         from report_fee_month_statistics t
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        where t.community_id = #{communityId}
+        left join building_room br on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
+        t.community_id and br.status_cd = '0'
+        left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
+        left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
+        where 1=1
+        and t.fee_year= #{feeYear}
+        and t.fee_month= #{feeMonth}
+        and t.community_id = #{communityId}
         group by t.fee_name
+        ) a
     </select>
 
 
@@ -2610,6 +2640,12 @@
         </if>
         <if test="objName !=null and objName != ''">
             and rfms.obj_name= #{objName}
+        </if>
+        <if test="feeYear !=null and feeYear != ''">
+            and t.fee_year= #{feeYear}
+        </if>
+        <if test="feeMonth !=null and feeMonth != ''">
+            and t.fee_month= #{feeMonth}
         </if>
         GROUP BY t.floor_num
         ) a,
@@ -2994,7 +3030,7 @@
 
     <!--娓呯悊鎶ヨ〃 鏃犳晥鏁版嵁-->
     <update id="deleteInvalidFee" parameterType="Map">
-        delete from report_fee_month_statistics where fee_id  in
+        delete from report_fee_month_statistics where fee_id in
         <foreach collection="feeIds" item="item" open="(" close=")" separator=",">
             #{item}
         </foreach>

--
Gitblit v1.8.0