Kaynağa Gözat

优化代码

wuxw 2 yıl önce
ebeveyn
işleme
21d4e5c62c

+ 26 - 62
java110-db/src/main/resources/mapper/report/ReportFeeStatisticsServiceDaoImplMapper.xml

@@ -446,11 +446,9 @@
         select ifnull(sum(t.received_amount),0.0) receivedFee
         from pay_fee_detail t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on pf.payer_obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.create_time > #{startDate}
@@ -462,18 +460,16 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) receivedFee,
         (
         select ifnull(sum(t.received_amount),0.0) preReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.pay_fee_time &gt; #{startDate}
@@ -486,18 +482,16 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) preReceivedFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) hisOweFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.detail_id = '-1'
@@ -509,18 +503,16 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) hisOweFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.cur_month_time &gt;= #{startDate}
@@ -532,18 +524,16 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) curReceivableFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.cur_month_time &gt;= #{startDate}
@@ -556,18 +546,16 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) curReceivedFee,
         (
         select ifnull(sum(t.received_amount),0.0) hisReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         where
         1=1
-        and bu.floor_id = a.floor_id
+        and t.obj_fpc_id = a.floor_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
         and t.pay_fee_time &gt; #{startDate}
@@ -581,7 +569,7 @@
             </foreach>
         </if>
         <if test="feeTypeCd != null and feeTypeCd != ''">
-            and pf.fee_type_cd = #{feeTypeCd}
+            and t.fee_type_cd = #{feeTypeCd}
         </if>
         ) hisReceivedFee
         from f_floor a
@@ -674,14 +662,10 @@
         select ifnull(sum(t.received_amount),0.0) preReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        <if test="floorId != null and floorId != ''">
-            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
-        </if>
         where
         1=1
         <if test="floorId != null and floorId != ''">
-            and bu.floor_id = #{floorId}
+            and t.floor_id = #{floorId}
         </if>
         and t.status_cd = '0'
         and t.community_id= #{communityId}
@@ -695,20 +679,16 @@
                 #{item}
             </foreach>
         </if>
-        and pf.fee_type_cd = a.status_cd
+        and t.fee_type_cd = a.status_cd
         ) preReceivedFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) hisOweFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        <if test="floorId != null and floorId != ''">
-            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
-        </if>
         where
         1=1
         <if test="floorId != null and floorId != ''">
-            and bu.floor_id = #{floorId}
+            and t.floor_id = #{floorId}
         </if>
         and t.status_cd = '0'
         and t.community_id= #{communityId}
@@ -720,20 +700,16 @@
                 #{item}
             </foreach>
         </if>
-        and pf.fee_type_cd = a.status_cd
+        and t.fee_type_cd = a.status_cd
         ) hisOweFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) curReceivableFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        <if test="floorId != null and floorId != ''">
-            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
-        </if>
         where
         1=1
         <if test="floorId != null and floorId != ''">
-            and bu.floor_id = #{floorId}
+            and t.floor_id = #{floorId}
         </if>
         and t.status_cd = '0'
         and t.community_id= #{communityId}
@@ -745,20 +721,16 @@
                 #{item}
             </foreach>
         </if>
-        and pf.fee_type_cd = a.status_cd
+        and t.fee_type_cd = a.status_cd
         ) curReceivableFee,
         (
         select ifnull(sum(t.receivable_amount),0.0) curReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        <if test="floorId != null and floorId != ''">
-            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
-        </if>
         where
         1=1
         <if test="floorId != null and floorId != ''">
-            and bu.floor_id = #{floorId}
+            and t.floor_id = #{floorId}
         </if>
         and t.status_cd = '0'
         and t.community_id= #{communityId}
@@ -771,20 +743,16 @@
                 #{item}
             </foreach>
         </if>
-        and pf.fee_type_cd = a.status_cd
+        and t.fee_type_cd = a.status_cd
         ) curReceivedFee,
         (
         select ifnull(sum(t.received_amount),0.0) hisReceivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        <if test="floorId != null and floorId != ''">
-            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
-            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
-        </if>
         where
         1=1
         <if test="floorId != null and floorId != ''">
-            and bu.floor_id = #{floorId}
+            and t.floor_id = #{floorId}
         </if>
         and t.status_cd = '0'
         and t.community_id= #{communityId}
@@ -798,7 +766,7 @@
                 #{item}
             </foreach>
         </if>
-        and pf.fee_type_cd = a.status_cd
+        and t.fee_type_cd = a.status_cd
         ) hisReceivedFee
         from t_dict a
         where 1=1
@@ -831,23 +799,21 @@
         select ifnull(sum(t.receivable_amount),0.0) hisOweFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
         where  t.status_cd = '0'
         and t.detail_id = '-1'
         and t.community_id= a.community_id
         and t.obj_id = a.obj_id
-        and pfc1.fee_type_cd = pfc.fee_type_cd
+        and t.fee_type_cd = a.fee_type_cd
         and t.cur_month_time &lt; #{endDate}
         ) oweFee,
         (
         select ifnull(sum(t.received_amount),0.0) receivedFee
         from pay_fee_detail t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        inner join pay_fee_config pfc1 on pfc1.config_id = pf.config_id and pfc1.status_cd = '0'
         where pf.payer_obj_id = a.obj_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
-        and pfc1.fee_type_cd = pfc.fee_type_cd
+        and t.fee_type_cd = a.fee_type_cd
         and t.create_time &gt; #{startDate}
         and t.create_time &lt; #{endDate}
         ) receivedFee
@@ -868,24 +834,22 @@
         select ifnull(sum(t.receivable_amount),0.0) hisOweFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
         where 1=1
         and t.status_cd = '0'
         and t.detail_id = '-1'
         and t.community_id= a.community_id
         and t.owner_id = a.owner_id
-        and pfc1.fee_type_cd = pfc.fee_type_cd
+        and t.fee_type_cd = a.fee_type_cd
         and t.cur_month_time &lt; #{endDate}
         ) oweFee,
         (
         select ifnull(sum(t.received_amount),0.0) receivedFee
         from pay_fee_detail_month t
         INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
-        inner join pay_fee_config pfc1 on pfc1.config_id = t.config_id and pfc1.status_cd = '0'
         where t.owner_id = a.owner_id
         and t.status_cd = '0'
         and t.community_id= a.community_id
-        and pfc1.fee_type_cd = pfc.fee_type_cd
+        and t.fee_type_cd = a.fee_type_cd
         and t.pay_fee_time &gt; #{startDate}
         and t.pay_fee_time &lt; #{endDate}
         ) receivedFee