不要阻塞程序启动!!!
This commit is contained in:
parent
cd082d34d2
commit
ddc3417007
|
@ -10,10 +10,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api/project")
|
@RequestMapping("api/project")
|
||||||
@Api(tags="视频流")
|
@Api(tags = "视频流")
|
||||||
public class FileController {
|
public class FileController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -21,21 +22,22 @@ public class FileController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据摄像头标识获取视频流
|
* 根据摄像头标识获取视频流
|
||||||
|
*
|
||||||
* @param channelCode
|
* @param channelCode
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@GetMapping("file")
|
@GetMapping("file")
|
||||||
@ApiOperation("根据摄像头标识获取视频流")
|
@ApiOperation("根据摄像头标识获取视频流")
|
||||||
public Result File(String channelCode)throws IOException {
|
public Result File(String channelCode) throws IOException {
|
||||||
String s = monitorService.fileCode(channelCode);
|
String s = monitorService.fileCode(channelCode);
|
||||||
Result success = Result.success(s);
|
Result success = Result.success(s);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("token")
|
@GetMapping("token")
|
||||||
public Result token( ) {
|
public Result token() throws ExecutionException, InterruptedException {
|
||||||
String s = monitorService.init();
|
String s = monitorService.init().get();
|
||||||
Result success = Result.success(s);
|
Result success = Result.success(s);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.time.ZoneOffset;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -86,19 +87,19 @@ public class MonitorService {
|
||||||
static int keepaliveCount = 16;
|
static int keepaliveCount = 16;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public String init(){
|
public CompletableFuture<String> init() {
|
||||||
|
// 不要阻塞程序启动!!屮
|
||||||
try {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
return monitorLogin();
|
try {
|
||||||
}catch (Exception e){
|
return monitorLogin();
|
||||||
log.warn("摄像头登录异常,跳过", e);
|
} catch (Exception e) {
|
||||||
}
|
log.warn("摄像头登录异常,跳过", e);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public String monitorLogin(){
|
public String monitorLogin() {
|
||||||
|
|
||||||
String loginUrl = monitorDomain + "/videoService/accounts/authorize";
|
String loginUrl = monitorDomain + "/videoService/accounts/authorize";
|
||||||
HashMap<String, String> loginParam = new HashMap<>();
|
HashMap<String, String> loginParam = new HashMap<>();
|
||||||
|
@ -110,14 +111,14 @@ public class MonitorService {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<HashMap> loginResEntity = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>());
|
ResponseEntity<HashMap> loginResEntity = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>());
|
||||||
reponse = loginResEntity.getBody();
|
reponse = loginResEntity.getBody();
|
||||||
}catch (HttpClientErrorException e){
|
} catch (HttpClientErrorException e) {
|
||||||
if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) {
|
if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) {
|
||||||
String responseString = e.getResponseBodyAsString();
|
String responseString = e.getResponseBodyAsString();
|
||||||
reponse = JSONObject.parseObject(responseString, HashMap.class);
|
reponse = JSONObject.parseObject(responseString, HashMap.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reponse == null){
|
if (reponse == null) {
|
||||||
log.error("[monitor-capture]:" + "监控系统登录握手失败");
|
log.error("[monitor-capture]:" + "监控系统登录握手失败");
|
||||||
throw new RuntimeException("监控系统登录握手失败");
|
throw new RuntimeException("监控系统登录握手失败");
|
||||||
}
|
}
|
||||||
|
@ -125,22 +126,22 @@ public class MonitorService {
|
||||||
//登录
|
//登录
|
||||||
loginParam.putAll(reponse);
|
loginParam.putAll(reponse);
|
||||||
String sigin = SecureUtil.md5(password);
|
String sigin = SecureUtil.md5(password);
|
||||||
sigin = SecureUtil.md5(userName+sigin);
|
sigin = SecureUtil.md5(userName + sigin);
|
||||||
sigin = SecureUtil.md5(sigin);
|
sigin = SecureUtil.md5(sigin);
|
||||||
sigin = SecureUtil.md5(userName+":"+loginParam.get("realm")+":"+sigin);
|
sigin = SecureUtil.md5(userName + ":" + loginParam.get("realm") + ":" + sigin);
|
||||||
sigin = SecureUtil.md5(sigin+":"+loginParam.get("randomKey"));
|
sigin = SecureUtil.md5(sigin + ":" + loginParam.get("randomKey"));
|
||||||
loginParam.put("signature", sigin);
|
loginParam.put("signature", sigin);
|
||||||
|
|
||||||
reponse = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>()).getBody();
|
reponse = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>()).getBody();
|
||||||
if (reponse != null){
|
if (reponse != null) {
|
||||||
String token = (String) reponse.get("token");
|
String token = (String) reponse.get("token");
|
||||||
if (token== null || StringUtils.isEmpty(token)){
|
if (token == null || StringUtils.isEmpty(token)) {
|
||||||
log.error("[monitor-capture]:" + "监控系统登录失败");
|
log.error("[monitor-capture]:" + "监控系统登录失败");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
this.token = token;
|
this.token = token;
|
||||||
Integer duration = (Integer) reponse.get("duration");
|
Integer duration = (Integer) reponse.get("duration");
|
||||||
if (duration == null || duration < 20){
|
if (duration == null || duration < 20) {
|
||||||
log.error("[monitor-capture]:" + "监控系统失效时间异常" + duration);
|
log.error("[monitor-capture]:" + "监控系统失效时间异常" + duration);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -151,27 +152,27 @@ public class MonitorService {
|
||||||
|
|
||||||
//会话保活
|
//会话保活
|
||||||
Timer timer = new Timer("monitor-capture-keepalive");
|
Timer timer = new Timer("monitor-capture-keepalive");
|
||||||
timer.scheduleAtFixedRate(new TimerTask(){
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try{
|
try {
|
||||||
String keepaliveUrl = monitorDomain + "/videoService/accounts/token/keepalive";
|
String keepaliveUrl = monitorDomain + "/videoService/accounts/token/keepalive";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("X-Subject-Token",token);
|
headers.add("X-Subject-Token", token);
|
||||||
|
|
||||||
HashMap<Object, Object> keepaliveParam = new HashMap<>();
|
HashMap<Object, Object> keepaliveParam = new HashMap<>();
|
||||||
keepaliveParam.put("token", token);
|
keepaliveParam.put("token", token);
|
||||||
HttpEntity<Object> httpEntity = new HttpEntity<>(keepaliveParam, headers);
|
HttpEntity<Object> httpEntity = new HttpEntity<>(keepaliveParam, headers);
|
||||||
restTemplate.put(keepaliveUrl, httpEntity);
|
restTemplate.put(keepaliveUrl, httpEntity);
|
||||||
|
|
||||||
if (keepaliveCount++ > 12){//大概36分钟输出一次日志
|
if (keepaliveCount++ > 12) {//大概36分钟输出一次日志
|
||||||
log.info("[monitor-capture]: keepalive success");
|
log.info("[monitor-capture]: keepalive success");
|
||||||
keepaliveCount = 0;
|
keepaliveCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.info("[monitor-capture]: keepalive faild, restart.....");
|
log.info("[monitor-capture]: keepalive faild, restart.....");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
@ -181,7 +182,6 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 0, duration * 1000);
|
}, 0, duration * 1000);
|
||||||
}
|
}
|
||||||
|
@ -208,14 +208,14 @@ public class MonitorService {
|
||||||
camera.setPic(picUrl);
|
camera.setPic(picUrl);
|
||||||
camera.setCaptureTime(new Date());
|
camera.setCaptureTime(new Date());
|
||||||
cameraMapper.updateById(camera);
|
cameraMapper.updateById(camera);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +cameraCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + cameraCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,25 +243,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点8:50抓图
|
* 特定摊点8:50抓图
|
||||||
*/
|
*/
|
||||||
|
@ -285,25 +286,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点9:50抓图
|
* 特定摊点9:50抓图
|
||||||
*/
|
*/
|
||||||
|
@ -327,25 +329,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点9:20抓图
|
* 特定摊点9:20抓图
|
||||||
*/
|
*/
|
||||||
|
@ -369,25 +372,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点11:20抓图
|
* 特定摊点11:20抓图
|
||||||
*/
|
*/
|
||||||
|
@ -411,25 +415,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点12:20抓图
|
* 特定摊点12:20抓图
|
||||||
*/
|
*/
|
||||||
|
@ -453,25 +458,26 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特定摊点19:20抓图
|
* 特定摊点19:20抓图
|
||||||
*/
|
*/
|
||||||
|
@ -495,22 +501,22 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,22 +544,22 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,22 +589,22 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture1");
|
log.info("[monitor-capture]: end capture1");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,22 +634,22 @@ public class MonitorService {
|
||||||
picture.setPicUrl(picUrl);
|
picture.setPicUrl(picUrl);
|
||||||
/*picture.setInsertTime(new Date());
|
/*picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.insert(picture);*/
|
channelPictureMapper.insert(picture);*/
|
||||||
if (channelCode == null){
|
if (channelCode == null) {
|
||||||
channelPictureMapper.insert(picture);
|
channelPictureMapper.insert(picture);
|
||||||
}else {
|
} else {
|
||||||
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("channel_code", channelCode);
|
queryWrapper.eq("channel_code", channelCode);
|
||||||
picture.setInsertTime(new Date());
|
picture.setInsertTime(new Date());
|
||||||
channelPictureMapper.update(picture, queryWrapper);
|
channelPictureMapper.update(picture, queryWrapper);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
|
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: end capture");
|
log.info("[monitor-capture]: end capture");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,7 +686,7 @@ public class MonitorService {
|
||||||
personImage.put("img_base64", imgBase64);
|
personImage.put("img_base64", imgBase64);
|
||||||
ResponseEntity<HashMap> responseEntity = restTemplate.postForEntity(personNumUrl, personImage, HashMap.class);
|
ResponseEntity<HashMap> responseEntity = restTemplate.postForEntity(personNumUrl, personImage, HashMap.class);
|
||||||
HashMap body = responseEntity.getBody();
|
HashMap body = responseEntity.getBody();
|
||||||
if (body != null && (Integer) body.get("code") == 200){
|
if (body != null && (Integer) body.get("code") == 200) {
|
||||||
Map data = (Map) body.get("data");
|
Map data = (Map) body.get("data");
|
||||||
Integer personNum = (Integer) data.get("person_num");
|
Integer personNum = (Integer) data.get("person_num");
|
||||||
CameraScenic cameraScenic = new CameraScenic();
|
CameraScenic cameraScenic = new CameraScenic();
|
||||||
|
@ -688,33 +694,33 @@ public class MonitorService {
|
||||||
cameraScenic.setPersonNum(personNum);
|
cameraScenic.setPersonNum(personNum);
|
||||||
|
|
||||||
CameraScenic cs = cameraScenicMapper.selectById(cameraCode);
|
CameraScenic cs = cameraScenicMapper.selectById(cameraCode);
|
||||||
if (cs == null){
|
if (cs == null) {
|
||||||
cameraScenicMapper.insert(cameraScenic);
|
cameraScenicMapper.insert(cameraScenic);
|
||||||
}else {
|
} else {
|
||||||
cameraScenicMapper.updateById(cameraScenic);
|
cameraScenicMapper.updateById(cameraScenic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e){
|
|
||||||
|
|
||||||
log.info( "[monitor-capture] " +cameraCode + " 人流识别失败 " + e.getMessage());
|
log.info("[monitor-capture] " + cameraCode + " 人流识别失败 " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("[monitor-capture]: startScenic end capture");
|
log.info("[monitor-capture]: startScenic end capture");
|
||||||
}catch (Exception exception){
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedImage capturecreenshot(String code) throws IOException {
|
private BufferedImage capturecreenshot(String code) throws IOException {
|
||||||
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
|
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("X-Subject-Token",token);
|
headers.add("X-Subject-Token", token);
|
||||||
|
|
||||||
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class );
|
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class);
|
||||||
|
|
||||||
HashMap body = forEntity.getBody();
|
HashMap body = forEntity.getBody();
|
||||||
|
|
||||||
|
@ -734,7 +740,7 @@ public class MonitorService {
|
||||||
|
|
||||||
int frameIndex = 60;
|
int frameIndex = 60;
|
||||||
Java2DFrameConverter converter = new Java2DFrameConverter();
|
Java2DFrameConverter converter = new Java2DFrameConverter();
|
||||||
while (true){
|
while (true) {
|
||||||
Frame frame = grabber.grabImage();
|
Frame frame = grabber.grabImage();
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
log.debug("grabber 跳帧:" + frameIndex);
|
log.debug("grabber 跳帧:" + frameIndex);
|
||||||
|
@ -744,23 +750,24 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
} finally {
|
||||||
grabber.stop();
|
grabber.stop();
|
||||||
grabber.release();
|
grabber.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public String fileCode(String code)throws IOException{
|
|
||||||
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
|
public String fileCode(String code) throws IOException {
|
||||||
|
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("X-Subject-Token",token);
|
headers.add("X-Subject-Token", token);
|
||||||
|
|
||||||
System.out.println(token);
|
System.out.println(token);
|
||||||
|
|
||||||
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class );
|
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class);
|
||||||
|
|
||||||
HashMap body = forEntity.getBody();
|
HashMap body = forEntity.getBody();
|
||||||
|
|
||||||
|
@ -779,17 +786,17 @@ public class MonitorService {
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
||||||
headers.add("X-Subject-Token",token);
|
headers.add("X-Subject-Token", token);
|
||||||
|
|
||||||
ResponseEntity<List> forEntity = null;
|
ResponseEntity<List> forEntity = null;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
try {
|
try {
|
||||||
forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class );
|
forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class);
|
||||||
break;
|
break;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("重试次数:{} url:{}",i,url);
|
log.error("重试次数:{} url:{}", i, url);
|
||||||
log.error(e);
|
log.error(e);
|
||||||
Thread.sleep(5*1000);
|
Thread.sleep(5 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,17 +809,17 @@ public class MonitorService {
|
||||||
for (Map result : results) {
|
for (Map result : results) {
|
||||||
Boolean isParent = (Boolean) result.get("isParent");
|
Boolean isParent = (Boolean) result.get("isParent");
|
||||||
|
|
||||||
if (isParent){
|
if (isParent) {
|
||||||
CameraOrganization cameraOrganization = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrganization.class);
|
CameraOrganization cameraOrganization = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrganization.class);
|
||||||
|
|
||||||
cameraOrgenMapper.insert(cameraOrganization);
|
cameraOrgenMapper.insert(cameraOrganization);
|
||||||
|
|
||||||
videoService((String) result.get("id"),path + sep + result.get("name"));
|
videoService((String) result.get("id"), path + sep + result.get("name"));
|
||||||
}else {
|
} else {
|
||||||
if (result.get("channelId") != null){
|
if (result.get("channelId") != null) {
|
||||||
CameraChannel cameraChannel = JSONObject.parseObject(JSONObject.toJSONString(result), CameraChannel.class);
|
CameraChannel cameraChannel = JSONObject.parseObject(JSONObject.toJSONString(result), CameraChannel.class);
|
||||||
|
|
||||||
String id = (String)result.get("orgCode");
|
String id = (String) result.get("orgCode");
|
||||||
|
|
||||||
if (path != null && path.startsWith(sep)) {
|
if (path != null && path.startsWith(sep)) {
|
||||||
path = path.substring(sep.length());
|
path = path.substring(sep.length());
|
||||||
|
@ -830,49 +837,49 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询视频点播巡检结果
|
//查询视频点播巡检结果
|
||||||
@Scheduled(cron="0 5 6 * * ?")
|
@Scheduled(cron = "0 5 6 * * ?")
|
||||||
public Result listChannelPlayStates(){
|
public Result listChannelPlayStates() {
|
||||||
//获取当前时间和前一天的UTC时间
|
//获取当前时间和前一天的UTC时间
|
||||||
Map<String,Object> condition = new HashMap<>();
|
Map<String, Object> condition = new HashMap<>();
|
||||||
ZonedDateTime endUTC = ZonedDateTime.now(ZoneOffset.UTC);
|
ZonedDateTime endUTC = ZonedDateTime.now(ZoneOffset.UTC);
|
||||||
ZonedDateTime startUTC = endUTC.minusDays(60);
|
ZonedDateTime startUTC = endUTC.minusDays(60);
|
||||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
|
||||||
condition.put("checkStatus",0);
|
condition.put("checkStatus", 0);
|
||||||
condition.put("startTime",dateTimeFormatter.format(startUTC));
|
condition.put("startTime", dateTimeFormatter.format(startUTC));
|
||||||
condition.put("endTime",dateTimeFormatter.format(endUTC));
|
condition.put("endTime", dateTimeFormatter.format(endUTC));
|
||||||
//组装查询条件,经过验证pageSize设置过大也没效果,最大512
|
//组装查询条件,经过验证pageSize设置过大也没效果,最大512
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("condition",condition);
|
map.put("condition", condition);
|
||||||
map.put("page",1);
|
map.put("page", 1);
|
||||||
map.put("pageSize",500);//最多一次512条
|
map.put("pageSize", 500);//最多一次512条
|
||||||
//查询路径和请求头信息
|
//查询路径和请求头信息
|
||||||
String url = monitorDomain + "/nms/api/channel/play/list";
|
String url = monitorDomain + "/nms/api/channel/play/list";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("X-Subject-Token",token);
|
headers.add("X-Subject-Token", token);
|
||||||
|
|
||||||
//查询数据的页数
|
//查询数据的页数
|
||||||
int pageCount = 0;
|
int pageCount = 0;
|
||||||
//查询结果
|
//查询结果
|
||||||
List<Map> list = new ArrayList<>();
|
List<Map> list = new ArrayList<>();
|
||||||
|
|
||||||
HttpEntity<Map<String,Object>> request = new HttpEntity<>(map,headers);
|
HttpEntity<Map<String, Object>> request = new HttpEntity<>(map, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class );
|
ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
|
||||||
JSONObject entityBody = responseEntity.getBody();
|
JSONObject entityBody = responseEntity.getBody();
|
||||||
if (entityBody.get("i18n") != null && entityBody.get("i18n").toString() == "error"){
|
if (entityBody.get("i18n") != null && entityBody.get("i18n").toString() == "error") {
|
||||||
log.info("{}程序异常{}",entityBody.get("message").toString());
|
log.info("{}程序异常{}", entityBody.get("message").toString());
|
||||||
}
|
}
|
||||||
List<Map> results = (List<Map>) entityBody.get("results");
|
List<Map> results = (List<Map>) entityBody.get("results");
|
||||||
if(!results.isEmpty()){
|
if (!results.isEmpty()) {
|
||||||
list.addAll(results);
|
list.addAll(results);
|
||||||
pageCount = entityBody.getIntValue("totalCount")/500 + 1;
|
pageCount = entityBody.getIntValue("totalCount") / 500 + 1;
|
||||||
}
|
}
|
||||||
for(int i = 2;i<=pageCount;i++){
|
for (int i = 2; i <= pageCount; i++) {
|
||||||
map.put("page",i);
|
map.put("page", i);
|
||||||
HttpEntity<Map<String,Object>> request2 = new HttpEntity<>(map,headers);
|
HttpEntity<Map<String, Object>> request2 = new HttpEntity<>(map, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class );
|
ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class);
|
||||||
JSONObject entityBody2 = responseEntity2.getBody();
|
JSONObject entityBody2 = responseEntity2.getBody();
|
||||||
List<Map> results2 = (List<Map>) entityBody2.get("results");
|
List<Map> results2 = (List<Map>) entityBody2.get("results");
|
||||||
if(!results2.isEmpty()){
|
if (!results2.isEmpty()) {
|
||||||
list.addAll(results);
|
list.addAll(results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -887,29 +894,29 @@ public class MonitorService {
|
||||||
//通过set对channel_code去重
|
//通过set对channel_code去重
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
|
|
||||||
for(Map m:list){
|
for (Map m : list) {
|
||||||
set.add(m.get("channelCode").toString());
|
set.add(m.get("channelCode").toString());
|
||||||
}
|
}
|
||||||
List<String> lists = new ArrayList<>(set.size());
|
List<String> lists = new ArrayList<>(set.size());
|
||||||
lists.addAll(set);
|
lists.addAll(set);
|
||||||
//根据channel_code对t_camera_channel表的status字段进行更新(0)
|
//根据channel_code对t_camera_channel表的status字段进行更新(0)
|
||||||
List<List<String>> listMap = Lists.partition(lists,100);
|
List<List<String>> listMap = Lists.partition(lists, 100);
|
||||||
for(List<String> ll:listMap){
|
for (List<String> ll : listMap) {
|
||||||
cameraChannelMapper.updateCameraStatus(ll);
|
cameraChannelMapper.updateCameraStatus(ll);
|
||||||
}
|
}
|
||||||
log.info("{} 查询视频点播巡检成功,发现异常数量:{}",LocalDateTime.now(),set.size());
|
log.info("{} 查询视频点播巡检成功,发现异常数量:{}", LocalDateTime.now(), set.size());
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
//道路统计数据与排名,调用公开接口
|
//道路统计数据与排名,调用公开接口
|
||||||
public List<Map> roadData(){
|
public List<Map> roadData() {
|
||||||
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
|
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
map.put("dt",this.dateTimeStr());
|
map.put("dt", this.dateTimeStr());
|
||||||
map.put("groupId",1);
|
map.put("groupId", 1);
|
||||||
map.put("timeType","日");
|
map.put("timeType", "日");
|
||||||
|
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
List<Map> list = new ArrayList<>();
|
List<Map> list = new ArrayList<>();
|
||||||
|
@ -932,7 +939,7 @@ public class MonitorService {
|
||||||
|
|
||||||
//启迪数据中台相关
|
//启迪数据中台相关
|
||||||
//1.登录
|
//1.登录
|
||||||
public String qidiToken () {
|
public String qidiToken() {
|
||||||
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
|
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
|
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
|
||||||
|
@ -963,32 +970,32 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//渣土车轨迹数据,最新的
|
//渣土车轨迹数据,最新的
|
||||||
public List<Map> resCatalogApplyZTYS () {
|
public List<Map> resCatalogApplyZTYS() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
search.put("opt","LIKE");
|
search.put("opt", "LIKE");
|
||||||
search.put("key","UPLOADTIME");
|
search.put("key", "UPLOADTIME");
|
||||||
search.put("val",this.dateStr());
|
search.put("val", this.dateStr());
|
||||||
|
|
||||||
// search.put("opt","EQ");
|
// search.put("opt","EQ");
|
||||||
// search.put("key","SPEED");
|
// search.put("key","SPEED");
|
||||||
// search.put("val","0");
|
// search.put("val","0");
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
|
||||||
|
|
||||||
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
|
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
try {
|
try {
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,map);
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class, map);
|
||||||
|
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}",jsonArray.size());
|
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}", jsonArray.size());
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
|
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
|
||||||
|
@ -997,26 +1004,26 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫车轨迹数据
|
//环卫车轨迹数据
|
||||||
public List<Map> resCatalogApplyHJWS () {
|
public List<Map> resCatalogApplyHJWS() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
search.put("opt","LIKE");
|
search.put("opt", "LIKE");
|
||||||
search.put("key","updatetime");
|
search.put("key", "updatetime");
|
||||||
search.put("val",this.dateStr());
|
search.put("val", this.dateStr());
|
||||||
// search.put("opt","EQ");
|
// search.put("opt","EQ");
|
||||||
// search.put("key","SIMKH");
|
// search.put("key","SIMKH");
|
||||||
// search.put("val","13302959786");
|
// search.put("val","13302959786");
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
try {
|
try {
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
@ -1027,22 +1034,22 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//工地信息
|
//工地信息
|
||||||
public List<Map> resCatalogApplyGDYS () {
|
public List<Map> resCatalogApplyGDYS() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
search.put("opt","LIKE");
|
search.put("opt", "LIKE");
|
||||||
search.put("key","updatetime");
|
search.put("key", "updatetime");
|
||||||
search.put("val",this.dateStr());
|
search.put("val", this.dateStr());
|
||||||
// search.put("opt","EQ");
|
// search.put("opt","EQ");
|
||||||
// search.put("key","SSDQ");
|
// search.put("key","SSDQ");
|
||||||
// search.put("val","西海岸新区");
|
// search.put("val","西海岸新区");
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
@ -1059,22 +1066,22 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫车辆数据1,基础
|
//环卫车辆数据1,基础
|
||||||
public List<Map> resCatalogApplyHJWSBase () {
|
public List<Map> resCatalogApplyHJWSBase() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
// search.put("opt","LIKE");
|
// search.put("opt","LIKE");
|
||||||
// search.put("key","updatetime");
|
// search.put("key","updatetime");
|
||||||
// search.put("val",this.dateStr());
|
// search.put("val",this.dateStr());
|
||||||
search.put("opt","EQ");
|
search.put("opt", "EQ");
|
||||||
search.put("key","SSQY");
|
search.put("key", "SSQY");
|
||||||
search.put("val","胶州市");
|
search.put("val", "胶州市");
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
|
@ -1091,24 +1098,24 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
|
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
|
||||||
public List<Map> resCatalogApplyHJWSZY () {
|
public List<Map> resCatalogApplyHJWSZY() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1";
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
// search.put("opt","LIKE");
|
// search.put("opt","LIKE");
|
||||||
// search.put("key","ZYRQ");
|
// search.put("key","ZYRQ");
|
||||||
// search.put("val",this.dateStr());
|
// search.put("val",this.dateStr());
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
try {
|
try {
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
|
||||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
|
@ -1119,39 +1126,40 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception{
|
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
List<Map> maps = new ArrayList<>();
|
List<Map> maps = new ArrayList<>();
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
JSONObject search = new JSONObject();
|
JSONObject search = new JSONObject();
|
||||||
search.put("opt","GT");
|
search.put("opt", "GT");
|
||||||
search.put("key","updatetime");
|
search.put("key", "updatetime");
|
||||||
search.put("val",updatetime);
|
search.put("val", updatetime);
|
||||||
map.put("json",search);
|
map.put("json", search);
|
||||||
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||||
ResponseEntity<JSONObject> responseEntity;
|
ResponseEntity<JSONObject> responseEntity;
|
||||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
|
||||||
JSONObject jsonObject = responseEntity.getBody();
|
JSONObject jsonObject = responseEntity.getBody();
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||||
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||||
|
|
||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
//环卫道路明细数据
|
//环卫道路明细数据
|
||||||
public List<Map> resCatalogApplyHJWSRoad () {
|
public List<Map> resCatalogApplyHJWSRoad() {
|
||||||
String token = this.qidiToken();
|
String token = this.qidiToken();
|
||||||
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2";
|
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2";
|
||||||
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
|
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Authorization", "Bearer " + token);
|
headers.add("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
// JSONObject search = new JSONObject();
|
// JSONObject search = new JSONObject();
|
||||||
// search.put("opt","LIKE");
|
// search.put("opt","LIKE");
|
||||||
// search.put("key","updatetime");
|
// search.put("key","updatetime");
|
||||||
// search.put("val",this.dateStr());
|
// search.put("val",this.dateStr());
|
||||||
|
@ -1173,16 +1181,18 @@ public class MonitorService {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前日期的时间串,2022-05-08 00:00:00
|
//获取当前日期的时间串,2022-05-08 00:00:00
|
||||||
private String dateTimeStr(){
|
private String dateTimeStr() {
|
||||||
LocalDate localDate = LocalDate.now();
|
LocalDate localDate = LocalDate.now();
|
||||||
LocalDate yestDay = localDate.minusDays(1);
|
LocalDate yestDay = localDate.minusDays(1);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0);
|
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(), yestDay.getMonth(), yestDay.getDayOfMonth(), 0, 0, 0);
|
||||||
return dateTime.format(formatter);
|
return dateTime.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前日期的时间串,2022-05-08
|
//获取当前日期的时间串,2022-05-08
|
||||||
private String dateStr(){
|
private String dateStr() {
|
||||||
LocalDate localDate = LocalDate.now();
|
LocalDate localDate = LocalDate.now();
|
||||||
LocalDate yestDay = localDate.minusDays(1);
|
LocalDate yestDay = localDate.minusDays(1);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
|
Loading…
Reference in New Issue