Quellcode durchsuchen

补充告警记录字段

liuyaowen vor 9 Monaten
Ursprung
Commit
dd56987c96

+ 2 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotWarnlogController.java

@@ -10,6 +10,7 @@ import com.yunfeiyun.agmp.common.utils.SecurityUtils;
 import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
 import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
 import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotWarnlogDealReqVo;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo;
 import com.yunfeiyun.agmp.iotm.web.service.IIotWarnlogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -39,7 +40,7 @@ public class IotWarnlogController extends BaseController{
     public TableDataInfo list(IotWarnlog iotWarnlog){
         iotWarnlog.setTid(SecurityUtils.getTid());
         startPage();
-        List<IotWarnlog> list = iotWarnlogService.selectIotWarnlogList(iotWarnlog);
+        List<IotWarnlogResVo> list = iotWarnlogService.selectIotWarnlogResVoList(iotWarnlog);
         return getDataTable(list);
     }
 

+ 12 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/IotWarnlogResVo.java

@@ -0,0 +1,12 @@
+package com.yunfeiyun.agmp.iotm.web.domain.resvo;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
+import lombok.Data;
+
+@Data
+public class IotWarnlogResVo extends IotWarnlog {
+    private String wlTypeContent;
+    private String wlLevelContent;
+    private String devTypeName;
+    private String devCode;
+}

+ 3 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotWarnlogMapper.java

@@ -1,6 +1,7 @@
 package com.yunfeiyun.agmp.iotm.web.mapper;
 
 import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -59,4 +60,6 @@ public interface IotWarnlogMapper {
      * @return 结果
      */
     public int deleteIotWarnlogByWlBids(@Param("array") String[] wlBids, @Param("tid") String tid);
+
+    List<IotWarnlogResVo> selectIotWarnlogResVoList(IotWarnlog iotWarnlog);
 }

+ 2 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/TosDevicetypeMapper.java

@@ -68,4 +68,6 @@ public interface TosDevicetypeMapper {
     public List<TosDevicetype> selectTosDevicetypeListyCreateDev(TosDevicetype tosDevicetype);
 
     TosDevicetype selectTosDevicetypeByDevtypeCode(@Param("devtypeCode") String devtypeCode);
+
+    List<TosDevicetype> selectTosDevicetypeByDevtypeBids(List<String> devTypeBids);
 }

+ 3 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotWarnlogService.java

@@ -1,6 +1,7 @@
 package com.yunfeiyun.agmp.iotm.web.service;
 
 import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo;
 
 import java.util.List;
 
@@ -19,6 +20,7 @@ public interface IIotWarnlogService {
      * @return 告警记录
      */
     public IotWarnlog selectIotWarnlogByWlBid(String wlBid, String tid );
+    public List<IotWarnlog> selectIotWarnlogList(IotWarnlog iotWarnlog);
 
     /**
      * 查询告警记录列表
@@ -26,7 +28,7 @@ public interface IIotWarnlogService {
      * @param iotWarnlog 告警记录
      * @return 告警记录集合
      */
-    public List<IotWarnlog> selectIotWarnlogList(IotWarnlog iotWarnlog);
+    public List<IotWarnlogResVo> selectIotWarnlogResVoList(IotWarnlog iotWarnlog);
 
     /**
      * 新增告警记录

+ 53 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotWarnlogServiceImpl.java

@@ -1,12 +1,24 @@
 package com.yunfeiyun.agmp.iotm.web.service.impl;
 
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
 import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
+import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
+import com.yunfeiyun.agmp.iot.common.enums.warn.IotWarnTouchTypeEnum;
+import com.yunfeiyun.agmp.iot.common.enums.warn.IotWarnlevelEnum;
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.IotDeviceMapper;
 import com.yunfeiyun.agmp.iotm.web.mapper.IotWarnlogMapper;
+import com.yunfeiyun.agmp.iotm.web.mapper.TosDevicetypeMapper;
 import com.yunfeiyun.agmp.iotm.web.service.IIotWarnlogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -19,6 +31,10 @@ import java.util.List;
 public class IotWarnlogServiceImpl implements IIotWarnlogService {
     @Autowired
     private IotWarnlogMapper iotWarnlogMapper;
+    @Resource
+    private IotDeviceMapper iotDeviceMapper;
+    @Resource
+    private TosDevicetypeMapper tosDevicetypeMapper;
 
     /**
      * 查询告警记录
@@ -33,7 +49,7 @@ public class IotWarnlogServiceImpl implements IIotWarnlogService {
 
     /**
      * 查询告警记录列表
-     * 
+     *
      * @param iotWarnlog 告警记录
      * @return 告警记录
      */
@@ -41,6 +57,42 @@ public class IotWarnlogServiceImpl implements IIotWarnlogService {
     public List<IotWarnlog> selectIotWarnlogList(IotWarnlog iotWarnlog){
         return iotWarnlogMapper.selectIotWarnlogList(iotWarnlog);
     }
+    /**
+     * 查询告警记录列表
+     *
+     * @param iotWarnlog 告警记录
+     * @return 告警记录
+     */
+    @Override
+    public List<IotWarnlogResVo> selectIotWarnlogResVoList(IotWarnlog iotWarnlog){
+        List<IotWarnlogResVo> iotWarnLogResVoList = iotWarnlogMapper.selectIotWarnlogResVoList(iotWarnlog);
+        List<String> devBids = new ArrayList<>();
+        List<String> devTypeBids = new ArrayList<>();
+        for(IotWarnlogResVo iotWarnlogResVo : iotWarnLogResVoList){
+            devBids.add(iotWarnlogResVo.getDevBid());
+            devTypeBids.add(iotWarnlogResVo.getDevtypeBid());
+        }
+        // 查询告警设备信息
+        List<IotDevice> iotDeviceList = iotDeviceMapper.selectIotDeviceByDevBids(devBids, SecurityUtils.getTid());
+        Map<String,String> iotDeviceMap = iotDeviceList.stream().collect(Collectors.toMap(IotDevice::getDevBid,IotDevice::getDevCode));
+        // 查询告警设备类型信息
+        List<TosDevicetype> tosDevicetypes = tosDevicetypeMapper.selectTosDevicetypeByDevtypeBids(devTypeBids);
+        Map<String,String> tosDeviceTypeMap = tosDevicetypes.stream().collect(Collectors.toMap(TosDevicetype::getDevtypeBid,TosDevicetype::getDevtypeName));
+        // 遍历结果进行赋值
+        for(IotWarnlogResVo iotWarnlogResVo : iotWarnLogResVoList){
+            // 设置设备编号
+            iotWarnlogResVo.setDevCode(iotDeviceMap.get(iotWarnlogResVo.getDevBid()));
+            // 设置设备类型名称
+            iotWarnlogResVo.setDevTypeName(tosDeviceTypeMap.get(iotWarnlogResVo.getDevtypeBid()));
+            // 获取设备触发类型,并进行赋值
+            IotWarnTouchTypeEnum iotWarnTouchTypeEnum = IotWarnTouchTypeEnum.findByCode(iotWarnlogResVo.getWlType());
+            iotWarnlogResVo.setWlTypeContent(iotWarnTouchTypeEnum==null?null:iotWarnTouchTypeEnum.getContent());
+            // 获取设备告警等级,并进行赋值
+            IotWarnlevelEnum iotWarnlevelEnum = IotWarnlevelEnum.findByCode(iotWarnlogResVo.getWlLevel());
+            iotWarnlogResVo.setWlLevelContent(iotWarnlevelEnum==null?null:iotWarnlevelEnum.getContent());
+        }
+        return iotWarnLogResVoList;
+    }
 
     /**
      * 新增告警记录

+ 22 - 0
src/main/resources/mapper/IotWarnlogMapper.xml

@@ -122,4 +122,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{wlBid}
         </foreach>
     </delete>
+
+    <select id="selectIotWarnlogResVoList"
+            resultType="com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo">
+        <include refid="selectIotWarnlogVo"/>
+        <where>
+            <if test="wlBid != null  and wlBid != ''"> and wlBid = #{wlBid}</if>
+            <if test="wlName != null  and wlName != ''"> and wlName like concat('%', #{wlName}, '%')</if>
+            <if test="wlType != null  and wlType != ''"> and wlType = #{wlType}</if>
+            <if test="wlContent != null  and wlContent != ''"> and wlContent = #{wlContent}</if>
+            <if test="wlLevel != null  and wlLevel != ''"> and wlLevel = #{wlLevel}</if>
+            <if test="devtypeBid != null  and devtypeBid != ''"> and devtypeBid = #{devtypeBid}</if>
+            <if test="devBid != null  and devBid != ''"> and devBid = #{devBid}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="wlDealuserid != null  and wlDealuserid != ''"> and wlDealuserid = #{wlDealuserid}</if>
+            <if test="wlDealresult != null  and wlDealresult != ''"> and wlDealresult = #{wlDealresult}</if>
+            <if test="wlDealtime != null  and wlDealtime != ''"> and wlDealtime = #{wlDealtime}</if>
+
+            <if test="wlCreateddate != null  and wlCreateddate != ''"> and wlCreateddate = #{wlCreateddate}</if>
+            <if test="wlData != null  and wlData != ''"> and wlData = #{wlData}</if>
+            <if test="tid != null  and tid != ''"> and tid = #{tid}</if>
+        </where>
+    </select>
 </mapper>

+ 8 - 1
src/main/resources/mapper/TosDevicetypeMapper.xml

@@ -171,8 +171,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="selectTosDevicetypeByDevtypeCode"
             resultType="com.yunfeiyun.agmp.iot.common.domain.TosDevicetype">
-               select * from TosDevicetype where devtypeCode=#{devtypeCode}
+        select * from TosDevicetype where devtypeCode=#{devtypeCode}
+    </select>
 
+    <select id="selectTosDevicetypeByDevtypeBids"
+            resultType="com.yunfeiyun.agmp.iot.common.domain.TosDevicetype">
+        select * from TosDevicetype where devtypeBid in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
     </select>
 
 </mapper>