|
@@ -126,10 +126,11 @@ public class ScheduledService {
|
|
|
return count;
|
|
return count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //定时保存设备传感器假数据 后续删除
|
|
|
|
|
- @Scheduled(cron="0 0 1 1/5 * ?")
|
|
|
|
|
|
|
+ //定时更新token
|
|
|
|
|
+ @Scheduled(cron="0 30 0 * * ?")
|
|
|
@RequestMapping("/updateAccessToken")
|
|
@RequestMapping("/updateAccessToken")
|
|
|
public void updateAccessToken() {
|
|
public void updateAccessToken() {
|
|
|
|
|
+ Configs configs=configsService.getOne(new QueryWrapper<Configs>().eq("name","ys_access_token"));
|
|
|
RestTemplate client = new RestTemplate();
|
|
RestTemplate client = new RestTemplate();
|
|
|
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
|
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
|
|
map.add("appKey", appKey);
|
|
map.add("appKey", appKey);
|
|
@@ -142,14 +143,19 @@ public class ScheduledService {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
String status = String.valueOf(jsonObject.get("code"));
|
|
String status = String.valueOf(jsonObject.get("code"));
|
|
|
if("200".equals(status)){
|
|
if("200".equals(status)){
|
|
|
- Configs configs=configsService.getOne(new QueryWrapper<Configs>().eq("name","ys_access_token"));
|
|
|
|
|
configs.setValue(jsonObject.getString("data"));
|
|
configs.setValue(jsonObject.getString("data"));
|
|
|
- boolean a=configsService.saveOrUpdate(configs);
|
|
|
|
|
- logger.info("更新accesstoken返回结果:"+a);
|
|
|
|
|
|
|
+ if(configs.getId()!=null){
|
|
|
|
|
+ boolean a=configsService.updateById(configs);
|
|
|
|
|
+ logger.info("更新accesstoken返回结果:"+a);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ boolean a=configsService.save(configs);
|
|
|
|
|
+ logger.info("插入accesstoken返回结果:"+a);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //定时保存设备传感器假数据 后续删除
|
|
|
|
|
|
|
+ //定时更新视频地址
|
|
|
@Scheduled(cron="0 0 1 * * ?")
|
|
@Scheduled(cron="0 0 1 * * ?")
|
|
|
@RequestMapping("/updatePicture")
|
|
@RequestMapping("/updatePicture")
|
|
|
public void updatePicture() {
|
|
public void updatePicture() {
|
|
@@ -158,6 +164,13 @@ public class ScheduledService {
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(configs.getValue());
|
|
JSONObject jsonObject1 = JSONObject.parseObject(configs.getValue());
|
|
|
String accessToken =jsonObject1.getString("accessToken");
|
|
String accessToken =jsonObject1.getString("accessToken");
|
|
|
logger.info("查询accesstoken返回结果:"+accessToken);
|
|
logger.info("查询accesstoken返回结果:"+accessToken);
|
|
|
|
|
+ Long time =jsonObject1.getLong("expireTime");
|
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
|
|
+ if (time<l){
|
|
|
|
|
+ this.updateAccessToken();
|
|
|
|
|
+ configs=configsService.getOne(new QueryWrapper<Configs>().eq("name","ys_access_token"));
|
|
|
|
|
+ accessToken=JSONObject.parseObject(configs.getValue()).getString("accessToken");
|
|
|
|
|
+ }
|
|
|
List<Devices> devicesList = devicesService.list(new QueryWrapper<>());
|
|
List<Devices> devicesList = devicesService.list(new QueryWrapper<>());
|
|
|
for (Devices devices:devicesList){
|
|
for (Devices devices:devicesList){
|
|
|
String[] arr=devices.getDeviceSerial().split(",");
|
|
String[] arr=devices.getDeviceSerial().split(",");
|
|
@@ -173,7 +186,7 @@ public class ScheduledService {
|
|
|
//header.setBearerAuth(request.getHeader("Authorization").replace("Bearer ",""));
|
|
//header.setBearerAuth(request.getHeader("Authorization").replace("Bearer ",""));
|
|
|
HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(map, header);
|
|
HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(map, header);
|
|
|
String result = client.postForObject(url+"/v2/live/address/get", httpEntity, String.class);
|
|
String result = client.postForObject(url+"/v2/live/address/get", httpEntity, String.class);
|
|
|
- logger.info("获取accesstoken返回结果"+result);
|
|
|
|
|
|
|
+ logger.info("获取视频链接返回结果"+result);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
String status = String.valueOf(jsonObject.get("code"));
|
|
String status = String.valueOf(jsonObject.get("code"));
|
|
|
if("200".equals(status)){
|
|
if("200".equals(status)){
|