java110
2020-10-16 3d7a4912e2408f1dd06a82d99f255ae15650180b
优化加入报表基础生成表
11个文件已修改
3个文件已添加
1263 ■■■■ 已修改文件
java110-bean/src/main/java/com/java110/dto/report/ReportCarDto.java 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/report/ReportFeeDetailDto.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/report/ReportCommunityServiceDaoImplMapper.xml 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml 371 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/report/ReportFeeServiceDaoImplMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-utils/src/main/java/com/java110/utils/util/ListUtil.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/IReportCommunityServiceDao.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/IReportFeeMonthStatisticsServiceDao.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/IReportFeeServiceDao.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/impl/ReportCommunityServiceDaoImpl.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeMonthStatisticsServiceDaoImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeServiceDaoImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java 306 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/report/ReportCarDto.java
New file
@@ -0,0 +1,171 @@
package com.java110.dto.report;
import com.java110.dto.PageDto;
import java.io.Serializable;
/**
 * @ClassName ReportRoomDto
 * @Description TODO
 * @Author wuxw
 * @Date 2020/10/15 22:20
 * @Version 1.0
 * add by wuxw 2020/10/15
 **/
public class ReportCarDto extends PageDto implements Serializable {
    private String carId;
    private String ownerId;
    private String carNum;
    private String carBrand;
    private String carType;
    private String carColor;
    private String ownerName;
    private String idCard;
    private String link;
    private String state;
    private String stateName;
    private String unitNum;
    private String num;
    private String psId;
    private String paId;
    private String areaNum;
    private String communityId;
    public String getCarId() {
        return carId;
    }
    public void setCarId(String carId) {
        this.carId = carId;
    }
    public String getOwnerId() {
        return ownerId;
    }
    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }
    public String getCarNum() {
        return carNum;
    }
    public void setCarNum(String carNum) {
        this.carNum = carNum;
    }
    public String getCarBrand() {
        return carBrand;
    }
    public void setCarBrand(String carBrand) {
        this.carBrand = carBrand;
    }
    public String getCarType() {
        return carType;
    }
    public void setCarType(String carType) {
        this.carType = carType;
    }
    public String getCarColor() {
        return carColor;
    }
    public void setCarColor(String carColor) {
        this.carColor = carColor;
    }
    public String getOwnerName() {
        return ownerName;
    }
    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }
    public String getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getLink() {
        return link;
    }
    public void setLink(String link) {
        this.link = link;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public String getStateName() {
        return stateName;
    }
    public void setStateName(String stateName) {
        this.stateName = stateName;
    }
    public String getUnitNum() {
        return unitNum;
    }
    public void setUnitNum(String unitNum) {
        this.unitNum = unitNum;
    }
    public String getNum() {
        return num;
    }
    public void setNum(String num) {
        this.num = num;
    }
    public String getPsId() {
        return psId;
    }
    public void setPsId(String psId) {
        this.psId = psId;
    }
    public String getPaId() {
        return paId;
    }
    public void setPaId(String paId) {
        this.paId = paId;
    }
    public String getAreaNum() {
        return areaNum;
    }
    public void setAreaNum(String areaNum) {
        this.areaNum = areaNum;
    }
    public String getCommunityId() {
        return communityId;
    }
    public void setCommunityId(String communityId) {
        this.communityId = communityId;
    }
}
java110-bean/src/main/java/com/java110/dto/report/ReportFeeDetailDto.java
New file
@@ -0,0 +1,124 @@
package com.java110.dto.report;
import com.java110.dto.PageDto;
import java.io.Serializable;
/**
 * @ClassName ReportRoomDto
 * @Description TODO
 * @Author wuxw
 * @Date 2020/10/15 22:20
 * @Version 1.0
 * add by wuxw 2020/10/15
 **/
public class ReportFeeDetailDto extends PageDto implements Serializable {
    private String detailId;
    private String feeId;
    private String communityId;
    private String cycles;
    private String receivableAmount;
    private String receivedAmount;
    private String primeRate;
    private String remark;
    private String startTime;
    private String endTime;
    private String createTime;
    private String state;
    public String getDetailId() {
        return detailId;
    }
    public void setDetailId(String detailId) {
        this.detailId = detailId;
    }
    public String getFeeId() {
        return feeId;
    }
    public void setFeeId(String feeId) {
        this.feeId = feeId;
    }
    public String getCommunityId() {
        return communityId;
    }
    public void setCommunityId(String communityId) {
        this.communityId = communityId;
    }
    public String getCycles() {
        return cycles;
    }
    public void setCycles(String cycles) {
        this.cycles = cycles;
    }
    public String getReceivableAmount() {
        return receivableAmount;
    }
    public void setReceivableAmount(String receivableAmount) {
        this.receivableAmount = receivableAmount;
    }
    public String getReceivedAmount() {
        return receivedAmount;
    }
    public void setReceivedAmount(String receivedAmount) {
        this.receivedAmount = receivedAmount;
    }
    public String getPrimeRate() {
        return primeRate;
    }
    public void setPrimeRate(String primeRate) {
        this.primeRate = primeRate;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}
java110-db/src/main/resources/mapper/report/ReportCommunityServiceDaoImplMapper.xml
@@ -42,4 +42,41 @@
    </select>
    <!-- 查询房屋个数 add by wuxw 2018-07-03 -->
    <select id="getCarCount" parameterType="com.java110.dto.report.ReportCarDto" resultType="Map">
        select count(1) count
        from owner_car t
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
    </select>
    <!-- 查询 房屋 楼栋 单元 业主 -->
    <select id="getCarParkingSpace" parameterType="com.java110.dto.report.ReportCarDto"
            resultType="com.java110.dto.report.ReportCarDto">
        select t.car_brand carBrand,t.car_color carColor,t.car_id carId,t.car_num carNum,t.car_type carType,
        t.community_id communityId,bo.`name` ownerName,bo.id_card idCard,bo.link,bo.owner_id ownerId,ps.ps_id psId,
        ps.num,pa.pa_id paId,pa.num areaNum,ps.state
        from owner_car t
        INNER JOIN building_owner bo on t.owner_id = bo.member_id and t.status_cd = '0'
        left join parking_space ps on t.ps_id = t.ps_id and ps.status_cd = '0'
        left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
</mapper>
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -5,201 +5,224 @@
<mapper namespace="reportFeeMonthStatisticsServiceDaoImpl">
    <!-- 保存费用月统计信息 add by wuxw 2018-07-03 -->
    <insert id="saveReportFeeMonthStatisticsInfo" parameterType="Map">
        insert into report_fee_month_statistics(
receivable_amount,statistics_id,update_time,remark,obj_name,received_amount,fee_year,fee_month,fee_id,config_id,obj_id,fee_name,owe_amount,community_id,fee_create_time,obj_type
) values (
#{receivableAmount},#{statisticsId},#{updateTime},#{remark},#{objName},#{receivedAmount},#{feeYear},#{feeMonth},#{feeId},#{configId},#{objId},#{feeName},#{oweAmount},#{communityId},#{feeCreateTime},#{objType}
)
        receivable_amount,statistics_id,update_time,remark,obj_name,received_amount,fee_year,fee_month,fee_id,config_id,obj_id,fee_name,owe_amount,community_id,fee_create_time,obj_type
        ) values (
        #{receivableAmount},#{statisticsId},#{updateTime},#{remark},#{objName},#{receivedAmount},#{feeYear},#{feeMonth},#{feeId},#{configId},#{objId},#{feeName},#{oweAmount},#{communityId},#{feeCreateTime},#{objType}
        )
    </insert>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="getReportFeeMonthStatisticsInfo" parameterType="Map" resultType="Map">
        select  t.receivable_amount,t.receivable_amount receivableAmount,t.statistics_id,t.statistics_id statisticsId,t.update_time,t.update_time updateTime,t.remark,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name objName,t.received_amount,t.received_amount receivedAmount,t.fee_year,t.fee_year feeYear,t.fee_month,t.fee_month feeMonth,t.fee_id,t.fee_id feeId,t.config_id,t.config_id configId,t.obj_id,t.obj_id objId,t.fee_name,t.fee_name feeName,t.owe_amount,t.owe_amount oweAmount,t.community_id,t.community_id communityId,t.fee_create_time,t.fee_create_time feeCreateTime,t.obj_type,t.obj_type objType
from report_fee_month_statistics t
where 1 =1
<if test="receivableAmount !=null and receivableAmount != ''">
   and t.receivable_amount= #{receivableAmount}
</if>
<if test="statisticsId !=null and statisticsId != ''">
   and t.statistics_id= #{statisticsId}
</if>
<if test="updateTime !=null and updateTime != ''">
   and t.update_time= #{updateTime}
</if>
<if test="remark !=null and remark != ''">
   and t.remark= #{remark}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
<if test="objName !=null and objName != ''">
   and t.obj_name= #{objName}
</if>
<if test="receivedAmount !=null and receivedAmount != ''">
   and t.received_amount= #{receivedAmount}
</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>
<if test="feeId !=null and feeId != ''">
   and t.fee_id= #{feeId}
</if>
<if test="configId !=null and configId != ''">
   and t.config_id= #{configId}
</if>
<if test="objId !=null and objId != ''">
   and t.obj_id= #{objId}
</if>
<if test="feeName !=null and feeName != ''">
   and t.fee_name= #{feeName}
</if>
<if test="oweAmount !=null and oweAmount != ''">
   and t.owe_amount= #{oweAmount}
</if>
<if test="communityId !=null and communityId != ''">
   and t.community_id= #{communityId}
</if>
<if test="feeCreateTime !=null and feeCreateTime != ''">
   and t.fee_create_time= #{feeCreateTime}
</if>
<if test="objType !=null and objType != ''">
   and t.obj_type= #{objType}
</if>
order by t.create_time desc
<if test="page != -1 and page != null ">
   limit #{page}, #{row}
</if>
        select t.receivable_amount,t.receivable_amount receivableAmount,t.statistics_id,t.statistics_id
        statisticsId,t.update_time,t.update_time updateTime,t.remark,t.status_cd,t.status_cd
        statusCd,t.obj_name,t.obj_name objName,t.received_amount,t.received_amount receivedAmount,t.fee_year,t.fee_year
        feeYear,t.fee_month,t.fee_month feeMonth,t.fee_id,t.fee_id feeId,t.config_id,t.config_id
        configId,t.obj_id,t.obj_id objId,t.fee_name,t.fee_name feeName,t.owe_amount,t.owe_amount
        oweAmount,t.community_id,t.community_id communityId,t.fee_create_time,t.fee_create_time
        feeCreateTime,t.obj_type,t.obj_type objType
        from report_fee_month_statistics t
        where 1 =1
        <if test="receivableAmount !=null and receivableAmount != ''">
            and t.receivable_amount= #{receivableAmount}
        </if>
        <if test="statisticsId !=null and statisticsId != ''">
            and t.statistics_id= #{statisticsId}
        </if>
        <if test="updateTime !=null and updateTime != ''">
            and t.update_time= #{updateTime}
        </if>
        <if test="remark !=null and remark != ''">
            and t.remark= #{remark}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="receivedAmount !=null and receivedAmount != ''">
            and t.received_amount= #{receivedAmount}
        </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>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        </if>
        <if test="oweAmount !=null and oweAmount != ''">
            and t.owe_amount= #{oweAmount}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="feeCreateTime !=null and feeCreateTime != ''">
            and t.fee_create_time= #{feeCreateTime}
        </if>
        <if test="objType !=null and objType != ''">
            and t.obj_type= #{objType}
        </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="updateReportFeeMonthStatisticsOwe" parameterType="Map">
        update report_fee_month_statistics t set
             t.owe_amount= #{oweAmount}
        where 1=1
        <if test="statisticsId !=null and statisticsId != ''">
            and t.statistics_id= #{statisticsId}
        </if>
        <if test="feeYear !=null ">
            and t.fee_year &lt;= #{feeYear}
        </if>
        <if test="feeMonth !=null ">
            and t.fee_month &lt;= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
    </update>
    <!-- 修改费用月统计信息 add by wuxw 2018-07-03 -->
    <update id="updateReportFeeMonthStatisticsInfo" parameterType="Map">
        update  report_fee_month_statistics t set t.status_cd = #{statusCd}
<if test="newBId != null and newBId != ''">
,t.b_id = #{newBId}
</if>
<if test="receivableAmount !=null and receivableAmount != ''">
, t.receivable_amount= #{receivableAmount}
</if>
<if test="updateTime !=null and updateTime != ''">
, t.update_time= #{updateTime}
</if>
<if test="remark !=null and remark != ''">
, t.remark= #{remark}
</if>
<if test="objName !=null and objName != ''">
, t.obj_name= #{objName}
</if>
<if test="receivedAmount !=null and receivedAmount != ''">
, t.received_amount= #{receivedAmount}
</if>
<if test="feeYear !=null and feeYear != ''">
, t.fee_year= #{feeYear}
</if>
<if test="feeMonth !=null and feeMonth != ''">
, t.fee_month= #{feeMonth}
</if>
<if test="feeId !=null and feeId != ''">
, t.fee_id= #{feeId}
</if>
<if test="configId !=null and configId != ''">
, t.config_id= #{configId}
</if>
<if test="objId !=null and objId != ''">
, t.obj_id= #{objId}
</if>
<if test="feeName !=null and feeName != ''">
, t.fee_name= #{feeName}
</if>
<if test="oweAmount !=null and oweAmount != ''">
, t.owe_amount= #{oweAmount}
</if>
<if test="communityId !=null and communityId != ''">
, t.community_id= #{communityId}
</if>
<if test="feeCreateTime !=null and feeCreateTime != ''">
, t.fee_create_time= #{feeCreateTime}
</if>
<if test="objType !=null and objType != ''">
, t.obj_type= #{objType}
</if>
 where 1=1 <if test="statisticsId !=null and statisticsId != ''">
and t.statistics_id= #{statisticsId}
</if>
        update report_fee_month_statistics t set t.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="receivableAmount !=null and receivableAmount != ''">
            , t.receivable_amount= #{receivableAmount}
        </if>
        <if test="updateTime !=null and updateTime != ''">
            , t.update_time= #{updateTime}
        </if>
        <if test="remark !=null and remark != ''">
            , t.remark= #{remark}
        </if>
        <if test="objName !=null and objName != ''">
            , t.obj_name= #{objName}
        </if>
        <if test="receivedAmount !=null and receivedAmount != ''">
            , t.received_amount= #{receivedAmount}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            , t.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            , t.fee_month= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            , t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            , t.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            , t.obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            , t.fee_name= #{feeName}
        </if>
        <if test="oweAmount !=null and oweAmount != ''">
            , t.owe_amount= #{oweAmount}
        </if>
        <if test="communityId !=null and communityId != ''">
            , t.community_id= #{communityId}
        </if>
        <if test="feeCreateTime !=null and feeCreateTime != ''">
            , t.fee_create_time= #{feeCreateTime}
        </if>
        <if test="objType !=null and objType != ''">
            , t.obj_type= #{objType}
        </if>
        where 1=1
        <if test="statisticsId !=null and statisticsId != ''">
            and t.statistics_id= #{statisticsId}
        </if>
    </update>
    <!-- 查询费用月统计数量 add by wuxw 2018-07-03 -->
     <select id="queryReportFeeMonthStatisticssCount" parameterType="Map" resultType="Map">
        select  count(1) count
from report_fee_month_statistics t
where 1 =1
<if test="receivableAmount !=null and receivableAmount != ''">
   and t.receivable_amount= #{receivableAmount}
</if>
<if test="statisticsId !=null and statisticsId != ''">
   and t.statistics_id= #{statisticsId}
</if>
<if test="updateTime !=null and updateTime != ''">
   and t.update_time= #{updateTime}
</if>
<if test="remark !=null and remark != ''">
   and t.remark= #{remark}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
<if test="objName !=null and objName != ''">
   and t.obj_name= #{objName}
</if>
<if test="receivedAmount !=null and receivedAmount != ''">
   and t.received_amount= #{receivedAmount}
</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>
<if test="feeId !=null and feeId != ''">
   and t.fee_id= #{feeId}
</if>
<if test="configId !=null and configId != ''">
   and t.config_id= #{configId}
</if>
<if test="objId !=null and objId != ''">
   and t.obj_id= #{objId}
</if>
<if test="feeName !=null and feeName != ''">
   and t.fee_name= #{feeName}
</if>
<if test="oweAmount !=null and oweAmount != ''">
   and t.owe_amount= #{oweAmount}
</if>
<if test="communityId !=null and communityId != ''">
   and t.community_id= #{communityId}
</if>
<if test="feeCreateTime !=null and feeCreateTime != ''">
   and t.fee_create_time= #{feeCreateTime}
</if>
<if test="objType !=null and objType != ''">
   and t.obj_type= #{objType}
</if>
    <select id="queryReportFeeMonthStatisticssCount" parameterType="Map" resultType="Map">
        select count(1) count
        from report_fee_month_statistics t
        where 1 =1
        <if test="receivableAmount !=null and receivableAmount != ''">
            and t.receivable_amount= #{receivableAmount}
        </if>
        <if test="statisticsId !=null and statisticsId != ''">
            and t.statistics_id= #{statisticsId}
        </if>
        <if test="updateTime !=null and updateTime != ''">
            and t.update_time= #{updateTime}
        </if>
        <if test="remark !=null and remark != ''">
            and t.remark= #{remark}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="receivedAmount !=null and receivedAmount != ''">
            and t.received_amount= #{receivedAmount}
        </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>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        </if>
        <if test="oweAmount !=null and oweAmount != ''">
            and t.owe_amount= #{oweAmount}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="feeCreateTime !=null and feeCreateTime != ''">
            and t.fee_create_time= #{feeCreateTime}
        </if>
        <if test="objType !=null and objType != ''">
            and t.obj_type= #{objType}
        </if>
     </select>
    </select>
</mapper>
java110-db/src/main/resources/mapper/report/ReportFeeServiceDaoImplMapper.xml
@@ -4,6 +4,19 @@
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="reportFeeServiceDaoImpl">
    <!-- 查询实收金额 -->
    <select id="getFeeReceivedAmount" parameterType="com.java110.dto.report.ReportFeeDetailDto" resultType="Map">
        select SUM(t.received_amount) receivedAmount from pay_fee_detail t
        where 1=1
        and t.fee_id = #{feeId}
        <if test="startTime != null">
        and t.create_time &gt; #{startTime}
        </if>
        <if test="endTime != null">
            and t.create_time &lt; #{endTime}
        </if>
    </select>
    <!-- 查询房屋个数 add by wuxw 2018-07-03 -->
    <select id="getFeeCount" parameterType="com.java110.dto.report.ReportFeeDto" resultType="Map">
        select count(1) count
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java
@@ -347,16 +347,22 @@
        return returndate;
    }
    public static Date getNextMonthFirstDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.add(Calendar.MONTH, 1);
        return calendar.getTime();
    }
    public static Date getFirstDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        return calendar.getTime();
    }
    public static String getNextMonthFirstDay(String fmt) {
        String returndate = "";
        Date date = null;
        Calendar cl = Calendar.getInstance();
        cl.set(2, cl.get(2) + 1);
        cl.set(5, 1);
        date = cl.getTime();
        Date date = getNextMonthFirstDate();
        returndate = getFormatTimeString(date, fmt);
        return returndate;
@@ -426,4 +432,42 @@
        return dateStr;
    }
    public static int getYear() {
        Date date = getCurrentDate();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.YEAR);
    }
    public static int getMonth() {
        Date date = getCurrentDate();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.MONTH) + 1;
    }
    /**
     * 判断时间是否在时间段内
     *
     * @param nowTime
     * @param beginTime
     * @param endTime
     * @return
     */
    public static boolean belongCalendar(Date nowTime, Date beginTime, Date endTime) {
        Calendar date = Calendar.getInstance();
        date.setTime(nowTime);
        Calendar begin = Calendar.getInstance();
        begin.setTime(beginTime);
        Calendar end = Calendar.getInstance();
        end.setTime(endTime);
        if (date.after(begin) && date.before(end)) {
            return true;
        } else if (nowTime.compareTo(beginTime) == 0 || nowTime.compareTo(endTime) == 0) {
            return true;
        } else {
            return false;
        }
    }
}
java110-utils/src/main/java/com/java110/utils/util/ListUtil.java
New file
@@ -0,0 +1,50 @@
package com.java110.utils.util;
import java.util.List;
/**
 * list 工具类
 *
 * add by wuxw 2020-10-16
 */
public class ListUtil {
    /**
     * 判断 List 是否为空
     *
     * @param values list 数据
     * @return 空为true 有值为false
     */
    public  static boolean isNull(List values) {
        if (values == null) {
            return true;
        }
        if (values.size() < 1) {
            return true;
        }
        return false;
    }
    /**
     * 判断 list 是否只有一个结果集
     *
     * @param values list 数据
     * @return 只有一个值 为true 否则为false
     */
    public  static boolean hasOne(List values) {
        if (isNull(values)) {
            return false;
        }
        if (values.size() > 1) {
            return false;
        }
        return true;
    }
}
service-report/src/main/java/com/java110/report/dao/IReportCommunityServiceDao.java
@@ -1,5 +1,6 @@
package com.java110.report.dao;
import com.java110.dto.report.ReportCarDto;
import com.java110.dto.report.ReportRoomDto;
import java.util.List;
@@ -16,6 +17,7 @@
    /**
     * 查询房屋个数
     *
     * @param reportRoomDto
     * @return
     */
@@ -23,7 +25,24 @@
    /**
     * 查询 房屋 楼栋 单元 和 业主 信息
     *
     * @return
     */
    List<ReportRoomDto> getRoomFloorUnitAndOwner(ReportRoomDto reportRoomDto);
    /**
     * 查询房屋个数
     *
     * @param reportCarDto
     * @return
     */
    int getCarCount(ReportCarDto reportCarDto);
    /**
     * 查询 房屋 楼栋 单元 和 业主 信息
     *
     * @return
     */
    List<ReportCarDto> getCarParkingSpace(ReportCarDto reportCarDto);
}
service-report/src/main/java/com/java110/report/dao/IReportFeeMonthStatisticsServiceDao.java
@@ -51,6 +51,15 @@
    void updateReportFeeMonthStatisticsInfo(Map info) throws DAOException;
    /**
     * 修改费用月统计信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    void updateReportFeeMonthStatisticsOwe(Map info) throws DAOException;
    /**
     * 查询费用月统计总数
     *
service-report/src/main/java/com/java110/report/dao/IReportFeeServiceDao.java
@@ -1,5 +1,6 @@
package com.java110.report.dao;
import com.java110.dto.report.ReportFeeDetailDto;
import com.java110.dto.report.ReportFeeDto;
import com.java110.dto.report.ReportRoomDto;
@@ -27,4 +28,11 @@
     * @return
     */
    List<ReportFeeDto> getFees(ReportFeeDto reportFeeDto);
    /**
     * 实收费用查询
     * @param reportFeeDetailDto
     * @return
     */
    double getFeeReceivedAmount(ReportFeeDetailDto reportFeeDetailDto);
}
service-report/src/main/java/com/java110/report/dao/impl/ReportCommunityServiceDaoImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.dto.report.ReportCarDto;
import com.java110.dto.report.ReportRoomDto;
import com.java110.report.dao.IReportCommunityServiceDao;
import org.slf4j.Logger;
@@ -44,4 +45,31 @@
        return roomDtos;
    }
    /**
     * 统计车辆
     *
     * @param reportCarDto
     * @return
     */
    @Override
    public int getCarCount(ReportCarDto reportCarDto) {
        logger.debug("查询费用月统计数据 入参 info : {}", JSONObject.toJSONString(reportCarDto));
        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportCommunityServiceDaoImpl.getCarCount", reportCarDto);
        if (businessReportFeeMonthStatisticsInfos.size() < 1) {
            return 0;
        }
        return Integer.parseInt(businessReportFeeMonthStatisticsInfos.get(0).get("count").toString());
    }
    @Override
    public List<ReportCarDto> getCarParkingSpace(ReportCarDto reportCarDto) {
        logger.debug("查询房屋信息 入参 info : {}", JSONObject.toJSONString(reportCarDto));
        List<ReportCarDto> carDtos = sqlSessionTemplate.selectList("reportCommunityServiceDaoImpl.getCarParkingSpace", reportCarDto);
        return carDtos;
    }
}
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeMonthStatisticsServiceDaoImpl.java
@@ -1,15 +1,13 @@
package com.java110.report.dao.impl;
import com.alibaba.fastjson.JSONObject;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.DAOException;
import com.java110.utils.util.DateUtil;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.DAOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@@ -25,37 +23,36 @@
    private static Logger logger = LoggerFactory.getLogger(ReportFeeMonthStatisticsServiceDaoImpl.class);
    /**
     * 保存费用月统计信息 到 instance
     * @param info   bId 信息
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public void saveReportFeeMonthStatisticsInfo(Map info) throws DAOException {
        logger.debug("保存费用月统计信息Instance 入参 info : {}",info);
        logger.debug("保存费用月统计信息Instance 入参 info : {}", info);
        int saveFlag = sqlSessionTemplate.insert("reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo",info);
        int saveFlag = sqlSessionTemplate.insert("reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo", info);
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存费用月统计信息Instance数据失败:"+ JSONObject.toJSONString(info));
        if (saveFlag < 1) {
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存费用月统计信息Instance数据失败:" + JSONObject.toJSONString(info));
        }
    }
    /**
     * 查询费用月统计信息(instance)
     *
     * @param info bId 信息
     * @return List<Map>
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getReportFeeMonthStatisticsInfo(Map info) throws DAOException {
        logger.debug("查询费用月统计信息 入参 info : {}",info);
        logger.debug("查询费用月统计信息 入参 info : {}", info);
        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo",info);
        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo", info);
        return businessReportFeeMonthStatisticsInfos;
    }
@@ -63,28 +60,45 @@
    /**
     * 修改费用月统计信息
     *
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    @Override
    public void updateReportFeeMonthStatisticsInfo(Map info) throws DAOException {
        logger.debug("修改费用月统计信息Instance 入参 info : {}",info);
        logger.debug("修改费用月统计信息Instance 入参 info : {}", info);
        int saveFlag = sqlSessionTemplate.update("reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo",info);
        int saveFlag = sqlSessionTemplate.update("reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo", info);
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改费用月统计信息Instance数据失败:"+ JSONObject.toJSONString(info));
        if (saveFlag < 1) {
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改费用月统计信息Instance数据失败:" + JSONObject.toJSONString(info));
        }
    }
     /**
    /**
     * 修改费用月统计信息
     *
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    @Override
    public void updateReportFeeMonthStatisticsOwe(Map info) throws DAOException {
        logger.debug("修改费用月统计信息Instance 入参 info : {}", info);
        sqlSessionTemplate.update("reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe", info);
    }
    /**
     * 查询费用月统计数量
     *
     * @param info 费用月统计信息
     * @return 费用月统计数量
     */
    @Override
    public int queryReportFeeMonthStatisticssCount(Map info) {
        logger.debug("查询费用月统计数据 入参 info : {}",info);
        logger.debug("查询费用月统计数据 入参 info : {}", info);
        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.queryReportFeeMonthStatisticssCount", info);
        if (businessReportFeeMonthStatisticsInfos.size() < 1) {
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeServiceDaoImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.dto.report.ReportFeeDetailDto;
import com.java110.dto.report.ReportFeeDto;
import com.java110.report.dao.IReportFeeServiceDao;
import org.slf4j.Logger;
@@ -44,4 +45,16 @@
        return roomDtos;
    }
    @Override
    public double getFeeReceivedAmount(ReportFeeDetailDto reportFeeDetailDto) {
        logger.debug("查询实收费用 入参 info : {}", JSONObject.toJSONString(reportFeeDetailDto));
        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeServiceDaoImpl.getFeeReceivedAmount", reportFeeDetailDto);
        if (businessReportFeeMonthStatisticsInfos.size() < 1) {
            return 0;
        }
        return Double.parseDouble(businessReportFeeMonthStatisticsInfos.get(0).get("receivedAmount").toString());
    }
}
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
@@ -1,21 +1,32 @@
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.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.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
import com.java110.intf.report.IGeneratorFeeMonthStatisticsInnerServiceSMO;
import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
import com.java110.report.dao.IReportCommunityServiceDao;
import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
import com.java110.report.dao.IReportFeeServiceDao;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.ListUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@@ -42,6 +53,9 @@
    @Autowired
    private IReportFeeServiceDao reportFeeServiceDaoImpl;
    @Autowired
    private IComputeFeeSMO computeFeeSMOImpl;
    @Override
    public int generatorData(@RequestBody ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo) {
@@ -52,8 +66,47 @@
        //处理房屋费用
        dealRoomFee(reportFeeMonthStatisticsPo);
        //处理车位费用
        dealCarFee(reportFeeMonthStatisticsPo);
        return 0;
    }
    /**
     * 处理车位 车辆费用
     *
     * @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);
                }
            }
        }
    }
@@ -86,7 +139,7 @@
            List<ReportRoomDto> reportRoomDtos = reportCommunityServiceDaoImpl.getRoomFloorUnitAndOwner(reportRoomDto);
            for (ReportRoomDto tmpReportRoomDto : reportRoomDtos) {
                try {
                    doDealRoomFee(tmpReportRoomDto);
                    doDealRoomFees(tmpReportRoomDto);
                } catch (Exception e) {
                    logger.error("生成费用报表失败" + JSONObject.toJSONString(tmpReportRoomDto), e);
                }
@@ -94,12 +147,98 @@
        }
    }
    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);
        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) {
        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
        reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
        reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
        reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
        reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
        reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
        List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
                reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
                ReportFeeMonthStatisticsDto.class);
        double receivedAmount = getReceivedAmount(tmpReportFeeDto); //实收
        //费用已经结束 并且当月实收为0 那就是 之前就结束了 无需处理  && ListUtil.isNull(statistics)
        if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
                && receivedAmount == 0) {
            return;
        }
        double receivableAmount = getReceivableAmount(tmpReportFeeDto); //应收
        double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //欠费
        ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
        if (!ListUtil.isNull(statistics)) {
            ReportFeeMonthStatisticsDto statistic = statistics.get(0);
            reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
            reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
            reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
        } else {
            reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
            reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
            reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
            reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
            reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
            reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
            reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
            reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
            reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
            reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
            reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "停车场" + tmpReportCarDto.getNum() + "车位");
            reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
        }
        Date endTime = tmpReportFeeDto.getEndTime();
        Calendar calender = Calendar.getInstance();
        calender.setTime(endTime);
        int year = calender.get(Calendar.YEAR);
        int month = calender.get(Calendar.MONTH);
        ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
        tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
        tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
        tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
        tmpReportFeeMonthStatisticsPo.setOweAmount("0");
        reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
    }
    /**
     * 处理费用
     *
     * @param reportRoomDto
     */
    private void doDealRoomFee(ReportRoomDto reportRoomDto) {
    private void doDealRoomFees(ReportRoomDto reportRoomDto) {
        ReportFeeDto reportFeeDto = new ReportFeeDto();
        reportFeeDto.setPayerObjId(reportRoomDto.getRoomId());
        reportFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
@@ -110,6 +249,169 @@
            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) {
        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
        reportFeeMonthStatisticsDto.setCommunityId(reportRoomDto.getCommunityId());
        reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
        reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
        reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
        reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
        List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
                reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
                ReportFeeMonthStatisticsDto.class);
        double receivedAmount = getReceivedAmount(tmpReportFeeDto); //实收
        //费用已经结束 并且当月实收为0 那就是 之前就结束了 无需处理  && ListUtil.isNull(statistics)
        if (FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())
                && receivedAmount == 0) {
            return;
        }
        double receivableAmount = getReceivableAmount(tmpReportFeeDto); //应收
        double oweAmount = getOweAmount(tmpReportFeeDto, receivableAmount, receivedAmount); //欠费
        ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
        if (!ListUtil.isNull(statistics)) {
            ReportFeeMonthStatisticsDto statistic = statistics.get(0);
            reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
            reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
            reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
        } else {
            reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
            reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
            reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
            reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
            reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
            reportFeeMonthStatisticsPo.setFeeMonth(DateUtil.getMonth() + "");
            reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
            reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
            reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
            reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
            reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getUnitNum() + "单元" + reportRoomDto.getRoomNum() + "室");
            reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
        }
        Date endTime = tmpReportFeeDto.getEndTime();
        Calendar calender = Calendar.getInstance();
        calender.setTime(endTime);
        int year = calender.get(Calendar.YEAR);
        int month = calender.get(Calendar.MONTH);
        ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
        tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
        tmpReportFeeMonthStatisticsPo.setFeeYear(year + "");
        tmpReportFeeMonthStatisticsPo.setFeeMonth(month + "");
        tmpReportFeeMonthStatisticsPo.setOweAmount("0");
        reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
    }
    /**
     * 当月欠费
     *
     * @param tmpReportFeeDto
     * @param receivableAmount
     * @param receivedAmount
     * @return
     */
    private double getOweAmount(ReportFeeDto tmpReportFeeDto, double receivableAmount, double receivedAmount) {
        if (receivableAmount == 0) {
            return 0;
        }
        if (receivedAmount > receivableAmount) {
            return 0;
        }
        BigDecimal receivedAmountDec = new BigDecimal(receivedAmount);
        BigDecimal receivableAmountDec = new BigDecimal(receivedAmount);
        return receivableAmountDec.subtract(receivedAmountDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
    }
    /**
     * 获取当月实收
     *
     * @param tmpReportFeeDto
     * @return
     */
    private double getReceivedAmount(ReportFeeDto tmpReportFeeDto) {
        ReportFeeDetailDto feeDetailDto = new ReportFeeDetailDto();
        feeDetailDto.setStartTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
        feeDetailDto.setEndTime(DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
        feeDetailDto.setFeeId(tmpReportFeeDto.getFeeId());
        double receivedAmount = reportFeeServiceDaoImpl.getFeeReceivedAmount(feeDetailDto);
        return receivedAmount;
    }
    /**
     * 获取当月应收
     *
     * @param tmpReportFeeDto
     * @return
     */
    private double getReceivableAmount(ReportFeeDto tmpReportFeeDto) {
        FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
        double feePrice = computeFeeSMOImpl.getFeePrice(feeDto);
        BigDecimal feePriceDec = new BigDecimal(feePrice);
        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeTypeCd())) {
            return feePrice;
        }
        //1.0 费用到期时间和费用结束时间 都不在当月
        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())
                && tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) {
            return feePrice;
        }
        //2.0 费用到期时间 在当月,费用结束时间不在当月
        if (belongCurMonth(tmpReportFeeDto.getEndTime())
                && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }
        //3.0 费用到期时间 不在当月,费用结束时间在当月
        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                && belongCurMonth(tmpReportFeeDto.getConfigEndTime())) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime());
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }
        return 0.0;
    }
    private boolean belongCurMonth(Date date) {
        if (DateUtil.belongCalendar(date, DateUtil.getFirstDate(), DateUtil.getNextMonthFirstDate())) {
            return true;
        }
        return false;
    }
}