From 33a442b6654fbe7f54910ed32731f54e7e597647 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 13 Sep 2024 14:37:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?#=E8=BF=90=E8=A1=8C=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/electric/entity/RunTemplateEntity.java | 30 ++++ .../hzims/electric/vo/RunDeviceSignagesVo.java | 20 +++ .../com/hnac/hzims/electric/vo/RunParamVo.java | 23 +++ .../com/hnac/hzims/electric/vo/RunResultVo.java | 16 +++ .../hnac/hzims/equipment/vo/StartStopTimeVO.java | 33 +++++ .../constant/HydroelectricConstant.java | 5 + .../main/constant/ScheduledConstant.java | 2 + .../main/vo/HydropowerUnitTargetVo.java | 6 - .../controller/ElectricReportController.java | 20 +-- .../electric/controller/RunTemplateController.java | 50 +++++++ .../hzims/electric/mapper/RunTemplateMapper.java | 11 ++ .../hzims/electric/mapper/RunTemplateMapper.xml | 5 + .../electric/service/IElectricReportService.java | 4 + .../electric/service/IRunTemplateService.java | 16 +++ .../service/impl/ElectricReportServiceImpl.java | 155 +++++++++++++++++++-- .../service/impl/RunTemplateServiceImpl.java | 28 ++++ .../hzims/equipment/feign/PlanGenertionClient.java | 7 +- .../scheduled/RealTargetScheduledTask.java | 4 +- .../scheduled/StartStopScheduledTask.java | 4 +- .../impl/StartStopDurationServiceImpl.java | 46 ++++++ .../home/impl/ObtainGenerationServiceImpl.java | 5 +- .../operation/home/impl/RealTargetServiceImpl.java | 21 +-- .../service/impl/HydroelectricServiceImpl.java | 28 +++- .../station/mapper/StationVideoTypeMapper.java | 4 - 24 files changed, 487 insertions(+), 56 deletions(-) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/RunTemplateEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunDeviceSignagesVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/StartStopTimeVO.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/RunTemplateController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/RunTemplateMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IRunTemplateService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/RunTemplateServiceImpl.java 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; /** From 33e51df49de84767196d060514405f79aad08093 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 24 Sep 2024 10:35:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#=E8=BF=90=E8=A1=8C=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/config/constants/AlarmConstants.java | 2 +- .../hnac/hzims/alarm/config/vo/AlarmHistoryVo.java | 8 +- .../hzims/electric/vo/RunDeviceSignagesVo.java | 3 - .../hnac/hzims/electric/vo/RunParamSignageVo.java | 20 + .../com/hnac/hzims/electric/vo/RunParamVo.java | 8 +- .../hnac/hzims/electric/vo/RunResultValueVo.java | 20 + .../com/hnac/hzims/electric/vo/RunResultVo.java | 16 - .../station/entity/FrameRecordEntity.java | 6 + .../controller/ElectricReportController.java | 27 +- .../electric/service/IElectricReportService.java | 8 +- .../service/impl/ElectricReportServiceImpl.java | 691 ++++++++++++++++++++- .../hzims/alarm/show/mapper/AlarmHandleMapper.xml | 1 + .../hnac/hzims/alarm/show/mapper/AlarmMapper.xml | 20 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 16 +- .../scheduled/GenerationScheduledTask.java | 2 +- .../scheduled/scheduled/ShowScheduledTask.java | 8 +- .../scheduled/StartStopScheduledTask.java | 2 +- .../service/alarm/impl/AlarmServiceImpl.java | 1 + .../impl/StartStopDurationServiceImpl.java | 5 +- .../business/impl/PhenomenonServiceImpl.java | 2 +- .../home/impl/ObtainGenerationServiceImpl.java | 6 +- .../operation/home/impl/RealTargetServiceImpl.java | 5 + .../census/controller/TargetController.java | 2 +- .../census/service/impl/TargetServiceImpl.java | 2 +- .../service/impl/HydroelectricServiceImpl.java | 28 +- 25 files changed, 812 insertions(+), 97 deletions(-) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamSignageVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultValueVo.java delete mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java index 33c1c14..b4104c2 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmConstants.java @@ -70,5 +70,5 @@ public interface AlarmConstants { String FDP_INVALID_ZOME_STATUS = "1"; - List WHOLE_ALARM_TYPE = Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.START,AlarmConstants.STOP); + List WHOLE_ALARM_TYPE = Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.ONE_LEVEL,AlarmConstants.TWO_LEVEL,AlarmConstants.THREE_LEVEL); } 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 feac662..615361a 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 @@ -23,17 +23,23 @@ public class AlarmHistoryVo { @ApiModelProperty(value = "站点名称") private String stationName; + @ApiModelProperty(value = "告警Id") + private String alarmId; + @ApiModelProperty(value = "告警类型") private Integer alarmType; @ApiModelProperty(value = "告警内容") private String alarmContext; + @ApiModelProperty(value = "处理方式") + private Long handleWay; + @ApiModelProperty("处理人") private Long handleUser; @ApiModelProperty("处理人名称") - private Long handleUserName; + private String handleUserName; @ApiModelProperty("处理附件地址") private String filePath; 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 index 3f3314a..69b884a 100644 --- 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 @@ -12,9 +12,6 @@ import java.util.List; @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/RunParamSignageVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamSignageVo.java new file mode 100644 index 0000000..9f8a941 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunParamSignageVo.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 RunParamSignageVo { + + @ApiModelProperty(value = "属性标识") + private String signage; + + @ApiModelProperty(value = "属性名称") + private String signagesName; +} \ 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 index 15d50e7..ba98ce4 100644 --- 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 @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; +import java.util.Map; /** @@ -15,9 +16,6 @@ public class RunParamVo { @ApiModelProperty(value = "时间 :yyyy-MM-dd") private String time; - @ApiModelProperty(value = "机构Id") - private Long deptId; - - @ApiModelProperty(value = "机构Id") - private List deviceSignages; + @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/RunResultValueVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultValueVo.java new file mode 100644 index 0000000..6dee912 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultValueVo.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.electric.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Map; + + +/** + * @author ysj + */ +@Data +public class RunResultValueVo { + + @ApiModelProperty(value = "时间") + private String ts; + + @ApiModelProperty(value = "值") + private String val; +} \ 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 deleted file mode 100644 index 3c0c892..0000000 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/RunResultVo.java +++ /dev/null @@ -1,16 +0,0 @@ -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/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java index 14445e5..7ecdce8 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java @@ -31,4 +31,10 @@ public class FrameRecordEntity extends TenantEntity { @ApiModelProperty("实时画面地址") private String frameAddress; + + @ApiModelProperty("区分站点V3、v4") + private String type; + + @ApiModelProperty("画面来源: 0云组态 、1 hz3000v3.0、 2 hz3000v4.0") + private Integer picSource; } \ No newline at end of file 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 b9e8ece..6315535 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 @@ -4,7 +4,6 @@ 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.electric.vo.RunParamVo; -import com.hnac.hzims.electric.vo.RunResultVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -12,6 +11,7 @@ import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -31,20 +31,39 @@ public class ElectricReportController extends BladeController { @ApiOperation(value = "基础报表", notes = "传入 type : 0-日报 1-月报 2-年报") public R> basics(@RequestParam(value = "deptId",required = false) Long deptId, @RequestParam(value = "type") Long type, - @RequestParam(value = "time") String time) { + @RequestParam(value = "time") String time) { return R.data(service.basics(deptId,type,time)); } - @GetMapping("/comprehensive") + @GetMapping("/basics/export") @ApiOperationSupport(order = 2) + @ApiOperation(value = "基础报表导出", notes = "传入 deptId、year") + public void basicsExport(HttpServletResponse response, + @RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value = "type") Long type, + @RequestParam(value = "time") String time) { + service.basicsExport(response,deptId,type,time); + } + + @GetMapping("/comprehensive") + @ApiOperationSupport(order = 3) @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)); } + @GetMapping("/comprehensive/export") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "综合报表导出", notes = "传入 deptId、year") + public void comprehensiveExport(HttpServletResponse response, + @RequestParam(value = "deptId") Long deptId, + @RequestParam(value = "year") String year) { + service.comprehensiveExport(response,deptId,year); + } + @PostMapping("/run") - @ApiOperationSupport(order = 3) + @ApiOperationSupport(order = 5) @ApiOperation(value = "运行报表", notes = "传入 deptId、day") public R> run(@RequestBody RunParamVo param) { return R.data(service.run(param)); 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 4d99281..978b6fb 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 @@ -2,8 +2,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 javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -15,7 +15,11 @@ public interface IElectricReportService { Map basics(Long deptId, Long type,String time); + void basicsExport(HttpServletResponse response, Long deptId, Long type, String time); + List comprehensive(Long deptId,String year); - Map run(RunParamVo param); + void comprehensiveExport(HttpServletResponse response, Long deptId, String year); + + Map run(RunParamVo param); } 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 ae9a00c..50ac589 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 @@ -1,6 +1,7 @@ package com.hnac.hzims.electric.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -10,10 +11,7 @@ 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.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.electric.vo.*; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.feign.IRainfallClient; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -22,8 +20,20 @@ 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.AnalyzeDataConditionVO; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.source.dto.HisFacSlicerDataDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; @@ -33,9 +43,14 @@ import org.springblade.system.feign.ISysClient; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; +import java.net.URLEncoder; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -56,6 +71,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { private final IRainfallClient rainClient; + private final DeviceDataClient deviceDataClient; + private final IStationClient stationClient; private final IAnalyseDataSearchClient analyseDataSearchClient; @@ -100,6 +117,145 @@ public class ElectricReportServiceImpl implements IElectricReportService { } /** + * 基础报表导出 + * @param response + * @param deptId + * @param type + * @param time + */ + @Override + public void basicsExport(HttpServletResponse response, Long deptId, Long type, String time) { + Map basics = this.basics(deptId,type,time); + if(MapUtils.isEmpty(basics)){ + throw new ServiceException("暂无可进行导出报表!"); + } + // 创建Excel文件 + HSSFWorkbook hssWB = new HSSFWorkbook(); + // 添加sheet页 + HSSFSheet sheet = hssWB.createSheet("电量报表"); + // 行高 + sheet.setDefaultRowHeight((short) (20 * 25)); + // 列宽 + sheet.setDefaultColumnWidth(15); + // 填充数据 + List tableHeads = JSONObject.parseArray(JSONObject.toJSONString(basics.get("tableHead")),TableHeadVo.class); + List> tableBodys = JSON.parseObject(JSONObject.toJSONString(basics.get("tableDate")), new TypeReference>>() {}); + // 表头 + this.setBasicsHeader(hssWB, sheet,tableHeads); + if (!MapUtils.isEmpty(basics)) { + // 数据填充 + this.setBasicsWork(hssWB, sheet, tableBodys); + } + + // 下载导出 + StringBuilder filename = new StringBuilder(); + filename.append(sysClient.getDept(deptId).getData().getDeptName()); + if(type == 0){ + filename.append("_电量(").append(time).append(")日报表"); + }else if(type == 1){ + filename.append("_电量(").append(time).append(")月报表"); + }else if(type == 2){ + filename.append("_电量(").append(time).append(")年报表"); + }else{ + filename.append("_电量报表"); + } + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + hssWB.write(outputStream); + // 关闭 + outputStream.close(); + hssWB.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 基础报表表头 + * @param hssWB + * @param sheet + * @param tableHeads + */ + private void setBasicsHeader(HSSFWorkbook hssWB, HSSFSheet sheet, List tableHeads) { + // 第一行 + int size = tableHeads.size(); + int rowIndex = 0; + HSSFRow row = sheet.createRow(rowIndex); + // 首列暂一个单元格,下标从0开始,所以要减2 + this.setTitileStyle(hssWB, row, (size * 2) - 1 - 1 , true); + for (int i = 0; i < size; i++) { + if(i == 0){ + HSSFCell heade_cell = row.getCell(i); + heade_cell.setCellValue(tableHeads.get(i).getTableName()); + CellRangeAddress heade_region = new CellRangeAddress(rowIndex, rowIndex + 1, (short) 0, (short) 0); + sheet.addMergedRegion(heade_region); + continue; + } + int line = ((i - 1) * 2) + 1; + HSSFCell heade_cell = row.getCell(line); + heade_cell.setCellValue(tableHeads.get(i).getTableName()); + CellRangeAddress heade_region = new CellRangeAddress(rowIndex, rowIndex, (short) line, (short) line + 1); + sheet.addMergedRegion(heade_region); + } + // 第二行 + rowIndex = 1; + HSSFRow heade_row = sheet.createRow(rowIndex); + // 首列暂一个单元格,下标从0开始,所以要减2 + this.setTitileStyle(hssWB, heade_row, (size * 2) - 1 - 1, true); + for (int i = 0; i < size; i++) { + if(tableHeads.get(i).getIsChildren()){ + int line = ((i - 1) * 2) + 1; + HSSFCell heade_cell = heade_row.getCell(line); + heade_cell.setCellValue(tableHeads.get(i).getChildren().get(0)); + + HSSFCell heade_cell_1 = heade_row.getCell(line + 1); + heade_cell_1.setCellValue(tableHeads.get(i).getChildren().get(1)); + } + } + } + + /** + * 基础报表内容填充 + * @param hssWB + * @param sheet + * @param tableBodys + */ + private void setBasicsWork(HSSFWorkbook hssWB, HSSFSheet sheet, List> tableBodys) { + // 第一行 + int rowIndex = 2; + // 首列暂一个单元格,下标从0开始,所以要减2 + for(List bodys : tableBodys){ + HSSFRow bodyRow = sheet.createRow(rowIndex); + // 下标从0开始,所以要减1 + this.setTitileStyle(hssWB, bodyRow, bodys.size() - 1, false); + // 内容填充 + for(int i = 0; i < bodys.size() ; i++){ + HSSFCell body_cell = bodyRow.getCell(i); + if(i > 0){ + double value = BigDecimal.valueOf(Double.parseDouble(bodys.get(i).toString())).setScale(2, RoundingMode.HALF_UP).doubleValue(); + if(value >= 0){ + body_cell.setCellValue(value); + } else{ + body_cell.setCellValue("-"); + } + } else { + body_cell.setCellValue(bodys.get(0).toString()); + } + + } + rowIndex++; + } + } + + /** * 综合报表 * @param deptId * @return @@ -140,8 +296,6 @@ public class ElectricReportServiceImpl implements IElectricReportService { Date finish = calendar.getTime(); calendar.add(Calendar.YEAR,-1); Date current = calendar.getTime(); - // fixme 随机器模拟数据 - Random random = new Random(); List electrics = new ArrayList<>(); while (current.compareTo(finish) < 0){ ComprehensiveElectricVo comprehensive = new ComprehensiveElectricVo(); @@ -174,8 +328,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { calendar.add(Calendar.YEAR,1); // 电量 if(CollectionUtil.isNotEmpty(threes)){ - comprehensive.setMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); - comprehensive.setLastMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); + comprehensive.setMonthGenerate(BigDecimal.valueOf(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum() / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue()); + comprehensive.setLastMonthGenerate(BigDecimal.valueOf(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum() / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue()); if(comprehensive.getMonthGenerate() > 0 && comprehensive.getLastMonthGenerate() > 0){ comprehensive.setLastMonthGenerateRate(BigDecimal.valueOf(comprehensive.getMonthGenerate() / comprehensive.getLastMonthGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); }else{ @@ -275,6 +429,346 @@ public class ElectricReportServiceImpl implements IElectricReportService { return electrics; } + + /** + * 综合报表导出 + * @param response + * @param deptId + * @param year + */ + @Override + public void comprehensiveExport(HttpServletResponse response, Long deptId, String year) { + // 创建Excel文件 + HSSFWorkbook hssWB = new HSSFWorkbook(); + // 添加sheet页 + HSSFSheet sheet = hssWB.createSheet("综合报表"); + // 行高 + sheet.setDefaultRowHeight((short) (20 * 25)); + // 列宽 + sheet.setDefaultColumnWidth(6); + // 表头 + this.setHeader(hssWB, sheet); + // 填充数据 + List comprehensives = this.comprehensive(deptId,year); + if (!CollectionUtil.isEmpty(comprehensives)) { + // 数据填充 + this.setWork(hssWB, sheet, comprehensives); + } + + // 下载导出 + String filename = sysClient.getDept(deptId).getData().getDeptName() + "_" + year + "_综合报表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + hssWB.write(outputStream); + // 关闭 + outputStream.close(); + hssWB.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 首行表头样式 + * @param hssWB + * @param sheet + */ + private void setHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 第一行 + HSSFRow fisrtRow = sheet.createRow(0); + this.setTitileStyle(hssWB, fisrtRow, 28, true); + // 第一个单元格... + HSSFCell headCell = fisrtRow.getCell(0); + headCell.setCellValue("月份"); + HSSFCell headCell1 = fisrtRow.getCell(1); + headCell1.setCellValue("发电量(万kWh)"); + HSSFCell headCell2 = fisrtRow.getCell(13); + headCell2.setCellValue("降雨量(mm)"); + HSSFCell headCell3 = fisrtRow.getCell(21); + headCell3.setCellValue("等效小时"); + // 第一行合并情况 + CellRangeAddress region1 = new CellRangeAddress(0, 1, (short) 0, (short) 0); + CellRangeAddress region2 = new CellRangeAddress(0, 0, (short) 1, (short) 12); + CellRangeAddress region3 = new CellRangeAddress(0, 0, (short) 13, (short) 20); + CellRangeAddress region4 = new CellRangeAddress(0, 0, (short) 21, (short) 28); + sheet.addMergedRegion(region1); + sheet.addMergedRegion(region2); + sheet.addMergedRegion(region3); + sheet.addMergedRegion(region4); + + // 第二行 + HSSFRow secondRow = sheet.createRow(1); + this.setTitileStyle(hssWB, secondRow, 28, true); + + // 第二行第一个单元格 + HSSFCell secondRow_cell = secondRow.getCell(1); + secondRow_cell.setCellValue("本月"); + HSSFCell secondRow_cell_1 = secondRow.getCell(3); + secondRow_cell_1.setCellValue("去年同月"); + HSSFCell secondRow_cell_2 = secondRow.getCell(5); + secondRow_cell_2.setCellValue("月同比"); + HSSFCell secondRow_cell_3 = secondRow.getCell(7); + secondRow_cell_3.setCellValue("本年"); + HSSFCell secondRow_cell_4 = secondRow.getCell(9); + secondRow_cell_4.setCellValue("去年同期"); + HSSFCell secondRow_cell_5 = secondRow.getCell(11); + secondRow_cell_5.setCellValue("年同比"); + HSSFCell secondRow_cell_6 = secondRow.getCell(13); + secondRow_cell_6.setCellValue("本月"); + HSSFCell secondRow_cell_7 = secondRow.getCell(15); + secondRow_cell_7.setCellValue("去年同月"); + HSSFCell secondRow_cell_8 = secondRow.getCell(17); + secondRow_cell_8.setCellValue("本年"); + HSSFCell secondRow_cell_9 = secondRow.getCell(19); + secondRow_cell_9.setCellValue("去年同期"); + HSSFCell secondRow_cell_10 = secondRow.getCell(21); + secondRow_cell_10.setCellValue("本月"); + HSSFCell secondRow_cell_11 = secondRow.getCell(23); + secondRow_cell_11.setCellValue("去年同月"); + HSSFCell secondRow_cell_12 = secondRow.getCell(25); + secondRow_cell_12.setCellValue("本年"); + HSSFCell secondRow_cell_13 = secondRow.getCell(27); + secondRow_cell_13.setCellValue("去年同期"); + + // 第二行合并情况 + // 发电量 + CellRangeAddress second1 = new CellRangeAddress(1, 1, (short) 1, (short) 2); + CellRangeAddress second2 = new CellRangeAddress(1, 1, (short) 3, (short) 4); + CellRangeAddress second3 = new CellRangeAddress(1, 1, (short) 5, (short) 6); + CellRangeAddress second4 = new CellRangeAddress(1, 1, (short) 7, (short) 8); + CellRangeAddress second5 = new CellRangeAddress(1, 1, (short) 9, (short) 10); + CellRangeAddress second6 = new CellRangeAddress(1, 1, (short) 11, (short) 12); + // 降雨量 + CellRangeAddress second7 = new CellRangeAddress(1, 1, (short) 13, (short) 14); + CellRangeAddress second8 = new CellRangeAddress(1, 1, (short) 15, (short) 16); + CellRangeAddress second9 = new CellRangeAddress(1, 1, (short) 17, (short) 18); + CellRangeAddress second10 = new CellRangeAddress(1, 1, (short) 19, (short) 20); + // 等效小时 + CellRangeAddress second11 = new CellRangeAddress(1, 1, (short) 21, (short) 22); + CellRangeAddress second12 = new CellRangeAddress(1, 1, (short) 23, (short) 24); + CellRangeAddress second13 = new CellRangeAddress(1, 1, (short) 25, (short) 26); + CellRangeAddress second14 = new CellRangeAddress(1, 1, (short) 27, (short) 28); + + sheet.addMergedRegion(second1); + sheet.addMergedRegion(second2); + sheet.addMergedRegion(second3); + sheet.addMergedRegion(second4); + sheet.addMergedRegion(second5); + sheet.addMergedRegion(second6); + sheet.addMergedRegion(second7); + sheet.addMergedRegion(second8); + sheet.addMergedRegion(second9); + sheet.addMergedRegion(second10); + sheet.addMergedRegion(second11); + sheet.addMergedRegion(second12); + sheet.addMergedRegion(second13); + sheet.addMergedRegion(second14); + } + + private void setWork(HSSFWorkbook hssWB, HSSFSheet sheet, List comprehensives) { + int size = comprehensives.size(); + for (int i = 0; i < size; i++) { + int rowIndex = i + 2; + HSSFRow row = sheet.createRow(rowIndex); + this.setTitileStyle(hssWB, row, 28, false); + ComprehensiveElectricVo comprehensive = comprehensives.get(i); + // 月份 + HSSFCell body_cell_0 = row.getCell(0); + body_cell_0.setCellValue(comprehensive.getMonth()); + // 本月 + HSSFCell body_cell_1 = row.getCell(1); + if(comprehensive.getMonthGenerate() >= 0){ + body_cell_1.setCellValue(comprehensive.getMonthGenerate()); + }else{ + body_cell_1.setCellValue("-"); + } + // 去年同月 + HSSFCell body_cell_2 = row.getCell(3); + if(comprehensive.getLastMonthGenerate() >= 0){ + body_cell_2.setCellValue(comprehensive.getLastMonthGenerate()); + }else{ + body_cell_2.setCellValue("-"); + } + // 月同比 + HSSFCell body_cell_3 = row.getCell(5); + if(comprehensive.getLastMonthGenerateRate() >= 0){ + body_cell_3.setCellValue(comprehensive.getLastMonthGenerateRate()); + }else{ + body_cell_3.setCellValue("-"); + } + // 本年 + HSSFCell body_cell_4 = row.getCell(7); + if(comprehensive.getYearGenerate() >= 0){ + body_cell_4.setCellValue(comprehensive.getYearGenerate()); + }else{ + body_cell_4.setCellValue("-"); + } + // 去年同期 + HSSFCell body_cell_5 = row.getCell(9); + if(comprehensive.getLastYearGenerate() >= 0){ + body_cell_5.setCellValue(comprehensive.getLastYearGenerate()); + }else{ + body_cell_5.setCellValue("-"); + } + // 年同比 + HSSFCell body_cell_6 = row.getCell(11); + if(comprehensive.getLastYearGenerateRate() >= 0){ + body_cell_6.setCellValue(comprehensive.getLastYearGenerateRate()); + }else{ + body_cell_6.setCellValue("-"); + } + // 本月降雨 + HSSFCell body_cell_7 = row.getCell(13); + if(comprehensive.getMonthRain() >= 0){ + body_cell_7.setCellValue(comprehensive.getMonthRain()); + }else{ + body_cell_7.setCellValue("-"); + } + // 去年同月降雨 + HSSFCell body_cell_8 = row.getCell(15); + if(comprehensive.getMonthRain() >= 0){ + body_cell_8.setCellValue(comprehensive.getLastMonthRain()); + }else{ + body_cell_8.setCellValue("-"); + } + // 本年降雨 + HSSFCell body_cell_9 = row.getCell(17); + if(comprehensive.getYearRain() >= 0){ + body_cell_9.setCellValue(comprehensive.getYearRain()); + }else{ + body_cell_9.setCellValue("-"); + } + // 去年同期降雨 + HSSFCell body_cell_10 = row.getCell(19); + if(comprehensive.getYearRain() >= 0){ + body_cell_10.setCellValue(comprehensive.getLastYearRain()); + }else{ + body_cell_10.setCellValue("-"); + } + // 本月等效小时 + HSSFCell body_cell_11 = row.getCell(21); + if(comprehensive.getMonthEquivalent() >= 0){ + body_cell_11.setCellValue(comprehensive.getMonthEquivalent()); + }else{ + body_cell_11.setCellValue("-"); + } + // 去年同月等效小时 + HSSFCell body_cell_12 = row.getCell(23); + if(comprehensive.getLastMonthEquivalent() >= 0){ + body_cell_12.setCellValue(comprehensive.getLastMonthEquivalent()); + }else{ + body_cell_12.setCellValue("-"); + } + // 本年等效小时 + HSSFCell body_cell_13 = row.getCell(25); + if(comprehensive.getYearEquivalent() >= 0){ + body_cell_13.setCellValue(comprehensive.getYearEquivalent()); + }else{ + body_cell_13.setCellValue("-"); + } + // 去年同期等效小时 + HSSFCell body_cell_14 = row.getCell(27); + if(comprehensive.getLastYearEquivalent() >= 0){ + body_cell_14.setCellValue(comprehensive.getLastYearEquivalent()); + }else{ + body_cell_14.setCellValue("-"); + } + + CellRangeAddress body1 = new CellRangeAddress(rowIndex, rowIndex, (short) 1, (short) 2); + CellRangeAddress body2 = new CellRangeAddress(rowIndex, rowIndex, (short) 3, (short) 4); + CellRangeAddress body3 = new CellRangeAddress(rowIndex, rowIndex, (short) 5, (short) 6); + CellRangeAddress body4 = new CellRangeAddress(rowIndex, rowIndex, (short) 7, (short) 8); + CellRangeAddress body5 = new CellRangeAddress(rowIndex, rowIndex, (short) 9, (short) 10); + CellRangeAddress body6 = new CellRangeAddress(rowIndex, rowIndex, (short) 11, (short) 12); + CellRangeAddress body7 = new CellRangeAddress(rowIndex, rowIndex, (short) 13, (short) 14); + CellRangeAddress body8 = new CellRangeAddress(rowIndex, rowIndex, (short) 15, (short) 16); + CellRangeAddress body9 = new CellRangeAddress(rowIndex, rowIndex, (short) 17, (short) 18); + CellRangeAddress body10 = new CellRangeAddress(rowIndex, rowIndex, (short) 19, (short) 20); + CellRangeAddress body11 = new CellRangeAddress(rowIndex, rowIndex, (short) 21, (short) 22); + CellRangeAddress body12 = new CellRangeAddress(rowIndex, rowIndex, (short) 23, (short) 24); + CellRangeAddress body13 = new CellRangeAddress(rowIndex, rowIndex, (short) 25, (short) 26); + CellRangeAddress body14 = new CellRangeAddress(rowIndex, rowIndex, (short) 27, (short) 28); + + sheet.addMergedRegion(body1); + sheet.addMergedRegion(body2); + sheet.addMergedRegion(body3); + sheet.addMergedRegion(body4); + sheet.addMergedRegion(body5); + sheet.addMergedRegion(body6); + sheet.addMergedRegion(body7); + sheet.addMergedRegion(body8); + sheet.addMergedRegion(body9); + sheet.addMergedRegion(body10); + sheet.addMergedRegion(body11); + sheet.addMergedRegion(body12); + sheet.addMergedRegion(body13); + sheet.addMergedRegion(body14); + } + } + + + /** + * 设置Titile单元格样式 + * + * @param hssWB + * @param row + * @param len + */ + private void setTitileStyle(HSSFWorkbook hssWB, HSSFRow row, int len, boolean isHead) { + HSSFCellStyle cellStyle = getHeadStyle(hssWB, isHead); + for (int i = 0; i <= len; i++) { + HSSFCell hssfcell = row.createCell(i); + hssfcell.setCellStyle(cellStyle); + } + } + + /** + * 设置表头样式 + * + * @param hssWB + * @return + */ + private HSSFCellStyle getHeadStyle(HSSFWorkbook hssWB, boolean isHead) { + HSSFCellStyle headStyle = hssWB.createCellStyle(); + //边框 + headStyle.setBorderLeft(BorderStyle.THIN); + headStyle.setBorderRight(BorderStyle.THIN); + headStyle.setBorderTop(BorderStyle.THIN); + headStyle.setBorderBottom(BorderStyle.THIN); + //居中: + headStyle.setAlignment(HorizontalAlignment.CENTER); + // 垂直居中 + headStyle.setVerticalAlignment(VerticalAlignment.CENTER); + //字体: + HSSFFont font = hssWB.createFont(); + font.setFontName("黑体"); + if (isHead) { + //设置字体大小 + font.setFontHeightInPoints((short) 12); + //背景颜色 + headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()); + } else { + //设置字体大小 + font.setFontHeightInPoints((short) 8); + //背景颜色 + headStyle.setFillPattern(FillPatternType.NO_FILL); + headStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); + } + //字体格式 + headStyle.setFont(font); + return headStyle; + } + + /** * 站点降雨量查询 * @param stationId @@ -333,7 +827,7 @@ public class ElectricReportServiceImpl implements IElectricReportService { // 查询月数据 List thirtys = thirtyService.list(Wrappers.lambdaQuery() //.isNotNull(ThirtyEntity::getDeviceCode) - .in(ThirtyEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) + .in(ThirtyEntity::getStationId,stations.getData().stream().filter(station->deptIds.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList())) .like(ThirtyEntity::getStrDay,time) ); if(CollectionUtil.isEmpty(thirtys)){ @@ -382,8 +876,9 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add(-1.0); item.add(-1.0); }); - calendar.add(Calendar.HOUR_OF_DAY,1); + calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); + tableDate.add(item); continue; } @@ -405,7 +900,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -415,7 +915,7 @@ public class ElectricReportServiceImpl implements IElectricReportService { // 查询月数据 List threes = threeService.list(Wrappers.lambdaQuery() //.isNotNull(ThreeEntity::getDeviceCode) - .in(ThreeEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList())) + .in(ThreeEntity::getStationId,stations.getData().stream().filter(station->deptIds.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList())) .like(ThreeEntity::getStrMonth,time) ); if(CollectionUtil.isEmpty(threes)){ @@ -456,6 +956,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String mon = DateUtil.format(start,"yyyy-MM"); item.add(start.getMonth() + 1 + "月"); + 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.MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + continue; + } // 总计:有功、无功 item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); @@ -474,7 +987,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -533,7 +1051,7 @@ public class ElectricReportServiceImpl implements IElectricReportService { if(CollectionUtil.isEmpty(childs)){ 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()); + List codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(codes)){ return; } @@ -564,8 +1082,9 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add(-1.0); item.add(-1.0); }); - calendar.add(Calendar.HOUR_OF_DAY,1); + calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); + tableDate.add(item); continue; } @@ -598,7 +1117,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -655,6 +1179,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String mon = DateUtil.format(start,"yyyy-MM"); item.add(start.getMonth() + 1 + "月"); + 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.MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + continue; + } + // 总计:有功、无功 item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); @@ -680,7 +1217,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -761,6 +1303,7 @@ public class ElectricReportServiceImpl implements IElectricReportService { }); calendar.add(Calendar.HOUR_OF_DAY,1); start = calendar.getTime(); + tableDate.add(item); continue; } // 总计:有功、无功 @@ -781,7 +1324,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -832,6 +1380,20 @@ 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.DAY_OF_MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + 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()); @@ -851,7 +1413,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -902,6 +1469,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { List item = new ArrayList<>(); String mon = DateUtil.format(start,"yyyy-MM"); item.add(start.getMonth() + 1 + "月"); + 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.MONTH,1); + start = calendar.getTime(); + tableDate.add(item); + continue; + } // 总计:有功、无功 item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); @@ -921,7 +1501,12 @@ public class ElectricReportServiceImpl implements IElectricReportService { item.add("合计"); for(int i = 1 ; i < tableDate.get(0).size() ; i++){ int index = i; - item.add(tableDate.stream().mapToDouble(o-> Double.parseDouble(o.get(index).toString())).sum()); + item.add(tableDate.stream().mapToDouble(o-> { + if(Double.parseDouble(o.get(index).toString()) >= 0){ + return Double.parseDouble(o.get(index).toString()); + } + return 0.0; + }).sum()); } tableDate.add(item); result.put("tableDate",tableDate); @@ -1014,25 +1599,65 @@ public class ElectricReportServiceImpl implements IElectricReportService { * @return */ @Override - public Map run(RunParamVo param) { + 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())){ + if(CollectionUtil.isEmpty(param.getSignages()) || StringUtils.isEmpty(param.getTime())){ return new HashMap<>(); } // 开始时间、结束时间 Date start = DateUtil.parse(param.getTime() + " 00:00:00",DateUtil.PATTERN_DATETIME); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(start); Date end = DateUtil.parse(param.getTime() + " 23:59:59",DateUtil.PATTERN_DATETIME); - - - return null; + HisFacSlicerDataDTO facSlicer = new HisFacSlicerDataDTO(); + List attrIds = param.getSignages().stream().map(RunParamSignageVo::getSignage).collect(Collectors.toList()); + facSlicer.setFacDeivceAttrIds(attrIds); + facSlicer.setAccessRules(0); + facSlicer.setSaveTimeType(2); + facSlicer.setBeginTime(LocalDateTime.ofInstant(start.toInstant(), ZoneId.systemDefault())); + facSlicer.setFinishTime(LocalDateTime.ofInstant(end.toInstant(), ZoneId.systemDefault())); + facSlicer.setTimeInterval(1); + facSlicer.setIsPage(false); + facSlicer.setIsFill(false); + facSlicer.setCurrent(1); + facSlicer.setPageSize(1000); + Result> result = deviceDataClient.facHisDataSearch(facSlicer); + if(!result.isSuccess()){ + return new HashMap<>(); + } + // 头部 + Map table = new HashMap<>(); + List tableHeads = new ArrayList<>(); + tableHeads.add("时间"); + param.getSignages().forEach(signage -> tableHeads.add(signage.getSignagesName())); + table.put("tableHead",tableHeads); + // 内容 + List tableDates = new ArrayList<>(); + while (start.compareTo(end) < 0){ + List items = new ArrayList<>(); + // 时间 + String time = DateUtil.format(start,DateUtil.PATTERN_DATETIME); + items.add(time); + // 数据遍历 + param.getSignages().forEach(signage -> { + if (MapUtils.isEmpty(result.getData()) || !result.getData().containsKey(signage.getSignage())) { + items.add("-"); + }else{ + List values = JSONObject.parseArray(JSONObject.toJSONString(result.getData().get(signage.getSignage())), RunResultValueVo.class); + if (CollectionUtil.isEmpty(values)) { + items.add("-"); + }else{ + items.add(String.valueOf(values.stream().filter(o -> StringUtils.isNotEmpty(o.getVal()) && o.getTs().contains(time)).mapToDouble(o -> Double.parseDouble(o.getVal())).sum())); + } + } + }); + // 填充一行内容 + tableDates.add(items); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + } + table.put("tableDate",tableDates); + return table; } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml index 33cd2e4..06fea4d 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml @@ -34,6 +34,7 @@ FROM HZIMS_ALARM_HANDLE HANDLER HANDLER.IS_DELETED = 0 + AND NOT HANDLER.ALARM_ID IS NULL AND HANDLER.CREATE_TIME BETWEEN #{start} AND #{end} 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 86cc042..7603c76 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 @@ -3,9 +3,8 @@ diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 11ac69c..54404a5 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -41,6 +41,9 @@ import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.message.fegin.IMessageClient; +import org.springblade.system.cache.DictCache; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -553,6 +556,17 @@ public class AlarmServiceImpl extends ServiceImpl impl */ @Override public IPage pageCondition(AlarmHistoryParamVo param, IPage page) { - return this.baseMapper.pageCondition(param,page); + IPage iPage = this.baseMapper.pageCondition(param,page); + if(CollectionUtil.isNotEmpty(iPage.getRecords())){ + iPage.setRecords(iPage.getRecords().stream().peek(record->{ + if(ObjectUtil.isNotEmpty(record.getHandleUser())){ + User user = UserCache.getUser(record.getHandleUser()); + if(ObjectUtil.isNotEmpty(user)){ + record.setHandleUserName(user.getRealName()); + } + } + }).collect(Collectors.toList())); + } + return iPage; } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java index 1fb0ed2..ca2bf04 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java @@ -80,7 +80,7 @@ public class GenerationScheduledTask { * @return */ //@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) - @Scheduled(cron = "0 0 1 * * ? ") + @Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadThreeYearPowerGeneration() { String param = ""; if (Func.isBlank(param)) { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java index 6c0a431..37deeb3 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java @@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Date; @@ -41,9 +42,10 @@ public class ShowScheduledTask { /** * 首页-区域班组数据 */ - @XxlJob(REGIONAL_DUTY_INFO) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadRegionalDuty(String param) { + // @XxlJob(REGIONAL_DUTY_INFO) + @Scheduled(cron = "0 0/5 * * * ? ") + public ReturnT loadRegionalDuty() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } 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 92e6d16..235d214 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 @@ -45,7 +45,7 @@ public class StartStopScheduledTask { * 设备开停机时间记录 */ //@XxlJob(START_STOP_TIME_RECORD) - @Scheduled(cron = "0 0/2 * * * ? ") + @Scheduled(cron = "0/40 * * * * ? ") public ReturnT startStopTimeRecord() { String param = ""; if (Func.isBlank(param)) { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 1ea944f..71337ab 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -200,6 +200,7 @@ public class AlarmServiceImpl implements AlarmService { public void interruption(String param) { // 查询接入站点 List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType,0) .eq(StationEntity::getDataOrigin,"0") ); if(CollectionUtil.isEmpty(stations)){ 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 acb00ff..d84636e 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 @@ -6,6 +6,7 @@ import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.equipment.entity.StartStopDurationEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.StartStopTimeVO; @@ -181,7 +182,7 @@ public class StartStopDurationServiceImpl extends ServiceImpl fields = dataService.getRealDataByAnalyzeCode(device.getEmCode(),Collections.singletonList(HomePageConstant.START_STOP_STATUS)); - if(CollectionUtil.isEmpty(fields) || fields.get(0).getQ() > -1){ + if(CollectionUtil.isEmpty(fields) || fields.get(0).getQ() != 0){ startStopTime.setQuality(-1); return startStopTime; } @@ -189,7 +190,7 @@ public class StartStopDurationServiceImpl extends ServiceImpl optional = startStopTimes.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).findFirst(); - if(optional.isPresent() && optional.get().getValue().equals(fields.get(0).getValue())){ + if(optional.isPresent() && StringUtils.isNotEmpty(optional.get().getValue()) && optional.get().getValue().equals(fields.get(0).getValue())){ startStopTime.setValue(optional.get().getValue()); startStopTime.setTime(optional.get().getTime()); startStopTime.setQuality(optional.get().getQuality()); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java index 211662c..a75dcaa 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/PhenomenonServiceImpl.java @@ -118,7 +118,7 @@ public class PhenomenonServiceImpl extends ServiceImpl shortagesList = defects.stream().filter(defect-> !ObjectUtil.isEmpty(defect.getHandleTaskId())).map(OperPhenomenonEntity::getId).collect(Collectors.toList()); + List shortagesList = defects.stream().filter(defect-> "流程结束".equals(defect.getCurrentOperator())).map(OperPhenomenonEntity::getId).collect(Collectors.toList()); if(CollectionUtil.isEmpty(shortagesList)){ shortagesVo.setShortages(0); } 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 9f70c71..0d65df5 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 @@ -107,7 +107,6 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { // 步骤1.水电、光伏站点 List stations = stationService.list(Wrappers.lambdaQuery(). in(StationEntity::getType, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC)) - .in(StationEntity::getCode, Arrays.asList("901800000612","901800000137")) ); // 步骤2.缓存设备信息 @@ -276,6 +275,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { generate.setStrMonth(strMonth); generate.setMonth(date.getMonth() + 1); generate.setGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP)); + generate.setReactiveGenerate(BigDecimal.valueOf(thirtyGenerationEntities.stream().mapToDouble(o -> o.getReactiveGenerate().doubleValue()).sum()).setScale(2, RoundingMode.HALF_UP)); return generate; }).collect(Collectors.toList())); } @@ -503,9 +503,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { }else{ generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP)); } - generation.setReactiveGenerate(BigDecimal.ZERO - - ); + generation.setReactiveGenerate(BigDecimal.ZERO); return generation; }).collect(Collectors.toList()); } 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 2347a51..bea786c 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 @@ -339,6 +339,7 @@ public class RealTargetServiceImpl implements RealTargetService { target.setStartupDurationYear(-1.0); target.setShutDownDurationYear(-1.0); } + targets.add(target); countDownLatch.countDown(); }catch (Exception exception){ countDownLatch.countDown(); @@ -1656,6 +1657,10 @@ public class RealTargetServiceImpl implements RealTargetService { target.setPowerDay(generateService.generate(day,station.getCode())); // 昨日发电量 target.setPowerYesterDay(0f); + // 开机时长 + target.setStartupDurationYear(-1.0); + // 关机时长 + target.setShutDownDurationYear(-1.0); // 30天发电量 target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode())); return target; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java index f71c869..f8b1d4e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java @@ -137,7 +137,7 @@ public class TargetController { public R> deviceClassify(Query query, @RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId, - @RequestParam(value="status")Integer status) { + @RequestParam(value="status",required = false)Integer status) { return R.data(service.deviceClassify(Condition.getPage(query),stationName,deptId,status)); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index b81905b..a431b00 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -1186,7 +1186,7 @@ public class TargetServiceImpl implements TargetService { le(OperPhenomenonEntity::getCreateTime,business.getEndTime()); } if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){ - isNotNull(OperPhenomenonEntity::getHandleTaskId); + eq(OperPhenomenonEntity::getCurrentOperator,"流程结束"); } if(!StringUtil.isBlank(business.getDeptIds())){ in(OperPhenomenonEntity::getCreateDept, Func.toLongList(",",business.getDeptIds())); 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 8af82a2..cea1f3e 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 @@ -159,11 +159,19 @@ public class HydroelectricServiceImpl implements HydroelectricService { if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){ device.setGenerates(target.get().getGenerationPowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDeviceGenerateVo.class)).collect(Collectors.toList())); } + }else{ + device.setPowerDay(0f); + device.setPowerYesterDay(0f); + device.setPowerYear(0f); + device.setPowerYesterYear(0f); + device.setPowerMon(0f); + device.setStartupDurationYear(-1.0); + device.setShutDownDurationYear(-1.0); } // 开停机数据 - Optional startStop = startStopTimes.stream().filter(o->iter.equals(o.getDeviceCode())).findFirst(); + Optional startStop = startStopTimes.stream().filter(o->iter.getEmCode().equals(o.getDeviceCode())).findFirst(); if(startStop.isPresent()){ - if(startStop.get().getQuality() > 0){ + 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"); @@ -171,7 +179,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { 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()); + device.setStartupDownDuration(BigDecimal.valueOf((System.currentTimeMillis() - time.getTime()) / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue()); }else{ device.setStartDownTime("-1"); device.setStartupDownDuration(-1.0); @@ -199,7 +207,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { }else{ result.setPowerMonPlan(0.0); } - result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum()); + result.setPowerMon(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); if(result.getPowerMonPlan() <= 0 || result.getPowerMon() <= 0){ result.setPowerRateMon(0.0); }else{ @@ -212,7 +220,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { }else{ result.setPowerYearPlan(0.0); } - result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum()); + result.setPowerYear(targets.stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerYear()) && o.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); if(result.getPowerYearPlan() <= 0 || result.getPowerYear() <= 0){ result.setPowerRateYear(0.0); }else{ @@ -220,11 +228,12 @@ public class HydroelectricServiceImpl implements HydroelectricService { } // 今日发电量、昨日发电量 - result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); - result.setPowerYesterDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum()); + result.setPowerDay(result.getDevices().stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerDay())).mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); + result.setPowerYesterDay(result.getDevices().stream().filter(o->ObjectUtil.isNotEmpty(o.getPowerYesterDay())).mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum()); } // 站点水位 result.setWater(this.water(waterLevels,station.getCode())); + // 近30日降雨量/发电量 //result.setPowerRains(this.stationPowerRains(result.getDevices(),rains)); // 近24小时总有功率/水位 @@ -361,6 +370,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { List refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); // 站点数量 group.setCount(stations.size()); + group.setGeneratePlanYear(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); // 实时数据 List reals = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY); if (CollectionUtil.isNotEmpty(reals)) { @@ -395,10 +405,6 @@ public class HydroelectricServiceImpl implements HydroelectricService { // 日发电量 group.setGenerateDay(stationTargets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); // 年计划发电量 - DevicePlanGenerationVo planParam = new DevicePlanGenerationVo(); - param.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - param.setDate(DateUtil.format(new Date(),"yyyy")); - group.setGeneratePlanYear(planClient.getPlanPowerYear(planParam)); if(group.getGeneratePlanYear() <= 0 || group.getGenerateYear() <= 0){ group.setGenerateRate(0.0); }else{