lihui001 vor 3 Jahren
Ursprung
Commit
f50b4ad5af

+ 12 - 0
zoniot-water/zoniot-water-api/src/main/java/com/bz/zoneiot/water/api/vo/MonitorDataVo.java

@@ -6,6 +6,7 @@ import com.bz.zoneiot.core.utils.converter.Double3Serializer;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 import java.io.Serializable;
 
@@ -47,4 +48,15 @@ public class MonitorDataVo implements Serializable {
     private Double latestValue;
     @ApiModelProperty(value = "报警范围")
     private String alarmRange;
+
+    public String getAlarmRange(){
+        if (StringUtils.isEmpty(alarmRange)) {
+            return alarmRange;
+        }
+        String relation = alarmRange.substring(0, 3);
+        if ("and".equals(relation.toLowerCase())){
+            return alarmRange.replaceFirst("AND","");
+        }
+        return alarmRange.replaceFirst("OR","");
+    }
 }

+ 1 - 3
zoniot-water/zoniot-water-core/src/main/java/com/bz/zoneiot/water/core/mapper/AlarmDetailMapper.xml

@@ -25,7 +25,6 @@
             ,a.MIN_VALUE as "minValue"
             ,a.MAX_VALUE as "maxValue"
             ,timestampdiff(MINUTE,ifnull(a.ALARM_END_TIME,now()),a.ALARM_START_TIME) as "duration"
-            /*,(case when ALARM_END_TIME is not null then timestampdiff(MINUTE,a.ALARM_END_TIME,a.ALARM_START_TIME) else null end ) as "duration"*/
             ,att.`NAME` as "attributeName"
             ,a.SCENE_NAME as "sceneName"
             ,d.DEVICE_NAME as "deviceName"
@@ -34,8 +33,7 @@
             ,d.POINT_X as "pointX"
             ,d.POINT_Y as "pointY"
             ,ast.id as "alarmSettingId"
-            /*,ast.ALARM_CONDITION +" " +ast.ALARM_VALUE as "alermRule"*/
-            ,concat(ifnull(asr.operator,''),ifnull(asr.`value`,'')) as "alermRule" ,
+            ,concat(ifnull(asr.operator,''),ifnull(asr.`value`,'')) as "alermRule"
             ,att.UNIT as "unit"
     </sql>
 

+ 2 - 2
zoniot-water/zoniot-water-core/src/main/java/com/bz/zoneiot/water/core/mapper/OnlineMonitorMapper.xml

@@ -443,7 +443,8 @@
     <!--查询设备地图参数数据-->
     <select id="selectDeviceMapParam" resultMap="deviceDataMap">
         select distinct t1.id device_id,t1.device_code,t1.device_name,t1.point_x,point_y,t1.address,t2.attribute_id, ifnull(t2.remark, t3.`name`) attribute_name,t3.unit,t2.parm_type attribute_type,
-         t2.seq,case when t2.attribute_id is  null then null when t6.id is null then 0 else 1 end is_alarm,concat(t12.operator,cast(t12.operator as char)+0) alarm_range
+         t2.seq,case when t2.attribute_id is  null then null when t6.id is null then 0 else 1 end is_alarm,
+        (select GROUP_CONCAT(t12.relation , ' ',t12.operator,' ',t12.value, ' ' SEPARATOR '') as `alarm_range` from sms_alarm_rule t12 where t12.alarm_type_id = t11.id) alarm_range
         <if test="flag == null or flag ==0">
             ,if (t4.alarm_count>0, 1, 0) device_state
         </if>
@@ -466,7 +467,6 @@
         )t4 on t4.device_id=t1.id
         left join sms_alarm_details t6 on t6.device_id=t1.id and t6.attribute_id=t2.attribute_id and t6.status = 1 and t6.state=1
         left join sms_alarm_type t11 on t6.ALARM_ID=t11.id and t11.status = 1
-        left join sms_alarm_rule t12 on t12.alarm_type_id=t11.id and t12.status = 1
         where t1. status = 1 and t1.id= #{deviceId}
         order by t2.seq
     </select>