Browse Source

#光伏关联

zhongwei
yang_shj 2 years ago
parent
commit
a76d6a50dd
  1. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/PhotovoTargetVo.java
  2. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java
  3. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java
  4. 362
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  5. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java
  6. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java
  7. 34
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  8. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/DeptController.java
  9. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IDeptService.java
  10. 27
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java
  11. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

26
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/PhotovoTargetVo.java

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.census.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/04/19 15:01:17
* @version 4.0.0
*/
@Data
public class PhotovoTargetVo {
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty("功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
}

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java

@ -122,7 +122,6 @@ public class TargetController {
return R.data(service.hydropowerTarget(stationName,deptId,target)); return R.data(service.hydropowerTarget(stationName,deptId,target));
} }
@ApiLog @ApiLog
@ApiOperation("水利集团、区域指标关联") @ApiOperation("水利集团、区域指标关联")
@GetMapping("/water-target") @GetMapping("/water-target")
@ -132,14 +131,13 @@ public class TargetController {
} }
@ApiLog @ApiLog
@ApiOperation("集团设备统计") @ApiOperation("光伏集团、区域指标关联")
@GetMapping("/device-group") @GetMapping("/photovoltaic-target")
@ApiOperationSupport(order = 11) @ApiOperationSupport(order = 10)
public R deviceGroup(@RequestParam(value = "areaName",required = false) String areaName) { public R photovoltaicTarget(@RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId,@RequestParam(value = "target") Integer target) {
return R.data(service.deviceGroup(areaName)); return R.data(service.photovoltaicTarget(stationName,deptId,target));
} }
@ApiLog @ApiLog
@ApiOperation("集团操作票/工作票") @ApiOperation("集团操作票/工作票")
@GetMapping("/ticket-group") @GetMapping("/ticket-group")

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO;
import com.hnac.hzims.operational.census.vo.*; import com.hnac.hzims.operational.census.vo.*;
import com.hnac.hzims.operational.main.vo.PhotovoltaicTargetVo;
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
@ -54,9 +55,13 @@ public interface TargetService {
// 水利指标关联数据 // 水利指标关联数据
List<WaterTargetVo> waterTarget(String stationName, Long deptId,Integer target); List<WaterTargetVo> waterTarget(String stationName, Long deptId,Integer target);
// 光伏指标关联数据
List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target);
// 集团设备 // 集团设备
List<DeviceGroupVo> deviceGroup(String areaName); List<DeviceGroupVo> deviceGroup(String areaName);
// 集团工作牌/操作票 // 集团工作牌/操作票
List<TicketGroupVo> ticketGroup(String areaName,Long type); List<TicketGroupVo> ticketGroup(String areaName,Long type);
} }

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

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.census.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
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.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
@ -11,15 +12,15 @@ import com.hnac.hzims.operational.access.service.IOperAccessTaskService;
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO;
import com.hnac.hzims.operational.census.constants.CensusConstant; import com.hnac.hzims.operational.census.constants.CensusConstant;
import com.hnac.hzims.operational.census.service.TargetService; import com.hnac.hzims.operational.census.service.TargetService;
import com.hnac.hzims.operational.census.vo.*;
import com.hnac.hzims.operational.census.vo.WaterTargetVo; import com.hnac.hzims.operational.census.vo.WaterTargetVo;
import com.hnac.hzims.operational.census.vo.*;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.fill.entity.*;
import com.hnac.hzims.operational.fill.service.*; import com.hnac.hzims.operational.fill.service.*;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
@ -45,14 +46,11 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -64,41 +62,35 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class TargetServiceImpl implements TargetService { public class TargetServiceImpl implements TargetService {
private final IStationService stationService;
private final IMainSystemMonitoringService maintenanceService;
private final PowerService powerService;
private final AreaService areaService; private final AreaService areaService;
private final IOperMaintenanceTaskService maintenanceTaskService;
private final IOperPhenomenonService phenomenonService;
private final OverService overService; private final OverService overService;
private final OverDetailsService overDetailsService; private final PowerService powerService;
private final SolveService solveService; private final SolveService solveService;
private final OtherService otherService; private final OtherService otherService;
private final IStationService stationService;
private final OverDetailsService overDetailsService;
private final IOperAccessTaskService accessTaskService; private final IOperAccessTaskService accessTaskService;
private final IPlanGenertionClient planClient; private final IOperPhenomenonService phenomenonService;
private final ITicketInfoAllClient ticketInfoAllClient; private final IMainSystemMonitoringService maintenanceService;
private final ISysClient sysClient; private final IOperMaintenanceTaskService maintenanceTaskService;
private final RedisTemplate redisTemplate; private final ISysClient sysClient;
private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); private final IPlanGenertionClient planClient;
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final ITicketInfoAllClient ticketInfoAllClient;
private final static String KEY_INDICATORS_INFO = "hzims:operation:key:indicators:info"; private final RedisTemplate redisTemplate;
@Value("${hzims.operation.region.deviceClassifyKey}") @Value("${hzims.operation.region.deviceClassifyKey}")
private String device_classify_key; private String device_classify_key;
@ -109,9 +101,17 @@ public class TargetServiceImpl implements TargetService {
@Value("${hzims.operation.region.areaDutyInfoKey}") @Value("${hzims.operation.region.areaDutyInfoKey}")
private String areaDutyInfoKey; private String areaDutyInfoKey;
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; private final static String load_waterpump_real_key = "hzims:operation:loadwaterpump:real:key";
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_waterpump_target_key = "hzims:operation:loadwaterpump:target:key";
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
/** /**
* 获取站点装机容量 * 获取站点装机容量
@ -121,7 +121,7 @@ public class TargetServiceImpl implements TargetService {
public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type) { public List<InstalledCapacityVo> installedCapacity(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);
@ -130,7 +130,6 @@ public class TargetServiceImpl implements TargetService {
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return new ArrayList<>();
} }
if(HomePageConstant.HYDROPOWER.equals(type)){
// 设备 // 设备
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList(); List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList();
return stations.stream().map(station->{ return stations.stream().map(station->{
@ -149,27 +148,7 @@ public class TargetServiceImpl implements TargetService {
List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList());
item.setDetail(String.join("|",details)); item.setDetail(String.join("|",details));
return item; return item;
}).collect(Collectors.toList()); }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList());
}
// 查询填报数据
String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery()
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()))
.ge(PowerEntity::getMon, mon + "-01")
);
return stations.stream().map(station -> {
InstalledCapacityVo item = new InstalledCapacityVo();
item.setStationName(station.getName());
// 装机容量
List<PowerEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stationPowers)){
item.setInstalledCapacity(0.0);
}else{
item.setInstalledCapacity(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getInstalledCapacity());
}
item.setDetail("站点为填报数据,暂无设备装机容量信息!");
return item;
}).collect(Collectors.toList());
} }
/** /**
@ -180,7 +159,7 @@ public class TargetServiceImpl implements TargetService {
public List<ElectricGenerationVo> electricGeneration(String stationName,Integer type) { public List<ElectricGenerationVo> electricGeneration(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);
@ -206,13 +185,36 @@ public class TargetServiceImpl implements TargetService {
return item; return item;
} }
// 年发电量 // 年发电量
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
item.setElectricGeneration(sum); item.setElectricGeneration(sum);
// 发电量详情 // 发电量详情
List<String> details = targets.stream().map(target-> "[" + target.getDeviceCode() + " " + target.getPowerYear() +"kw]").collect(Collectors.toList()); List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList());
item.setDetail(String.join("|",details)); item.setDetail(String.join("|",details));
return item; return item;
}).collect(Collectors.toList()); }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList());
}else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(targets)){
return new ArrayList<>();
}
return stations.stream().map(station->{
ElectricGenerationVo item = new ElectricGenerationVo();
item.setStationName(station.getName());
List<PhotovoltaicTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stationTargets)){
item.setElectricGeneration(0.0);
item.setDetail("站点暂无发电");
return item;
}
// 年发电量
double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum();
item.setElectricGeneration(sum);
// 发电量详情
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList());
item.setDetail(String.join("|",details));
return item;
}).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList());
} }
// 查询填报数据 // 查询填报数据
String mon = DateUtil.format(new Date(),"yyyy"); String mon = DateUtil.format(new Date(),"yyyy");
@ -243,7 +245,7 @@ public class TargetServiceImpl implements TargetService {
public List<CompleteGenerationVo> completeGeneration(String stationName,Integer type) { public List<CompleteGenerationVo> completeGeneration(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);
@ -263,20 +265,21 @@ public class TargetServiceImpl implements TargetService {
return stations.stream().map(station->{ return stations.stream().map(station->{
CompleteGenerationVo item = new CompleteGenerationVo(); CompleteGenerationVo item = new CompleteGenerationVo();
item.setStationName(station.getName()); item.setStationName(station.getName());
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).collect(Collectors.toList());
// 实际发电量 // 实际发电量
if(CollectionUtils.isEmpty(stationTargets)){ if(CollectionUtils.isEmpty(stationTargets)){
item.setRealityGeneration(0.0); item.setRealityGeneration(0.0);
}else { }else {
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); double sum = stationTargets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
item.setRealityGeneration(sum); item.setRealityGeneration(sum);
} }
if(CollectionUtil.isNotEmpty(plans)){
// 计划发电量 // 计划发电量
List<Float> planGenerations = plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).map(PlanGenerationEntity::getPlanGeneration).collect(Collectors.toList()); double planGenerate = plans.stream().filter(plan -> plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(CollectionUtils.isEmpty(planGenerations)){ if(Math.abs(planGenerate) <= 0){
item.setPlanGeneration(0.0); item.setPlanGeneration(0.0);
}else{ }else{
item.setPlanGeneration(BigDecimal.valueOf(planGenerations.get(0)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); item.setPlanGeneration(planGenerate);
} }
// 完成率 // 完成率
if(Math.abs(item.getPlanGeneration()) <= 0){ if(Math.abs(item.getPlanGeneration()) <= 0){
@ -284,8 +287,55 @@ public class TargetServiceImpl implements TargetService {
}else{ }else{
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
}else{
item.setPlanGeneration(0.0);
item.setCompleteRate(0.0);
}
return item; return item;
}).collect(Collectors.toList()); }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList());
}else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){
// 计划发电量
String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> plans = powerService.list(Wrappers.<PowerEntity>lambdaQuery()
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()))
.ge(PowerEntity::getMon, mon + "-01")
);
// 设备指标数据
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtils.isEmpty(targets)){
return new ArrayList<>();
}
return stations.stream().map(station->{
CompleteGenerationVo item = new CompleteGenerationVo();
item.setStationName(station.getName());
List<PhotovoltaicTargetVo> stationTargets = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).collect(Collectors.toList());
// 实际发电量
if(CollectionUtils.isEmpty(stationTargets)){
item.setRealityGeneration(0.0);
}else {
double sum = stationTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum();
item.setRealityGeneration(sum);
}
if(CollectionUtil.isNotEmpty(plans)){
// 计划发电量
double planGenerate = plans.stream().filter(plan -> plan.getCreateDept().equals(station.getRefDept())).mapToDouble(PowerEntity::getPlannedPowerMon).sum();
if(Math.abs(planGenerate) <= 0){
item.setPlanGeneration(0.0);
}else{
item.setPlanGeneration(planGenerate);
}
// 完成率
if(Math.abs(item.getPlanGeneration()) <= 0){
item.setCompleteRate(0.0);
}else{
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
}
}else{
item.setPlanGeneration(0.0);
item.setCompleteRate(0.0);
}
return item;
}).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList());
} }
String mon = DateUtil.format(new Date(),"yyyy"); String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery()
@ -327,24 +377,20 @@ public class TargetServiceImpl implements TargetService {
}else{ }else{
types = Collections.singletonList(type); types = Collections.singletonList(type);
} }
// 获取水电站区域机构 List<Dept> areas = this.areas(types);
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,types,HomePageConstant.HYDROPOWER_SERVETYPE); if(CollectionUtils.isEmpty(areas)){
if(MapUtils.isEmpty(areas)){
return new ArrayList<>();
}
List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(depts)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 开始时间 // 开始时间
LocalDate firstDay = LocalDate.now().withDayOfYear(1); LocalDate firstDay = LocalDate.now().withDayOfYear(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(areas.size(), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//监控线程执行完后返回结果 //监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); CountDownLatch countDownLatch = new CountDownLatch(areas.size());
List<CompleteTicketVo> completeTickets = new ArrayList<>(); List<CompleteTicketVo> completeTickets = new ArrayList<>();
pool.execute(()-> { exe.execute(()-> {
for (Dept dept: depts) { for (Dept dept: areas) {
// 双票 // 双票
DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now());
CompleteTicketVo completeTicketVo = new CompleteTicketVo(); CompleteTicketVo completeTicketVo = new CompleteTicketVo();
@ -370,8 +416,33 @@ public class TargetServiceImpl implements TargetService {
e.printStackTrace(); e.printStackTrace();
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
pool.shutdown(); exe.shutdown();
return completeTickets; return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).collect(Collectors.toList());
}
/**
* 获取区域机构
* @param types
* @return
*/
private List<Dept> areas(List<Integer> types) {
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.in(StationEntity::getType,types)
);
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
// 站点父级区域
List<Long> parents = result.getData().stream().filter(dept->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(parents)){
return new ArrayList<>();
}
return result.getData().stream().filter(dept->parents.contains(dept.getId()) && HomePageConstant.AREA.equals(dept.getDeptCategory())).collect(Collectors.toList());
} }
/** /**
@ -399,7 +470,13 @@ public class TargetServiceImpl implements TargetService {
// 双票合格率 // 双票合格率
item.setTicketCount("*"); item.setTicketCount("*");
item.setCompleteCount("*"); item.setCompleteCount("*");
item.setCompleteRate(powers.stream().mapToDouble(o->Double.valueOf(o.getDoubleQualifyRate())).average().toString()); List<PowerEntity> stationPower = powers.stream().filter(power->power.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationPower)){
item.setCompleteRate("0.0");
}else{
double rate = stationPower.stream().mapToDouble(o->Double.parseDouble(o.getDoubleQualifyRate())).sum();
item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
}
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@ -427,11 +504,13 @@ public class TargetServiceImpl implements TargetService {
} }
String startTime = this.getFristDayByYear(); String startTime = this.getFristDayByYear();
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(depts.size(), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//监控线程执行完后返回结果 //监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); CountDownLatch countDownLatch = new CountDownLatch(depts.size());
List<CompleteDefectVo> completeDefects = new ArrayList<>(); List<CompleteDefectVo> completeDefects = new ArrayList<>();
pool.execute(()-> { exe.execute(()-> {
for (Dept dept: depts) { for (Dept dept: depts) {
// 缺陷 // 缺陷
DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId())); DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId()));
@ -454,7 +533,7 @@ public class TargetServiceImpl implements TargetService {
e.printStackTrace(); e.printStackTrace();
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
pool.shutdown(); exe.shutdown();
return completeDefects; return completeDefects;
} }
@ -660,9 +739,9 @@ public class TargetServiceImpl implements TargetService {
return new ArrayList<>(); return new ArrayList<>();
} }
// 获取设备集合 // 获取设备集合
List<DeviceClassifyVo> deviceClassifys = devices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { List<DeviceClassifyVo> deviceClassifys = devices.stream().filter(device->detpIds.contains(device.getCreateDept())).sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> {
DeviceClassifyVo deviceClassify = new DeviceClassifyVo(); DeviceClassifyVo deviceClassify = new DeviceClassifyVo();
deviceClassify.setStationName(stations.stream().filter(o-> o.getRefDept().equals(o.getCreateDept())).collect(Collectors.toList()).get(0).getName()); deviceClassify.setStationName(stations.stream().filter(o-> o.getRefDept().equals(device.getCreateDept())).collect(Collectors.toList()).get(0).getName());
deviceClassify.setDeviceName(device.getName()); deviceClassify.setDeviceName(device.getName());
if(faultList.contains(device.getEmCode())){ if(faultList.contains(device.getEmCode())){
deviceClassify.setDeviceStatus(4); deviceClassify.setDeviceStatus(4);
@ -693,13 +772,12 @@ public class TargetServiceImpl implements TargetService {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER);
wappers.eq(StationEntity::getServeType,2); wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtils.isEmpty(stationName)){ if(!StringUtil.isEmpty(stationName)){
wappers.like(StationEntity::getName,stationName); wappers.like(StationEntity::getName,stationName);
} }
if(!ObjectUtil.isEmpty(deptId)){ if(ObjectUtil.isNotEmpty(deptId)){
List<Long> deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); wappers.in(StationEntity::getRefDept,sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()));
wappers.in(StationEntity::getRefDept,deptIds);
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
@ -707,48 +785,44 @@ public class TargetServiceImpl implements TargetService {
} }
// 功率 // 功率
if(HomePageConstant.POWER.equals(target)){ if(HomePageConstant.POWER.equals(target)){
Map<String, Double> activePowerMap = (Map<String, Double>) redisTemplate.opsForValue().get(activePowerKey); // 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
return stations.stream().map(station->{ return stations.stream().map(station->{
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); HydropowerTargetVo hydropower = new HydropowerTargetVo();
hydropowerTarget.setStationName(station.getName()); hydropower.setStationName(station.getName());
if(MapUtils.isEmpty(activePowerMap)){ if(CollectionUtil.isEmpty(reals)){
hydropowerTarget.setPower(0.0); hydropower.setPower(0.0);
return hydropowerTarget; }else{
hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum());
} }
Double power = activePowerMap.get(station.getCode()); return hydropower;
hydropowerTarget.setPower(Optional.ofNullable(power).orElse(0.0)); })/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList());
return hydropowerTarget;
}).sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList());
} }
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
// 发电量 // 发电量
KeyIndicatorsVo keyIndicatorsVo = (KeyIndicatorsVo) redisTemplate.opsForValue().get(KEY_INDICATORS_INFO);
// 水电站
List<PowerStationTotalVo> powers = keyIndicatorsVo.getPowerStationTotalVoList();
return stations.stream().map(station->{ return stations.stream().map(station->{
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo();
hydropowerTarget.setStationName(station.getName()); hydropowerTarget.setStationName(station.getName());
if(CollectionUtils.isEmpty(powers)){ if(CollectionUtils.isEmpty(targets)){
hydropowerTarget.setElectric(0.0);
return hydropowerTarget;
}
List<PowerStationTotalVo> stationTargets = powers.stream().filter(o-> o.getStationId().equals(station.getId())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stationTargets)){
hydropowerTarget.setElectric(0.0); hydropowerTarget.setElectric(0.0);
return hydropowerTarget; }else{
}
switch (target){ switch (target){
case 3: case 3:
hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentYearPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
break; break;
case 2: case 2:
hydropowerTarget.setElectric(stationTargets.get(0).getPowerGeneration()); hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
break; break;
case 1: case 1:
hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentDayPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
break; break;
default:
hydropowerTarget.setElectric(0.0);
}
} }
return hydropowerTarget; return hydropowerTarget;
}).sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList()); })/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList());
} }
/** /**
@ -776,7 +850,7 @@ public class TargetServiceImpl implements TargetService {
} }
// 负荷 // 负荷
if(HomePageConstant.LOADING.equals(target)){ if(HomePageConstant.LOADING.equals(target)){
List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(loadwaterpump_real_key); List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(load_waterpump_real_key);
return stations.stream().map(station->{ return stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo(); WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName()); water.setStationName(station.getName());
@ -787,10 +861,10 @@ 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;
}).sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); })/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList());
} }
// 用电量 // 用电量
List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(loadwaterpump_target_key); List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key);
return stations.stream().map(station->{ return stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo(); WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName()); water.setStationName(station.getName());
@ -808,9 +882,69 @@ public class TargetServiceImpl implements TargetService {
case 1: case 1:
water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum()); water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum());
break; break;
default:
water.setUse(0.0);
} }
return water; return water;
}).sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList()); })/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList());
}
@Override
public List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target) {
// 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.in(StationEntity::getType, HomePageConstant.waterList);
wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
wappers.like(StationEntity::getName,stationName);
}
if(!ObjectUtil.isEmpty(deptId)){
List<Long> deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList());
wappers.in(StationEntity::getRefDept,deptIds);
}
List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>();
}
// 负荷
if(HomePageConstant.LOADING.equals(target)){
// 实时数据
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
return stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(reals)){
photovo.setLoad(0.0);
}else{
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());
}
// 发电量
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
return stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(targets)){
photovo.setGenerate(0.0);
}else{
switch (target){
case 3:
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum());
break;
case 2:
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum());
break;
case 1:
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
break;
default:
photovo.setGenerate(0.0);
}
}
return photovo;
})/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate)).collect(Collectors.toList());
} }
/** /**
@ -912,6 +1046,6 @@ public class TargetServiceImpl implements TargetService {
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
return sdf.format(calendar.getTime()); return DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
} }
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java

@ -72,6 +72,7 @@ public class SideHustleController extends BladeController {
List<PowerFinishVo> powerFinishVoList = regionService.areaPowerMonth(deptId); List<PowerFinishVo> powerFinishVoList = regionService.areaPowerMonth(deptId);
return R.data(powerFinishVoList); return R.data(powerFinishVoList);
} }
@ApiLog @ApiLog
@ApiOperation("获取地图标记") @ApiOperation("获取地图标记")
@GetMapping("/getMapMarker") @GetMapping("/getMapMarker")
@ -81,9 +82,10 @@ public class SideHustleController extends BladeController {
public R<List<MapMarkerVo>> getMapMarker(@ApiParam(value = "区域机构ID") Long deptId,@RequestParam(value ="types") List<Integer> types) { public R<List<MapMarkerVo>> getMapMarker(@ApiParam(value = "区域机构ID") Long deptId,@RequestParam(value ="types") List<Integer> types) {
return R.data(regionService.getMapMarker(deptId,types)); return R.data(regionService.getMapMarker(deptId,types));
} }
@ApiLog @ApiLog
@ApiOperation("区域当月发电量完成情况") @ApiOperation("区域当月发电量完成情况")
// @GetMapping("/powerFinishMonth") @GetMapping("/powerFinishMonth")
@ApiOperationSupport(order = 7) @ApiOperationSupport(order = 7)
public R<PowerFinishVo> powerFinishMonth(@ApiParam(value = "区域id",required = true) @RequestParam("deptId") Long deptId) { public R<PowerFinishVo> powerFinishMonth(@ApiParam(value = "区域id",required = true) @RequestParam("deptId") Long deptId) {
PowerFinishVo response = regionService.powerFinishMonth(deptId); PowerFinishVo response = regionService.powerFinishMonth(deptId);

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java

@ -297,7 +297,7 @@ public class HomeServiceImpl implements HomeService {
target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
// 双票合格率 // 双票合格率
target.setTaget_four(BigDecimal.valueOf(pass / list.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
return target; return target;
} }
@ -335,7 +335,7 @@ public class HomeServiceImpl implements HomeService {
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(areas)){ if(CollectionUtil.isNotEmpty(areas)){
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(4, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(STORAGE_POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
// 监控线程执行完后返回结果 // 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(STORAGE_POOL_QUANTITY); CountDownLatch countDownLatch = new CountDownLatch(STORAGE_POOL_QUANTITY);
// 日常维护 // 日常维护
@ -385,7 +385,7 @@ public class HomeServiceImpl implements HomeService {
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK)); target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK));
// 线程池 // 线程池
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build(); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(3, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(NETWORK_POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
// 监控线程执行完后返回结果 // 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(NETWORK_POOL_QUANTITY); CountDownLatch countDownLatch = new CountDownLatch(NETWORK_POOL_QUANTITY);
// 当月 // 当月

34
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -3,6 +3,7 @@ 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.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; 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;
@ -44,9 +45,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -1107,8 +1106,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
LocalDate firstDay = LocalDate.now().withDayOfMonth(1); LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN); LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.now(); LocalDateTime endTime = LocalDateTime.now();
//通过线程池异步获取月报各模块内容 主要分为五块内容 ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY); ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//监控线程执行完后返回结果 //监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 日常维护 // 日常维护
@ -1302,6 +1301,20 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* @return * @return
*/ */
private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) { private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) {
// FIXME 当天功率测试数据
Calendar start = Calendar.getInstance();
start.add(Calendar.HOUR_OF_DAY,-start.get(Calendar.HOUR_OF_DAY));
List<PhotovoltaicLoadGenerateVo> list = new ArrayList<>();
Random random = new Random();
while (start.getTime().compareTo(new Date()) <= 0){
PhotovoltaicLoadGenerateVo load = new PhotovoltaicLoadGenerateVo();
load.setPeriod(DateUtil.format(start.getTime(),"yyyy-mm-dd HH"));
load.setValue(random.nextFloat() * 500);
list.add(load);
start.add(Calendar.HOUR_OF_DAY,1);
}
return list;
/*
// redis实时数据 // redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(photovoltaics)){ if(CollectionUtil.isEmpty(photovoltaics)){
@ -1312,14 +1325,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
if(CollectionUtil.isEmpty(devices)){ if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>(); return new ArrayList<>();
} }
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
// 开始日期
Calendar calendar = Calendar.getInstance();
String end = sdf.format(calendar.getTime());
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = sdf.format(calendar.getTime());
List<AnalyseDataTaosVO> list = new ArrayList<>(); List<AnalyseDataTaosVO> list = new ArrayList<>();
for(PhotovoltaicTargetVo device : devices){ for(PhotovoltaicTargetVo device : devices){
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PV_LOAD)); list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PV_LOAD));
@ -1333,7 +1339,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
target.setPeriod(String.valueOf(time.getHour())); target.setPeriod(String.valueOf(time.getHour()));
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum()); target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
return target; return target;
}).collect(Collectors.toList()); }).collect(Collectors.toList());*/
} }
/** /**

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/DeptController.java

@ -3,8 +3,10 @@ package com.hnac.hzims.operational.report.controller;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.report.service.IDeptService; import com.hnac.hzims.operational.report.service.IDeptService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@ -45,4 +48,14 @@ public class DeptController extends BladeController {
public R<List<Long>> alarmDeptByCurrentUser(){ public R<List<Long>> alarmDeptByCurrentUser(){
return R.data(deptService.alarmDeptByCurrentUser()); return R.data(deptService.alarmDeptByCurrentUser());
} }
@ApiLog
@ApiOperation(value = "区域机构",notes = "下拉框区域")
@GetMapping("/select_area")
public R<List<Dept>> selectArea(@RequestParam(value = "serveType") Integer serveType, @RequestParam(value = "type") Integer type){
if(HomePageConstant.WATER_CONSERVANCY.equals(type)){
return R.data(deptService.selectArea(serveType,HomePageConstant.waterList));
}
return R.data(deptService.selectArea(serveType,Collections.singletonList(type)));
}
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IDeptService.java

@ -1,5 +1,6 @@
package com.hnac.hzims.operational.report.service; package com.hnac.hzims.operational.report.service;
import io.swagger.models.auth.In;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.vo.DeptVO; import org.springblade.system.vo.DeptVO;
@ -29,4 +30,6 @@ public interface IDeptService {
List<Dept> getCurrentUserDept(String name,String type); List<Dept> getCurrentUserDept(String name,String type);
List<Long> alarmDeptByCurrentUser(); List<Long> alarmDeptByCurrentUser();
List<Dept> selectArea(Integer servrType,List<Integer> types);
} }

27
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/DeptServiceImpl.java

@ -147,4 +147,31 @@ public class DeptServiceImpl implements IDeptService {
} }
return stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); return stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
} }
/**
*
* 获取区域机构
* @param types
* @return
*/
@Override
public List<Dept> selectArea(Integer servrType,List<Integer> types) {
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,servrType)
.in(StationEntity::getType,types)
);
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
// 站点父级区域
List<Long> parents = result.getData().stream().filter(dept->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(parents)){
return new ArrayList<>();
}
return result.getData().stream().filter(dept->parents.contains(dept.getId()) && HomePageConstant.AREA.equals(dept.getDeptCategory())).collect(Collectors.toList());
}
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -486,7 +486,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (null == deptId) { if (null == deptId) {
// 最小类型机构 // 最小类型机构
Optional<Dept> min = authList.stream().min(Comparator.comparing(Dept::getDeptCategory)); Optional<Dept> min = authList.stream().min(Comparator.comparing(Dept::getDeptCategory));
dept = min.isPresent() ? min.get() : null; dept = min.orElse(null);
if (ObjectUtil.isEmpty(dept)) { if (ObjectUtil.isEmpty(dept)) {
return null; return null;
} }

Loading…
Cancel
Save