liurunyu
2025-01-09 f7b2aa672c00c2c35b08cdf19b8fa4bcad6df59d
优化”未曾上线“功能实现
3个文件已修改
179 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOnHourReportHistoryMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntkeCtrl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOnHourReportHistoryMapper.xml
@@ -261,16 +261,18 @@
        COUNT(*) AS recordCount
    FROM pr_intake inta
    LEFT JOIN
         (SELECT * FROM rm_on_hour_report_history
         (SELECT intake_id FROM rm_on_hour_report_history
         <where>
           <if test = "timeStart != null and timeStop != null">
           dt BETWEEN #{timeStart} AND #{timeStop}
           <if test = "idStart != null">
             id <![CDATA[>=]]> #{idStart}
           </if>
           <if test = "idEnd != null">
             AND id <![CDATA[<=]]> #{idEnd}
           </if>
         </where>) his
         ON his.intake_id = inta.id
    INNER JOIN ba_block blo ON blo.id = inta.blockId
    LEFT JOIN ba_block blo ON blo.id = inta.blockId
    WHERE his.intake_id IS NULL AND inta.deleted = 0
  </select>
  <!--获取指定时间段内未上线的取水口-->
@@ -278,17 +280,22 @@
    SELECT
      inta.id AS intakeId,
      inta.name AS intakeNum,
      inta.lng AS lng,
      inta.lat AS lat,
      blo.name AS blockName
    FROM pr_intake inta
    LEFT JOIN
    (SELECT * FROM rm_on_hour_report_history
    (SELECT intake_id FROM rm_on_hour_report_history
    <where>
      <if test = "timeStart != null and timeStop != null">
        dt BETWEEN #{timeStart} AND #{timeStop}
      <if test = "idStart != null">
        id <![CDATA[>=]]> #{idStart}
      </if>
      <if test = "idEnd != null">
        AND id <![CDATA[<=]]> #{idEnd}
      </if>
    </where>) his
    ON his.intake_id = inta.id
    INNER JOIN ba_block blo ON blo.id = inta.blockId
    LEFT JOIN ba_block blo ON blo.id = inta.blockId
    WHERE his.intake_id IS NULL AND inta.deleted = 0
    ORDER BY inta.id
    <trim prefix="limit " >
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
@@ -55,29 +55,10 @@
     * @param qo
     * @return
     */
    public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo) {
        DecimalFormat df = new DecimalFormat("0.00");
        /**
         * 补齐起止时间,如果开始时间为空,则默认为当前日期
         */
        String timeStart = qo.getTimeStart();
        String timeStop = qo.getTimeStop();
        if(timeStop != null) {
            timeStop = timeStop + " 23:59:59";
            if(timeStart != null) {
                timeStart = timeStart + " 00:00:00";
            }else {
                timeStart = LocalDate.now() + " 00:00:00";
            }
        }else {
            timeStart = null;
        }
        qo.setTimeStart(timeStart);
        qo.setTimeStop(timeStop);
        // 生成查询参数
    public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo, Long idStart, Long idEnd) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
        params.put("idStart", idStart) ;
        params.put("idEnd", idEnd) ;
        // 获取符合条件的记录数
        Long itemTotal = Optional.ofNullable(rmOnHourReportHistoryMapper.getNotOnlineIntakesCount(params)).orElse(0L);
@@ -89,6 +70,43 @@
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmOnHourReportHistoryMapper.getNotOnlineIntakes(params);
        return rsVo ;
    }
    /**
     * 最近未报数的取水口
     * @param qo
     * @return
     */
    public QueryResultVo<List<VoIntakeUnReported>> getUnReportedIntakes(CommonQO qo) {
        String timeStart = qo.getTimeStart();
        String timeStop = qo.getTimeStop();
        if(timeStart == "") {
            timeStart = null;
        }
        if(timeStop == "") {
            timeStop = null;
        }
        if(timeStart != null && timeStart != "") {
            timeStart = timeStart + " 00:00:00";
        }
        qo.setTimeStart(timeStart);
        if(timeStop != null && timeStop != "") {
            timeStop = timeStop + " 23:59:59";
        }
        qo.setTimeStop(timeStop);
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
        Long itemTotal = rmOnHourReportLastMapper.getUnReportedIntakesCount(params);
        QueryResultVo<List<VoIntakeUnReported>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmOnHourReportLastMapper.getUnReportedIntakes(params);
        return rsVo ;
    }
@@ -690,40 +708,4 @@
        return rsVo ;
    }
    /**
     * 最近未报数的取水口
     * @param qo
     * @return
     */
    public QueryResultVo<List<VoIntakeUnReported>> getUnReportedIntakes(CommonQO qo) {
        String timeStart = qo.getTimeStart();
        String timeStop = qo.getTimeStop();
        if(timeStart == "") {
            timeStart = null;
        }
        if(timeStop == "") {
            timeStop = null;
        }
        if(timeStart != null && timeStart != "") {
            timeStart = timeStart + " 00:00:00";
        }
        qo.setTimeStart(timeStart);
        if(timeStop != null && timeStop != "") {
            timeStop = timeStop + " 23:59:59";
        }
        qo.setTimeStop(timeStop);
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
        Long itemTotal = rmOnHourReportLastMapper.getUnReportedIntakesCount(params);
        QueryResultVo<List<VoIntakeUnReported>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmOnHourReportLastMapper.getUnReportedIntakes(params);
        return rsVo ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntkeCtrl.java
@@ -38,26 +38,58 @@
public class IntkeCtrl {
    private final IntakeSv intakeSv;
    /**
    /** ok 111
     * 获取指定时间段内未上线的取水口
     * @param qo
     * @return
     */
    @GetMapping(path = "/getNotOnlineIntakes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoIntake>>> getNotOnlineIntakes(@Valid CommonQO qo, BindingResult bindingResult) {
    public BaseResponse<QueryResultVo<List<VoIntake>>> getNotOnlineIntakes(@Valid CommonQO qo, BindingResult bindingResult) throws Exception {
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        String timeStart = qo.getTimeStart();
        String timeStop = qo.getTimeStop();
        Long startId = null ;
        Long endId = null ;
        if(timeStart != null && !timeStart.trim().equals("")){
            int[] ymdStart = DateTime.yyyy_MM_dd_2_ymdGroup(timeStart) ;
            startId = IDLongGenerator.generateOneDayStartId(ymdStart[0], ymdStart[1], ymdStart[2]) ;
        }
        if(timeStop != null && !timeStop.trim().equals("")){
            int[] ymdEnd = DateTime.yyyy_MM_dd_2_ymdGroup(timeStop) ;
            endId = IDLongGenerator.generateOneDayStartId(ymdEnd[0], ymdEnd[1], ymdEnd[2]) ;
        }
        if(startId != null && endId != null){
            if(endId < startId){
                return BaseResponseUtils.buildErrorMsg("截止时间不能早于开始时间");
            }
        }
        try {
            return BaseResponseUtils.buildSuccess(intakeSv.getNotOnlineIntakes(qo));
            return BaseResponseUtils.buildSuccess(intakeSv.getNotOnlineIntakes(qo, startId, endId));
        } catch (Exception e) {
            log.error("获取记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /** ok 112
     * 最近未报数的取水口
     * @param
     * @return
     */
    @GetMapping(path = "/getUnReportedIntakes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoIntakeUnReported>>> getUnReportedIntakes(CommonQO qo) {
        try {
            QueryResultVo<List<VoIntakeUnReported>> res = intakeSv.getUnReportedIntakes(qo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("获取记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /** ok 1
     * 获取累计流量超过指定值的取水口
     * @param qo
@@ -559,20 +591,4 @@
        }
    }
    /**
     * 最近未报数的取水口
     * @param
     * @return
     */
    @GetMapping(path = "/getUnReportedIntakes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoIntakeUnReported>>> getUnReportedIntakes(CommonQO qo) {
        try {
            QueryResultVo<List<VoIntakeUnReported>> res = intakeSv.getUnReportedIntakes(qo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("获取记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}