查询摄像头详细信息优化

添加订阅任务下发接口
This commit is contained in:
wuweida 2022-05-16 15:16:04 +08:00
parent 8d052e3918
commit f2aff62d51
5 changed files with 131 additions and 85 deletions

View File

@ -1,5 +1,6 @@
package com.hisense.monitormanage.controller;
import com.alibaba.fastjson.JSONObject;
import com.hisense.monitormanage.dto.*;
import com.hisense.monitormanage.entity.*;
import com.hisense.monitormanage.mapper.*;
@ -130,14 +131,14 @@ public class Controller {
}
/**
* 根据channelId查询摄像头详细信息
* @param channelId
* 根据channelCode查询摄像头详细信息
* @param channelCode
* @return
*/
@RequestMapping("selectByChannelId")
public Result selectByChannelId(String channelId){
@RequestMapping("selectByChannelCode")
public Result selectByChannelCode(String channelCode){
List<CameraChannelDto1> list = cameraChannelMapper.selectByChannelId(channelId);
List<CameraChannelDto1> list = cameraChannelMapper.selectByChannelCode(channelCode);
Result success = Result.success(list);
@ -167,9 +168,9 @@ public class Controller {
* @return
*/
@RequestMapping("selectByParentId")
public Result selectByParentId(String parentId){
public Result selectByParentId(String parentId,String checkStatus){
List<CameraChannel> list = cameraChannelMapper.selectByParentId(parentId);
List<CameraChannel> list = cameraChannelMapper.selectByParentId(parentId,checkStatus);
Result success = Result.success(list);
@ -266,6 +267,26 @@ public class Controller {
return success;
}
/**
* 订阅任务下发接口
* @return
*/
@RequestMapping("subscribe")
public JSONObject subscribe(){
return monitorService.subscribe();
}
/**
* 事件模板分页查询接口
* @return
*/
@RequestMapping("tamplate")
public JSONObject tamplate(){
return monitorService.template();
}
//查询视频点播巡检结果只取异常的
// @RequestMapping("listChannelPlayStates")
// public Result listChannelPlayStates(

View File

@ -7,11 +7,17 @@ public class ChannelLabelDto {
private String channelCode;
private String channelName;
private String gpsX;
private String gpsY;
private String checkStatus;
private String nodeName;
}

View File

@ -12,5 +12,6 @@ public class Label {
private String labelCode;
private String labelName;
private String capturePatternn;
private String used;
}

View File

@ -18,13 +18,14 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
List<CameraChannelDto> selectAll();
@Select("select cc.*,cp.pic_url from t_camera_channel cc LEFT JOIN t_channel_picture cp ON cc.channel_code=cp.channel_code where cc.channel_id = #{channelId}")
List<CameraChannelDto1> selectByChannelId(@Param("channelId") String channelId);
@Select("select cc.*,cp.pic_url from t_camera_channel cc LEFT JOIN t_channel_picture cp ON cc.channel_code=cp.channel_code where cc.channel_code = #{channelCode}")
List<CameraChannelDto1> selectByChannelCode(@Param("channelCode") String channelCode);
@Select("select * from t_camera_channel where parent_id = #{parentId}")
List<CameraChannel> selectByParentId(@Param("parentId") String parentId);
@Select("select * from t_camera_channel where parent_id = #{parentId} and check_status in (${checkStatus}) ")
List<CameraChannel> selectByParentId(@Param("parentId") String parentId,
@Param("checkStatus") String checkStatus);
@Select("select c.channel_code,c.gps_x,c.gps_y,c.node_name from t_camera_channel c where channel_code in " +
@Select("select c.* from t_camera_channel c where channel_code in " +
"(select b.channel_code from t_channel_mtm_label b where b.label_code = #{labelCode}) ")
List<ChannelLabelDto> selectLabel(@Param("labelCode") String labelCode);
//@Update("update t_camera_channel set state = list")
@ -40,8 +41,8 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
List<CameraChannel> selectByChannelName(String channelName);
@Select("select * from (select a.label_code,a.label_name,c.channel_code,c.channel_name from t_channel_mtm_label b JOIN t_label a JOIN t_camera_channel c " +
"ON a.label_code = b.label_code AND b.channel_code = c.channel_code where c.`status`!= 0) m where m.label_code in (#{labelCode},#{labelCode1}) ")
List<ChannelLabelDto> selectLabelAndChannel(@Param("labelCode") String labelCode,@Param("labelCode1") String labelCode1);
"ON a.label_code = b.label_code AND b.channel_code = c.channel_code where c.`status`!= 0) m where m.label_code in (${labelCode}) ")
List<ChannelLabelDto> selectLabelAndChannel(@Param("labelCode") String labelCode);
@Select("select cc.channel_code,cc.gps_x,cc.gps_y from t_camera_channel cc " +
"where (gps_x between #{gpsX} and #{gpsX1}) and (gps_y between #{gpsY} and #{gpsY1} )")

View File

@ -182,7 +182,7 @@ public class MonitorService {
try {
log.info("[monitor-capture]: start capture");
log.info("[monitor-capture]: start capture1");
List<Camera> cameras = cameraMapper.selectList(null);
cameras.forEach(camera -> {
@ -202,7 +202,7 @@ public class MonitorService {
}
});
log.info("[monitor-capture]: end capture");
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
exception.printStackTrace();
}
@ -213,9 +213,9 @@ public class MonitorService {
try {
log.info("[monitor-capture]: start capture");
log.info("[monitor-capture]: start capture1");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1009","1008");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1009,1008");
labels.forEach(label -> {
String channelCode = label.getChannelCode();
try {
@ -230,17 +230,21 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
channelPictureMapper.insert(picture);
}else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code",channelCode);
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture,queryWrapper);
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture");
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
exception.printStackTrace();
}
@ -253,7 +257,7 @@ public class MonitorService {
log.info("[monitor-capture]: start capture");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1004","1006");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1004,1006");
labels.forEach(label -> {
String channelCode = label.getChannelCode();
try {
@ -268,10 +272,14 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
channelPictureMapper.insert(picture);
}else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code",channelCode);
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture,queryWrapper);
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
@ -447,68 +455,77 @@ public class MonitorService {
}
}
//地名地址搜索服务的Suggest操作
public Result suggest(Map<String,Object> map){
String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/suggest?"+"text={text}&key={key}";
map.put("key",key);
//1.登录
//2.获取token
public String shangtangToken () {
String url = "http://10.132.191.54:10270/whale-open-api/tenant/token";
ResponseEntity<String> responseEntity;
try{
responseEntity = restTemplate.getForEntity(url, String.class,map);
HttpStatus statusCode = responseEntity.getStatusCode();
if(statusCode.is2xxSuccessful()){
return Result.success(responseEntity.getBody());
}else{
return Result.error(String.valueOf(statusCode.value()));
}
} catch (Exception e){
log.info("[suggest] exception:{}",e.getMessage());
return Result.error(e.getMessage());
}
}
//地名地址搜索服务的Geocode操作
public Result geocode(Map<String,Object> map){
String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/findAddressCandidates?"
+"SingleLine={SingleLine}&key={key}";
map.put("key",key);
ResponseEntity<String> responseEntity;
try{
responseEntity = restTemplate.getForEntity(url, String.class,map);
HttpStatus statusCode = responseEntity.getStatusCode();
if(statusCode.is2xxSuccessful()){
return Result.success(responseEntity.getBody());
}else{
return Result.error(String.valueOf(statusCode.value()));
}
} catch (Exception e){
log.info("[geocode] exception:{}",e.getMessage());
return Result.error(e.getMessage());
}
}
//地名地址搜索服务的reverseGeocode操作
public Result reverseGeocode(Map<String,Object> map){
String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/reverseGeocode?"
+"location={location}&key={key}";
map.put("key",key);
ResponseEntity<String> responseEntity;
Map<String,Object> map = new HashMap<>();
map.put("ksUserName","hisense");
map.put("ksUserPassWord","Admin@2022");
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.getForEntity(url, String.class, map);
HttpStatus statusCode = responseEntity.getStatusCode();
if(statusCode.is2xxSuccessful()){
return Result.success(responseEntity.getBody());
}else{
return Result.error(String.valueOf(statusCode.value()));
}
}catch (HttpClientErrorException e){
log.info("[reverseGeocode] exception:{}",e.getMessage());
return Result.error(e.getMessage());
responseEntity = restTemplate.postForEntity(url,map,JSONObject.class);
JSONObject body = responseEntity.getBody();
JSONObject data = body.getJSONObject("data");
String token = data.getString("token");
return token;
} catch (Exception e) {
log.info("[shangtangToken] exception:{}", e.getMessage());
return null;
}
}
//订阅任务下发接口
public JSONObject subscribe(){
String token = this.shangtangToken();
String url = "http://10.132.191.54:10270/whale-open-api/subscribe";
HttpHeaders headers = new HttpHeaders();
headers.add("token", token);
headers.add("tid","default");
Map<String,Object> map = new HashMap<>();
map.put("callBackUrl","http://15.2.23.205:7009/api/project/subscribe");
// map.put("certPubKey","");
map.put("subscribeType",1);
// map.put("taskId","serial");
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url,HttpMethod.POST,new HttpEntity<>(map,headers),JSONObject.class);
JSONObject body = responseEntity.getBody();
return body;
}catch (Exception e){
log.info( "[subscribe] exception:{}",e.getMessage());
return null;
}
}
//事件模板分页查询接口
public JSONObject template(){
//String token = this.shangtangToken();
String url = "http://10.132.191.54:10270/whale-open-api/scenario/event/template?pageNum=1&pageSize=1000";
HttpHeaders headers = new HttpHeaders();
headers.add("token","506eaf5d5d4a4cddb18f0370d906e22f");
headers.add("tid","default");
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url,HttpMethod.GET,new HttpEntity<>(headers),JSONObject.class);
JSONObject jsonObject = responseEntity.getBody();
return jsonObject;
} catch (Exception e) {
log.info("[template] exception:{}", e.getMessage());
return null;
}
}
//查询视频点播巡检结果
@Scheduled(cron="0 5 6 * * ?")
public Result listChannelPlayStates(){