pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoRm.RmOpenCloseValveHistory; import com.dy.pipIrrGlobal.voRm.VoOpenCloseValve; import com.dy.pipIrrGlobal.voSt.VoIntake; import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -76,4 +78,47 @@ * @return */ List<VoOpenCloseValve> getOpenCloseValveReports_history(Map<?, ?> params); /** * 获取指定时间段内从未开过阀的取水口数量 * @param params * @return */ Long getNeverOpenValveIntakesCount(Map<?, ?> params); /** * 获取指定时间段内从未开过阀的取水口 * @param params * @return */ List<VoIntake> getNeverOpenValveIntakes(Map<?, ?> params); /** * 获取指定时间段内开阀次数超过指定值的取水口数量 * @param params * @return */ Long getOpenValveGtIntakesCount(Map<String, Object> params); /** * 获取指定时间段内开阀次数超过指定值的取水口 * @param params * @return */ List<VoIntakeOpenCount> getOpenValveGtIntakes(Map<String, Object> params); /** * 获取指定时间段内开阀次数低于指定值的取水口数量 * @param params * @return */ Long getOpenValveLtIntakesCount(Map<String, Object> params); /** * 获取指定时间段内开阀次数低于指定值的取水口 * @param params * @return */ List<VoIntakeOpenCount> getOpenValveLtIntakes(Map<String, Object> params); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoIntakeOpenCount.java
New file @@ -0,0 +1,21 @@ package com.dy.pipIrrGlobal.voSt; import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import lombok.Data; /** * @author :WuZeYu * @Date :2024/8/5 10:45 * @LastEditTime :2024/8/5 10:45 * @Description 取水口开阀 指定值 次数 */ @Data public class VoIntakeOpenCount extends VoIntake{ private static final long serialVersionUID = 202408051046001L; /** * 指定值 */ private Long recordCount; } pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -425,10 +425,10 @@ <if test = "rtuAddr != null and rtuAddr !=''"> AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') </if> <if test = "timeStart_open != null and timeStop_open != null"> <if test = "timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != '' "> AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} </if> <if test = "timeStart_close != null and timeStop_close != null"> <if test = "timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != '' "> AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} </if> </where> @@ -490,10 +490,10 @@ <if test = "rtuAddr != null and rtuAddr !=''"> AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') </if> <if test = "timeStart_open != null and timeStop_open != null"> <if test = "timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != '' "> AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} </if> <if test = "timeStart_close != null and timeStop_close != null"> <if test = "timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != '' "> AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} </if> </where> @@ -504,4 +504,100 @@ </if> </trim> </select> <!--获取指定时间段内从未开过阀的取水口数量--> <select id="getNeverOpenValveIntakesCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) </select> <!--获取指定时间段内从未开过阀的取水口--> <select id="getNeverOpenValveIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> SELECT inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) ORDER BY inta.id <trim prefix="limit " > <if test="start != null and count != null"> #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} </if> </trim> </select> <!--获取指定时间段内开阀次数超过指定值的取水口数量--> <select id="getOpenValveGtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount > #{value}) a </select> <!--获取指定时间段内开阀次数超过指定值的取水口--> <select id="getOpenValveGtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount > #{value} ORDER BY inta.id <trim prefix="limit " > <if test="start != null and count != null"> #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} </if> </trim> </select> <!--获取指定时间段内开阀次数低于指定值的取水口数量--> <select id="getOpenValveLtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount < #{value}) a </select> <!--获取指定时间段内开阀次数低于指定值的取水口--> <select id="getOpenValveLtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount < #{value} ORDER BY inta.id <trim prefix="limit " > <if test="start != null and count != null"> #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} </if> </trim> </select> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveLastMapper.xml
@@ -445,10 +445,10 @@ <if test = "rtuAddr != null and rtuAddr !=''"> AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') </if> <if test = "timeStart_open != null and timeStop_open != null"> <if test = "timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != '' "> AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} </if> <if test = "timeStart_close != null and timeStop_close != null"> <if test = "timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != '' "> AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} </if> </where> @@ -510,10 +510,10 @@ <if test = "rtuAddr != null and rtuAddr !=''"> AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') </if> <if test = "timeStart_open != null and timeStop_open != null"> <if test = "timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != '' "> AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} </if> <if test = "timeStart_close != null and timeStop_close != null"> <if test = "timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != '' "> AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} </if> </where> pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/report/ReportSv.java
@@ -13,6 +13,8 @@ import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -109,25 +111,35 @@ public QueryResultVo<List<VoOpenCloseValve>> getOpenCloseValveReports_history(OpenCloseValveQO qo) { String timeStart_open = qo.getTimeStart_open(); String timeStop_open = qo.getTimeStop_open(); if(timeStart_open != null) { if(timeStart_open != null && timeStart_open != "") { timeStart_open = timeStart_open + " 00:00:00"; qo.setTimeStop_open(timeStart_open); } else { timeStart_open = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); } if(timeStop_open != null) { qo.setTimeStop_open(timeStart_open); if(timeStop_open != null && timeStop_open != "") { timeStop_open = timeStop_open + " 23:59:59"; qo.setTimeStop_open(timeStop_open); }else { timeStop_open = LocalDate.now() + " 23:59:59"; } qo.setTimeStop_open(timeStop_open); String timeStart_close = qo.getTimeStart_close(); String timeStop_close = qo.getTimeStop_close(); if(timeStart_close != null) { if(timeStart_close != null && timeStart_close != "") { timeStart_close = timeStart_close + " 00:00:00"; qo.setTimeStart_close(timeStart_close); } else { timeStart_close = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); } if(timeStop_close != null) { qo.setTimeStart_close(timeStart_close); if(timeStop_close != null && timeStop_close != "") { timeStop_close = timeStop_close + " 23:59:59"; qo.setTimeStop_close(timeStop_close); }else { timeStop_close = LocalDate.now() + " 23:59:59"; } qo.setTimeStop_close(timeStop_close); Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); Long itemTotal = rmOpenCloseValveHistoryMapper.getOpenCloseValveReportsCount_history(params); pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
@@ -2,10 +2,13 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoRm.RmOnHourReportHistoryMapper; import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; import com.dy.pipIrrGlobal.voSt.VoCumulativeFlow; import com.dy.pipIrrGlobal.voSt.VoIntake; import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount; import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO; import com.dy.pipIrrStatistics.intake.qo.IntakeQO; import com.dy.pipIrrStatistics.intake.qo.IntakeValueQO; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +32,8 @@ public class IntakeSv { @Autowired private RmOnHourReportHistoryMapper rmOnHourReportHistoryMapper; @Autowired private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; /** * 获取指定时间段内未上线的取水口 @@ -112,4 +117,117 @@ rsVo.obj = rmOnHourReportHistoryMapper.getSmallFlowIntakes(params); return rsVo ; } /** * 获取从未开过阀的取水口 * @return */ public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(IntakeQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); if(timeStop != null) { timeStop = timeStop + " 23:59:59"; }else { timeStop = LocalDate.now() + " 23:59:59"; } qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getNeverOpenValveIntakesCount(params)).orElse(0L); QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getNeverOpenValveIntakes(params); return rsVo ; } /** * 获取指定时间段内开阀次数超过指定值的取水口 * @param qo * @return */ public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveGtIntakes(IntakeValueQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); if(timeStop != null) { timeStop = timeStop + " 23:59:59"; }else { timeStop = LocalDate.now() + " 23:59:59"; } qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getOpenValveGtIntakesCount(params)).orElse(0L); QueryResultVo<List<VoIntakeOpenCount>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getOpenValveGtIntakes(params); return rsVo ; } /** * 获取指定时间段内开阀次数低于指定值的取水口 * @param qo * @return */ public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveLtIntakes(IntakeValueQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); if(timeStop != null) { timeStop = timeStop + " 23:59:59"; }else { timeStop = LocalDate.now() + " 23:59:59"; } qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getOpenValveLtIntakesCount(params)).orElse(0L); QueryResultVo<List<VoIntakeOpenCount>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getOpenValveLtIntakes(params); return rsVo ; } } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntkeCtrl.java
@@ -6,8 +6,10 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.voSt.VoCumulativeFlow; import com.dy.pipIrrGlobal.voSt.VoIntake; import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount; import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO; import com.dy.pipIrrStatistics.intake.qo.IntakeQO; import com.dy.pipIrrStatistics.intake.qo.IntakeValueQO; import com.dy.pipIrrStatistics.result.StatisticlResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -90,4 +92,67 @@ return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取从未开过阀的取水口 * @param * @return */ @GetMapping(path = "/getNeverOpenValveIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoIntake>>> getNeverOpenValveIntakes(IntakeQO qo) { try { QueryResultVo<List<VoIntake>> res = intakeSv.getNeverOpenValveIntakes(qo); if(res.itemTotal == 0) { return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.NO_RECORDS.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("获取记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取指定时间段内开阀次数超过指定值的取水口 * @param * @return */ @GetMapping(path = "/getOpenValveGtIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoIntakeOpenCount>>> getOpenValveGtIntakes(IntakeValueQO qo) { try { QueryResultVo<List<VoIntakeOpenCount>> res = intakeSv.getOpenValveGtIntakes(qo); if(res.itemTotal == 0) { return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.NO_RECORDS.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("获取记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取指定时间段内开阀次数低于指定值的取水口 * @param * @return */ @GetMapping(path = "/getOpenValveLtIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoIntakeOpenCount>>> getOpenValveLtIntakes(IntakeValueQO qo) { try { QueryResultVo<List<VoIntakeOpenCount>> res = intakeSv.getOpenValveLtIntakes(qo); if(res.itemTotal == 0) { return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.NO_RECORDS.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("获取记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/qo/IntakeValueQO.java
New file @@ -0,0 +1,23 @@ package com.dy.pipIrrStatistics.intake.qo; import com.dy.common.webUtil.QueryConditionVo; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotBlank; import lombok.Data; /** * @author :WuZeYu * @Date :2024/8/3 9:32 * @LastEditTime :2024/8/3 9:32 * @Description */ @Data public class IntakeValueQO extends IntakeQO { /** * 值 */ @NotBlank(message = "值不能为空") private int value; }