Commit f7dfd861 authored by 赵啸非's avatar 赵啸非

添加智慧办公回调信息

parent 9c2ee29c
package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceEntity;
import lombok.Data;
import java.util.HashMap;
......@@ -26,8 +27,10 @@ public class DeviceAlarmInfoVo extends BaseEntityLong {
*/
private String alarmTimeEnd;
/** 告警设备Id列表 */
private List <Long> alarmDeviceList;
/**
* 告警设备Id列表
*/
private List<Long> alarmDeviceList;
private Integer deviceTotalCount;
......@@ -53,5 +56,9 @@ public class DeviceAlarmInfoVo extends BaseEntityLong {
private List<HashMap<String, Object>> deviceAlarmMapInfoList;
private DeviceEntity device;
private String alarmTypeStr;
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.device.model.DeviceAlarmInfoEntity;
import java.util.List;
/**
* DeviceAlarmInfoService
* <p>
......@@ -17,4 +19,5 @@ public interface DeviceAlarmInfoService extends ICRUDService<DeviceAlarmInfoEnti
Rest<DeviceAlarmInfoEntity> alarmStats(DeviceAlarmInfoEntity deviceAlarmInfo, Context context);
Rest<List<DeviceAlarmInfoEntity>> alarmStatList(DeviceAlarmInfoEntity deviceAlarmInfo, Context context);
}
\ No newline at end of file
......@@ -54,8 +54,6 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
@Override
public Rest<DeviceAlarmInfoEntity> alarmStats(DeviceAlarmInfoEntity deviceAlarmInfo, Context context) {
try {
Rest<RespData<List<SitePdu>>> rest = siteFeign.list(new SitePdu());
Map<Long, SitePdu> siteMap = rest.getData().getData().stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
if (ObjectUtils.isEmpty(siteMap)) {
......@@ -92,7 +90,7 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
//分站点统计设备今日告警数量
Map<String, Long> siteDeviceAlarmCollect = deviceAlarmInfoList.parallelStream().distinct().collect(groupingBy(x -> x.getSiteId(), counting()))
.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.collect(Collectors.toMap(x->siteMap.get(x.getKey())==null?"未知站点":siteMap.get(x.getKey()).getSiteName(),y->y.getValue(),(o,n)->n));
.collect(Collectors.toMap(x -> siteMap.get(x.getKey()) == null ? "未知站点" : siteMap.get(x.getKey()).getSiteName(), y -> y.getValue(), (o, n) -> n));
deviceAlarmInfo.setSiteDeviceAlarmCollect(siteDeviceAlarmCollect);
//设备类型分布
Map<String, String> deviceConnTypeCollect = deviceList.parallelStream().collect(groupingBy(x -> DeviceSrcEnum.getByValue(x.getDeviceSrc()).getDesc(), Collectors.collectingAndThen(counting(), y ->
......@@ -143,4 +141,46 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
return Rest.fail(e.getMessage());
}
}
@Override
public Rest<List<DeviceAlarmInfoEntity>> alarmStatList(DeviceAlarmInfoEntity deviceAlarmInfo, Context context) {
ArrayList<DeviceAlarmInfoEntity> infoList = new ArrayList<>();
try {
Rest<RespData<List<SitePdu>>> rest = siteFeign.list(new SitePdu());
Map<Long, SitePdu> siteMap = rest.getData().getData().stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
if (ObjectUtils.isEmpty(siteMap)) {
return Rest.fail("获取站点列表异常!");
}
Long siteId = deviceAlarmInfo.getSiteId();
DeviceAlarmInfoQuery deviceAlarmInfoQuery = new DeviceAlarmInfoQuery();
deviceAlarmInfoQuery.setSiteId(siteId);
deviceAlarmInfoQuery.setAlarmTimeStart(DateUtil.today());
deviceAlarmInfoQuery.setAlarmTimeEnd(DateUtil.today());
deviceAlarmInfoQuery.setOrderColList(Arrays.asList(new OrderCol("alarmTime", OrderCol.DESCENDING)));
List<DeviceAlarmInfoEntity> deviceAlarmInfoList = this.find(deviceAlarmInfoQuery);
Map<Long, Map<Integer, List<DeviceAlarmInfoEntity>>> collect = deviceAlarmInfoList.parallelStream().collect(groupingBy(x -> x.getAlarmDevice(), groupingBy(y -> y.getAlarmType())));
collect.entrySet().stream().forEach(entry -> {
Long key = entry.getKey();
Map<Integer, List<DeviceAlarmInfoEntity>> listMap = entry.getValue();
listMap.entrySet().stream().forEach(entry1 -> {
List<DeviceAlarmInfoEntity> vals = entry1.getValue();
DeviceAlarmInfoEntity deviceAlarmInfoEntity = new DeviceAlarmInfoEntity();
deviceAlarmInfoEntity.initAttrValue();
DeviceEntity extCache = deviceService.getCache(key.toString());
deviceAlarmInfoEntity.setDevice(extCache);
deviceAlarmInfoEntity.setAlarmTime(vals.get(0).getAlarmTime());
deviceAlarmInfoEntity.setAlarmTypeStr(AlarmTypeEnum.getByValue(vals.get(0).getAlarmType()).getDesc());
deviceAlarmInfoEntity.setTodayAlarmInfoCount(vals.size());
infoList.add(deviceAlarmInfoEntity);
});
});
return Rest.ok(infoList);
} catch (Exception e) {
log.error("设备告警信息统计异常", e);
return Rest.fail(e.getMessage());
}
}
}
\ No newline at end of file
......@@ -84,4 +84,20 @@ public class DeviceAlarmInfoController extends BaseCRUDJsonBodyMappingController
}
}
/**
* 设备告警信息统计
*/
@PostMapping(value = "statlist")
public Rest<List<DeviceAlarmInfoEntity>> alarmStatList(@RequestBody DeviceAlarmInfoEntity deviceAlarmInfo) {
String busiDesc = this.getModuleDesc() + "设备告警统计";
try {
Rest<List<DeviceAlarmInfoEntity>> rest = this.service.alarmStatList(deviceAlarmInfo, getContext());
recordSysLog(request, busiDesc + " 【成功】");
return rest;
} catch (Exception e) {
log.error("设备告警信息统计", e);
return Rest.fail(super.convertException(e));
}
}
}
\ No newline at end of file
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