Просмотр исходного кода

优化按时间段缴费逻辑

Your Name лет назад: 2
Родитель
Сommit
159cf1db54

+ 10 - 0
java110-bean/src/main/java/com/java110/dto/reportFee/ReportFeeMonthStatisticsDto.java

@@ -156,6 +156,8 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
 
     private String feeFlag;
 
+    private String preOweAmount;
+
 
     public String getReceivableAmount() {
         return receivableAmount;
@@ -804,4 +806,12 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
     public void setFeeFlag(String feeFlag) {
         this.feeFlag = feeFlag;
     }
+
+    public String getPreOweAmount() {
+        return preOweAmount;
+    }
+
+    public void setPreOweAmount(String preOweAmount) {
+        this.preOweAmount = preOweAmount;
+    }
 }

+ 57 - 104
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -2761,117 +2761,70 @@
 
     <select id="queryHuaningOweFeeCount" parameterType="Map" resultType="Map">
         select count(1) count
-        from (
-        select a.floorNum,a.oweAmount,b.curOweAmount
-        from
-        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
-        from f_floor t
-        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
-        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
-        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
-        rfms.status_cd = '0'
-        where t.status_cd = '0'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
-        <if test="roomNum !=null and roomNum != ''">
-            and br.room_num= #{roomNum}
-        </if>
-        <if test="objName !=null and objName != ''">
-            and rfms.obj_name= #{objName}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and rfms.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and rfms.fee_month= #{feeMonth}
-        </if>
-        GROUP BY t.floor_num
-        ) a,
-        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
-        from f_floor t
-        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
-        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
-        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
-        curT.status_cd = '0' and curT.community_id = t.community_id
-        where t.status_cd = '0'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
-        <if test="roomNum !=null and roomNum != ''">
-            and br.room_num= #{roomNum}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and curT.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and curT.fee_month= #{feeMonth}
-        </if>
-        GROUP BY t.floor_num
-        ) b
-        where a.floorNum = b.floorNum
-        <if test="floorId !=null and floorId != ''">
-            and a.floor_id = #{floorId}
-        </if>
-        ) t
+        from f_floor f
+        where 1=1
+        and f.community_id = #{communityId}
+        and f.status_cd = '0'
+
     </select>
 
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <select id="queryHuaningOweFee" parameterType="Map" resultType="Map">
-        select a.floorNum,a.oweAmount,b.curOweAmount
-        from
-        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
-        from f_floor t
-        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
-        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
-        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
-        rfms.status_cd = '0'
-        where t.status_cd = '0'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
-        <if test="roomNum !=null and roomNum != ''">
-            and br.room_num= #{roomNum}
-        </if>
-        <if test="objName !=null and objName != ''">
-            and rfms.obj_name= #{objName}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and rfms.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and rfms.fee_month= #{feeMonth}
-        </if>
-        GROUP BY t.floor_num
-        ) a,
-        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
-        from f_floor t
-        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
-        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
-        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
-        curT.status_cd = '0' and curT.community_id = t.community_id
-        where t.status_cd = '0'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
-        <if test="roomNum !=null and roomNum != ''">
-            and br.room_num= #{roomNum}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and curT.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and curT.fee_month= #{feeMonth}
+        select
+        f.floor_num floorNum,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
+        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
+        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
+        where
+        1=1
+        and bu.floor_id = f.floor_id
+        and t.community_id = f.community_id
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
         </if>
-        GROUP BY t.floor_num
-        ) b
-        where a.floorNum = b.floorNum
-        <if test="floorId !=null and floorId != ''">
-            and a.floor_id = #{floorId}
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt;= #{endTime}
+        ) oweAmount,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
+        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
+        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
+        where
+        1=1
+        and bu.floor_id = f.floor_id
+        and t.community_id = f.community_id
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
         </if>
-        <if test="page != -1 and page != null ">
-            limit #{page}, #{row}
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt;= #{endTime}
+        and t.cur_month_time &gt;= #{startTime}
+        ) curOweAmount,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
+        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
+        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
+        where
+        1=1
+        and bu.floor_id = f.floor_id
+        and t.community_id = f.community_id
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
         </if>
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt; #{startTime}
+        ) preOweAmount
+        from f_floor f
+        where 1=1
+        and f.community_id = #{communityId}
+        and f.status_cd = '0'
     </select>
 
 

+ 2 - 1
service-report/src/main/java/com/java110/report/api/ReportFeeMonthStatisticsApi.java

@@ -565,7 +565,8 @@ public class ReportFeeMonthStatisticsApi {
         reportFeeMonthStatisticsDto.setFloorNum(floorNum);
         reportFeeMonthStatisticsDto.setPage(page);
         reportFeeMonthStatisticsDto.setRow(row);
-        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
+        reportFeeMonthStatisticsDto.setStartTime(DateUtil.getYear()+"-01-01");
+        reportFeeMonthStatisticsDto.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
         return getReportFeeMonthStatisticsBMOImpl.queryHuaningOweFee(reportFeeMonthStatisticsDto);
     }
 

+ 2 - 9
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java

@@ -832,18 +832,11 @@ public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthSta
 
     @Override
     public ResponseEntity<String> queryHuaningOweFee(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
-        int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFeeCount(reportFeeMonthStatisticsDto);
 
         List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
-        if (count > 0) {
-            reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFee(reportFeeMonthStatisticsDto);
-        } else {
-            reportFeeMonthStatisticsDtos = new ArrayList<>();
-        }
+        reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFee(reportFeeMonthStatisticsDto);
 
-        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportFeeMonthStatisticsDtos);
-
-        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        ResponseEntity<String> responseEntity = ResultVo.createResponseEntity(reportFeeMonthStatisticsDtos);
 
         return responseEntity;
     }