liurunyu
2024-07-31 9c0d574df29258bed16ae02344d652e385f0ab4d
通信中间件对报警的取水口间隔发送消息实现
8个文件已修改
88 ■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/upVos/DataAlarmVo.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmAlarmStateLast.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmAlarmStateLastMapper.xml 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/ServerProperties.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealAlarmStatus.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkFindP206V1_0_0.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/upVos/DataAlarmVo.java
@@ -9,6 +9,34 @@
    public Byte meter ;//流量计故障
    public Byte valve ;//阀门
    public boolean hasAlarm(){
        boolean flag = false ;
        if((batteryVolt != null && batteryVolt == 1) ||
                (loss != null && loss == 1) ||
                (meter != null && meter == 1) ||
                (valve != null && valve == 1)){
            flag = true ;
        }
        return flag ;
    }
    public String alarmContent(){
        String txt = "" ;
        if(batteryVolt != null && batteryVolt == 1){
            txt += "蓄电池电压报警" ;
        }
        if(meter != null && meter == 1){
            txt += ",流量计故障报警" ;
        }
        if(valve != null && valve == 1){
            txt += ",阀门故障报警" ;
        }
       if(loss != null && loss == 1){
            txt += ",漏损报警" ;
        }
        return txt ;
    }
    public String toString(){
        StringBuilder str = new StringBuilder() ;
        str.append("      报警:\n");
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmAlarmStateLast.java
@@ -160,6 +160,11 @@
     */
    public Byte powerType;
    /**
     * 发送消息时刻
     */
    public Long sendMsTime ;
    public void valueFrom(DataV1_0_1 dV1_0_1, String rtuDt, DataAlarmVo alarmVo, DataStateVo stateVo) throws Exception{
        this.dt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(dV1_0_1.dt)   ;
        this.rtuDt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(rtuDt)  ;
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmAlarmStateLastMapper.xml
@@ -28,13 +28,14 @@
    <result column="alarm_battery_volt" jdbcType="TINYINT" property="alarmBatteryVolt" />
    <result column="alarm_valve" jdbcType="TINYINT" property="alarmValve" />
    <result column="power_type" jdbcType="TINYINT" property="alarmValve" />
    <result column="send_ms_time" jdbcType="BIGINT" property="sendMsTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, controller_id, intake_id, rtu_addr, dt, rtu_dt, valve_state, alarm_remain_water,
    alarm0_water_remain, alarm_exceed_year, alarm_water_meter_fault, alarm_loss, alarm_water_meter_break,
    alarm_ele_meter_fault, alarm0_money_remain, alarm_inner_door, alarm_outer_door, alarm_ele_miss, 
    alarm_ele_exceed, alarm_ele_low_volt, state_ic_enable,alarm_battery_volt,alarm_valve,power_type
    alarm_ele_exceed, alarm_ele_low_volt, state_ic_enable,alarm_battery_volt,alarm_valve,power_type,send_ms_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -64,7 +65,8 @@
      alarm_loss, alarm_water_meter_break, alarm_ele_meter_fault, 
      alarm0_money_remain, alarm_inner_door, alarm_outer_door, 
      alarm_ele_miss, alarm_ele_exceed, alarm_ele_low_volt, 
      state_ic_enable,alarm_battery_volt,alarm_valve,power_type)
      state_ic_enable,alarm_battery_volt,alarm_valve,power_type,
      send_ms_time)
    values (#{id,jdbcType=BIGINT}, #{controllerId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, 
      #{rtuAddr,jdbcType=VARCHAR}, #{dt,jdbcType=TIMESTAMP}, #{rtuDt,jdbcType=TIMESTAMP}, 
      #{valveState,jdbcType=TINYINT}, #{alarmRemainWater,jdbcType=TINYINT}, #{alarm0WaterRemain,jdbcType=TINYINT}, 
@@ -73,7 +75,7 @@
      #{alarm0MoneyRemain,jdbcType=TINYINT}, #{alarmInnerDoor,jdbcType=TINYINT}, #{alarmOuterDoor,jdbcType=TINYINT}, 
      #{alarmEleMiss,jdbcType=TINYINT}, #{alarmEleExceed,jdbcType=TINYINT}, #{alarmEleLowVolt,jdbcType=TINYINT},
      #{stateIcEnable,jdbcType=TINYINT}, #{alarmBatteryVolt,jdbcType=TINYINT}, #{alarmValve,jdbcType=TINYINT},
      #{powerType,jdbcType=TINYINT})
      #{powerType,jdbcType=TINYINT},#{sendMsTime,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmAlarmStateLast">
    <!--@mbg.generated-->
@@ -151,6 +153,9 @@
     <if test="powerType != null">
        power_type,
      </if>
     <if test="sendMsTime != null">
       send_ms_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
@@ -224,6 +229,9 @@
      </if>
     <if test="powerType != null">
        #{powerType,jdbcType=TINYINT},
      </if>
      <if test="sendMsTime != null">
        #{sendMsTime,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
@@ -300,6 +308,9 @@
      <if test="powerType != null">
        power_type = #{powerType,jdbcType=TINYINT},
      </if>
      <if test="sendMsTime != null">
        send_ms_time = #{sendMsTime,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
@@ -328,7 +339,8 @@
      state_ic_enable = #{stateIcEnable,jdbcType=TINYINT},
      alarm_battery_volt = #{alarmBatteryVolt,jdbcType=TINYINT},
      alarm_valve = #{alarmValve,jdbcType=TINYINT},
      power_type = #{powerType,jdbcType=TINYINT}
      power_type = #{powerType,jdbcType=TINYINT},
      send_ms_time = #{powerType,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据指定条件获取记录总数-->
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
@@ -189,9 +189,9 @@
            //工作报太频繁,N次上报处理1次,取值范围是1-100
            ServerProperties.workReportDealOneByTimes =  conf.getSetAttrPlusInt(doc, "config.base", "workReportDealOneByTimes", null, 1, 100, null) ;
            if(ServerProperties.workReportDealOneByTimes < 1 || ServerProperties.workReportDealOneByTimes > 100){
                throw new Exception("workReportDealOneByTimes取值必须是1~100") ;
            }
            //有报警发生时,向钉钉发送消息的间隔时长(分钟)
            ServerProperties.sendDingDingAlarmMsInterval =  conf.getSetAttrPlusInt(doc, "config.base", "sendDingDingAlarmMsInterval", null, 1, 600, null) ;
            //设置ID生成器的后缀
            IDLongGenerator.setSuffix(ServerProperties.dbDataIdSuffix.intValue());
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/ServerProperties.java
@@ -46,4 +46,7 @@
    //工作报太频繁,N次上报处理1次
    public static Integer workReportDealOneByTimes = 5 ;
    //有报警发生时,向钉钉发送消息的间隔时长(分钟)
    public static Integer sendDingDingAlarmMsInterval = 60 ;
}
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealAlarmStatus.java
@@ -3,6 +3,7 @@
import com.dy.common.mw.protocol.p206V1_0_0.upVos.*;
import com.dy.common.util.DateTime;
import com.dy.pipIrrGlobal.pojoRm.RmAlarmStateHistory;
import com.dy.rtuMw.server.ServerProperties;
import com.dy.rtuMw.server.rtuData.TaskSurpport;
import com.dy.rtuMw.server.rtuData.dbSv.DbSv;
import com.dy.common.mw.protocol.Data;
@@ -92,8 +93,23 @@
            po.intakeId = controller==null?null:controller.getIntakeId() ;
            po.rtuAddr = rtuAddr ;
            po.valueFrom(dV1_0_1, rtuDt, alarmVo, stateVo);
            if(alarmVo.hasAlarm()){
                po.sendMsTime = System.currentTimeMillis() ;
                this.sendMessage(controller, alarmVo);
            }
            sv.saveRmAlarmStateLast(po) ;
        }else{
            if(po.sendMsTime == null){
                po.sendMsTime = System.currentTimeMillis() ;
                this.sendMessage(controller, alarmVo);
            }else{
                Long now = System.currentTimeMillis() ;
                if(((now - po.sendMsTime) / (1000 * 60)) > ServerProperties.sendDingDingAlarmMsInterval){
                    //大于规定的间隔时间
                    po.sendMsTime = System.currentTimeMillis() ;
                    this.sendMessage(controller, alarmVo);
                }
            }
            po = this.update(controller, po, rtuDt, dV1_0_1, alarmVo, stateVo) ;
            sv.updateRmAlarmStateLast(po);
        }
@@ -129,7 +145,7 @@
    /**
     * 虚拟卡在取水中的占用状态改为非应用状态
     * 虚拟卡在取水口上的占用状态改为非应用状态
     */
    private void updateVirCardNoUseState(DbSv sv,
                                         PrController controller,
@@ -146,4 +162,8 @@
    }
    private void sendMessage(PrController controller, DataAlarmVo alarmVo){
        String ms = "取水口" + controller.getIntakeName() + "产生报警:" + alarmVo.alarmContent() ;
    }
}
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkFindP206V1_0_0.java
@@ -1,8 +1,6 @@
package com.dy.rtuMw.server.rtuData.p206V1_0_0;
import com.dy.common.mw.protocol.p206V1_0_0.DataV1_0_1;
import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCd02Vo;
import com.dy.rtuMw.server.rtuData.TaskSurpport;
import com.dy.common.mw.protocol.Data;
import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0;
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml
@@ -20,6 +20,7 @@
        cacheUpDownDataMaxCount:上下行数据缓存队列中缓存数据个数的最大值,这个与现实项目所接水表数相关
        disconnectedByNoUpDataMinutes:没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2-100
        workReportDealOneByTimes: 工作报太频繁,N次上报处理1次,取值范围是1-100
        sendDingDingAlarmMsInterval: 有报警发生时,向钉钉发送消息的间隔时长(分钟)
         -->
        <base
            orgTag="ym"
@@ -36,6 +37,7 @@
            cacheUpDownDataMaxCount="110000"
            disconnectedByNoUpDataMinutes="3"
            workReportDealOneByTimes="5"
            sendDingDingAlarmMsInterval="60"
        />
        
        <!--