|
|
|
@ -118,6 +118,8 @@ public class HydropowerServiceImpl implements HydropowerService {
|
|
|
|
|
|
|
|
|
|
private final static int POOL_QUANTITY = 4; |
|
|
|
|
|
|
|
|
|
private final static int DUTY_POOL_QUANTITY = 5; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加载水电站机组实时数据 |
|
|
|
@ -1499,12 +1501,17 @@ public class HydropowerServiceImpl implements HydropowerService {
|
|
|
|
|
if (CollectionUtil.isEmpty(stations)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 获取站点7日天气
|
|
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
// 实时监测点数据
|
|
|
|
|
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.setMaxTemp(this.intervalTemp(weekWeather,station.getCode(),true)); |
|
|
|
|
hydropower.setMinTemp(this.intervalTemp(weekWeather,station.getCode(),false)); |
|
|
|
|
// 装机容量
|
|
|
|
|
hydropower.setCapacity(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); |
|
|
|
|
// 负荷
|
|
|
|
@ -1543,6 +1550,22 @@ public class HydropowerServiceImpl implements HydropowerService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 天气区间 |
|
|
|
|
* @param week |
|
|
|
|
* @param flag |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String intervalTemp(Map<String, HeWeatherWeatherDailyResponse> week, String code,boolean flag) { |
|
|
|
|
if(MapUtils.isEmpty(week) || !week.containsKey(code)){ |
|
|
|
|
return "21"; |
|
|
|
|
} |
|
|
|
|
if(flag){ |
|
|
|
|
return week.get(code).getDaily().get(0).getTempMax(); |
|
|
|
|
} |
|
|
|
|
return week.get(code).getDaily().get(0).getTempMin(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* app区域值班数据 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
@ -1566,11 +1589,11 @@ public class HydropowerServiceImpl implements HydropowerService {
|
|
|
|
|
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()); |
|
|
|
|
List<Long> deptList = Collections.singletonList(deptId); |
|
|
|
|
// 使用多线程处理数据
|
|
|
|
|
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); |
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(DUTY_POOL_QUANTITY); |
|
|
|
|
// 下一班组
|
|
|
|
|
pool.execute(()-> { |
|
|
|
|
this.getNextDuty(item,duty.getId()); |
|
|
|
@ -1642,7 +1665,7 @@ public class HydropowerServiceImpl implements HydropowerService {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
item.setNextShift(nextDuty.getClassName()); |
|
|
|
|
item.setNextTeam(nextDuty.getGroupName()); |
|
|
|
|
item.setNextTeam(Optional.ofNullable(nextDuty.getGroupName()).orElse("灵活排版")); |
|
|
|
|
// 下一班组负责人
|
|
|
|
|
String managerName = this.getManagerName(nextDuty.getManagerId()); |
|
|
|
|
item.setNextTeamLeader(managerName); |
|
|
|
|