|
|
@@ -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;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新增告警记录
|