浏览代码

需求变更-在线监测修改

yuejiaying 4 年之前
父节点
当前提交
c8f2c828ef

+ 1 - 1
sms_water/src/main/java/com/huaxu/dto/MonitorDataCollectDto.java

@@ -92,7 +92,7 @@ public class MonitorDataCollectDto {
     @JsonIgnore
     private String sceneTypeName;
 
-    @ApiModelProperty(value ="在线监测类型 1查询需计算的属性、2查询监测列表的属性",hidden = true)
+    @ApiModelProperty(value ="在线监测类型 1查询需计算的属性、2查询监测列表的属性、3查询地图悬浮属性、4查询地图参数属性",hidden = true)
     @JsonIgnore
     private Integer type;
 }

+ 2 - 2
sms_water/src/main/java/com/huaxu/service/impl/OnlineMonitorImpl.java

@@ -81,7 +81,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
         monitorDataCollectDto.setUserType(loginUser.getType());
         //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
         monitorDataCollectDto.setPermissonType(loginUser.getPermissonType());
-
+        monitorDataCollectDto.setType(3);
         List<MonitorDataCollectDto> result=onlineMonitorMapper.selectMapSuspension(monitorDataCollectDto);
         monitorDataCollectDto.setType(1);
         List<MonitorDataCollectDto> calculateRes=onlineMonitorMapper.selectSceneParam(monitorDataCollectDto);
@@ -116,7 +116,7 @@ public class OnlineMonitorImpl implements OnlineMonitorService {
         monitorDataCollectDto.setUserType(loginUser.getType());
         //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
         monitorDataCollectDto.setPermissonType(loginUser.getPermissonType());
-
+        monitorDataCollectDto.setType(4);
         List<MonitorDataCollectDto> result=onlineMonitorMapper.selectMapParam(monitorDataCollectDto);
         monitorDataCollectDto.setType(1);
         List<MonitorDataCollectDto> calculateRes=onlineMonitorMapper.selectSceneParam(monitorDataCollectDto);

+ 37 - 59
sms_water/src/main/resources/mapper/OnlineMonitorMapper.xml

@@ -17,7 +17,6 @@
             <result property="isAlarm" column="is_Alarm" jdbcType="VARCHAR"/>
             <result property="attributeType" column="attribute_type" jdbcType="VARCHAR"/>
             <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
-            <result property="sumValue" column="sum_value" jdbcType="VARCHAR"/>
             <result property="latestValue" column="latest_value" jdbcType="VARCHAR"/>
         </collection>
     </resultMap>
@@ -28,45 +27,43 @@
         t1.point_x ,
         t1.point_y,
         t1.address ,
-        if (t7.alarm_count>0, 1, 0) scene_state,
         t5.device_id,
         t5.attribute_id ,
-        ifnull(t5.remark, t5.`name`) attribute_name,
-        t5.unit ,
+        ifnull(t5.remark, t9.`name`) attribute_name,
+        t9.unit ,
         case when t5.attribute_id is  null then null when t6.id is null then 0 else 1 end is_alarm,
-        t5.attribute_type,
+        t5.parm_type attribute_type,
         if (t5.device_id is null, null, t4.device_code) device_code
     </sql>
 
     <sql id="sceneDeviceJoins">
-        inner join sms_scene t2 on find_in_set(t1.id, t2.parent_scene_ids) and t2. status = 1
         inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
-        left join sms_device t4 on t4.scene_id=t2.id and t4. status = 1 and  t4.enable_state=1
-    </sql>
-    <sql id="attributeJoins">
-        select a1.device_id,a1.attribute_id,a1.remark,a1.seq,a2.name,a2.unit,a2.attribute_type
-        from sms_device_parm a1
-        inner join sms_device_attribute a2 on a1.attribute_id=a2.id
-        where a1. status = 1 and a2.status = 1
-    </sql>
-    <sql id="alarmDetailsJoins">
-        inner join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1
+        left join sms_device_scene t2 on t2.parent_scene_id=t1.id and t2. status = 1
+        left join sms_device t4 on t2.device_id=t4.id and t4. status = 1 and t4. enable_state = 1
+        left join sms_device_parm t5 on t5.scene_id = t2.scene_id and t5.device_id=t2.device_id and  t5. status = 1
+        <if test="type == 3 ">
+            and t5.is_suspension = 1
+        </if>
+        <if test="type == 4 ">
+            and t5.is_map = 1
+        </if>
+        left join sms_device_attribute t9 on t5.attribute_id=t9.id and t9.status = 1
+        left join sms_alarm_details t6 on t6.scene_id=t2.scene_id and t6.device_id=t2.device_id and t6.attribute_id=t5.attribute_id and t6.status = 1
     </sql>
+
     <sql id="sceneAlarmJoins">
         left join (
-            select substring_index(substring_index(a3.parent_scene_ids, ',', 2), ',', -1) one_scene_id,count(1) alarm_count
-            from sms_device a1
-            inner join sms_alarm_details a2 on a1.id=a2.device_id and a2.`status` = 1 and  a2.state = 1
-            inner join sms_scene a3 on a3.id=a1.scene_id and a3.`status` = 1
-            where a1.`status` = 1 and a1.enable_state=1
+            select parent_scene_id,count(1) alarm_count
+            from sms_alarm_details a1
+            where a1.`status` = 1 and a1.state = 1
             <if test="sceneIds != null and sceneIds.size() > 0">
                 and a1.scene_id  in
                 <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
-            group by one_scene_id
-        )t7 on t7.one_scene_id=t1.id
+            group by parent_scene_id
+        )t7 on t7.parent_scene_id=t1.id
     </sql>
 
     <!--查询实时报警信息-->
@@ -76,8 +73,8 @@
         t6.alarm_content as "alarmContent",
         t6.alarm_start_time as "alarmStartTime"
         from sms_scene t1
-        <include refid="sceneDeviceJoins"/>
-        <include refid="alarmDetailsJoins"/>
+        inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
+        inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
         where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
         <if test="sceneIds != null and sceneIds.size() > 0">
             and t1.id  in
@@ -102,8 +99,8 @@
         t1.scene_name as "sceneName",
         count(1) as "alalmCount"
         from sms_scene t1
-        <include refid="sceneDeviceJoins"/>
-        <include refid="alarmDetailsJoins"/>
+        inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
+        inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
         where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName} and t6.state=1
         <if test="sceneIds != null and sceneIds.size() > 0">
             and t1.id  in
@@ -126,14 +123,10 @@
     <!--查询地图悬浮数据-->
     <select id="selectMapSuspension" resultMap="monitorDataMap">
         select
-        <include refid="Base_Column_List"/>
+        <include refid="Base_Column_List"/>,if (t7.alarm_count>0, 1, 0) scene_state
         from sms_scene t1
         <include refid="sceneDeviceJoins"/>
         <include refid="sceneAlarmJoins"/>
-        left join(
-            <include refid="attributeJoins"/> and a1.is_suspension = 1
-        )t5 on t5.device_id=t4.id
-        left join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1 and t6.attribute_id = t5.attribute_id and t6.state = 1
         where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = #{sceneTypeName}
         <if test="sceneIds != null and sceneIds.size() > 0">
             and t1.id  in
@@ -156,10 +149,6 @@
         from sms_scene t1
         <include refid="sceneDeviceJoins"/>
         <include refid="sceneAlarmJoins"/>
-        left join(
-            <include refid="attributeJoins"/> and a1.is_map = 1
-        )t5 on t5.device_id=t4.id
-        left join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1 and t6.attribute_id = t5.attribute_id and t6.state = 1
         where t1.parent_scene_id = 0 and t1. status = 1 and t1.id = #{sceneId}
         <if test="sceneIds != null and sceneIds.size() > 0">
             and t1.id  in
@@ -200,8 +189,9 @@
         count(1) as "alarmCount",
         sum(timestampdiff(minute,t6.alarm_start_time,ifnull(t6.alarm_end_time,now()))) as "alarmDuration"
         from sms_scene t1
-        <include refid="sceneDeviceJoins"/>
-        <include refid="alarmDetailsJoins"/>
+        inner join sms_scene_type t3 on t3.id = t1.scene_type_id and t3. status = 1
+        inner join sms_alarm_details t6 on t1.id=t6.parent_scene_id and t6.`status`=1
+        inner join sms_device t4 on t4.id=t6.device_id and t4.`status`=1 and t4. enable_state = 1
         where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t1.id = #{id}
         <if test="sceneIds != null and sceneIds.size() > 0">
             and t1.id  in
@@ -217,27 +207,9 @@
     <!--查询场景对应参数数据-->
     <select id="selectSceneParam" resultMap="monitorDataMap">
         select
-        t1.id scene_Id,
-        t1.scene_name ,
-        t5.device_id,
-        t5.attribute_id ,
-        ifnull(t5.remark, t5.`name`) attribute_name,
-        if(t6.id is null , 0 , 1 ) is_alarm,
-        t5.attribute_type,
-        if (t5.device_id is null, null, t4.device_code) device_code,
-        t8.latest_value
+        <include refid="Base_Column_List"/>,t8.latest_value
         from sms_scene t1
         <include refid="sceneDeviceJoins"/>
-        inner join(
-        <include refid="attributeJoins"/>
-        <if test="type == 1 ">
-            and a2.attribute_type in(3,4,5,6)
-        </if>
-        <if test="type == 2 ">
-        and a2.attribute_type in(2,3,4,5,6,7,8,9,10,11,12,13,14)
-        </if>
-        )t5 on t5.device_id=t4.id
-        left join sms_alarm_details t6 on t6.device_id=t4.id and t6. status = 1 and t6.attribute_id = t5.attribute_id and t6.state = 1
         left join (
             select b1.device_id,b1.attribute_id,max(latest_value) latest_value
             from sms_day_report b1
@@ -248,9 +220,15 @@
                         #{item}
                     </foreach>
                 </if>
-            group by  b1.device_id,b1.attribute_id
-        )t8 on t8.attribute_id =t5.attribute_id and t8.device_id=t5.device_id
+            group by b1.device_id,b1.attribute_id
+        )t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id
         where t1.parent_scene_id = 0 and t1. status = 1
+        <if test="type == 1 ">
+            and t5.parm_type in(3,4,5,6)
+        </if>
+        <if test="type == 2 ">
+            and t5.parm_type in(2,3,4,5,6,7,8,9,10,11,12,13,14)
+        </if>
         <if test="sceneTypeName != null and sceneTypeName != '' ">
             and t3.scene_type_name = #{sceneTypeName}
         </if>