From 8276c60682d1c69e632ac010988c5ada173a178e Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 06 二月 2025 16:28:03 +0800 Subject: [PATCH] 1、大屏展示模块:基本信息统计、当前信息统计、监测信息统计(部分); 2、优化代码。 --- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoBaseInfo.java | 65 +++++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml | 8 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsCtrl.java | 107 +++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/说明.txt | 1 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java | 2 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoCurrentInfo.java | 58 +++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 1 pipIrr-platform/pipIrr-global/src/main/resources/mapper/Ls4StatisticsMapper.xml | 134 ++++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoMonitorInfo.java | 33 +++ pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsSv.java | 127 +++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoLargeScreen/Ls4StatisticsMapper.java | 78 +++++++ 11 files changed, 608 insertions(+), 6 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoLargeScreen/Ls4StatisticsMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoLargeScreen/Ls4StatisticsMapper.java new file mode 100644 index 0000000..9f27c42 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoLargeScreen/Ls4StatisticsMapper.java @@ -0,0 +1,78 @@ +package com.dy.pipIrrGlobal.daoLargeScreen; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:46 + * @Description + */ +@Mapper +public interface Ls4StatisticsMapper extends BaseMapper<Object> { + + /** + * 娑夊強琛屾斂鍖哄垝鎬绘暟 + * @return + */ + Integer totalCountOfDistrict(@Param("level")Integer level) ; + /** + * 鐗囧尯鎬绘暟 + * @return + */ + Integer totalCountOfBlock() ; + /** + * 鍒嗘按鎴挎�绘暟 + * @return + */ + Integer totalCountOfDivide() ; + /** + * 鍙栨按鍙f�绘暟 + * @return + */ + Integer totalCountOfIntake() ; + /** + * 宸茬粦瀹氭帶鍒跺櫒鐨勫彇姘村彛鎬绘暟 + * @return + */ + Integer totalCountOfIntakeWithController() ; + /** + * 鏈粦瀹氭帶鍒跺櫒鐨勫彇姘村彛鎬绘暟 + * @return + */ + Integer totalCountOfIntakeWithoutController() ; + /** + * 闃�鎺у櫒鎬绘暟 + * @return + */ + Integer totalCountOfController() ; + /** + * 娴佹氮闃�鎺у櫒鎬绘暟 + * @return + */ + Integer totalCountOfControllerTramp() ; + + /** + * 寮�闃�鎬绘暟 + */ + Integer totalCountOfOpenValve(@Param("dt") Date dt) ; + + /** + * 鍏抽榾鎬绘暟 + */ + Integer totalCountOfCloseValve(@Param("dt") Date dt) ; + + /** + * 鎶ヨ鎬绘暟 + */ + Integer totalCountOfAlarm(@Param("dt") Date dt) ; + + /** + * 鏃犳姤璀︽�绘暟 + */ + Integer totalCountOfNoAlarm(@Param("dt") Date dt) ; + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java index c4318f7..728a1ae 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java @@ -3,7 +3,6 @@ import com.dy.common.multiDataSource.DataSourceContext; import com.dy.common.mw.protocol.Command; import com.dy.common.mw.protocol.CommandType; -import com.dy.common.softUpgrade.state.UpgradeTaskVo; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import org.springframework.core.env.Environment; diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoBaseInfo.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoBaseInfo.java new file mode 100644 index 0000000..4f4213c --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoBaseInfo.java @@ -0,0 +1,65 @@ +package com.dy.pipIrrGlobal.voLargeScreen; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:40 + * @Description + */ + +@Data +@JsonPropertyOrder({"totalCountOfTown", + "totalCountOfVillage", + "totalCountOfBlock", + "totalCountOfDivide", + "totalCountOfIntake", + "totalCountOfIntakeWithController", + "totalCountOfIntakeWithoutController", + "totalCountOfController", + "totalCountOfControllerTramp" + }) +public class VoBaseInfo { + + private static final long serialVersionUID = 202502060948001L; + + /** + * 涔¢晣鎬绘暟 + */ + public Integer totalCountOfTown ; + + /** + * 琛屾斂鏉戞�绘暟 + */ + public Integer totalCountOfVillage ; + /** + * 鐗囧尯鎬绘暟 + */ + public Integer totalCountOfBlock ; + /** + * 鍒嗘按鎴挎�绘暟 + */ + public Integer totalCountOfDivide ; + /** + * 鍙栨按鍙f�绘暟 + */ + public Integer totalCountOfIntake ; + /** + * 宸茬粦瀹氭帶鍒跺櫒鐨勫彇姘村彛鎬绘暟 + */ + public Integer totalCountOfIntakeWithController ; + /** + * 鏈粦瀹氭帶鍒跺櫒鐨勫彇姘村彛鎬绘暟 + */ + public Integer totalCountOfIntakeWithoutController ; + /** + * 闃�鎺у櫒鎬绘暟 + */ + public Integer totalCountOfController ; + /** + * 娴佹氮闃�鎺у櫒鎬绘暟 + */ + public Integer totalCountOfControllerTramp ; + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoCurrentInfo.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoCurrentInfo.java new file mode 100644 index 0000000..a76175a --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoCurrentInfo.java @@ -0,0 +1,58 @@ +package com.dy.pipIrrGlobal.voLargeScreen; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:40 + * @Description 褰撳墠淇℃伅 + */ + +@Data +@JsonPropertyOrder({"totalCountOfOnLine", + "totalCountOfOffLine", + "totalCountOfOpenValve", + "totalCountOfCloseValve", + "totalCountOfUnknownValve" + }) +public class VoCurrentInfo { + + private static final long serialVersionUID = 202502061348001L; + + /** + * 鍦ㄧ嚎鎬绘暟 + */ + public Integer totalCountOfOnLine ; + /** + * 绂荤嚎鎬绘暟 + */ + public Integer totalCountOfOffLine ; + + /** + * 闃�寮�鎬绘暟 + */ + public Integer totalCountOfOpenValve ; + /** + * 闃�鍏虫�绘暟 + */ + public Integer totalCountOfCloseValve ; + /** + * 鏈煡闃�闂ㄧ姸鎬佹�绘暟 + */ + public Integer totalCountOfUnknownValve ; + + /** + * 鎶ヨ鎬绘暟 + */ + public Integer totalCountOfAlarm ; + /** + * 鏃犳姤璀︽�绘暟 + */ + public Integer totalCountOfNoAlarm ; + /** + * 鏈煡鎶ヨ鐘舵�佹�绘暟 + */ + public Integer totalCountOfUnknownAlarm ; + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoMonitorInfo.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoMonitorInfo.java new file mode 100644 index 0000000..2909d0b --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voLargeScreen/VoMonitorInfo.java @@ -0,0 +1,33 @@ +package com.dy.pipIrrGlobal.voLargeScreen; + +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Data; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:40 + * @Description 鐩戞祴淇℃伅 + */ + +@Data +@JsonPropertyOrder({"totalCountOfOnLine", + "totalCountOfOffLine" + }) +public class VoMonitorInfo { + + private static final long serialVersionUID = 202502061348001L; + + /** + * 浠庢煇鏃朵互鏉ワ紝鏇句笂鎶ヨ繃鏁版嵁鐨勬�绘暟 + */ + public Integer totalCountOfReport ; + /** + * 浠庢煇鏃朵互鏉ワ紝鏈浘涓婃姤杩囨暟鎹殑鎬绘暟 + */ + public Integer totalCountOfNoReport ; + /** + * 浠庢湭涓婃姤杩囨暟鎹殑鎬绘暟 + */ + public Integer totalCountOfNeverReport ; + +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Ls4StatisticsMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Ls4StatisticsMapper.xml new file mode 100644 index 0000000..8674548 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Ls4StatisticsMapper.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dy.pipIrrGlobal.daoLargeScreen.Ls4StatisticsMapper"> + + <select id="totalCountOfDistrict" resultType="java.lang.Integer"> + select + count(*) as count + from ba_district tb + where tb.level = #{level, jdbcType=INTEGER} + and tb.deleted != 1 + </select> + + <select id="totalCountOfBlock" resultType="java.lang.Integer"> + select + count(*) as count + from ba_block tb + where tb.deleted != 1 + </select> + + <select id="totalCountOfDivide" resultType="java.lang.Integer"> + select + count(*) as count + from pr_divide tb + where tb.deleted != 1 + </select> + + <select id="totalCountOfIntake" resultType="java.lang.Integer"> + select + count(*) as count + from pr_intake tb + where tb.deleted != 1 + </select> + + <select id="totalCountOfIntakeWithController" resultType="java.lang.Integer"> + select count(*) as count + from ( + select distinct tb.id + from pr_intake tb + inner join pr_intake_controller ctb on tb.id = ctb.intakeId + where tb.deleted != 1 + and ctb.id is not null + ) otb + </select> + + <select id="totalCountOfIntakeWithoutController" resultType="java.lang.Integer"> + select + count(*) as count + from pr_intake tb + left join pr_intake_controller ctb on tb.id = ctb.intakeId + where tb.deleted != 1 + and ctb.id is null + </select> + + <select id="totalCountOfController" resultType="java.lang.Integer"> + select + count(*) as count + from pr_controller tb + where tb.deleted != 1 + </select> + + <select id="totalCountOfControllerTramp" resultType="java.lang.Integer"> + select + count(*) as count + from pr_controller_tramp tb + </select> + + <select id="totalCountOfOpenValve" resultType="java.lang.Integer"> + select + count(*) as count + from rm_alarm_state_last tb + where valve_state = 0 + <if test="dt != null "> + AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} + </if> + </select> + + <select id="totalCountOfCloseValve" resultType="java.lang.Integer"> + select + count(*) as count + from rm_alarm_state_last tb + where valve_state = 1 + <if test="dt != null "> + AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} + </if> + </select> + + <select id="totalCountOfAlarm" resultType="java.lang.Integer"> + select + count(*) as count + from rm_alarm_state_last tb + where (alarm_remain_water = 1 or + alarm_exceed_year = 1 or + alarm_water_meter_fault = 1 or + alarm_loss = 1 or + alarm_water_meter_break = 1 or + alarm_ele_meter_fault = 1 or + alarm_inner_door = 1 or + alarm_outer_door = 1 or + alarm_ele_miss = 1 or + alarm_ele_exceed = 1 or + alarm_ele_low_volt = 1 or + state_ic_enable = 1 or + alarm_battery_volt = 1 or + alarm_valve = 1) + <if test="dt != null "> + AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} + </if> + </select> + + <select id="totalCountOfNoAlarm" resultType="java.lang.Integer"> + select + count(*) as count + from rm_alarm_state_last tb + where ((alarm_remain_water is null or alarm_remain_water = 0) and + (alarm_remain_water is null or alarm_exceed_year = 0) and + (alarm_remain_water is null or alarm_water_meter_fault = 0) and + (alarm_remain_water is null or alarm_loss = 0) and + (alarm_remain_water is null or alarm_water_meter_break = 0) and + (alarm_remain_water is null or alarm_ele_meter_fault = 0) and + (alarm_remain_water is null or alarm_inner_door = 0) and + (alarm_remain_water is null or alarm_outer_door = 0) and + (alarm_remain_water is null or alarm_ele_miss = 0) and + (alarm_remain_water is null or alarm_ele_exceed = 0) and + (alarm_remain_water is null or alarm_ele_low_volt = 0) and + (alarm_remain_water is null or state_ic_enable = 0) and + (alarm_remain_water is null or alarm_battery_volt = 0) and + (alarm_remain_water is null or alarm_valve = 0) ) + <if test="dt != null "> + AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} + </if> + </select> + + +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml index 6c5d694..3c10897 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml @@ -1336,8 +1336,8 @@ count(ocvh.id) as times from rm_open_close_valve_history ocvh inner join se_client_card cc on CAST(cc.cardNum AS CHAR) = ocvh.cl_ic_card_no - where ocvh.cl_dt <![CDATA[>=]]> #{startDt, jdbcType=BIGINT} - and ocvh.cl_dt <![CDATA[<=]]> #{endDt, jdbcType=BIGINT} + where ocvh.cl_dt <![CDATA[>=]]> #{startDt, jdbcType=TIMESTAMP } + and ocvh.cl_dt <![CDATA[<=]]> #{endDt, jdbcType=TIMESTAMP} group by ocvh.client_id, cc.id </select> <select id="statisticsByClient" resultType="com.dy.pipIrrGlobal.voSt.VoClientConsumeStatistics"> @@ -1347,8 +1347,8 @@ sum(cl_this_time) as duration, count(id) as times from rm_open_close_valve_history - where cl_dt <![CDATA[>=]]> #{startDt, jdbcType=BIGINT} - and cl_dt <![CDATA[<=]]> #{endDt, jdbcType=BIGINT} + where cl_dt <![CDATA[>=]]> #{startDt, jdbcType=TIMESTAMP} + and cl_dt <![CDATA[<=]]> #{endDt, jdbcType=TIMESTAMP} group by client_id </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java index d03d826..5d92f5a 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java @@ -128,7 +128,7 @@ /** * 寰楀埌鎵�鏈夊湪绾夸笌绂荤嚎鏁伴噺缁熻 - * @return [0]=鍦ㄧ嚎鏁伴噺锛孾2]涓婄嚎杩囷紝浣嗗綋鍓嶇绾跨殑鏁伴噺 + * @return [0]=鍦ㄧ嚎鏁伴噺锛孾1]涓婄嚎杩囷紝浣嗗綋鍓嶇绾跨殑鏁伴噺 */ public static Integer[] allOnLineStateStatistics(){ synchronized (map){ diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsCtrl.java new file mode 100644 index 0000000..e42cbc0 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsCtrl.java @@ -0,0 +1,107 @@ +package com.dy.pipIrrStatistics.largeScreen; + +import com.dy.common.aop.SsoAop; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.voLargeScreen.VoBaseInfo; +import com.dy.pipIrrGlobal.voLargeScreen.VoCurrentInfo; +import com.dy.pipIrrGlobal.voLargeScreen.VoMonitorInfo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:32 + * @Description + */ +@Slf4j +@Tag(name = "澶у睆灞曠ず", description = "澶у睆灞曠ず---缁熻淇℃伅") +@RestController +@RequestMapping(path = "ls4Statistics") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class Ls4StatisticsCtrl { + + private Ls4StatisticsSv sv; + + @Autowired + private void setSv(Ls4StatisticsSv sv) { + this.sv = sv; + } + + + /** + * 澶у睆灞曠ず---鍩烘湰淇℃伅 + * @return 鍩烘湰淇℃伅 + */ + @Operation(summary = "澶у睆灞曠ず", description = "鍩烘湰淇℃伅") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鍩烘湰淇℃伅锛圔aseResponse.content:VoBaseInfo{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoBaseInfo.class))} + ) + }) + @GetMapping(path = "baseInfo") + @SsoAop() + public BaseResponse<VoBaseInfo> baseInfo() { + VoBaseInfo res = this.sv.baseInfo(); + return BaseResponseUtils.buildSuccess(res); + } + + + /** + * 澶у睆灞曠ず---褰撳墠淇℃伅 + * @return 褰撳墠淇℃伅 + */ + @Operation(summary = "澶у睆灞曠ず", description = "褰撳墠淇℃伅") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鍩烘湰淇℃伅锛圔aseResponse.content:VoCurrentInfo{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoCurrentInfo.class))} + ) + }) + @GetMapping(path = "currentInfo") + @SsoAop() + public BaseResponse<VoCurrentInfo> currentInfo() throws Exception { + VoCurrentInfo res = this.sv.currentInfo(); + return BaseResponseUtils.buildSuccess(res); + } + + /** + * 澶у睆灞曠ず---鐩戞祴淇℃伅 + * @return 鐩戞祴淇℃伅 + * @param startDt 寮�濮嬫棩鏈燂紙鏍煎紡 yyyy-mm-dd锛� + */ + @Operation(summary = "澶у睆灞曠ず", description = "鐩戞祴淇℃伅") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鍩烘湰淇℃伅锛圔aseResponse.content:VoMonitorInfo{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoMonitorInfo.class))} + ) + }) + @GetMapping(path = "monitorInfo") + @SsoAop() + public BaseResponse<VoMonitorInfo> monitorInfo(Date startDt) { + VoMonitorInfo res = this.sv.monitorInfo(startDt); + return BaseResponseUtils.buildSuccess(res); + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsSv.java new file mode 100644 index 0000000..620ad5f --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/Ls4StatisticsSv.java @@ -0,0 +1,127 @@ +package com.dy.pipIrrStatistics.largeScreen; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.dy.common.mw.protocol.Command; +import com.dy.common.mw.protocol.CommandBackParam; +import com.dy.common.util.DateTime; +import com.dy.common.webUtil.BaseResponse; +import com.dy.pipIrrGlobal.daoLargeScreen.Ls4StatisticsMapper; +import com.dy.pipIrrGlobal.rtuMw.CodeLocal; +import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; +import com.dy.pipIrrGlobal.voLargeScreen.VoBaseInfo; +import com.dy.pipIrrGlobal.voLargeScreen.VoCurrentInfo; +import com.dy.pipIrrGlobal.voLargeScreen.VoMonitorInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.Date; + +/** + * @Author: liurunyu + * @Date: 2025/2/6 10:33 + * @Description + */ +@Slf4j +@Service +public class Ls4StatisticsSv extends Web2RtuMw { + private Environment env; + private RestTemplate restTemplate; + private Ls4StatisticsMapper dao ; + + @Autowired + private void setEnvironment(Environment env){ + this.env = env; + } + @Autowired + private void setRestTemplate(RestTemplate restTemplate){ + this.restTemplate = restTemplate; + } + @Autowired + private void setDao(Ls4StatisticsMapper dao){ + this.dao = dao; + } + + /** + * 鍩烘湰淇℃伅缁熻 + * @return + */ + public VoBaseInfo baseInfo(){ + VoBaseInfo vo = new VoBaseInfo() ; + vo.totalCountOfTown = this.dao.totalCountOfDistrict(3) ; + vo.totalCountOfVillage = this.dao.totalCountOfDistrict(4) ; + vo.totalCountOfBlock = this.dao.totalCountOfBlock() ; + vo.totalCountOfDivide = this.dao.totalCountOfDivide() ; + vo.totalCountOfIntake = this.dao.totalCountOfIntake() ; + vo.totalCountOfIntakeWithController = this.dao.totalCountOfIntakeWithController() ; + vo.totalCountOfIntakeWithoutController = this.dao.totalCountOfIntakeWithoutController() ; + vo.totalCountOfController = this.dao.totalCountOfController() ; + vo.totalCountOfControllerTramp = this.dao.totalCountOfControllerTramp() ; + return vo ; + } + + /** + * 褰撳墠淇℃伅缁熻 + * @return + */ + public VoCurrentInfo currentInfo() throws Exception{ + Integer totalCountOfIntake = this.dao.totalCountOfIntake() ; + Date dtAtXHourBefore = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(DateTime.lastXHour_yyyy_MM_dd_HH_mm_ss(24)) ;//X涓皬鏃跺墠 + VoCurrentInfo vo = new VoCurrentInfo() ; + Integer[] result = this.queryMwOnAndOffLine() ; + vo.totalCountOfOnLine = result[0] ; + vo.totalCountOfOffLine = totalCountOfIntake - vo.totalCountOfOnLine; ; + vo.totalCountOfOpenValve = this.dao.totalCountOfOpenValve(dtAtXHourBefore) ; + vo.totalCountOfCloseValve = this.dao.totalCountOfCloseValve(dtAtXHourBefore) ; + vo.totalCountOfUnknownValve = totalCountOfIntake - vo.totalCountOfOpenValve - vo.totalCountOfCloseValve ; + vo.totalCountOfAlarm = this.dao.totalCountOfAlarm(dtAtXHourBefore) ; + vo.totalCountOfNoAlarm = this.dao.totalCountOfNoAlarm(dtAtXHourBefore) ; + vo.totalCountOfUnknownAlarm = totalCountOfIntake - vo.totalCountOfAlarm - vo.totalCountOfNoAlarm ; + return vo ; + } + + /** + * 鐩戞祴淇℃伅缁熻 + * @return + */ + public VoMonitorInfo monitorInfo(Date startDt){ + VoMonitorInfo vo = new VoMonitorInfo() ; + return vo ; + } + + /** + * 鏌ヨ鍙栨按鍙e湪绾垮拰绂荤嚎缁熻 + * @return + */ + private Integer[] queryMwOnAndOffLine() { + Integer[] result = new Integer[]{0,0} ; + //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨRTU鍦ㄧ嚎缁熻鎯呭喌 + Command com = this.createInnerCommand(CodeLocal.onLineStatistics); + String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ; + BaseResponse res = this.sendPostRequest2Mw(restTemplate, rqUrl, com) ; + if(res != null){ + if(res.isSuccess()){ + Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; + CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ; + if(bakParam != null){ + if(bakParam.getSuccess().booleanValue() && reCom.getAttachment() != null){ + //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋� + JSONObject comRes = (JSONObject) JSON.toJSON(reCom.getAttachment()); + result[0] = comRes.getInteger("onLineNum") ; + result[1] = comRes.getInteger("offLineNum") ; + } + }else{ + log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟"); + } + }else{ + log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ; + } + }else{ + log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null"); + } + return result ; + } +} diff --git "a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..952e79b --- /dev/null +++ "b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/largeScreen/\350\257\264\346\230\216.txt" @@ -0,0 +1 @@ +澶у睆绯荤粺锛坙argeScreen锛岀缉鍐橪s锛� \ No newline at end of file -- Gitblit v1.8.0