Kaynağa Gözat

告警阶段提交:iots告警的业务类

yf_zn 9 ay önce
ebeveyn
işleme
17deee1bcb

+ 7 - 1
src/main/java/com/yunfeiyun/agmp/iots/warn/job/WarnJob.java

@@ -1,17 +1,23 @@
 package com.yunfeiyun.agmp.iots.warn.job;
 
+import com.yunfeiyun.agmp.iots.warn.service.ReCountService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 @Slf4j
 @Component
 public class WarnJob {
+
+    @Autowired
+    private ReCountService reCountService;
+
     /**
      * 每天凌晨12点清除重复次数
      */
     @Scheduled(cron = "0 0 0 * * ?")
     public void resetReCount() {
-
+        reCountService.resetAllReCount();
     }
 }

+ 14 - 0
src/main/java/com/yunfeiyun/agmp/iots/warn/mapper/IotWarnBussinessMapper.java

@@ -0,0 +1,14 @@
+package com.yunfeiyun.agmp.iots.warn.mapper;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotWarncount;
+
+public interface IotWarnBussinessMapper {
+    /**
+     * 查询设备+配置的重复次数
+     *
+     * @param devId
+     * @param configId
+     * @return
+     */
+    IotWarncount selectIotWarnCountByDevAndConfig(String devId, String configId);
+}

+ 23 - 0
src/main/java/com/yunfeiyun/agmp/iots/warn/service/IotWarnBussinessService.java

@@ -0,0 +1,23 @@
+package com.yunfeiyun.agmp.iots.warn.service;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotWarncount;
+import com.yunfeiyun.agmp.iots.warn.mapper.IotWarnBussinessMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class IotWarnBussinessService {
+    @Autowired
+    private IotWarnBussinessMapper iotWarncountMapper;
+
+    /**
+     * 查询设备+配置的重复次数
+     *
+     * @param devId
+     * @param configId
+     * @return
+     */
+    public IotWarncount selectIotWarnCountByDevAndConfig(String devId, String configId) {
+        return iotWarncountMapper.selectIotWarnCountByDevAndConfig(devId, configId);
+    }
+}

+ 15 - 1
src/main/java/com/yunfeiyun/agmp/iots/warn/service/ReCountService.java

@@ -1,6 +1,7 @@
 package com.yunfeiyun.agmp.iots.warn.service;
 
 import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -8,9 +9,16 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class ReCountService {
+    @Autowired
+    private IotWarnBussinessService iotWarnBussinessService;
 
+    /**
+     * 针对预警解析出来的结果进行处理
+     *
+     * @param warnResult
+     */
     public void handlerMessage(WarnResult warnResult) {
-        // 触发了预警,进行瑞校验处理
+        // 触发了预警,进行校验处理
         if (warnResult.isTriggered()) {
             // 当前的获取重复次数
             int reCount = 5;
@@ -46,4 +54,10 @@ public class ReCountService {
         }
     }
 
+    /**
+     * 清空重复次数
+     */
+    public void resetAllReCount() {
+
+    }
 }

+ 12 - 0
src/main/resources/mapper/IotWarnBusinessMapper.xml

@@ -0,0 +1,12 @@
+<?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.yunfeiyun.agmp.iots.warn.mapper.IotWarnBussinessMapper">
+
+
+    <select id="selectIotWarnCountByDevAndConfig"
+            resultType="com.yunfeiyun.agmp.iot.common.domain.IotWarncount">
+
+    </select>
+</mapper>