Browse Source

#指标数据增加try/catch

zhongwei
yang_shj 7 months ago
parent
commit
75be1bf2db
  1. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  2. 26
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -524,7 +524,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
Map<String, Object> param = new HashMap<>();
param.put("faultId", faultId);
String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST");
if (StringUtil.isNotBlank(result)) {
if (StringUtil.isBlank(result)) {
throw new ServiceException("未查询到智能预警设备信息!");
}
HashMap<String, Object> map = JSONObject.parseObject(result, new TypeReference<HashMap<String, Object>>() {
@ -538,7 +538,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
throw new ServiceException("未查询到智能预警设备信息!");
}
String deviceCode = (String) data.get(0).get("TAOS_INSTANCE");
if(StringUtil.isNotBlank(deviceCode)){
if(StringUtil.isBlank(deviceCode)){
throw new ServiceException("未查询到智能预警设备信息!");
}
return this.deviceVideos(stationCode,deviceCode);
@ -573,7 +573,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
}
// 查询设备绑定视频点位
R<List<EmVideoBandingEntity>> videos = emVideoClient.getEmBandingVideos(deviceCodes);
if(videos.isSuccess() && CollectionUtil.isEmpty(videos.getData())){
if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){
throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!");
}
return videos.getData().stream().distinct().map(video->{

26
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService {
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(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy());
@Override
public void loadEmInfo(String param) {
@ -281,7 +281,10 @@ public class RealTargetServiceImpl implements RealTargetService {
// 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isNotEmpty(devices)){
targets.addAll(devices.stream().map(device->{
CountDownLatch countDownLatch = new CountDownLatch(devices.size());
for(EminfoAndEmParamVo device : devices) {
pool.submit(() -> {
try{
HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
@ -297,8 +300,19 @@ public class RealTargetServiceImpl implements RealTargetService {
target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(device));
return target;
}).collect(Collectors.toList()));
targets.add(target);
countDownLatch.countDown();
}catch (Exception exception){
countDownLatch.countDown();
}
});
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
// 站点指标数据为空
if(CollectionUtil.isEmpty(targets)){
@ -1253,6 +1267,7 @@ public class RealTargetServiceImpl implements RealTargetService {
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){
pool.submit(()->{
try{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
@ -1263,6 +1278,9 @@ public class RealTargetServiceImpl implements RealTargetService {
powerMap.put(station.getId(),generateMap);
});
countDownLatch.countDown();
}catch (Exception exception){
countDownLatch.countDown();
}
log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
});

Loading…
Cancel
Save