|
|
|
@ -19,7 +19,6 @@ import com.hnac.hzims.scheduled.service.operation.home.ObtainGenerationService;
|
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.plate.DataService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.station.StationService; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
|
import io.undertow.util.CopyOnWriteMap; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
@ -65,6 +64,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
|
|
|
|
|
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设备近3年发电量数据 : 按月分割 |
|
|
|
|
* @param param |
|
|
|
@ -135,8 +135,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(limits.size()); |
|
|
|
|
List<ThirtyGenerationEntity> saves = new CopyOnWriteArrayList<>(); |
|
|
|
|
for(List<StationEntity> item : limits){ |
|
|
|
|
try{ |
|
|
|
|
pool.submit(()->{ |
|
|
|
|
pool.submit(()->{ |
|
|
|
|
try{ |
|
|
|
|
item.forEach(station->{ |
|
|
|
|
// 站点设备集合
|
|
|
|
|
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
@ -179,10 +179,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
}); |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
}); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 等待所有线程执行完成
|
|
|
|
|
try { |
|
|
|
@ -220,9 +221,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); |
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
stations.forEach(station->{ |
|
|
|
|
this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end)); |
|
|
|
|
}); |
|
|
|
|
stations.forEach(station-> this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -310,6 +309,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
}); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -382,6 +382,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
}); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -486,9 +487,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
// 接收月份发电量对象
|
|
|
|
|
Map<String, Float> son = new HashMap<>(); |
|
|
|
|
// 遍历月份数据
|
|
|
|
|
months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> { |
|
|
|
|
son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()); |
|
|
|
|
}); |
|
|
|
|
months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum())); |
|
|
|
|
container.put(optional.get().getId(), son); |
|
|
|
|
}); |
|
|
|
|
redisTemplate.opsForValue().set(recent_year_power_data, container); |
|
|
|
|