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

32
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 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 @Override
public void loadEmInfo(String param) { public void loadEmInfo(String param) {
@ -281,24 +281,38 @@ public class RealTargetServiceImpl implements RealTargetService {
// 水电站设备 // 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isNotEmpty(devices)){ 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(); HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(device.getCreateDept()); target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode()); target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName()); target.setDeviceName(device.getName());
target.setDeptName(device.getName()); target.setDeptName(device.getName());
// 当年发电量 // 当年发电量
target.setPowerYear(this.getGenerationPower(device,0)); target.setPowerYear(this.getGenerationPower(device, 0));
// 当月发电量 // 当月发电量
target.setPowerMon(this.getGenerationPower(device,1)); target.setPowerMon(this.getGenerationPower(device, 1));
// 当日发电量 // 当日发电量
target.setPowerDay(this.getGenerationPower(device,2)); target.setPowerDay(this.getGenerationPower(device, 2));
// 当天有功功率 // 当天有功功率
target.setActivePowerVoList(this.getLoadsByDay(device)); target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量 // 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(device)); target.setGenerationPowerVoList(this.getGenerationPowerList(device));
return target; targets.add(target);
}).collect(Collectors.toList())); countDownLatch.countDown();
}catch (Exception exception){
countDownLatch.countDown();
}
});
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
} }
// 站点指标数据为空 // 站点指标数据为空
if(CollectionUtil.isEmpty(targets)){ if(CollectionUtil.isEmpty(targets)){
@ -1253,6 +1267,7 @@ public class RealTargetServiceImpl implements RealTargetService {
CountDownLatch countDownLatch = new CountDownLatch(limits.size()); CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){ for(List<StationEntity> item : limits){
pool.submit(()->{ pool.submit(()->{
try{
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());
@ -1263,6 +1278,9 @@ public class RealTargetServiceImpl implements RealTargetService {
powerMap.put(station.getId(),generateMap); powerMap.put(station.getId(),generateMap);
}); });
countDownLatch.countDown(); countDownLatch.countDown();
}catch (Exception exception){
countDownLatch.countDown();
}
log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
}); });

Loading…
Cancel
Save