Browse Source

告警BUG

lin 3 years ago
parent
commit
a22ce8f07f

+ 8 - 5
zoniot-rmcp/zoniot-rmcp-alarm/src/main/java/com/bz/rmcp/alarm/service/impl/DeviceAlarmServiceImpl.java

@@ -26,6 +26,7 @@ import com.zcxk.rmcp.core.dao.DeviceAlarmMapper;
 import com.zcxk.rmcp.core.dao.DeviceAlarmRuleMapper;
 import com.zcxk.rmcp.core.dao.DeviceMapper;
 
+import com.zcxk.rmcp.core.entity.AlarmType;
 import com.zcxk.rmcp.core.entity.Device;
 import com.zcxk.rmcp.core.entity.DeviceAlarm;
 
@@ -91,11 +92,13 @@ public class DeviceAlarmServiceImpl implements DeviceAlarmService {
         List<DeviceAlarm> deviceAlarmList = new ArrayList<>();
 
         // 1,查找产品对应的告警类型,
-        AlarmTypePageDto alarmTypeDto = new AlarmTypePageDto();
-        alarmTypeDto.setTenantId(device.getTenantId());
-        alarmTypeDto.setProductCategroyId(device.getCategoryId());
-        alarmTypeDto.setDeviceTypeId(device.getProductId());
-        List<AlarmTypeDto> alarmTypeList = alarmTypeMapper.selectList(alarmTypeDto);
+        AlarmType alarmTypeCondition = new AlarmType();
+        alarmTypeCondition.setTenantId(device.getTenantId());
+        alarmTypeCondition.setProductCategroyId(device.getCategoryId());
+        alarmTypeCondition.setDeviceTypeId(device.getProductId());
+        alarmTypeCondition.setAlarmStatus(1);
+
+        List<AlarmTypeDto> alarmTypeList = alarmTypeMapper.findList(alarmTypeCondition);
         for (AlarmTypeDto alarmType : alarmTypeList) {
 
             // 2,获取规则对应的测点以及表达式进行报警判断

+ 15 - 8
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/dao/AlarmTypeMapper.java

@@ -83,22 +83,29 @@ public interface AlarmTypeMapper {
     int count();
 
 
-    /**查询告警类型所拥有的告警规则数目
-      * @param ids
+    /**
+     * 查询告警类型所拥有的告警规则数目
+     *
+     * @param ids
+     * @return java.util.List<com.zcxk.rmcp.api.dto.alarm.AlarmTypeDto>
+     * @throws
      * @description
      * @author hym
      * @updateTime 2021/8/3 9:45
-     * @return java.util.List<com.zcxk.rmcp.api.dto.alarm.AlarmTypeDto>
-     * @throws
      */
     List<AlarmTypeDto> selectTypesWithRules(List<Integer> ids);
-    /**删除告警类型
-      * @param ids
+
+    /**
+     * 删除告警类型
+     *
+     * @param ids
+     * @return void
+     * @throws
      * @description
      * @author hym
      * @updateTime 2021/8/3 9:56
-     * @return void
-     * @throws
      */
     void delete(List<Integer> ids);
+
+    List<AlarmTypeDto> findList(@Param("alarmType") AlarmType alarmType);
 }

+ 7 - 0
zoniot-rmcp/zoniot-rmcp-core/src/main/java/com/zcxk/rmcp/core/mapper/AlarmTypeMapper.xml

@@ -166,4 +166,11 @@ rt.type_desc, rt.tenant_id, rt.alarm_status    </sql>
         </foreach>
     </select>
 
+    <select id="findList" resultType="com.zcxk.rmcp.api.dto.alarm.AlarmTypeDto">
+        select id,name from rmcp_alarm_type where status = 1
+        <if test="alarmType.tenantId != null">and tenant_id = #{alarmType.tenantId}</if>
+        <if test="alarmType.productCategroyId != null">and product_categroy_id = #{alarmType.productCategroyId}</if>
+        <if test="alarmType.deviceTypeId != null">and device_type_id = #{alarmType.deviceTypeId}</if>
+        <if test="alarmType.alarmStatus != null">and alarm_status = #{alarmType.alarmStatus}</if>
+    </select>
 </mapper>