双球机混用

nanjing-zhongyan
yiming 3 years ago
parent f5ae3d9505
commit 954f7299e9

@ -0,0 +1 @@
{"server":{"ice_credential":"","ice_servers":["stun:stun.l.google.com:19302"],"ice_username":"","http_port":":8083"},"streams":{"camera1":{"disable_audio":true,"url":"rtsp://admin:a1234567@172.16.0.123:554/cam/realmonitor?channel=1&subtype=0","on_demand":false},"camera2":{"disable_audio":true,"url":"rtsp://admin:a1234567@172.16.0.27:554/cam/realmonitor?channel=1&subtype=0","on_demand":false}}}

@ -47,7 +47,9 @@ public class ConfigProperties {
private String cameraUser; private String cameraUser;
private Integer cameraPort; private Integer cameraPort0;
private Integer cameraPort1;
private Long delayCaptureTime; private Long delayCaptureTime;

@ -9,6 +9,8 @@ import com.zhehekeji.web.lib.*;
import com.zhehekeji.web.lib.hik.HCNetSDK; import com.zhehekeji.web.lib.hik.HCNetSDK;
import com.zhehekeji.web.lib.joyware.NetSDKLib; import com.zhehekeji.web.lib.joyware.NetSDKLib;
import com.zhehekeji.web.mapper.CameraMapper; import com.zhehekeji.web.mapper.CameraMapper;
import com.zhehekeji.web.service.CameraChoice;
import com.zhehekeji.web.service.CameraLoginChoice;
import com.zhehekeji.web.service.CameraService; import com.zhehekeji.web.service.CameraService;
import com.zhehekeji.web.service.PlcService; import com.zhehekeji.web.service.PlcService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -30,9 +32,9 @@ public class CameraControlController {
private CameraMapper cameraMapper; private CameraMapper cameraMapper;
@Resource @Resource
private CameraControlModule cameraControlModule; private CameraChoice cameraChoice;
@Resource @Resource
private CameraControlLoginModule loginControlModule; private CameraLoginChoice cameraLoginChoice;
@PostMapping("/{id}") @PostMapping("/{id}")
@ApiOperation(value = "球机登录") @ApiOperation(value = "球机登录")
@ -41,20 +43,12 @@ public class CameraControlController {
return Result.success(); return Result.success();
} }
private NetSDKLib.LLong cameraLogin(Integer cameraId){
log.info("相机登录 cameraId:{}",cameraId);
Camera camera = cameraMapper.selectById(cameraId);
Assert.notNull(camera,"球机不存在");
NetSDKLib.LLong lLong = loginControlModule.login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword());
return lLong;
}
@PostMapping("/up/{id}") @PostMapping("/up/{id}")
@ApiOperation(value = "球机控制向上") @ApiOperation(value = "球机控制向上")
public Result up(@PathVariable Integer id) { public Result up(@PathVariable Integer id) {
log.debug("球机控制向上"); log.debug("球机控制向上");
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlUpStart(id,0,0,1); cameraChoice.ptzControlUpStart(id,0,0,1);
return Result.success(); return Result.success();
} }
@ -63,7 +57,7 @@ public class CameraControlController {
public Result upStop(@PathVariable Integer id) { public Result upStop(@PathVariable Integer id) {
log.debug("球机控制向上 停止"); log.debug("球机控制向上 停止");
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlUpEnd(id,0); cameraChoice.ptzControlUpEnd(id,0);
return Result.success(); return Result.success();
} }
@ -71,7 +65,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向下") @ApiOperation(value = "球机控制向下")
public Result down(@PathVariable Integer id) { public Result down(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlDownStart(id,0,0,1); cameraChoice.ptzControlDownStart(id,0,0,1);
log.debug("球机控制向下"); log.debug("球机控制向下");
return Result.success(); return Result.success();
} }
@ -80,7 +74,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向下-停止") @ApiOperation(value = "球机控制向下-停止")
public Result downStop(@PathVariable Integer id) { public Result downStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlDownEnd(id,0); cameraChoice.ptzControlDownEnd(id,0);
log.debug("球机控制向下 停止"); log.debug("球机控制向下 停止");
return Result.success(); return Result.success();
} }
@ -89,7 +83,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向左") @ApiOperation(value = "球机控制向左")
public Result left(@PathVariable Integer id) { public Result left(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftStart(id,0,0,1); cameraChoice.ptzControlLeftStart(id,0,0,1);
log.debug("球机控制向左"); log.debug("球机控制向左");
return Result.success(); return Result.success();
} }
@ -98,7 +92,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制左-停止") @ApiOperation(value = "球机控制左-停止")
public Result leftStop(@PathVariable Integer id) { public Result leftStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftEnd(id,0); cameraChoice.ptzControlLeftEnd(id,0);
log.debug("球机控制向左 -停止"); log.debug("球机控制向左 -停止");
return Result.success(); return Result.success();
} }
@ -108,7 +102,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向左上") @ApiOperation(value = "球机控制向左上")
public Result leftUp(@PathVariable Integer id) { public Result leftUp(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftUpStart(id,0,1,1); cameraChoice.ptzControlLeftUpStart(id,0,1,1);
log.debug("球机控制向上"); log.debug("球机控制向上");
return Result.success(); return Result.success();
} }
@ -117,7 +111,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制左上-停止") @ApiOperation(value = "球机控制左上-停止")
public Result leftUpStop(@PathVariable Integer id) { public Result leftUpStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftUpEnd(id,0); cameraChoice.ptzControlLeftUpEnd(id,0);
log.debug("球机控制向上 停止"); log.debug("球机控制向上 停止");
return Result.success(); return Result.success();
} }
@ -126,7 +120,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向左下") @ApiOperation(value = "球机控制向左下")
public Result leftDown(@PathVariable Integer id) { public Result leftDown(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftDownStart(id,0,1,1); cameraChoice.ptzControlLeftDownStart(id,0,1,1);
log.debug("球机控制左下"); log.debug("球机控制左下");
return Result.success(); return Result.success();
} }
@ -135,7 +129,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制左下-停止") @ApiOperation(value = "球机控制左下-停止")
public Result leftDownStop(@PathVariable Integer id) { public Result leftDownStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlLeftDownEnd(id,0); cameraChoice.ptzControlLeftDownEnd(id,0);
log.debug("球机控制左下 停止"); log.debug("球机控制左下 停止");
return Result.success(); return Result.success();
@ -145,7 +139,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向右") @ApiOperation(value = "球机控制向右")
public Result right(@PathVariable Integer id) { public Result right(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightStart(id,0,0,1); cameraChoice.ptzControlRightStart(id,0,0,1);
log.debug("球机控制右"); log.debug("球机控制右");
return Result.success(); return Result.success();
} }
@ -154,7 +148,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制右-停止") @ApiOperation(value = "球机控制右-停止")
public Result rightStop(@PathVariable Integer id) { public Result rightStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightEnd(id,0); cameraChoice.ptzControlRightEnd(id,0);
log.debug("球机控制右 停止"); log.debug("球机控制右 停止");
return Result.success(); return Result.success();
} }
@ -164,7 +158,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向右上") @ApiOperation(value = "球机控制向右上")
public Result rightUp(@PathVariable Integer id) { public Result rightUp(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightUpStart(id,0,1,1); cameraChoice.ptzControlRightUpStart(id,0,1,1);
log.debug("球机控制右上"); log.debug("球机控制右上");
return Result.success(); return Result.success();
} }
@ -173,7 +167,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制右上-停止") @ApiOperation(value = "球机控制右上-停止")
public Result rightUpStop(@PathVariable Integer id) { public Result rightUpStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightUpEnd(id,0); cameraChoice.ptzControlRightUpEnd(id,0);
log.debug("球机控制右上 -停止"); log.debug("球机控制右上 -停止");
return Result.success(); return Result.success();
} }
@ -182,7 +176,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制向右下") @ApiOperation(value = "球机控制向右下")
public Result rightDown(@PathVariable Integer id) { public Result rightDown(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightDownStart(id,0,1,1); cameraChoice.ptzControlRightDownStart(id,0,1,1);
log.debug("球机控制右下"); log.debug("球机控制右下");
return Result.success(); return Result.success();
} }
@ -191,7 +185,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制右下-停止") @ApiOperation(value = "球机控制右下-停止")
public Result rightDownStop(@PathVariable Integer id) { public Result rightDownStop(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlRightDownEnd(id,0); cameraChoice.ptzControlRightDownEnd(id,0);
log.debug("球机控制右下 -停止"); log.debug("球机控制右下 -停止");
return Result.success(); return Result.success();
} }
@ -200,7 +194,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变倍+") @ApiOperation(value = "球机控制 变倍+")
public Result ZoomAddStart(@PathVariable Integer id) { public Result ZoomAddStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlZoomAddStart(id,0,1); cameraChoice.ptzControlZoomAddStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -208,7 +202,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变倍+ 停止") @ApiOperation(value = "球机控制 变倍+ 停止")
public Result ZoomAddEnd(@PathVariable Integer id) { public Result ZoomAddEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlZoomAddEnd(id,0); cameraChoice.ptzControlZoomAddEnd(id,0);
return Result.success(); return Result.success();
} }
@ -216,7 +210,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变倍-") @ApiOperation(value = "球机控制 变倍-")
public Result ZoomDecStart(@PathVariable Integer id) { public Result ZoomDecStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlZoomDecStart(id,0,1); cameraChoice.ptzControlZoomDecStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -224,7 +218,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变倍- 停止") @ApiOperation(value = "球机控制 变倍- 停止")
public Result ZoomDecEnd(@PathVariable Integer id) { public Result ZoomDecEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlZoomDecEnd(id,0); cameraChoice.ptzControlZoomDecEnd(id,0);
return Result.success(); return Result.success();
} }
@ -232,7 +226,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变焦 +") @ApiOperation(value = "球机控制 变焦 +")
public Result FocusAddStart(@PathVariable Integer id) { public Result FocusAddStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlFocusAddStart(id,0,1); cameraChoice.ptzControlFocusAddStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -240,7 +234,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变焦+ 停止") @ApiOperation(value = "球机控制 变焦+ 停止")
public Result focusAddEnd(@PathVariable Integer id) { public Result focusAddEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlFocusAddEnd(id,0); cameraChoice.ptzControlFocusAddEnd(id,0);
return Result.success(); return Result.success();
} }
@ -248,7 +242,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变焦 -") @ApiOperation(value = "球机控制 变焦 -")
public Result FocusDecStart(@PathVariable Integer id) { public Result FocusDecStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlFocusDecStart(id,0,1); cameraChoice.ptzControlFocusDecStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -256,7 +250,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 变焦- 停止") @ApiOperation(value = "球机控制 变焦- 停止")
public Result focusDecEnd(@PathVariable Integer id) { public Result focusDecEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlFocusDecEnd(id,0); cameraChoice.ptzControlFocusDecEnd(id,0);
return Result.success(); return Result.success();
} }
@ -264,7 +258,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 光圈 +") @ApiOperation(value = "球机控制 光圈 +")
public Result irisAddStart(@PathVariable Integer id) { public Result irisAddStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlIrisAddStart(id,0,1); cameraChoice.ptzControlIrisAddStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -272,7 +266,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 光圈+ 停止") @ApiOperation(value = "球机控制 光圈+ 停止")
public Result irisAddEnd(@PathVariable Integer id) { public Result irisAddEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlIrisAddEnd(id,0); cameraChoice.ptzControlIrisAddEnd(id,0);
return Result.success(); return Result.success();
} }
@ -280,7 +274,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 光圈 -") @ApiOperation(value = "球机控制 光圈 -")
public Result irisDecStart(@PathVariable Integer id) { public Result irisDecStart(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlIrisDecStart(id,0,1); cameraChoice.ptzControlIrisDecStart(id,0,1);
return Result.success(); return Result.success();
} }
@ -288,7 +282,7 @@ public class CameraControlController {
@ApiOperation(value = "球机控制 光圈- 停止") @ApiOperation(value = "球机控制 光圈- 停止")
public Result irisDecEnd(@PathVariable Integer id) { public Result irisDecEnd(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
cameraControlModule.ptzControlIrisDecEnd(id,0); cameraChoice.ptzControlIrisDecEnd(id,0);
return Result.success(); return Result.success();
} }
@ -324,7 +318,7 @@ public class CameraControlController {
public Result MP4(@PathVariable Integer id) { public Result MP4(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
LocalDateTime localDateTime = LocalDateTime.of(2022,7,21,8,20); LocalDateTime localDateTime = LocalDateTime.of(2022,7,21,8,20);
cameraControlModule.downloadMp4(id,"E:\\work\\"+localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".mp4", localDateTime,localDateTime.plusMinutes(3)); cameraChoice.downloadMp4(id,"E:\\work\\"+localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".mp4", localDateTime,localDateTime.plusMinutes(3));
return Result.success(); return Result.success();
} }

@ -16,6 +16,7 @@ import com.zhehekeji.web.lib.joyware.NetSDKLib;
import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq; import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq;
import com.zhehekeji.web.pojo.camera.CameraIOPtz; import com.zhehekeji.web.pojo.camera.CameraIOPtz;
import com.zhehekeji.web.pojo.street.StreetSearch; import com.zhehekeji.web.pojo.street.StreetSearch;
import com.zhehekeji.web.service.CameraChoice;
import com.zhehekeji.web.service.CameraService; import com.zhehekeji.web.service.CameraService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -127,13 +128,13 @@ public class CameraController {
} }
@Resource @Resource
private CameraControlModule cameraControlModule; private CameraChoice cameraChoice;
@PostMapping("/io/toPtz") @PostMapping("/io/toPtz")
@ApiOperation(value = "转至球机IO配置点") @ApiOperation(value = "转至球机IO配置点")
public Result toPtz(@RequestBody CameraIOPtz req) { public Result toPtz(@RequestBody CameraIOPtz req) {
Integer ptzId = cameraService.getPtzId(req.getCameraIOId()); Integer ptzId = cameraService.getPtzId(req.getCameraIOId());
cameraControlModule.toPtz(ptzId,req.getCameraId()); cameraChoice.toPtz(ptzId,req.getCameraId());
return Result.success(); return Result.success();
} }

@ -23,6 +23,11 @@ public class Camera {
private Integer port; private Integer port;
/**
* 0:hik 1:lipo
*/
private Integer type;
private String user; private String user;
private String password; private String password;

@ -1,6 +1,7 @@
package com.zhehekeji.web.lib; package com.zhehekeji.web.lib;
import com.zhehekeji.common.util.SpringContextUtil; import com.zhehekeji.common.util.SpringContextUtil;
import com.zhehekeji.web.service.CameraChoice;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.concurrent.DelayQueue; import java.util.concurrent.DelayQueue;
@ -39,17 +40,17 @@ public class TaskDelayExecutor {
public void run() { public void run() {
while (true) { while (true) {
try { try {
CameraControlModule cameraControlModule = SpringContextUtil.getBean(CameraControlModule.class); CameraChoice cameraChoice = SpringContextUtil.getBean(CameraChoice.class);
CameraDelayTask cameraDelayTask = queue.take(); CameraDelayTask cameraDelayTask = queue.take();
if(cameraDelayTask != null){ if(cameraDelayTask != null){
if(cameraDelayTask.getType() == 0){ if(cameraDelayTask.getType() == 0){
cameraControlModule.downloadMp4(cameraDelayTask.getCameraId(), cameraDelayTask.getPath(), cameraDelayTask.getStartTime(), cameraDelayTask.getEndTime()); cameraChoice.downloadMp4(cameraDelayTask.getCameraId(), cameraDelayTask.getPath(), cameraDelayTask.getStartTime(), cameraDelayTask.getEndTime());
}else if(cameraDelayTask.getType() == 1){ }else if(cameraDelayTask.getType() == 1){
cameraControlModule.pic(cameraDelayTask.getCameraId(),0, cameraDelayTask.getPath()); cameraChoice.pic(cameraDelayTask.getCameraId(),0, cameraDelayTask.getPath());
}else if(cameraDelayTask.getType() == 2){ }else if(cameraDelayTask.getType() == 2){
cameraControlModule.toPtz(cameraDelayTask.getPtzId(),cameraDelayTask.getCameraId()); cameraChoice.toPtz(cameraDelayTask.getPtzId(),cameraDelayTask.getCameraId());
} }
} }

@ -8,7 +8,9 @@ import com.zhehekeji.web.lib.CameraConnMap;
import com.zhehekeji.web.lib.CameraControlModule; import com.zhehekeji.web.lib.CameraControlModule;
import com.zhehekeji.web.lib.joyware.NetSDKLib; import com.zhehekeji.web.lib.joyware.NetSDKLib;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Duration; import java.time.Duration;
@ -23,6 +25,7 @@ import java.util.Timer;
* *
*/ */
@Slf4j @Slf4j
@Component("HikCameraControlModuleImpl")
public class HikCameraControlModuleImpl implements CameraControlModule { public class HikCameraControlModuleImpl implements CameraControlModule {
public boolean connectStatus(Integer cameraId){ public boolean connectStatus(Integer cameraId){

@ -4,12 +4,16 @@ import com.sun.jna.Pointer;
import com.zhehekeji.web.lib.CameraControlLoginModule; import com.zhehekeji.web.lib.CameraControlLoginModule;
import com.zhehekeji.web.lib.joyware.NetSDKLib; import com.zhehekeji.web.lib.joyware.NetSDKLib;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/** /**
* *
* *
*/ */
@Slf4j @Slf4j
@Component("HikLoginModuleImpl")
public class HikLoginModuleImpl implements CameraControlLoginModule { public class HikLoginModuleImpl implements CameraControlLoginModule {

@ -6,7 +6,9 @@ import com.zhehekeji.core.util.Assert;
import com.zhehekeji.web.lib.CameraConnMap; import com.zhehekeji.web.lib.CameraConnMap;
import com.zhehekeji.web.lib.CameraControlModule; import com.zhehekeji.web.lib.CameraControlModule;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl.mp4ReceiveCB; import static com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl.mp4ReceiveCB;
@ -16,6 +18,7 @@ import static com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl.mp4ReceiveCB;
* *
*/ */
@Slf4j @Slf4j
@Component("JoywareCameraControlModuleImpl")
public class JoywareCameraControlModuleImpl implements CameraControlModule { public class JoywareCameraControlModuleImpl implements CameraControlModule {
//中威球机断线会自动直接重连!!,没有等待的心跳时间所以这里直接返回true //中威球机断线会自动直接重连!!,没有等待的心跳时间所以这里直接返回true

@ -11,12 +11,14 @@ import com.zhehekeji.web.lib.joyware.NetSDKLib.LLong;
import com.zhehekeji.web.lib.joyware.NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY; import com.zhehekeji.web.lib.joyware.NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY;
import com.zhehekeji.web.lib.joyware.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY; import com.zhehekeji.web.lib.joyware.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/** /**
* *
* *
*/ */
@Slf4j @Slf4j
@Component("JoywareLoginModuleImpl")
public class JoywareLoginModuleImpl implements CameraControlLoginModule { public class JoywareLoginModuleImpl implements CameraControlLoginModule {
public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;

@ -0,0 +1,373 @@
package com.zhehekeji.web.service;
import com.zhehekeji.web.entity.Camera;
import com.zhehekeji.web.lib.hik.HikCameraControlModuleImpl;
import com.zhehekeji.web.lib.joyware.JoywareCameraControlModuleImpl;
import com.zhehekeji.web.mapper.CameraMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@Component
public class CameraChoice {
@Resource
private CameraMapper cameraMapper;
@Qualifier(value = "JoywareCameraControlModuleImpl")
@Resource
JoywareCameraControlModuleImpl joywareCameraControlModule;
@Qualifier(value = "HikCameraControlModuleImpl")
@Resource
HikCameraControlModuleImpl hikCameraControlModule;
/**
* key : cameraId
* value: 0:lipo 1hik
*/
private Map<Integer, Integer> typeMap = new HashMap<>();
public void addCamera(Camera camera){
typeMap.put(camera.getId(),camera.getType());
}
public void delCamera(Integer cameraId){
typeMap.remove(cameraId);
}
public boolean connectStatus(Integer cameraId){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.connectStatus(cameraId);
}else {
return joywareCameraControlModule.connectStatus(cameraId);
}
}
/**
*
*/
public boolean ptzControlUpStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlUpStart( cameraId, nChannelID, lParam1, lParam2);
}else {
return joywareCameraControlModule.ptzControlUpStart( cameraId, nChannelID, lParam1, lParam2);
}
}
public boolean ptzControlUpEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlUpEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlUpEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlDownStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlDownStart(cameraId, nChannelID, lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlDownStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlDownEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlDownEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlDownEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlLeftStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlLeftStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlLeftEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlLeftEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlRightStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlRightStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlRightEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlRightEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlLeftUpStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftUpStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlLeftUpStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlLeftUpEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftUpEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlLeftUpEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlRightUpStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightUpStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlRightUpStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlRightUpEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightUpEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlRightUpEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlLeftDownStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftDownStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlLeftDownStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlLeftDownEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlLeftDownEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlLeftDownEnd(cameraId, nChannelID);
}
}
/**
*
*/
public boolean ptzControlRightDownStart(Integer cameraId, int nChannelID, int lParam1, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightDownStart(cameraId, nChannelID,lParam1,lParam2);
}else {
return joywareCameraControlModule.ptzControlRightDownStart(cameraId, nChannelID,lParam1,lParam2);
}
}
public boolean ptzControlRightDownEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlRightDownEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlRightDownEnd(cameraId, nChannelID);
}
}
/**
* +
*/
public boolean ptzControlZoomAddStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlZoomAddStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlZoomAddStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlZoomAddEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlZoomAddEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlZoomAddEnd(cameraId, nChannelID);
}
}
/**
* -
*/
public boolean ptzControlZoomDecStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlZoomDecStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlZoomDecStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlZoomDecEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlZoomDecEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlZoomDecEnd(cameraId, nChannelID);
}
}
/**
* +
*/
public boolean ptzControlFocusAddStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlFocusAddStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlFocusAddStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlFocusAddEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlFocusAddEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlFocusAddEnd(cameraId, nChannelID);
}
}
/**
* -
*/
public boolean ptzControlFocusDecStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlFocusDecStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlFocusDecStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlFocusDecEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlFocusDecEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlFocusDecEnd(cameraId, nChannelID);
}
}
/**
* +
*/
public boolean ptzControlIrisAddStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlIrisAddStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlIrisAddStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlIrisAddEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlIrisAddEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlIrisAddEnd(cameraId, nChannelID);
}
}
/**
* -
*/
public boolean ptzControlIrisDecStart(Integer cameraId, int nChannelID, int lParam2){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlIrisDecStart(cameraId, nChannelID,lParam2);
}else {
return joywareCameraControlModule.ptzControlIrisDecStart(cameraId, nChannelID,lParam2);
}
}
public boolean ptzControlIrisDecEnd(Integer cameraId, int nChannelID){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.ptzControlIrisDecEnd(cameraId, nChannelID);
}else {
return joywareCameraControlModule.ptzControlIrisDecEnd(cameraId, nChannelID);
}
}
public boolean pic(Integer cameraId, int channel, String realPath){
if(typeMap.get(cameraId) == 1){
return hikCameraControlModule.pic(cameraId, channel, realPath);
}else {
return joywareCameraControlModule.pic(cameraId, channel, realPath);
}
}
public void downloadMp4(Integer cameraId, String path, LocalDateTime start, LocalDateTime end){
if(typeMap.get(cameraId) == 1){
hikCameraControlModule.downloadMp4(cameraId, path, start, end);
}else {
joywareCameraControlModule.downloadMp4(cameraId, path, start, end);
}
}
/**
*
*
* @param ptzId ID
* @param name
* @param cameraId ID,
*/
public void ptz(Integer ptzId, String name, Integer cameraId){
if(typeMap.get(cameraId) == 1){
hikCameraControlModule.ptz( ptzId, name, cameraId);
}else {
joywareCameraControlModule.ptz( ptzId, name, cameraId);
}
}
/**
*
*
* @param ptzId
* @param cameraId
*/
public void toPtz(Integer ptzId, Integer cameraId){
if(typeMap.get(cameraId) == 1){
hikCameraControlModule.toPtz( ptzId, cameraId);
}else {
joywareCameraControlModule.toPtz( ptzId, cameraId);
}
}
/**
*
*
* @param cameraId
*/
public void toPtzSlow(Integer cameraId, Integer x){
if(typeMap.get(cameraId) == 1){
hikCameraControlModule.toPtzSlow( cameraId, x);
}else {
joywareCameraControlModule.toPtzSlow( cameraId, x);
}
}
}

@ -0,0 +1,31 @@
package com.zhehekeji.web.service;
import com.zhehekeji.web.entity.Camera;
import com.zhehekeji.web.lib.hik.HikLoginModuleImpl;
import com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl;
import com.zhehekeji.web.lib.joyware.NetSDKLib;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class CameraLoginChoice {
@Resource
private CameraChoice cameraChoice;
@Resource
@Qualifier(value = "JoywareLoginModuleImpl")
private JoywareLoginModuleImpl joywareLoginModule;
@Resource
@Qualifier(value = "HikLoginModuleImpl")
private HikLoginModuleImpl hikLoginModule;
public NetSDKLib.LLong login(Camera camera){
if(camera.getType() == 1){
return hikLoginModule.login(camera.getIp(),camera.getPort(),camera.getUser(), camera.getPassword());
}else {
return joywareLoginModule.login(camera.getIp(),camera.getPort(),camera.getUser(), camera.getPassword());
}
}
}

@ -52,22 +52,20 @@ public class CameraService {
@Resource @Resource
private ConfigProperties configProperties; private ConfigProperties configProperties;
private CameraControlModule cameraControlModule; @Resource
private CameraChoice cameraChoice;
private CameraControlLoginModule cameraControlLoginModule; @Resource
private CameraLoginChoice cameraLoginChoice;
public void setCameraControlModule(CameraControlModule cameraControlModule){
this.cameraControlModule = cameraControlModule;
}
public void setCameraLoginModule(CameraControlLoginModule cameraControlLoginModule){
this.cameraControlLoginModule = cameraControlLoginModule;
}
public Integer add(Camera camera) { public Integer add(Camera camera) {
camera.setUser(configProperties.getCameraConfig().getCameraUser()); camera.setUser(configProperties.getCameraConfig().getCameraUser());
camera.setPassword(configProperties.getCameraConfig().getCameraPassword()); camera.setPassword(configProperties.getCameraConfig().getCameraPassword());
camera.setPort(configProperties.getCameraConfig().getCameraPort()); if(camera.getType()==0){
camera.setPort(configProperties.getCameraConfig().getCameraPort0());
}else {
camera.setPort(configProperties.getCameraConfig().getCameraPort1());
}
camera.setUpdateTime(LocalDateTime.now()); camera.setUpdateTime(LocalDateTime.now());
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0"); camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0");
if(StringUtils.isEmpty(camera.getRtcServer())){ if(StringUtils.isEmpty(camera.getRtcServer())){
@ -79,7 +77,7 @@ public class CameraService {
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
Assert.isTrue(false, "rtsp地址已存在"); Assert.isTrue(false, "rtsp地址已存在");
} }
cameraChoice.addCamera(camera);
return camera.getId(); return camera.getId();
} }
@ -89,7 +87,11 @@ public class CameraService {
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()); if(camera.getType()==0){
camera.setPort(configProperties.getCameraConfig().getCameraPort0());
}else {
camera.setPort(configProperties.getCameraConfig().getCameraPort1());
}
camera.setUser(configProperties.getCameraConfig().getCameraUser()); camera.setUser(configProperties.getCameraConfig().getCameraUser());
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0"); camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0");
try { try {
@ -97,12 +99,14 @@ public class CameraService {
} catch (DuplicateKeyException e) { } catch (DuplicateKeyException e) {
Assert.isTrue(false, "rtsp地址已存在"); Assert.isTrue(false, "rtsp地址已存在");
} }
cameraChoice.addCamera(camera);
} }
public void del(Integer id) { public void del(Integer id) {
Integer count = streetMapper.checkCamera(id); Integer count = streetMapper.checkCamera(id);
Assert.isTrue(count == null || count == 0, "球机已被绑定"); Assert.isTrue(count == null || count == 0, "球机已被绑定");
cameraMapper.deleteById(id); cameraMapper.deleteById(id);
cameraChoice.delCamera(id);
} }
public PageInfo<Camera> cameras(StreetSearch streetSearch) { public PageInfo<Camera> cameras(StreetSearch streetSearch) {
@ -135,10 +139,10 @@ public class CameraService {
public void run() { public void run() {
try { try {
Boolean ok = false; Boolean ok = false;
if(configProperties.getCameraConfig().getCameraType() == ConfigProperties.HIK_CAMERA){ if(camera.getType() == 0){
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()).intValue());
}else {
ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId())); ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()));
}else {
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()).intValue());
} }
if(ok){ if(ok){
@ -265,11 +269,11 @@ public class CameraService {
conver(cameraIO,type); conver(cameraIO,type);
ioMapper.updateById(cameraIO); ioMapper.updateById(cameraIO);
} }
boolean ok = cameraControlModule.connectStatus(cameraId); boolean ok = cameraChoice.connectStatus(cameraId);
if(!ok){ if(!ok){
} }
cameraControlModule.ptz(ptzId,cameraIO.getName(),cameraId); cameraChoice.ptz(ptzId,cameraIO.getName(),cameraId);
log.info("设置 预置点 球机ID:{},预置点ID:{}", cameraId, ptzId); log.info("设置 预置点 球机ID:{},预置点ID:{}", cameraId, ptzId);
return cameraIO.getId(); return cameraIO.getId();
} }
@ -308,7 +312,7 @@ public class CameraService {
} }
public void cameraConnectStatus(Integer cameraId){ public void cameraConnectStatus(Integer cameraId){
Boolean ok = cameraControlModule.connectStatus(cameraId); Boolean ok = cameraChoice.connectStatus(cameraId);
if(!ok){ if(!ok){
log.error("camera unconnected,cameraId:{}",cameraId); log.error("camera unconnected,cameraId:{}",cameraId);
Camera camera = cameraMapper.selectById(cameraId); Camera camera = cameraMapper.selectById(cameraId);
@ -317,7 +321,8 @@ public class CameraService {
} }
public void cameraLogin(Camera camera){ public void cameraLogin(Camera camera){
NetSDKLib.LLong lLong = cameraControlLoginModule.login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword());
NetSDKLib.LLong lLong = cameraLoginChoice.login(camera);
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);

@ -50,37 +50,17 @@ public class InitService implements ApplicationRunner {
private PlcService plcService; private PlcService plcService;
@Resource @Resource
private CameraService cameraService; private CameraService cameraService;
@Resource
private CameraChoice cameraChoice;
@Bean
public CameraControlLoginModule cameraControlLoginModule(){
CameraControlLoginModule cameraControlLoginModule = null;
if(configProperties.getCameraConfig().getCameraType() == ConfigProperties.JOYWARE_CAMERA){
cameraControlLoginModule = new JoywareLoginModuleImpl();
}else {
cameraControlLoginModule = new HikLoginModuleImpl();
}
cameraService.setCameraLoginModule(cameraControlLoginModule);
return cameraControlLoginModule;
}
@Bean
public CameraControlModule cameraControlModule(ConfigProperties configProperties){
CameraControlModule cameraControlModule = null;
if(configProperties.getCameraConfig().getCameraType() == ConfigProperties.JOYWARE_CAMERA){
cameraControlModule = new JoywareCameraControlModuleImpl();
}else {
cameraControlModule = new HikCameraControlModuleImpl();
}
plcService.setCameraControlModule(cameraControlModule);
cameraService.setCameraControlModule(cameraControlModule);
return cameraControlModule;
}
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
//球机登录 //球机登录
List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0)); List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0));
cameras.forEach(camera -> { cameras.forEach(camera -> {
cameraChoice.addCamera(camera);
LoginThread loginThread = new LoginThread(camera); LoginThread loginThread = new LoginThread(camera);
loginThread.start(); loginThread.start();
}); });

@ -63,21 +63,17 @@ public class PlcService {
private StockService stockService; private StockService stockService;
@Resource @Resource
private CameraService cameraService; private CameraService cameraService;
private CameraControlModule cameraControlModule;
@Resource @Resource
private SensorService sensorService; private SensorService sensorService;
@Resource @Resource
private RFIDService rfidService; private RFIDService rfidService;
@Resource @Resource
private CheckLogMapper checkLogMapper; private CheckLogMapper checkLogMapper;
@Resource
private CameraChoice cameraChoice;
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,8,200,TimeUnit.MINUTES,new ArrayBlockingQueue<>(100000)); private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,8,200,TimeUnit.MINUTES,new ArrayBlockingQueue<>(100000));
public void setCameraControlModule(CameraControlModule cameraControlModule){
this.cameraControlModule = cameraControlModule;
}
/** /**
* *
*/ */
@ -333,7 +329,7 @@ public class PlcService {
if(delay){ if(delay){
TaskDelayExecutor.addPicDelayTask(cameraId,realPath,delayTime); TaskDelayExecutor.addPicDelayTask(cameraId,realPath,delayTime);
}else { }else {
cameraControlModule.pic(cameraId,0,realPath); cameraChoice.pic(cameraId,0,realPath);
} }
return path; return path;
} }
@ -348,7 +344,7 @@ public class PlcService {
Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId); Integer ptzId = cameraService.getPtzIdByCodeAndCameraId(code, cameraId);
if (ptzId != null && ptzId >= 0) { if (ptzId != null && ptzId >= 0) {
log.info("gyrate camera by code, code{},cameraId:{},ptId:{}", code, cameraId, ptzId); log.info("gyrate camera by code, code{},cameraId:{},ptId:{}", code, cameraId, ptzId);
cameraControlModule.toPtz(ptzId,cameraId); cameraChoice.toPtz(ptzId,cameraId);
} else { } else {
log.error("ptz not found ,code{},cameraId:{}", code, cameraId); log.error("ptz not found ,code{},cameraId:{}", code, cameraId);
} }

@ -2,6 +2,9 @@ package com.zhehekeji.web.service.ksec;
import lombok.Data; import lombok.Data;
import java.util.HashSet;
import java.util.Set;
@Data @Data
public class KsecDataInfo { public class KsecDataInfo {
@ -37,10 +40,23 @@ public class KsecDataInfo {
private Integer ackStatus; private Integer ackStatus;
private String trayCode; private String trayCodes;
private Integer row;
private Integer check;
/** /**
* *
*/ */
private String lotnum; private String lotnum;
public Set<String> getAllTrayCodes(){
String [] strings = trayCodes.split(",");
Set<String> sets = new HashSet<>();
for(int i = 0;i<strings.length;i++){
sets.add(strings[i]);
}
return sets;
}
} }

@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -86,17 +87,6 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
String srmNumber = null; String srmNumber = null;
String cmdName = null; String cmdName = null;
if(dataInfo != null){ if(dataInfo != null){
//左右换过来
if(dataInfo.getFromDirection() == 1){
dataInfo.setFromDirection(2);
}else {
dataInfo.setFromDirection(1);
}
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){
dataInfo.setToDirection(2);
}else {
dataInfo.setToDirection(1);
}
plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(), dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(), dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(), dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),dataInfo.getToSeparation(),lotnum); plcCmdInfo = new PlcCmdInfo(dataInfo.getSRMNumber(), dataInfo.getTaskId(), dataInfo.getFromSide(), dataInfo.getFromDirection(), dataInfo.getFromColumn(), dataInfo.getFromRow(), dataInfo.getFromSeparation(),dataInfo.getToSide(), dataInfo.getToDirection(), dataInfo.getToColumn(), dataInfo.getToRow(),dataInfo.getToSeparation(),lotnum);
srmNumber = dataInfo.getSRMNumber(); srmNumber = dataInfo.getSRMNumber();
@ -184,13 +174,14 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
//盘点 //盘点
//转球机到盘点位 然后拍照 //转球机到盘点位 然后拍照
// if(!StringUtils.isEmpty(lotnum) && !lotnum.equals(lastLotnum)){ if(!StringUtils.isEmpty(lotnum) && !lotnum.equals(lastLotnum)){
// //需要把stock表truncate //需要把stock表truncate
// FileUtil.save(lotnum,"lastLotnum"); FileUtil.save(lotnum,"lastLotnum");
// tcpLogger.info("truncate table ,last lotnum:{},new lotnum:{}",lastLotnum,lotnum); tcpLogger.info("truncate table ,last lotnum:{},new lotnum:{}",lastLotnum,lotnum);
// plcService.truncateStock(); plcService.truncateStock();
// lastLotnum = lotnum; lastLotnum = lotnum;
// } }
// plcCmdInfo.setTimes(1); // plcCmdInfo.setTimes(1);
// Boolean ok = plcService.check(plcCmdInfo,ksecInfo.getData().getCmdName(), dataInfo.getCode(), dataInfo.getTrayCode()); // Boolean ok = plcService.check(plcCmdInfo,ksecInfo.getData().getCmdName(), dataInfo.getCode(), dataInfo.getTrayCode());
// if(ok){ // if(ok){
@ -203,8 +194,18 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
String code = dataInfo.getCmdName(); String code = dataInfo.getCmdName();
if("E1".equals(code)){ if("E1".equals(code)){
plcService.RFIDCheck(plcCmdInfo); plcService.RFIDCheck(plcCmdInfo);
}else if("E2".equals(code)){
Set<String> scanCodes = plcService.RFIDStop(plcCmdInfo);
if(scanCodes.containsAll(dataInfo.getAllTrayCodes())){
dataInfo.setCheck(1);
}else { }else {
plcService.RFIDStop(plcCmdInfo); dataInfo.setCheck(0);
}
dataInfo.setTrayCodes(null);
dataInfo.setCmdName("E3");
ksecInfo.setHeader("LP");
ksecInfo.setData(dataInfo);
ctx.channel().writeAndFlush(ksecInfo);
} }
} }

@ -14,7 +14,7 @@ spring:
testWhileIdle: false testWhileIdle: false
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 60000
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://115.236.65.98:12004/lia_duoji_test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 url: jdbc:mysql://115.236.65.98:12004/lia_duoji_nanjing_zhongyan?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
# --------本服务端口号 # --------本服务端口号
@ -30,7 +30,8 @@ cameraConfig:
cameraType: 0 cameraType: 0
cameraPassword: a1234567 cameraPassword: a1234567
cameraUser: admin cameraUser: admin
cameraPort: 37777 cameraPort0: 37777
cameraPort1: 8000
videoServer: 127.0.0.1:8083 videoServer: 127.0.0.1:8083
#相机抓图延迟 毫秒,这个延迟是等待球机球机转动到位,然后拍照的 #相机抓图延迟 毫秒,这个延迟是等待球机球机转动到位,然后拍照的
delayCaptureTime: 3500 delayCaptureTime: 3500

Loading…
Cancel
Save