Browse Source

#app水电站集团/区域优化

zhongwei
yang_shj 2 years ago
parent
commit
cbcaf21b31
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/constants/CensusConstant.java
  2. 31
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerDeviceVo.java
  3. 54
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java
  4. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationAreaVo.java
  5. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppStationTargetVo.java
  6. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/DeviceVo.java
  7. 92
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerAreaVo.java
  8. 14
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerGroupVo.java
  9. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java
  10. 1
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java
  11. 9
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java
  12. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  13. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml
  14. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java
  15. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java
  16. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java
  17. 37
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java
  18. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java
  19. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAppHomeService.java
  20. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java
  21. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java
  22. 631
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  23. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaDutyVo.java

2
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"; String WATER_SIGNAGE = "front_water_level";
Integer QUERY_TYPE_DEFAULT = 0; Integer QUERY_TYPE_DEFAULT = 0;
Integer QUERY_TYPE_FA = 1;
} }

31
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;
}

54
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<SoeData> alertList;
@ApiModelProperty("站点告警列表")
private List<AppHydropowerDeviceVo> devices;
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaStationVo.java → 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 * @author ysj
*/ */
@Data @Data
public class AppAreaStationVo { public class AppStationAreaVo {
@ApiModelProperty("归属机构") @ApiModelProperty("归属机构")
private Long deptId; private Long deptId;
@ -19,5 +19,5 @@ public class AppAreaStationVo {
private String deptName; private String deptName;
@ApiModelProperty("站点列表集合") @ApiModelProperty("站点列表集合")
private List<AppStationListVo> list; private List<AppStationTargetVo> list;
} }

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppStationListVo.java → 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; package com.hnac.hzims.operational.main.vo;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* APP-站点对象 * APP-站点对象
* @author ysj * @author ysj
*/ */
@Data @Data
public class AppStationListVo { public class AppStationTargetVo {
@ApiModelProperty("归属机构") @ApiModelProperty("归属机构")
private Long deptId; private Long deptId;

3
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 io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/**
* @author Lch
*/
@Data @Data
@ApiModel(value = "设备对象") @ApiModel(value = "设备对象")
public class DeviceVo { public class DeviceVo {

92
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<Daily> 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<AppStationTargetVo> stationTargets;
}

14
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 {
}

4
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; private String typeName;
@ApiModelProperty(value = "指标1") @ApiModelProperty(value = "指标1")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double taget_one; private Double taget_one;
@ApiModelProperty(value = "指标2") @ApiModelProperty(value = "指标2")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double taget_two; private Double taget_two;
@ApiModelProperty(value = "指标3") @ApiModelProperty(value = "指标3")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double taget_three; private Double taget_three;
@ApiModelProperty(value = "指标4") @ApiModelProperty(value = "指标4")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double taget_four; private Double taget_four;
@ApiModelProperty(value = "指标5:充电庄数量") @ApiModelProperty(value = "指标5:充电庄数量")

1
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("上属机构") @ApiModelProperty("上属机构")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
@NotNull
private Long higherDept; private Long higherDept;
@ApiModelProperty("所属机构") @ApiModelProperty("所属机构")

9
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; package com.hnac.hzinfo.inspect.task.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.operational.defect.constants.DefectConstant; import com.hnac.hzims.operational.defect.constants.DefectConstant;
@ -93,13 +92,13 @@ public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEnti
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean addTaskEvent(EventAddVO eventVO){ public boolean addTaskEvent(EventAddVO eventVO){
BladeUser user = AuthUtil.getUser();
//第一次登记时,需领用任务 //第一次登记时,需领用任务
if(!AuthUtil.isAdministrator()){ if(!AuthUtil.isAdministrator()){
ITaskService taskService = SpringUtil.getBean(ITaskService.class); ITaskService taskService = SpringUtil.getBean(ITaskService.class);
TaskEntity taskEntity = taskService.getById(eventVO.getTaskId()); TaskEntity taskEntity = taskService.getById(eventVO.getTaskId());
TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId())); TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery()
.eq(TaskUserEntity::getTaskId,eventVO.getTaskId())
.eq(TaskUserEntity::getUserId,eventVO.getUserId()));
if(taskUserEntity==null){ if(taskUserEntity==null){
throw new ServiceException("该任务已被别人领取"); throw new ServiceException("该任务已被别人领取");
} }
@ -114,7 +113,7 @@ public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEnti
} }
EventEntity event = BeanUtil.copy(eventVO, EventEntity.class); EventEntity event = BeanUtil.copy(eventVO, EventEntity.class);
event.setUserId(user == null ? eventVO.getUserId() : user.getUserId()); event.setUserId(eventVO.getUserId());
// if(Func.isEmpty(user)){ // if(Func.isEmpty(user)){
// event.setTenantId("000000"); // event.setTenantId("000000");
// } // }

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

@ -548,7 +548,7 @@ public class TargetServiceImpl implements TargetService {
public List<ExamineCardVo> examineCard(String stationName, Integer type) { public List<ExamineCardVo> examineCard(String stationName, Integer type) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,2); wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){ if(!StringUtils.isEmpty(stationName)){
wappers.like(StationEntity::getName,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->{ return overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{
ExamineCardVo examineCard = new ExamineCardVo(); ExamineCardVo examineCard = new ExamineCardVo();
examineCard.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); 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()); examineCard.setCardCount(overDetails.stream().filter(detail-> entry.getValue().stream().map(OverEntity::getId).collect(Collectors.toList()).contains(detail.getOverId())).mapToInt(OverDetailsEntity::getQuantity).sum());
return examineCard; return examineCard;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -592,8 +592,8 @@ public class TargetServiceImpl implements TargetService {
public List<CompleteOtherVo> completeOther(String stationName, Integer type, Integer queryType) { public List<CompleteOtherVo> completeOther(String stationName, Integer type, Integer queryType) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,2); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtils.isEmpty(stationName)){ if(!StringUtils.isEmpty(stationName)){
wappers.like(StationEntity::getName,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 -> { return others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> {
CompleteOtherVo other = new CompleteOtherVo(); CompleteOtherVo other = new CompleteOtherVo();
other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName());
if(CensusConstant.QUERY_TYPE_DEFAULT.equals(0)){ if(CensusConstant.QUERY_TYPE_DEFAULT.equals(queryType)){
other.setOnlineRate(entry.getValue().stream().mapToDouble(value ->Double.valueOf(value.getOnlineRate())).average().orElse(0.0)); other.setOnlineRate(entry.getValue().stream().mapToDouble(value ->Double.parseDouble(value.getOnlineRate())).average().orElse(0.0));
}else{ }else if(CensusConstant.QUERY_TYPE_FA.equals(queryType)){
other.setFaCount(entry.getValue().stream().mapToDouble(OtherEntity::getFaQuantity).sum()); other.setFaCount(entry.getValue().stream().mapToDouble(OtherEntity::getFaQuantity).sum());
} }
return other; return other;
@ -633,8 +633,8 @@ public class TargetServiceImpl implements TargetService {
private List<CompleteDefectVo> getFillDefect(String areaName, Integer type) { private List<CompleteDefectVo> getFillDefect(String areaName, Integer type) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,2); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtils.isEmpty(areaName)){ if(!StringUtils.isEmpty(areaName)){
wappers.like(StationEntity::getName,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()); hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum());
} }
return hydropower; 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<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
@ -822,7 +822,7 @@ public class TargetServiceImpl implements TargetService {
} }
} }
return hydropowerTarget; 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(); Double use = pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum();
water.setLoad(Optional.ofNullable(use).orElse(0.0)); water.setLoad(Optional.ofNullable(use).orElse(0.0));
return water; 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<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key); List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key);
@ -886,14 +886,14 @@ public class TargetServiceImpl implements TargetService {
water.setUse(0.0); water.setUse(0.0);
} }
return water; 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 @Override
public List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target) { public List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.in(StationEntity::getType, HomePageConstant.waterList); wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC);
wappers.eq(StationEntity::getServeType,2); wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){ if(!StringUtils.isEmpty(stationName)){
wappers.like(StationEntity::getName,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()); photovo.setLoad(reals.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
} }
return photovo; 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<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
@ -944,7 +944,7 @@ public class TargetServiceImpl implements TargetService {
} }
} }
return photovo; 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());
} }
/** /**

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml

@ -293,7 +293,6 @@
JOIN hz_ims_duty_class DC JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID` ON DM.`CLASS_ID` = DC.`ID`
WHERE DM.`STATUS` = '1' WHERE DM.`STATUS` = '1'
AND DG.MANAGER_ID IS NOT NULL
<if test="deptId != null"> <if test="deptId != null">
and DM.CREATE_DEPT = #{deptId} and DM.CREATE_DEPT = #{deptId}
</if> </if>
@ -315,8 +314,7 @@
FROM hz_ims_duty_main DM FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID` ON DM.`CLASS_ID` = DC.`ID`
WHERE DG.MANAGER_ID IS NOT NULL WHERE DM.PRE_DUTY_ID = #{preDutyId}
AND DM.PRE_DUTY_ID = #{preDutyId}
order by DM.duty_date desc order by DM.duty_date desc
limit 1; limit 1;
</select> </select>

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

@ -1640,6 +1640,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (null == s.getDutyGroupId()) { if (null == s.getDutyGroupId()) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId());
last("limit 1");
}}); }});
s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString());
} else { } else {
@ -1664,6 +1665,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (null == dutyMainInfoVo.getDutyGroupId()) { if (null == dutyMainInfoVo.getDutyGroupId()) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId());
last("limit 1");
}}); }});
dutyMainInfoVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); dutyMainInfoVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString());
} else { } else {

9
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.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.IAppHomeService; import com.hnac.hzims.operational.main.service.IAppHomeService;
import com.hnac.hzims.operational.main.vo.AppAreaStationVo; import com.hnac.hzims.operational.main.vo.AppStationAreaVo;
import com.hnac.hzims.operational.main.vo.AppDutyVo; import com.hnac.hzims.operational.main.vo.AppAreaDutyVo;
import com.hnac.hzims.operational.main.vo.AppStationListVo;
import com.hnac.hzims.operational.main.vo.AppStationVo; import com.hnac.hzims.operational.main.vo.AppStationVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -41,7 +40,7 @@ public class AppHomeController extends BladeController {
@ApiOperation("app首页-站点列表数据") @ApiOperation("app首页-站点列表数据")
@GetMapping("/appStationList") @GetMapping("/appStationList")
@ApiOperationSupport(order = 11) @ApiOperationSupport(order = 11)
public R<List<AppAreaStationVo>> appStationList(@ApiParam(value = "机构ID") Long deptId) { public R<List<AppStationAreaVo>> appStationList(@ApiParam(value = "机构ID") Long deptId) {
return R.data(appService.appStationList(deptId)); return R.data(appService.appStationList(deptId));
} }
@ -49,7 +48,7 @@ public class AppHomeController extends BladeController {
@ApiOperation("app首页-当班数据") @ApiOperation("app首页-当班数据")
@GetMapping("/getDutyData") @GetMapping("/getDutyData")
@ApiOperationSupport(order = 11) @ApiOperationSupport(order = 11)
public R<List<AppDutyVo>> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) { public R<List<AppAreaDutyVo>> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(appService.getDutyData(deptId)); return R.data(appService.getDutyData(deptId));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java

@ -22,7 +22,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/home") @RequestMapping("/home")
@Api(value = "app首页", tags = "app-首页") @Api(value = "首页", tags = "首页")
@AllArgsConstructor @AllArgsConstructor
public class HomeController extends BladeController { public class HomeController extends BladeController {

37
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.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.HydropowerService; import com.hnac.hzims.operational.main.service.HydropowerService;
import com.hnac.hzims.operational.main.vo.AreaScaleVo; import com.hnac.hzims.operational.main.vo.*;
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 io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -42,7 +39,7 @@ public class HydropowerController extends BladeController {
@ApiLog @ApiLog
@ApiOperation("水电站集团/区域占比") @ApiOperation("水电站集团/区域占比")
@GetMapping("/proportion") @GetMapping("/proportion")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 2)
public R<List<AreaScaleVo>> proportion(@ApiParam(value = "站点机构ID") Long deptId) { public R<List<AreaScaleVo>> proportion(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.proportion(deptId)); return R.data(service.proportion(deptId));
} }
@ -51,7 +48,7 @@ public class HydropowerController extends BladeController {
@ApiLog @ApiLog
@ApiOperation("水电站站点指标") @ApiOperation("水电站站点指标")
@GetMapping("/station") @GetMapping("/station")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 3)
public R<HydropowerStationVo> hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) { public R<HydropowerStationVo> hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.station(deptId)); return R.data(service.station(deptId));
} }
@ -59,7 +56,7 @@ public class HydropowerController extends BladeController {
@ApiLog @ApiLog
@ApiOperation("水电站机组列表") @ApiOperation("水电站机组列表")
@GetMapping("/getPumpList") @GetMapping("/getPumpList")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 4)
public R<List<HydropowerUnitVo>> hydropowerDevice(@ApiParam(value = "站点机构ID") Long deptId) { public R<List<HydropowerUnitVo>> hydropowerDevice(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.hydropowerDevice(deptId)); return R.data(service.hydropowerDevice(deptId));
} }
@ -67,9 +64,33 @@ public class HydropowerController extends BladeController {
@ApiLog @ApiLog
@ApiOperation("水电站站点列表") @ApiOperation("水电站站点列表")
@GetMapping("/webStationList") @GetMapping("/webStationList")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 5)
public R<List<HydropowerStationVo>> webStationList(@ApiParam(value = "站点机构ID") Long deptId) { public R<List<HydropowerStationVo>> webStationList(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.webStationList(deptId)); return R.data(service.webStationList(deptId));
} }
@ApiLog
@ApiOperation("app水电站集团")
@GetMapping("/app/group")
@ApiOperationSupport(order = 6)
public R<List<HydropowerAreaVo>> group(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.group(deptId));
}
@ApiLog
@ApiOperation("app水电站集团")
@GetMapping("/app/area")
@ApiOperationSupport(order = 7)
public R<List<AppHydropowerStationVo>> area(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.area(deptId));
}
@ApiLog
@ApiOperation("app水电站集团")
@GetMapping("/app/area-duty")
@ApiOperationSupport(order = 8)
public R<AppAreaDutyVo> areaDuty(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.areaDuty(deptId));
}
} }

11
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; package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.AreaScaleVo; import com.hnac.hzims.operational.main.vo.*;
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 java.util.List; import java.util.List;
@ -28,4 +25,10 @@ public interface HydropowerService {
HydropowerScoreVo KPIs(Long deptId); HydropowerScoreVo KPIs(Long deptId);
List<AreaScaleVo> proportion(Long deptId); List<AreaScaleVo> proportion(Long deptId);
List<HydropowerAreaVo> group(Long deptId);
List<AppHydropowerStationVo> area(Long deptId);
AppAreaDutyVo areaDuty(Long deptId);
} }

9
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; package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.AppAreaStationVo; import com.hnac.hzims.operational.main.vo.AppStationAreaVo;
import com.hnac.hzims.operational.main.vo.AppDutyVo; import com.hnac.hzims.operational.main.vo.AppAreaDutyVo;
import com.hnac.hzims.operational.main.vo.AppStationListVo;
import com.hnac.hzims.operational.main.vo.AppStationVo; import com.hnac.hzims.operational.main.vo.AppStationVo;
import java.util.List; import java.util.List;
@ -25,11 +24,11 @@ public interface IAppHomeService {
* @param deptId * @param deptId
* @return * @return
*/ */
List<AppAreaStationVo> appStationList(Long deptId); List<AppStationAreaVo> appStationList(Long deptId);
/** /**
* app首页-当班数据 * app首页-当班数据
* @return * @return
*/ */
List<AppDutyVo> getDutyData(Long deptId); List<AppAreaDutyVo> getDutyData(Long deptId);
} }

26
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 * @return
*/ */
@Override @Override
public List<AppAreaStationVo> appStationList(Long deptId) { public List<AppStationAreaVo> appStationList(Long deptId) {
// 获取区域或者站点map结构 // 获取区域或者站点map结构
Map<Dept,List<StationEntity>> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); Map<Dept,List<StationEntity>> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if(MapUtils.isEmpty(map)){ if(MapUtils.isEmpty(map)){
@ -361,12 +361,12 @@ public class AppHomeServiceImpl implements IAppHomeService {
// 获取设备实时数据 // 获取设备实时数据
List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_REAL_KEY); List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_REAL_KEY);
// 响应结果 // 响应结果
List<AppAreaStationVo> result = new ArrayList<>(); List<AppStationAreaVo> result = new ArrayList<>();
map.forEach((key,value)->{ map.forEach((key,value)->{
AppAreaStationVo vo = new AppAreaStationVo(); AppStationAreaVo vo = new AppStationAreaVo();
List<AppStationListVo> children = new ArrayList<>(); List<AppStationTargetVo> children = new ArrayList<>();
value.forEach(item->{ value.forEach(item->{
AppStationListVo response = new AppStationListVo(); AppStationTargetVo response = new AppStationTargetVo();
response.setDeptId(item.getRefDept()); response.setDeptId(item.getRefDept());
response.setDeptName(item.getName()); response.setDeptName(item.getName());
// 站点年计划发电量 // 站点年计划发电量
@ -483,7 +483,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @return * @return
*/ */
@Override @Override
public List<AppDutyVo> getDutyData(Long deptId) { public List<AppAreaDutyVo> getDutyData(Long deptId) {
// 获取当班列表数据 // 获取当班列表数据
List<DutyMainInfoVo> list = this.dutyMainService.getDutyDataV2(deptId); List<DutyMainInfoVo> list = this.dutyMainService.getDutyDataV2(deptId);
if(CollectionUtil.isEmpty(list)){ if(CollectionUtil.isEmpty(list)){
@ -491,7 +491,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
} }
// 响应数据 // 响应数据
return list.stream().map(duty->{ return list.stream().map(duty->{
AppDutyVo item = new AppDutyVo(); AppAreaDutyVo item = new AppAreaDutyVo();
// 班组基础数据设置 // 班组基础数据设置
this.settingBase(duty,item); this.settingBase(duty,item);
// 开始时间、结束时间 // 开始时间、结束时间
@ -556,7 +556,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param duty * @param duty
* @param item * @param item
*/ */
private void settingBase(DutyMainInfoVo duty, AppDutyVo item) { private void settingBase(DutyMainInfoVo duty, AppAreaDutyVo item) {
item.setShift(duty.getClassName()); item.setShift(duty.getClassName());
item.setTeam(duty.getGroupName()); item.setTeam(duty.getGroupName());
// 班组负责人 // 班组负责人
@ -572,7 +572,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param item * @param item
* @param id * @param id
*/ */
private void getNextDuty(AppDutyVo item, Long id) { private void getNextDuty(AppAreaDutyVo item, Long id) {
DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id); DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id);
if(ObjectUtil.isEmpty(nextDuty)){ if(ObjectUtil.isEmpty(nextDuty)){
return; return;
@ -593,7 +593,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param startDate * @param startDate
* @param endDate * @param endDate
*/ */
private void getInspectionTask(AppDutyVo item, String startDate, String endDate,List<Long> deptList) { private void getInspectionTask(AppAreaDutyVo item, String startDate, String endDate, List<Long> deptList) {
item.setInspectionTaskCount(0); item.setInspectionTaskCount(0);
item.setInspectionTaskFinishCount(0); item.setInspectionTaskFinishCount(0);
item.setNotInspectionTaskCount(0); item.setNotInspectionTaskCount(0);
@ -619,7 +619,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param end * @param end
* @param deptList * @param deptList
*/ */
private void getMaintenanceTask(AppDutyVo item, String start, String end, List<Long> deptList) { private void getMaintenanceTask(AppAreaDutyVo item, String start, String end, List<Long> deptList) {
item.setMaintenanceTaskCount(0); item.setMaintenanceTaskCount(0);
item.setMaintenanceTaskFinishCount(0); item.setMaintenanceTaskFinishCount(0);
item.setNotMaintenanceTaskCount(0); item.setNotMaintenanceTaskCount(0);
@ -645,7 +645,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param end * @param end
* @param deptList * @param deptList
*/ */
private void getOverhaulTask(AppDutyVo item, String start, String end,List<Long> deptList) { private void getOverhaulTask(AppAreaDutyVo item, String start, String end, List<Long> deptList) {
item.setOverhaulTaskCount(0); item.setOverhaulTaskCount(0);
item.setNotOverhaulTaskCount(0); item.setNotOverhaulTaskCount(0);
item.setOverhaulTaskFinishCount(0); item.setOverhaulTaskFinishCount(0);
@ -670,7 +670,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
* @param startTime * @param startTime
* @param endTime * @param endTime
*/ */
private void getDutyDefect(AppDutyVo item, LocalDateTime startTime, LocalDateTime endTime) { private void getDutyDefect(AppAreaDutyVo item, LocalDateTime startTime, LocalDateTime endTime) {
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery();
wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime); wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime);
//wrapper.le(OperPhenomenonEntity::getCreateTime,endTime); //wrapper.le(OperPhenomenonEntity::getCreateTime,endTime);

6
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(); countDownLatch.countDown();
return; return;
} }
target.setTaget_three(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum()); // FA上线率
double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum(); double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum();
if(Math.abs(online) > 0){ 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(); countDownLatch.countDown();
}); });
// 等待所有线程执行完成 // 等待所有线程执行完成

631
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.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; 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.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; 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.GenerateService;
import com.hnac.hzims.operational.fill.service.PowerService; import com.hnac.hzims.operational.fill.service.PowerService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*; 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.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService; 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.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData; 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 lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.api.R; 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.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept; 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.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -49,6 +72,8 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class HydropowerServiceImpl implements HydropowerService { public class HydropowerServiceImpl implements HydropowerService {
private final AreaService areaService;
private final IWeatherService weatherService; private final IWeatherService weatherService;
private final IStationService stationService; private final IStationService stationService;
@ -57,18 +82,30 @@ public class HydropowerServiceImpl implements HydropowerService {
private final PowerService photovoltaicService; private final PowerService photovoltaicService;
private final AreaService areaService; private final IImsDutyMainService dutyMainService;
private final IAnalyseDataService analyseDataService; private final IAnalyseDataService analyseDataService;
private final IOperPhenomenonService phenomenonService;
private final IOperAccessTaskService accessTaskService;
private final IStationAttributeService attributeService; private final IStationAttributeService attributeService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final IMainTaskStatisticService mainTaskStatisticService;
private final IOperMaintenanceTaskService operMaintenanceTaskService;
private final ISoeClient soeClient; private final ISoeClient soeClient;
private final ITicketInfoClient ticketInfoClient;
private final IPlanGenertionClient planGenertionClient; private final IPlanGenertionClient planGenertionClient;
private final IInspectTaskReportClient inspectTaskReportClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@Value("${hzims.operation.realIdKey}") @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 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 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; return powerYearVo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/*=====================================================app=====================================================*/
/**
* app集团数据
* @param deptId
* @return
*/
@Override
public List<HydropowerAreaVo> group(Long deptId) {
Map<Dept,List<StationEntity>> areas = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if(MapUtils.isEmpty(areas)) {
return new ArrayList<>();
}
// 实时监测点数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
// 获取站点机组指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
// 获取站点编码集合
List<String> stations = areas.values().stream().map(values -> values.get(0).getCode()).collect(Collectors.toList());
// 获取站点实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(stations);
// 获取站点7日天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(stations);
List<String> codes = new ArrayList<>();
areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList())));
// 计划发电量
List<PlanGenerationEntity> 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<String, HeWeatherWeatherNowResponse> nowWeather,Map<String, HeWeatherWeatherDailyResponse> 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<Daily> dailyList = weekData.getDaily();
if (CollectionUtil.isNotEmpty(dailyList)) {
area.setWeather(dailyList);
}
}
}
/**
* 计划发电量
* @param stations
* @param plans
* @return
*/
private Double appAreaPlan(List<StationEntity> stations, List<PlanGenerationEntity> 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<StationEntity> stations, List<HydropowerUnitTargetVo> 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<String,Object> map = new HashMap<>();
map.put("startDate",start);
map.put("endDate",end);
map.put("deptList",Collections.singletonList(area.getDeptId()));
R<TicketMonthVO> 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<AppStationTargetVo> stationTarget(List<StationEntity> stations,List<HydropowerUnitRealVo> reals,List<HydropowerUnitTargetVo> targets,List<PlanGenerationEntity> 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<PlanGenerationEntity> 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<HydropowerUnitTargetVo> 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<HydropowerUnitRealVo> 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<HydropowerUnitRealVo> 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<AppHydropowerStationVo> area(Long deptId) {
// 查询水电站站点
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE);
if (CollectionUtil.isEmpty(stations)) {
return new ArrayList<>();
}
// 实时监测点数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) 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<List<SoeData>> result = soeClient.getByLastLimitTime(null, station.getCode(), 1);
if(result.isSuccess() || CollectionUtil.isNotEmpty(result.getData())){
hydropower.setAlertList(result.getData());
}
// 站点设备
List<HydropowerUnitRealVo> 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<DutyMainInfoVo> 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<Long> 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<Runnable>(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<Long> deptList) {
item.setInspectionTaskCount(0);
item.setInspectionTaskFinishCount(0);
item.setNotInspectionTaskCount(0);
// 查询当班巡检任务
Map<String, Object> params = new HashMap<>();
params.put("startDate",startDate);
params.put("endDate",endDate);
params.put("deptList",deptList);
R<DutyInspectTaskVO> 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<Long> deptList) {
item.setMaintenanceTaskCount(0);
item.setMaintenanceTaskFinishCount(0);
item.setNotMaintenanceTaskCount(0);
// 查询当班日常维护任务
List<OperMaintenanceTaskEntity> 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<Long> deptList) {
item.setOverhaulTaskCount(0);
item.setNotOverhaulTaskCount(0);
item.setOverhaulTaskFinishCount(0);
// 查询当班检修任务
List<OperAccessTaskEntity> 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<OperPhenomenonEntity> 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<OperPhenomenonEntity> 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);
}
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppDutyVo.java → hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/AppAreaDutyVo.java

@ -10,7 +10,7 @@ import lombok.Data;
* @author ysj * @author ysj
*/ */
@Data @Data
public class AppDutyVo { public class AppAreaDutyVo {
@ApiModelProperty("班次") @ApiModelProperty("班次")
private String shift; private String shift;
Loading…
Cancel
Save