Ver código fonte

加入欠费约束

java110 5 anos atrás
pai
commit
3647f5f6db

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

@@ -46,6 +46,8 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
 
     private String statusCd = "0";
 
+    private int oweDay;
+
 
     public String getReceivableAmount() {
         return receivableAmount;
@@ -255,4 +257,12 @@ public class ReportFeeMonthStatisticsDto extends PageDto implements Serializable
     public void setEndTime(String endTime) {
         this.endTime = endTime;
     }
+
+    public int getOweDay() {
+        return oweDay;
+    }
+
+    public void setOweDay(int oweDay) {
+        this.oweDay = oweDay;
+    }
 }

+ 84 - 0
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -561,5 +561,89 @@
             limit #{page}, #{row}
         </if>
     </select>
+    <select id="queryOweFeeDetailCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from (
+        select t.obj_name objName,t.fee_name feeName,pfc.start_time,SUM(t.owe_amount) oweAmount
+        from report_fee_month_statistics t
+        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
+        where t.status_cd = '0'
+        <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}
+        </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="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="startTime !=null">
+            and t.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null">
+            and t.create_time &lt;= #{endTime}
+        </if>
+        group by t.config_id,t.fee_name,pfc.start_time,t.obj_id,t.obj_name
+        HAVING oweAmount > 0
+        ) t
+    </select>
+
+    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
+    <select id="queryOweFeeDetail" parameterType="Map" resultType="Map">
+        select t.obj_name objName,t.fee_name feeName,pfc.start_time feeCreateTime,SUM(t.receivable_amount) receivableAmount,SUM(t.received_amount) receivedAmount,SUM(t.owe_amount) oweAmount
+        from report_fee_month_statistics t
+        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
+        where t.status_cd = '0'
+        <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}
+        </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="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="startTime !=null">
+            and t.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null">
+            and t.create_time &lt;= #{endTime}
+        </if>
+        group by t.config_id,t.fee_name,pfc.start_time,t.obj_id,t.obj_name
+        HAVING oweAmount > 0
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
+    </select>
 
 </mapper>

+ 15 - 0
java110-interface/src/main/java/com/java110/intf/report/IReportFeeMonthStatisticsInnerServiceSMO.java

@@ -114,6 +114,21 @@ public interface IReportFeeMonthStatisticsInnerServiceSMO {
      */
     @RequestMapping(value = "/queryFeeDetail", method = RequestMethod.POST)
     List<ReportFeeMonthStatisticsDto> queryFeeDetail(@RequestBody ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
+    /**
+     * 查询费用汇总表个数
+     * @param reportFeeMonthStatisticsDto
+     * @return
+     */
+    @RequestMapping(value = "/queryOweFeeDetailCount", method = RequestMethod.POST)
+    int queryOweFeeDetailCount(@RequestBody ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
+
+    /**
+     * 查询费用汇总表
+     * @param reportFeeMonthStatisticsDto
+     * @return
+     */
+    @RequestMapping(value = "/queryOweFeeDetail", method = RequestMethod.POST)
+    List<ReportFeeMonthStatisticsDto> queryOweFeeDetail(@RequestBody ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
 
 
 }

+ 26 - 0
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java

@@ -470,4 +470,30 @@ public class DateUtil {
             return false;
         }
     }
+
+    //获取两个日期之间的天数
+    public static int daysBetween(Date now, Date returnDate) {
+        Calendar cNow = Calendar.getInstance();
+        Calendar cReturnDate = Calendar.getInstance();
+        cNow.setTime(now);
+        cReturnDate.setTime(returnDate);
+        setTimeToMidnight(cNow);
+        setTimeToMidnight(cReturnDate);
+        long todayMs = cNow.getTimeInMillis();
+        long returnMs = cReturnDate.getTimeInMillis();
+        long intervalMs = todayMs - returnMs;
+        return millisecondsToDays(intervalMs);
+    }
+
+    //获取两个日期之间的毫秒数
+    private static void setTimeToMidnight(Calendar calendar) {
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+    }
+
+    //获取两个日期之间的分钟数
+    private static int millisecondsToDays(long intervalMs) {
+        return (int) (intervalMs / (1000 * 86400));
+    }
 }

+ 35 - 0
service-report/src/main/java/com/java110/report/api/ReportFeeMonthStatisticsApi.java

@@ -243,5 +243,40 @@ public class ReportFeeMonthStatisticsApi {
         return getReportFeeMonthStatisticsBMOImpl.queryFeeDetail(reportFeeMonthStatisticsDto);
     }
 
+    /**
+     * 查询费用分项表
+     *
+     * @param communityId 小区ID
+     * @return
+     * @serviceCode /reportFeeMonthStatistics/queryOweFeeDetail
+     * @path /app/reportFeeMonthStatistics/queryOweFeeDetail
+     */
+    @RequestMapping(value = "/", method = RequestMethod.GET)
+    public ResponseEntity<String> queryOweFeeDetail(@RequestParam(value = "communityId") String communityId,
+                                                 @RequestParam(value = "floorId", required = false) String floorId,
+                                                 @RequestParam(value = "floorNum", required = false) String floorNum,
+                                                 @RequestParam(value = "unitNum", required = false) String unitNum,
+                                                 @RequestParam(value = "unitId", required = false) String unitId,
+                                                 @RequestParam(value = "roomId", required = false) String roomId,
+                                                 @RequestParam(value = "roomNum", required = false) String roomNum,
+                                                 @RequestParam(value = "startTime", required = false) String startTime,
+                                                 @RequestParam(value = "endTime", required = false) String endTime,
+                                                 @RequestParam(value = "page") int page,
+                                                 @RequestParam(value = "row") int row) {
+        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
+        reportFeeMonthStatisticsDto.setPage(page);
+        reportFeeMonthStatisticsDto.setRow(row);
+        reportFeeMonthStatisticsDto.setCommunityId(communityId);
+        reportFeeMonthStatisticsDto.setFloorId(floorId);
+        reportFeeMonthStatisticsDto.setFloorNum(floorNum);
+        reportFeeMonthStatisticsDto.setUnitId(unitId);
+        reportFeeMonthStatisticsDto.setUnitNum(unitNum);
+        reportFeeMonthStatisticsDto.setRoomId(roomId);
+        reportFeeMonthStatisticsDto.setRoomNum(roomNum);
+        reportFeeMonthStatisticsDto.setStartTime(startTime);
+        reportFeeMonthStatisticsDto.setEndTime(endTime);
+        return getReportFeeMonthStatisticsBMOImpl.queryOweFeeDetail(reportFeeMonthStatisticsDto);
+    }
+
 
 }

+ 1 - 0
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/IGetReportFeeMonthStatisticsBMO.java

@@ -29,5 +29,6 @@ public interface IGetReportFeeMonthStatisticsBMO {
 
     ResponseEntity<String> queryFeeBreakdown(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
     ResponseEntity<String> queryFeeDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
+    ResponseEntity<String> queryOweFeeDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto);
 
 }

+ 38 - 0
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java

@@ -3,6 +3,7 @@ package com.java110.report.bmo.reportFeeMonthStatistics.impl;
 import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
 import com.java110.intf.IReportFeeMonthStatisticsInnerServiceSMO;
 import com.java110.report.bmo.reportFeeMonthStatistics.IGetReportFeeMonthStatisticsBMO;
+import com.java110.utils.util.DateUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,6 +13,7 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Service("getReportFeeMonthStatisticsBMOImpl")
@@ -117,5 +119,41 @@ public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthSta
         return responseEntity;
     }
 
+    @Override
+    public ResponseEntity<String> queryOweFeeDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailCount(reportFeeMonthStatisticsDto);
+
+        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
+        if (count > 0) {
+            reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetail(reportFeeMonthStatisticsDto);
+
+            freshReportOweDay(reportFeeMonthStatisticsDtos);
+        } else {
+            reportFeeMonthStatisticsDtos = new ArrayList<>();
+        }
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportFeeMonthStatisticsDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        return responseEntity;
+    }
+
+    private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
+
+        Date monthFirstDate = DateUtil.getNextMonthFirstDate();
+
+        for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+            try {
+                int day = DateUtil.daysBetween(DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
+                        DateUtil.DATE_FORMATE_STRING_A), monthFirstDate);
+                reportFeeMonthStatisticsDto.setOweDay(day);
+            } catch (Exception e) {
+                logger.error("计算欠费天数失败", e);
+            }
+
+        }
+    }
+
 
 }

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

@@ -139,6 +139,25 @@ public interface IReportFeeMonthStatisticsServiceDao {
     List<Map> queryFeeDetail(Map info) throws DAOException;
 
 
+    /**
+     * 查询费用月统计总数
+     *
+     * @param info 费用月统计信息
+     * @return 费用月统计数量
+     */
+    int queryOweFeeDetailCount(Map info);
+
+
+    /**
+     * 查询费用月统计信息(instance过程)
+     * 根据bId 查询费用月统计信息
+     *
+     * @param info bId 信息
+     * @return 费用月统计信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> queryOweFeeDetail(Map info) throws DAOException;
+
 
 
 }

+ 20 - 0
service-report/src/main/java/com/java110/report/dao/impl/ReportFeeMonthStatisticsServiceDaoImpl.java

@@ -191,6 +191,26 @@ public class ReportFeeMonthStatisticsServiceDaoImpl extends BaseServiceDao imple
 
         return businessReportFeeMonthStatisticsInfos;
     }
+    @Override
+    public int queryOweFeeDetailCount(Map info) {
+        logger.debug("查询费用月统计数据 入参 info : {}", info);
+
+        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.queryOweFeeDetailCount", info);
+        if (businessReportFeeMonthStatisticsInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessReportFeeMonthStatisticsInfos.get(0).get("count").toString());
+    }
+
+    @Override
+    public List<Map> queryOweFeeDetail(Map info) throws DAOException {
+        logger.debug("查询费用月统计信息 入参 info : {}", info);
+
+        List<Map> businessReportFeeMonthStatisticsInfos = sqlSessionTemplate.selectList("reportFeeMonthStatisticsServiceDaoImpl.queryOweFeeDetail", info);
+
+        return businessReportFeeMonthStatisticsInfos;
+    }
 
 
 

+ 19 - 0
service-report/src/main/java/com/java110/report/smo/impl/ReportFeeMonthStatisticsInnerServiceSMOImpl.java

@@ -152,6 +152,25 @@ public class ReportFeeMonthStatisticsInnerServiceSMOImpl extends BaseServiceSMO
 
         return reportFeeMonthStatisticss;
     }
+    @Override
+    public int queryOweFeeDetailCount(@RequestBody ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        return reportFeeMonthStatisticsServiceDaoImpl.queryOweFeeDetailCount(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto));
+    }
+
+    @Override
+    public List<ReportFeeMonthStatisticsDto> queryOweFeeDetail(@RequestBody ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        //校验是否传了 分页信息
+
+        int page = reportFeeMonthStatisticsDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            reportFeeMonthStatisticsDto.setPage((page - 1) * reportFeeMonthStatisticsDto.getRow());
+        }
+
+        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticss = BeanConvertUtil.covertBeanList(reportFeeMonthStatisticsServiceDaoImpl.queryOweFeeDetail(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)), ReportFeeMonthStatisticsDto.class);
+
+        return reportFeeMonthStatisticss;
+    }
 
 
     public IReportFeeMonthStatisticsServiceDao getReportFeeMonthStatisticsServiceDaoImpl() {