Browse Source

#告警历史数据查询

zhongwei
yang_shj 3 months ago
parent
commit
315c99893e
  1. 3
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java
  2. 27
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/DeviceElectricVo.java
  3. 150
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java
  4. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml

3
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java

@ -35,6 +35,9 @@ public class AlarmHistoryVo {
@ApiModelProperty("处理人名称")
private Long handleUserName;
@ApiModelProperty("处理附件地址")
private String filePath;
@ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")

27
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/DeviceElectricVo.java

@ -0,0 +1,27 @@
package com.hnac.hzims.electric.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author 表头
*/
@Data
public class DeviceElectricVo {
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "字符串格式时间")
private String strTime;
@ApiModelProperty(value = "时间")
private Integer time;
@ApiModelProperty(value = "有功电量")
private Double generate;
@ApiModelProperty(value = "无功电量")
private Double reactiveGenerate;
}

150
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java

@ -2,25 +2,37 @@ package com.hnac.hzims.electric.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.electric.entity.ThirtyEntity;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.service.IElectricReportService;
import com.hnac.hzims.electric.service.ThirtyService;
import com.hnac.hzims.electric.service.ThreeService;
import com.hnac.hzims.electric.vo.DeviceElectricVo;
import com.hnac.hzims.electric.vo.TableHeadVo;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.operational.station.vo.StationsByDeptIdsParamVo;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -36,10 +48,14 @@ public class ElectricReportServiceImpl implements IElectricReportService {
private final ThirtyService thirtyService;
private final IEmInfoService deviceService;
private final ISysClient sysClient;
private final IStationClient stationClient;
private final IAnalyseDataSearchClient analyseDataSearchClient;
/**
* 基础报表
* @param deptId
@ -433,7 +449,65 @@ public class ElectricReportServiceImpl implements IElectricReportService {
Map<String,Object> result = new HashMap<>();
// 日
if (type == 0) {
// 站点设备集合
List<EmInfoEntity> devices = deviceService.list(Wrappers.<EmInfoEntity>lambdaQuery()
.eq(EmInfoEntity::getCreateDept,station.getData().getRefDept())
.eq(EmInfoEntity::getEmType,2)
.eq(EmInfoEntity::getHomePageDisplay,1)
);
if(CollectionUtil.isEmpty(devices)){
return new HashMap<>();
}
Date date = DateUtil.parse(time,DateUtil.PATTERN_DATE);
// 根据设备查询当日有功/无功电量
List<DeviceElectricVo> electrics = this.deviceElectrics(devices,date);
// 表头
List<TableHeadVo> tableHeads = new ArrayList<>();
TableHeadVo firstHead = new TableHeadVo();
firstHead.setTableName("时间");
firstHead.setIsChildren(false);
tableHeads.add(firstHead);
TableHeadVo secondHead = new TableHeadVo();
secondHead.setTableName("时总计发电量");
secondHead.setIsChildren(true);
secondHead.setChildren(Arrays.asList("时总有功","时总无功"));
tableHeads.add(secondHead);
// 根据设备分组
devices.forEach(device->{
TableHeadVo tableHead = new TableHeadVo();
tableHead.setTableName(device.getName() + "发电量(kWh)");
tableHead.setIsChildren(true);
tableHead.setChildren(Arrays.asList("时有功","时无功"));
tableHeads.add(tableHead);
});
result.put("tableHead",tableHeads);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
Date end = calendar.getTime();
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
Date start = calendar.getTime();
List<List<Object>> tableDate = new ArrayList<>();
while (start.compareTo(end) < 0){
List<Object> item = new ArrayList<>();
String hours = DateUtil.format(start,"yyyy-MM-dd HH");
item.add(start.getMonth() + 1 + "月");
// 总计:有功、无功
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum());
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum());
// 遍历机组
devices.stream().sorted(Comparator.comparing(EmInfoEntity::getEmIndex)).forEach(device->{
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getNumber()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum());
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getNumber()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum());
});
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
tableDate.add(item);
}
result.put("tableDate",tableDate);
}
// 月
else if (type == 1) {
@ -561,4 +635,80 @@ public class ElectricReportServiceImpl implements IElectricReportService {
}
return result;
}
/**
* 查询设备当日有功/无功电量
* @param devices
* @return
*/
private List<DeviceElectricVo> deviceElectrics(List<EmInfoEntity> devices,Date date) {
List<DeviceElectricVo> electrics = new ArrayList<>();
devices.forEach(device->{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
Date endTime = calendar.getTime();
LocalDateTime end = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(endTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
Date startTime = calendar.getTime();
LocalDateTime start = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(startTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
AnalyseCodeByAnalyseDataPO param = new AnalyseCodeByAnalyseDataPO();
param.setDeviceCode(device.getNumber());
List<AnalyzeDataConditionPO> conditions = new ArrayList<>();
// 有功电量
AnalyzeDataConditionPO generate = new AnalyzeDataConditionPO();
generate.setFull(1);
generate.setKeepFigures(2);
generate.setAccessRules(6);
generate.setSaveTimeType(2);
generate.setSignages("generation_capacity");
generate.setTimeInterval(1);
generate.setBeginTime(start);
generate.setEndTime(end);
conditions.add(generate);
// 无功电量
AnalyzeDataConditionPO reactive = new AnalyzeDataConditionPO();
reactive.setFull(1);
reactive.setKeepFigures(2);
reactive.setAccessRules(6);
reactive.setSaveTimeType(2);
reactive.setSignages("reactive_generation");
reactive.setTimeInterval(1);
reactive.setBeginTime(start);
reactive.setEndTime(end);conditions.add(reactive);
param.setSignboardConditions(conditions);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(param);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){
return;
}
while (startTime.compareTo(endTime) < 0){
DeviceElectricVo electric = new DeviceElectricVo();
electric.setStrTime(DateUtil.format(startTime,"yyyy-MM-dd HH"));
electric.setTime(startTime.getHours());
if(ObjectUtil.isEmpty(result.getData().get(0)) || CollectionUtil.isEmpty(result.getData().get(0).getList())){
electric.setGenerate(result.getData().get(0).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{
if(StringUtils.isEmpty(val.getVal())){
return 0.0;
}
return Double.parseDouble(val.getVal());
}).sum());
}else{
electric.setGenerate(0.0);
}
if(ObjectUtil.isEmpty(result.getData().get(1)) || CollectionUtil.isEmpty(result.getData().get(1).getList())){
electric.setReactiveGenerate(result.getData().get(1).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{
if(StringUtils.isEmpty(val.getVal())){
return 0.0;
}
return Double.parseDouble(val.getVal());
}).sum());
}else{
electric.setReactiveGenerate(0.0);
}
electrics.add(electric);
calendar.add(Calendar.HOUR_OF_DAY,+1);
startTime = calendar.getTime();
}
});
return electrics;
}
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml

@ -5,7 +5,7 @@
<select id="pageCondition" resultType="com.hnac.hzims.alarm.config.vo.AlarmHistoryVo">
SELECT ALARM.STATION_ID,ALARM.STATION_NAME,ALARM.ALARM_TYPE,ALARM.ALARM_CONTEXT,
HANDLE.HANDLE_WAY,HANDLE.CREATE_USER HANDLE_USER,HANDLE.CREATE_USER_NAME HANDLE_USER_NAME,ALARM.ALARM_TIME,
HANDLE.CREATE_TIME HANDLE_TIME
HANDLE.CREATE_TIME HANDLE_TIME,HANDLE.FILE_PATH
FROM HZIMS_ALARM ALARM
LEFT JOIN HZIMS_ALARM_HANDLE HANDLE
ON ALARM.ALARM_ID = HANDLE.ALARM_ID

Loading…
Cancel
Save