java110 лет назад: 4
Родитель
Сommit
a14792ed88

+ 22 - 42
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -891,14 +891,15 @@
     <select id="queryOweFeeDetailCount" parameterType="Map" resultType="Map">
     <select id="queryOweFeeDetailCount" parameterType="Map" resultType="Map">
         select count(1) count
         select count(1) count
         from (
         from (
-        select t.obj_name objName,t.fee_name feeName,pfc.start_time,SUM(t.owe_amount) oweAmount
-        from report_fee_month_statistics t
+        select t.payer_obj_name objName,t.fee_name feeName,pf.end_time feeCreateTime,t.create_time
+        createTime,SUM(t.amount_owed) oweAmount,max(t.deadline_time) deadlineTime
+        from report_owe_fee t
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
-        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
+        left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
         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 t.status_cd = '0'
+        where 1=1
         <if test="roomNum !=null and roomNum != ''">
         <if test="roomNum !=null and roomNum != ''">
             and br.room_num= #{roomNum}
             and br.room_num= #{roomNum}
         </if>
         </if>
@@ -909,13 +910,7 @@
             and f.floor_id = #{floorId}
             and f.floor_id = #{floorId}
         </if>
         </if>
         <if test="objName !=null and objName != ''">
         <if test="objName !=null and objName != ''">
-            and t.obj_name= #{objName}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and t.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and t.fee_month= #{feeMonth}
+            and t.payer_obj_name= #{objName}
         </if>
         </if>
         <if test="feeId !=null and feeId != ''">
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
             and t.fee_id= #{feeId}
@@ -924,7 +919,7 @@
             and t.config_id= #{configId}
             and t.config_id= #{configId}
         </if>
         </if>
         <if test="objId !=null and objId != ''">
         <if test="objId !=null and objId != ''">
-            and t.obj_id= #{objId}
+            and t.payer_obj_id= #{objId}
         </if>
         </if>
         <if test="feeName !=null and feeName != ''">
         <if test="feeName !=null and feeName != ''">
             and t.fee_name= #{feeName}
             and t.fee_name= #{feeName}
@@ -938,23 +933,22 @@
         <if test="endTime !=null">
         <if test="endTime !=null">
             and t.create_time &lt;= #{endTime}
             and t.create_time &lt;= #{endTime}
         </if>
         </if>
-        group by t.config_id,t.fee_name,pfc.start_time,t.obj_id,t.obj_name
+        group by t.fee_name,t.payer_obj_id,t.payer_obj_name
         HAVING oweAmount > 0
         HAVING oweAmount > 0
         ) t
         ) t
     </select>
     </select>
 
 
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
     <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
-        select t.obj_name objName,t.fee_name feeName,t.fee_create_time feeCreateTime,t.create_time
-        createTime,SUM(t.receivable_amount)
-        receivableAmount,SUM(t.received_amount) receivedAmount,SUM(t.owe_amount) oweAmount
-        from report_fee_month_statistics t
+        select t.payer_obj_name objName,t.fee_name feeName,pf.end_time feeCreateTime,t.create_time
+        createTime,SUM(t.amount_owed) oweAmount,max(t.deadline_time) deadlineTime
+        from report_owe_fee t
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
-        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
+        left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
         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 t.status_cd = '0'
+        where 1=1
         <if test="roomNum !=null and roomNum != ''">
         <if test="roomNum !=null and roomNum != ''">
             and br.room_num= #{roomNum}
             and br.room_num= #{roomNum}
         </if>
         </if>
@@ -965,13 +959,7 @@
             and f.floor_id = #{floorId}
             and f.floor_id = #{floorId}
         </if>
         </if>
         <if test="objName !=null and objName != ''">
         <if test="objName !=null and objName != ''">
-            and t.obj_name= #{objName}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and t.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and t.fee_month= #{feeMonth}
+            and t.payer_obj_name= #{objName}
         </if>
         </if>
         <if test="feeId !=null and feeId != ''">
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
             and t.fee_id= #{feeId}
@@ -980,7 +968,7 @@
             and t.config_id= #{configId}
             and t.config_id= #{configId}
         </if>
         </if>
         <if test="objId !=null and objId != ''">
         <if test="objId !=null and objId != ''">
-            and t.obj_id= #{objId}
+            and t.payer_obj_id= #{objId}
         </if>
         </if>
         <if test="feeName !=null and feeName != ''">
         <if test="feeName !=null and feeName != ''">
             and t.fee_name= #{feeName}
             and t.fee_name= #{feeName}
@@ -994,7 +982,7 @@
         <if test="endTime !=null">
         <if test="endTime !=null">
             and t.create_time &lt;= #{endTime}
             and t.create_time &lt;= #{endTime}
         </if>
         </if>
-        group by t.config_id,t.fee_name,pfc.start_time,t.obj_id,t.obj_name
+        group by t.fee_name,t.payer_obj_id,t.payer_obj_name
         HAVING oweAmount > 0
         HAVING oweAmount > 0
         <if test="page != -1 and page != null ">
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
             limit #{page}, #{row}
@@ -1002,16 +990,14 @@
     </select>
     </select>
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <select id="queryOweFeeDetailMajor" parameterType="Map" resultType="Map">
     <select id="queryOweFeeDetailMajor" parameterType="Map" resultType="Map">
-        select SUM(t.receivable_amount)
-        allReceivableAmount,SUM(t.received_amount)
-        allReceivedAmount,SUM(t.owe_amount) allOweAmount
-        from report_fee_month_statistics t
+        select SUM(t.amount_owed) oweAmount
+        from report_owe_fee t
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
-        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
+        left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
         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 t.status_cd = '0'
+        where 1=1
         <if test="roomNum !=null and roomNum != ''">
         <if test="roomNum !=null and roomNum != ''">
             and br.room_num= #{roomNum}
             and br.room_num= #{roomNum}
         </if>
         </if>
@@ -1022,13 +1008,7 @@
             and f.floor_id = #{floorId}
             and f.floor_id = #{floorId}
         </if>
         </if>
         <if test="objName !=null and objName != ''">
         <if test="objName !=null and objName != ''">
-            and t.obj_name= #{objName}
-        </if>
-        <if test="feeYear !=null and feeYear != ''">
-            and t.fee_year= #{feeYear}
-        </if>
-        <if test="feeMonth !=null and feeMonth != ''">
-            and t.fee_month= #{feeMonth}
+            and t.payer_obj_name= #{objName}
         </if>
         </if>
         <if test="feeId !=null and feeId != ''">
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
             and t.fee_id= #{feeId}
@@ -1037,7 +1017,7 @@
             and t.config_id= #{configId}
             and t.config_id= #{configId}
         </if>
         </if>
         <if test="objId !=null and objId != ''">
         <if test="objId !=null and objId != ''">
-            and t.obj_id= #{objId}
+            and t.payer_obj_id= #{objId}
         </if>
         </if>
         <if test="feeName !=null and feeName != ''">
         <if test="feeName !=null and feeName != ''">
             and t.fee_name= #{feeName}
             and t.fee_name= #{feeName}

+ 28 - 10
service-job/src/main/java/com/java110/job/task/fee/GenerateOweFeeTemplate.java

@@ -24,7 +24,6 @@ import com.java110.po.reportOweFee.ReportOweFeePo;
 import com.java110.service.smo.ISaveSystemErrorSMO;
 import com.java110.service.smo.ISaveSystemErrorSMO;
 import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.ExceptionUtil;
 import com.java110.utils.util.ExceptionUtil;
-import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -41,6 +40,8 @@ import java.util.List;
 @Component
 @Component
 public class GenerateOweFeeTemplate extends TaskSystemQuartz {
 public class GenerateOweFeeTemplate extends TaskSystemQuartz {
 
 
+    public static final double DEFAULT_ROW = 200.0;
+
 
 
     @Autowired
     @Autowired
     private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
     private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
@@ -125,26 +126,43 @@ public class GenerateOweFeeTemplate extends TaskSystemQuartz {
     private void GenerateOweFeeByFeeConfig(TaskDto taskDto, FeeConfigDto feeConfigDto) throws Exception {
     private void GenerateOweFeeByFeeConfig(TaskDto taskDto, FeeConfigDto feeConfigDto) throws Exception {
 
 
         //当前费用项是否
         //当前费用项是否
-
         FeeDto feeDto = new FeeDto();
         FeeDto feeDto = new FeeDto();
         feeDto.setConfigId(feeConfigDto.getConfigId());
         feeDto.setConfigId(feeConfigDto.getConfigId());
         feeDto.setCommunityId(feeConfigDto.getCommunityId());
         feeDto.setCommunityId(feeConfigDto.getCommunityId());
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
 
 
-        //没有关联费用
-        if (feeDto == null || feeDtos.size() < 1) {
-            return;
-        }
-        for (FeeDto tmpFeeDto : feeDtos) {
+        //先查询总数
+        int count = feeInnerServiceSMOImpl.queryFeesCount(feeDto);
+
+        double record = Math.ceil(count / DEFAULT_ROW);
+
+        for (int page = 1; page <= record; page++) {
             try {
             try {
-                generateFee(tmpFeeDto, feeConfigDto);
+                feeDto.setPage(page);
+                feeDto.setRow(new Double(DEFAULT_ROW).intValue());
+                List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+                //没有关联费用
+                if (feeDto == null || feeDtos.size() < 1) {
+                    continue;
+                }
+                for (FeeDto tmpFeeDto : feeDtos) {
+                    try {
+                        generateFee(tmpFeeDto, feeConfigDto);
+                    } catch (Exception e) {
+                        LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
+                        logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
+                        logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_JOB);
+                        logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e));
+                        saveSystemErrorSMOImpl.saveLog(logSystemErrorPo);
+                        logger.error("生成费用失败", e);
+                    }
+                }
             } catch (Exception e) {
             } catch (Exception e) {
                 LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
                 LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
                 logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
                 logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
                 logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_JOB);
                 logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_JOB);
                 logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e));
                 logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e));
                 saveSystemErrorSMOImpl.saveLog(logSystemErrorPo);
                 saveSystemErrorSMOImpl.saveLog(logSystemErrorPo);
-                logger.error("生成费用失败", e);
+                logger.error("费用出账失败" + feeConfigDto.getConfigId(), e);
             }
             }
         }
         }
 
 

+ 4 - 12
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java

@@ -33,12 +33,7 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Service("getReportFeeMonthStatisticsBMOImpl")
 @Service("getReportFeeMonthStatisticsBMOImpl")
 public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthStatisticsBMO {
 public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthStatisticsBMO {
@@ -246,8 +241,8 @@ public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthSta
             ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailMajor(reportFeeMonthStatisticsDto);
             ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailMajor(reportFeeMonthStatisticsDto);
             if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
             if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
                 for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
                 for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
-                    reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
-                    reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
+//                    reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
+//                    reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
                     reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
                     reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
                 }
                 }
             }
             }
@@ -997,12 +992,9 @@ public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthSta
     }
     }
 
 
     private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
     private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
-
-        Date nowDate = DateUtil.getCurrentDate();
-
         for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
         for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
             try {
             try {
-                int day = DateUtil.daysBetween(nowDate, DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
+                int day = DateUtil.daysBetween(DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A), DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
                         DateUtil.DATE_FORMATE_STRING_A));
                         DateUtil.DATE_FORMATE_STRING_A));
                 reportFeeMonthStatisticsDto.setOweDay(day);
                 reportFeeMonthStatisticsDto.setOweDay(day);
             } catch (Exception e) {
             } catch (Exception e) {