|
|
|
@ -58,11 +58,11 @@ public class CameraService {
|
|
|
|
|
|
|
|
|
|
|
|
private CameraControlLoginModule cameraControlLoginModule;
|
|
|
|
private CameraControlLoginModule cameraControlLoginModule;
|
|
|
|
|
|
|
|
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule){
|
|
|
|
public void setCameraControlModule(CameraControlModule cameraControlModule) {
|
|
|
|
this.cameraControlModule = cameraControlModule;
|
|
|
|
this.cameraControlModule = cameraControlModule;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setCameraLoginModule(CameraControlLoginModule cameraControlLoginModule){
|
|
|
|
public void setCameraLoginModule(CameraControlLoginModule cameraControlLoginModule) {
|
|
|
|
this.cameraControlLoginModule = cameraControlLoginModule;
|
|
|
|
this.cameraControlLoginModule = cameraControlLoginModule;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -71,8 +71,8 @@ public class CameraService {
|
|
|
|
camera.setPassword(configProperties.getCameraConfig().getCameraPassword());
|
|
|
|
camera.setPassword(configProperties.getCameraConfig().getCameraPassword());
|
|
|
|
camera.setPort(configProperties.getCameraConfig().getCameraPort());
|
|
|
|
camera.setPort(configProperties.getCameraConfig().getCameraPort());
|
|
|
|
camera.setUpdateTime(LocalDateTime.now());
|
|
|
|
camera.setUpdateTime(LocalDateTime.now());
|
|
|
|
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/h264/ch1/sub/av_stream");
|
|
|
|
camera.setRtsp("rtsp://" + configProperties.getCameraConfig().getCameraUser() + ":" + configProperties.getCameraConfig().getCameraPassword() + "@" + camera.getIp() + ":554/h264/ch1/sub/av_stream");
|
|
|
|
if(StringUtils.isEmpty(camera.getRtcServer())){
|
|
|
|
if (StringUtils.isEmpty(camera.getRtcServer())) {
|
|
|
|
camera.setRtcServer("127.0.0.1");
|
|
|
|
camera.setRtcServer("127.0.0.1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
camera.setRtcServerPort(8083);
|
|
|
|
camera.setRtcServerPort(8083);
|
|
|
|
@ -88,12 +88,12 @@ public class CameraService {
|
|
|
|
public void edit(Camera camera) {
|
|
|
|
public void edit(Camera camera) {
|
|
|
|
camera.setUpdateTime(LocalDateTime.now());
|
|
|
|
camera.setUpdateTime(LocalDateTime.now());
|
|
|
|
camera.setPtzId(null);
|
|
|
|
camera.setPtzId(null);
|
|
|
|
if(StringUtils.isEmpty(camera.getRtcServer())){
|
|
|
|
if (StringUtils.isEmpty(camera.getRtcServer())) {
|
|
|
|
camera.setRtcServer("127.0.0.1");
|
|
|
|
camera.setRtcServer("127.0.0.1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
camera.setPort(configProperties.getCameraConfig().getCameraPort());
|
|
|
|
camera.setPort(configProperties.getCameraConfig().getCameraPort());
|
|
|
|
camera.setUser(configProperties.getCameraConfig().getCameraUser());
|
|
|
|
camera.setUser(configProperties.getCameraConfig().getCameraUser());
|
|
|
|
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/h264/ch1/sub/av_stream");
|
|
|
|
camera.setRtsp("rtsp://" + configProperties.getCameraConfig().getCameraUser() + ":" + configProperties.getCameraConfig().getCameraPassword() + "@" + camera.getIp() + ":554/h264/ch1/sub/av_stream");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
cameraMapper.updateById(camera);
|
|
|
|
cameraMapper.updateById(camera);
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
@ -110,10 +110,10 @@ public class CameraService {
|
|
|
|
public PageInfo<Camera> cameras(StreetSearch streetSearch) {
|
|
|
|
public PageInfo<Camera> cameras(StreetSearch streetSearch) {
|
|
|
|
PageHelper.startPage(streetSearch.getPageNum(), streetSearch.getPageSize());
|
|
|
|
PageHelper.startPage(streetSearch.getPageNum(), streetSearch.getPageSize());
|
|
|
|
List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0));
|
|
|
|
List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0));
|
|
|
|
if(cameras.size() > 0){
|
|
|
|
if (cameras.size() > 0) {
|
|
|
|
CountDownLatch latch = new CountDownLatch(cameras.size());
|
|
|
|
CountDownLatch latch = new CountDownLatch(cameras.size());
|
|
|
|
cameras.forEach(camera -> {
|
|
|
|
cameras.forEach(camera -> {
|
|
|
|
StatusThread statusThread = new StatusThread(camera,latch);
|
|
|
|
StatusThread statusThread = new StatusThread(camera, latch);
|
|
|
|
statusThread.start();
|
|
|
|
statusThread.start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -126,66 +126,69 @@ public class CameraService {
|
|
|
|
return new PageInfo<>(cameras);
|
|
|
|
return new PageInfo<>(cameras);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class StatusThread extends Thread{
|
|
|
|
public class StatusThread extends Thread {
|
|
|
|
private Camera camera;
|
|
|
|
private Camera camera;
|
|
|
|
private CountDownLatch latch;
|
|
|
|
private CountDownLatch latch;
|
|
|
|
public StatusThread(Camera camera,CountDownLatch latch){
|
|
|
|
|
|
|
|
|
|
|
|
public StatusThread(Camera camera, CountDownLatch latch) {
|
|
|
|
this.camera = camera;
|
|
|
|
this.camera = camera;
|
|
|
|
this.latch = latch;
|
|
|
|
this.latch = latch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Boolean ok = false;
|
|
|
|
Boolean ok = false;
|
|
|
|
if(configProperties.getCameraConfig().getCameraType() == ConfigProperties.HIK_CAMERA){
|
|
|
|
if (configProperties.getCameraConfig().getCameraType() == ConfigProperties.HIK_CAMERA) {
|
|
|
|
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()).intValue());
|
|
|
|
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()).intValue());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()));
|
|
|
|
ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ok){
|
|
|
|
if (ok) {
|
|
|
|
camera.setStatus("连接正常");
|
|
|
|
camera.setStatus("连接正常");
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
CameraConnMap.disConn(camera.getId());
|
|
|
|
//CameraConnMap.disConn(camera.getId());
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
} catch (Exception e) {
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
}finally {
|
|
|
|
} finally {
|
|
|
|
latch.countDown();
|
|
|
|
latch.countDown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Camera detail(Integer id){
|
|
|
|
public Camera detail(Integer id) {
|
|
|
|
return cameraMapper.selectById(id);
|
|
|
|
return cameraMapper.selectById(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Camera> allCameras(){
|
|
|
|
public List<Camera> allCameras() {
|
|
|
|
|
|
|
|
|
|
|
|
return cameraMapper.selectByMap(new HashMap<>());
|
|
|
|
return cameraMapper.selectByMap(new HashMap<>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* HD01 - HD05
|
|
|
|
* HD01 - HD05
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<Camera> allCameras1(){
|
|
|
|
public List<Camera> allCameras1() {
|
|
|
|
//Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() *configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
//Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() *configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
Integer count = cameraMapper.selectCount(new QueryWrapper<Camera>());
|
|
|
|
Integer count = cameraMapper.selectCount(new QueryWrapper<Camera>());
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit "+8));
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit " + 8));
|
|
|
|
return cameras;
|
|
|
|
return cameras;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Camera> allCameras2(){
|
|
|
|
public List<Camera> allCameras2() {
|
|
|
|
Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() *configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() * configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit 0,4"));
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit 0,4"));
|
|
|
|
return cameras;
|
|
|
|
return cameras;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Camera> allCameras3(){
|
|
|
|
public List<Camera> allCameras3() {
|
|
|
|
Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() *configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
Integer num = configProperties.getVideoStyleConfig().getVideoStyleRow() * configProperties.getVideoStyleConfig().getVideoStyleColumn();
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit 4,4"));
|
|
|
|
List<Camera> cameras = cameraMapper.selectList(new QueryWrapper<Camera>().last("limit 4,4"));
|
|
|
|
|
|
|
|
|
|
|
|
return cameras;
|
|
|
|
return cameras;
|
|
|
|
@ -244,6 +247,7 @@ public class CameraService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* io列表
|
|
|
|
* io列表
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param cameraId
|
|
|
|
* @param cameraId
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -255,11 +259,12 @@ public class CameraService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 球机新增、或修改预置点
|
|
|
|
* 球机新增、或修改预置点
|
|
|
|
* synchronized 设置为同步方法,防止出现同一个ptzId在同一个球机上
|
|
|
|
* synchronized 设置为同步方法,防止出现同一个ptzId在同一个球机上
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param IOId 存在修改,不存在 新增
|
|
|
|
* @param IOId 存在修改,不存在 新增
|
|
|
|
* @param cameraId
|
|
|
|
* @param cameraId
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@CacheEvict(value = "ptz",key = "#cameraId+'-'+#code")
|
|
|
|
@CacheEvict(value = "ptz", key = "#cameraId+'-'+#code")
|
|
|
|
public synchronized Integer ptz(Integer IOId, Integer cameraId, String name,Integer type,String code) {
|
|
|
|
public synchronized Integer ptz(Integer IOId, Integer cameraId, String name, Integer type, String code) {
|
|
|
|
Camera camera = cameraMapper.selectById(cameraId);
|
|
|
|
Camera camera = cameraMapper.selectById(cameraId);
|
|
|
|
Assert.notNull(camera, "球机不存在");
|
|
|
|
Assert.notNull(camera, "球机不存在");
|
|
|
|
CameraIO cameraIO = null;
|
|
|
|
CameraIO cameraIO = null;
|
|
|
|
@ -275,11 +280,11 @@ public class CameraService {
|
|
|
|
cameraIO.setName(name);
|
|
|
|
cameraIO.setName(name);
|
|
|
|
cameraIO.setPtzId(ptzId);
|
|
|
|
cameraIO.setPtzId(ptzId);
|
|
|
|
cameraIO.setCode(code);
|
|
|
|
cameraIO.setCode(code);
|
|
|
|
conver(cameraIO,0);
|
|
|
|
conver(cameraIO, 0);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ioMapper.insert(cameraIO);
|
|
|
|
ioMapper.insert(cameraIO);
|
|
|
|
}catch (DuplicateKeyException e){
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
Assert.isTrue(false,"code已存在:"+code);
|
|
|
|
Assert.isTrue(false, "code已存在:" + code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
camera.setPtzId(ptzId);
|
|
|
|
camera.setPtzId(ptzId);
|
|
|
|
cameraMapper.updateById(camera);
|
|
|
|
cameraMapper.updateById(camera);
|
|
|
|
@ -290,75 +295,67 @@ public class CameraService {
|
|
|
|
//将ptzId赋值为旧的,不能用新的
|
|
|
|
//将ptzId赋值为旧的,不能用新的
|
|
|
|
ptzId = cameraIO.getPtzId();
|
|
|
|
ptzId = cameraIO.getPtzId();
|
|
|
|
cameraIO.setUpdateTime(LocalDateTime.now());
|
|
|
|
cameraIO.setUpdateTime(LocalDateTime.now());
|
|
|
|
conver(cameraIO,type);
|
|
|
|
conver(cameraIO, type);
|
|
|
|
ioMapper.updateById(cameraIO);
|
|
|
|
ioMapper.updateById(cameraIO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean ok = cameraControlModule.connectStatus(cameraId);
|
|
|
|
boolean ok = cameraControlModule.connectStatus(cameraId);
|
|
|
|
if(!ok){
|
|
|
|
if (!ok) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cameraControlModule.ptz(ptzId,cameraIO.getName(),cameraId);
|
|
|
|
cameraControlModule.ptz(ptzId, cameraIO.getName(), cameraId);
|
|
|
|
log.info("设置 预置点 球机ID:{},预置点ID:{}", cameraId, ptzId);
|
|
|
|
log.info("设置 预置点 球机ID:{},预置点ID:{}", cameraId, ptzId);
|
|
|
|
return cameraIO.getId();
|
|
|
|
return cameraIO.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 所有的根据code和caameraId获取预置点都使用此方法,有缓存
|
|
|
|
* 所有的根据code和caameraId获取预置点都使用此方法,有缓存
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param code
|
|
|
|
* @param code
|
|
|
|
* @param cameraId
|
|
|
|
* @param cameraId
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Cacheable(value = "ptz",key = "#cameraId+'-'+#code")
|
|
|
|
@Cacheable(value = "ptz", key = "#cameraId+'-'+#code")
|
|
|
|
public Integer getPtzIdByCodeAndCameraId(String code,Integer cameraId){
|
|
|
|
public Integer getPtzIdByCodeAndCameraId(String code, Integer cameraId) {
|
|
|
|
CameraIO cameraIO = ioMapper.getByCodeAndCameraId(code,cameraId);
|
|
|
|
CameraIO cameraIO = ioMapper.getByCodeAndCameraId(code, cameraId);
|
|
|
|
if(cameraIO != null){
|
|
|
|
if (cameraIO != null) {
|
|
|
|
return cameraIO.getPtzId();
|
|
|
|
return cameraIO.getPtzId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getPtzId(Integer ioId){
|
|
|
|
public Integer getPtzId(Integer ioId) {
|
|
|
|
CameraIO cameraIO = ioMapper.selectById(ioId);
|
|
|
|
CameraIO cameraIO = ioMapper.selectById(ioId);
|
|
|
|
Assert.notNull(cameraIO,"IO配置不存在");
|
|
|
|
Assert.notNull(cameraIO, "IO配置不存在");
|
|
|
|
return cameraIO.getPtzId();
|
|
|
|
return cameraIO.getPtzId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void conver(CameraIO cameraIO,Integer type){
|
|
|
|
private void conver(CameraIO cameraIO, Integer type) {
|
|
|
|
if(type == 0){
|
|
|
|
if (type == 0) {
|
|
|
|
cameraIO.setPosition("OK");
|
|
|
|
cameraIO.setPosition("OK");
|
|
|
|
}else if(type == 1){
|
|
|
|
} else if (type == 1) {
|
|
|
|
cameraIO.setFocusing("OK");
|
|
|
|
cameraIO.setFocusing("OK");
|
|
|
|
}else if(type == 2){
|
|
|
|
} else if (type == 2) {
|
|
|
|
cameraIO.setMultiple("OK");
|
|
|
|
cameraIO.setMultiple("OK");
|
|
|
|
}else if(type == 3){
|
|
|
|
} else if (type == 3) {
|
|
|
|
cameraIO.setAperture("OK");
|
|
|
|
cameraIO.setAperture("OK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void cameraConnectStatus(Integer cameraId){
|
|
|
|
public void cameraConnect(Integer cameraId) {
|
|
|
|
Boolean ok = cameraControlModule.connectStatus(cameraId);
|
|
|
|
|
|
|
|
if(!ok){
|
|
|
|
|
|
|
|
log.error("camera unconnected,cameraId:{}",cameraId);
|
|
|
|
|
|
|
|
Camera camera = cameraMapper.selectById(cameraId);
|
|
|
|
|
|
|
|
cameraLogin(camera);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void cameraConnect(Integer cameraId){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.error("camera unconnected,cameraId:{}",cameraId);
|
|
|
|
log.error("camera unconnected,cameraId:{}", cameraId);
|
|
|
|
Camera camera = cameraMapper.selectById(cameraId);
|
|
|
|
Camera camera = cameraMapper.selectById(cameraId);
|
|
|
|
cameraLogin(camera);
|
|
|
|
cameraLogin(camera);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void cameraLogin(Camera camera){
|
|
|
|
public void cameraLogin(Camera camera) {
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (camera.getId().toString().intern()){
|
|
|
|
synchronized (camera.getId().toString().intern()) {
|
|
|
|
NetSDKLib.LLong lLong = cameraControlLoginModule.login(camera.getId(),camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword());
|
|
|
|
NetSDKLib.LLong lLong = cameraControlLoginModule.login(camera.getId(), camera.getIp(), camera.getPort(), camera.getUser(), camera.getPassword());
|
|
|
|
if(lLong != null){
|
|
|
|
if (lLong != null) {
|
|
|
|
log.info("camera login success,cameraId:{},ip:{}",camera.getId(),camera.getIp());
|
|
|
|
log.info("camera login success,cameraId:{},ip:{}", camera.getId(), camera.getIp());
|
|
|
|
CameraConnMap.conn(camera.getId(),lLong);
|
|
|
|
CameraConnMap.conn(camera.getId(), lLong);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|