Compare commits

..

No commits in common. '3d10a2646baef7afb0aea8d1d3f8c3635a25c50c' and '9e7f33b1aac056dfb0994a27f7d24429a5b9c81e' have entirely different histories.

  1. 34
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  2. 51
      hzims-service/weather/src/main/java/com/hnac/hzims/weather/schedule/StationWeatherSchedule.java

34
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.hnac.hzims.operational.config.HikPathConfiguration;
import com.hnac.hzims.operational.station.StationConstants;
@ -56,14 +57,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
private String videoLoginUrl;
@Value("${hzims.video.random-code}")
private String definitionCode;
@Value("${url.video.left}")
private List<String> videoLeft;
@Value("${url.video.right}")
private List<String> videoRight;
/**
* 获取海康视频接口
*
* @return
*/
@Override
@ -78,7 +73,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
,stationVideoTypeEntity.getPointCode(), DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE,
stationVideoTypeEntity.getType()),0));
ids.add(stationVideoTypeEntity.getId());
} catch (Exception e) {
}
catch (Exception e){
stationVideoTypeEntity.setLiveSourceAddress(null);
}
}
@ -141,7 +137,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
for (StationVideoTypeEntity video : result.getRecords()) {
try {
video.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(video.getVideoHost(), video.getAppKey(), video.getAppSecret(), video.getPointCode(), 1));
} catch (Exception e) {
}
catch(Exception e) {
log.error("视频点位【"+video.getName()+"】获取地址失败");
}
}
@ -149,7 +146,6 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
return result;
}
@Override
public List<StationVideoTypeEntity> getVideoByIdsAndType(String ids,String type) {
List<Long> idList = Func.toLongList(",",ids);
@ -214,7 +210,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
HttpResponse response;
try {
response = HttpUtil.createGet(pathConfiguration.getStationsPath()).execute();
} catch (Exception e) {
}
catch(Exception e) {
logger.error("getHikVisionStations",e.getMessage());
return Lists.newArrayList();
// throw new ServiceException(e.getMessage());
@ -233,7 +230,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
HttpResponse response;
try{
response = HttpUtil.createGet(pathConfiguration.getMonitorsPath()+"/"+stationId).execute();
} catch (RuntimeException e) {
}
catch (RuntimeException e) {
throw new ServiceException(e.getMessage());
}
Assert.isTrue(HttpServletResponse.SC_OK == response.getStatus(),()->{
@ -278,7 +276,8 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
, DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE,stationVideoTypeEntity.getType())
, streamType
));
} catch (Exception e) {
}
catch (Exception e){
stationVideoTypeEntity.setLiveSourceAddress(null);
}
}
@ -323,31 +322,32 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
/**
* 水利监控视频
*
* @return
*/
@Override
public WaterMonitorVideoVo waterMonitorVideo() {
WaterMonitorVideoVo video = new WaterMonitorVideoVo();
List<StationVideoTypeEntity> left = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery().
in(StationVideoTypeEntity::getId, videoLeft));
in(StationVideoTypeEntity::getId,Arrays.asList(28483776900235440L,28483776900235463L, 28483776900235466L)));
if(CollectionUtil.isNotEmpty(left)){
video.setLeft(left.stream().peek(item->{
try {
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1));
} catch (Exception e) {
}
catch(Exception e) {
log.error("视频点位【"+item.getPointCode()+"】获取地址失败");
}
}).collect(Collectors.toList()));
}
List<StationVideoTypeEntity> right = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery().
in(StationVideoTypeEntity::getId, videoRight));
in(StationVideoTypeEntity::getId,Arrays.asList(28483776900235468L,28483776900235467L,28483776900235472L)));
if(CollectionUtil.isNotEmpty(right)){
video.setRight(right.stream().peek(item->{
try {
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1));
} catch (Exception e) {
}
catch(Exception e) {
log.error("视频点位【"+item.getPointCode()+"】获取地址失败");
}
}).collect(Collectors.toList()));

51
hzims-service/weather/src/main/java/com/hnac/hzims/weather/schedule/StationWeatherSchedule.java

@ -1,13 +1,16 @@
package com.hnac.hzims.weather.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.hzimsweather.constants.WeatherConstant;
import com.hnac.hzims.hzimsweather.entity.DailyHeWeatherEntity;
import com.hnac.hzims.hzimsweather.entity.VStationEntity;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.weather.service.HeWeatherHistoricalService;
import com.hnac.hzims.weather.service.HeWeatherWeatherService;
import com.hnac.hzims.weather.service.IDailyHeWeatherService;
import com.hnac.hzims.weather.service.IStationService;
@ -16,13 +19,23 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.*;
import static com.hnac.hzims.hzimsweather.constants.XxlJobConstant.*;
import static com.hnac.hzims.hzimsweather.constants.XxlJobConstant.STATION_DAILY_WEATHER;
import static com.hnac.hzims.hzimsweather.constants.XxlJobConstant.STATION_3D_WEATHER;
import static com.hnac.hzims.hzimsweather.constants.XxlJobConstant.STATION_NOW_WEATHER;
import static com.hnac.hzims.hzimsweather.constants.XxlJobConstant.STATION_7D_WEATHER;
/**
* @author hx
@ -38,10 +51,9 @@ public class StationWeatherSchedule {
/**
* 获取各站点下七日内天气 存入缓存
*
* @Scheduled(cron = "0 10 0/12 * * ?")
* @return
* @throws InterruptedException
* @Scheduled(cron = "0 10 0/12 * * ?")
*/
@XxlJob(STATION_7D_WEATHER)
public ReturnT<String> save7dWeather(String param) throws InterruptedException {
@ -66,7 +78,8 @@ public class StationWeatherSchedule {
);
if(ObjectUtil.isNotEmpty(dailyHeWeatherEntity)) {
entity.setId(dailyHeWeatherEntity.getId());
} else {
}
else {
entity.setStationCode(vStationEntity.getCode());
entity.setDeptId(vStationEntity.getRefDept());
entity.setTenantId(vStationEntity.getTenantId());
@ -77,11 +90,12 @@ public class StationWeatherSchedule {
}
dailyHeWeatherService.saveOrUpdateBatch(weatherEntityList);
}
} catch (Exception e) {
log.error("{}获取七日天气失败,位置信息为:{},{}", vStationEntity.getName(), vStationEntity.getLgtd(), vStationEntity.getLttd());
log.error("获取七日天气失败", e);
}
catch (Exception e) {
e.printStackTrace();
XxlJobLogger.log(vStationEntity.getName()+"获取七日天气失败,位置信息为:"+ vStationEntity.getLgtd() + "," + vStationEntity.getLttd());
} finally {
}
finally {
downLatch.countDown();
}
}));
@ -92,7 +106,6 @@ public class StationWeatherSchedule {
/**
* 获取各站点下三日内天气 存入缓存 @Scheduled(cron = "0 5 0/1 * * ?")
*
* @return
* @throws InterruptedException
*/
@ -106,11 +119,12 @@ public class StationWeatherSchedule {
XxlJobLogger.log(vStationEntity.getName()+"获取三日天气开始,位置信息为:"+ vStationEntity.getLgtd() + "," + vStationEntity.getLttd());
String location = vStationEntity.getLgtd() + "," + vStationEntity.getLttd();
weatherService.getWeather3d(location);
} catch (Exception e) {
log.error("{}获取三日天气失败,位置信息为:{},{}", vStationEntity.getName(), vStationEntity.getLgtd(), vStationEntity.getLttd());
log.error("获取三日天气失败", e);
}
catch (Exception e) {
e.printStackTrace();
XxlJobLogger.log(vStationEntity.getName()+"获取三日天气失败,位置信息为:"+ vStationEntity.getLgtd() + "," + vStationEntity.getLttd());
} finally {
}
finally {
downLatch.countDown();
}
}));
@ -121,7 +135,6 @@ public class StationWeatherSchedule {
/**
* 获取各站点下实况天气 存入缓存 @Scheduled(cron = "0 0 0/1 * * ?")
*
* @return
* @throws InterruptedException
*/
@ -135,10 +148,12 @@ public class StationWeatherSchedule {
XxlJobLogger.log(vStationEntity.getName()+"获取实时天气开始,位置信息为:"+ vStationEntity.getLgtd() + "," + vStationEntity.getLttd());
String location = vStationEntity.getLgtd() + "," + vStationEntity.getLttd();
weatherService.getWeatherNow(location);
} catch (Exception e) {
log.error("获取实时天气失败", e);
}
catch(Exception e) {
e.printStackTrace();
XxlJobLogger.log(vStationEntity.getName()+"获取实时天气失败,位置信息为:"+ vStationEntity.getLgtd() + "," + vStationEntity.getLttd());
} finally {
}
finally {
downLatch.countDown();
}
}));

Loading…
Cancel
Save