diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/RunTemplateEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/RunTemplateEntity.java new file mode 100644 index 0000000..179e6d9 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/RunTemplateEntity.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.electric.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * @author ysj + */ +@Data +@TableName("hzims_run_template") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "运行报表模板") +public class RunTemplateEntity extends TenantEntity { + + @ApiModelProperty(value = "模板名称") + private String templateName; + + @ApiModelProperty(value = "站点编码") + private String stationId; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "标识数据") + private String signages; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java new file mode 100644 index 0000000..3f3314a --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.electric.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + + +/** + * @author ysj + */ +@Data +public class RunDeviceSignagesVo { + + @ApiModelProperty(value = "设备编号") + private String deviceCode; + + @ApiModelProperty(value = "属性标识") + private List signages; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java new file mode 100644 index 0000000..15d50e7 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.electric.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + + +/** + * @author ysj + */ +@Data +public class RunParamVo { + + @ApiModelProperty(value = "时间 :yyyy-MM-dd") + private String time; + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构Id") + private List deviceSignages; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java new file mode 100644 index 0000000..3c0c892 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.electric.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +/** + * @author ysj + */ +@Data +public class RunResultVo { + + @ApiModelProperty(value = "时间") + private String time; + +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopTimeVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopTimeVO.java new file mode 100644 index 0000000..93fc6e6 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopTimeVO.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.equipment.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author ysj + */ +@Data +public class StartStopTimeVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "设备编号") + private String deviceCode; + + @ApiModelProperty(value = "设备名称") + private String deviceName; + + @ApiModelProperty(value = "属性标识") + private String signage; + + @ApiModelProperty(value = "时间") + private String time; + + @ApiModelProperty(value = "值") + private String value; + + @ApiModelProperty(value = "质量值 : 0-有效 1-无效") + private Integer quality; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/constant/HydroelectricConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/constant/HydroelectricConstant.java index bd008e2..5fe0a87 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/constant/HydroelectricConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/constant/HydroelectricConstant.java @@ -15,4 +15,9 @@ public interface HydroelectricConstant { * 代运维 */ Integer PROXY_OPEARIONAL = 2; + + /** + * 站点状态: 有效站点 + */ + Integer INVALID_STATION = 2; } \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java index 9c3b265..e5ac2d6 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java @@ -15,4 +15,6 @@ public interface ScheduledConstant { String LOAD_THREE_YEAR_POWER_GENERATION = "loadThreeYearPowerGeneration"; String THIS_DAY_START_STOP_RECORD = "thisDayStartStopRecord"; + + String START_STOP_TIME_RECORD = "startStopTimeRecord"; } \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java index a74368e..5c04f91 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java @@ -40,12 +40,6 @@ public class HydropowerUnitTargetVo { @ApiModelProperty(value = "昨日发电量") private Float powerYesterDay; - @ApiModelProperty(value = "本次开机时间") - private String startDownTime; - - @ApiModelProperty(value = "本次开机时长") - private Double startupDownDuration; - @ApiModelProperty(value = "年停机时长") private Double shutDownDurationYear; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java index 8dde5c1..b9e8ece 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java @@ -3,17 +3,14 @@ package com.hnac.hzims.electric.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.electric.service.IElectricReportService; import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; -import com.hnac.hzims.equipment.entity.EmAssociationEntity; +import com.hnac.hzims.electric.vo.RunParamVo; +import com.hnac.hzims.electric.vo.RunResultVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @@ -39,10 +36,17 @@ public class ElectricReportController extends BladeController { } @GetMapping("/comprehensive") - @ApiOperationSupport(order = 1) - @ApiOperation(value = "综合报表", notes = "传入 deptId") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "综合报表", notes = "传入 deptId、year") public R> comprehensive(@RequestParam(value = "deptId") Long deptId, @RequestParam(value = "year") String year) { return R.data(service.comprehensive(deptId,year)); } + + @PostMapping("/run") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "运行报表", notes = "传入 deptId、day") + public R> run(@RequestBody RunParamVo param) { + return R.data(service.run(param)); + } } \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/RunTemplateController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/RunTemplateController.java new file mode 100644 index 0000000..0b16087 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/RunTemplateController.java @@ -0,0 +1,50 @@ +package com.hnac.hzims.electric.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.electric.entity.RunTemplateEntity; +import com.hnac.hzims.electric.service.IRunTemplateService; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/run/template") +@Api(tags = "电量报表") +public class RunTemplateController extends BladeController { + + private final IRunTemplateService service; + + @PostMapping("/save") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增历史数据模板", notes = "传入HistoryTemplateEntity") + public R save(@RequestBody RunTemplateEntity entity) { + return R.status(service.save(entity)); + } + + @PostMapping("/remove") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "删除历史数据模板") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(service.removeByIds(Func.toLongList(ids))); + } + + @GetMapping("/pages") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "分页历史数据模板", notes = "查询条件:params、query") + public R> pageCondition(HistoryTemplateParamVo params, Query query) { + return R.data(service.pageCondition(params, Condition.getPage(query))); + } +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.java new file mode 100644 index 0000000..7841e17 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.electric.mapper; + +import com.hnac.hzims.electric.entity.RunTemplateEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface RunTemplateMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.xml new file mode 100644 index 0000000..fdfcae5 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java index 24bc9a2..4d99281 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java @@ -1,6 +1,8 @@ package com.hnac.hzims.electric.service; import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; +import com.hnac.hzims.electric.vo.RunParamVo; +import com.hnac.hzims.electric.vo.RunResultVo; import java.util.List; import java.util.Map; @@ -14,4 +16,6 @@ public interface IElectricReportService { Map basics(Long deptId, Long type,String time); List comprehensive(Long deptId,String year); + + Map run(RunParamVo param); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IRunTemplateService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IRunTemplateService.java new file mode 100644 index 0000000..e2b83fd --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IRunTemplateService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.electric.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.electric.entity.RunTemplateEntity; +import com.hnac.hzims.history.entity.HistoryTemplateEntity; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; + +/** + * @author ysj + */ +public interface IRunTemplateService extends IService { + + + IPage pageCondition(HistoryTemplateParamVo params, IPage page); +} 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 b549b72..ae9a00c 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 @@ -12,8 +12,10 @@ import com.hnac.hzims.electric.service.ThirtyService; import com.hnac.hzims.electric.service.ThreeService; import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; import com.hnac.hzims.electric.vo.DeviceElectricVo; +import com.hnac.hzims.electric.vo.RunParamVo; import com.hnac.hzims.electric.vo.TableHeadVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.hzimsweather.feign.IRainfallClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; @@ -52,6 +54,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { private final ISysClient sysClient; + private final IRainfallClient rainClient; + private final IStationClient stationClient; private final IAnalyseDataSearchClient analyseDataSearchClient; @@ -128,7 +132,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { .ge(ThreeEntity::getStrMonth, DateUtil.format(start,DateUtil.PATTERN_DATE)) .le(ThreeEntity::getStrMonth, DateUtil.format(end,DateUtil.PATTERN_DATE)) ); - + // 查询站点降雨量 + List> rains = this.rains(station.getData().getCode(),DateUtil.format(start,DateUtil.PATTERN_DATE),DateUtil.format(end,DateUtil.PATTERN_DATE)); calendar.setTime(DateUtil.parse(year,"yyyy")); calendar.add(Calendar.YEAR,1); @@ -143,6 +148,26 @@ public class ElectricReportServiceImpl implements IElectricReportService { comprehensive.setMonth(current.getMonth() + 1 + "月"); String currentMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); String currentYear = DateUtil.format(calendar.getTime(),"yyyy"); + if(calendar.getTime().compareTo(new Date()) > 0){ + comprehensive.setMonthGenerate(-1.0); + comprehensive.setLastMonthGenerate(-1.0); + comprehensive.setYearGenerate(-1.0); + comprehensive.setLastYearGenerate(-1.0); + comprehensive.setLastMonthGenerateRate(-1.0); + comprehensive.setLastYearGenerateRate(-1.0); + comprehensive.setMonthEquivalent(-1.0); + comprehensive.setLastMonthEquivalent(-1.0); + comprehensive.setYearEquivalent(-1.0); + comprehensive.setLastYearEquivalent(-1.0); + comprehensive.setMonthRain(-1.0); + comprehensive.setLastMonthRain(-1.0); + comprehensive.setYearRain(-1.0); + comprehensive.setLastYearRain(-1.0); + electrics.add(comprehensive); + calendar.add(Calendar.MONTH,1); + current = calendar.getTime(); + continue; + } calendar.add(Calendar.YEAR,-1); String lastMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); String lastYear = DateUtil.format(calendar.getTime(),"yyyy"); @@ -205,16 +230,43 @@ public class ElectricReportServiceImpl implements IElectricReportService { comprehensive.setYearEquivalent(0.0); comprehensive.setLastYearEquivalent(0.0); } - // 降雨 : fixme 模拟降雨 - comprehensive.setMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); - comprehensive.setLastMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); - if(CollectionUtil.isEmpty(electrics)){ - comprehensive.setYearRain(comprehensive.getMonthRain()); - comprehensive.setLastYearRain(comprehensive.getLastMonthRain()); + // 降雨量 + if(CollectionUtil.isNotEmpty(rains)){ + comprehensive.setMonthRain(rains.stream().mapToDouble(map->{ + if (map.get("fx_date").toString().contains(currentMon)) { + Object object = map.get("precip"); + if(ObjectUtil.isEmpty(object)){ + return 0.0; + }else{ + return Double.parseDouble(object.toString()); + } + } + return 0.0; + }).sum()); + comprehensive.setLastMonthRain(rains.stream().mapToDouble(map->{ + if (map.get("fx_date").toString().contains(lastMon)) { + Object object = map.get("precip"); + if(ObjectUtil.isEmpty(object)){ + return 0.0; + }else{ + return Double.parseDouble(object.toString()); + } + } + return 0.0; + }).sum()); + if(CollectionUtil.isEmpty(electrics)){ + comprehensive.setYearRain(comprehensive.getMonthRain()); + comprehensive.setLastYearRain(comprehensive.getLastMonthRain()); + }else{ + // 累计降雨 + comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain()); + comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain()); + } }else{ - // 累计降雨 - comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain()); - comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain()); + comprehensive.setMonthRain(0.0); + comprehensive.setLastMonthRain(0.0); + comprehensive.setYearRain(0.0); + comprehensive.setLastYearRain(0.0); } electrics.add(comprehensive); calendar.add(Calendar.MONTH,1); @@ -223,6 +275,21 @@ public class ElectricReportServiceImpl implements IElectricReportService { return electrics; } + /** + * 站点降雨量查询 + * @param stationId + * @param start + * @param end + * @return + */ + private List> rains(String stationId, String start, String end) { + R>> durations = rainClient.getDurationRainFall(stationId,start,end); + if(!durations.isSuccess() || CollectionUtil.isEmpty(durations.getData())){ + return new ArrayList<>(); + } + return durations.getData(); + } + /** * 确认机构级别 @@ -307,6 +374,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String day = DateUtil.format(start,DateUtil.PATTERN_DATE); item.add(start.getDate() + "日"); + if(start.compareTo(new Date()) > 0){ + item.add(-1.0); + item.add(-1.0); + group.entrySet().stream().sorted(Map.Entry. + comparingByKey()).forEach(entry->{ + item.add(-1.0); + item.add(-1.0); + }); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + continue; + } + // 总计:有功、无功 item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); @@ -477,6 +557,18 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String day = DateUtil.format(start,DateUtil.PATTERN_DATE); item.add(start.getDate() + "日"); + if(start.compareTo(new Date()) > 0){ + item.add(-1.0); + item.add(-1.0); + areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ + item.add(-1.0); + item.add(-1.0); + }); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + continue; + } + // 总计:有功、无功 item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); @@ -485,10 +577,14 @@ public class ElectricReportServiceImpl implements IElectricReportService { areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ List childs = depts.stream().filter(o->o.getParentId().equals(area.getId())).map(Dept::getId).collect(Collectors.toList()); if(CollectionUtil.isEmpty(childs)){ + item.add(0.0); + item.add(0.0); return; } List codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept()) && ObjectUtil.isNotEmpty(o.getType()) && o.getType().equals(0)).map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(codes)){ + item.add(0.0); + item.add(0.0); return; } item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day) && codes.contains(thirty.getStationId())).mapToDouble(o->o.getGenerate().doubleValue()).sum()); @@ -656,6 +752,17 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String hours = DateUtil.format(start,"yyyy-MM-dd HH"); item.add(start.getHours() + "时"); + if(start.compareTo(new Date()) > 0){ + item.add(-1.0); + item.add(-1.0); + stationDevices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getOrd)).forEach(device->{ + item.add(-1.0); + item.add(-1.0); + }); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + continue; + } // 总计:有功、无功 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()); @@ -900,4 +1007,32 @@ public class ElectricReportServiceImpl implements IElectricReportService { }); return electrics; } + + /** + * 运行报表 + * @param param + * @return + */ + @Override + public Map run(RunParamVo param) { + // 设备参数校验 + if(CollectionUtil.isEmpty(param.getDeviceSignages())){ + return new HashMap<>(); + } + + // 查询站点 + StationEntity query = new StationEntity(); + query.setRefDept(param.getDeptId()); + R station = stationClient.getStationByCodeOrRedDept(query); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + return new HashMap<>(); + } + + // 开始时间、结束时间 + Date start = DateUtil.parse(param.getTime() + " 00:00:00",DateUtil.PATTERN_DATETIME); + Date end = DateUtil.parse(param.getTime() + " 23:59:59",DateUtil.PATTERN_DATETIME); + + + return null; + } } \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/RunTemplateServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/RunTemplateServiceImpl.java new file mode 100644 index 0000000..b727720 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/RunTemplateServiceImpl.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.electric.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.electric.entity.RunTemplateEntity; +import com.hnac.hzims.electric.mapper.RunTemplateMapper; +import com.hnac.hzims.electric.service.IRunTemplateService; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +public class RunTemplateServiceImpl extends ServiceImpl implements IRunTemplateService { + + + /** + * 查询运行报表模板 + * @param params + * @param page + * @return + */ + @Override + public IPage pageCondition(HistoryTemplateParamVo params, IPage page) { + return null; + } +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java index ef65993..2473b01 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java @@ -12,10 +12,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; @@ -112,7 +109,7 @@ public class PlanGenertionClient implements IPlanGenertionClient{ */ @PostMapping(GET_POWER_YEAR) @Override - public Double getPlanPowerYear(DevicePlanGenerationVo param) { + public Double getPlanPowerYear(@RequestBody DevicePlanGenerationVo param) { return service.getPlanPowerYear(param.getStationIds(),param.getDate()); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index 0a1b3ff..5aca754 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -62,7 +62,7 @@ public class RealTargetScheduledTask { * 水电站-机组指标加载 */ //@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) - @Scheduled(cron = "0 0/2 * * * ? ") + @Scheduled(cron = "0 0/3 * * * ? ") public ReturnT loadHydropowerTarget() { String param = ""; if (Func.isBlank(param)) { @@ -114,7 +114,7 @@ public class RealTargetScheduledTask { * 水利-站点水位数据 */ //@XxlJob(LOAD_WATER_LEVEL) - @Scheduled(cron = "0/40 * * * * ? ") + @Scheduled(cron = "0 0/5 * * * ? ") public ReturnT loadWaterLevel() { String param = ""; if (Func.isBlank(param)) { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java index a9e7284..92e6d16 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java @@ -44,8 +44,8 @@ public class StartStopScheduledTask { /** * 设备开停机时间记录 */ - @XxlJob(START_STOP_TIME_RECORD) - //@Scheduled(cron = "0/40 * * * * ? ") + //@XxlJob(START_STOP_TIME_RECORD) + @Scheduled(cron = "0 0/2 * * * ? ") public ReturnT startStopTimeRecord() { String param = ""; if (Func.isBlank(param)) { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java index a65d855..acb00ff 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java @@ -8,15 +8,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.equipment.entity.StartStopDurationEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.equipment.vo.StartStopTimeVO; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.vo.StartStopDurationRecordVo; import com.hnac.hzims.scheduled.mapper.equipment.StartStopDurationMapper; import com.hnac.hzims.scheduled.service.equipment.StartStopDurationService; +import com.hnac.hzims.scheduled.service.operation.plate.DataService; import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; @@ -55,6 +59,8 @@ import java.util.stream.Collectors; @DS("equipment") public class StartStopDurationServiceImpl extends ServiceImpl implements StartStopDurationService { + private final DataService dataService; + private final StationService stationService; private final DeviceDataClient deviceDataClient; @@ -64,6 +70,8 @@ public class StartStopDurationServiceImpl extends ServiceImpl(256), new ThreadFactoryBuilder().setNameFormat("device-start-stop-duration-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); /** @@ -154,7 +162,45 @@ public class StartStopDurationServiceImpl extends ServiceImpl devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() {}); + if(CollectionUtil.isEmpty(devices)){ + return; + } + // 获取历史开关机状态记录 + List startStopTimes = (List) redisTemplate.opsForValue().get(START_STOP_TIME_KEY); + // 遍历设备 + redisTemplate.opsForValue().set(START_STOP_TIME_KEY,devices.stream().map(device->{ + StartStopTimeVO startStopTime = new StartStopTimeVO(); + startStopTime.setDeviceCode(device.getEmCode()); + startStopTime.setDeviceName(device.getName()); + startStopTime.setSignage(HomePageConstant.START_STOP_STATUS); + if(MapUtils.isEmpty(device.getPoint()) || !device.getPoint().containsKey(HomePageConstant.START_STOP_STATUS)){ + startStopTime.setQuality(-1); + } + // 调用fegin接口查询实时数据 + List fields = dataService.getRealDataByAnalyzeCode(device.getEmCode(),Collections.singletonList(HomePageConstant.START_STOP_STATUS)); + if(CollectionUtil.isEmpty(fields) || fields.get(0).getQ() > -1){ + startStopTime.setQuality(-1); + return startStopTime; + } + // 有效开关机点位比较value差异 + if(CollectionUtil.isNotEmpty(startStopTimes)){ + // 寻找设备上次记录值 + Optional optional = startStopTimes.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).findFirst(); + if(optional.isPresent() && optional.get().getValue().equals(fields.get(0).getValue())){ + startStopTime.setValue(optional.get().getValue()); + startStopTime.setTime(optional.get().getTime()); + startStopTime.setQuality(optional.get().getQuality()); + return startStopTime; + } + } + startStopTime.setTime(fields.get(0).getTime()); + startStopTime.setValue(fields.get(0).getValue()); + startStopTime.setQuality(fields.get(0).getQ()); + return startStopTime; + }).collect(Collectors.toList())); } /** diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java index 2ac7435..9f70c71 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java @@ -105,7 +105,10 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { public void thisDayPowerGeneration(String param) { String month = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); // 步骤1.水电、光伏站点 - List stations = stationService.list(Wrappers.lambdaQuery().in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC))); + List stations = stationService.list(Wrappers.lambdaQuery(). + in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC)) + .in(StationEntity::getCode, Arrays.asList("901800000612","901800000137")) + ); // 步骤2.缓存设备信息 List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() {}); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index f61cec6..2347a51 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -297,7 +297,6 @@ public class RealTargetServiceImpl implements RealTargetService { // 今年已经过去多少个小时了 double hoursPassed = this.hoursPassed(); - Random random = new Random(); if(CollectionUtil.isNotEmpty(devices)){ CountDownLatch countDownLatch = new CountDownLatch(devices.size()); for(EminfoAndEmParamVo device : devices) { @@ -330,23 +329,16 @@ public class RealTargetServiceImpl implements RealTargetService { .eq(StartStopDurationEntity::getDeviceCode,device.getEmCode()) ); if(CollectionUtil.isEmpty(durations)){ - target.setStartupDurationYear(0.0); - target.setShutDownDurationYear(hoursPassed); + target.setStartupDurationYear(-1.0); + target.setShutDownDurationYear(-1.0); }else{ target.setStartupDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStartDuration).sum()); target.setShutDownDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStopDuration).sum()); } }else{ - target.setStartupDurationYear(0.0); - target.setShutDownDurationYear(hoursPassed); + target.setStartupDurationYear(-1.0); + target.setShutDownDurationYear(-1.0); } - // FIXME 本次开机/停机时间 - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.MINUTE,random.nextInt(1440)); - target.setStartDownTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); - // FIXME 本次开/停机时长 - target.setStartupDownDuration(random.nextDouble() * 24); - targets.add(target); countDownLatch.countDown(); }catch (Exception exception){ countDownLatch.countDown(); @@ -1256,10 +1248,7 @@ public class RealTargetServiceImpl implements RealTargetService { * @return */ private double getWaterLevel(String instanceCode, String signage) { - RealDataSearchPO realData = new RealDataSearchPO(); - realData.setAnalyzeCode(instanceCode); List signages = Collections.singletonList(signage); - realData.setSignages(signages); // 调用fegin接口查询实时数据 List fields = dataService.getRealDataByAnalyzeCode(instanceCode,signages); if(CollectionUtil.isEmpty(fields)){ @@ -1559,7 +1548,7 @@ public class RealTargetServiceImpl implements RealTargetService { calendar.add(Calendar.HOUR_OF_DAY,-23); // 开始日期 Date start = calendar.getTime(); - List records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(start,"yyyy-MM-dd HH") + ":59:59", 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + List records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(end,"yyyy-MM-dd HH") + ":59:59", 3, 2, device.getEmCode(), HomePageConstant.HYDROPOWER_ACTIVE_POWER); List activePowers = new ArrayList<>(); while (start.compareTo(end) <= 0){ String time = DateUtil.format(start,"yyyy-MM-dd HH"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index 7f05544..8af82a2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -9,6 +9,7 @@ import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.vo.DevicePlanGenerationVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.PlanPowerYearVo; +import com.hnac.hzims.equipment.vo.StartStopTimeVO; import com.hnac.hzims.hzimsweather.feign.IRainfallClient; import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; @@ -66,6 +67,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { private final static String LOADWATER_LEVEL_KEY = "hzims:operation:loadwater:level:key"; private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; + private final static String START_STOP_TIME_KEY = "hzims:operation:start:stop:key"; private final static String LOAD_HYDROPOWER_REAL_KEY = "hzims:operation:loadhydropowerunit:real:key"; private final static String LOAD_HYDROPOWER_TARGET_KEY = "hzims:operation:loadhydropowerunit:target:key"; private final static String DEVICE_CACHE_COFIG_FINAL = "hzims:equipment:emInfo:deviceCode.emInfoList"; @@ -99,6 +101,8 @@ public class HydroelectricServiceImpl implements HydroelectricService { List plans = planClient.getPlanPowerByYear(station.getCode(), Integer.parseInt(DateUtil.format(new Date(),"yyyy"))); // 水位数据 List waterLevels = (List) redisTemplate.opsForValue().get(LOADWATER_LEVEL_KEY); + // 设备开停机 + List startStopTimes = (List) redisTemplate.opsForValue().get(START_STOP_TIME_KEY); // 步骤3.数据处理、赋值 HydroelectricStationVo result = new HydroelectricStationVo(); @@ -147,8 +151,6 @@ public class HydroelectricServiceImpl implements HydroelectricService { device.setPowerYear(target.get().getPowerYear()); device.setPowerYesterYear(target.get().getPowerYesterYear()); device.setPowerMon(target.get().getPowerMon()); - device.setStartDownTime(target.get().getStartDownTime()); - device.setStartupDownDuration(target.get().getStartupDownDuration()); device.setStartupDurationYear(target.get().getStartupDurationYear()); device.setShutDownDurationYear(target.get().getShutDownDurationYear()); if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){ @@ -158,6 +160,26 @@ public class HydroelectricServiceImpl implements HydroelectricService { device.setGenerates(target.get().getGenerationPowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDeviceGenerateVo.class)).collect(Collectors.toList())); } } + // 开停机数据 + Optional startStop = startStopTimes.stream().filter(o->iter.equals(o.getDeviceCode())).findFirst(); + if(startStop.isPresent()){ + if(startStop.get().getQuality() > 0){ + Date time; + if(startStop.get().getTime().contains(".000")){ + time = DateUtil.parse(startStop.get().getTime(), "yyyy-MM-dd HH:mm:ss.sss"); + }else{ + time = DateUtil.parse(startStop.get().getTime(), DateUtil.PATTERN_DATETIME); + } + device.setStartDownTime(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); + device.setStartupDownDuration(BigDecimal.valueOf(new Date().getTime() - time.getTime() / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + device.setStartDownTime("-1"); + device.setStartupDownDuration(-1.0); + } + }else{ + device.setStartDownTime("-1"); + device.setStartupDownDuration(-1.0); + } return device; }).collect(Collectors.toList())); } @@ -304,6 +326,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { // 查询用户当前权限站点 List stations = stationService.list(Wrappers.lambdaQuery() + .ne(StationEntity::getStatus,HydroelectricConstant.INVALID_STATION) .eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL) .eq(StationEntity::getType,HydroelectricConstant.HYDROPOWER) ); @@ -703,6 +726,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { return new ArrayList<>(); } return stationService.list(Wrappers.lambdaQuery() + .ne(StationEntity::getStatus,HydroelectricConstant.INVALID_STATION) .eq(StationEntity::getType, HydroelectricConstant.HYDROPOWER) .eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL) .in(StationEntity::getRefDept,deptIds) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java index 38672d7..71161ef 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationVideoTypeMapper.java @@ -1,11 +1,8 @@ package com.hnac.hzims.operational.station.mapper; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; @@ -14,7 +11,6 @@ import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; -import java.sql.Wrapper; import java.util.List; /**