Kaynağa Gözat

优化报表

java110 4 yıl önce
ebeveyn
işleme
15f6aadbad

+ 46 - 0
java110-bean/src/main/java/com/java110/dto/reportFeeMonthStatistics/ReportFeeMonthStatisticsDto.java

@@ -125,6 +125,12 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
 
     private String repairId;
 
+    private String hisOweAmount;
+    private String curReceivableAmount;
+    private String curReceivedAmount;
+    private String hisOweReceivedAmount;
+    private String preReceivedAmount;
+
     public String getReceivableAmount() {
         return receivableAmount;
     }
@@ -619,4 +625,44 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
     public void setBuiltUpArea(String builtUpArea) {
         this.builtUpArea = builtUpArea;
     }
+
+    public String getHisOweAmount() {
+        return hisOweAmount;
+    }
+
+    public void setHisOweAmount(String hisOweAmount) {
+        this.hisOweAmount = hisOweAmount;
+    }
+
+    public String getCurReceivableAmount() {
+        return curReceivableAmount;
+    }
+
+    public void setCurReceivableAmount(String curReceivableAmount) {
+        this.curReceivableAmount = curReceivableAmount;
+    }
+
+    public String getCurReceivedAmount() {
+        return curReceivedAmount;
+    }
+
+    public void setCurReceivedAmount(String curReceivedAmount) {
+        this.curReceivedAmount = curReceivedAmount;
+    }
+
+    public String getHisOweReceivedAmount() {
+        return hisOweReceivedAmount;
+    }
+
+    public void setHisOweReceivedAmount(String hisOweReceivedAmount) {
+        this.hisOweReceivedAmount = hisOweReceivedAmount;
+    }
+
+    public String getPreReceivedAmount() {
+        return preReceivedAmount;
+    }
+
+    public void setPreReceivedAmount(String preReceivedAmount) {
+        this.preReceivedAmount = preReceivedAmount;
+    }
 }

+ 45 - 0
java110-bean/src/main/java/com/java110/po/reportFeeMonthStatistics/ReportFeeMonthStatisticsPo.java

@@ -23,6 +23,11 @@ public class ReportFeeMonthStatisticsPo implements Serializable {
     private String objType;
     private String deadlineTime;
     private String curMaxTime;
+    private String hisOweAmount;
+    private String curReceivableAmount;
+    private String curReceivedAmount;
+    private String hisOweReceivedAmount;
+    private String preReceivedAmount;
 
     public String getReceivableAmount() {
         return receivableAmount;
@@ -175,4 +180,44 @@ public class ReportFeeMonthStatisticsPo implements Serializable {
     public void setCurMaxTime(String curMaxTime) {
         this.curMaxTime = curMaxTime;
     }
+
+    public String getHisOweAmount() {
+        return hisOweAmount;
+    }
+
+    public void setHisOweAmount(String hisOweAmount) {
+        this.hisOweAmount = hisOweAmount;
+    }
+
+    public String getCurReceivableAmount() {
+        return curReceivableAmount;
+    }
+
+    public void setCurReceivableAmount(String curReceivableAmount) {
+        this.curReceivableAmount = curReceivableAmount;
+    }
+
+    public String getCurReceivedAmount() {
+        return curReceivedAmount;
+    }
+
+    public void setCurReceivedAmount(String curReceivedAmount) {
+        this.curReceivedAmount = curReceivedAmount;
+    }
+
+    public String getHisOweReceivedAmount() {
+        return hisOweReceivedAmount;
+    }
+
+    public void setHisOweReceivedAmount(String hisOweReceivedAmount) {
+        this.hisOweReceivedAmount = hisOweReceivedAmount;
+    }
+
+    public String getPreReceivedAmount() {
+        return preReceivedAmount;
+    }
+
+    public void setPreReceivedAmount(String preReceivedAmount) {
+        this.preReceivedAmount = preReceivedAmount;
+    }
 }

+ 45 - 4
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -8,10 +8,12 @@
     <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,deadline_time,cur_max_time
+        obj_id,fee_name,owe_amount,community_id,fee_create_time,obj_type,deadline_time,cur_max_time,
+        his_owe_amount,cur_receivable_amount,cur_received_amount, his_owe_received_amount,pre_received_amount
         ) values (
         #{receivableAmount},#{statisticsId},#{updateTime},#{remark},#{objName},#{receivedAmount},#{feeYear},#{feeMonth},
-        #{feeId},#{configId},#{objId},#{feeName},#{oweAmount},#{communityId},#{feeCreateTime},#{objType},#{deadlineTime},#{curMaxTime}
+        #{feeId},#{configId},#{objId},#{feeName},#{oweAmount},#{communityId},#{feeCreateTime},#{objType},#{deadlineTime},#{curMaxTime},
+        #{hisOweAmount},#{curReceivableAmount},#{curReceivedAmount},#{hisOweReceivedAmount},#{preReceivedAmount}
         )
     </insert>
 
@@ -23,7 +25,9 @@
         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,t.cur_max_time curMaxTime
+        feeCreateTime,t.obj_type,t.obj_type objType,t.cur_max_time curMaxTime,
+        t.his_owe_amount hisOweAmount,t.cur_receivable_amount curReceivableAmount,t.cur_received_amount curReceivedAmount,
+        t.his_owe_received_amount hisOweReceivedAmount,t.pre_received_amount preReceivedAmount
         from report_fee_month_statistics t
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
         where 1 =1
@@ -145,13 +149,27 @@
         <if test="oweAmount !=null and oweAmount != ''">
             , t.owe_amount= #{oweAmount}
         </if>
-
         <if test="feeCreateTime !=null and feeCreateTime != ''">
             , t.fee_create_time= #{feeCreateTime}
         </if>
         <if test="objType !=null and objType != ''">
             , t.obj_type= #{objType}
         </if>
+        <if test="hisOweAmount !=null and hisOweAmount != ''">
+            , t.his_owe_amount= #{hisOweAmount}
+        </if>
+        <if test="curReceivableAmount !=null and curReceivableAmount != ''">
+            , t.cur_receivable_amount= #{curReceivableAmount}
+        </if>
+        <if test="curReceivedAmount !=null and curReceivedAmount != ''">
+            , t.cur_received_amount= #{curReceivedAmount}
+        </if>
+        <if test="hisOweReceivedAmount !=null and hisOweReceivedAmount != ''">
+            , t.his_owe_received_amount= #{hisOweReceivedAmount}
+        </if>
+        <if test="preReceivedAmount !=null and preReceivedAmount != ''">
+            , t.pre_received_amount= #{preReceivedAmount}
+        </if>
         where 1=1
         and t.statistics_id= #{statisticsId}
         <if test="communityId !=null and communityId != ''">
@@ -2442,4 +2460,27 @@
             limit #{page}, #{row}
         </if>
     </select>
+    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
+    <select id="getReceivedAmountByMonth" parameterType="Map" resultType="Map">
+        select sum(t.received_amount) total
+        from pay_fee_detail_month t
+        where
+        1=1
+        and t.create_time &gt; #{startTime}
+        and t.create_time &lt; #{endTime}
+        and t.fee_id = #{feeId}
+        <if test="flag == 1">
+            and concat(t.detail_year,t.detail_month) = #{yearMonth}
+        </if>
+        <if test="flag == 2">
+            and concat(t.detail_year,t.detail_month) &lt; #{yearMonth}
+        </if>
+        <if test="flag == 3">
+            and concat(t.detail_year,t.detail_month) &gt; #{yearMonth}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+    </select>
+
 </mapper>

+ 14 - 3
java110-utils/src/main/java/com/java110/utils/App.java

@@ -1,13 +1,24 @@
 package com.java110.utils;
 
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.util.DateUtil;
+
+import java.util.Calendar;
+import java.util.Date;
+
 /**
  * Hello world!
  *
  */
 public class App 
 {
-    public static void main( String[] args )
-    {
-        System.out.println( "Hello World!" );
+    public static void main(String[] args) {
+        Calendar curDateCal = Calendar.getInstance();
+        curDateCal.set(Calendar.DAY_OF_MONTH, 1);
+        curDateCal.set(Calendar.HOUR_OF_DAY, 0);
+        curDateCal.set(Calendar.MINUTE, 0);
+        curDateCal.set(Calendar.SECOND, 0);
+        Date curDate = curDateCal.getTime();
+        System.out.println(DateUtil.getFormatTimeString(curDate,DateUtil.DATE_FORMATE_STRING_A));
     }
 }

+ 13 - 4
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java

@@ -32,6 +32,7 @@ public class DateUtil {
     public static final String DATE_FORMATE_STRING_J = "yyyyMMddHHmmss.SSS";
     public static final String DATE_FORMATE_STRING_K = "yyyyMMddHHmmssSSS";
     public static final String DATE_FORMATE_STRING_L = "MMdd";
+    public static final String DATE_FORMATE_STRING_M = "yyyyMM";
 
     static {
         formats.put("yyyyMMddHHmmss", new SimpleDateFormat("yyyyMMddHHmmss"));
@@ -47,6 +48,7 @@ public class DateUtil {
         formats.put("yyyyMMddHHmmss.SSS", new SimpleDateFormat("yyyyMMddHHmmss.SSS"));
         formats.put("yyyyMMddHHmmssSSS", new SimpleDateFormat("yyyyMMddHHmmssSSS"));
         formats.put("MMdd", new SimpleDateFormat("MMdd"));
+        formats.put("yyyyMM", new SimpleDateFormat("yyyyMM"));
     }
 
 
@@ -350,14 +352,21 @@ public class DateUtil {
     public static Date getNextMonthFirstDate() {
         Calendar calendar = Calendar.getInstance();
         calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
         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();
+        Calendar curDateCal = Calendar.getInstance();
+        curDateCal.set(Calendar.DAY_OF_MONTH, 1);
+        curDateCal.set(Calendar.HOUR_OF_DAY, 0);
+        curDateCal.set(Calendar.MINUTE, 0);
+        curDateCal.set(Calendar.SECOND, 0);
+        Date curDate = curDateCal.getTime();
+        return curDate;
     }
 
     public static String getNextMonthFirstDay(String fmt) {
@@ -425,7 +434,7 @@ public class DateUtil {
      * 在给定的日期加上或减去指定天数后的日期
      *
      * @param sourceDate 原始时间
-     * @param day      要调整的月份,向前为负数,向后为正数
+     * @param day        要调整的月份,向前为负数,向后为正数
      * @return
      */
     public static Date stepDay(Date sourceDate, int day) {

+ 7 - 0
service-report/src/main/java/com/java110/report/dao/IReportFeeMonthStatisticsServiceDao.java

@@ -327,4 +327,11 @@ public interface IReportFeeMonthStatisticsServiceDao {
     List<Map> queryHuaningOweFeeDetail(Map beanCovertMap);
 
     void deleteReportFeeMonthStatisticsInfo(Map beanCovertMap);
+
+    /**
+     * 查询当月实收
+     * @param beanCovertMap
+     * @return
+     */
+    double getReceivedAmountByMonth(Map beanCovertMap);
 }

+ 13 - 3
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeMonthStatisticsServiceDaoImpl.java

@@ -87,6 +87,16 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
         }
     }
 
+    @Override
+    public double getReceivedAmountByMonth(Map info) {
+        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.getReceivedAmountByMonth", info);
+        if (businessReportFeeMonthStatisticsInfos.size() < 1) {
+            return 0;
+        }
+
+        return Double.parseDouble(businessReportFeeMonthStatisticsInfos.get(0).get("count").toString());
+    }
+
     /**
      * 修改费用月统计信息
      *
@@ -201,6 +211,7 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
 
         return businessReportFeeMonthStatisticsInfos;
     }
+
     @Override
     public Map queryFeeBreakdownMajor(Map info) {
         logger.debug("查询费用queryFeeBreakdownMajor 入参 info : {}", info);
@@ -209,6 +220,7 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
 
         return businessReportFeeMonthStatisticsInfos.get(0);
     }
+
     @Override
     public int queryFeeDetailCount(Map info) {
         logger.debug("查询费用月统计数据 入参 info : {}", info);
@@ -231,7 +243,6 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
     }
 
 
-
     @Override
     public int queryOweFeeDetailCount(Map info) {
         logger.debug("查询费用月统计数据 入参 info : {}", info);
@@ -252,6 +263,7 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
 
         return businessReportFeeMonthStatisticsInfos;
     }
+
     @Override
     public Map queryOweFeeDetailMajor(Map info) {
         logger.debug("查询费用queryOweFeeDetailMajor 入参 info : {}", info);
@@ -577,6 +589,4 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
     }
 
 
-
-
 }

+ 131 - 35
service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java

@@ -1,6 +1,5 @@
 package com.java110.report.smo.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.smo.IComputeFeeSMO;
@@ -18,11 +17,7 @@ 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 com.java110.utils.util.StringUtil;
+import com.java110.utils.util.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,11 +26,7 @@ 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.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @ClassName GeneratorFeeMonthStatisticsInnerServiceSMOImpl
@@ -242,24 +233,29 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         tmpReportFeeDto.setDeadlineTime(targetEndDate);
         double oweAmount = getOweAmountByCar(tmpReportFeeDto, null, tmpReportCarDto); //应收
 
-        dealBeforeUploadCarFee(tmpReportFeeDto, tmpReportCarDto);
-        double receivableAmount = getReceivableAmount(tmpReportFeeDto,receivedAmount); //欠费
+        //dealBeforeUploadCarFee(tmpReportFeeDto, tmpReportCarDto);
+        //double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //欠费
 
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, null, tmpReportCarDto);
+        tmpReportFeeDto.setFeePrice(feePrice);
 
         ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
         reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(targetEndDate, DateUtil.DATE_FORMATE_STRING_A));
         if (!ListUtil.isNull(statistics)) {
             ReportFeeMonthStatisticsDto statistic = statistics.get(0);
             reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
-            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
-            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
+//            reportFeeMonthStatisticsPo.setReceivableAmount("0");
+//            reportFeeMonthStatisticsPo.setReceivedAmount("0");
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+            reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+            reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
         } else {
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
-            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
-            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+            reportFeeMonthStatisticsPo.setReceivedAmount("0");
+            reportFeeMonthStatisticsPo.setReceivableAmount("0");
             reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
             reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
             reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
@@ -273,6 +269,11 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
             reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
             reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "停车场" + tmpReportCarDto.getNum() + "车位)");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+            reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
+            reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+            reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+            reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
         }
 
@@ -286,7 +287,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
 
         ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
         tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
-        tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime,DateUtil.DATE_FORMATE_STRING_A));
+        tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
         tmpReportFeeMonthStatisticsPo.setOweAmount("0");
         reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
     }
@@ -357,7 +358,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
         reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
         reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
-        reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(),DateUtil.DATE_FORMATE_STRING_A));
+        reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
         reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
         reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
         reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
@@ -417,7 +418,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
                 ReportFeeMonthStatisticsDto.class);
 
 
-        double receivedAmount = getReceivedAmount(tmpReportFeeDto); //实收
+        //double receivedAmount = getReceivedAmount(tmpReportFeeDto); //实收
 
         FeeDto feeDto = BeanConvertUtil.covertBean(tmpReportFeeDto, FeeDto.class);
         Map<String, Object> targetEndDateAndOweMonth = computeFeeSMOImpl.getTargetEndDateAndOweMonth(feeDto, null);
@@ -426,11 +427,12 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         tmpReportFeeDto.setDeadlineTime(targetEndDate);
         double oweAmount = getOweAmount(tmpReportFeeDto, reportRoomDto, null); //欠费
 
-        double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //应收
+        //double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //应收
         //解决上线时 之前欠费没有刷入导致费用金额对不上问题处理
-        dealBeforeUploadRoomFee(reportRoomDto, tmpReportFeeDto, receivableAmount);
-
+        //dealBeforeUploadRoomFee(reportRoomDto, tmpReportFeeDto);
 
+        double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, null);
+        tmpReportFeeDto.setFeePrice(feePrice);
 
         ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
         reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(targetEndDate, DateUtil.DATE_FORMATE_STRING_A));
@@ -438,16 +440,19 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
             ReportFeeMonthStatisticsDto statistic = statistics.get(0);
             reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
             //reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
-            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
+            //reportFeeMonthStatisticsPo.setReceivedAmount("0");
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
             reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
             reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
+            reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+            reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+            reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
         } else {
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
-            reportFeeMonthStatisticsPo.setReceivedAmount(receivedAmount + "");
-            reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
+            reportFeeMonthStatisticsPo.setReceivedAmount("0");
+            reportFeeMonthStatisticsPo.setReceivableAmount("0");
             reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
             reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
             reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
@@ -464,6 +469,12 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
             } else {
                 reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getRoomNum() + "室");
             }
+            //计算历史欠费
+            reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
+            reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
+            reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
+            reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
+            reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
             reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
         }
@@ -474,26 +485,104 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
 
         ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
         tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
-        tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime,DateUtil.DATE_FORMATE_STRING_A));
+        tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
         tmpReportFeeMonthStatisticsPo.setOweAmount("0");
         reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
     }
 
-    public static void main(String[] args) {
-        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));
 
-        System.out.println(JSONObject.toJSONString(feeDetailDto));
+    /**
+     * @return
+     */
+    private double getReceivedAmount(ReportFeeDto tmpReportFeeDto, int flag) {
+        Map paramIn = new HashMap();
+        paramIn.put("startTime", DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+        paramIn.put("endTime", DateUtil.getFormatTimeString(DateUtil.getNextMonthFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
+        paramIn.put("feeId", tmpReportFeeDto.getFeeId());
+        paramIn.put("yearMonth", DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_M));
+        paramIn.put("flag", 1);
+        double curReceivedAmount = reportFeeMonthStatisticsServiceDaoImpl.getReceivedAmountByMonth(paramIn);
+        return curReceivedAmount;
+    }
+
+    /**
+     * 当月应收
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
+    private double getCurFeeReceivableAmount(ReportFeeDto tmpReportFeeDto) {
+        BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
+
+        Date curDate = DateUtil.getFirstDate();
+        double month = 0.0;
+        //已经超过截止时间 和 还没有到开始时间
+        if (curDate.getTime() > tmpReportFeeDto.getDeadlineTime().getTime()
+                || curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+            return 0.0;
+        }
+        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+            month = Math.ceil(month);
+            if (month == 0) {
+                return 0.0;
+            }
+            double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+            return money;
+        }
+        month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
+        if (month < 1) {
+            return feePriceDec.multiply(new BigDecimal(month)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+
+        return tmpReportFeeDto.getFeePrice();
+    }
+
+
+    /**
+     * 计算历史欠费
+     *
+     * @param tmpReportFeeDto
+     * @return
+     */
+    private double getHisOweAmount(ReportFeeDto tmpReportFeeDto) {
+
+        BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
+        Date curDate = DateUtil.getFirstDate();
+        //说明没有历史欠费
+        if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+            return 0.0;
+        }
+
+        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
+            //说明一次性费用都欠了
+            if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
+                return tmpReportFeeDto.getFeePrice();
+            }
+            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
+            month = Math.ceil(month);
+            double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+            return money;
+        }
+
+        double month = 0.0;
+        if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
+            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
+        } else {
+            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
+        }
+        BigDecimal curDegree = new BigDecimal(month);
+        return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
     }
 
+
     /**
      * 解决上线前 欠费数据
      *
      * @param reportRoomDto
      * @param tmpReportFeeDto
      */
-    private void dealBeforeUploadRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto, double curMonthReceivableAmount) {
+    private void dealBeforeUploadRoomFee(ReportRoomDto reportRoomDto, ReportFeeDto tmpReportFeeDto) {
 
 
         Calendar preMonthDate = Calendar.getInstance();
@@ -551,7 +640,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
         reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
         reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
-        reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(),DateUtil.DATE_FORMATE_STRING_A));
+        reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
 
         reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
         reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
@@ -561,6 +650,13 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         } else {
             reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getRoomNum() + "室");
         }
+        //计算历史欠费
+        reportFeeMonthStatisticsPo.setHisOweAmount("0");
+        reportFeeMonthStatisticsPo.setCurReceivableAmount(receivableAmount + "");
+        reportFeeMonthStatisticsPo.setCurReceivedAmount("0");
+        reportFeeMonthStatisticsPo.setHisOweReceivedAmount("0");
+        reportFeeMonthStatisticsPo.setPreReceivedAmount("0");
+
         reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
         reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
 
@@ -683,7 +779,7 @@ public class GeneratorFeeMonthStatisticsInnerServiceSMOImpl implements IGenerato
         month = Math.ceil(month);
 
         BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
-        double money = feePriceDec.divide(new BigDecimal(month),2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        double money = feePriceDec.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
         return money;
     }