java110 лет назад: 5
Родитель
Сommit
3b620cc00e

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/fee/FeeDto.java

@@ -25,6 +25,7 @@ public class FeeDto extends PageDto implements Serializable {
     public static final String PAYER_OBJ_TYPE_RENTING = "9999";//房源ID
 
     public static final String FEE_FLAG_ONCE = "2006012";
+    public static final String FEE_FLAG_CYCLE = "1003006";
     public static final String REDIS_PAY_OWE_FEE = "PAY_OWE_FEE_";
 
     private String amount;

+ 18 - 0
java110-bean/src/main/java/com/java110/dto/report/ReportFeeDetailDto.java

@@ -25,6 +25,8 @@ public class ReportFeeDetailDto extends PageDto implements Serializable {
     private String endTime;
     private String createTime;
     private String state;
+    private String curStartYear;
+    private String curEndYear;
 
     public String getDetailId() {
         return detailId;
@@ -121,4 +123,20 @@ public class ReportFeeDetailDto extends PageDto implements Serializable {
     public void setState(String state) {
         this.state = state;
     }
+
+    public String getCurStartYear() {
+        return curStartYear;
+    }
+
+    public void setCurStartYear(String curStartYear) {
+        this.curStartYear = curStartYear;
+    }
+
+    public String getCurEndYear() {
+        return curEndYear;
+    }
+
+    public void setCurEndYear(String curEndYear) {
+        this.curEndYear = curEndYear;
+    }
 }

+ 39 - 25
java110-bean/src/main/java/com/java110/po/reportFeeYearCollectionDetail/ReportFeeYearCollectionDetailPo.java

@@ -1,67 +1,81 @@
 package com.java110.po.reportFeeYearCollectionDetail;
 
 import java.io.Serializable;
-import java.util.Date;
 
 public class ReportFeeYearCollectionDetailPo implements Serializable {
 
     private String collectionYear;
-private String relationYear;
-private String detailId;
-private String receivableAmount;
-private String statusCd = "0";
-private String receivedAmount;
-private String communityId;
-private String collectionId;
-public String getCollectionYear() {
+    private String relationYear;
+    private String detailId;
+    private String receivableAmount;
+    private String statusCd = "0";
+    private String receivedAmount;
+    private String communityId;
+    private String collectionId;
+
+    public String getCollectionYear() {
         return collectionYear;
     }
-public void setCollectionYear(String collectionYear) {
+
+    public void setCollectionYear(String collectionYear) {
         this.collectionYear = collectionYear;
     }
-public String getRelationYear() {
+
+    public String getRelationYear() {
         return relationYear;
     }
-public void setRelationYear(String relationYear) {
+
+    public void setRelationYear(String relationYear) {
         this.relationYear = relationYear;
     }
-public String getDetailId() {
+
+    public String getDetailId() {
         return detailId;
     }
-public void setDetailId(String detailId) {
+
+    public void setDetailId(String detailId) {
         this.detailId = detailId;
     }
-public String getReceivableAmount() {
+
+    public String getReceivableAmount() {
         return receivableAmount;
     }
-public void setReceivableAmount(String receivableAmount) {
+
+    public void setReceivableAmount(String receivableAmount) {
         this.receivableAmount = receivableAmount;
     }
-public String getStatusCd() {
+
+    public String getStatusCd() {
         return statusCd;
     }
-public void setStatusCd(String statusCd) {
+
+    public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
-public String getReceivedAmount() {
+
+    public String getReceivedAmount() {
         return receivedAmount;
     }
-public void setReceivedAmount(String receivedAmount) {
+
+    public void setReceivedAmount(String receivedAmount) {
         this.receivedAmount = receivedAmount;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
-public String getCollectionId() {
+
+    public String getCollectionId() {
         return collectionId;
     }
-public void setCollectionId(String collectionId) {
+
+    public void setCollectionId(String collectionId) {
         this.collectionId = collectionId;
     }
 
 
-
 }

+ 9 - 0
java110-db/src/main/resources/mapper/report/ReportFeeServiceDaoImplMapper.xml

@@ -15,6 +15,12 @@
         <if test="endTime != null">
             and t.create_time &lt; #{endTime}
         </if>
+        <if test="curStartYear != null and curStartYear != ''">
+            and DATE_FORMAT(t.start_time,'%Y') = #{curStartYear}
+        </if>
+        <if test="curEndYear != null and curEndYear != ''">
+            and DATE_FORMAT(t.end_time,'%Y') = #{curEndYear}
+        </if>
     </select>
 
     <!-- 查询房屋个数 add by wuxw 2018-07-03 -->
@@ -61,6 +67,9 @@
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>
+        <if test="feeFlag !=null and feeFlag != ''">
+            and t.fee_flag= #{feeFlag}
+        </if>
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>

+ 94 - 95
java110-db/src/main/resources/mapper/report/ReportFeeYearCollectionDetailServiceDaoImplMapper.xml

@@ -5,120 +5,119 @@
 <mapper namespace="reportFeeYearCollectionDetailServiceDaoImpl">
 
 
-
-
-
     <!-- 保存费用年收费明细信息 add by wuxw 2018-07-03 -->
     <insert id="saveReportFeeYearCollectionDetailInfo" parameterType="Map">
         insert into report_fee_year_collection_detail(
-collection_year,relation_year,detail_id,receivable_amount,received_amount,community_id,collection_id
-) values (
-#{collectionYear},#{relationYear},#{detailId},#{receivableAmount},#{receivedAmount},#{communityId},#{collectionId}
-)
+        collection_year,relation_year,detail_id,receivable_amount,received_amount,community_id,collection_id
+        ) values (
+        #{collectionYear},#{relationYear},#{detailId},#{receivableAmount},#{receivedAmount},#{communityId},#{collectionId}
+        )
     </insert>
 
 
-
     <!-- 查询费用年收费明细信息 add by wuxw 2018-07-03 -->
     <select id="getReportFeeYearCollectionDetailInfo" parameterType="Map" resultType="Map">
-        select  t.collection_year,t.collection_year collectionYear,t.relation_year,t.relation_year relationYear,t.detail_id,t.detail_id detailId,t.receivable_amount,t.receivable_amount receivableAmount,t.status_cd,t.status_cd statusCd,t.received_amount,t.received_amount receivedAmount,t.community_id,t.community_id communityId,t.collection_id,t.collection_id collectionId 
-from report_fee_year_collection_detail t 
-where 1 =1 
-<if test="collectionYear !=null and collectionYear != ''">
-   and t.collection_year= #{collectionYear}
-</if> 
-<if test="relationYear !=null and relationYear != ''">
-   and t.relation_year= #{relationYear}
-</if> 
-<if test="detailId !=null and detailId != ''">
-   and t.detail_id= #{detailId}
-</if> 
-<if test="receivableAmount !=null and receivableAmount != ''">
-   and t.receivable_amount= #{receivableAmount}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="receivedAmount !=null and receivedAmount != ''">
-   and t.received_amount= #{receivedAmount}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="collectionId !=null and collectionId != ''">
-   and t.collection_id= #{collectionId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.collection_year,t.collection_year collectionYear,t.relation_year,t.relation_year
+        relationYear,t.detail_id,t.detail_id detailId,t.receivable_amount,t.receivable_amount
+        receivableAmount,t.status_cd,t.status_cd statusCd,t.received_amount,t.received_amount
+        receivedAmount,t.community_id,t.community_id communityId,t.collection_id,t.collection_id collectionId
+        from report_fee_year_collection_detail t
+        where 1 =1
+        <if test="collectionYear !=null and collectionYear != ''">
+            and t.collection_year= #{collectionYear}
+        </if>
+        <if test="relationYear !=null and relationYear != ''">
+            and t.relation_year= #{relationYear}
+        </if>
+        <if test="detailId !=null and detailId != ''">
+            and t.detail_id= #{detailId}
+        </if>
+        <if test="receivableAmount !=null and receivableAmount != ''">
+            and t.receivable_amount= #{receivableAmount}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="receivedAmount !=null and receivedAmount != ''">
+            and t.received_amount= #{receivedAmount}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="collectionId !=null and collectionId != ''">
+            and t.collection_id= #{collectionId}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改费用年收费明细信息 add by wuxw 2018-07-03 -->
     <update id="updateReportFeeYearCollectionDetailInfo" parameterType="Map">
-        update  report_fee_year_collection_detail t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="collectionYear !=null and collectionYear != ''">
-, t.collection_year= #{collectionYear}
-</if> 
-<if test="relationYear !=null and relationYear != ''">
-, t.relation_year= #{relationYear}
-</if> 
-<if test="receivableAmount !=null and receivableAmount != ''">
-, t.receivable_amount= #{receivableAmount}
-</if> 
-<if test="receivedAmount !=null and receivedAmount != ''">
-, t.received_amount= #{receivedAmount}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="collectionId !=null and collectionId != ''">
-, t.collection_id= #{collectionId}
-</if> 
- where 1=1 <if test="detailId !=null and detailId != ''">
-and t.detail_id= #{detailId}
-</if> 
+        update report_fee_year_collection_detail t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="collectionYear !=null and collectionYear != ''">
+            , t.collection_year= #{collectionYear}
+        </if>
+        <if test="relationYear !=null and relationYear != ''">
+            , t.relation_year= #{relationYear}
+        </if>
+        <if test="receivableAmount !=null and receivableAmount != ''">
+            , t.receivable_amount= #{receivableAmount}
+        </if>
+        <if test="receivedAmount !=null and receivedAmount != ''">
+            , t.received_amount= #{receivedAmount}
+        </if>
+
+        <if test="collectionId !=null and collectionId != ''">
+            , t.collection_id= #{collectionId}
+        </if>
+        where 1=1
+        <if test="detailId !=null and detailId != ''">
+            and t.detail_id= #{detailId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
 
     </update>
 
     <!-- 查询费用年收费明细数量 add by wuxw 2018-07-03 -->
-     <select id="queryReportFeeYearCollectionDetailsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from report_fee_year_collection_detail t 
-where 1 =1 
-<if test="collectionYear !=null and collectionYear != ''">
-   and t.collection_year= #{collectionYear}
-</if> 
-<if test="relationYear !=null and relationYear != ''">
-   and t.relation_year= #{relationYear}
-</if> 
-<if test="detailId !=null and detailId != ''">
-   and t.detail_id= #{detailId}
-</if> 
-<if test="receivableAmount !=null and receivableAmount != ''">
-   and t.receivable_amount= #{receivableAmount}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="receivedAmount !=null and receivedAmount != ''">
-   and t.received_amount= #{receivedAmount}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="collectionId !=null and collectionId != ''">
-   and t.collection_id= #{collectionId}
-</if> 
+    <select id="queryReportFeeYearCollectionDetailsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from report_fee_year_collection_detail t
+        where 1 =1
+        <if test="collectionYear !=null and collectionYear != ''">
+            and t.collection_year= #{collectionYear}
+        </if>
+        <if test="relationYear !=null and relationYear != ''">
+            and t.relation_year= #{relationYear}
+        </if>
+        <if test="detailId !=null and detailId != ''">
+            and t.detail_id= #{detailId}
+        </if>
+        <if test="receivableAmount !=null and receivableAmount != ''">
+            and t.receivable_amount= #{receivableAmount}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="receivedAmount !=null and receivedAmount != ''">
+            and t.received_amount= #{receivedAmount}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="collectionId !=null and collectionId != ''">
+            and t.collection_id= #{collectionId}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 27 - 0
java110-interface/src/main/java/com/java110/intf/report/IGeneratorFeeYearStatisticsInnerServiceSMO.java

@@ -0,0 +1,27 @@
+package com.java110.intf.report;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * @ClassName IGeneratorFeeMonthStatisticsInnerServiceSMO
+ * @Description TODO
+ * @Author wuxw
+ * @Date 2020/10/15 21:51
+ * @Version 1.0
+ * add by wuxw 2020/10/15
+ **/
+@FeignClient(name = "report-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/generatorFeeYearStatisticsApi")
+public interface IGeneratorFeeYearStatisticsInnerServiceSMO {
+
+
+
+    @RequestMapping(value = "/generatorData", method = RequestMethod.POST)
+    public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo);
+
+}

+ 434 - 0
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeYearStatisticsInnerServiceSMOImpl.java

@@ -0,0 +1,434 @@
+package com.java110.report.smo.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.RoomDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.report.ReportCarDto;
+import com.java110.dto.report.ReportFeeDetailDto;
+import com.java110.dto.report.ReportFeeDto;
+import com.java110.dto.report.ReportRoomDto;
+import com.java110.dto.reportFeeYearCollection.ReportFeeYearCollectionDto;
+import com.java110.dto.reportFeeYearCollectionDetail.ReportFeeYearCollectionDetailDto;
+import com.java110.intf.report.IGeneratorFeeYearStatisticsInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
+import com.java110.po.reportFeeYearCollection.ReportFeeYearCollectionPo;
+import com.java110.po.reportFeeYearCollectionDetail.ReportFeeYearCollectionDetailPo;
+import com.java110.report.dao.IReportCommunityServiceDao;
+import com.java110.report.dao.IReportFeeServiceDao;
+import com.java110.report.dao.IReportFeeYearCollectionDetailServiceDao;
+import com.java110.report.dao.IReportFeeYearCollectionServiceDao;
+import com.java110.utils.cache.CommonCache;
+import com.java110.utils.util.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * @ClassName GeneratorFeeMonthStatisticsInnerServiceSMOImpl
+ * @Description TODO
+ * @Author wuxw
+ * @Date 2020/10/15 21:53
+ * @Version 1.0
+ * add by wuxw 2020/10/15
+ **/
+@RestController
+public class GeneratorFeeYearStatisticsInnerServiceSMOImpl implements IGeneratorFeeYearStatisticsInnerServiceSMO {
+    private static final Logger logger = LoggerFactory.getLogger(GeneratorFeeYearStatisticsInnerServiceSMOImpl.class);
+
+    //默认 处理房屋数量
+    private static final int DEFAULT_DEAL_ROOM_COUNT = 1000;
+
+    private static final String RECEIVED_TIME = "RECEIVED_TIME";
+    private static final String RECEIVED_TIME_START = "START";
+    private static final String RECEIVED_TIME_END = "END";
+
+    @Autowired
+    private IReportFeeYearCollectionServiceDao reportFeeYearCollectionServiceDaoImpl;
+
+    @Autowired
+    private IReportFeeYearCollectionDetailServiceDao reportFeeYearCollectionDetailServiceDaoImpl;
+
+    @Autowired
+    private IReportCommunityServiceDao reportCommunityServiceDaoImpl;
+
+    @Autowired
+    private IReportFeeServiceDao reportFeeServiceDaoImpl;
+
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Override
+    public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
+
+        doGeneratorData(reportFeeMonthStatisticsPo);
+        return 0;
+    }
+
+    @Async
+    private void doGeneratorData(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
+        String communityId = reportFeeMonthStatisticsPo.getCommunityId();
+
+        Assert.hasLength(communityId, "未包含小区信息");
+
+        //处理房屋费用
+        dealRoomFee(reportFeeMonthStatisticsPo);
+
+        //处理车位费用
+        dealCarFee(reportFeeMonthStatisticsPo);
+
+    }
+
+
+    /**
+     * 处理车位 车辆费用
+     *
+     * @param reportFeeMonthStatisticsPo
+     */
+    private void dealCarFee(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
+
+        int page = 0;
+        int max = DEFAULT_DEAL_ROOM_COUNT;
+
+        ReportCarDto reportCarDto = new ReportCarDto();
+        reportCarDto.setCommunityId(reportFeeMonthStatisticsPo.getCommunityId());
+        int count = reportCommunityServiceDaoImpl.getCarCount(reportCarDto);
+
+
+        if (count < DEFAULT_DEAL_ROOM_COUNT) {
+            page = 1;
+            max = count;
+        } else {
+            page = (int) Math.ceil((double) count / (double) DEFAULT_DEAL_ROOM_COUNT);
+            max = DEFAULT_DEAL_ROOM_COUNT;
+        }
+
+        for (int pageIndex = 0; pageIndex < page; pageIndex++) {
+            reportCarDto.setPage(pageIndex * max);
+            reportCarDto.setRow(max);
+            List<ReportCarDto> reportRoomDtos = reportCommunityServiceDaoImpl.getCarParkingSpace(reportCarDto);
+            for (ReportCarDto tmpReportCarDto : reportRoomDtos) {
+                try {
+                    doDealCarFees(tmpReportCarDto);
+                } catch (Exception e) {
+                    logger.error("生成费用报表失败" + JSONObject.toJSONString(tmpReportCarDto), e);
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 处理 房屋费用
+     *
+     * @param reportFeeMonthStatisticsPo
+     */
+    private void dealRoomFee(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
+
+        int page = 0;
+        int max = DEFAULT_DEAL_ROOM_COUNT;
+
+        ReportRoomDto reportRoomDto = new ReportRoomDto();
+        reportRoomDto.setCommunityId(reportFeeMonthStatisticsPo.getCommunityId());
+        int count = reportCommunityServiceDaoImpl.getRoomCount(reportRoomDto);
+
+
+        if (count < DEFAULT_DEAL_ROOM_COUNT) {
+            page = 1;
+            max = count;
+        } else {
+            page = (int) Math.ceil((double) count / (double) DEFAULT_DEAL_ROOM_COUNT);
+            max = DEFAULT_DEAL_ROOM_COUNT;
+        }
+
+        for (int pageIndex = 0; pageIndex < page; pageIndex++) {
+            reportRoomDto.setPage(pageIndex * max);
+            reportRoomDto.setRow(max);
+            List<ReportRoomDto> reportRoomDtos = reportCommunityServiceDaoImpl.getRoomFloorUnitAndOwner(reportRoomDto);
+            for (ReportRoomDto tmpReportRoomDto : reportRoomDtos) {
+                try {
+                    doDealRoomFees(tmpReportRoomDto);
+                } catch (Exception e) {
+                    logger.error("生成费用报表失败" + JSONObject.toJSONString(tmpReportRoomDto), e);
+                }
+            }
+        }
+    }
+
+    private void doDealCarFees(ReportCarDto tmpReportCarDto) {
+        ReportFeeDto reportFeeDto = new ReportFeeDto();
+        reportFeeDto.setPayerObjId(tmpReportCarDto.getCarId());
+        reportFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
+        //reportFeeDto.setState(FeeDto.STATE_DOING);
+        reportFeeDto.setFeeFlag(FeeDto.FEE_FLAG_CYCLE);
+        List<ReportFeeDto> feeDtos = reportFeeServiceDaoImpl.getFees(reportFeeDto);
+
+        if (feeDtos == null || feeDtos.size() < 1) {
+            return;
+        }
+
+        for (ReportFeeDto tmpReportFeeDto : feeDtos) {
+            try {
+                doDealCarFee(tmpReportCarDto, tmpReportFeeDto);
+            } catch (Exception e) {
+                logger.error("处理房屋费用失败" + JSONObject.toJSONString(tmpReportFeeDto), e);
+            }
+        }
+    }
+
+    private void doDealCarFee(ReportCarDto tmpReportCarDto, ReportFeeDto tmpReportFeeDto) {
+
+        ReportFeeYearCollectionDto reportFeeYearCollectionDto = new ReportFeeYearCollectionDto();
+        reportFeeYearCollectionDto.setCommunityId(tmpReportCarDto.getCommunityId());
+        reportFeeYearCollectionDto.setConfigId(tmpReportFeeDto.getConfigId());
+        reportFeeYearCollectionDto.setObjId(tmpReportFeeDto.getPayerObjId());
+        reportFeeYearCollectionDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeYearCollectionDto.setObjType(tmpReportFeeDto.getPayerObjType());
+        List<ReportFeeYearCollectionDto> statistics = BeanConvertUtil.covertBeanList(
+                reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto)),
+                ReportFeeYearCollectionDto.class);
+
+        ReportFeeYearCollectionPo reportFeeYearCollectionPo = new ReportFeeYearCollectionPo();
+        if (ListUtil.isNull(statistics)) {
+            reportFeeYearCollectionPo.setBuiltUpArea("0");
+            reportFeeYearCollectionPo.setCollectionId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_collectionId));
+            reportFeeYearCollectionPo.setCommunityId(tmpReportFeeDto.getCommunityId());
+            reportFeeYearCollectionPo.setConfigId(tmpReportFeeDto.getConfigId());
+            reportFeeYearCollectionPo.setFeeId(tmpReportFeeDto.getFeeId());
+            reportFeeYearCollectionPo.setObjId(tmpReportCarDto.getCarId());
+            reportFeeYearCollectionPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
+            reportFeeYearCollectionPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+            reportFeeYearCollectionPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "停车场" + tmpReportCarDto.getNum() + "车位)");
+            reportFeeYearCollectionPo.setOwnerId(tmpReportCarDto.getOwnerId());
+            reportFeeYearCollectionPo.setObjName(tmpReportCarDto.getOwnerName());
+            reportFeeYearCollectionPo.setOwnerLink(tmpReportCarDto.getLink());
+
+            //reportFeeYearCollectionPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            reportFeeYearCollectionServiceDaoImpl.saveReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionPo));
+        } else {
+            BeanConvertUtil.covertBean(statistics.get(0), reportFeeYearCollectionPo);
+        }
+
+        //计算费用项开始时间 起始 时间至现在的年份
+        Calendar configStartTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigStartTime());
+
+        int startYear = configStartTime.get(Calendar.YEAR);
+        Calendar configEndTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigEndTime());
+        int endYear = configEndTime.get(Calendar.YEAR);
+        int curYear = Calendar.getInstance().get(Calendar.YEAR);
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, null, tmpReportCarDto);
+        tmpReportFeeDto.setFeePrice(feePrice);
+
+        if (endYear > curYear) {
+            endYear = curYear;
+        }
+
+        for (int year = startYear; year <= endYear; year++) {
+            computeYearFee(year, tmpReportFeeDto, reportFeeYearCollectionPo);
+        }
+
+    }
+
+
+    /**
+     * 处理费用
+     *
+     * @param reportRoomDto
+     */
+    private void doDealRoomFees(ReportRoomDto reportRoomDto) {
+        ReportFeeDto reportFeeDto = new ReportFeeDto();
+        reportFeeDto.setPayerObjId(reportRoomDto.getRoomId());
+        reportFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
+        //reportFeeDto.setState(FeeDto.STATE_DOING);
+        reportFeeDto.setFeeFlag(FeeDto.FEE_FLAG_CYCLE);
+        List<ReportFeeDto> feeDtos = reportFeeServiceDaoImpl.getFees(reportFeeDto);
+
+        if (feeDtos == null || feeDtos.size() < 1) {
+            return;
+        }
+
+        for (ReportFeeDto tmpReportFeeDto : feeDtos) {
+            try {
+                doDealRoomFee(reportRoomDto, tmpReportFeeDto);
+            } catch (Exception e) {
+                logger.error("处理房屋费用失败" + JSONObject.toJSONString(tmpReportFeeDto), e);
+            }
+        }
+
+
+    }
+
+    private void doDealRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto) {
+
+
+        ReportFeeYearCollectionDto reportFeeYearCollectionDto = new ReportFeeYearCollectionDto();
+        reportFeeYearCollectionDto.setCommunityId(reportRoomDto.getCommunityId());
+        reportFeeYearCollectionDto.setConfigId(tmpReportFeeDto.getConfigId());
+        reportFeeYearCollectionDto.setObjId(tmpReportFeeDto.getPayerObjId());
+        reportFeeYearCollectionDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeYearCollectionDto.setObjType(tmpReportFeeDto.getPayerObjType());
+        List<ReportFeeYearCollectionDto> statistics = BeanConvertUtil.covertBeanList(
+                reportFeeYearCollectionServiceDaoImpl.getReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDto)),
+                ReportFeeYearCollectionDto.class);
+
+        ReportFeeYearCollectionPo reportFeeYearCollectionPo = new ReportFeeYearCollectionPo();
+        if (ListUtil.isNull(statistics)) {
+            reportFeeYearCollectionPo.setBuiltUpArea(reportRoomDto.getBuiltUpArea());
+            reportFeeYearCollectionPo.setCollectionId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_collectionId));
+            reportFeeYearCollectionPo.setCommunityId(tmpReportFeeDto.getCommunityId());
+            reportFeeYearCollectionPo.setConfigId(tmpReportFeeDto.getConfigId());
+            reportFeeYearCollectionPo.setFeeId(tmpReportFeeDto.getFeeId());
+            reportFeeYearCollectionPo.setObjId(reportRoomDto.getRoomId());
+            reportFeeYearCollectionPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
+            reportFeeYearCollectionPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+            if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
+                reportFeeYearCollectionPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getUnitNum() + "单元" + reportRoomDto.getRoomNum() + "室");
+            } else {
+                reportFeeYearCollectionPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getRoomNum() + "室");
+            }
+            reportFeeYearCollectionPo.setOwnerId(reportRoomDto.getOwnerId());
+            reportFeeYearCollectionPo.setObjName(reportRoomDto.getOwnerName());
+            reportFeeYearCollectionPo.setOwnerLink(reportRoomDto.getLink());
+
+            //reportFeeYearCollectionPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            reportFeeYearCollectionServiceDaoImpl.saveReportFeeYearCollectionInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionPo));
+        } else {
+            BeanConvertUtil.covertBean(statistics.get(0), reportFeeYearCollectionPo);
+        }
+
+        //计算费用项开始时间 起始 时间至现在的年份
+        Calendar configStartTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigStartTime());
+        int startYear = configStartTime.get(Calendar.YEAR);
+        //结束年
+        Calendar configEndTime = Calendar.getInstance();
+        configStartTime.setTime(tmpReportFeeDto.getConfigEndTime());
+        int endYear = configEndTime.get(Calendar.YEAR);
+
+        //当前年
+        int curYear = Calendar.getInstance().get(Calendar.YEAR);
+
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, null);
+        tmpReportFeeDto.setFeePrice(feePrice);
+
+        if (endYear > curYear) {
+            endYear = curYear;
+        }
+
+        for (int year = startYear; year <= endYear; year++) {
+            computeYearFee(year, tmpReportFeeDto, reportFeeYearCollectionPo);
+        }
+    }
+
+    /**
+     * 计算指定年的数据
+     *
+     * @param year
+     * @param tmpReportFeeDto
+     * @param reportFeeYearCollectionPo
+     */
+    private void computeYearFee(int year, ReportFeeDto tmpReportFeeDto, ReportFeeYearCollectionPo reportFeeYearCollectionPo) {
+        int curYear = Calendar.getInstance().get(Calendar.YEAR);
+
+        ReportFeeYearCollectionDetailDto reportFeeYearCollectionDetailDto = new ReportFeeYearCollectionDetailDto();
+        reportFeeYearCollectionDetailDto.setCollectionId(reportFeeYearCollectionPo.getCollectionId());
+        reportFeeYearCollectionDetailDto.setCommunityId(reportFeeYearCollectionPo.getCommunityId());
+        reportFeeYearCollectionDetailDto.setCollectionYear(year + "");
+
+        List<ReportFeeYearCollectionDetailDto> reportFeeYearCollectionDetailDtos
+                = BeanConvertUtil.covertBeanList(reportFeeYearCollectionDetailServiceDaoImpl.getReportFeeYearCollectionDetailInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDetailDto)),
+                ReportFeeYearCollectionDetailDto.class);
+
+        if (!ListUtil.isNull(reportFeeYearCollectionDetailDtos) && year != curYear) { // 说明已经处理过了 不再处理
+            return;
+        }
+
+        double receivableAmount = getReceivableAmount(tmpReportFeeDto);
+
+        double receivedAmount = getReceivedAmount(tmpReportFeeDto, year);
+
+        ReportFeeYearCollectionDetailPo reportFeeYearCollectionDetailPo = null;
+
+        if (!ListUtil.isNull(reportFeeYearCollectionDetailDtos)) {
+            reportFeeYearCollectionDetailPo = BeanConvertUtil.covertBean(reportFeeYearCollectionDetailDtos.get(0), ReportFeeYearCollectionDetailPo.class);
+            reportFeeYearCollectionDetailPo.setReceivableAmount(receivableAmount + "");
+            reportFeeYearCollectionDetailPo.setReceivedAmount(receivedAmount + "");
+            reportFeeYearCollectionDetailServiceDaoImpl.updateReportFeeYearCollectionDetailInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDetailPo));
+        } else {
+            reportFeeYearCollectionDetailPo = new ReportFeeYearCollectionDetailPo();
+            reportFeeYearCollectionDetailPo.setCollectionId(reportFeeYearCollectionPo.getCollectionId());
+            reportFeeYearCollectionDetailPo.setCommunityId(reportFeeYearCollectionPo.getCommunityId());
+            reportFeeYearCollectionDetailPo.setCollectionYear(year + "");
+            reportFeeYearCollectionDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+            reportFeeYearCollectionDetailPo.setReceivableAmount(receivableAmount + "");
+            reportFeeYearCollectionDetailPo.setReceivedAmount(receivedAmount + "");
+            reportFeeYearCollectionDetailPo.setRelationYear(year + "");
+            reportFeeYearCollectionDetailServiceDaoImpl.saveReportFeeYearCollectionDetailInfo(BeanConvertUtil.beanCovertMap(reportFeeYearCollectionDetailPo));
+        }
+    }
+
+
+    /**
+     * 当月欠费
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
+    private double getReceivableAmount(ReportFeeDto tmpReportFeeDto) {
+
+        //最后一年的处理
+        Calendar configEndTime = Calendar.getInstance();
+        configEndTime.setTime(tmpReportFeeDto.getConfigEndTime());
+        int endYear = configEndTime.get(Calendar.YEAR);
+        int curYear = Calendar.getInstance().get(Calendar.YEAR);
+        double cycleMonth = 12;
+
+        if (endYear == curYear) {
+            try {
+                cycleMonth = computeFeeSMOImpl.dayCompare(DateUtil.getDateFromString(curYear + "-01-01", DateUtil.DATE_FORMATE_STRING_B), tmpReportFeeDto.getConfigEndTime());
+            } catch (ParseException e) {
+                logger.error("计算 时间差出错", e);
+                cycleMonth = configEndTime.get(Calendar.MONTH) + 1;
+            }
+        }
+
+        return new BigDecimal(tmpReportFeeDto.getFeePrice()).multiply(new BigDecimal(cycleMonth)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+
+    }
+
+    /**
+     * 获取当年实收
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
+    private double getReceivedAmount(ReportFeeDto tmpReportFeeDto, int year) {
+        ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
+        feeDetailDto.setFeeId(tmpReportFeeDto.getFeeId());
+        String flag = CommonCache.getValue(RECEIVED_TIME);
+        if (RECEIVED_TIME_START.equals(flag)) {
+            feeDetailDto.setStartTime(year + "");
+        } else {
+            feeDetailDto.setEndTime(year + "");
+        }
+        double receivedAmount = reportFeeServiceDaoImpl.getFeeReceivedAmount(feeDetailDto);
+
+        return receivedAmount;
+    }
+
+}