diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java index c353134..feac662 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/AlarmHistoryVo.java +++ b/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") diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/DeviceElectricVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/DeviceElectricVo.java new file mode 100644 index 0000000..9c1f934 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java index 651732a..2c7e061 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java +++ b/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 result = new HashMap<>(); // 日 if (type == 0) { + // 站点设备集合 + List devices = deviceService.list(Wrappers.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 electrics = this.deviceElectrics(devices,date); + + // 表头 + List 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> tableDate = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List 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 deviceElectrics(List devices,Date date) { + List 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 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> 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; + } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml index 7f86437..f583dc7 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmMapper.xml @@ -5,7 +5,7 @@