diff --git a/web/src/main/java/com/zhehekeji/web/controller/CameraControlController.java b/web/src/main/java/com/zhehekeji/web/controller/CameraControlController.java index 546ad2b..03cc858 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/CameraControlController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/CameraControlController.java @@ -297,6 +297,7 @@ public class CameraControlController { public Result pic(@PathVariable Integer id) { checkLogin(id); String path = "D:\\work\\"+LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".jpeg"; + cameraControlModule.pic(id,0,path); TaskDelayExecutor.addPicDelayTask(id,path,0L); return Result.success(path); } diff --git a/web/src/main/java/com/zhehekeji/web/controller/RealTimeController.java b/web/src/main/java/com/zhehekeji/web/controller/RealTimeController.java index afccf53..57d19c2 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/RealTimeController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/RealTimeController.java @@ -40,6 +40,13 @@ public class RealTimeController { return Result.success(cameraService.allCameras(0)); } + @GetMapping("/allCameras") + @ApiOperation(value = "全部球机") + //@SessionHandler + public Result> allCameras() { + return Result.success(cameraService.allCameras()); + } + @GetMapping("/allCameras2") @ApiOperation(value = "全部球机") //@SessionHandler diff --git a/web/src/main/java/com/zhehekeji/web/controller/StreetController.java b/web/src/main/java/com/zhehekeji/web/controller/StreetController.java index e3dbe9d..042b03c 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/StreetController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/StreetController.java @@ -96,6 +96,8 @@ public class StreetController { }else if(configProperties.getLightSource().getType() == 2){ 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); }else if(configProperties.getLightSource().getType() == 2){ 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(); }else if(configProperties.getLightSource().getType() == 2){ 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(); }else if(configProperties.getLightSource().getType() == 2){ HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); + }else if (configProperties.getLightSource().getType() == 3){ + LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0); } }); diff --git a/web/src/main/java/com/zhehekeji/web/lib/CameraDelayTask.java b/web/src/main/java/com/zhehekeji/web/lib/CameraDelayTask.java index 3552de4..abee0c2 100644 --- a/web/src/main/java/com/zhehekeji/web/lib/CameraDelayTask.java +++ b/web/src/main/java/com/zhehekeji/web/lib/CameraDelayTask.java @@ -2,6 +2,7 @@ package com.zhehekeji.web.lib; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import java.time.LocalDateTime; import java.util.concurrent.Delayed; @@ -9,6 +10,7 @@ import java.util.concurrent.TimeUnit; @Data @AllArgsConstructor +@Slf4j public class CameraDelayTask implements Delayed { private Integer cameraId; @@ -37,6 +39,7 @@ public class CameraDelayTask implements Delayed { this.path = path; this.type = type; this.executeTime = System.currentTimeMillis()+delayTime; + log.info("cameraId:{},executeTime:{},systemTime:{},path:{},type:{},delayTime:{}",cameraId,executeTime,System.currentTimeMillis(),path,type,delayTime); this.delayTime = delayTime; } diff --git a/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java b/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java index 68cafc2..0155e3c 100644 --- a/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java +++ b/web/src/main/java/com/zhehekeji/web/lib/hik/HikCameraControlModuleImpl.java @@ -251,6 +251,7 @@ public class HikCameraControlModuleImpl implements CameraControlModule { short wPicQuality = 0; HCNetSDK.NET_DVR_JPEGPARA jpegpara = new HCNetSDK.NET_DVR_JPEGPARA(wPicSize, wPicQuality); boolean picResult = HikLoginModuleImpl.hcNetsdk.NET_DVR_CaptureJPEGPicture(lUserId, 1, jpegpara, path); + log.info("picPath:{},cameraId:{}",path,cameraId); if (!picResult) { log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId); } diff --git a/web/src/main/java/com/zhehekeji/web/service/InitService.java b/web/src/main/java/com/zhehekeji/web/service/InitService.java index a115466..273992a 100644 --- a/web/src/main/java/com/zhehekeji/web/service/InitService.java +++ b/web/src/main/java/com/zhehekeji/web/service/InitService.java @@ -115,7 +115,7 @@ public class InitService implements ApplicationRunner { }else { log.error("ksec no config"); } - } + }else if(configProperties.getServerMode() == 3){} TaskDelayExecutor.runMp4DownloadExecutor(); } diff --git a/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java b/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java index 3f60d19..a0e4c2f 100644 --- a/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java +++ b/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java @@ -6,6 +6,12 @@ import com.zhehekeji.web.mapper.LightSourceMapper; import org.springframework.beans.factory.annotation.Autowired; 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.List; @@ -22,4 +28,57 @@ public class LightSourceService { public List getLightSourceByStreetId(Integer streetId){ return lightSourceMapper.selectList(new QueryWrapper().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 1开启,2关闭 + */ + 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(); + } + + } + + } } diff --git a/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java b/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java index eebbf4b..002cbff 100644 --- a/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java +++ b/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java @@ -4,6 +4,9 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; + @Data @AllArgsConstructor @NoArgsConstructor @@ -124,4 +127,40 @@ public class PlcCmdInfo { return ""; } } + + + //针对单双伸货架 单伸的是空,双伸且为外侧为 Out + public String getEndStr(int times){ + List 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); + } } diff --git a/web/src/main/java/com/zhehekeji/web/service/PlcService.java b/web/src/main/java/com/zhehekeji/web/service/PlcService.java index 6bf0ae8..361a514 100644 --- a/web/src/main/java/com/zhehekeji/web/service/PlcService.java +++ b/web/src/main/java/com/zhehekeji/web/service/PlcService.java @@ -322,9 +322,9 @@ public class PlcService { Street street = streetService.getStreetByPlcId(plcCmdInfo.getPlcId()); //只进行相机方向判断左边 if (code.contains("L")) { - return street.getCamera1Id(); - } else { 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) { //String path = PathUtil.createFileName("jpg",cameraId); String realPath = configProperties.getSavePath().getMediaPath() + path; + log.info("capture picture, cameraId:{},path:{}delayTime:{}", cameraId, realPath,delayTime); if (delay) { TaskDelayExecutor.addPicDelayTask(cameraId, realPath, delayTime); } else { @@ -646,7 +647,7 @@ public class PlcService { log.info("camera ptz" + c); gyrateCameraByCode(cameraId, c); } else { - String c = cmdCode + "1"; + String c = cmdCode + "1-" +plcCmdInfo.getEndStr(1); gyrateCameraByCode(cameraId, c); try { Thread.sleep(configProperties.getCameraConfig().getDelayCaptureTime()); @@ -812,7 +813,7 @@ public class PlcService { plcCmdInfo.setFromSeparation(dataInfo.getFromSeparation()); plcCmdInfo.setToSeparation(dataInfo.getToSeparation()); plcCmdInfo.setToSide(dataInfo.getToSide()); - //左右不换过来 + //左右不交换 if(dataInfo.getFromDirection() == 1){ //dataInfo.setFromDirection(2); plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); @@ -821,7 +822,7 @@ public class PlcService { plcCmdInfo.setLeftRight1(dataInfo.getFromDirection()); } if(dataInfo.getToDirection() != null && dataInfo.getToDirection() == 1){ - //dataInfo.setToDirection(2); + //dataInfo.setToDirection(2); plcCmdInfo.setLeftRight2(dataInfo.getToDirection()); }else { //dataInfo.setToDirection(1); @@ -877,7 +878,7 @@ public class PlcService { //执行动作,需要保存执行到第几步了 Integer times = GoodsActionTimes.get(dataInfo.getCmdName()); plcCmdInfo.setTimes(times); - code = code + "-" + plcCmdInfo.getLeftRightStr(times) + plcCmdInfo.getInOutStr(times); + code = code + "-" + plcCmdInfo.getEndStr(times); //执行动作 try { action(plcCmdInfo, times, code); diff --git a/web/src/main/resources/application-prod.yml b/web/src/main/resources/application-prod.yml index c8f8e8e..267c69f 100644 --- a/web/src/main/resources/application-prod.yml +++ b/web/src/main/resources/application-prod.yml @@ -14,7 +14,7 @@ spring: testWhileIdle: false timeBetweenEvictionRunsMillis: 60000 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 validationQuery: SELECT 1 FROM DUAL # --------本服务端口号