球机页面修改

增加不再关注昆船连接
光源控制增加只采用tcp控制的
球机类型修改
bozhou-古井贡酒
LAPTOP-S9HJSOEB\昊天 2 years ago
parent c14541a1fa
commit 6e864b75c6

@ -297,6 +297,7 @@ public class CameraControlController {
public Result pic(@PathVariable Integer id) { public Result pic(@PathVariable Integer id) {
checkLogin(id); checkLogin(id);
String path = "D:\\work\\"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".jpeg"; String path = "D:\\work\\"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".jpeg";
cameraControlModule.pic(id,0,path);
TaskDelayExecutor.addPicDelayTask(id,path,0L); TaskDelayExecutor.addPicDelayTask(id,path,0L);
return Result.success(path); return Result.success(path);
} }

@ -40,6 +40,13 @@ public class RealTimeController {
return Result.success(cameraService.allCameras(0)); return Result.success(cameraService.allCameras(0));
} }
@GetMapping("/allCameras")
@ApiOperation(value = "全部球机")
//@SessionHandler
public Result<List<Camera>> allCameras() {
return Result.success(cameraService.allCameras());
}
@GetMapping("/allCameras2") @GetMapping("/allCameras2")
@ApiOperation(value = "全部球机") @ApiOperation(value = "全部球机")
//@SessionHandler //@SessionHandler

@ -96,6 +96,8 @@ public class StreetController {
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
}else if (configProperties.getLightSource().getType() == 3){
LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),1);
} }
}); });
@ -119,6 +121,8 @@ public class StreetController {
log.info("ip:{},status:{}",lightSource.getIp(),status); log.info("ip:{},status:{}",lightSource.getIp(),status);
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
}else if (configProperties.getLightSource().getType() == 3){
LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0);
} }
}); });
@ -139,6 +143,8 @@ public class StreetController {
equip.DisConnect(); equip.DisConnect();
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
}else if (configProperties.getLightSource().getType() == 3){
LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),1);
} }
}); });
@ -159,6 +165,8 @@ public class StreetController {
equip.DisConnect(); equip.DisConnect();
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
}else if (configProperties.getLightSource().getType() == 3){
LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0);
} }
}); });

@ -2,6 +2,7 @@ package com.zhehekeji.web.lib;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.concurrent.Delayed; import java.util.concurrent.Delayed;
@ -9,6 +10,7 @@ import java.util.concurrent.TimeUnit;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@Slf4j
public class CameraDelayTask implements Delayed { public class CameraDelayTask implements Delayed {
private Integer cameraId; private Integer cameraId;
@ -37,6 +39,7 @@ public class CameraDelayTask implements Delayed {
this.path = path; this.path = path;
this.type = type; this.type = type;
this.executeTime = System.currentTimeMillis()+delayTime; this.executeTime = System.currentTimeMillis()+delayTime;
log.info("cameraId:{},executeTime:{},systemTime:{},path:{},type:{},delayTime:{}",cameraId,executeTime,System.currentTimeMillis(),path,type,delayTime);
this.delayTime = delayTime; this.delayTime = delayTime;
} }

@ -251,6 +251,7 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
short wPicQuality = 0; short wPicQuality = 0;
HCNetSDK.NET_DVR_JPEGPARA jpegpara = new HCNetSDK.NET_DVR_JPEGPARA(wPicSize, wPicQuality); HCNetSDK.NET_DVR_JPEGPARA jpegpara = new HCNetSDK.NET_DVR_JPEGPARA(wPicSize, wPicQuality);
boolean picResult = HikLoginModuleImpl.hcNetsdk.NET_DVR_CaptureJPEGPicture(lUserId, 1, jpegpara, path); boolean picResult = HikLoginModuleImpl.hcNetsdk.NET_DVR_CaptureJPEGPicture(lUserId, 1, jpegpara, path);
log.info("picPath:{},cameraId:{}",path,cameraId);
if (!picResult) { if (!picResult) {
log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId); log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId);
} }

@ -115,7 +115,7 @@ public class InitService implements ApplicationRunner {
}else { }else {
log.error("ksec no config"); log.error("ksec no config");
} }
} }else if(configProperties.getServerMode() == 3){}
TaskDelayExecutor.runMp4DownloadExecutor(); TaskDelayExecutor.runMp4DownloadExecutor();
} }

@ -6,6 +6,12 @@ import com.zhehekeji.web.mapper.LightSourceMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -22,4 +28,57 @@ public class LightSourceService {
public List<LightSource> getLightSourceByStreetId(Integer streetId){ public List<LightSource> getLightSourceByStreetId(Integer streetId){
return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",streetId)); return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",streetId));
} }
public static void main(String[] args) {
LightSourceService.lightController("10.135.207.121",9900,0);
LightSourceService.lightController("127.0.0.1",9900,1);
}
/**
*
* @param ip
* @param port
* @param stat 12
*/
public static void lightController(String ip ,Integer port,Integer stat){
Socket socket = new Socket();
OutputStream os = null;
InputStream is = null;
try {
socket.connect(new InetSocketAddress(ip,port),3000);
os = socket.getOutputStream();
is = socket.getInputStream();
int i = 0;
socket.setSoTimeout(1000);
String startCmd = "<1,"+stat+",post>";
byte[]bytes = startCmd.getBytes(StandardCharsets.UTF_8);
os.write(bytes);
} catch (IOException e) {
}finally {
if(os != null){
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(is != null){
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }

@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ -124,4 +127,40 @@ public class PlcCmdInfo {
return ""; return "";
} }
} }
//针对单双伸货架 单伸的是空,双伸且为外侧为 Out
public String getEndStr(int times){
List<String > endString = new ArrayList<>();
if (times <= 2) {
if (column1 == 65){
endString.add("B");
}else {
endString.add(column1%2 == 1 ? "F" : "B") ;
}
} else if(times <= 4) {
if (column2 == 65){
endString.add("B");
}else {
endString.add(column2%2 == 1 ? "F" : "B") ;
}
}else {
}
if (times <= 2) {
endString.add(leftRight1 == 1 ? "L" : "R") ;
} else if(times <= 4) {
endString.add(leftRight2 == 1 ? "L" : "R") ;
}else {
}
if (times <= 2) {
endString.add(separation1 == 1 ? "I" : "O") ;
} else if(times <= 4) {
endString.add(separation2 == 1 ? "I" : "O") ;
}else {
}
return String.join("-",endString);
}
} }

@ -322,9 +322,9 @@ public class PlcService {
Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId()); Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId());
//只进行相机方向判断左边 //只进行相机方向判断左边
if (code.contains("L")) { if (code.contains("L")) {
return street.getCamera1Id();
} else {
return street.getCamera2Id(); return street.getCamera2Id();
} else {
return street.getCamera1Id();
} }
} }
@ -373,6 +373,7 @@ public class PlcService {
public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) { public String cameraCapture(Integer cameraId, Boolean delay, Long delayTime, String path) {
//String path = PathUtil.createFileName("jpg",cameraId); //String path = PathUtil.createFileName("jpg",cameraId);
String realPath = configProperties.getSavePath().getMediaPath() + path; String realPath = configProperties.getSavePath().getMediaPath() + path;
log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath,delayTime);
if (delay) { if (delay) {
TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime); TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime);
} else { } else {
@ -646,7 +647,7 @@ public class PlcService {
log.info("camera ptz" + c); log.info("camera ptz" + c);
gyrateCameraByCode(cameraId, c); gyrateCameraByCode(cameraId, c);
} else { } else {
String c = cmdCode + "1"; String c = cmdCode + "1-" +plcCmdInfo.getEndStr(1);
gyrateCameraByCode(cameraId, c); gyrateCameraByCode(cameraId, c);
try { try {
Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime()); Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime());
@ -812,7 +813,7 @@ public class PlcService {
plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation()); plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation());
plcCmdInfo.setToSeparation(dataInfo.getToSeparation()); plcCmdInfo.setToSeparation(dataInfo.getToSeparation());
plcCmdInfo.setToSide(dataInfo.getToSide()); plcCmdInfo.setToSide(dataInfo.getToSide());
//左右不过来 //左右不
if(dataInfo.getFromDirection() == 1){ if(dataInfo.getFromDirection() == 1){
//dataInfo.setFromDirection(2); //dataInfo.setFromDirection(2);
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
@ -821,7 +822,7 @@ public class PlcService {
plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); plcCmdInfo.setLeftRight1(dataInfo.getFromDirection());
} }
if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){ if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){
//dataInfo.setToDirection(2); //dataInfo.setToDirection(2);
plcCmdInfo.setLeftRight2(dataInfo.getToDirection()); plcCmdInfo.setLeftRight2(dataInfo.getToDirection());
}else { }else {
//dataInfo.setToDirection(1); //dataInfo.setToDirection(1);
@ -877,7 +878,7 @@ public class PlcService {
//执行动作,需要保存执行到第几步了 //执行动作,需要保存执行到第几步了
Integer times = GoodsActionTimes.get(dataInfo.getCmdName()); Integer times = GoodsActionTimes.get(dataInfo.getCmdName());
plcCmdInfo.setTimes(times); plcCmdInfo.setTimes(times);
code = code + "-" + plcCmdInfo.getLeftRightStr(times) + plcCmdInfo.getInOutStr(times); code = code + "-" + plcCmdInfo.getEndStr(times);
//执行动作 //执行动作
try { try {
action(plcCmdInfo, times, code); action(plcCmdInfo, times, code);

@ -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://127.0.0.1:3306/lia_duoji?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:3306/lia_duoji_gujinggong?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: root username: root
validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
# --------本服务端口号 # --------本服务端口号

Loading…
Cancel
Save