java110 лет назад: 2
Родитель
Сommit
d85d68e2bf

+ 152 - 0
java110-db/src/main/resources/mapper/report/ReportFeeStatisticsServiceDaoImplMapper.xml

@@ -344,5 +344,157 @@
     </select>
 
 
+    <select id="getFloorFeeSummary" parameterType="Map" resultType="Map">
+
+        select a.floor_id floorId,a.floor_num floorNum,
+        (
+        select count(1) from (
+        select t.obj_id 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.status_cd = '0'
+        and pf.payer_obj_type = '3333'
+        and t.community_id= a.community_id
+        and t.cur_month_time &lt; #{endDate}
+        and (t.receivable_amount - t.received_amount - t.discount_amount) > 0
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
+        </if>
+        group by t.obj_id) b
+        ) oweRoomCount,-- 欠费户
+        (
+        select count(1) from (
+        select t.obj_id
+        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.status_cd = '0'
+        and pf.payer_obj_type = '3333'
+        and t.community_id= a.community_id
+        and t.cur_month_time &lt; #{endDate}
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
+        </if>
+        group by t.obj_id) b
+        ) feeRoomCount, -- 收费户
+        (
+        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'
+        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.status_cd = '0'
+        and t.community_id= a.community_id
+        and t.pay_fee_time &gt; #{startDate}
+        and t.pay_fee_time &lt; #{endDate}
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.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.status_cd = '0'
+        and t.community_id= a.community_id
+        and t.pay_fee_time &gt; #{startDate}
+        and t.pay_fee_time &lt; #{endDate}
+        and t.cur_month_time &gt; #{endDate}
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
+        </if>
+        ) preReceivedFee, -- 预收
+        (
+        select ifnull(sum(t.receivable_amount - t.received_amount - t.discount_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.status_cd = '0'
+        and t.community_id= a.community_id
+        and t.cur_month_time &lt; #{startDate}
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.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.status_cd = '0'
+        and t.community_id= a.community_id
+        and t.cur_month_time  &gt; #{startDate}
+        and t.cur_month_time &lt; #{endDate}
+        <if test="configIds !=null ">
+            and t.config_id in
+            <foreach collection="configIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
+        </if>
+        ) curReceivableFee -- 当期应收
+        from f_floor a
+        where 1=1
+        and a.status_cd = '0'
+        and a.community_id = #{communityId}
+        order by a.seq
+    </select>
+
 
 </mapper>

+ 14 - 0
java110-interface/src/main/java/com/java110/intf/report/IReportFeeStatisticsInnerServiceSMO.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName IReportFeeStatisticsInnerServiceSMO
@@ -36,6 +37,7 @@ public interface IReportFeeStatisticsInnerServiceSMO {
 
     /**
      * 查询当月欠费
+     *
      * @param queryFeeStatisticsDto
      * @return
      */
@@ -45,6 +47,7 @@ public interface IReportFeeStatisticsInnerServiceSMO {
 
     /**
      * 查询当月应收
+     *
      * @param queryStatisticsDto
      * @return
      */
@@ -62,6 +65,7 @@ public interface IReportFeeStatisticsInnerServiceSMO {
 
     /**
      * 欠费户数
+     *
      * @param queryStatisticsDto
      * @return
      */
@@ -70,9 +74,19 @@ public interface IReportFeeStatisticsInnerServiceSMO {
 
     /**
      * 查询收费房屋数
+     *
      * @param queryStatisticsDto
      * @return
      */
     @RequestMapping(value = "/getFeeRoomCount", method = RequestMethod.POST)
     long getFeeRoomCount(@RequestBody QueryStatisticsDto queryStatisticsDto);
+
+    /**
+     * 楼栋收费率信息统计
+     *
+     * @param queryStatisticsDto
+     * @return
+     */
+    @RequestMapping(value = "/getFloorFeeSummary", method = RequestMethod.POST)
+    List<Map> getFloorFeeSummary(@RequestBody QueryStatisticsDto queryStatisticsDto);
 }

+ 86 - 0
service-report/src/main/java/com/java110/report/cmd/reportFeeMonthStatistics/QueryReportFloorFeeSummaryCmd.java

@@ -0,0 +1,86 @@
+package com.java110.report.cmd.reportFeeMonthStatistics;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.report.QueryStatisticsDto;
+import com.java110.report.statistics.IFeeStatistics;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 楼栋费用统计
+ */
+@Java110Cmd(serviceCode = "reportFeeMonthStatistics.queryReportFloorFeeSummary")
+public class QueryReportFloorFeeSummaryCmd extends Cmd {
+
+    @Autowired
+    private IFeeStatistics feeStatisticsImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        Assert.hasKeyAndValue(reqJson, "startDate", "未包含开始日期");
+        Assert.hasKeyAndValue(reqJson, "endDate", "未包含结束日期");
+        Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        QueryStatisticsDto queryStatisticsDto = new QueryStatisticsDto();
+        queryStatisticsDto.setCommunityId(reqJson.getString("communityId"));
+        queryStatisticsDto.setStartDate(reqJson.getString("startDate"));
+        queryStatisticsDto.setEndDate(reqJson.getString("endDate"));
+        queryStatisticsDto.setFeeTypeCd(reqJson.getString("feeTypeCd"));
+        if(reqJson.containsKey("configIds")){
+            queryStatisticsDto.setConfigIds(reqJson.getString("configIds").split(","));
+        }
+
+        List<Map> datas = feeStatisticsImpl.getFloorFeeSummary(queryStatisticsDto);
+
+        if(datas == null || datas.size() < 1){
+            context.setResponseEntity(ResultVo.createResponseEntity(datas));
+            return;
+        }
+        BigDecimal feeRoomCountDec = null;
+        BigDecimal oweRoomCountDec = null;
+        BigDecimal feeRoomRate = null;
+        BigDecimal hisOweFee = null;
+        BigDecimal curReceivableFee = null;
+        BigDecimal receivedFee = null;
+        BigDecimal preReceivedFee = null;
+        for(Map data:datas){
+            //todo 计算 户收费率
+            if(Double.parseDouble(data.get("feeRoomCount").toString())>0){
+                feeRoomCountDec = new BigDecimal(Double.parseDouble(data.get("feeRoomCount").toString()));
+                oweRoomCountDec = new BigDecimal(Double.parseDouble(data.get("oweRoomCount").toString()));
+                feeRoomRate = feeRoomCountDec.subtract(oweRoomCountDec).divide(feeRoomCountDec).multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP);
+                data.put("feeRoomRate",feeRoomRate.doubleValue());
+            }else{
+                data.put("feeRoomRate",0.0);
+            }
+
+            //todo 计算 收费率
+            hisOweFee = new BigDecimal(Double.parseDouble(data.get("hisOweFee").toString()));
+            curReceivableFee = new BigDecimal(Double.parseDouble(data.get("curReceivableFee").toString()));
+            hisOweFee = curReceivableFee.add(hisOweFee);
+
+            if(hisOweFee.doubleValue()> 0){
+                receivedFee = new BigDecimal(Double.parseDouble(data.get("receivedFee").toString()));
+                preReceivedFee = new BigDecimal(Double.parseDouble(data.get("preReceivedFee").toString()));
+                feeRoomRate = receivedFee.subtract(preReceivedFee).divide(hisOweFee).multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP);
+                data.put("feeRate",feeRoomRate.doubleValue());
+            }else{
+                data.put("feeRate",0.0);
+            }
+        }
+    }
+}

+ 8 - 0
service-report/src/main/java/com/java110/report/dao/IReportFeeStatisticsServiceDao.java

@@ -1,5 +1,6 @@
 package com.java110.report.dao;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -66,4 +67,11 @@ public interface IReportFeeStatisticsServiceDao {
      * @return
      */
     int getFeeRoomCount(Map info);
+
+    /**
+     * 统计楼栋 收费率信息
+     * @param info
+     * @return
+     */
+    List<Map> getFloorFeeSummary(Map info);
 }

+ 10 - 0
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeStatisticsServiceDaoImpl.java

@@ -147,5 +147,15 @@ public class ReportFeeStatisticsServiceDaoImpl extends BaseServiceDao implements
         return Integer.parseInt(infos.get(0).get("feeRoomCount").toString());
     }
 
+    @Override
+    public List<Map> getFloorFeeSummary(Map info) {
+        logger.debug("查询 楼栋收费率 入参 info : {}", JSONObject.toJSONString(info));
+
+        List<Map> infos = sqlSessionTemplate.selectList("reportFeeStatisticsServiceDaoImpl.getFloorFeeSummary", info);
+
+
+        return infos;
+    }
+
 
 }

+ 17 - 0
service-report/src/main/java/com/java110/report/smo/impl/ReportFeeStatisticsInnerServiceSMOImpl.java

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -46,6 +47,7 @@ public class ReportFeeStatisticsInnerServiceSMOImpl extends BaseServiceSMO imple
 
     /**
      * 查询当月应收
+     *
      * @param queryStatisticsDto
      * @return
      */
@@ -75,6 +77,7 @@ public class ReportFeeStatisticsInnerServiceSMOImpl extends BaseServiceSMO imple
 
     /**
      * 查询欠费户数
+     *
      * @param queryStatisticsDto
      * @return
      */
@@ -86,6 +89,7 @@ public class ReportFeeStatisticsInnerServiceSMOImpl extends BaseServiceSMO imple
 
     /**
      * 查询收费房屋数
+     *
      * @param queryStatisticsDto
      * @return
      */
@@ -94,4 +98,17 @@ public class ReportFeeStatisticsInnerServiceSMOImpl extends BaseServiceSMO imple
         int info = reportFeeStatisticsServiceDaoImpl.getFeeRoomCount(BeanConvertUtil.beanCovertMap(queryStatisticsDto));
         return info;
     }
+
+    /**
+     * 楼栋收费率信息统计
+     *
+     * @param queryStatisticsDto
+     * @return
+     */
+    @Override
+    public List<Map> getFloorFeeSummary(QueryStatisticsDto queryStatisticsDto) {
+
+        List<Map> info = reportFeeStatisticsServiceDaoImpl.getFloorFeeSummary(BeanConvertUtil.beanCovertMap(queryStatisticsDto));
+        return info;
+    }
 }

+ 10 - 0
service-report/src/main/java/com/java110/report/statistics/IFeeStatistics.java

@@ -3,6 +3,9 @@ package com.java110.report.statistics;
 
 import com.java110.dto.report.QueryStatisticsDto;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 费用统计类
  */
@@ -64,4 +67,11 @@ public interface IFeeStatistics {
      * @return
      */
     long getFeeRoomCount(QueryStatisticsDto queryStatisticsDto);
+
+    /**
+     * 查询楼栋费用统计信息
+     * @param queryStatisticsDto
+     * @return
+     */
+    List<Map> getFloorFeeSummary(QueryStatisticsDto queryStatisticsDto);
 }

+ 13 - 0
service-report/src/main/java/com/java110/report/statistics/impl/FeeStatisticsImpl.java

@@ -6,6 +6,9 @@ import com.java110.report.statistics.IFeeStatistics;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 基础报表统计 实现类
  */
@@ -90,4 +93,14 @@ public class FeeStatisticsImpl implements IFeeStatistics {
         return reportFeeStatisticsInnerServiceSMOImpl.getFeeRoomCount(queryStatisticsDto);
     }
 
+    /**
+     * 楼栋收费率信息统计
+     * @param queryStatisticsDto
+     * @return
+     */
+    @Override
+    public List<Map> getFloorFeeSummary(QueryStatisticsDto queryStatisticsDto) {
+        return reportFeeStatisticsInnerServiceSMOImpl.getFloorFeeSummary(queryStatisticsDto);
+    }
+
 }