@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService {
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key" ;
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key" ;
// 创建线程池
// 创建线程池
//private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy());
private static final ExecutorService pool = new ThreadPoolExecutor ( 10 , 10 , 0L , TimeUnit . MILLISECONDS , new LinkedBlockingQueue < > ( 1024 ) , new ThreadFactoryBuilder ( ) . setNameFormat ( "load-power-data-pool-%d" ) . build ( ) , new ThreadPoolExecutor . CallerRunsPolicy ( ) ) ;
@Override
@Override
public void loadEmInfo ( String param ) {
public void loadEmInfo ( String param ) {
@ -1250,8 +1250,10 @@ public class RealTargetServiceImpl implements RealTargetService {
// 将站点切割
// 将站点切割
int limit = countStep ( stations . size ( ) ) ;
int limit = countStep ( stations . size ( ) ) ;
List < List < StationEntity > > limits = Stream . iterate ( 0 , n - > n + 1 ) . limit ( limit ) . parallel ( ) . map ( a - > stations . stream ( ) . skip ( ( long ) a * 3 ) . limit ( 3 ) . parallel ( ) . collect ( Collectors . toList ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < List < StationEntity > > limits = Stream . iterate ( 0 , n - > n + 1 ) . limit ( limit ) . parallel ( ) . map ( a - > stations . stream ( ) . skip ( ( long ) a * 3 ) . limit ( 3 ) . parallel ( ) . collect ( Collectors . toList ( ) ) ) . collect ( Collectors . toList ( ) ) ;
CountDownLatch countDownLatch = new CountDownLatch ( limits . size ( ) ) ;
for ( List < StationEntity > item : limits ) {
for ( List < StationEntity > item : limits ) {
try {
try {
pool . submit ( ( ) - > {
item . forEach ( station - > {
item . forEach ( station - > {
// 站点设备集合
// 站点设备集合
List < EminfoAndEmParamVo > stationDevices = devices . stream ( ) . filter ( device - > device . getCreateDept ( ) . equals ( station . getRefDept ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < EminfoAndEmParamVo > stationDevices = devices . stream ( ) . filter ( device - > device . getCreateDept ( ) . equals ( station . getRefDept ( ) ) ) . collect ( Collectors . toList ( ) ) ;
@ -1259,11 +1261,13 @@ public class RealTargetServiceImpl implements RealTargetService {
if ( MapUtils . isEmpty ( generateMap ) ) {
if ( MapUtils . isEmpty ( generateMap ) ) {
return ;
return ;
}
}
log . error ( "pool_item_execute_complete: {}" , JSONObject . toJSONString ( generateMap ) ) ;
powerMap . put ( station . getId ( ) , generateMap ) ;
powerMap . put ( station . getId ( ) , generateMap ) ;
} ) ;
} ) ;
} catch ( Exception exception ) {
countDownLatch . countDown ( ) ;
log . error ( "pool_item_execute_complete_error: {}" , exception . getMessage ( ) ) ;
log . error ( "pool_item_execute_complete: {}" , item . stream ( ) . map ( StationEntity : : getName ) . collect ( Collectors . toList ( ) ) ) ;
} ) ;
} catch ( Exception e ) {
log . error ( "pool_item_execute_complete_error : {}" , e . getMessage ( ) ) ;
}
}
}
}
redisTemplate . opsForValue ( ) . set ( recent_year_power_data , powerMap ) ;
redisTemplate . opsForValue ( ) . set ( recent_year_power_data , powerMap ) ;