Browse Source

#bug修改

zhongwei
yang_shj 2 years ago
parent
commit
c5529dc9e4
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java
  3. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java
  4. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  6. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainTaskStatisticServiceImpl.java
  7. 135
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java

@ -15,7 +15,7 @@ import lombok.Data;
public class PhotovoltaicPowerVo { public class PhotovoltaicPowerVo {
@ApiModelProperty(value = "小时") @ApiModelProperty(value = "小时")
private String hour; private Integer hour;
@ApiModelProperty(value = "有功功率") @ApiModelProperty(value = "有功功率")
private String activePower; private String activePower;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java

@ -25,6 +25,9 @@ public class PhotovoltaicSubordinateAppVo {
@ApiModelProperty(value = "机构名称") @ApiModelProperty(value = "机构名称")
private String deptName; private String deptName;
@ApiModelProperty(value = "机构类型:1-集团、2-省子公司、3-区域、4-站点")
private Integer type;
@ApiModelProperty(value = "天气") @ApiModelProperty(value = "天气")
private Now now; private Now now;
@ -44,7 +47,7 @@ public class PhotovoltaicSubordinateAppVo {
private Double load; private Double load;
@ApiModelProperty(value = "站点实时功率列表") @ApiModelProperty(value = "站点实时功率列表")
private List<PhotovoltaicLoadVo> stationLoads; private List<PhotovoltaicLoadVo> loads;
@ApiModelProperty(value = "日常任务数量") @ApiModelProperty(value = "日常任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
@ -87,5 +90,6 @@ public class PhotovoltaicSubordinateAppVo {
private Integer workFinishCount; private Integer workFinishCount;
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer sort; private Integer sort;
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java

@ -58,9 +58,8 @@ public class PhotovoltaicController extends BladeController {
return R.data(service.station(deptId)); return R.data(service.station(deptId));
} }
@ApiLog @ApiLog
@ApiOperation("App区域下属数据") @ApiOperation("App集团/区域数据")
@GetMapping("/app_subordinate") @GetMapping("/app_subordinate")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R app_subordinate(@ApiParam(value = "区域/站点机构编号") Long deptId) { public R app_subordinate(@ApiParam(value = "区域/站点机构编号") Long deptId) {

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

@ -29,8 +29,8 @@ public interface PhotovoltaicService {
// 站点数据 // 站点数据
PhotovoltaicStationVo station(Long deptId); PhotovoltaicStationVo station(Long deptId);
// app区域数据 // app集团/区域数据
List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId); PhotovoltaicSubordinateAppVo app_subordinate(Long deptId);
// app站点数据 // app站点数据
PhotovoltaicStationAppVo app_station(Long deptId); PhotovoltaicStationAppVo app_station(Long deptId);

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

@ -1331,7 +1331,7 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param area * @param area
*/ */
private void complteTask(HydropowerAreaVo area) { private void complteTask(HydropowerAreaVo area) {
String start = DateUtil.format(new Date(),"yyyy-mm") + "-01 00:00:00"; String start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00";
area.setStart(start); area.setStart(start);
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
area.setEnd(end); area.setEnd(end);

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainTaskStatisticServiceImpl.java

@ -219,10 +219,10 @@ public class MainTaskStatisticServiceImpl implements IMainTaskStatisticService {
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// 消缺总数 // 消缺总数
List<OperDefectEntity> shortagesSumList = defectService.list(new LambdaQueryWrapper<OperDefectEntity>(){{ List<OperPhenomenonEntity> shortagesSumList = phenomenonService.list(new LambdaQueryWrapper<OperPhenomenonEntity>(){{
ge(OperDefectEntity::getCreateTime,firstDateTime); ge(OperPhenomenonEntity::getCreateTime,firstDateTime);
le(OperDefectEntity::getCreateTime,now); le(OperPhenomenonEntity::getCreateTime,now);
in(OperDefectEntity::getCreateDept,list); in(OperPhenomenonEntity::getCreateDept,list);
}}); }});
if(CollectionUtil.isEmpty(shortagesSumList)){ if(CollectionUtil.isEmpty(shortagesSumList)){
shortagesVo.setShortagesSum(0); shortagesVo.setShortagesSum(0);
@ -231,7 +231,8 @@ public class MainTaskStatisticServiceImpl implements IMainTaskStatisticService {
} }
// 消缺数 // 消缺数
shortagesVo.setShortagesSum(shortagesSumList.size()); shortagesVo.setShortagesSum(shortagesSumList.size());
List<Long> shortagesList = shortagesSumList.stream().filter(o -> "1".equals(o.getHandleStatus())).map(OperDefectEntity::getId).collect(Collectors.toList()); List<Long> shortagesList = shortagesSumList.stream().filter(o -> (Func.isNotEmpty(o.getIsDefect()) && o.getIsDefect() == 0) || "1".equals(o.getConclusionStatus())).
map(OperPhenomenonEntity::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(shortagesList)){ if(CollectionUtil.isEmpty(shortagesList)){
shortagesVo.setShortages(0); shortagesVo.setShortages(0);
} }

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

@ -24,6 +24,7 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result; 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.jsoup.helper.DataUtil;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
@ -309,12 +310,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
Random random = new Random(); Random random = new Random();
while (start.getTime().compareTo(new Date()) <= 0){ while (start.getTime().compareTo(new Date()) <= 0){
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
load.setHour(DateUtil.format(start.getTime(),"yyyy-mm-dd HH")); load.setHour(start.get(Calendar.HOUR_OF_DAY));
load.setActivePower(String.valueOf(random.nextDouble() * 500)); load.setActivePower(String.valueOf(random.nextDouble() * 500));
list.add(load); list.add(load);
start.add(Calendar.HOUR_OF_DAY,1); start.add(Calendar.HOUR_OF_DAY,1);
} }
return list; return list.stream().sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());
/*String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; /*String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
@ -324,7 +325,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return records.stream().map(record -> { return records.stream().map(record -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(DateUtil.format(time,"yyyy-mm-dd HH")); load.setHour(time.getHours());
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load; return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());*/ }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());*/
@ -1053,46 +1054,83 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
/** /**
* App区域下属数据 * APP集团/省子公司数据
*
* @param deptId * @param deptId
* @return * @return
*/ */
@Override @Override
public List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId) { public PhotovoltaicSubordinateAppVo app_subordinate(Long deptId) {
// 获取区域或者站点map结构 // 查询光伏站点
Map<Dept, List<StationEntity>> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE);
if (MapUtils.isEmpty(map)) { if (CollectionUtil.isEmpty(stations)) {
return new ArrayList<>(); return new PhotovoltaicSubordinateAppVo();
} }
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo();
// 实时数据 // 实时数据
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key); List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 指标数据 // 指标数据
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
// 遍历数据 // 获取区域或者站点map结构
List<PhotovoltaicSubordinateAppVo> subordinates = new ArrayList<>(); Map<Dept, List<StationEntity>> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC));
for (Map.Entry<Dept, List<StationEntity>> entry : map.entrySet()) { // 集团/省子公司名称
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo(); this.subordinateDept(subordinate,deptId);
if (ObjectUtil.isEmpty(entry.getValue())) { // 区域数据
continue; this.subordinateTargetData(subordinate, stations, deviceReals, deviceTargets);
} if(HomePageConstant.AREA > subordinate.getType()){
StationEntity station = entry.getValue().get(0); // 集团数据
subordinate.setDeptId(entry.getKey().getId()); this.targetArea(subordinate, map, deviceReals);
subordinate.setDeptName(entry.getKey().getDeptName()); }else{
subordinate.setSort(entry.getKey().getSort());
subordinate.setAddress(station.getAddress());
// 获取实时天气 // 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode())); Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(stations.get(0).getCode()));
if (MapUtils.isNotEmpty(nowWeather)) { if (MapUtils.isNotEmpty(nowWeather)) {
subordinate.setNow(nowWeather.get(station.getCode()).getNow()); subordinate.setNow(nowWeather.get(stations.get(0).getCode()).getNow());
}
} }
// 容量、实时功率、今日发电量
this.subordinateTargetData(subordinate, new ArrayList<>(entry.getValue()), deviceReals, deviceTargets);
// 当月任务执行情况 // 当月任务执行情况
this.subordinateTaskMon(subordinate, Collections.singletonList(entry.getKey().getId())); this.subordinateTaskMon(subordinate, map.keySet().stream().map(Dept::getId).collect(Collectors.toList()));
subordinates.add(subordinate); return subordinate;
}
/**
* 区域数据
* @param subordinate
* @param map
* @param reals
*/
private void targetArea(PhotovoltaicSubordinateAppVo subordinate, Map<Dept, List<StationEntity>> map, List<PhotovoltaicRealVo> reals) {
if(MapUtils.isEmpty(map)){
return;
}
subordinate.setLoads(map.entrySet().stream().map(entry -> {
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo();
load.setDeptId(entry.getKey().getId());
load.setName(entry.getKey().getDeptName());
load.setLoad(reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
return load;
}).collect(Collectors.toList()));
}
/**
* 设置省子公司名称
* @param subordinate
*/
private void subordinateDept(PhotovoltaicSubordinateAppVo subordinate,Long deptId) {
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return;
}
Optional<Dept> optional;
if(ObjectUtil.isNotEmpty(deptId)){
optional = result.getData().stream().filter(dept -> dept.getId().equals(deptId)).min(Comparator.comparing(Dept::getDeptCategory));
}else{
optional = result.getData().stream().min(Comparator.comparing(Dept::getDeptCategory));
} }
return subordinates; optional.ifPresent(dept -> {
subordinate.setDeptId(dept.getId());
subordinate.setDeptName(dept.getDeptName());
subordinate.setType(dept.getDeptCategory());
});
} }
/** /**
@ -1101,17 +1139,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* @param subordinate * @param subordinate
*/ */
private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate, List<Long> depts) { private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate, List<Long> depts) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); String start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00";
LocalDate firstDay = LocalDate.now().withDayOfMonth(1); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.now();
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
//监控线程执行完后返回结果 //监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 日常维护 // 日常维护
exe.execute(() -> { exe.execute(() -> {
MaintainVo maintainVo = taskService.getMaintain(dtf.format(startTime), dtf.format(endTime), depts); MaintainVo maintainVo = taskService.getMaintain(start, end, depts);
subordinate.setMaintenanceCount(maintainVo.getMaintain()); subordinate.setMaintenanceCount(maintainVo.getMaintain());
subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish()); subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish());
countDownLatch.countDown(); countDownLatch.countDown();
@ -1126,7 +1162,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}); });
// 检修 // 检修
exe.execute(() -> { exe.execute(() -> {
OverhaulVo overhaulVo = taskService.getOverhaul(dtf.format(startTime), dtf.format(endTime), depts); OverhaulVo overhaulVo = taskService.getOverhaul(start, end, depts);
int overhaul = overhaulVo.getOverhaul(); int overhaul = overhaulVo.getOverhaul();
int overhaulFinish = overhaulVo.getOverhaulFinish(); int overhaulFinish = overhaulVo.getOverhaulFinish();
subordinate.setOverhaulCount(overhaul); subordinate.setOverhaulCount(overhaul);
@ -1136,8 +1172,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 操作票&工作票 // 操作票&工作票
exe.execute(() -> { exe.execute(() -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("startDate", dtf.format(startTime)); map.put("startDate", start);
map.put("endDate", dtf.format(endTime)); map.put("endDate", end);
map.put("deptList", depts); map.put("deptList", depts);
R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map); R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
@ -1152,6 +1188,14 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify()); subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify());
countDownLatch.countDown(); countDownLatch.countDown();
}); });
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
} }
/** /**
@ -1167,26 +1211,31 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(reals)) { if(CollectionUtil.isNotEmpty(stations) && HomePageConstant.AREA.equals(subordinate.getType())){
// 容量 、 实时功率 subordinate.setLoads(
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
subordinate.setStationLoads(
stations.stream().map(station -> { stations.stream().map(station -> {
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo(); PhotovoltaicLoadVo load = new PhotovoltaicLoadVo();
load.setDeptId(station.getRefDept()); load.setDeptId(station.getRefDept());
load.setCode(station.getCode()); load.setCode(station.getCode());
load.setName(station.getName()); load.setName(station.getName());
if(CollectionUtil.isNotEmpty(reals)){
load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}else{
load.setLoad(0.0);
}
return load; return load;
}).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList()) }).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList())
); );
} }
if (CollectionUtil.isNotEmpty(reals)) {
// 容量 、 实时功率
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}
if (CollectionUtil.isNotEmpty(targets)) { if (CollectionUtil.isNotEmpty(targets)) {
// 今日发电量 // 今日发电量
subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
} }
} }
/** /**

Loading…
Cancel
Save