parent
f5673ec512
commit
675e353d46
|
@ -2,9 +2,11 @@ package com.hisense.monitormanage.controller;
|
||||||
|
|
||||||
import com.hisense.monitormanage.dto.ChengguanDto;
|
import com.hisense.monitormanage.dto.ChengguanDto;
|
||||||
import com.hisense.monitormanage.dto.ScenicCameraDto;
|
import com.hisense.monitormanage.dto.ScenicCameraDto;
|
||||||
|
import com.hisense.monitormanage.entity.CameraChannel;
|
||||||
import com.hisense.monitormanage.entity.Picture;
|
import com.hisense.monitormanage.entity.Picture;
|
||||||
import com.hisense.monitormanage.entity.Project;
|
import com.hisense.monitormanage.entity.Project;
|
||||||
import com.hisense.monitormanage.entity.Result;
|
import com.hisense.monitormanage.entity.Result;
|
||||||
|
import com.hisense.monitormanage.mapper.CameraChannelMapper;
|
||||||
import com.hisense.monitormanage.mapper.CameraMapper;
|
import com.hisense.monitormanage.mapper.CameraMapper;
|
||||||
import com.hisense.monitormanage.mapper.ProjectMapper;
|
import com.hisense.monitormanage.mapper.ProjectMapper;
|
||||||
import com.hisense.monitormanage.mapper.ScenicMapper;
|
import com.hisense.monitormanage.mapper.ScenicMapper;
|
||||||
|
@ -34,6 +36,9 @@ public class Controller {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MonitorService monitorService;
|
private MonitorService monitorService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CameraChannelMapper cameraChannelMapper;
|
||||||
|
|
||||||
@RequestMapping("all")
|
@RequestMapping("all")
|
||||||
public Object all(){
|
public Object all(){
|
||||||
List<Project> projects = projectMapper.selectList(null);
|
List<Project> projects = projectMapper.selectList(null);
|
||||||
|
@ -127,4 +132,28 @@ public class Controller {
|
||||||
map.put("location",location);
|
map.put("location",location);
|
||||||
return monitorService.reverseGeocode(map);
|
return monitorService.reverseGeocode(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("selectAll")
|
||||||
|
public Result selectAll(CameraChannel cameraChannel){
|
||||||
|
|
||||||
|
List<CameraChannel> list = cameraChannelMapper.selectAll(cameraChannel);
|
||||||
|
|
||||||
|
Result success = Result.success(list);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("selectById")
|
||||||
|
public Result selectById(String idtCameraChannel){
|
||||||
|
|
||||||
|
List<String> list = cameraChannelMapper.selectById(idtCameraChannel);
|
||||||
|
|
||||||
|
Result success = Result.success(list);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.hisense.monitormanage.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("t_camera_channel")
|
||||||
|
public class CameraChannel {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long idtCameraChannel;
|
||||||
|
|
||||||
|
private String channelCode;
|
||||||
|
|
||||||
|
private String channelId;
|
||||||
|
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
private String gpsX;
|
||||||
|
|
||||||
|
private String gpsY;
|
||||||
|
|
||||||
|
private Integer status;//1在线;0离线
|
||||||
|
|
||||||
|
private String nodeName;
|
||||||
|
|
||||||
|
private Integer checkStatus;//1正常;0异常
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.hisense.monitormanage.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.hisense.monitormanage.entity.CameraChannel;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
|
||||||
|
@Select("select c.* from t_camera_channel c where (c.gps_x NOT IN('0.0','0','') OR c.gps_y NOT IN('0.0','0','')) AND c.status != 0")
|
||||||
|
List<CameraChannel> selectAll(CameraChannel cameraChannel);
|
||||||
|
|
||||||
|
@Select("select * from t_camera_channel where idt_camera_channel = #{idtCameraChannel}")
|
||||||
|
List<String> selectById(@Param("idtCameraChannel") String idtCameraChannel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -3,8 +3,10 @@ package com.hisense.monitormanage.service;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hisense.monitormanage.entity.Camera;
|
import com.hisense.monitormanage.entity.Camera;
|
||||||
|
import com.hisense.monitormanage.entity.CameraChannel;
|
||||||
import com.hisense.monitormanage.entity.CameraScenic;
|
import com.hisense.monitormanage.entity.CameraScenic;
|
||||||
import com.hisense.monitormanage.entity.Result;
|
import com.hisense.monitormanage.entity.Result;
|
||||||
|
import com.hisense.monitormanage.mapper.CameraChannelMapper;
|
||||||
import com.hisense.monitormanage.mapper.CameraMapper;
|
import com.hisense.monitormanage.mapper.CameraMapper;
|
||||||
import com.hisense.monitormanage.mapper.CameraScenicMapper;
|
import com.hisense.monitormanage.mapper.CameraScenicMapper;
|
||||||
import com.hisense.monitormanage.mapper.ScenicMapper;
|
import com.hisense.monitormanage.mapper.ScenicMapper;
|
||||||
|
@ -48,6 +50,9 @@ public class MonitorService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CameraScenicMapper cameraScenicMapper;
|
private CameraScenicMapper cameraScenicMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CameraChannelMapper cameraChannelMapper;
|
||||||
|
|
||||||
@Value("${hwx.file.work-path}")
|
@Value("${hwx.file.work-path}")
|
||||||
private String fileDir;
|
private String fileDir;
|
||||||
@Value("${hwx.file.pic-host}")
|
@Value("${hwx.file.pic-host}")
|
||||||
|
@ -60,6 +65,7 @@ public class MonitorService {
|
||||||
|
|
||||||
final private String userName = "yunnaoshuzidizuo";
|
final private String userName = "yunnaoshuzidizuo";
|
||||||
final private String password = "Admin@123";
|
final private String password = "Admin@123";
|
||||||
|
final private String monitorDomain = "http://10.132.191.3:8314";
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
|
@ -68,7 +74,7 @@ public class MonitorService {
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init(){
|
public void init(){
|
||||||
|
|
||||||
String loginUrl = "http://10.132.191.3:8314/videoService/accounts/authorize";
|
String loginUrl = monitorDomain + "/videoService/accounts/authorize";
|
||||||
HashMap<String, String> loginParam = new HashMap<>();
|
HashMap<String, String> loginParam = new HashMap<>();
|
||||||
loginParam.put("userName", userName);
|
loginParam.put("userName", userName);
|
||||||
loginParam.put("clientType", "winpc");
|
loginParam.put("clientType", "winpc");
|
||||||
|
@ -125,7 +131,7 @@ public class MonitorService {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
String keepaliveUrl = "http://10.132.191.3:8314/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);
|
||||||
|
|
||||||
|
@ -248,7 +254,7 @@ public class MonitorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private BufferedImage capturecreenshot(String code) throws IOException {
|
private BufferedImage capturecreenshot(String code) throws IOException {
|
||||||
String url = "http://10.132.191.3:8314/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);
|
||||||
|
@ -353,5 +359,57 @@ public class MonitorService {
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static public List cameras = new LinkedList<Map>();
|
||||||
|
|
||||||
|
public void videoService(String parentId, String path)throws IOException{
|
||||||
|
|
||||||
|
String url = monitorDomain + "/videoService/devicesManager/deviceTree?nodeType=1&typeCode=01;0;ALL;ALL&id=" + parentId;
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
||||||
|
headers.add("X-Subject-Token",token);
|
||||||
|
|
||||||
|
ResponseEntity<List> forEntity = null;
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class );
|
||||||
|
break;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("重试次数:{} url:{}",i,url);
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forEntity == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
List<Map> results = forEntity.getBody();
|
||||||
|
|
||||||
|
// log.debug("response {}", JSONObject.toJSONString(results));
|
||||||
|
String sep = "->";
|
||||||
|
|
||||||
|
for (Map result : results) {
|
||||||
|
Boolean isParent = (Boolean) result.get("isParent");
|
||||||
|
|
||||||
|
if (isParent){
|
||||||
|
videoService((String) result.get("id"),path + sep + result.get("name"));
|
||||||
|
}else {
|
||||||
|
if (result.get("channelId") != null){
|
||||||
|
CameraChannel cameraChannel = JSONObject.parseObject(JSONObject.toJSONString(result), CameraChannel.class);
|
||||||
|
|
||||||
|
if (path != null && path.startsWith(sep)) {
|
||||||
|
path = path.substring(sep.length());
|
||||||
|
}
|
||||||
|
cameraChannel.setNodeName(path);
|
||||||
|
cameraChannelMapper.insert(cameraChannel);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.hisense.monitormanage;
|
package com.hisense.monitormanage;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hisense.monitormanage.service.MonitorService;
|
import com.hisense.monitormanage.service.MonitorService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -26,4 +28,13 @@ class MonitorManageApplicationTests {
|
||||||
monitorService.reverseGeocode(map);
|
monitorService.reverseGeocode(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void videoService()throws IOException {
|
||||||
|
|
||||||
|
monitorService.videoService("","");
|
||||||
|
|
||||||
|
System.out.println(JSONObject.toJSONString(MonitorService.cameras));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue