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 index 2ad20fe..7d0d9a2 100644 --- 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 @@ -10,4 +10,6 @@ public interface CensusConstant { String WATER_SIGNAGE = "front_water_level"; Integer QUERY_TYPE_DEFAULT = 0; + + Integer QUERY_TYPE_FA = 1; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerDeviceVo.java new file mode 100644 index 0000000..604bd60 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerDeviceVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "设备对象") +public class AppHydropowerDeviceVo { + + @ApiModelProperty(value = "设备编号") + private String deviceCode; + + @ApiModelProperty(value = "设备名称") + private String deviceName; + + @ApiModelProperty(value = "状态") + private Boolean state; + + @ApiModelProperty(value = "容量") + private Double capacity; + + @ApiModelProperty(value = "负荷") + private Double load; + + @ApiModelProperty(value = "负荷单位") + private String loadUnit; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java new file mode 100644 index 0000000..708c4a7 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.operational.main.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "水利站点首页对象") +public class AppHydropowerStationVo { + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "站点编码") + private String stationCode; + + @ApiModelProperty(value = "装机容量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacity; + + @ApiModelProperty(value = "总负荷") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; + + @ApiModelProperty(value = "负荷单位") + private String loadUnit; + + @ApiModelProperty(value = "出力") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double output; + + @ApiModelProperty(value = "运行天数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer runDay; + + @ApiModelProperty("站点告警列表") + private List alertList; + + @ApiModelProperty("站点告警列表") + private List devices; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationAreaVo.java similarity index 82% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaStationVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationAreaVo.java index 17d479c..98f0df8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationAreaVo.java @@ -10,7 +10,7 @@ import java.util.List; * @author ysj */ @Data -public class AppAreaStationVo { +public class AppStationAreaVo { @ApiModelProperty("归属机构") private Long deptId; @@ -19,5 +19,5 @@ public class AppAreaStationVo { private String deptName; @ApiModelProperty("站点列表集合") - private List list; + private List list; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppStationListVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationTargetVo.java similarity index 86% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppStationListVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationTargetVo.java index fcdd6d9..5ace44d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppStationListVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationTargetVo.java @@ -1,17 +1,14 @@ package com.hnac.hzims.operational.main.vo; -import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; - /** * APP-站点对象 * @author ysj */ @Data -public class AppStationListVo { +public class AppStationTargetVo { @ApiModelProperty("归属机构") private Long deptId; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/DeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/DeviceVo.java index 1c1faa3..471b7b2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/DeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/DeviceVo.java @@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +/** + * @author Lch + */ @Data @ApiModel(value = "设备对象") public class DeviceVo { diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerAreaVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerAreaVo.java new file mode 100644 index 0000000..515390f --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerAreaVo.java @@ -0,0 +1,92 @@ +package com.hnac.hzims.operational.main.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import com.hnac.hzims.hzimsweather.response.weather.Now; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "app水电站区域对象") +public class HydropowerAreaVo { + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "实时天气") + private Now now; + + @ApiModelProperty(value = "7天天气") + private List weather; + + @ApiModelProperty(value = "开始时间") + private String start; + + @ApiModelProperty(value = "结束时间") + private String end; + + @ApiModelProperty(value = "计划发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double plan; + + @ApiModelProperty(value = "实际发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double reality; + + @ApiModelProperty(value = "发电完成率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double rate; + + @ApiModelProperty(value = "日常维护总数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer maintain; + + @ApiModelProperty(value = "日常维护完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer maintainFinish; + + @ApiModelProperty(value = "缺陷总数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer defect; + + @ApiModelProperty(value = "缺陷完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer defectFinish; + + @ApiModelProperty(value = "检修总数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer overhaul; + + @ApiModelProperty(value = "检修完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer overhaulFinish; + + @ApiModelProperty(value = "操作票完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer operate; + + @ApiModelProperty(value = "操作票完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer operateFinish; + + @ApiModelProperty(value = "工作票完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer work; + + @ApiModelProperty(value = "工作票完成数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer workFinish; + + @ApiModelProperty(value = "站点设备情况") + private List stationTargets; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerGroupVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerGroupVo.java new file mode 100644 index 0000000..856e8e1 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerGroupVo.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "水电站集团对象") +public class HydropowerGroupVo { + + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java index 967b694..481100c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java @@ -25,15 +25,19 @@ public class TargetVo { private String typeName; @ApiModelProperty(value = "指标1") + @JsonSerialize(nullsUsing = NullSerializer.class) private Double taget_one; @ApiModelProperty(value = "指标2") + @JsonSerialize(nullsUsing = NullSerializer.class) private Double taget_two; @ApiModelProperty(value = "指标3") + @JsonSerialize(nullsUsing = NullSerializer.class) private Double taget_three; @ApiModelProperty(value = "指标4") + @JsonSerialize(nullsUsing = NullSerializer.class) private Double taget_four; @ApiModelProperty(value = "指标5:充电庄数量") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java index 95d5f9b..4468b3b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java @@ -54,7 +54,6 @@ public class StationEntity extends TenantEntity implements Serializable { @ApiModelProperty("上属机构") @QueryField(condition = SqlCondition.EQUAL) - @NotNull private Long higherDept; @ApiModelProperty("所属机构") diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java index 26f6060..ea2131c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java @@ -1,6 +1,5 @@ package com.hnac.hzinfo.inspect.task.service.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hnac.hzims.operational.defect.constants.DefectConstant; @@ -93,13 +92,13 @@ public class EventServiceImpl extends BaseServiceImpllambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId())); + TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.lambdaQuery() + .eq(TaskUserEntity::getTaskId,eventVO.getTaskId()) + .eq(TaskUserEntity::getUserId,eventVO.getUserId())); if(taskUserEntity==null){ throw new ServiceException("该任务已被别人领取"); } @@ -114,7 +113,7 @@ public class EventServiceImpl extends BaseServiceImpl examineCard(String stationName, Integer type) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); - wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getServeType,2); if(!StringUtils.isEmpty(stationName)){ wappers.like(StationEntity::getName,stationName); @@ -575,7 +575,7 @@ public class TargetServiceImpl implements TargetService { 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.setCardTotal(entry.getValue().stream().mapToDouble(over-> Double.parseDouble(over.getTotalPrice().toString())).sum()); examineCard.setCardCount(overDetails.stream().filter(detail-> entry.getValue().stream().map(OverEntity::getId).collect(Collectors.toList()).contains(detail.getOverId())).mapToInt(OverDetailsEntity::getQuantity).sum()); return examineCard; }).collect(Collectors.toList()); @@ -592,8 +592,8 @@ public class TargetServiceImpl implements TargetService { public List completeOther(String stationName, Integer type, Integer queryType) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); - wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); - wappers.eq(StationEntity::getServeType,2); + wappers.eq(StationEntity::getType, type); + wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); if(!StringUtils.isEmpty(stationName)){ wappers.like(StationEntity::getName,stationName); } @@ -615,9 +615,9 @@ public class TargetServiceImpl implements TargetService { 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{ + if(CensusConstant.QUERY_TYPE_DEFAULT.equals(queryType)){ + other.setOnlineRate(entry.getValue().stream().mapToDouble(value ->Double.parseDouble(value.getOnlineRate())).average().orElse(0.0)); + }else if(CensusConstant.QUERY_TYPE_FA.equals(queryType)){ other.setFaCount(entry.getValue().stream().mapToDouble(OtherEntity::getFaQuantity).sum()); } return other; @@ -633,8 +633,8 @@ public class TargetServiceImpl implements TargetService { private List getFillDefect(String areaName, Integer type) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); - wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); - wappers.eq(StationEntity::getServeType,2); + wappers.eq(StationEntity::getType, type); + wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); if(!StringUtils.isEmpty(areaName)){ wappers.like(StationEntity::getName,areaName); } @@ -796,7 +796,7 @@ public class TargetServiceImpl implements TargetService { hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); } return hydropower; - })/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList()); + })/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower).reversed()).collect(Collectors.toList()); } // 指标数据 List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); @@ -822,7 +822,7 @@ public class TargetServiceImpl implements TargetService { } } return hydropowerTarget; - })/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList()); + })/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric).reversed()).collect(Collectors.toList()); } /** @@ -861,7 +861,7 @@ public class TargetServiceImpl implements TargetService { Double use = pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum(); water.setLoad(Optional.ofNullable(use).orElse(0.0)); return water; - })/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); + })/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad).reversed()).collect(Collectors.toList()); } // 用电量 List targets = (List) redisTemplate.opsForValue().get(load_waterpump_target_key); @@ -886,14 +886,14 @@ public class TargetServiceImpl implements TargetService { water.setUse(0.0); } return water; - })/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList()); + })/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse).reversed()).collect(Collectors.toList()); } @Override public List photovoltaicTarget(String stationName, Long deptId, Integer target) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); - wappers.in(StationEntity::getType, HomePageConstant.waterList); + wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC); wappers.eq(StationEntity::getServeType,2); if(!StringUtils.isEmpty(stationName)){ wappers.like(StationEntity::getName,stationName); @@ -919,7 +919,7 @@ public class TargetServiceImpl implements TargetService { photovo.setLoad(reals.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); } return photovo; - })/*.filter(photovoltaic -> Math.abs(photovoltaic.getLoad()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getLoad)).collect(Collectors.toList()); + })/*.filter(photovoltaic -> Math.abs(photovoltaic.getLoad()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getLoad).reversed()).collect(Collectors.toList()); } // 发电量 List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); @@ -944,7 +944,7 @@ public class TargetServiceImpl implements TargetService { } } return photovo; - })/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate)).collect(Collectors.toList()); + })/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate).reversed()).collect(Collectors.toList()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml index ae1758f..12f2cc9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml @@ -293,7 +293,6 @@ JOIN hz_ims_duty_class DC ON DM.`CLASS_ID` = DC.`ID` WHERE DM.`STATUS` = '1' - AND DG.MANAGER_ID IS NOT NULL and DM.CREATE_DEPT = #{deptId} @@ -315,8 +314,7 @@ FROM hz_ims_duty_main DM JOIN hz_ims_duty_class DC ON DM.`CLASS_ID` = DC.`ID` - WHERE DG.MANAGER_ID IS NOT NULL - AND DM.PRE_DUTY_ID = #{preDutyId} + WHERE DM.PRE_DUTY_ID = #{preDutyId} order by DM.duty_date desc limit 1; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 1ddfc71..295ff91 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -1640,6 +1640,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); + last("limit 1"); }}); s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); } else { @@ -1664,6 +1665,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); + last("limit 1"); }}); dutyMainInfoVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); } else { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java index b9e16bf..fc614c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java @@ -2,9 +2,8 @@ package com.hnac.hzims.operational.main.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.main.service.IAppHomeService; -import com.hnac.hzims.operational.main.vo.AppAreaStationVo; -import com.hnac.hzims.operational.main.vo.AppDutyVo; -import com.hnac.hzims.operational.main.vo.AppStationListVo; +import com.hnac.hzims.operational.main.vo.AppStationAreaVo; +import com.hnac.hzims.operational.main.vo.AppAreaDutyVo; import com.hnac.hzims.operational.main.vo.AppStationVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -41,7 +40,7 @@ public class AppHomeController extends BladeController { @ApiOperation("app首页-站点列表数据") @GetMapping("/appStationList") @ApiOperationSupport(order = 11) - public R> appStationList(@ApiParam(value = "机构ID") Long deptId) { + public R> appStationList(@ApiParam(value = "机构ID") Long deptId) { return R.data(appService.appStationList(deptId)); } @@ -49,7 +48,7 @@ public class AppHomeController extends BladeController { @ApiOperation("app首页-当班数据") @GetMapping("/getDutyData") @ApiOperationSupport(order = 11) - public R> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) { + public R> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) { return R.data(appService.getDutyData(deptId)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java index 2ac6bb5..99eb136 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java @@ -22,7 +22,7 @@ import java.util.List; */ @RestController @RequestMapping("/home") -@Api(value = "app首页", tags = "app-首页") +@Api(value = "首页", tags = "首页") @AllArgsConstructor public class HomeController extends BladeController { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java index 930a7fa..0d0c46b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java @@ -2,10 +2,7 @@ package com.hnac.hzims.operational.main.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.main.service.HydropowerService; -import com.hnac.hzims.operational.main.vo.AreaScaleVo; -import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; -import com.hnac.hzims.operational.main.vo.HydropowerStationVo; -import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; +import com.hnac.hzims.operational.main.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -42,7 +39,7 @@ public class HydropowerController extends BladeController { @ApiLog @ApiOperation("水电站集团/区域占比") @GetMapping("/proportion") - @ApiOperationSupport(order = 1) + @ApiOperationSupport(order = 2) public R> proportion(@ApiParam(value = "站点机构ID") Long deptId) { return R.data(service.proportion(deptId)); } @@ -51,7 +48,7 @@ public class HydropowerController extends BladeController { @ApiLog @ApiOperation("水电站站点指标") @GetMapping("/station") - @ApiOperationSupport(order = 1) + @ApiOperationSupport(order = 3) public R hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) { return R.data(service.station(deptId)); } @@ -59,7 +56,7 @@ public class HydropowerController extends BladeController { @ApiLog @ApiOperation("水电站机组列表") @GetMapping("/getPumpList") - @ApiOperationSupport(order = 2) + @ApiOperationSupport(order = 4) public R> hydropowerDevice(@ApiParam(value = "站点机构ID") Long deptId) { return R.data(service.hydropowerDevice(deptId)); } @@ -67,9 +64,33 @@ public class HydropowerController extends BladeController { @ApiLog @ApiOperation("水电站站点列表") @GetMapping("/webStationList") - @ApiOperationSupport(order = 2) + @ApiOperationSupport(order = 5) public R> webStationList(@ApiParam(value = "站点机构ID") Long deptId) { return R.data(service.webStationList(deptId)); } + + @ApiLog + @ApiOperation("app水电站集团") + @GetMapping("/app/group") + @ApiOperationSupport(order = 6) + public R> group(@ApiParam(value = "站点机构ID") Long deptId) { + return R.data(service.group(deptId)); + } + + @ApiLog + @ApiOperation("app水电站集团") + @GetMapping("/app/area") + @ApiOperationSupport(order = 7) + public R> area(@ApiParam(value = "站点机构ID") Long deptId) { + return R.data(service.area(deptId)); + } + + @ApiLog + @ApiOperation("app水电站集团") + @GetMapping("/app/area-duty") + @ApiOperationSupport(order = 8) + public R areaDuty(@ApiParam(value = "站点机构ID") Long deptId) { + return R.data(service.areaDuty(deptId)); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java index c2d86aa..f1f4dc6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java @@ -1,9 +1,6 @@ package com.hnac.hzims.operational.main.service; -import com.hnac.hzims.operational.main.vo.AreaScaleVo; -import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; -import com.hnac.hzims.operational.main.vo.HydropowerStationVo; -import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; +import com.hnac.hzims.operational.main.vo.*; import java.util.List; @@ -28,4 +25,10 @@ public interface HydropowerService { HydropowerScoreVo KPIs(Long deptId); List proportion(Long deptId); + + List group(Long deptId); + + List area(Long deptId); + + AppAreaDutyVo areaDuty(Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java index 08af0d2..582bd96 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java @@ -1,8 +1,7 @@ package com.hnac.hzims.operational.main.service; -import com.hnac.hzims.operational.main.vo.AppAreaStationVo; -import com.hnac.hzims.operational.main.vo.AppDutyVo; -import com.hnac.hzims.operational.main.vo.AppStationListVo; +import com.hnac.hzims.operational.main.vo.AppStationAreaVo; +import com.hnac.hzims.operational.main.vo.AppAreaDutyVo; import com.hnac.hzims.operational.main.vo.AppStationVo; import java.util.List; @@ -25,11 +24,11 @@ public interface IAppHomeService { * @param deptId * @return */ - List appStationList(Long deptId); + List appStationList(Long deptId); /** * app首页-当班数据 * @return */ - List getDutyData(Long deptId); + List getDutyData(Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java index 20590c1..4aaf926 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java @@ -348,7 +348,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @return */ @Override - public List appStationList(Long deptId) { + public List appStationList(Long deptId) { // 获取区域或者站点map结构 Map> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); if(MapUtils.isEmpty(map)){ @@ -361,12 +361,12 @@ public class AppHomeServiceImpl implements IAppHomeService { // 获取设备实时数据 List realList = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_REAL_KEY); // 响应结果 - List result = new ArrayList<>(); + List result = new ArrayList<>(); map.forEach((key,value)->{ - AppAreaStationVo vo = new AppAreaStationVo(); - List children = new ArrayList<>(); + AppStationAreaVo vo = new AppStationAreaVo(); + List children = new ArrayList<>(); value.forEach(item->{ - AppStationListVo response = new AppStationListVo(); + AppStationTargetVo response = new AppStationTargetVo(); response.setDeptId(item.getRefDept()); response.setDeptName(item.getName()); // 站点年计划发电量 @@ -483,7 +483,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @return */ @Override - public List getDutyData(Long deptId) { + public List getDutyData(Long deptId) { // 获取当班列表数据 List list = this.dutyMainService.getDutyDataV2(deptId); if(CollectionUtil.isEmpty(list)){ @@ -491,7 +491,7 @@ public class AppHomeServiceImpl implements IAppHomeService { } // 响应数据 return list.stream().map(duty->{ - AppDutyVo item = new AppDutyVo(); + AppAreaDutyVo item = new AppAreaDutyVo(); // 班组基础数据设置 this.settingBase(duty,item); // 开始时间、结束时间 @@ -556,7 +556,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param duty * @param item */ - private void settingBase(DutyMainInfoVo duty, AppDutyVo item) { + private void settingBase(DutyMainInfoVo duty, AppAreaDutyVo item) { item.setShift(duty.getClassName()); item.setTeam(duty.getGroupName()); // 班组负责人 @@ -572,7 +572,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param item * @param id */ - private void getNextDuty(AppDutyVo item, Long id) { + private void getNextDuty(AppAreaDutyVo item, Long id) { DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id); if(ObjectUtil.isEmpty(nextDuty)){ return; @@ -593,7 +593,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param startDate * @param endDate */ - private void getInspectionTask(AppDutyVo item, String startDate, String endDate,List deptList) { + private void getInspectionTask(AppAreaDutyVo item, String startDate, String endDate, List deptList) { item.setInspectionTaskCount(0); item.setInspectionTaskFinishCount(0); item.setNotInspectionTaskCount(0); @@ -619,7 +619,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param end * @param deptList */ - private void getMaintenanceTask(AppDutyVo item, String start, String end, List deptList) { + private void getMaintenanceTask(AppAreaDutyVo item, String start, String end, List deptList) { item.setMaintenanceTaskCount(0); item.setMaintenanceTaskFinishCount(0); item.setNotMaintenanceTaskCount(0); @@ -645,7 +645,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param end * @param deptList */ - private void getOverhaulTask(AppDutyVo item, String start, String end,List deptList) { + private void getOverhaulTask(AppAreaDutyVo item, String start, String end, List deptList) { item.setOverhaulTaskCount(0); item.setNotOverhaulTaskCount(0); item.setOverhaulTaskFinishCount(0); @@ -670,7 +670,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param startTime * @param endTime */ - private void getDutyDefect(AppDutyVo item, LocalDateTime startTime, LocalDateTime endTime) { + private void getDutyDefect(AppAreaDutyVo item, LocalDateTime startTime, LocalDateTime endTime) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime); //wrapper.le(OperPhenomenonEntity::getCreateTime,endTime); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java index 3daa316..afadb2e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java @@ -436,11 +436,13 @@ public class HomeServiceImpl implements HomeService { countDownLatch.countDown(); return; } - target.setTaget_three(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum()); + // FA上线率 double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum(); if(Math.abs(online) > 0){ - target.setTaget_three(BigDecimal.valueOf(online / others.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + target.setTaget_three(BigDecimal.valueOf(online / others.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); } + // FA投入条数 + target.setTaget_four(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum()); countDownLatch.countDown(); }); // 等待所有线程执行完成 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index d7bb3b4..21f86fb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -2,7 +2,9 @@ package com.hnac.hzims.operational.main.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IPlanGenertionClient; @@ -10,17 +12,33 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; +import com.hnac.hzims.operational.access.constants.AccessConstants; +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.access.service.IOperAccessTaskService; +import com.hnac.hzims.operational.defect.constants.TreatMethodConstant; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; +import com.hnac.hzims.operational.duty.service.IImsDutyMainService; +import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; import com.hnac.hzims.operational.fill.service.GenerateService; import com.hnac.hzims.operational.fill.service.PowerService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; +import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; +import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; +import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.MapUtils; import org.springblade.core.tool.api.R; @@ -29,16 +47,21 @@ import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.entity.Dept; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -49,6 +72,8 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class HydropowerServiceImpl implements HydropowerService { + private final AreaService areaService; + private final IWeatherService weatherService; private final IStationService stationService; @@ -57,18 +82,30 @@ public class HydropowerServiceImpl implements HydropowerService { private final PowerService photovoltaicService; - private final AreaService areaService; + private final IImsDutyMainService dutyMainService; private final IAnalyseDataService analyseDataService; + private final IOperPhenomenonService phenomenonService; + + private final IOperAccessTaskService accessTaskService; + private final IStationAttributeService attributeService; private final IMainSystemMonitoringService maintenanceTaskService; + private final IMainTaskStatisticService mainTaskStatisticService; + + private final IOperMaintenanceTaskService operMaintenanceTaskService; + private final ISoeClient soeClient; + private final ITicketInfoClient ticketInfoClient; + private final IPlanGenertionClient planGenertionClient; + private final IInspectTaskReportClient inspectTaskReportClient; + private final RedisTemplate redisTemplate; @Value("${hzims.operation.realIdKey}") @@ -79,6 +116,8 @@ public class HydropowerServiceImpl implements HydropowerService { private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; + private final static int POOL_QUANTITY = 4; + /** * 加载水电站机组实时数据 @@ -1181,4 +1220,594 @@ public class HydropowerServiceImpl implements HydropowerService { return powerYearVo; }).collect(Collectors.toList()); } + + + /*=====================================================app=====================================================*/ + + /** + * app集团数据 + * @param deptId + * @return + */ + @Override + public List group(Long deptId) { + Map> areas = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + if(MapUtils.isEmpty(areas)) { + return new ArrayList<>(); + } + // 实时监测点数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 获取站点机组指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + // 获取站点编码集合 + List stations = areas.values().stream().map(values -> values.get(0).getCode()).collect(Collectors.toList()); + // 获取站点实时天气 + Map nowWeather = this.weatherService.getNowWeather(stations); + // 获取站点7日天气 + Map weekWeather = this.weatherService.getWeekWeather(stations); + List codes = new ArrayList<>(); + areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList()))); + // 计划发电量 + List plans = planGenertionClient.getPlanGenerationByParam(codes,null,String.valueOf(Calendar.getInstance().get(Calendar.YEAR))); + return areas.entrySet().stream().map(entry->{ + HydropowerAreaVo area = new HydropowerAreaVo(); + area.setDeptId(entry.getKey().getId()); + area.setDeptName(entry.getKey().getDeptName()); + // 天气 + this.appAreaWeather(area,nowWeather,weekWeather,entry.getValue().get(0).getCode()); + // 计划发电量 + double plan = this.appAreaPlan(entry.getValue(),plans); + area.setPlan(plan); + // 实际发电量 + area.setReality(this.appAreaReality(entry.getValue(),targets)); + // 发电完成率 + if(Math.abs(plan) > 0){ + area.setRate(BigDecimal.valueOf(area.getReality() / plan *100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + }else{ + area.setRate(0.0); + } + // 当月任务执行情况 + this.complteTask(area); + // 站点指标数据 + area.setStationTargets(this.stationTarget(entry.getValue(),reals,targets,plans)); + return area; + }).sorted(Comparator.comparing(HydropowerAreaVo::getReality)).collect(Collectors.toList()); + } + + /** + * 区域实时天气 + * @param area + * @param nowWeather + * @param code + */ + private void appAreaWeather(HydropowerAreaVo area, Map nowWeather,Map weekWeather, String code) { + // 实时天气 + if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){ + HeWeatherWeatherNowResponse nowData = nowWeather.get(code); + if(ObjectUtil.isNotEmpty(nowData.getNow())){ + area.setNow(nowData.getNow()); + } + } + // 站点七日内天气 + if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){ + HeWeatherWeatherDailyResponse weekData = weekWeather.get(code); + List dailyList = weekData.getDaily(); + if (CollectionUtil.isNotEmpty(dailyList)) { + area.setWeather(dailyList); + } + } + } + + /** + * 计划发电量 + * @param stations + * @param plans + * @return + */ + private Double appAreaPlan(List stations, List plans) { + if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(plans)){ + return 0.0; + } + return plans.stream().filter(plan->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + } + + /** + * 实际发电量 + * @param stations + * @param targets + * @return + */ + private Double appAreaReality(List stations, List targets) { + if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(targets)){ + return 0.0; + } + return targets.stream().filter(target->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + } + + /** + * 当月任务执行情况 + * @param area + */ + private void complteTask(HydropowerAreaVo area) { + String start = DateUtil.format(new Date(),"yyyy-mm") + "-01 00:00:00"; + area.setStart(start); + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + area.setEnd(end); + // 线程 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("app-area-taget-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); + // 日常维护 + exe.execute(()->{ + MaintainVo maintainVo = mainTaskStatisticService.getMaintain(start,end,Collections.singletonList(area.getDeptId())); + area.setMaintain(maintainVo.getMaintain()); + area.setMaintainFinish(maintainVo.getMaintainFinish()); + countDownLatch.countDown(); + }); + + // 消缺 + exe.execute(()->{ + ShortagesVo shortagesVo = mainTaskStatisticService.getShortage(start,end,Collections.singletonList(area.getDeptId())); + area.setDefect(shortagesVo.getShortagesSum()); + area.setDefectFinish(shortagesVo.getShortages()); + countDownLatch.countDown(); + }); + // 检修 + exe.execute(()->{ + OverhaulVo overhaulVo = mainTaskStatisticService.getOverhaul(start,end,Collections.singletonList(area.getDeptId())); + area.setOverhaul(overhaulVo.getOverhaul()); + area.setOverhaulFinish(overhaulVo.getOverhaulFinish()); + countDownLatch.countDown(); + }); + // 操作票&工作票 + exe.execute(()->{ + Map map = new HashMap<>(); + map.put("startDate",start); + map.put("endDate",end); + map.put("deptList",Collections.singletonList(area.getDeptId())); + R result = ticketInfoClient.getOperateWorkStatistic(map); + if (result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) { + // 操作票 + TicketMonthVO tiket = result.getData(); + area.setOperate(tiket.getOperate()); + area.setOperateFinish(tiket.getOperateQualify()); + // 工作票 + area.setWork(tiket.getWork()); + area.setWorkFinish(tiket.getWorkQualify()); + } + countDownLatch.countDown(); + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + } + + + /** + * 站点指标数据 + * @param stations + * @param reals + * @param targets + * @param plans + * @return + */ + private List stationTarget(List stations,List reals,List targets,List plans) { + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + return stations.stream().map(station->{ + AppStationTargetVo target = new AppStationTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 站点年计划发电量 + target.setPlanPowerYear(this.plan(plans,station.getCode())); + // 站点发电完成率 + double powerRate = this.getPowerRate(targets,station.getRefDept(),target.getPlanPowerYear()); + target.setPowerRate(powerRate); + // 设备总数 + int deviceSum = this.getDeviceSum(reals,station.getRefDept(),false); + target.setDeviceSum(deviceSum); + // 设备开机数 + int deviceRunSum = this.getDeviceSum(reals,station.getRefDept(),true); + target.setDeviceRunSum(deviceRunSum); + // 实时负荷 + float realPowerSum = this.getRealPowerSum(reals,station.getRefDept()); + target.setRealPowerSum(realPowerSum); + // 负荷单位 + String unit = this.getPowerUnit(reals,station.getRefDept()); + target.setRealPowerUnit(unit); + return target; + }).sorted(Comparator.comparing(AppStationTargetVo::getRealPowerSum).reversed()).collect(Collectors.toList()); + } + + /** + * 站点计划发电量 + * @param plans + * @param code + * @return + */ + private Float plan(List plans, String code) { + if(CollectionUtil.isEmpty(plans)){ + return 0f; + } + return (float) plans.stream().filter(o->code.equals(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + } + + /** + * 站点发电完成率 + * @param list + * @param createDept + * @return + */ + private double getPowerRate(List list, Long createDept ,float planPowerYear) { + if(CollectionUtil.isEmpty(list) || ObjectUtil.isEmpty(createDept)){ + return 0.0; + } + if(Math.abs(planPowerYear) <= 0){ + return 0.0; + } + double power = list.stream().filter(o->createDept.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + if(Math.abs(power) <= 0){ + return 0.0; + } + return BigDecimal.valueOf((float) power / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * 设备总数 + * @param list + * @param createDept + * @return + */ + private int getDeviceSum(List list, Long createDept,boolean isRun) { + if(CollectionUtil.isEmpty(list)){ + return 0; + } + if(isRun){ + return (int) list.stream().filter(o -> createDept.equals(o.getDeptId()) && o.getState()).count(); + } + return (int) list.stream().filter(o -> createDept.equals(o.getDeptId())).count(); + } + + /** + * 实时负荷 + * @param list + * @param createDept + * @return + */ + private float getRealPowerSum(List list, Long createDept) { + if(CollectionUtil.isEmpty(list)){ + return 0; + } + return (float) list.stream().filter(o->createDept.equals(o.getDeptId())).mapToDouble(o->Double.valueOf(o.getActivePower())).sum(); + } + + /** + * app区域数据 + * @param deptId + * @return + */ + @Override + public List area(Long deptId) { + // 查询水电站站点 + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { + return new ArrayList<>(); + } + // 实时监测点数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + return stations.stream().map(station -> { + AppHydropowerStationVo hydropower = new AppHydropowerStationVo(); + hydropower.setDeptId(station.getRefDept()); + hydropower.setDeptName(station.getName()); + // 装机容量 + hydropower.setCapacity(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + // 负荷 + hydropower.setLoad(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); + // 出力 + if(Math.abs(hydropower.getCapacity()) > 0){ + hydropower.setOutput(BigDecimal.valueOf(hydropower.getLoad() / hydropower.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + hydropower.setOutput(0.0); + } + // 运行天数 + hydropower.setRunDay(this.getRunDay(station)); + // 告警 + Result> result = soeClient.getByLastLimitTime(null, station.getCode(), 1); + if(result.isSuccess() || CollectionUtil.isNotEmpty(result.getData())){ + hydropower.setAlertList(result.getData()); + } + // 站点设备 + List devices = reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(devices)){ + // 设备 + hydropower.setDevices(devices.stream().map(real->{ + AppHydropowerDeviceVo device = new AppHydropowerDeviceVo(); + device.setDeviceCode(real.getDeviceCode()); + device.setDeviceName(real.getDeviceName()); + device.setState(real.getState()); + device.setLoadUnit(Optional.ofNullable(real.getPowerUnit()).orElse("kw")); + device.setCapacity(real.getInstalledCapacity()); + device.setLoad(real.getActivePower()); + return device; + }).collect(Collectors.toList())); + hydropower.setLoadUnit(hydropower.getDevices().get(0).getLoadUnit()); + } + return hydropower; + }).collect(Collectors.toList()); + } + + /** + * app区域值班数据 + * @param deptId + * @return + */ + @Override + public AppAreaDutyVo areaDuty(Long deptId) { + // 获取当班列表数据 + List dutys = this.dutyMainService.getDutyDataV2(deptId); + if(CollectionUtil.isEmpty(dutys)){ + return null; + } + DutyMainInfoVo duty = dutys.get(0); + // 响应数据 + AppAreaDutyVo item = new AppAreaDutyVo(); + // 班组基础数据设置 + this.settingBase(duty,item); + // 开始时间、结束时间 + LocalDateTime localDateTime = LocalDateTime.ofInstant(duty.getDutyDate().toInstant(), ZoneId.systemDefault()); + LocalDateTime startDate = localDateTime.withHour(duty.getStartTime().getHours()).withMinute(duty.getStartTime().getMinutes()).withSecond(00); + //LocalDateTime endDate = localDateTime.withHour(duty.getEndTime().getHours()).withMinute(duty.getEndTime().getMinutes()).withSecond(00); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); + String start = dtf.format(startDate); + String end = dtf.format(LocalDateTime.now()); + List deptList = Collections.singletonList(duty.getCreateDept()); + // 使用多线程处理数据 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty_data-pool-%d").build(); + ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); + // 下一班组 + pool.execute(()-> { + this.getNextDuty(item,duty.getId()); + countDownLatch.countDown(); + }); + // 缺陷 + pool.execute(()-> { + this.getDutyDefect(item,startDate,null); + countDownLatch.countDown(); + }); + // 巡检 + pool.execute(()-> { + this.getInspectionTask(item,start,end,deptList); + countDownLatch.countDown(); + }); + // 维护 + pool.execute(()-> { + this.getMaintenanceTask(item,start,end,deptList); + countDownLatch.countDown(); + }); + // 检修 + pool.execute(()-> { + this.getOverhaulTask(item,start,end,deptList); + countDownLatch.countDown(); + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + // 任务完成率 + int taskSum = item.getDefectSum() + item.getInspectionTaskCount() + item.getMaintenanceTaskCount() + item.getOverhaulTaskCount(); + int finishSum = item.getSolvedCount() + item.getInspectionTaskFinishCount() + item.getMaintenanceTaskFinishCount() + item.getOverhaulTaskFinishCount(); + if(Math.abs(taskSum) <= 0){ + item.setTaskRate(0.0); + }else{ + double taskRate = BigDecimal.valueOf((double)finishSum / (double)taskSum * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + item.setTaskRate(taskRate); + } + return item; + } + + /** + * 班组基础数据设置 + * @param duty + * @param item + */ + private void settingBase(DutyMainInfoVo duty, AppAreaDutyVo item) { + item.setShift(duty.getClassName()); + item.setTeam(Optional.ofNullable(duty.getGroupName()).orElse("灵活排班")); + // 班组负责人 + String managerName = this.getManagerName(duty.getManagerId()); + item.setTeamLeader(managerName); + // 班组成员 + String classMember = this.getClassMemberName(duty.getDutyPersonIds(),duty.getManagerId()); + item.setClassMember(classMember); + } + + /** + * 获取下一班组数据 + * @param item + * @param id + */ + private void getNextDuty(AppAreaDutyVo item, Long id) { + DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id); + if(ObjectUtil.isEmpty(nextDuty)){ + return; + } + item.setNextShift(nextDuty.getClassName()); + item.setNextTeam(nextDuty.getGroupName()); + // 下一班组负责人 + String managerName = this.getManagerName(nextDuty.getManagerId()); + item.setNextTeamLeader(managerName); + // 下一班组成员 + String classMember = this.getClassMemberName(nextDuty.getDutyPersonIds(),nextDuty.getManagerId()); + item.setNextClassMember(classMember); + } + + /** + * 获取巡检任务数量 + * @param item + * @param startDate + * @param endDate + */ + private void getInspectionTask(AppAreaDutyVo item, String startDate, String endDate, List deptList) { + item.setInspectionTaskCount(0); + item.setInspectionTaskFinishCount(0); + item.setNotInspectionTaskCount(0); + // 查询当班巡检任务 + Map params = new HashMap<>(); + params.put("startDate",startDate); + params.put("endDate",endDate); + params.put("deptList",deptList); + R response = inspectTaskReportClient.getDutyInspectTask(params); + if(!response.isSuccess() || ObjectUtil.isEmpty(response.getData())){ + return; + } + // 赋值 + item.setInspectionTaskCount(response.getData().getInspectTaskSum()); + item.setInspectionTaskFinishCount(response.getData().getInspectTaskFinish()); + item.setNotInspectionTaskCount(response.getData().getNotExecuteTaskCount()); + } + + /** + * 获取当班日常维护数据 + * @param item + * @param start + * @param end + * @param deptList + */ + private void getMaintenanceTask(AppAreaDutyVo item, String start, String end, List deptList) { + item.setMaintenanceTaskCount(0); + item.setMaintenanceTaskFinishCount(0); + item.setNotMaintenanceTaskCount(0); + // 查询当班日常维护任务 + List list = operMaintenanceTaskService.getMaintenanceTask(start, end, deptList); + if(CollectionUtil.isEmpty(list)){ + return; + } + // 总数 + item.setMaintenanceTaskCount(list.size()); + // 完成数 + int maintenanceTaskFinishCount = (int) list.stream().filter(o-> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).count(); + item.setMaintenanceTaskFinishCount(maintenanceTaskFinishCount); + // 未完成数 + int notMaintenanceTaskCount = list.size() - maintenanceTaskFinishCount; + item.setNotMaintenanceTaskCount(notMaintenanceTaskCount); + } + + /** + * 获取检修任务数量 + * @param item + * @param start + * @param end + * @param deptList + */ + private void getOverhaulTask(AppAreaDutyVo item, String start, String end, List deptList) { + item.setOverhaulTaskCount(0); + item.setNotOverhaulTaskCount(0); + item.setOverhaulTaskFinishCount(0); + // 查询当班检修任务 + List list = accessTaskService.getAccessTask(start, end, deptList); + if(CollectionUtil.isEmpty(list)){ + return; + } + // 总数 + item.setOverhaulTaskCount(list.size()); + // 完成数 + int overhaulTaskFinishCount = (int) list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_4 == o.getStatus()).count(); + item.setOverhaulTaskFinishCount(overhaulTaskFinishCount); + // 未开始数 + int notOverhaulTaskCount = (int) list.stream().filter(o-> AccessConstants.ACCESS_TASK_STATUS_0 == o.getStatus()).count(); + item.setNotOverhaulTaskCount(notOverhaulTaskCount); + } + + /** + * 获取当班缺陷数据 + * @param item + * @param startTime + * @param endTime + */ + private void getDutyDefect(AppAreaDutyVo item, LocalDateTime startTime, LocalDateTime endTime) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime); + //wrapper.le(OperPhenomenonEntity::getCreateTime,endTime); + wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT); + wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus,TreatMethodConstant.AUTO_SCREENED); + // 查询现象 + List list = phenomenonService.list(wrapper); + if(CollectionUtil.isEmpty(list)){ + item.setUnsolvedCount(0); + item.setSolvedCount(0); + item.setDefectSum(0); + item.setSeriousCount(0); + item.setDefectRate(0.0); + return; + } + // 缺陷总数 + int defectSum = list.size(); + item.setDefectSum(defectSum); + // 缺陷已解决数量 + int solvedCount = (int) list.stream().filter(o->TreatMethodConstant.CONCLUSION_COMPLETED.equals(o.getConclusionStatus())).count(); + item.setSolvedCount(solvedCount); + // 缺陷未解决数量 + int unsolvedCount = list.size() - solvedCount; + item.setUnsolvedCount(unsolvedCount); + // 缺陷严重数量 + int seriousCount = (int) list.stream().filter(o-> TreatMethodConstant.CLASS_I_DEFECT.toString().equals(o.getDefectLevel())).count(); + item.setSeriousCount(seriousCount); + // 消缺率 + double defectRate = BigDecimal.valueOf((double) solvedCount / (double)list.size() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); + item.setDefectRate(defectRate); + } + + /** + * 获取班组负责人 + * @param managerId + * @return + */ + private String getManagerName(String managerId) { + if(StringUtil.isBlank(managerId)){ + return ""; + } + User user = UserCache.getUser(Long.valueOf(managerId)); + if (ObjectUtil.isEmpty(user)) { + return ""; + } + return user.getName(); + } + + /** + * 获取班组成员 + * @param personIds + * @param managerId + * @return + */ + private String getClassMemberName(String personIds,String managerId) { + if(StringUtil.isBlank(personIds)){ + return ""; + } + StringBuilder builder = new StringBuilder(); + // 遍历成员 + for (String item : personIds.split("\\^")) { + if (item.equals(managerId)) { + continue; + } + User user = UserCache.getUser(Long.valueOf(item)); + if (ObjectUtil.isEmpty(user)) { + continue; + } + builder.append(user.getName()).append(","); + } + if(builder.length() <= 0){ + return ""; + } + return builder.substring(0,builder.toString().length() - 1); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppDutyVo.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaDutyVo.java similarity index 98% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppDutyVo.java rename to hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaDutyVo.java index 7c9f4bd..05edbf7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppDutyVo.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaDutyVo.java @@ -10,7 +10,7 @@ import lombok.Data; * @author ysj */ @Data -public class AppDutyVo { +public class AppAreaDutyVo { @ApiModelProperty("班次") private String shift;