Parcourir la source

项目整理,采用总线方式管理数据

qzyReal il y a 1 an
Parent
commit
e059871c40
100 fichiers modifiés avec 643 ajouts et 648 suppressions
  1. 8 0
      config.xml
  2. 0 67
      src/main/java/com/gzlh/api/CheckCarNumberBO.java
  3. 7 5
      src/main/java/com/gzlh/api/OpenApi.java
  4. 0 2
      src/main/java/com/gzlh/background/client/BackgroundClientNetty.java
  5. 8 0
      src/main/java/com/gzlh/bus/CenterActionCommand.java
  6. 29 0
      src/main/java/com/gzlh/bus/EventBus.java
  7. 48 0
      src/main/java/com/gzlh/bus/EventDataManager.java
  8. 25 19
      src/main/java/com/gzlh/bus/EventThread.java
  9. 1 0
      src/main/java/com/gzlh/config/ApplicationConfig.java
  10. 2 1
      src/main/java/com/gzlh/config/ModuleEnum.java
  11. 75 0
      src/main/java/com/gzlh/config/SystemObject.java
  12. 1 1
      src/main/java/com/gzlh/config/dto/ApplicationConfigDTO.java
  13. 1 1
      src/main/java/com/gzlh/config/dto/EventDTO.java
  14. 23 12
      src/main/java/com/gzlh/config/hksdk/AlarmParseService.java
  15. 1 2
      src/main/java/com/gzlh/config/hksdk/EventCallback.java
  16. 1 2
      src/main/java/com/gzlh/config/hksdk/FExceptionCallBack.java
  17. 1 1
      src/main/java/com/gzlh/config/hksdk/HCNetSDK.java
  18. 1 1
      src/main/java/com/gzlh/config/hksdk/HkLibProperties.java
  19. 1 1
      src/main/java/com/gzlh/config/hksdk/HkUtils.java
  20. 1 3
      src/main/java/com/gzlh/config/hksdk/InitSDK.java
  21. 1 2
      src/main/java/com/gzlh/config/hksdk/MessageCallBack.java
  22. 2 7
      src/main/java/com/gzlh/config/hksdk/StartUpInit.java
  23. 51 0
      src/main/java/com/gzlh/config/hksdk/bo/HKCacheManager.java
  24. 1 1
      src/main/java/com/gzlh/config/task/Task.java
  25. 1 1
      src/main/java/com/gzlh/config/task/TaskService.java
  26. 1 1
      src/main/java/com/gzlh/device/camera/CameraServer.java
  27. 1 1
      src/main/java/com/gzlh/device/camera/action/CameraCommonAction.java
  28. 1 1
      src/main/java/com/gzlh/device/camera/brand/CameraBrandType.java
  29. 1 1
      src/main/java/com/gzlh/device/camera/client/CameraClientHandler.java
  30. 2 2
      src/main/java/com/gzlh/device/camera/client/CameraNettyConfig.java
  31. 3 6
      src/main/java/com/gzlh/device/camera/controller/CameraController.java
  32. 1 1
      src/main/java/com/gzlh/device/camera/event/CameraDefaultEvent.java
  33. 2 2
      src/main/java/com/gzlh/device/camera/factory/CameraFactory.java
  34. 2 2
      src/main/java/com/gzlh/device/camera/handler/ICameraHandler.java
  35. 4 4
      src/main/java/com/gzlh/device/camera/handler/impl/CameraHandlerHikvision.java
  36. 1 1
      src/main/java/com/gzlh/device/camera/properties/CameraPropertiesConfig.java
  37. 8 0
      src/main/java/com/gzlh/device/capture/action/ICaptureAction.java
  38. 3 3
      src/main/java/com/gzlh/device/capture/brand/CaptureBrandType.java
  39. 18 0
      src/main/java/com/gzlh/device/capture/controller/GateController.java
  40. 8 0
      src/main/java/com/gzlh/device/capture/event/CaptureEvent.java
  41. 5 6
      src/main/java/com/gzlh/device/capture/factory/CaptureFactory.java
  42. 16 0
      src/main/java/com/gzlh/device/capture/handler/ICaptureHandler.java
  43. 33 0
      src/main/java/com/gzlh/device/capture/handler/impl/CaptureHandlerHk.java
  44. 20 0
      src/main/java/com/gzlh/device/capture/properties/CapturePropertiesConfig.java
  45. 38 0
      src/main/java/com/gzlh/device/capture/task/HandlerCarImage.java
  46. 1 1
      src/main/java/com/gzlh/device/capture/utils/ZKTecoCommandUtils.java
  47. 1 1
      src/main/java/com/gzlh/device/capture/utils/ZKTecoUtils.java
  48. 1 1
      src/main/java/com/gzlh/device/infrared/action/InfraredAction.java
  49. 1 1
      src/main/java/com/gzlh/device/infrared/brand/RedBrandType.java
  50. 3 3
      src/main/java/com/gzlh/device/infrared/client/RedClientHandler.java
  51. 2 2
      src/main/java/com/gzlh/device/infrared/client/RedNettyConfig.java
  52. 1 1
      src/main/java/com/gzlh/device/infrared/config/RedPropertiesConfig.java
  53. 2 2
      src/main/java/com/gzlh/device/infrared/factory/RedFactory.java
  54. 2 2
      src/main/java/com/gzlh/device/infrared/handler/IRedHandler.java
  55. 6 13
      src/main/java/com/gzlh/device/infrared/handler/impl/RedHandlerSoarDAM0404.java
  56. 1 1
      src/main/java/com/gzlh/device/led/LedServer.java
  57. 8 0
      src/main/java/com/gzlh/device/led/action/LedAction.java
  58. 1 1
      src/main/java/com/gzlh/device/led/brand/LedBrandType.java
  59. 1 2
      src/main/java/com/gzlh/device/led/client/LedClientHandler.java
  60. 6 4
      src/main/java/com/gzlh/device/led/client/LedNettyConfig.java
  61. 1 1
      src/main/java/com/gzlh/device/led/event/LedDefaultEvent.java
  62. 2 2
      src/main/java/com/gzlh/device/led/factory/LedFactory.java
  63. 2 4
      src/main/java/com/gzlh/device/led/handler/ILedHandler.java
  64. 11 7
      src/main/java/com/gzlh/device/led/handler/impl/LedHandlerYangBandV4d2.java
  65. 1 1
      src/main/java/com/gzlh/device/led/properties/LedPropertiesConfig.java
  66. 1 1
      src/main/java/com/gzlh/device/led/utils/CRC16.java
  67. 1 1
      src/main/java/com/gzlh/device/led/utils/ColorConver.java
  68. 1 3
      src/main/java/com/gzlh/device/led/utils/YangBandPackage.java
  69. 1 6
      src/main/java/com/gzlh/device/weighbridge/Test.java
  70. 1 1
      src/main/java/com/gzlh/device/weighbridge/action/WeighbridgeCommonAction.java
  71. 1 1
      src/main/java/com/gzlh/device/weighbridge/brand/WeighbridgeBrandType.java
  72. 3 3
      src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeClientHandler.java
  73. 2 2
      src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeNettyConfig.java
  74. 1 1
      src/main/java/com/gzlh/device/weighbridge/config/WeighbridgePropertiesConfig.java
  75. 1 1
      src/main/java/com/gzlh/device/weighbridge/event/WeighbridgeEvent.java
  76. 2 2
      src/main/java/com/gzlh/device/weighbridge/factory/WeighbridgeFactory.java
  77. 2 2
      src/main/java/com/gzlh/device/weighbridge/handler/IWeighbridgeHandler.java
  78. 5 7
      src/main/java/com/gzlh/device/weighbridge/handler/impl/CommonWeighbridgeHandler.java
  79. 4 4
      src/main/java/com/gzlh/device/weighbridge/handler/impl/WeighbridgeHandlerKeDaKD8137.java
  80. 5 5
      src/main/java/com/gzlh/device/weighbridge/handler/impl/WeighbridgeHandlerKeLi.java
  81. 1 2
      src/main/java/com/gzlh/device/weighbridge/server/CheckManager.java
  82. 1 1
      src/main/java/com/gzlh/device/weighbridge/server/Count.java
  83. 39 0
      src/main/java/com/gzlh/entity/CommandBO.java
  84. 6 1
      src/main/java/com/gzlh/entity/ReqBO.java
  85. 0 14
      src/main/java/com/gzlh/event/CenterActionCommand.java
  86. 0 50
      src/main/java/com/gzlh/event/EventBus.java
  87. 0 11
      src/main/java/com/gzlh/gate/bo/ReqBO.java
  88. 0 31
      src/main/java/com/gzlh/gate/controller/GateController.java
  89. 0 20
      src/main/java/com/gzlh/gate/handler/IGateHandler.java
  90. 0 100
      src/main/java/com/gzlh/gate/handler/impl/GateHandlerShangJi.java
  91. 0 14
      src/main/java/com/gzlh/gate/properties/GatePropertiesConfig.java
  92. 0 45
      src/main/java/com/gzlh/gate/task/GateBase64ToImage.java
  93. 0 4
      src/main/java/com/gzlh/gate/task/GateService.java
  94. 0 19
      src/main/java/com/gzlh/job/BeatTask.java
  95. 0 22
      src/main/java/com/gzlh/job/CleanTask.java
  96. 0 26
      src/main/java/com/gzlh/job/UploadTask.java
  97. 37 21
      src/main/java/com/gzlh/startup/StartupRunner.java
  98. 0 8
      src/main/java/com/gzlh/utils/WeightCacheManager.java
  99. 3 5
      src/main/java/com/gzlh/utils/WordHandlerUtils.java
  100. 13 4
      src/main/resources/application.yml

+ 8 - 0
config.xml

@@ -19,5 +19,13 @@
                 <action>LED.LED_SHOW_CONTENT(欢迎使用红外)</action>
             </actionList>
         </event>
+        <event>
+            <name>CAPTURE.CAPTURE_CAR_NO</name>
+            <actionList>
+                <action>LED.LED_SHOW_CONTENT(识别到车牌${platNo})</action>
+                <action>CENTER.TIMER_SLEEP(10000)</action>
+                <action>CAPTURE.UPLOAD_CAR_NO</action>
+            </actionList>
+        </event>
     </eventList>
 </config>

+ 0 - 67
src/main/java/com/gzlh/api/CheckCarNumberBO.java

@@ -1,67 +0,0 @@
-package com.gzlh.api;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.io.Serializable;
-
-
-public class CheckCarNumberBO implements Serializable {
-    /**
-     * 当前设别车牌的通道名称
-     */
-    private String ChannelName;
-    private String CarNumber;
-    /**
-     * 1 入场 2 出场
-     */
-    private int InOrOut;
-    private String ImageData;
-    /**
-     * 操作员
-     */
-    private String OperationUserName;
-
-    @JsonProperty("ChannelName")
-    public String getChannelName() {
-        return ChannelName;
-    }
-
-    public void setChannelName(String channelName) {
-        ChannelName = channelName;
-    }
-
-    @JsonProperty("CarNumber")
-    public String getCarNumber() {
-        return CarNumber;
-    }
-
-    public void setCarNumber(String carNumber) {
-        CarNumber = carNumber;
-    }
-
-    @JsonProperty("InOrOut")
-    public int getInOrOut() {
-        return InOrOut;
-    }
-
-    public void setInOrOut(int inOrOut) {
-        InOrOut = inOrOut;
-    }
-
-    @JsonProperty("ImageData")
-    public String getImageData() {
-        return ImageData;
-    }
-
-    public void setImageData(String imageData) {
-        ImageData = imageData;
-    }
-
-    public String getOperationUserName() {
-        return OperationUserName;
-    }
-
-    public void setOperationUserName(String operationUserName) {
-        OperationUserName = operationUserName;
-    }
-}

+ 7 - 5
src/main/java/com/gzlh/api/OpenApi.java

@@ -1,10 +1,11 @@
 package com.gzlh.api;
 
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.event.EventBus;
-import com.gzlh.led.event.LedDefaultEvent;
+import com.gzlh.bus.EventBus;
+import com.gzlh.config.SystemObject;
+import com.gzlh.device.led.event.LedDefaultEvent;
 import com.gzlh.utils.ResultJson;
-import com.gzlh.weighbridge.event.WeighbridgeEvent;
+import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -21,8 +22,9 @@ public class OpenApi {
 
     @RequestMapping("test")
     public ResultJson test(){
-        eventBus.start(ModuleEnum.LED_MODULE.getModuleEn()+"."+ LedDefaultEvent.READ);
-        eventBus.start(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn()+"."+ WeighbridgeEvent.READ);
+       // eventBus.startEvent(ModuleEnum.LED_MODULE.getModuleEn()+"."+ LedDefaultEvent.READ);
+       // eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn()+"."+ WeighbridgeEvent.READ);
+        SystemObject.ledFactory.handler(SystemObject.ledPropertiesConfig.getBrand()).sendMsg("你好");
         return ResultJson.success();
     }
 }

+ 0 - 2
src/main/java/com/gzlh/background/client/BackgroundClientNetty.java

@@ -1,8 +1,6 @@
 package com.gzlh.background.client;
 
 import com.gzlh.background.properties.BackgroundPropertiesConfig;
-import com.gzlh.led.properties.LedPropertiesConfig;
-import com.gzlh.socket.TestClientHandler;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;

+ 8 - 0
src/main/java/com/gzlh/bus/CenterActionCommand.java

@@ -0,0 +1,8 @@
+package com.gzlh.bus;
+
+
+public interface CenterActionCommand {
+    //现成休眠
+  String   SLEEP_COMMAND="TIMER_SLEEP";
+
+}

+ 29 - 0
src/main/java/com/gzlh/bus/EventBus.java

@@ -0,0 +1,29 @@
+package com.gzlh.bus;
+
+import cn.hutool.core.thread.ThreadUtil;
+import com.gzlh.config.dto.EventDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+@Slf4j
+public class EventBus {
+    private List<EventDTO> eventDTOList;
+
+
+    public void setEventDTOList(List<EventDTO> eventDTOList) {
+        this.eventDTOList = eventDTOList;
+    }
+
+    /**
+     * 触发事件
+     * @param eventName
+     */
+    public void startEvent(String eventName){
+        EventThread thread = new EventThread(eventName);
+        thread.setEventDTOList(eventDTOList);
+        ThreadUtil.execute(thread);
+    }
+}

+ 48 - 0
src/main/java/com/gzlh/bus/EventDataManager.java

@@ -0,0 +1,48 @@
+package com.gzlh.bus;
+
+import cn.hutool.cache.CacheUtil;
+import cn.hutool.cache.impl.TimedCache;
+import cn.hutool.core.util.ReflectUtil;
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
+import com.gzlh.config.SystemObject;
+import com.gzlh.entity.ReqBO;
+
+public class EventDataManager {
+
+    private static final TimedCache<String, ReqBO> CACHE_MAP= CacheUtil.newTimedCache(20*60*1000);
+
+    private static final String KEY="event_key";
+
+    /**
+     * 缓存
+     * @param field
+     * @param value
+     */
+    public static void cacheData(String field,Object value){
+        ReqBO reqBO=  CACHE_MAP.get(KEY);
+        if (reqBO==null){
+            reqBO=new ReqBO();
+            reqBO.setDirection(1);
+        }
+        reqBO.setChannelCode(SystemObject.applicationConfig.getChannelCode());
+        ReflectUtil.setFieldValue(reqBO,field,value);
+        CACHE_MAP.put(KEY,reqBO);
+        StaticLog.info("cache bo:{}", JSONUtil.toJsonStr(reqBO));
+    }
+
+    /**
+     * 获取数据中心数据
+     * @return
+     */
+    public static ReqBO getCacheData(){
+        return CACHE_MAP.get(KEY);
+    }
+
+    /**
+     * 清除掉缓存
+     */
+    public static void cleanData(){
+        CACHE_MAP.clear();
+    }
+}

+ 25 - 19
src/main/java/com/gzlh/event/EventThread.java → src/main/java/com/gzlh/bus/EventThread.java

@@ -1,34 +1,29 @@
-package com.gzlh.event;
+package com.gzlh.bus;
 
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.NumberUtil;
-import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
+import com.gzlh.device.capture.factory.CaptureFactory;
+import com.gzlh.device.capture.properties.CapturePropertiesConfig;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.dto.EventDTO;
-import com.gzlh.infrared.config.RedPropertiesConfig;
-import com.gzlh.infrared.factory.RedFactory;
-import com.gzlh.led.factory.LedFactory;
-import com.gzlh.led.properties.LedPropertiesConfig;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import com.gzlh.config.SystemObject;
+import com.gzlh.config.dto.EventDTO;
+import com.gzlh.device.infrared.config.RedPropertiesConfig;
+import com.gzlh.device.infrared.factory.RedFactory;
+import com.gzlh.device.led.factory.LedFactory;
+import com.gzlh.device.led.properties.LedPropertiesConfig;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
 import lombok.extern.slf4j.Slf4j;
 
-import javax.annotation.Resource;
-import java.util.Date;
 import java.util.List;
 
 @Slf4j
 public class EventThread implements Runnable{
     private List<EventDTO> eventDTOList;
     private String eventName;
-    private final LedFactory ledFactory= SpringUtil.getBean(LedFactory.class);
-    private final RedFactory redFactory=SpringUtil.getBean(RedFactory.class);
-    private  final WeighbridgeFactory weighbridgeFactory=SpringUtil.getBean(WeighbridgeFactory.class);
-    private final WeighbridgePropertiesConfig weighbridgePropertiesConfig=SpringUtil.getBean(WeighbridgePropertiesConfig.class);
-    private final RedPropertiesConfig redPropertiesConfig=SpringUtil.getBean(RedPropertiesConfig.class);
-    private final LedPropertiesConfig ledPropertiesConfig=SpringUtil.getBean(LedPropertiesConfig.class);
+
+
 
     public EventThread(String eventName) {
         this.eventName=eventName;
@@ -46,6 +41,14 @@ public class EventThread implements Runnable{
      * @param eventName 服务.事件名 比如led.ready
      */
     public void handlerEvent(String eventName) {
+        LedFactory ledFactory= SystemObject.ledFactory;
+        RedFactory redFactory=SystemObject.redFactory;
+        WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
+        WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
+        RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
+        LedPropertiesConfig ledPropertiesConfig=SystemObject.ledPropertiesConfig;
+        CaptureFactory captureFactory=SystemObject.captureFactory;
+        CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
         log.info("event:{}", eventName);
         eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
                 .findFirst().ifPresent(eventDTO -> {
@@ -63,6 +66,9 @@ public class EventThread implements Runnable{
                 } else if (StrUtil.equals(module, ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn())) {
                     //动作属于地磅
                     weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).handlerAction(command);
+                }else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
+                    //动作属于抓拍单元--车牌识别
+                    captureFactory.handler(capturePropertiesConfig.getBrand()).handlerAction(command);
                 } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
                     //动作属于中心总线
                     handlerAction(command);
@@ -79,7 +85,7 @@ public class EventThread implements Runnable{
      * @param action
      */
     private void handlerAction(String action) {
-        if (StrUtil.contains(action, CenterActionCommand.SLEEP_COMMAND.getCommand())) {
+        if (StrUtil.contains(action, CenterActionCommand.SLEEP_COMMAND)) {
             //休眠
             handlerSleep(action);
         }

+ 1 - 0
src/main/java/com/gzlh/config/ApplicationConfig.java

@@ -10,5 +10,6 @@ import org.springframework.context.annotation.Configuration;
 public class ApplicationConfig {
   private String serverUrl;
   private String channelName;
+  private String channelCode;
 
 }

+ 2 - 1
src/main/java/com/gzlh/config/ModuleEnum.java

@@ -10,7 +10,8 @@ public enum ModuleEnum {
     WEIGHBRIDGE_MODULE("地磅","WEIGHBRIDGE"),
     INFRARED_MODULE("红外","INFRARED"),
     TRAFFIC_MODULE("红绿灯","TRAFFIC"),
-    GATE_MODULE("红绿灯","GATE"),
+    GATE_MODULE("道闸","GATE"),
+    CAPTURE_MODULE("抓拍单元","CAPTURE"),
     PLC_MODULE("PLC","PLC"),
     CENTER_MODULE("action调度中心","CENTER"),
 

+ 75 - 0
src/main/java/com/gzlh/config/SystemObject.java

@@ -0,0 +1,75 @@
+package com.gzlh.config;
+
+import com.gzlh.device.capture.factory.CaptureFactory;
+import com.gzlh.device.capture.properties.CapturePropertiesConfig;
+import com.gzlh.device.infrared.config.RedPropertiesConfig;
+import com.gzlh.device.infrared.factory.RedFactory;
+import com.gzlh.device.led.factory.LedFactory;
+import com.gzlh.device.led.properties.LedPropertiesConfig;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SystemObject {
+
+    public static ApplicationConfig applicationConfig;
+
+    public static FilePropertiesConfig filePropertiesConfig;
+    public static RedFactory redFactory;
+    public static RedPropertiesConfig redPropertiesConfig;
+
+    public static WeighbridgeFactory weighbridgeFactory;
+    public static WeighbridgePropertiesConfig weighbridgePropertiesConfig;
+
+    public static LedFactory ledFactory;
+    public static LedPropertiesConfig ledPropertiesConfig;
+
+    public static CaptureFactory captureFactory;
+
+    public static CapturePropertiesConfig capturePropertiesConfig;
+
+
+    @Autowired
+    void setApplicationConfig(ApplicationConfig applicationConfig) {
+        SystemObject.applicationConfig = applicationConfig;
+    }
+    @Autowired
+   void setFilePropertiesConfig(FilePropertiesConfig filePropertiesConfig) {
+        SystemObject.filePropertiesConfig = filePropertiesConfig;
+    }
+
+    @Autowired
+   void setRedFactory(RedFactory redFactory) {
+        SystemObject.redFactory = redFactory;
+    }
+    @Autowired
+    void setRedPropertiesConfig(RedPropertiesConfig redPropertiesConfig) {
+        SystemObject.redPropertiesConfig = redPropertiesConfig;
+    }
+    @Autowired
+     void setWeighbridgeFactory(WeighbridgeFactory weighbridgeFactory) {
+        SystemObject.weighbridgeFactory = weighbridgeFactory;
+    }
+    @Autowired
+     void setWeighbridgePropertiesConfig(WeighbridgePropertiesConfig weighbridgePropertiesConfig) {
+        SystemObject.weighbridgePropertiesConfig = weighbridgePropertiesConfig;
+    }
+    @Autowired
+    void setLedFactory(LedFactory ledFactory) {
+        SystemObject.ledFactory = ledFactory;
+    }
+    @Autowired
+    void setLedPropertiesConfig(LedPropertiesConfig ledPropertiesConfig) {
+        SystemObject.ledPropertiesConfig = ledPropertiesConfig;
+    }
+    @Autowired
+   void setCaptureFactory(CaptureFactory captureFactory) {
+        SystemObject.captureFactory = captureFactory;
+    }
+    @Autowired
+     void setCapturePropertiesConfig(CapturePropertiesConfig capturePropertiesConfig) {
+        SystemObject.capturePropertiesConfig = capturePropertiesConfig;
+    }
+}

+ 1 - 1
src/main/java/com/gzlh/dto/ApplicationConfigDTO.java → src/main/java/com/gzlh/config/dto/ApplicationConfigDTO.java

@@ -1,4 +1,4 @@
-package com.gzlh.dto;
+package com.gzlh.config.dto;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;

+ 1 - 1
src/main/java/com/gzlh/dto/EventDTO.java → src/main/java/com/gzlh/config/dto/EventDTO.java

@@ -1,4 +1,4 @@
-package com.gzlh.dto;
+package com.gzlh.config.dto;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;

+ 23 - 12
src/main/java/com/gzlh/hksdk/AlarmParseService.java → src/main/java/com/gzlh/config/hksdk/AlarmParseService.java

@@ -1,10 +1,14 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import cn.hutool.cache.CacheUtil;
 import cn.hutool.cache.impl.TimedCache;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
+import com.gzlh.device.capture.task.HandlerCarImage;
+import com.gzlh.config.FilePropertiesConfig;
+import com.gzlh.config.task.TaskService;
 import com.sun.jna.Pointer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Lazy;
@@ -17,8 +21,8 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.Date;
-import java.util.List;
 
 /**
  * 报警处理
@@ -32,12 +36,18 @@ public class AlarmParseService {
     @Resource
     @Lazy
     private HCNetSDK hcNetSDK;
+    @Resource
+    @Lazy
+    private FilePropertiesConfig filePropertiesConfig;
+ @Resource
+    TaskService taskService;
 
 
     TimedCache<String, Integer> CACHE_MAP = CacheUtil.newTimedCache(20000);
 
     public void alarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
         //lCommand是传的报警类型
+        String separator=File.separator;
         if (lCommand == HCNetSDK.COMM_ITS_PLATE_RESULT) {//交通抓拍结果(新报警信息)
             HCNetSDK.NET_ITS_PLATE_RESULT strItsPlateResult = new HCNetSDK.NET_ITS_PLATE_RESULT();
             strItsPlateResult.write();
@@ -51,10 +61,9 @@ public class AlarmParseService {
                 log.error("上传车牌为空:{}", e.getMessage());
                 return;
             }
-            int color = strItsPlateResult.struPlateInfo.byColor;
-            byte VehicleType = strItsPlateResult.byVehicleType;  //0-其他车辆,1-小型车,2-大型车,3- 行人触发,4- 二轮车触发,5- 三轮车触发,6- 机动车触发
-            log.info("车牌号:{} ;车辆类型:{}", sLicense, VehicleType);
-            String now = DateUtil.now();
+//            int color = strItsPlateResult.struPlateInfo.byColor;
+//            byte VehicleType = strItsPlateResult.byVehicleType;  //0-其他车辆,1-小型车,2-大型车,3- 行人触发,4- 二轮车触发,5- 三轮车触发,6- 机动车触发
+//            log.info("车牌号:{} ;车辆类型:{}", sLicense, VehicleType);
             sLicense = StrUtil.trim(StrUtil.sub(sLicense, 1, -1));
             if (CACHE_MAP.get(sLicense) != null) {
                 log.error("重复上传:{}", sLicense);
@@ -69,16 +78,18 @@ public class AlarmParseService {
             if (strItsPlateResult.struPicInfo.length > 0) {
                 HCNetSDK.NET_ITS_PICTURE_INFO net_its_picture_info = strItsPlateResult.struPicInfo[0];
                 if (net_its_picture_info.dwDataLen > 0) {
-                    String currDateFolder = new SimpleDateFormat("/yyyy/MM-dd").format(nowTime);
-                    String newName = DateUtil.format(nowTime, "yyyyMMddHHmmss");
+                    String currDateFolder = new SimpleDateFormat("MM-dd").format(nowTime);
+                    String newName = DateUtil.format(nowTime, "yyyyMMddHHmm");
                     FileOutputStream fout;
                     try {
                         // 文件名
-                        String fileName = newName + "_ItsPlate.jpg";
+                        String fileName =sLicense+"-" +newName + ".jpg";
                         // 需要保存到的文件夹地址
-                        String fileFolder="";
+                        String fileFolder=filePropertiesConfig.getRootPath()+ LocalDate.now().getYear() +currDateFolder;;
                         FileUtil.mkdir(fileFolder);
-                        fout = new FileOutputStream(fileFolder + fileName);
+                        String filePath=fileFolder +separator+ fileName;
+                        log.info("车牌保存路径:{},{}",sLicense,filePath);
+                        fout = new FileOutputStream(filePath);
                         //将字节写入文件
                         long offset = 0;
                         ByteBuffer buffers = net_its_picture_info.pBuffer.getByteBuffer(offset, net_its_picture_info.dwDataLen);
@@ -87,7 +98,7 @@ public class AlarmParseService {
                         buffers.get(bytes);
                         fout.write(bytes);
                         fout.close();
-
+                        taskService.addTask(new HandlerCarImage(RandomUtil.randomNumbers(10),100,filePath,sLicense));
                     } catch (IOException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();

+ 1 - 2
src/main/java/com/gzlh/hksdk/EventCallback.java → src/main/java/com/gzlh/config/hksdk/EventCallback.java

@@ -1,8 +1,7 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import com.sun.jna.Pointer;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
 /**

+ 1 - 2
src/main/java/com/gzlh/hksdk/FExceptionCallBack.java → src/main/java/com/gzlh/config/hksdk/FExceptionCallBack.java

@@ -1,8 +1,7 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import com.sun.jna.Pointer;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
 /**

+ 1 - 1
src/main/java/com/gzlh/hksdk/HCNetSDK.java → src/main/java/com/gzlh/config/hksdk/HCNetSDK.java

@@ -1,4 +1,4 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import com.sun.jna.*;
 import com.sun.jna.ptr.ByteByReference;

+ 1 - 1
src/main/java/com/gzlh/hksdk/HkLibProperties.java → src/main/java/com/gzlh/config/hksdk/HkLibProperties.java

@@ -1,4 +1,4 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;

+ 1 - 1
src/main/java/com/gzlh/hksdk/HkUtils.java → src/main/java/com/gzlh/config/hksdk/HkUtils.java

@@ -1,4 +1,4 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import cn.hutool.log.StaticLog;
 import com.sun.jna.Pointer;

+ 1 - 3
src/main/java/com/gzlh/hksdk/InitSDK.java → src/main/java/com/gzlh/config/hksdk/InitSDK.java

@@ -1,11 +1,9 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import cn.hutool.log.StaticLog;
 import com.gzlh.utils.osSelect;
 import com.sun.jna.Native;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Conditional;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;

+ 1 - 2
src/main/java/com/gzlh/hksdk/MessageCallBack.java → src/main/java/com/gzlh/config/hksdk/MessageCallBack.java

@@ -1,8 +1,7 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import com.sun.jna.Pointer;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;

+ 2 - 7
src/main/java/com/gzlh/hksdk/StartUpInit.java → src/main/java/com/gzlh/config/hksdk/StartUpInit.java

@@ -1,4 +1,4 @@
-package com.gzlh.hksdk;
+package com.gzlh.config.hksdk;
 
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
@@ -21,11 +21,6 @@ public class StartUpInit implements CommandLineRunner {
 
     @Override
     public void run(String... args)   {
-        short port=8000;
-        int userId = hkUtils.Login_V40("192.168.1.11", port, "admin", "ap123456", hcNetSDK);
-        log.info("user id:{}",userId);
-        log.info("登录海康设备:{},{}",hcNetSDK.NET_DVR_GetLastError(),userId);
-        hkUtils.handlerUp(hcNetSDK,userId);
-        log.info("海康抬杆设备:{},{}",hcNetSDK.NET_DVR_GetLastError(),userId);
+
     }
 }

+ 51 - 0
src/main/java/com/gzlh/config/hksdk/bo/HKCacheManager.java

@@ -0,0 +1,51 @@
+package com.gzlh.config.hksdk.bo;
+
+import cn.hutool.core.util.StrUtil;
+import com.gzlh.config.ModuleEnum;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * 因为可能会有多个海康设备
+ */
+public class HKCacheManager {
+
+
+    private final static List<DeviceType>DEVICE_TYPES=new CopyOnWriteArrayList<>();
+
+    /**
+     * 添加
+     * @param module 类型
+     * @param userId 登录设备返回的userId
+     */
+    public static void add(ModuleEnum module,int userId){
+       Optional<DeviceType>deviceTypeOptional= DEVICE_TYPES.stream()
+               .filter(deviceType -> StrUtil.equals(deviceType.getModule(), module.getModuleEn()))
+                .findAny();
+        if (deviceTypeOptional.isPresent()) {
+            deviceTypeOptional.get().setUserId(userId);
+        }else {
+            DeviceType deviceType=new DeviceType();
+            deviceType.setUserId(userId).setModule(module.getModuleEn());
+            DEVICE_TYPES.add(deviceType);
+        }
+    }
+
+    public static int getUserId(ModuleEnum module){
+        Optional<DeviceType>deviceTypeOptional= DEVICE_TYPES.stream()
+                .filter(deviceType -> StrUtil.equals(module.getModuleEn(), deviceType.module))
+                .findAny();
+        return deviceTypeOptional.map(DeviceType::getUserId).orElse(-1);
+    }
+
+    @Data
+    @Accessors(chain = true)
+    static class DeviceType{
+        private String module;
+        private int userId;
+    }
+}

+ 1 - 1
src/main/java/com/gzlh/task/Task.java → src/main/java/com/gzlh/config/task/Task.java

@@ -1,4 +1,4 @@
-package com.gzlh.task;
+package com.gzlh.config.task;
 
 import com.google.common.primitives.Ints;
 

+ 1 - 1
src/main/java/com/gzlh/task/TaskService.java → src/main/java/com/gzlh/config/task/TaskService.java

@@ -1,4 +1,4 @@
-package com.gzlh.task;
+package com.gzlh.config.task;
 
 import org.springframework.stereotype.Component;
 

+ 1 - 1
src/main/java/com/gzlh/camera/CameraServer.java → src/main/java/com/gzlh/device/camera/CameraServer.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera;
+package com.gzlh.device.camera;
 
 public class CameraServer {
 

+ 1 - 1
src/main/java/com/gzlh/camera/action/CameraCommonAction.java → src/main/java/com/gzlh/device/camera/action/CameraCommonAction.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera.action;
+package com.gzlh.device.camera.action;
 
 /**
  * led共同

+ 1 - 1
src/main/java/com/gzlh/camera/brand/CameraBrandType.java → src/main/java/com/gzlh/device/camera/brand/CameraBrandType.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera.brand;
+package com.gzlh.device.camera.brand;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;

+ 1 - 1
src/main/java/com/gzlh/camera/client/CameraClientHandler.java → src/main/java/com/gzlh/device/camera/client/CameraClientHandler.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera.client;
+package com.gzlh.device.camera.client;
 
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;

+ 2 - 2
src/main/java/com/gzlh/camera/client/CameraNettyConfig.java → src/main/java/com/gzlh/device/camera/client/CameraNettyConfig.java

@@ -1,6 +1,6 @@
-package com.gzlh.camera.client;
+package com.gzlh.device.camera.client;
 
-import com.gzlh.camera.properties.CameraPropertiesConfig;
+import com.gzlh.device.camera.properties.CameraPropertiesConfig;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;

+ 3 - 6
src/main/java/com/gzlh/camera/controller/CameraController.java → src/main/java/com/gzlh/device/camera/controller/CameraController.java

@@ -1,13 +1,10 @@
-package com.gzlh.camera.controller;
+package com.gzlh.device.camera.controller;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.XmlUtil;
-import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.camera.factory.CameraFactory;
-import com.gzlh.camera.properties.CameraPropertiesConfig;
-import com.gzlh.event.EventBus;
+import com.gzlh.device.camera.factory.CameraFactory;
+import com.gzlh.device.camera.properties.CameraPropertiesConfig;
 import com.gzlh.utils.FileUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;

+ 1 - 1
src/main/java/com/gzlh/camera/event/CameraDefaultEvent.java → src/main/java/com/gzlh/device/camera/event/CameraDefaultEvent.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera.event;
+package com.gzlh.device.camera.event;
 
 /**
  * led内置事件

+ 2 - 2
src/main/java/com/gzlh/camera/factory/CameraFactory.java → src/main/java/com/gzlh/device/camera/factory/CameraFactory.java

@@ -1,8 +1,8 @@
-package com.gzlh.camera.factory;
+package com.gzlh.device.camera.factory;
 
 
 
-import com.gzlh.camera.handler.ICameraHandler;
+import com.gzlh.device.camera.handler.ICameraHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

+ 2 - 2
src/main/java/com/gzlh/camera/handler/ICameraHandler.java → src/main/java/com/gzlh/device/camera/handler/ICameraHandler.java

@@ -1,6 +1,6 @@
-package com.gzlh.camera.handler;
+package com.gzlh.device.camera.handler;
 
-import com.gzlh.camera.brand.CameraBrandType;
+import com.gzlh.device.camera.brand.CameraBrandType;
 
 public interface ICameraHandler {
 

+ 4 - 4
src/main/java/com/gzlh/camera/handler/impl/CameraHandlerHikvision.java → src/main/java/com/gzlh/device/camera/handler/impl/CameraHandlerHikvision.java

@@ -1,8 +1,8 @@
-package com.gzlh.camera.handler.impl;
+package com.gzlh.device.camera.handler.impl;
 
-import com.gzlh.camera.brand.CameraBrandType;
-import com.gzlh.camera.client.CameraNettyConfig;
-import com.gzlh.camera.handler.ICameraHandler;
+import com.gzlh.device.camera.brand.CameraBrandType;
+import com.gzlh.device.camera.client.CameraNettyConfig;
+import com.gzlh.device.camera.handler.ICameraHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 

+ 1 - 1
src/main/java/com/gzlh/camera/properties/CameraPropertiesConfig.java → src/main/java/com/gzlh/device/camera/properties/CameraPropertiesConfig.java

@@ -1,4 +1,4 @@
-package com.gzlh.camera.properties;
+package com.gzlh.device.camera.properties;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;

+ 8 - 0
src/main/java/com/gzlh/device/capture/action/ICaptureAction.java

@@ -0,0 +1,8 @@
+package com.gzlh.device.capture.action;
+
+public interface ICaptureAction {
+    /**
+     * 上传车牌号
+     */
+    String UPLOAD_CAR_NO="UPLOAD_CAR_NO";
+}

+ 3 - 3
src/main/java/com/gzlh/gate/brand/GateBrandType.java → src/main/java/com/gzlh/device/capture/brand/CaptureBrandType.java

@@ -1,13 +1,13 @@
-package com.gzlh.gate.brand;
+package com.gzlh.device.capture.brand;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
 @Getter
 @AllArgsConstructor
-public enum GateBrandType {
+public enum CaptureBrandType {
 
-    SHANGJI_BRAND(4000,"熵基相机")
+    HK_BRAND(5000,"海康相机")
     ;
 
 

+ 18 - 0
src/main/java/com/gzlh/device/capture/controller/GateController.java

@@ -0,0 +1,18 @@
+package com.gzlh.device.capture.controller;
+
+import com.gzlh.device.capture.factory.CaptureFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("gate")
+@Slf4j
+public class GateController {
+    @Resource
+    private CaptureFactory captureFactory;
+
+
+}

+ 8 - 0
src/main/java/com/gzlh/device/capture/event/CaptureEvent.java

@@ -0,0 +1,8 @@
+package com.gzlh.device.capture.event;
+
+public interface CaptureEvent {
+    /**
+     * 抓拍到车牌
+     */
+    String CAPTURE_CAR_NO="CAPTURE_CAR_NO";
+}

+ 5 - 6
src/main/java/com/gzlh/gate/factory/GateFactory.java → src/main/java/com/gzlh/device/capture/factory/CaptureFactory.java

@@ -1,20 +1,19 @@
-package com.gzlh.gate.factory;
+package com.gzlh.device.capture.factory;
 
 
 
-import com.gzlh.gate.handler.IGateHandler;
-import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.device.capture.handler.ICaptureHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 
 @Service
-public class GateFactory {
+public class CaptureFactory {
     @Autowired
-    private List<IGateHandler>handlers;
+    private List<ICaptureHandler>handlers;
 
-    public IGateHandler handler(int code){
+    public ICaptureHandler handler(int code){
        return handlers.stream().filter(h->h.brandType().getCode()==code)
                 .findAny().orElseThrow(()->new IllegalArgumentException("不支持相机"));
     }

+ 16 - 0
src/main/java/com/gzlh/device/capture/handler/ICaptureHandler.java

@@ -0,0 +1,16 @@
+package com.gzlh.device.capture.handler;
+
+import com.gzlh.device.capture.brand.CaptureBrandType;
+
+public interface ICaptureHandler {
+
+    CaptureBrandType brandType();
+
+
+    /**
+     * 处理命令
+     * @param action
+     */
+    void handlerAction(String action);
+
+}

+ 33 - 0
src/main/java/com/gzlh/device/capture/handler/impl/CaptureHandlerHk.java

@@ -0,0 +1,33 @@
+package com.gzlh.device.capture.handler.impl;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import com.gzlh.device.capture.action.ICaptureAction;
+import com.gzlh.device.capture.brand.CaptureBrandType;
+import com.gzlh.device.capture.handler.ICaptureHandler;
+import com.gzlh.entity.ReqBO;
+import com.gzlh.bus.EventDataManager;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * 海康车牌抓拍机处理类
+ */
+@Component
+@Slf4j
+public class CaptureHandlerHk implements ICaptureHandler {
+    @Override
+    public CaptureBrandType brandType() {
+        return CaptureBrandType.HK_BRAND;
+    }
+
+    @Override
+    public void handlerAction(String action) {
+        if (StrUtil.equals(action, ICaptureAction.UPLOAD_CAR_NO)){
+           ReqBO reqBO= EventDataManager.getCacheData();
+            //upload file
+            log.info("upload car info:{}", JSONUtil.toJsonStr(reqBO));
+        }
+    }
+
+}

+ 20 - 0
src/main/java/com/gzlh/device/capture/properties/CapturePropertiesConfig.java

@@ -0,0 +1,20 @@
+package com.gzlh.device.capture.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@ConfigurationProperties(prefix = "capture")
+@Configuration
+@Data
+public class CapturePropertiesConfig {
+    /**
+     * 品牌
+     */
+    private int brand;
+    private String host;
+    private int port;
+    private String username;
+    private String pwd;
+    private boolean enable;
+}

+ 38 - 0
src/main/java/com/gzlh/device/capture/task/HandlerCarImage.java

@@ -0,0 +1,38 @@
+package com.gzlh.device.capture.task;
+
+import cn.hutool.core.codec.Base64;
+import cn.hutool.extra.spring.SpringUtil;
+
+import com.gzlh.device.capture.event.CaptureEvent;
+import com.gzlh.device.capture.factory.CaptureFactory;
+import com.gzlh.device.capture.properties.CapturePropertiesConfig;
+import com.gzlh.config.ModuleEnum;
+import com.gzlh.bus.EventBus;
+import com.gzlh.bus.EventDataManager;
+import com.gzlh.config.task.Task;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.File;
+
+@Slf4j
+public class HandlerCarImage extends Task {
+    private CaptureFactory captureFactory=SpringUtil.getBean(CaptureFactory.class);
+    CapturePropertiesConfig capturePropertiesConfig=SpringUtil.getBean(CapturePropertiesConfig.class);
+    private String filePath;
+    private String carNo;
+    public HandlerCarImage(String id, long delayInMilliseconds, String filePath, String carNo) {
+        super(id, delayInMilliseconds);
+        this.filePath=filePath;
+        this.carNo=carNo;
+    }
+
+    @Override
+    public void run() {
+      String base64=  Base64.encode(new File(filePath));
+        EventDataManager.cacheData("carImg",base64);
+        EventDataManager.cacheData("carNo",carNo);
+        EventBus eventBus=SpringUtil.getBean(EventBus.class);
+        //向总线发送抓拍到车牌事件
+        eventBus.startEvent(ModuleEnum.CAPTURE_MODULE.getModuleEn()+"."+ CaptureEvent.CAPTURE_CAR_NO);
+    }
+}

+ 1 - 1
src/main/java/com/gzlh/gate/utils/ZKTecoCommandUtils.java → src/main/java/com/gzlh/device/capture/utils/ZKTecoCommandUtils.java

@@ -1,4 +1,4 @@
-package com.gzlh.gate.utils;
+package com.gzlh.device.capture.utils;
 
 import cn.hutool.core.codec.Base64;
 import cn.hutool.core.util.RandomUtil;

+ 1 - 1
src/main/java/com/gzlh/gate/utils/ZKTecoUtils.java → src/main/java/com/gzlh/device/capture/utils/ZKTecoUtils.java

@@ -1,4 +1,4 @@
-package com.gzlh.gate.utils;
+package com.gzlh.device.capture.utils;
 
 import cn.hutool.log.StaticLog;
 

+ 1 - 1
src/main/java/com/gzlh/infrared/action/InfraredAction.java → src/main/java/com/gzlh/device/infrared/action/InfraredAction.java

@@ -1,4 +1,4 @@
-package com.gzlh.infrared.action;
+package com.gzlh.device.infrared.action;
 
 public interface InfraredAction {
     /**

+ 1 - 1
src/main/java/com/gzlh/infrared/brand/RedBrandType.java → src/main/java/com/gzlh/device/infrared/brand/RedBrandType.java

@@ -1,4 +1,4 @@
-package com.gzlh.infrared.brand;
+package com.gzlh.device.infrared.brand;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;

+ 3 - 3
src/main/java/com/gzlh/infrared/client/RedClientHandler.java → src/main/java/com/gzlh/device/infrared/client/RedClientHandler.java

@@ -1,9 +1,9 @@
-package com.gzlh.infrared.client;
+package com.gzlh.device.infrared.client;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.infrared.config.RedPropertiesConfig;
-import com.gzlh.infrared.factory.RedFactory;
+import com.gzlh.device.infrared.config.RedPropertiesConfig;
+import com.gzlh.device.infrared.factory.RedFactory;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;

+ 2 - 2
src/main/java/com/gzlh/infrared/client/RedNettyConfig.java → src/main/java/com/gzlh/device/infrared/client/RedNettyConfig.java

@@ -1,6 +1,6 @@
-package com.gzlh.infrared.client;
+package com.gzlh.device.infrared.client;
 
-import com.gzlh.infrared.config.RedPropertiesConfig;
+import com.gzlh.device.infrared.config.RedPropertiesConfig;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;

+ 1 - 1
src/main/java/com/gzlh/infrared/config/RedPropertiesConfig.java → src/main/java/com/gzlh/device/infrared/config/RedPropertiesConfig.java

@@ -1,4 +1,4 @@
-package com.gzlh.infrared.config;
+package com.gzlh.device.infrared.config;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;

+ 2 - 2
src/main/java/com/gzlh/infrared/factory/RedFactory.java → src/main/java/com/gzlh/device/infrared/factory/RedFactory.java

@@ -1,8 +1,8 @@
-package com.gzlh.infrared.factory;
+package com.gzlh.device.infrared.factory;
 
 
 
-import com.gzlh.infrared.handler.IRedHandler;
+import com.gzlh.device.infrared.handler.IRedHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

+ 2 - 2
src/main/java/com/gzlh/infrared/handler/IRedHandler.java → src/main/java/com/gzlh/device/infrared/handler/IRedHandler.java

@@ -1,6 +1,6 @@
-package com.gzlh.infrared.handler;
+package com.gzlh.device.infrared.handler;
 
-import com.gzlh.infrared.brand.RedBrandType;
+import com.gzlh.device.infrared.brand.RedBrandType;
 
 /**
  * 红外

+ 6 - 13
src/main/java/com/gzlh/infrared/handler/impl/RedHandlerSoarDAM0404.java → src/main/java/com/gzlh/device/infrared/handler/impl/RedHandlerSoarDAM0404.java

@@ -1,22 +1,15 @@
-package com.gzlh.infrared.handler.impl;
+package com.gzlh.device.infrared.handler.impl;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.event.EventBus;
-import com.gzlh.infrared.action.InfraredAction;
-import com.gzlh.led.factory.LedFactory;
-import com.gzlh.led.handler.ILedHandler;
-import com.gzlh.led.properties.LedPropertiesConfig;
-import com.gzlh.infrared.brand.RedBrandType;
-import com.gzlh.infrared.handler.IRedHandler;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import com.gzlh.bus.EventBus;
+import com.gzlh.device.infrared.action.InfraredAction;
+import com.gzlh.device.infrared.brand.RedBrandType;
+import com.gzlh.device.infrared.handler.IRedHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
-
 /**
  * 聚英翱翔电子 01082899821  聚英翱翔电子,按0,转技术电话
  * dam0404d 品牌
@@ -49,7 +42,7 @@ public class RedHandlerSoarDAM0404 implements IRedHandler {
         }else if (StrUtil.equals(StrUtil.replace(FIRST_LINK_SIGNAL, " ", ""), content)){
             EventBus eventBus= SpringUtil.getBean(EventBus.class);
 //            //入红外被挡住
-            eventBus.start(ModuleEnum.INFRARED_MODULE.getModuleEn()+"."+ InfraredAction.IN_BREAK);
+            eventBus.startEvent(ModuleEnum.INFRARED_MODULE.getModuleEn()+"."+ InfraredAction.IN_BREAK);
         }
     }
 

+ 1 - 1
src/main/java/com/gzlh/led/LedServer.java → src/main/java/com/gzlh/device/led/LedServer.java

@@ -1,4 +1,4 @@
-package com.gzlh.led;
+package com.gzlh.device.led;
 
 public class LedServer {
 

+ 8 - 0
src/main/java/com/gzlh/device/led/action/LedAction.java

@@ -0,0 +1,8 @@
+package com.gzlh.device.led.action;
+
+public interface LedAction {
+    /**
+     * 展示内容
+     */
+    String LED_SHOW_CONTENT="LED_SHOW_CONTENT";
+}

+ 1 - 1
src/main/java/com/gzlh/led/brand/LedBrandType.java → src/main/java/com/gzlh/device/led/brand/LedBrandType.java

@@ -1,4 +1,4 @@
-package com.gzlh.led.brand;
+package com.gzlh.device.led.brand;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;

+ 1 - 2
src/main/java/com/gzlh/led/client/LedClientHandler.java → src/main/java/com/gzlh/device/led/client/LedClientHandler.java

@@ -1,6 +1,5 @@
-package com.gzlh.led.client;
+package com.gzlh.device.led.client;
 
-import cn.hutool.core.util.StrUtil;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;

+ 6 - 4
src/main/java/com/gzlh/led/client/LedNettyConfig.java → src/main/java/com/gzlh/device/led/client/LedNettyConfig.java

@@ -1,6 +1,6 @@
-package com.gzlh.led.client;
+package com.gzlh.device.led.client;
 
-import com.gzlh.led.properties.LedPropertiesConfig;
+import com.gzlh.device.led.properties.LedPropertiesConfig;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;
@@ -14,6 +14,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 import javax.annotation.Resource;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.TimeUnit;
 
 @Configuration
@@ -46,8 +48,8 @@ public class LedNettyConfig {
                     protected void initChannel(SocketChannel ch) {
                         try {
                             ChannelPipeline pipeline = ch.pipeline();
-                            pipeline.addLast("decoder", new StringDecoder());
-                            pipeline.addLast("encoder", new StringEncoder());
+                            pipeline.addLast("decoder", new StringDecoder(StandardCharsets.US_ASCII));
+                            pipeline.addLast("encoder", new StringEncoder(StandardCharsets.US_ASCII));
                             pipeline.addLast("handler", ledClientHandler);
                         } catch (Exception e) {
                             log.info("error connect:{}", e.getMessage());

+ 1 - 1
src/main/java/com/gzlh/led/event/LedDefaultEvent.java → src/main/java/com/gzlh/device/led/event/LedDefaultEvent.java

@@ -1,4 +1,4 @@
-package com.gzlh.led.event;
+package com.gzlh.device.led.event;
 
 /**
  * led内置事件

+ 2 - 2
src/main/java/com/gzlh/led/factory/LedFactory.java → src/main/java/com/gzlh/device/led/factory/LedFactory.java

@@ -1,8 +1,8 @@
-package com.gzlh.led.factory;
+package com.gzlh.device.led.factory;
 
 
 
-import com.gzlh.led.handler.ILedHandler;
+import com.gzlh.device.led.handler.ILedHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

+ 2 - 4
src/main/java/com/gzlh/led/handler/ILedHandler.java → src/main/java/com/gzlh/device/led/handler/ILedHandler.java

@@ -1,8 +1,6 @@
-package com.gzlh.led.handler;
+package com.gzlh.device.led.handler;
 
-import com.gzlh.led.brand.LedBrandType;
-
-import io.netty.channel.ChannelHandlerContext;
+import com.gzlh.device.led.brand.LedBrandType;
 
 public interface ILedHandler {
 

+ 11 - 7
src/main/java/com/gzlh/led/handler/impl/LedHandlerYangBandV4d2.java → src/main/java/com/gzlh/device/led/handler/impl/LedHandlerYangBandV4d2.java

@@ -1,11 +1,11 @@
-package com.gzlh.led.handler.impl;
+package com.gzlh.device.led.handler.impl;
 
-import com.gzlh.led.brand.LedBrandType;
-import com.gzlh.led.client.LedNettyConfig;
-import com.gzlh.led.handler.ILedHandler;
-import com.gzlh.led.utils.ColorConver;
-import com.gzlh.led.utils.YangBandPackage;
-import com.gzlh.infrared.brand.RedBrandType;
+import com.gzlh.device.led.brand.LedBrandType;
+import com.gzlh.device.led.client.LedNettyConfig;
+import com.gzlh.device.led.handler.ILedHandler;
+import com.gzlh.device.led.utils.ColorConver;
+import com.gzlh.device.led.utils.YangBandPackage;
+import com.gzlh.device.infrared.brand.RedBrandType;
 import com.gzlh.utils.WordHandlerUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -35,6 +35,10 @@ public class LedHandlerYangBandV4d2 implements ILedHandler {
         ledNettyConfig.send(pack);
     }
 
+    /**
+     * 特殊站位符 ${platNo}
+     * @param action
+     */
     @Override
     public void handlerAction(String action) {
         log.info("action:{}",action);

+ 1 - 1
src/main/java/com/gzlh/led/properties/LedPropertiesConfig.java → src/main/java/com/gzlh/device/led/properties/LedPropertiesConfig.java

@@ -1,4 +1,4 @@
-package com.gzlh.led.properties;
+package com.gzlh.device.led.properties;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;

+ 1 - 1
src/main/java/com/gzlh/led/utils/CRC16.java → src/main/java/com/gzlh/device/led/utils/CRC16.java

@@ -1,4 +1,4 @@
-package com.gzlh.led.utils;
+package com.gzlh.device.led.utils;
 
 public class CRC16 {
     public static String crc16(int[] data, int size) {

+ 1 - 1
src/main/java/com/gzlh/led/utils/ColorConver.java → src/main/java/com/gzlh/device/led/utils/ColorConver.java

@@ -1,4 +1,4 @@
-package com.gzlh.led.utils;
+package com.gzlh.device.led.utils;
 
 import java.util.LinkedHashMap;
 import java.util.Map;

+ 1 - 3
src/main/java/com/gzlh/led/utils/YangBandPackage.java → src/main/java/com/gzlh/device/led/utils/YangBandPackage.java

@@ -1,6 +1,4 @@
-package com.gzlh.led.utils;
-
-import cn.hutool.core.util.StrUtil;
+package com.gzlh.device.led.utils;
 
 public class YangBandPackage {
     /**

+ 1 - 6
src/main/java/com/gzlh/weighbridge/Test.java → src/main/java/com/gzlh/device/weighbridge/Test.java

@@ -1,15 +1,10 @@
-package com.gzlh.weighbridge;
+package com.gzlh.device.weighbridge;
 
 import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.XmlUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.XML;
 import lombok.extern.slf4j.Slf4j;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
 
 import java.io.File;
 @Slf4j

+ 1 - 1
src/main/java/com/gzlh/weighbridge/action/WeighbridgeCommonAction.java → src/main/java/com/gzlh/device/weighbridge/action/WeighbridgeCommonAction.java

@@ -1,4 +1,4 @@
-package com.gzlh.weighbridge.action;
+package com.gzlh.device.weighbridge.action;
 
 /**
  * 地磅共同

+ 1 - 1
src/main/java/com/gzlh/weighbridge/brand/WeighbridgeBrandType.java → src/main/java/com/gzlh/device/weighbridge/brand/WeighbridgeBrandType.java

@@ -1,4 +1,4 @@
-package com.gzlh.weighbridge.brand;
+package com.gzlh.device.weighbridge.brand;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;

+ 3 - 3
src/main/java/com/gzlh/weighbridge/client/WeighbridgeClientHandler.java → src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeClientHandler.java

@@ -1,8 +1,8 @@
-package com.gzlh.weighbridge.client;
+package com.gzlh.device.weighbridge.client;
 
 import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.factory.WeighbridgeFactory;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;

+ 2 - 2
src/main/java/com/gzlh/weighbridge/client/WeighbridgeNettyConfig.java → src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeNettyConfig.java

@@ -1,6 +1,6 @@
-package com.gzlh.weighbridge.client;
+package com.gzlh.device.weighbridge.client;
 
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;

+ 1 - 1
src/main/java/com/gzlh/weighbridge/config/WeighbridgePropertiesConfig.java → src/main/java/com/gzlh/device/weighbridge/config/WeighbridgePropertiesConfig.java

@@ -1,4 +1,4 @@
-package com.gzlh.weighbridge.config;
+package com.gzlh.device.weighbridge.config;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;

+ 1 - 1
src/main/java/com/gzlh/weighbridge/event/WeighbridgeEvent.java → src/main/java/com/gzlh/device/weighbridge/event/WeighbridgeEvent.java

@@ -1,4 +1,4 @@
-package com.gzlh.weighbridge.event;
+package com.gzlh.device.weighbridge.event;
 
 /**
  * 地磅内置事件

+ 2 - 2
src/main/java/com/gzlh/weighbridge/factory/WeighbridgeFactory.java → src/main/java/com/gzlh/device/weighbridge/factory/WeighbridgeFactory.java

@@ -1,5 +1,5 @@
-package com.gzlh.weighbridge.factory;
-import com.gzlh.weighbridge.handler.IWeighbridgeHandler;
+package com.gzlh.device.weighbridge.factory;
+import com.gzlh.device.weighbridge.handler.IWeighbridgeHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

+ 2 - 2
src/main/java/com/gzlh/weighbridge/handler/IWeighbridgeHandler.java → src/main/java/com/gzlh/device/weighbridge/handler/IWeighbridgeHandler.java

@@ -1,6 +1,6 @@
-package com.gzlh.weighbridge.handler;
+package com.gzlh.device.weighbridge.handler;
 
-import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
+import com.gzlh.device.weighbridge.brand.WeighbridgeBrandType;
 
 public interface IWeighbridgeHandler {
 

+ 5 - 7
src/main/java/com/gzlh/weighbridge/handler/impl/CommonWeighbridgeHandler.java → src/main/java/com/gzlh/device/weighbridge/handler/impl/CommonWeighbridgeHandler.java

@@ -1,13 +1,12 @@
-package com.gzlh.weighbridge.handler.impl;
+package com.gzlh.device.weighbridge.handler.impl;
 
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.gzlh.config.ApplicationConfig;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.event.EventBus;
-import com.gzlh.job.UploadTask;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.event.WeighbridgeEvent;
+import com.gzlh.bus.EventBus;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
 
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -62,7 +61,7 @@ public class CommonWeighbridgeHandler {
             if (averaWeight == 0 || weighbridgePropertiesConfig.getMinKg() > averaWeight) {
                 //todo read timeout
                 //读取超时
-                eventBus.start(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.TIMEOUT);
+                eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.TIMEOUT);
                 return;
             }
             isStart=false;
@@ -70,7 +69,6 @@ public class CommonWeighbridgeHandler {
             //上传地磅数据
             String channelName = applicationConfig.getChannelName();
             String serverUrl = applicationConfig.getServerUrl();
-            ThreadUtil.execute(new UploadTask(serverUrl, channelName, averaWeight));
         }
     }
 }

+ 4 - 4
src/main/java/com/gzlh/weighbridge/handler/impl/WeighbridgeHandlerKeDaKD8137.java → src/main/java/com/gzlh/device/weighbridge/handler/impl/WeighbridgeHandlerKeDaKD8137.java

@@ -1,9 +1,9 @@
-package com.gzlh.weighbridge.handler.impl;
+package com.gzlh.device.weighbridge.handler.impl;
 
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.weighbridge.action.WeighbridgeCommonAction;
-import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
-import com.gzlh.weighbridge.handler.IWeighbridgeHandler;
+import com.gzlh.device.weighbridge.action.WeighbridgeCommonAction;
+import com.gzlh.device.weighbridge.brand.WeighbridgeBrandType;
+import com.gzlh.device.weighbridge.handler.IWeighbridgeHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 

+ 5 - 5
src/main/java/com/gzlh/weighbridge/handler/impl/WeighbridgeHandlerKeLi.java → src/main/java/com/gzlh/device/weighbridge/handler/impl/WeighbridgeHandlerKeLi.java

@@ -1,10 +1,10 @@
-package com.gzlh.weighbridge.handler.impl;
+package com.gzlh.device.weighbridge.handler.impl;
 
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.weighbridge.action.WeighbridgeCommonAction;
-import com.gzlh.weighbridge.brand.WeighbridgeBrandType;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.handler.IWeighbridgeHandler;
+import com.gzlh.device.weighbridge.action.WeighbridgeCommonAction;
+import com.gzlh.device.weighbridge.brand.WeighbridgeBrandType;
+import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.device.weighbridge.handler.IWeighbridgeHandler;
 
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;

+ 1 - 2
src/main/java/com/gzlh/weighbridge/server/CheckManager.java → src/main/java/com/gzlh/device/weighbridge/server/CheckManager.java

@@ -1,11 +1,10 @@
-package com.gzlh.weighbridge.server;
+package com.gzlh.device.weighbridge.server;
 
 import cn.hutool.cache.CacheUtil;
 import cn.hutool.cache.impl.TimedCache;
 
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Collectors;
 
 public class CheckManager {
     private static String FLAG = "flag_key";

+ 1 - 1
src/main/java/com/gzlh/weighbridge/server/Count.java → src/main/java/com/gzlh/device/weighbridge/server/Count.java

@@ -1,4 +1,4 @@
-package com.gzlh.weighbridge.server;
+package com.gzlh.device.weighbridge.server;
 
 import lombok.Data;
 

+ 39 - 0
src/main/java/com/gzlh/entity/CommandBO.java

@@ -0,0 +1,39 @@
+package com.gzlh.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+public class CommandBO implements Serializable {
+    /**
+     * 命令ID
+     */
+    private String id;
+
+    private Command command;
+    /**
+     * 下发时间
+     */
+    private Date commandTime;
+
+    @Data
+    @Accessors(chain = true)
+    static class Command{
+        /**
+         * 设备模块 gate
+         */
+        private String module;
+        /**
+         * 具体命令 open
+         */
+        private String command;
+        /**
+         *
+         */
+        private String extra;
+    }
+}

+ 6 - 1
src/main/java/com/gzlh/entity/ReqBO.java

@@ -6,6 +6,7 @@ import org.springframework.context.annotation.Lazy;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Data
@@ -34,11 +35,15 @@ public class ReqBO implements Serializable {
     /**
      * 车厢号
      */
-    private String boxNo;
+    private List<String> boxNoList=new ArrayList<>();
     /**
      * 箱号图片 base64
      */
     private List<String> boxImgList=new ArrayList<>();
+    /**
+     * 采集时间
+     */
+    private Date gatherTime;
 
 
 }

+ 0 - 14
src/main/java/com/gzlh/event/CenterActionCommand.java

@@ -1,14 +0,0 @@
-package com.gzlh.event;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-@Getter
-@AllArgsConstructor
-public enum CenterActionCommand {
-    SLEEP_COMMAND("TIMER_SLEEP","线程休眠")
-
-    ;
-    private String command;
-    private String desc;
-}

+ 0 - 50
src/main/java/com/gzlh/event/EventBus.java

@@ -1,50 +0,0 @@
-package com.gzlh.event;
-
-import com.gzlh.dto.EventDTO;
-import com.gzlh.infrared.config.RedPropertiesConfig;
-import com.gzlh.infrared.factory.RedFactory;
-import com.gzlh.led.factory.LedFactory;
-import com.gzlh.led.properties.LedPropertiesConfig;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import com.gzlh.weighbridge.factory.WeighbridgeFactory;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-@Component
-@Slf4j
-public class EventBus {
-    private List<EventDTO> eventDTOList;
-    @Resource
-    private LedFactory ledFactory;
-    @Resource
-    private RedFactory redFactory;
-    @Resource
-    WeighbridgeFactory weighbridgeFactory;
-
-    @Resource
-    private WeighbridgePropertiesConfig weighbridgePropertiesConfig;
-    @Resource
-    private RedPropertiesConfig redPropertiesConfig;
-    @Resource
-    private LedPropertiesConfig ledPropertiesConfig;
-
-    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20,
-            10L, TimeUnit.SECONDS,
-            new LinkedBlockingQueue(100));
-
-    public void setEventDTOList(List<EventDTO> eventDTOList) {
-        this.eventDTOList = eventDTOList;
-    }
-
-    public void start(String eventName){
-        EventThread thread = new EventThread(eventName);
-        thread.setEventDTOList(eventDTOList);
-        threadPoolExecutor.execute(thread);
-    }
-}

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 11
src/main/java/com/gzlh/gate/bo/ReqBO.java


+ 0 - 31
src/main/java/com/gzlh/gate/controller/GateController.java

@@ -1,31 +0,0 @@
-package com.gzlh.gate.controller;
-
-import cn.hutool.json.JSONUtil;
-import com.gzlh.gate.bo.ReqBO;
-import com.gzlh.gate.brand.GateBrandType;
-import com.gzlh.gate.factory.GateFactory;
-import com.gzlh.utils.ResultJson;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-
-@RestController
-@RequestMapping("gate")
-@Slf4j
-public class GateController {
-    @Resource
-    private GateFactory gateFactory;
-
-
-    @RequestMapping("req")
-    public ResultJson req(HttpServletRequest request, HttpServletResponse response) {
-        log.info("收到道闸请求---------------------------------------------");
-       return gateFactory.handler(GateBrandType.SHANGJI_BRAND.getCode()).handlerReq(request,response);
-
-    }
-}

+ 0 - 20
src/main/java/com/gzlh/gate/handler/IGateHandler.java

@@ -1,20 +0,0 @@
-package com.gzlh.gate.handler;
-
-import com.gzlh.gate.brand.GateBrandType;
-import com.gzlh.led.brand.LedBrandType;
-import com.gzlh.utils.ResultJson;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public interface IGateHandler {
-
-    GateBrandType brandType();
-
-
-
-    void handlerAction(String action);
-
-    ResultJson handlerReq(HttpServletRequest request, HttpServletResponse response);
-
-}

+ 0 - 100
src/main/java/com/gzlh/gate/handler/impl/GateHandlerShangJi.java

@@ -1,100 +0,0 @@
-package com.gzlh.gate.handler.impl;
-
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.json.JSONUtil;
-import cn.hutool.socket.SocketUtil;
-import com.gzlh.gate.bo.ReqBO;
-import com.gzlh.gate.brand.GateBrandType;
-import com.gzlh.gate.handler.IGateHandler;
-import com.gzlh.gate.properties.GatePropertiesConfig;
-import com.gzlh.gate.task.GateBase64ToImage;
-import com.gzlh.gate.utils.ZKTecoCommandUtils;
-import com.gzlh.gate.utils.ZKTecoUtils;
-import com.gzlh.infrared.brand.RedBrandType;
-import com.gzlh.led.brand.LedBrandType;
-import com.gzlh.led.client.LedNettyConfig;
-import com.gzlh.led.utils.ColorConver;
-import com.gzlh.led.utils.YangBandPackage;
-import com.gzlh.task.TaskService;
-import com.gzlh.utils.ResultJson;
-import com.gzlh.utils.WordHandlerUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-/**
- * 熵基车牌识别相机处理类
- */
-@Service
-@Slf4j
-public class GateHandlerShangJi implements IGateHandler {
-    @Resource
-    private TaskService taskService;
-    @Resource
-    private GatePropertiesConfig gatePropertiesConfig;
-
-
-    @Override
-    public GateBrandType brandType() {
-        return GateBrandType.SHANGJI_BRAND;
-    }
-
-
-
-    @Override
-    public void handlerAction(String action) {
-        log.info("action:{}",action);
-    }
-
-    /**
-     * 处理相机推送请求
-     * @param request 请求
-     * @param response 相应
-     * @return
-     */
-    @Override
-    public ResultJson handlerReq(HttpServletRequest request, HttpServletResponse response) {
-        char[] lineChars = new char[1024 * 1024];
-        char[] totalChars = new char[1024 * 1024];
-        int readLen = 0;
-        int totalLen = 0;
-        try {
-            BufferedReader reader = request.getReader();
-            while ((readLen = reader.read(lineChars)) > 0) {
-                for (int i = 0; i < readLen; i++) {
-                    totalChars[totalLen + i] = lineChars[i];
-                }
-                totalLen += readLen;
-            }
-        } catch (Exception e) {
-            log.error("熵基请求异常:{}",e.getMessage());
-        }
-        String lineStr = new String(totalChars);
-        ReqBO bo = JSONUtil.toBean(JSONUtil.parseObj(lineStr).getStr("AlarmInfoPlate"), ReqBO.class);
-        String carNo= bo.getResult().getPlateResult().getLicense();
-        log.info("熵基道闸请求:{}",carNo);
-        taskService.addTask(new GateBase64ToImage(RandomUtil.randomNumbers(10),1000,bo.getResult().getPlateResult().getImageFile(),carNo));
-        openGate(bo.getIpaddr());
-        return ResultJson.success();
-    }
-    private void openGate(String ip){
-        Socket socket=   SocketUtil.connect(ip,gatePropertiesConfig.getGatePort());
-        String result = ZKTecoUtils.sendAndGetResult(socket, ZKTecoCommandUtils.openCommand());
-        try {
-            socket.close();
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        Integer code = JSONUtil.parseObj(result).getInt("state_code");
-        if (code == null || code != 200) {
-          log.error("打开道闸失败----------");
-        }
-    }
-}

+ 0 - 14
src/main/java/com/gzlh/gate/properties/GatePropertiesConfig.java

@@ -1,14 +0,0 @@
-package com.gzlh.gate.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-@ConfigurationProperties(prefix = "gate")
-@Configuration
-@Data
-public class GatePropertiesConfig {
-    private int brand;
-    private int gatePort;
-    private boolean enable;
-}

+ 0 - 45
src/main/java/com/gzlh/gate/task/GateBase64ToImage.java

@@ -1,45 +0,0 @@
-package com.gzlh.gate.task;
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
-
-import com.gzlh.config.FilePropertiesConfig;
-import com.gzlh.task.Task;
-import lombok.extern.slf4j.Slf4j;
-
-import java.io.File;
-
-@Slf4j
-public class GateBase64ToImage extends Task {
-    private String base64;
-    private String carNo;
-    public GateBase64ToImage(String id, long delayInMilliseconds, String base64,String carNo) {
-        super(id, delayInMilliseconds);
-        this.base64=base64;
-        this.carNo=carNo;
-    }
-
-    @Override
-    public void run() {
-        if (StrUtil.isEmpty(base64)) {
-            log.info("无图片信息--------");
-            return;
-        }
-        String separator=File.separator;
-        String fileTypeFolder = separator+"gate"+separator;
-        String currDateFolder = DateUtil.today()+separator;
-        String fileName = carNo+"-"+RandomUtil.randomNumbers(5) + ".jpg";
-        FilePropertiesConfig filePropertiesConfig=SpringUtil.getBean(FilePropertiesConfig.class);
-        String imgFilePath=filePropertiesConfig.getRootPath()+fileTypeFolder+currDateFolder;
-        if (!FileUtil.exist(imgFilePath)) {
-            FileUtil.mkdir(imgFilePath);
-        }
-        // 对外暴露的http路径
-        Base64.decodeToFile(base64,new File(imgFilePath + fileName));
-
-    }
-}

+ 0 - 4
src/main/java/com/gzlh/gate/task/GateService.java

@@ -1,4 +0,0 @@
-package com.gzlh.gate.task;
-
-public class GateService {
-}

+ 0 - 19
src/main/java/com/gzlh/job/BeatTask.java

@@ -1,19 +0,0 @@
-package com.gzlh.job;
-
-import cn.hutool.http.HttpUtil;
-import com.gzlh.config.ApplicationConfig;
-
-import javax.annotation.Resource;
-
-//@Component
-public class BeatTask {
-    @Resource
-    private ApplicationConfig applicationConfig;
-
-//    @Async
-//    @Scheduled(fixedRate = 10000)
-    public void  beat(){
-        HttpUtil.get(applicationConfig.getServerUrl()+"/SysChannelApplication/beat?channelName="+applicationConfig.getChannelName());
-    }
-
-}

+ 0 - 22
src/main/java/com/gzlh/job/CleanTask.java

@@ -1,22 +0,0 @@
-package com.gzlh.job;
-
-import cn.hutool.http.HttpUtil;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class CleanTask implements Runnable {
-    private String serverUrl;
-    private String channelName;
-
-    public CleanTask(String serverUrl, String channelName) {
-        this.serverUrl = serverUrl;
-        this.channelName = channelName;
-    }
-
-    @Override
-    public void run() {
-        log.info("clean weight req:{}", channelName);
-        HttpUtil.get(serverUrl + "/open/cleanWeighbridge?channel=" + channelName);
-        log.info("clean finish");
-    }
-}

+ 0 - 26
src/main/java/com/gzlh/job/UploadTask.java

@@ -1,26 +0,0 @@
-package com.gzlh.job;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 上传地磅数据
- */
-@Slf4j
-public class UploadTask implements Runnable {
-    private String serverUrl;
-    private String channelName;
-    private Integer weight;
-
-    public UploadTask(String serverUrl, String channelName, Integer weight) {
-        this.serverUrl = serverUrl;
-        this.channelName = channelName;
-        this.weight = weight;
-    }
-
-    @Override
-    public void run() {
-        log.info("upload weight req:{},{}", channelName, weight);
-       // HttpUtil.get(serverUrl + "/open/reqWeighbridge?channel=" + channelName + "&weight=" + weight);
-        log.info("upload finish");
-    }
-}

+ 37 - 21
src/main/java/com/gzlh/startup/StartupCommandLineRunner.java → src/main/java/com/gzlh/startup/StartupRunner.java

@@ -6,16 +6,17 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.XML;
 import com.gzlh.background.client.BackgroundClientNetty;
 import com.gzlh.background.properties.BackgroundPropertiesConfig;
-import com.gzlh.dto.ApplicationConfigDTO;
-import com.gzlh.event.EventBus;
-import com.gzlh.led.client.LedNettyConfig;
-import com.gzlh.led.properties.LedPropertiesConfig;
-import com.gzlh.infrared.client.RedNettyConfig;
-import com.gzlh.infrared.config.RedPropertiesConfig;
-import com.gzlh.socket.TestClientNetty;
-import com.gzlh.weighbridge.client.WeighbridgeNettyConfig;
-import com.gzlh.weighbridge.config.WeighbridgePropertiesConfig;
-import javafx.scene.layout.Background;
+import com.gzlh.device.capture.properties.CapturePropertiesConfig;
+import com.gzlh.config.ModuleEnum;
+import com.gzlh.config.SystemObject;
+import com.gzlh.config.dto.ApplicationConfigDTO;
+import com.gzlh.bus.EventBus;
+import com.gzlh.config.hksdk.HCNetSDK;
+import com.gzlh.config.hksdk.HkUtils;
+import com.gzlh.config.hksdk.bo.HKCacheManager;
+import com.gzlh.device.led.client.LedNettyConfig;
+import com.gzlh.device.infrared.client.RedNettyConfig;
+import com.gzlh.device.weighbridge.client.WeighbridgeNettyConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
@@ -26,41 +27,56 @@ import java.util.Properties;
 
 @Component
 @Slf4j
-public class StartupCommandLineRunner implements CommandLineRunner {
+public class StartupRunner implements CommandLineRunner {
     @Resource
     private EventBus eventBus;
     @Resource
     private WeighbridgeNettyConfig weighbridgeNettyConfig;
-    @Resource
-    private WeighbridgePropertiesConfig propertiesConfig;
+
     @Resource
     private LedNettyConfig ledNettyConfig;
     @Resource
-    private LedPropertiesConfig ledConfig;
-    @Resource
     private RedNettyConfig redNettyConfig;
-    @Resource
-    private RedPropertiesConfig redConfig;
+
     @Resource
     private BackgroundPropertiesConfig backgroundPropertiesConfig;
     @Resource
     private BackgroundClientNetty backgroundClientNetty;
 
+    @Resource
+    private HkUtils hkUtils;
+    @Resource
+    private HCNetSDK hcNetSDK;
+
     @Override
     public void run(String... args) throws Exception {
         initConfig();
-        if (propertiesConfig.isEnable()) {
+        if (SystemObject.weighbridgePropertiesConfig.isEnable()) {
             ThreadUtil.execute(() -> weighbridgeNettyConfig.connect());
         }
-        if (ledConfig.isEnable()) {
+        if (SystemObject.ledPropertiesConfig.isEnable()) {
             ThreadUtil.execute(() -> ledNettyConfig.connect());
         }
-        if (redConfig.isEnable()) {
+        if (SystemObject.redPropertiesConfig.isEnable()) {
             ThreadUtil.execute(() -> redNettyConfig.connect());
         }
         if (backgroundPropertiesConfig.isEnable()) {
-            ThreadUtil.execute(() -> backgroundClientNetty.connect());
+            //ThreadUtil.execute(() -> backgroundClientNetty.connect());
         }
+        if (SystemObject.capturePropertiesConfig.isEnable()){
+            CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
+            short port= (short) capturePropertiesConfig.getPort();
+            String ip=capturePropertiesConfig.getHost();
+            int userId = hkUtils.Login_V40(ip, port, capturePropertiesConfig.getUsername(), capturePropertiesConfig.getPwd(), hcNetSDK);
+            if (userId!=-1){
+                log.info("登录海康抓拍设备:{},{}",ip,userId);
+                hkUtils.SetAlarm(hcNetSDK,userId);
+                HKCacheManager.add(ModuleEnum.CAPTURE_MODULE,userId);
+            }else {
+                log.info("登录海康抓拍设备失败:{},{}",hcNetSDK.NET_DVR_GetLastError(),userId);
+            }
+        }
+
     }
 
     private void initConfig() {

+ 0 - 8
src/main/java/com/gzlh/utils/WeightCacheManager.java

@@ -1,8 +0,0 @@
-package com.gzlh.utils;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-public class WeightCacheManager {
-
-}

+ 3 - 5
src/main/java/com/gzlh/utils/WordHandlerUtils.java

@@ -1,10 +1,8 @@
 package com.gzlh.utils;
 
-import cn.hutool.core.util.HexUtil;
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.led.utils.CRC16;
-import com.gzlh.led.utils.ColorConver;
-import com.gzlh.led.utils.YangBandPackage;
+import com.gzlh.device.led.utils.ColorConver;
+import com.gzlh.device.led.utils.YangBandPackage;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -32,7 +30,7 @@ public class WordHandlerUtils {
 
 
     public static void main(String[] args) {
-        System.out.println(msgToASCII("8222.2吨"));
+        System.out.println(msgToASCII("请交费 10 元"));
         String pack=YangBandPackage.buildPackage(ColorConver.NU_TO_HEX.get(1)+msgToASCII("8222.2吨"));
         System.out.println(pack);
     }

+ 13 - 4
src/main/resources/application.yml

@@ -13,10 +13,10 @@ weighbridge:
   enable: false
 #LED配置
 led:
-  host: 127.0.0.1
-  port: 4008
+  host: 192.168.1.254
+  port: 4003
   brand: 1000
-  enable: false
+  enable: true
  #红外
 red:
     host: 127.0.0.1
@@ -33,13 +33,22 @@ camera:
   brand: 1000
   port: 8888
   enable: false
+
+capture:
+  brand: 5000
+  host: 192.168.1.11
+  port: 8000
+  username: admin
+  pwd: ap123456
+  enable: true
+
 background:
   host: 127.0.0.1
   port: 8080
   enable: true
   #图片存储根路径
 file:
-  root-path: D:\\upfile\\
+  root-path: D:\\upload\\
 #海康配置文件
 hk:
   log-home: D:\project\face\face-admin\logs\hk

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff