查询摄像头详细信息优化

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

View File

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

View File

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

View File

@ -18,13 +18,14 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
List<CameraChannelDto> selectAll(); 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}") @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> selectByChannelId(@Param("channelId") String channelId); List<CameraChannelDto1> selectByChannelCode(@Param("channelCode") String channelCode);
@Select("select * from t_camera_channel where parent_id = #{parentId}") @Select("select * from t_camera_channel where parent_id = #{parentId} and check_status in (${checkStatus}) ")
List<CameraChannel> selectByParentId(@Param("parentId") String parentId); 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}) ") "(select b.channel_code from t_channel_mtm_label b where b.label_code = #{labelCode}) ")
List<ChannelLabelDto> selectLabel(@Param("labelCode") String labelCode); List<ChannelLabelDto> selectLabel(@Param("labelCode") String labelCode);
//@Update("update t_camera_channel set state = list") //@Update("update t_camera_channel set state = list")
@ -40,8 +41,8 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
List<CameraChannel> selectByChannelName(String channelName); 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 " + @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}) ") "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,@Param("labelCode1") String labelCode1); List<ChannelLabelDto> selectLabelAndChannel(@Param("labelCode") String labelCode);
@Select("select cc.channel_code,cc.gps_x,cc.gps_y from t_camera_channel cc " + @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} )") "where (gps_x between #{gpsX} and #{gpsX1}) and (gps_y between #{gpsY} and #{gpsY1} )")

View File

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