Commit 409eae83 authored by duanruiming's avatar duanruiming

[update] 态势检测-设备状态 优化

parent 58fa61f7
......@@ -162,8 +162,6 @@ public class SituationDetectionController extends BaseController {
@GetMapping(value = "crossDeviceStatusInfo", produces = MediaType.APPLICATION_JSON)
public JsonViewObject crossDeviceStatusInfo() {
List<CrossDeviceStatusInfoOutVO> list = situationDetectionService.crossDeviceStatusInfo();
// 数据库 status 0离线;1在线 faultType 0正常
// 适配前端 status 1在线;2离线;3故障
for (CrossDeviceStatusInfoOutVO item : list) {
int fualType = item.getFaultType();
int status = item.getStatus();
......
......@@ -23,7 +23,10 @@ import net.wanji.web.common.enums.DeviceStatusEnum;
import net.wanji.web.common.enums.DeviceTypeEnum;
import net.wanji.web.common.util.StringUtils;
import net.wanji.web.dto.CrossIdNameDTO;
import net.wanji.web.entity.*;
import net.wanji.web.entity.TBaseAreaCross;
import net.wanji.web.entity.TBaseAreaInfo;
import net.wanji.web.entity.TCrossControlHist;
import net.wanji.web.entity.TDeviceStatusInfo;
import net.wanji.web.mapper.*;
import net.wanji.web.po.*;
import net.wanji.web.service.SituationDetectionService;
......@@ -350,27 +353,24 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
@Override
public Map<String, Map<String, Integer>> allDeviceStatus(String adCode) {
List<AllDeviceStatusPO> allDeviceStatusPOList = allDeviceStatusMapper.selectAllDeviceStatus(adCode);
Map<String, Map<String, Integer>> res = new LinkedHashMap<>();
// 初始化Map
for (DeviceTypeEnum value : DeviceTypeEnum.values()) {
res.put(value.getMsg(), null);
TDeviceStatusInfo queryEntity = new TDeviceStatusInfo();
if (StringUtils.isNotEmpty(adCode)) {
queryEntity.setType(Integer.valueOf(adCode));
}
Map<Integer, List<AllDeviceStatusPO>> collect = allDeviceStatusPOList.stream()
.collect(Collectors.groupingBy(AllDeviceStatusPO::getType));
for (Map.Entry<Integer, List<AllDeviceStatusPO>> entry : collect.entrySet()) {
Map<String, Integer> valueMap = new LinkedHashMap<>();
// 初始化Map
for (DeviceStatusEnum value : DeviceStatusEnum.values()) {
valueMap.put(value.getMsg(), 0);
}
for (AllDeviceStatusPO allDeviceStatusPO : entry.getValue()) {
Integer status = allDeviceStatusPO.getStatus();
Integer statusCount = allDeviceStatusPO.getStatusCount();
valueMap.put(DeviceStatusEnum.getMsgByCode(status), statusCount);
}
Integer key = entry.getKey();
res.put(DeviceTypeEnum.getMsgByCode(key), valueMap);
List<TDeviceStatusInfo> tDeviceStatusInfos = allDeviceStatusMapper.selectByEntity(queryEntity);
Map<String, Map<String, Integer>> res = new LinkedHashMap<>();
Map<Integer, List<TDeviceStatusInfo>> deviceTypeMap = tDeviceStatusInfos.stream().collect(Collectors.groupingBy(TDeviceStatusInfo::getType));
for (Map.Entry<Integer, List<TDeviceStatusInfo>> entry : deviceTypeMap.entrySet()) {
Integer type = entry.getKey();
List<TDeviceStatusInfo> all = entry.getValue();
List<TDeviceStatusInfo> offline = all.stream().filter(tDeviceStatusInfo -> tDeviceStatusInfo.getStatus() == 0).collect(Collectors.toList());
List<TDeviceStatusInfo> normal = all.stream().filter(tDeviceStatusInfo -> isDealStatus(tDeviceStatusInfo)).collect(Collectors.toList());
Map deviceMap = new HashMap<>();
deviceMap.put(DeviceStatusEnum.NORMAL.getMsg(), normal.size());
deviceMap.put(DeviceStatusEnum.WRONG.getMsg(), all.size() - normal.size() - offline.size());
deviceMap.put(DeviceStatusEnum.OFFLINE.getMsg(), offline.size());
res.put(DeviceTypeEnum.getMsgByCode(type), deviceMap);
}
return res;
......@@ -586,7 +586,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
for (CrossInfoOutVo crossInfoOutVo : crossInfoOutVoList) {
if (StringUtils.equals(crossInfoOutVo.getId(), tDeviceStatus.getCode())) {
signalFaultInfoVO.setIp(crossInfoOutVo.getIp());
if (tDeviceStatus.getFaultType() == 0 && tDeviceStatus.getStatus() == 1) {
if (isDealStatus(tDeviceStatus)) {
signalFaultInfoVO.setDealStatus("2");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment