From e20396e70a240eb8ccb0746672e896596bd92409 Mon Sep 17 00:00:00 2001 From: yang_shj Date: Mon, 6 Mar 2023 11:15:03 +0800 Subject: [PATCH] =?UTF-8?q?#=E7=94=B5=E7=AB=99=E5=88=A9=E7=94=A8=E7=8E=87?= =?UTF-8?q?=EF=BC=8C=E9=A6=96=E9=A1=B5=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../census/constants/CensusConstant.java | 13 + .../operational/census/vo/CompleteDefectVo.java | 25 + .../census/vo/CompleteGenerationVo.java | 25 + .../operational/census/vo/CompleteOtherVo.java | 22 + .../operational/census/vo/CompleteTicketVo.java | 25 + .../census/vo/ElectricGenerationVo.java | 22 + .../hzims/operational/census/vo/ExamineCardVo.java | 24 + .../operational/census/vo/InstalledCapacityVo.java | 22 + .../operational/census/vo/WaterFlowDataVo.java | 21 + .../operational/census/vo/WaterFlowResponseVo.java | 21 + .../hzims/operational/census/vo/WaterFlowVo.java | 31 ++ .../hnac/hzims/operational/main/vo/AreaDutyVo.java | 12 + .../main/vo/HydropowerUnitTargetVo.java | 3 + .../maintenance/dto/OperMaintenanceTaskDTO.java | 6 + .../ticket/allTicket/vo/DoublePassRateVO.java | 6 + .../access/dto/OperAccessStatisticsDTO.java | 5 + .../operational/access/dto/OperAccessTaskDTO.java | 3 + .../access/mapper/OperAccessTaskMapper.xml | 6 + .../census/controller/CensusController.java | 34 ++ .../census/controller/TargetController.java | 94 ++++ .../operational/census/service/CensusService.java | 18 + .../operational/census/service/TargetService.java | 49 ++ .../census/service/impl/CensusServiceImpl.java | 137 ++++++ .../census/service/impl/TargetServiceImpl.java | 519 +++++++++++++++++++++ .../main/service/impl/SideHustleServiceImpl.java | 16 +- .../main/service/impl/WebHomeServiceImpl.java | 1 + .../impl/OperMaintenanceTaskServiceImpl.java | 4 + .../service/impl/RealMonitorServiceImpl.java | 37 +- .../impl/StandardTicketInfoServiceImpl.java | 15 +- 29 files changed, 1197 insertions(+), 19 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/constants/CensusConstant.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteDefectVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteGenerationVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteOtherVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteTicketVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ElectricGenerationVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ExamineCardVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/InstalledCapacityVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowDataVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowResponseVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/CensusController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/CensusService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/CensusServiceImpl.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/constants/CensusConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/constants/CensusConstant.java new file mode 100644 index 0000000..2ad20fe --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/constants/CensusConstant.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.operational.census.constants; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +public interface CensusConstant { + + String WATER_SIGNAGE = "front_water_level"; + + Integer QUERY_TYPE_DEFAULT = 0; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteDefectVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteDefectVo.java new file mode 100644 index 0000000..68edd69 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteDefectVo.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class CompleteDefectVo { + + @ApiModelProperty("区域名称") + private String areaName; + + @ApiModelProperty("缺陷总数") + private Integer defectCount; + + @ApiModelProperty("消缺数") + private Integer completeCount; + + @ApiModelProperty("消缺率") + private Double completeRate; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteGenerationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteGenerationVo.java new file mode 100644 index 0000000..4136ab5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteGenerationVo.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class CompleteGenerationVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("计划发电量") + private Double planGeneration; + + @ApiModelProperty("实际发电量") + private Double realityGeneration; + + @ApiModelProperty("完成率") + private Double completeRate; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteOtherVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteOtherVo.java new file mode 100644 index 0000000..a063268 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteOtherVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class CompleteOtherVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("设备在线率") + private Double onlineRate; + + @ApiModelProperty("Fa投入条数") + private Double faCount; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteTicketVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteTicketVo.java new file mode 100644 index 0000000..4b699f5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/CompleteTicketVo.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class CompleteTicketVo { + + @ApiModelProperty("站点名称") + private String areaName; + + @ApiModelProperty("两票数量") + private Integer ticketCount; + + @ApiModelProperty("合格票据数量") + private Integer completeCount; + + @ApiModelProperty("合格率") + private String completeRate; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ElectricGenerationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ElectricGenerationVo.java new file mode 100644 index 0000000..0381de7 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ElectricGenerationVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class ElectricGenerationVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("发容量") + private Double electricGeneration; + + @ApiModelProperty("详情") + private String detail; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ExamineCardVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ExamineCardVo.java new file mode 100644 index 0000000..e88a627 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/ExamineCardVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class ExamineCardVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("检修卡数量") + private Integer cardCount; + + @ApiModelProperty("检修卡总额") + private Double cardTotal; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/InstalledCapacityVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/InstalledCapacityVo.java new file mode 100644 index 0000000..835ce30 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/InstalledCapacityVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class InstalledCapacityVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("装机容量") + private Double installedCapacity; + + @ApiModelProperty("详情") + private String detail; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowDataVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowDataVo.java new file mode 100644 index 0000000..4b09646 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowDataVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class WaterFlowDataVo { + + @ApiModelProperty("时间") + private String time; + + @ApiModelProperty("值") + private String value; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowResponseVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowResponseVo.java new file mode 100644 index 0000000..8ac6803 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowResponseVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class WaterFlowResponseVo { + + @ApiModelProperty("站点名称") + private String station; + + @ApiModelProperty("站点集合") + private List datas; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowVo.java new file mode 100644 index 0000000..e94b15b --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterFlowVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Data +public class WaterFlowVo { + + @ApiModelProperty("站点集合") + private List stations; + + @ApiModelProperty("监测类型:水位/流量") + private String type; + + @ApiModelProperty("时间跨域单位:2->h(小时)/3->d(天)/5->n(自然月)/6->y(自然年)") + private Integer timeType; + + @ApiModelProperty("开始时间") + private String startDate; + + @ApiModelProperty("结束时间") + private String endDate; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaDutyVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaDutyVo.java index 4a6cb0c..4ba3127 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaDutyVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaDutyVo.java @@ -160,4 +160,16 @@ public class AreaDutyVo { @ApiModelProperty(value = "排序字段") private Integer sort; + + @ApiModelProperty(value = "当班开始时间") + private String startTimeDuty; + + @ApiModelProperty(value = "当班结束时间") + private String endTimeDuty; + + @ApiModelProperty(value = "当月开始时间") + private String endTimeMoth; + + @ApiModelProperty(value = "当月结束时间") + private String startTimeMoth; } 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 90bff2c..3aa0339 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 @@ -20,6 +20,9 @@ public class HydropowerUnitTargetVo { @ApiModelProperty(value = "设备Code") private String deviceCode; + @ApiModelProperty(value = "设备名称") + private String deviceName; + @ApiModelProperty(value = "当年发电量") private Float powerYear; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java index 977e1db..379bd5d 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java @@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + /** * @author hx */ @@ -22,4 +24,8 @@ public class OperMaintenanceTaskDTO extends OperMaintenanceTaskEntity { @ApiModelProperty("任务Id 多个按逗号分隔") private String taskIds; + + @ApiModelProperty("任务Id 多个按逗号分隔") + private List deptIds; + } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/DoublePassRateVO.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/DoublePassRateVO.java index 2b1f6a1..cc993c5 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/DoublePassRateVO.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/DoublePassRateVO.java @@ -9,6 +9,12 @@ import lombok.EqualsAndHashCode; public class DoublePassRateVO { private static final long serialVersionUID = -8870464581684939369L; + @ApiModelProperty("双票数量") + private Integer doubleTicketCount; + + @ApiModelProperty("双票合格数量") + private Integer doubleTicketPassCount; + @ApiModelProperty("合格率") private String doublePassRate; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java index ecae157..8e0f492 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java @@ -5,6 +5,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity; +import java.util.List; + /** * 模型DTO * @@ -20,4 +22,7 @@ public class OperAccessStatisticsDTO extends OperAccessStatisticsEntity { @ApiModelProperty(value = "任务名称") private String taskName; + @ApiModelProperty(value = "创建机构集合") + private List deptIds; + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDTO.java index 735a954..4b648a4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessTaskDTO.java @@ -19,6 +19,9 @@ public class OperAccessTaskDTO extends OperAccessTaskEntity { private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "创建机构集合") + private List deptIds; + @ApiModelProperty(value = "工作流Key") private String procDefId; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml index 531ab75..4495409 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml @@ -77,6 +77,12 @@ and t1.`TICKET_ID` is null + + and t1.create_dept in + + #{item} + + ORDER BY t1.ID DESC diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/CensusController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/CensusController.java new file mode 100644 index 0000000..4d2a9c6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/CensusController.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.census.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.census.service.CensusService; +import com.hnac.hzims.operational.census.vo.WaterFlowVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/census") +@Api(value = "统计", tags = "数据统计") +public class CensusController { + + private final CensusService service; + + @ApiOperation("水位-流量统计") + @PostMapping("/water-flow") + @ApiOperationSupport(order = 1) + public R waterFlow(@RequestBody WaterFlowVo waterFlow) { + return R.data(service.waterFlow(waterFlow)); + } +} 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 new file mode 100644 index 0000000..68eede3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java @@ -0,0 +1,94 @@ +package com.hnac.hzims.operational.census.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.census.service.TargetService; +import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; +import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +/** + * @author ysj + * @date 2023/03/01 16:12:22 + * @version 4.0.0 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/target") +@Api(value = "指标关联数据", tags = "指标关联数据") +public class TargetController { + + private final TargetService service; + + @ApiOperation("装机容量统计") + @PostMapping("/installed-capacity") + @ApiOperationSupport(order = 1) + public R installedCapacity(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + return R.data(service.installedCapacity(stationName,type)); + } + + @ApiOperation("发电量统计") + @PostMapping("/electric-generation") + @ApiOperationSupport(order = 2) + public R electricGeneration() { + return R.data(service.electricGeneration()); + } + + @ApiOperation("计划发电量/实际发电量统计") + @PostMapping("/complete-generation") + @ApiOperationSupport(order = 3) + public R completeGeneration() { + return R.data(service.completeGeneration()); + } + + @ApiOperation("两票统计") + @PostMapping("/complete-ticket") + @ApiOperationSupport(order = 4) + public R completeTicket(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { + return R.data(service.completeTicket(areaName,type)); + } + + @ApiOperation("缺陷率统计") + @GetMapping("/complete-defect") + @ApiOperationSupport(order = 6) + public R completeDefect(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { + return R.data(service.defect(areaName,type)); + } + + @ApiOperation("上线率/Fa投入条数统计") + @GetMapping("/complete-other") + @ApiOperationSupport(order = 6) + public R completeOther(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type,@RequestParam(value = "queryType") Integer queryType) { + return R.data(service.completeOther(stationName,type,queryType)); + } + + @ApiOperation("日常维护统计") + @GetMapping("/routine-maintenance") + @ApiOperationSupport(order = 5) + public R> routineMaintenance(OperMaintenanceTaskDTO params,Query query,Integer type) { + return service.routineMaintenance(params,query,type); + } + + @ApiOperation("检修任务统计") + @GetMapping("/examine-repair") + @ApiOperationSupport(order = 6) + public R> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { + return service.examineRepair(params, query,type); + } + + @ApiOperation("检修卡统计") + @GetMapping("/examineCard") + @ApiOperationSupport(order = 6) + public R examineCard(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + return R.data(service.examineCard(stationName,type)); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/CensusService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/CensusService.java new file mode 100644 index 0000000..296119b --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/CensusService.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.operational.census.service; + +import com.hnac.hzims.operational.census.vo.WaterFlowResponseVo; +import com.hnac.hzims.operational.census.vo.WaterFlowVo; + +import java.util.List; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +public interface CensusService { + + + // 查询水位/流量数据 + List waterFlow(WaterFlowVo waterFlow); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java new file mode 100644 index 0000000..a497454 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java @@ -0,0 +1,49 @@ +package com.hnac.hzims.operational.census.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; +import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; +import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.census.vo.*; +import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; +import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; + +import java.util.List; + +/** + * @author ysj + * @date 2023/03/01 16:12:22 + * @version 4.0.0 + */ +public interface TargetService { + + // 获取站点装机容量 + List installedCapacity(String stationName,Integer type); + + // 发电量统计 + List electricGeneration(); + + // 计划发电量/实际发电量统计 + List completeGeneration(); + + // 两票统计 + List completeTicket(String areaName,Integer type); + + // 缺陷率统计 + List defect(String areaName, Integer type); + + // 检修卡统计 + List examineCard(String stationName, Integer type); + + // 设备在线率/Fa投入条数统计 + List completeOther(String stationName, Integer type,Integer queryType); + + // 日常维护统计 + R> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type); + + // 检修任务统计 + R> examineRepair(OperAccessTaskDTO params, Query query, Integer type); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/CensusServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/CensusServiceImpl.java new file mode 100644 index 0000000..670ce61 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/CensusServiceImpl.java @@ -0,0 +1,137 @@ +package com.hnac.hzims.operational.census.service.impl; + +import com.hnac.hzims.EquipmentConstants; +import com.hnac.hzims.operational.census.constants.CensusConstant; +import com.hnac.hzims.operational.census.service.CensusService; +import com.hnac.hzims.operational.census.vo.WaterFlowDataVo; +import com.hnac.hzims.operational.census.vo.WaterFlowResponseVo; +import com.hnac.hzims.operational.census.vo.WaterFlowVo; +import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; +import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; +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 lombok.RequiredArgsConstructor; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Service +@RequiredArgsConstructor +public class CensusServiceImpl implements CensusService { + + private final IAnalyseDataSearchClient dateSearch; + + private final IHzimsAnalyzeModelStationService analyzeStationService; + + /** + * 查询水位/流量统计数据 + * @param waterFlow + * @return + */ + @Override + public List waterFlow(WaterFlowVo waterFlow) { + // 查询参数设置 + List instances = this.getDefaultStations(waterFlow.getStations()); + if(CollectionUtils.isEmpty(instances)){ + return new ArrayList<>(); + } + + List params = instances.stream().map(instance->{ + AnalyseCodeByAnalyseDataPO analyseCodeByAnalyseData = new AnalyseCodeByAnalyseDataPO(); + analyseCodeByAnalyseData.setDeviceCode(instance); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataCondition = new AnalyzeDataConditionPO(); + analyzeDataCondition.setFull(1); + analyzeDataCondition.setSignages(Optional.ofNullable(waterFlow.getType()).orElse(CensusConstant.WATER_SIGNAGE)); + // 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值 + analyzeDataCondition.setAccessRules(EquipmentConstants.AccessRulesEnum.AVG_CYCLE.getType()); + // 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年) + analyzeDataCondition.setSaveTimeType(Optional.ofNullable(waterFlow.getTimeType()).orElse(3)); + // 间隔 + analyzeDataCondition.setTimeInterval(1); + analyzeDataCondition.setBeginTime(this.getSearchStartTime(waterFlow.getStartDate())); + analyzeDataCondition.setEndTime(this.getSearchEndTime(waterFlow.getEndDate())); + signboardConditions.add(analyzeDataCondition); + analyseCodeByAnalyseData.setSignboardConditions(signboardConditions); + return analyseCodeByAnalyseData; + }).collect(Collectors.toList()); + + // 查询数据 + return params.stream().map(o->{ + WaterFlowResponseVo waterFlowResponse = new WaterFlowResponseVo(); + waterFlowResponse.setStation(o.getDeviceCode()); + List data = dateSearch.getAnalyzeDataByAnalyzeCodeAndSignages(o).getData(); + if(CollectionUtils.isEmpty(data)){ + waterFlowResponse.setDatas(null); + }else{ + List datas = data.get(0).getList().stream().map(m->{ + WaterFlowDataVo waterFlowDataVo = new WaterFlowDataVo(); + waterFlowDataVo.setTime(m.getTs()); + waterFlowDataVo.setValue(m.getVal()); + return waterFlowDataVo; + }).collect(Collectors.toList()); + waterFlowResponse.setDatas(datas); + } + return waterFlowResponse; + }).collect(Collectors.toList()); + } + + + /** + * 查询默认水位/流量站点 + * @return + */ + private List getDefaultStations(List stations) { + if(CollectionUtils.isEmpty(stations)){ + List models = analyzeStationService.list(); + if(CollectionUtils.isEmpty(models)){ + return new ArrayList<>(); + } + return models.stream().map(HzimsAnalyzeModelStationEntity::getInstanceCode).collect(Collectors.toList()); + } + return stations; + } + + + /** + * 获取开始时间 + * @param date + * @return + */ + private LocalDateTime getSearchStartTime(String date) { + if(ObjectUtils.isEmpty(date)){ + Date startDate = new Date(); + startDate.setMonth(startDate.getMonth()-1); + date = DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss"); + } + return LocalDateTime.parse(DateUtil.format(new Date(), date), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); + } + + /** + * 获取结束时间 + * @param date + * @return + */ + private LocalDateTime getSearchEndTime(String date) { + if(ObjectUtils.isEmpty(date)){ + date = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } + return LocalDateTime.parse(DateUtil.format(new Date(), date), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); + } +} 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 new file mode 100644 index 0000000..6a56762 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -0,0 +1,519 @@ +package com.hnac.hzims.operational.census.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.equipment.feign.IPlanGenertionClient; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; +import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; +import com.hnac.hzims.operational.access.service.IOperAccessStatisticsService; +import com.hnac.hzims.operational.access.service.IOperAccessTaskService; +import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; +import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; +import com.hnac.hzims.operational.census.constants.CensusConstant; +import com.hnac.hzims.operational.census.service.TargetService; +import com.hnac.hzims.operational.census.vo.*; +import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; +import com.hnac.hzims.operational.fill.entity.*; +import com.hnac.hzims.operational.fill.service.*; +import com.hnac.hzims.operational.main.service.AreaService; +import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; +import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; +import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; +import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; +import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; +import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; +import com.hnac.hzims.operational.report.vo.DutyDefectVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.ticket.allTicket.fegin.ITicketInfoAllClient; +import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +import io.swagger.models.auth.In; +import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.MapUtils; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.entity.Dept; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Service +@RequiredArgsConstructor +public class TargetServiceImpl implements TargetService { + + private final IStationService stationService; + + private final IMainSystemMonitoringService maintenanceService; + + private final PowerService powerService; + + private final AreaService areaService; + + private final IOperMaintenanceTaskService maintenanceTaskService; + + private final IOperPhenomenonService phenomenonService; + + private final OverService overService; + + private final OverDetailsService overDetailsService; + + private final SolveService solveService; + + private final OtherService otherService; + + private final IOperAccessTaskService accessTaskService; + + private final IPlanGenertionClient planClient; + + private final ITicketInfoAllClient ticketInfoAllClient; + + private final RedisTemplate redisTemplate; + + private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); + + private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; + + /** + * 获取站点装机容量 + * @return + */ + @Override + public List installedCapacity(String stationName,Integer type) { + // 站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .eq(StationEntity::getServeType,2) + .like(StationEntity::getName,stationName) + ); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + if(HomePageConstant.HYDROPOWER.equals(type)){ + // 设备 + List devices = maintenanceService.getEmInfoList(); + return stations.stream().map(station->{ + InstalledCapacityVo item = new InstalledCapacityVo(); + item.setStationName(station.getName()); + List stationDevices = devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(stationDevices)){ + item.setInstalledCapacity(0.0); + item.setDetail("站点暂无设备!"); + return item; + } + // 装机容量 + double sum = stationDevices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); + item.setInstalledCapacity(sum); + // 装机容量详情 + List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); + item.setDetail(String.join("|",details)); + return item; + }).collect(Collectors.toList()); + } + // 查询填报数据 + String mon = DateUtil.format(new Date(),"yyyy"); + List powers = powerService.list(Wrappers.lambdaQuery() + .in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(PowerEntity::getMon, mon + "-01") + ); + return stations.stream().map(station -> { + InstalledCapacityVo item = new InstalledCapacityVo(); + item.setStationName(station.getName()); + // 装机容量 + List stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(stationPowers)){ + item.setInstalledCapacity(0.0); + }else{ + item.setInstalledCapacity(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getInstalledCapacity()); + } + item.setDetail("站点为填报数据,暂无设备装机容量信息!"); + return item; + }).collect(Collectors.toList()); + } + + /** + * 发电量 + * @return + */ + @Override + public List electricGeneration() { + // 站点 + List stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 设备指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if(CollectionUtils.isEmpty(targets)){ + return new ArrayList<>(); + } + return stations.stream().map(station->{ + ElectricGenerationVo item = new ElectricGenerationVo(); + item.setStationName(station.getName()); + List stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(stationTargets)){ + item.setElectricGeneration(0.0); + item.setDetail("站点暂无发电"); + return item; + } + // 年发电量 + double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + item.setElectricGeneration(sum); + // 装机容量详情 + List details = targets.stream().map(target-> "[" + target.getDeviceCode() + " " + target.getPowerYear() +"kw]").collect(Collectors.toList()); + item.setDetail(String.join("|",details)); + return item; + }).collect(Collectors.toList()); + } + + /** + * 电量完成率 + * @return + */ + @Override + public List completeGeneration() { + // 站点 + List stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 计划发电量 + List plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy")); + // 设备指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if(CollectionUtils.isEmpty(targets)){ + return new ArrayList<>(); + } + return stations.stream().map(station->{ + CompleteGenerationVo item = new CompleteGenerationVo(); + item.setStationName(station.getName()); + List stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); + // 实际发电量 + if(CollectionUtils.isEmpty(stationTargets)){ + item.setRealityGeneration(0.0); + }else { + double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + item.setRealityGeneration(sum); + } + // 计划发电量 + List planGenerations = plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).map(PlanGenerationEntity::getPlanGeneration).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(planGenerations)){ + item.setPlanGeneration(0.0); + }else{ + item.setPlanGeneration(BigDecimal.valueOf(planGenerations.get(0)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // 完成率 + if(Math.abs(item.getPlanGeneration()) <= 0){ + item.setCompleteRate(0.0); + }else{ + item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + return item; + }).collect(Collectors.toList()); + } + + /** + * 双票合格率 + * @return + */ + @Override + public List completeTicket(String areaName,Integer type) { + // 获取水电站区域机构 + Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE); + if(MapUtils.isEmpty(areas)){ + return new ArrayList<>(); + } + List depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(depts)){ + return new ArrayList<>(); + } + // 开始时间 + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + ExecutorService pool = Executors.newFixedThreadPool(depts.size()); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(depts.size()); + List completeTickets = new ArrayList<>(); + pool.execute(()-> { + for (Dept dept: depts) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(0); + completeTicketVo.setCompleteCount(0); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); + countDownLatch.countDown(); + } + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + pool.shutdown(); + return completeTickets; + } + + /** + * 缺陷统计 + * @param areaName + * @param type + * @return + */ + @Override + public List defect(String areaName, Integer type) { + if(HomePageConstant.DISTRIBUTION_NETWORK.equals(type)){ + return this.getFillDefect(areaName,type); + } + + // 获取区域机构 + Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); + if(MapUtils.isEmpty(areas)){ + return new ArrayList<>(); + } + List depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(depts)){ + return new ArrayList<>(); + } + String startTime = this.getFristDayByYear(); + String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + ExecutorService pool = Executors.newFixedThreadPool(depts.size()); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(depts.size()); + List completeDefects = new ArrayList<>(); + pool.execute(()-> { + for (Dept dept: depts) { + // 缺陷 + DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId())); + CompleteDefectVo defect = new CompleteDefectVo(); + defect.setDefectCount(defectVO.getDefectSum()); + defect.setCompleteCount(defectVO.getDefect()); + if (defect.getDefectCount() <= 0) { + defect.setCompleteRate(0.0); + } else { + defect.setCompleteRate(BigDecimal.valueOf(defect.getCompleteCount() / defect.getDefectCount() * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + completeDefects.add(defect); + countDownLatch.countDown(); + } + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + pool.shutdown(); + return completeDefects; + } + + + /** + * 检修卡统计 + * @param stationName + * @param type + * @return + */ + @Override + public List examineCard(String stationName, Integer type) { + // 站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .like(StationEntity::getName,stationName) + ); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 查询检修卡 + String startTime = this.getFristDayByYear(); + String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + List overs = overService.list(Wrappers.lambdaQuery() + .in(OverEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(OverEntity::getCreateTime,startTime) + .le(OverEntity::getCreateTime,endTime) + ); + if(CollectionUtils.isEmpty(overs)){ + return new ArrayList<>(); + } + List overDetails = overDetailsService.list(Wrappers.lambdaQuery() + .in(OverDetailsEntity::getOverId,overs.stream().map(OverEntity::getId).collect(Collectors.toList())) + ); + + return overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{ + ExamineCardVo examineCard = new ExamineCardVo(); + examineCard.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); + examineCard.setCardTotal(entry.getValue().stream().mapToDouble(over-> Double.valueOf(over.getTotalPrice().toString())).sum()); + examineCard.setCardCount(overDetails.stream().filter(detail-> detail.getOverId().equals(entry.getKey())).mapToInt(OverDetailsEntity::getQuantity).sum()); + return examineCard; + }).collect(Collectors.toList()); + } + + /** + * 配网设备在线率/Fa投入条数 + * @param stationName + * @param type + * @param queryType + * @return + */ + @Override + public List completeOther(String stationName, Integer type, Integer queryType) { + // 站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .like(StationEntity::getName,stationName) + ); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 查询设备在线率/Fa投入条数 + String startTime = this.getFristDayByYear(); + String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + List others = otherService.list(Wrappers.lambdaQuery() + .in(OtherEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(OtherEntity::getCreateTime,startTime) + .le(OtherEntity::getCreateTime,endTime) + ); + if(CollectionUtils.isEmpty(others)){ + return new ArrayList<>(); + } + return others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> { + CompleteOtherVo other = new CompleteOtherVo(); + other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); + if(CensusConstant.QUERY_TYPE_DEFAULT.equals(0)){ + other.setOnlineRate(entry.getValue().stream().mapToDouble(value ->Double.valueOf(value.getOnlineRate())).average().orElse(0.0)); + }else{ + other.setFaCount(entry.getValue().stream().mapToDouble(OtherEntity::getFaQuantity).sum()); + } + return other; + }).collect(Collectors.toList()); + } + + /** + * 配网消缺 + * @param areaName + * @param type + * @return + */ + private List getFillDefect(String areaName, Integer type) { + // 站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .eq(StationEntity::getServeType,2) + .like(StationEntity::getName,areaName) + ); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 缺陷填报记录 + String startTime = this.getFristDayByYear(); + String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + List solves = solveService.list(Wrappers.lambdaQuery() + .in(SolveEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(SolveEntity::getCreateTime,startTime) + .le(SolveEntity::getCreateTime,endTime) + ); + if(CollectionUtils.isEmpty(solves)){ + return new ArrayList<>(); + } + return solves.stream().collect(Collectors.groupingBy(SolveEntity::getCreateDept)).entrySet().stream().map(entry -> { + CompleteDefectVo defect = new CompleteDefectVo(); + defect.setAreaName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); + defect.setDefectCount(entry.getValue().stream().mapToInt(SolveEntity::getSolveQuantity).sum()); + defect.setCompleteCount(entry.getValue().stream().mapToInt(SolveEntity::getSolveSucQuantity).sum()); + if (Math.abs(defect.getDefectCount()) <= 0) { + defect.setCompleteRate(0.0); + } else { + defect.setCompleteRate(BigDecimal.valueOf(defect.getCompleteCount() / defect.getDefectCount() * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + return defect; + }).collect(Collectors.toList()); + + } + + /** + * 日常维护统计 + * @param param + * @param query + * @param type + * @return + */ + @Override + public R> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type) { + // 获取区域机构 + Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); + if(MapUtils.isEmpty(areas)){ + return null; + } + // 查询日常维护任务 + params.setDeptIds(areas.entrySet().stream().map(entry->entry.getKey().getId()).collect(Collectors.toList())); + return maintenanceTaskService.list(params,query); + } + + /** + * 检修任务统计 + * @param params + * @param query + * @param type + * @return + */ + @Override + public R> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { + // 获取区域机构 + Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); + if(MapUtils.isEmpty(areas)){ + return null; + } + // 查询检修任务 + params.setDeptIds(areas.keySet().stream().map(key-> key.getId()).collect(Collectors.toList())); + return accessTaskService.list(params,query); + } + + /** + * 获取当年的第一天 + * @return + */ + private String getFristDayByYear() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + return sdf.format(calendar.getTime()); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index 88c2afb..e009f87 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -184,6 +184,8 @@ public class SideHustleServiceImpl implements ISideHustleService { } Date startDate = this.getDutyStartTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime()); Date endDate = this.getDutyEndTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime(),dutyList.get(0).getEndTime()); + areaDutyVo.setStartTimeDuty(DateUtil.format(startDate,DateUtil.PATTERN_DATETIME)); + areaDutyVo.setEndTimeDuty(DateUtil.format(endDate,DateUtil.PATTERN_DATETIME)); // 上一班组发电量 this.getUpDutyPower(dutyList,deviceList,key.getId(),value,areaDutyVo); // 班组实时发电量 @@ -681,6 +683,8 @@ public class SideHustleServiceImpl implements ISideHustleService { LocalDate firstDay = LocalDate.now().withDayOfMonth(1); LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN); LocalDateTime endTime = LocalDateTime.now(); + areaDutyVo.setStartTimeMoth(dtf.format(startTime)); + areaDutyVo.setEndTimeMoth(dtf.format(endTime)); //通过线程池异步获取月报各模块内容 主要分为五块内容 ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY); //监控线程执行完后返回结果 @@ -867,7 +871,7 @@ public class SideHustleServiceImpl implements ISideHustleService { // 有功功率 Map activePowerMap = (Map) redisTemplate.opsForValue().get(active_power_key); // 设备开关机状态 - Map deviceStateMap = (Map) redisTemplate.opsForValue().get(joint_relay_key); + Map deviceStateMap = (Map) redisTemplate.opsForValue().get(joint_relay_key); // 获取总发电量 List monList = homePageService.getMonthList(0,12,false); float sumPower = this.getSumPower(map.values(),powerMap,monList); @@ -1089,21 +1093,21 @@ public class SideHustleServiceImpl implements ISideHustleService { * 电站利用率 * @return */ - private double getStationUseRate(List stationList,Map map) { + private double getStationUseRate(List stationList,Map map) { if(CollectionUtil.isEmpty(stationList) || MapUtils.isEmpty(map)){ return 0.0; } - List codeList = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(codeList)){ + List deptIds = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deptIds)){ return 0.0; } // 机组总数 - int unitSumCount = map.entrySet().stream().filter(o->codeList.contains(o.getKey())).mapToInt(vo-> vo.getValue().getUnitSum()).sum(); + int unitSumCount = map.entrySet().stream().filter(o -> deptIds.contains(o.getKey())).mapToInt(vo-> vo.getValue().getUnitSum()).sum(); if(Math.abs(unitSumCount) <= 0){ return 0.0; } // 机组开机总数 - int onOffCount = map.entrySet().stream().filter(o->codeList.contains(o.getKey())).mapToInt(vo-> vo.getValue().getStartingUpCount()).sum(); + int onOffCount = map.entrySet().stream().filter(o->deptIds.contains(o.getKey())).mapToInt(vo-> vo.getValue().getStartingUpCount()).sum(); return BigDecimal.valueOf(onOffCount / (double)unitSumCount * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java index d05fb8f..3b2cf84 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java @@ -158,6 +158,7 @@ public class WebHomeServiceImpl implements IWebHomeService { HydropowerUnitTargetVo targetVo = new HydropowerUnitTargetVo(); targetVo.setDeptId(device.getCreateDept()); targetVo.setDeviceCode(device.getEmCode()); + targetVo.setDeviceName(device.getName()); targetVo.setDeptName(device.getName()); // 当年用电量 float powerYear = this.getGenerationPower(device,0); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index 3227ecc..39900f5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -43,6 +43,7 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.text.DecimalFormat; import java.time.LocalDate; @@ -112,6 +113,9 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl realPowerMap = this.getPowerConversionMap(map); - if(CollectionUtil.isEmpty(realPowerMap)){ + if(MapUtils.isNotEmpty(realPowerMap)){ + redisTemplate.opsForValue().set(active_power_key, realPowerMap); + } + // 站点开关机状态 + List devices = systemMonitoringService.getEmInfoList(); + if(CollectionUtil.isEmpty(devices)){ return; } - redisTemplate.opsForValue().set(active_power_key, realPowerMap); + // key->机构编号 value -> 设备集合 + Map> deviceMap = devices.stream().collect(Collectors.groupingBy(EminfoAndEmParamVo::getCreateDept)); + Map data = new HashMap<>(); + deviceMap.entrySet().forEach(entry -> { + JointRelayVo value = new JointRelayVo(); + List relays = entry.getValue().stream().filter(o-> MapUtils.isNotEmpty(o.getPoint()) && !StringUtil.isEmpty(o.getPoint().get(HomePageConstant.JOINT_RELAY))).map(relay-> map.get(relay.getPoint().get(HomePageConstant.JOINT_RELAY))).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(relays)){ + value.setUnitSum(0); + value.setShutdownCount(0); + value.setStartingUpCount(0); + }else{ + value.setUnitSum(relays.size()); + Optional> off = Optional.ofNullable(relays.stream().filter(relay -> "0".equals(relay)).collect(Collectors.toList())); + value.setShutdownCount(off.map(o->o.size()).orElse(0)); + Optional> on = Optional.ofNullable(relays.stream().filter(relay -> "1".equals(relay)).collect(Collectors.toList())); + value.setStartingUpCount(on.map(o->o.size()).orElse(0)); + } + data.put(entry.getKey(),value); + }); + redisTemplate.opsForValue().set(joint_relay_key, data); + /*List jointRelayInfo = alertService.getJointRelayInfo(); - List jointRelayInfo = alertService.getJointRelayInfo(); - Map stationJointRelayMap = new HashMap<>(); //根据站点统计开关机 Map> jointRelayMap = jointRelayInfo.stream().collect(Collectors.groupingBy(AnalyzeCodeBySignagesVO::getStation)); jointRelayMap.forEach((key, value) -> { List readIdList = value.stream().map(AnalyzeCodeBySignagesVO::getRealId).collect(Collectors.toList()); - JointRelayVo vo = new JointRelayVo(); + vo = new JointRelayVo(); readIdList.forEach(iter -> { String jointRelay = map.get(iter); if ("0".equals(jointRelay)) {//关机 @@ -299,9 +322,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService { } }); stationJointRelayMap.put(key, vo); - }); - - redisTemplate.opsForValue().set(joint_relay_key, stationJointRelayMap); + });*/ } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index da77bd0..bc26baa 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -250,11 +250,11 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl depatList - * @param LocalDateTime firstDateTime - * @param LocalDateTime now - * @return DoublePassRateVO + * 获取双票合格率 + * @param depatList + * @param firstDateTime + * @param now + * @return */ @Override public DoublePassRateVO getDoublePassRate(List depatList, LocalDateTime firstDateTime, LocalDateTime now) { @@ -272,12 +272,15 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl standardIdList = new ArrayList<>(); standardIdList.addAll(standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList())); standardIdList.addAll(workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList())); + doublePassRateVO.setDoubleTicketCount(standardIdList.size()); // 查询合格评价 List evaluateList = ticketInfoEvaluateService.list(new LambdaQueryWrapper(){{ ge(TicketInfoEvaluateEntity::getCreateTime,firstDateTime); @@ -286,10 +289,12 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl