Browse Source

打包加密,配置文件配置放在config.xml目录下

qzyReal 1 year ago
parent
commit
5a7e9badb9
43 changed files with 167 additions and 984 deletions
  1. 8 0
      config.xml
  2. 43 0
      pom.xml
  3. 2 2
      src/main/java/com/gzlh/GatherServerApplication.java
  4. 2 3
      src/main/java/com/gzlh/api/OpenApi.java
  5. 8 11
      src/main/java/com/gzlh/background/client/BackgroundClientHandler.java
  6. 12 10
      src/main/java/com/gzlh/bus/EventDataManager.java
  7. 8 13
      src/main/java/com/gzlh/bus/EventThread.java
  8. 4 2
      src/main/java/com/gzlh/bus/SysConfig.java
  9. 3 22
      src/main/java/com/gzlh/config/SystemObject.java
  10. 2 0
      src/main/java/com/gzlh/config/dto/ApplicationConfigDTO.java
  11. 18 0
      src/main/java/com/gzlh/config/dto/CaputreSetting.java
  12. 1 1
      src/main/java/com/gzlh/config/hksdk/AlarmParseService.java
  13. 1 1
      src/main/java/com/gzlh/device/camera/brand/CameraBrandType.java
  14. 0 37
      src/main/java/com/gzlh/device/camera/client/CameraClientHandler.java
  15. 0 98
      src/main/java/com/gzlh/device/camera/client/CameraNettyConfig.java
  16. 1 4
      src/main/java/com/gzlh/device/camera/handler/impl/CameraHandlerHikvision.java
  17. 0 20
      src/main/java/com/gzlh/device/capture/properties/CapturePropertiesConfig.java
  18. 1 4
      src/main/java/com/gzlh/device/capture/task/HandlerCarImage.java
  19. 3 4
      src/main/java/com/gzlh/device/electron/client/ElectronClientHandler.java
  20. 3 3
      src/main/java/com/gzlh/device/electron/client/ElectronNettyConfig.java
  21. 0 5
      src/main/java/com/gzlh/device/electron/handler/impl/ElectronHandlerRuiDe.java
  22. 2 4
      src/main/java/com/gzlh/device/electron/job/ElectronReadJob.java
  23. 0 8
      src/main/java/com/gzlh/device/infrared/action/InfraredAction.java
  24. 0 20
      src/main/java/com/gzlh/device/infrared/brand/RedBrandType.java
  25. 0 47
      src/main/java/com/gzlh/device/infrared/client/RedClientHandler.java
  26. 0 98
      src/main/java/com/gzlh/device/infrared/client/RedNettyConfig.java
  27. 0 18
      src/main/java/com/gzlh/device/infrared/config/RedPropertiesConfig.java
  28. 0 21
      src/main/java/com/gzlh/device/infrared/factory/RedFactory.java
  29. 0 14
      src/main/java/com/gzlh/device/infrared/handler/IRedHandler.java
  30. 0 53
      src/main/java/com/gzlh/device/infrared/handler/impl/RedHandlerSoarDAM0404.java
  31. 0 7
      src/main/java/com/gzlh/device/led/client/LedClientHandler.java
  32. 3 11
      src/main/java/com/gzlh/device/led/client/LedNettyConfig.java
  33. 2 7
      src/main/java/com/gzlh/device/led/handler/impl/LedHandlerYangBandV4d2.java
  34. 0 8
      src/main/java/com/gzlh/device/plc/client/PlcClientHandler.java
  35. 3 6
      src/main/java/com/gzlh/device/plc/client/PlcNettyConfig.java
  36. 3 7
      src/main/java/com/gzlh/device/plc/handler/PLCHadnler.java
  37. 4 7
      src/main/java/com/gzlh/device/plc/service/PLCService.java
  38. 11 9
      src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeNettyConfig.java
  39. 4 5
      src/main/java/com/gzlh/device/weighbridge/handler/impl/CommonWeighbridgeHandler.java
  40. 0 330
      src/main/java/com/gzlh/startup/ReaderJavaWDemo.java
  41. 8 19
      src/main/java/com/gzlh/startup/StartupRunner.java
  42. 7 8
      src/main/java/com/gzlh/utils/DeviceCache.java
  43. 0 37
      src/main/resources/application.yml

+ 8 - 0
config.xml

@@ -2,6 +2,14 @@
 
 <config>
     <sysConfig>
+        <caputreSetting>
+            <enable>true</enable>
+            <host>192.168.1.11</host>
+            <port>8000</port>
+            <username>admin</username>
+            <pwd>ap123456</pwd>
+            <brand>5000</brand>
+        </caputreSetting>
         <serialSetting>
             <host>192.168.1.254</host>
             <weighbridge>

+ 43 - 0
pom.xml

@@ -16,6 +16,7 @@
     <properties>
         <java.version>8</java.version>
         <java.run.main.class>com.gzlh.GatherServerApplication</java.run.main.class>
+        <classfinal.version>1.2.1</classfinal.version>
     </properties>
     <dependencies>
         <dependency>
@@ -122,6 +123,48 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                        <include>
+                            <groupId>org.springframework</groupId>
+                            <artifactId>spring-core</artifactId>
+                        </include>
+                    </includes>
+                    >
+                </configuration>
+            </plugin>
+            <plugin>
+                <!-- https://gitee.com/roseboy/classfinal -->
+                <groupId>net.roseboy</groupId>
+                <artifactId>classfinal-maven-plugin</artifactId>
+                <version>${classfinal.version}</version>
+                <configuration>
+                    <!--加密打包之后pom.xml会被删除,不用担心在jar包里找到此密码-->
+                    <password>353568</password>
+                    <packages>com.gzlh</packages> <!--可以多个-->
+                    <!--                    <cfgfiles>application.yml</cfgfiles>-->
+                    <excludes>org.spring</excludes>
+                    <!--lib包中的jar加密-->
+                    <!--                    <libjars>a.jar,b.jar</libjars>-->
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>classFinal</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
         </plugins>
     </build>
 

+ 2 - 2
src/main/java/com/gzlh/GatherServerApplication.java

@@ -1,6 +1,6 @@
 package com.gzlh;
 
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -20,7 +20,7 @@ import java.util.Properties;
 public class GatherServerApplication  {
 
     public static void main(String[] args) {
-        EventConfig.initConfig();
+        SysConfig.initConfig();
         Properties properties = System.getProperties();
         String rootPath = properties.getProperty("user.dir");
         SpringApplication application = new SpringApplication(GatherServerApplication.class);

+ 2 - 3
src/main/java/com/gzlh/api/OpenApi.java

@@ -1,12 +1,11 @@
 package com.gzlh.api;
 
 import cn.hutool.core.thread.ThreadUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.bus.EventBus;
 import com.gzlh.config.SystemObject;
 import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.device.electron.client.ElectronNettyConfig;
 import com.gzlh.device.electron.job.ElectronReadJob;
 import com.gzlh.device.led.event.LedDefaultEvent;
 import com.gzlh.device.led.utils.LedOptions;
@@ -32,7 +31,7 @@ public class OpenApi {
         eventBus.startEvent(ModuleEnum.LED_MODULE.getModuleEn()+"."+ LedDefaultEvent.READ);
         eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn()+"."+ WeighbridgeEvent.READ);
         System.out.println();
-        SerialSetting.LedDTO ledDTO= EventConfig.serialSetting.getLed();
+        SerialSetting.LedDTO ledDTO= SysConfig.serialSetting.getLed();
         LedOptions ledOptions=new LedOptions();
         ledOptions.setLine(line).setShowType(showType).setColor(color);
         SystemObject.ledFactory.handler(ledDTO.getBrand()).sendMsg(msg,ledOptions);

+ 8 - 11
src/main/java/com/gzlh/background/client/BackgroundClientHandler.java

@@ -1,26 +1,23 @@
 package com.gzlh.background.client;
 
-import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.gzlh.bus.EventBus;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.config.SystemObject;
+import com.gzlh.config.dto.CaputreSetting;
 import com.gzlh.config.hksdk.HCNetSDK;
 import com.gzlh.config.hksdk.HkUtils;
 import com.gzlh.config.hksdk.bo.HKCacheManager;
 import com.gzlh.device.capture.brand.CaptureBrandType;
-import com.gzlh.device.capture.properties.CapturePropertiesConfig;
 import com.gzlh.device.led.utils.LedOptions;
 import com.gzlh.entity.CommandBO;
-import com.gzlh.entity.DeviceStatus;
 import com.gzlh.utils.DeviceCache;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import io.netty.handler.timeout.IdleStateEvent;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
@@ -56,7 +53,7 @@ public class BackgroundClientHandler extends SimpleChannelInboundHandler<String>
             eventBus.startEvent(command.getModule()+"."+command.getCommand());
             if (!StringUtils.isEmpty(command.getExtra())){
                 LedOptions options = new LedOptions().setLine("04").setColor("03").setShowType("00");
-                SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
+                SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
                             .sendMsg(command.getExtra(),options);
             }
         }
@@ -66,17 +63,17 @@ public class BackgroundClientHandler extends SimpleChannelInboundHandler<String>
     protected void sendHeartbeat(ChannelHandlerContext context) {
 //        向后台发送设备信息json字符串
 //        获取海康摄像头连接状态
-        if (SystemObject.capturePropertiesConfig.getBrand()== CaptureBrandType.HK_BRAND.getCode()){
+        CaputreSetting caputreSetting=SysConfig.caputreSetting;
+        if (caputreSetting.getBrand()== CaptureBrandType.HK_BRAND.getCode()){
             Map<String,Object> captrue = new HashMap<String,Object>();
             int userId = HKCacheManager.getUserId(ModuleEnum.CAPTURE_MODULE);
             boolean status = hkUtils.getStatus(hcNetSDK, userId);
 
             int loginV40=0;
             if (!status){
-                CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
-                short port= (short) capturePropertiesConfig.getPort();
-                String ip=capturePropertiesConfig.getHost();
-                loginV40 = hkUtils.Login_V40(ip, port, capturePropertiesConfig.getUsername(), capturePropertiesConfig.getPwd(), hcNetSDK);
+                short port= (short) caputreSetting.getPort();
+                String ip=caputreSetting.getHost();
+                loginV40 = hkUtils.Login_V40(ip, port, caputreSetting.getUsername(), caputreSetting.getPwd(), hcNetSDK);
             }
             DeviceCache.changeDeviceStatus(ModuleEnum.CAPTURE_MODULE.getModuleEn(), loginV40!=-1?1:0);
         }

+ 12 - 10
src/main/java/com/gzlh/bus/EventDataManager.java

@@ -10,39 +10,41 @@ import com.gzlh.entity.ReqBO;
 
 public class EventDataManager {
 
-    private static final TimedCache<String, ReqBO> CACHE_MAP= CacheUtil.newTimedCache(20*60*1000);
+    private static final TimedCache<String, ReqBO> CACHE_MAP = CacheUtil.newTimedCache(20 * 60 * 1000);
 
-    private static final String KEY="event_key";
+    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();
+    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);
+        ReflectUtil.setFieldValue(reqBO, field, value);
+        CACHE_MAP.put(KEY, reqBO);
         StaticLog.info("cache bo:{}", JSONUtil.toJsonStr(reqBO));
     }
 
     /**
      * 获取数据中心数据
+     *
      * @return
      */
-    public static ReqBO getCacheData(){
+    public static ReqBO getCacheData() {
         return CACHE_MAP.get(KEY);
     }
 
     /**
      * 清除掉缓存
      */
-    public static void cleanData(){
+    public static void cleanData() {
         CACHE_MAP.clear();
     }
 }

+ 8 - 13
src/main/java/com/gzlh/bus/EventThread.java

@@ -8,17 +8,15 @@ import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.gzlh.config.dto.CaputreSetting;
 import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.device.capture.factory.CaptureFactory;
-import com.gzlh.device.capture.properties.CapturePropertiesConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.config.SystemObject;
 import com.gzlh.device.electron.factory.ElectronFactory;
-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.utils.LedOptions;
-import com.gzlh.device.plc.action.PLCAction;
 import com.gzlh.device.plc.event.PLCEvent;
 import com.gzlh.device.plc.handler.PLCHadnler;
 import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
@@ -43,18 +41,16 @@ public class EventThread implements Runnable{
      * @param eventName 服务.事件名 比如led.ready
      */
     public void handlerEvent(String eventName) {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         LedFactory ledFactory= SystemObject.ledFactory;
-        RedFactory redFactory=SystemObject.redFactory;
         WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
         ElectronFactory electronFactory= SystemObject.electronFactory;
         WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
-        RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
         PLCHadnler plcHadnler= SpringUtil.getBean(PLCHadnler.class);
         CaptureFactory captureFactory=SystemObject.captureFactory;
-        CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
+        CaputreSetting caputreSetting=SysConfig.caputreSetting;
         log.info("event:{}", eventName);
-        EventConfig.eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
+        SysConfig.eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
                 .findFirst().ifPresent(eventDTO -> {
             List<String> actionList = eventDTO.getActionList().getAction();
             //依次执行动作
@@ -68,7 +64,6 @@ public class EventThread implements Runnable{
                 }
                 if (StrUtil.equals(module, ModuleEnum.INFRARED_MODULE.getModuleEn())) {
                     //动作属于红外
-                    redFactory.handler(redPropertiesConfig.getBrand()).handlerAction(command);
                 } else if (StrUtil.equals(module, ModuleEnum.LED_MODULE.getModuleEn())) {
                     //动作属于led
                     ledFactory.handler(serialSetting.getLed().getBrand()).handlerAction(command);
@@ -77,7 +72,7 @@ public class EventThread implements Runnable{
                     weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).handlerAction(command);
                 }else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
                     //动作属于抓拍单元--车牌识别
-                    captureFactory.handler(capturePropertiesConfig.getBrand()).handlerAction(command);
+                    captureFactory.handler(caputreSetting.getBrand()).handlerAction(command);
                 }else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
                     //动作属于plc
                     plcHadnler.handlerAction(command);
@@ -140,14 +135,14 @@ public class EventThread implements Runnable{
             if (response.getStatus()==200){
                 options.setColor("02");
                 if (ModuleEnum.LED_MODULE.getModuleEn().equalsIgnoreCase(commandBO.getCommand().getModule())){
-                    SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
+                    SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
                             .sendMsg(commandBO.getCommand().getExtra(),options);
                 }
                 eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn()+"."+ PLCEvent.RAILING_RISE);
             }else{
                 options.setColor("01");
                 if (ModuleEnum.LED_MODULE.getModuleEn().equalsIgnoreCase(commandBO.getCommand().getModule())){
-                    SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
+                    SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
                             .sendMsg(commandBO.getCommand().getExtra(),options);
                 }else {
                     eventBus.startEvent(commandBO.getCommand().getModule()+"."+ commandBO.getCommand().getCommand());

+ 4 - 2
src/main/java/com/gzlh/bus/EventConfig.java → src/main/java/com/gzlh/bus/SysConfig.java

@@ -4,9 +4,9 @@ import cn.hutool.core.io.FileUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.XML;
 import com.gzlh.config.dto.ApplicationConfigDTO;
+import com.gzlh.config.dto.CaputreSetting;
 import com.gzlh.config.dto.EventDTO;
 import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.utils.DeviceCache;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
@@ -16,9 +16,10 @@ import java.util.Properties;
 
 @Data
 @Slf4j
-public class EventConfig {
+public class SysConfig {
     public static List<EventDTO> eventDTOList;
     public static SerialSetting serialSetting;
+    public static CaputreSetting caputreSetting;
 
     public static void initConfig() {
         Properties properties = System.getProperties();
@@ -35,5 +36,6 @@ public class EventConfig {
         ApplicationConfigDTO configDTO = result.toBean(ApplicationConfigDTO.class);
         eventDTOList=configDTO.getConfig().getEventList().getEvent();
         serialSetting=configDTO.getConfig().getSysConfig().getSerialSetting();
+        caputreSetting=configDTO.getConfig().getSysConfig().getCaputreSetting();
     }
 }

+ 3 - 22
src/main/java/com/gzlh/config/SystemObject.java

@@ -1,10 +1,8 @@
 package com.gzlh.config;
 
 import com.gzlh.device.capture.factory.CaptureFactory;
-import com.gzlh.device.capture.properties.CapturePropertiesConfig;
 import com.gzlh.device.electron.factory.ElectronFactory;
-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.weighbridge.config.WeighbridgePropertiesConfig;
 import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
@@ -17,14 +15,12 @@ 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 CapturePropertiesConfig capturePropertiesConfig;
 
     public static CaptureFactory captureFactory;
     public static ElectronFactory electronFactory;
@@ -43,14 +39,6 @@ public class SystemObject {
     }
 
     @Autowired
-   void setRedFactory(RedFactory redFactory) {
-        SystemObject.redFactory = redFactory;
-    }
-    @Autowired
-    void setRedPropertiesConfig(RedPropertiesConfig redPropertiesConfig) {
-        SystemObject.redPropertiesConfig = redPropertiesConfig;
-    }
-    @Autowired
      void setWeighbridgeFactory(WeighbridgeFactory weighbridgeFactory) {
         SystemObject.weighbridgeFactory = weighbridgeFactory;
     }
@@ -63,12 +51,5 @@ public class SystemObject {
         SystemObject.ledFactory = ledFactory;
     }
 
-    @Autowired
-   void setCaptureFactory(CaptureFactory captureFactory) {
-        SystemObject.captureFactory = captureFactory;
-    }
-    @Autowired
-     void setCapturePropertiesConfig(CapturePropertiesConfig capturePropertiesConfig) {
-        SystemObject.capturePropertiesConfig = capturePropertiesConfig;
-    }
+
 }

+ 2 - 0
src/main/java/com/gzlh/config/dto/ApplicationConfigDTO.java

@@ -33,6 +33,8 @@ public class ApplicationConfigDTO implements Serializable {
         public static class ConfigListDTO{
             @JsonProperty("serialSetting")
             private SerialSetting serialSetting;
+            @JsonProperty("caputreSetting")
+            private CaputreSetting caputreSetting;
         }
     }
 }

+ 18 - 0
src/main/java/com/gzlh/config/dto/CaputreSetting.java

@@ -0,0 +1,18 @@
+package com.gzlh.config.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@Data
+@Accessors(chain = true)
+public class CaputreSetting implements Serializable {
+
+    private boolean enable;
+    private String host;
+    private int port;
+    private int brand;
+    private String username;
+    private String pwd;
+}

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

@@ -74,7 +74,7 @@ public class AlarmParseService {
                 return;
             }
 
-            hkUtils.handlerUp(hcNetSDK, pAlarmer.lUserID);
+           // hkUtils.handlerUp(hcNetSDK, pAlarmer.lUserID);
             Date nowTime=new Date();
             /**
              * 报警图片保存,车牌,车辆图片

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

@@ -7,7 +7,7 @@ import lombok.Getter;
 @AllArgsConstructor
 public enum CameraBrandType {
 
-    HIKVISION(1000,"海康威视")
+    HIKVISION(1000,"天勤箱号识别")
 
     ;
 

+ 0 - 37
src/main/java/com/gzlh/device/camera/client/CameraClientHandler.java

@@ -1,37 +0,0 @@
-package com.gzlh.device.camera.client;
-
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@ChannelHandler.Sharable
-public class CameraClientHandler extends SimpleChannelInboundHandler<String> {
-
-    private CameraNettyConfig cameraNettyConfig;
-
-    public CameraClientHandler(CameraNettyConfig cameraNettyConfig) {
-        this.cameraNettyConfig = cameraNettyConfig;
-    }
-
-    @Override
-    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
-        log.info("Camera 客户端收到消息:" + msg);
-
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        log.error("Camera 客户端 连接断开,进行重连");
-        cameraNettyConfig.connect();
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        cause.printStackTrace();
-        ctx.close();
-    }
-
-}
-

+ 0 - 98
src/main/java/com/gzlh/device/camera/client/CameraNettyConfig.java

@@ -1,98 +0,0 @@
-package com.gzlh.device.camera.client;
-
-import com.gzlh.device.camera.properties.CameraPropertiesConfig;
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.annotation.Resource;
-import java.util.concurrent.TimeUnit;
-
-@Configuration
-@Slf4j
-public class CameraNettyConfig {
-
-    @Resource
-    private CameraPropertiesConfig cameraConfig;
-
-    @Autowired
-    private CameraClientHandler cameraClientHandler;
-
-    private Channel channel;
-
-    @Bean("cameraBootstrap")
-    public Bootstrap bootstrap() {
-        String host = cameraConfig.getHost();
-        int port = cameraConfig.getPort();
-        if (cameraConfig.isEnable()) {
-            log.info("初始化 led:{},{}", host, port);
-        }
-        EventLoopGroup group = new NioEventLoopGroup();
-        return new Bootstrap()
-                .group(group)
-                .channel(NioSocketChannel.class)
-                .remoteAddress(host, port)
-                .option(ChannelOption.SO_KEEPALIVE, true)
-                .handler(new ChannelInitializer<SocketChannel>() {
-                    @Override
-                    protected void initChannel(SocketChannel ch) {
-                        try {
-                            ChannelPipeline pipeline = ch.pipeline();
-                            pipeline.addLast("decoder", new StringDecoder());
-                            pipeline.addLast("encoder", new StringEncoder());
-                            pipeline.addLast("handler", cameraClientHandler);
-                        } catch (Exception e) {
-                            log.info("error connect:{}", e.getMessage());
-                        }
-                    }
-                });
-    }
-
-    @Bean("cameraClientHandler")
-    public CameraClientHandler cameraClientHandler() {
-        return new CameraClientHandler(this);
-    }
-
-    public void connect() {
-        String host = cameraConfig.getHost();
-        int port = cameraConfig.getPort();
-        ChannelFuture future = bootstrap().connect();
-        future.addListener((ChannelFutureListener) future1 -> {
-            if (future1.isSuccess()) {
-                channel = future1.channel();
-                log.info("Camera 串口服务器连接成功,{},{}", host, port);
-            } else {
-                log.error("-------------Camera 连接服务器失败,{},{}-----------,进行重连", host, port);
-                future1.channel().eventLoop().schedule(this::connect, 5, TimeUnit.SECONDS);
-            }
-        });
-        try {
-            future.channel().closeFuture().sync();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void send(String message) {
-        if (channel != null && channel.isActive()) {
-            channel.writeAndFlush(message);
-        } else {
-            log.error("未建立连接,无法发送消息");
-        }
-    }
-
-    public void close() {
-        if (channel != null) {
-            channel.close();
-        }
-    }
-}
-

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

@@ -1,7 +1,6 @@
 package com.gzlh.device.camera.handler.impl;
 
 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;
@@ -15,8 +14,7 @@ import javax.annotation.Resource;
 @Slf4j
 public class CameraHandlerHikvision implements ICameraHandler {
 
-    @Resource
-    private CameraNettyConfig cameraNettyConfig;
+
 
     @Override
     public CameraBrandType brandType() {
@@ -26,7 +24,6 @@ public class CameraHandlerHikvision implements ICameraHandler {
     @Override
     public void sendMsg(String content) {
         log.info(CameraBrandType.HIKVISION.getBrand() + "发送消息:{}", content);
-        cameraNettyConfig.send(content);
     }
 
     @Override

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

@@ -1,20 +0,0 @@
-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;
-}

+ 1 - 4
src/main/java/com/gzlh/device/capture/task/HandlerCarImage.java

@@ -5,8 +5,7 @@ import cn.hutool.extra.spring.SpringUtil;
 
 import com.gzlh.config.SystemObject;
 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;
@@ -27,8 +26,6 @@ import java.util.Date;
  */
 @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) {

+ 3 - 4
src/main/java/com/gzlh/device/electron/client/ElectronClientHandler.java

@@ -1,10 +1,9 @@
 package com.gzlh.device.electron.client;
 
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.config.SystemObject;
-import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.device.electron.action.IElectronAction;
 import com.gzlh.utils.DeviceCache;
 import io.netty.channel.ChannelHandler;
@@ -33,7 +32,7 @@ public class ElectronClientHandler extends SimpleChannelInboundHandler<String> {
             return;
         }
         log.info("电子车牌 客户端收到消息:" + msg);
-        SystemObject.electronFactory.handler(EventConfig.serialSetting.getElectron().getBrand())
+        SystemObject.electronFactory.handler(SysConfig.serialSetting.getElectron().getBrand())
                 .handlerMsg(msg.toUpperCase());
     }
 
@@ -76,7 +75,7 @@ public class ElectronClientHandler extends SimpleChannelInboundHandler<String> {
 
     protected void handleWriterIdle(ChannelHandlerContext ctx) {
         //写空闲时发送读取版本信息指令
-        SystemObject.electronFactory.handler(EventConfig.serialSetting.getElectron().getBrand())
+        SystemObject.electronFactory.handler(SysConfig.serialSetting.getElectron().getBrand())
                 .handlerAction(IElectronAction.VERSION);
 //        System.err.println("---WRITER_IDLE---");
     }

+ 3 - 3
src/main/java/com/gzlh/device/electron/client/ElectronNettyConfig.java

@@ -1,6 +1,6 @@
 package com.gzlh.device.electron.client;
 
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.config.netty.NettyDecoder;
 import com.gzlh.utils.XorUtils;
@@ -34,7 +34,7 @@ public class ElectronNettyConfig {
 
     @Bean("electronBootstrap")
     public Bootstrap bootstrap() {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getElectron().getPort();
         EventLoopGroup group = new NioEventLoopGroup();
@@ -65,7 +65,7 @@ public class ElectronNettyConfig {
     }
 
     public void connect() {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getElectron().getPort();
         ChannelFuture future = bootstrap().connect();

+ 0 - 5
src/main/java/com/gzlh/device/electron/handler/impl/ElectronHandlerRuiDe.java

@@ -2,17 +2,12 @@ package com.gzlh.device.electron.handler.impl;
 
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.bus.EventConfig;
 import com.gzlh.bus.EventDataManager;
-import com.gzlh.config.SystemObject;
 import com.gzlh.device.electron.action.IElectronAction;
 import com.gzlh.device.electron.brand.ElectronBrandType;
 import com.gzlh.device.electron.client.ElectronNettyConfig;
 import com.gzlh.device.electron.handler.IElectronHandler;
-import com.gzlh.device.electron.job.ElectronReadJob;
 import com.gzlh.device.electron.utils.CheckNumUtils;
-import com.gzlh.device.led.utils.LedOptions;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 

+ 2 - 4
src/main/java/com/gzlh/device/electron/job/ElectronReadJob.java

@@ -1,10 +1,8 @@
 package com.gzlh.device.electron.job;
 
-import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.SystemObject;
 import com.gzlh.device.electron.action.IElectronAction;
-import com.gzlh.device.electron.client.ElectronNettyConfig;
 
 /**
  *下发指令读取卡
@@ -18,7 +16,7 @@ public class ElectronReadJob implements Runnable{
 
     @Override
     public void run() {
-        SystemObject.electronFactory.handler(EventConfig.serialSetting.getElectron().getBrand())
+        SystemObject.electronFactory.handler(SysConfig.serialSetting.getElectron().getBrand())
                 .handlerAction(IElectronAction.START_READ_CARD);
     }
 }

+ 0 - 8
src/main/java/com/gzlh/device/infrared/action/InfraredAction.java

@@ -1,8 +0,0 @@
-package com.gzlh.device.infrared.action;
-
-public interface InfraredAction {
-    /**
-     * 入地磅红外断开
-     */
-    String IN_BREAK="IN_BREAK";
-}

+ 0 - 20
src/main/java/com/gzlh/device/infrared/brand/RedBrandType.java

@@ -1,20 +0,0 @@
-package com.gzlh.device.infrared.brand;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * 红外内置支持品牌
- */
-@Getter
-@AllArgsConstructor
-public enum RedBrandType {
-
-    SHANGHAI_YANGBAND_BX(2000,"聚英翱翔电子")
-
-    ;
-
-
-    private int code;
-    private String brand;
-}

+ 0 - 47
src/main/java/com/gzlh/device/infrared/client/RedClientHandler.java

@@ -1,47 +0,0 @@
-package com.gzlh.device.infrared.client;
-
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
-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;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@ChannelHandler.Sharable
-public class RedClientHandler extends SimpleChannelInboundHandler<String> {
-
-    private RedNettyConfig redNettyConfig;
-
-    public RedClientHandler(RedNettyConfig redNettyConfig) {
-        this.redNettyConfig = redNettyConfig;
-    }
-
-    @Override
-    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
-        log.info("红外客户端收到消息:" + msg);
-        msg = StrUtil.replace(msg, "\u0003", "").replace("\u0002", "");
-        log.info("转换后消息:" + msg);
-        // 去掉开头和结尾的特殊字符
-        RedPropertiesConfig propertiesConfig = SpringUtil.getBean(RedPropertiesConfig.class);
-        RedFactory redFactory = SpringUtil.getBean(RedFactory.class);
-        redFactory.handler(propertiesConfig.getBrand()).handlerMsg(msg);
-
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        System.out.println("连接断开,进行重连");
-        redNettyConfig.connect();
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        cause.printStackTrace();
-        ctx.close();
-    }
-
-}
-

+ 0 - 98
src/main/java/com/gzlh/device/infrared/client/RedNettyConfig.java

@@ -1,98 +0,0 @@
-package com.gzlh.device.infrared.client;
-
-import com.gzlh.device.infrared.config.RedPropertiesConfig;
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.annotation.Resource;
-import java.util.concurrent.TimeUnit;
-
-@Configuration
-@Slf4j
-public class RedNettyConfig {
-
-    @Resource
-    private RedPropertiesConfig redConfig;
-
-    @Autowired
-    private RedClientHandler redClientHandler;
-
-    private Channel channel;
-
-    @Bean("RedBoostrap")
-    public Bootstrap bootstrap() {
-       String host= redConfig.getHost();
-       int port=redConfig.getPort();
-       if (redConfig.isEnable()){
-           log.info("初始化 红外===========:{},{}",host,port);
-       }
-        EventLoopGroup group = new NioEventLoopGroup();
-        return new Bootstrap()
-                .group(group)
-                .channel(NioSocketChannel.class)
-                .remoteAddress(host, port)
-                .option(ChannelOption.SO_KEEPALIVE, true)
-                .handler(new ChannelInitializer<SocketChannel>() {
-                    @Override
-                    protected void initChannel(SocketChannel ch)  {
-                        try {
-                            ChannelPipeline pipeline = ch.pipeline();
-                            pipeline.addLast("decoder", new StringDecoder());
-                            pipeline.addLast("encoder", new StringEncoder());
-                            pipeline.addLast("handler", redClientHandler);
-                        }catch (Exception e){
-                            log.info("error connect:{}",e.getMessage());
-                        }
-                    }
-                });
-    }
-
-    @Bean("RedClientHandler")
-    public RedClientHandler redClientHandler() {
-        return new RedClientHandler(this);
-    }
-
-    public void connect() {
-        String host= redConfig.getHost();
-        int port=redConfig.getPort();
-        ChannelFuture future = bootstrap().connect();
-        future.addListener((ChannelFutureListener) future1 -> {
-            if (future1.isSuccess()) {
-                channel = future1.channel();
-                log.info("红外 串口服务器连接成功 ,{},{}",host,port);
-            } else {
-                log.error("--------红外-----连接服务器失败,{},{}-----------,进行重连",host,port);
-                future1.channel().eventLoop().schedule(this::connect, 5, TimeUnit.SECONDS);
-            }
-        });
-        try {
-            future.channel().closeFuture().sync();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void send(String message) {
-        if (channel != null && channel.isActive()) {
-            channel.writeAndFlush(message);
-        } else {
-            log.error("未建立连接,无法发送消息");
-        }
-    }
-
-    public void close() {
-        if (channel != null) {
-            channel.close();
-        }
-    }
-}
-

+ 0 - 18
src/main/java/com/gzlh/device/infrared/config/RedPropertiesConfig.java

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

+ 0 - 21
src/main/java/com/gzlh/device/infrared/factory/RedFactory.java

@@ -1,21 +0,0 @@
-package com.gzlh.device.infrared.factory;
-
-
-
-import com.gzlh.device.infrared.handler.IRedHandler;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-@Service
-public class RedFactory {
-    @Autowired
-    private List<IRedHandler>handlers;
-
-    public IRedHandler handler(int code){
-       return handlers.stream().filter(h->h.brandType().getCode()==code)
-                .findAny().orElseThrow(()->new IllegalArgumentException("不支持交互"));
-    }
-
-}

+ 0 - 14
src/main/java/com/gzlh/device/infrared/handler/IRedHandler.java

@@ -1,14 +0,0 @@
-package com.gzlh.device.infrared.handler;
-
-import com.gzlh.device.infrared.brand.RedBrandType;
-
-/**
- * 红外
- */
-public interface IRedHandler {
-
-    RedBrandType brandType();
-
-    void handlerMsg(String content);
-    void handlerAction(String action);
-}

+ 0 - 53
src/main/java/com/gzlh/device/infrared/handler/impl/RedHandlerSoarDAM0404.java

@@ -1,53 +0,0 @@
-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.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;
-
-/**
- * 聚英翱翔电子 01082899821  聚英翱翔电子,按0,转技术电话
- * dam0404d 品牌
- */
-@Service
-@Slf4j
-public class RedHandlerSoarDAM0404 implements IRedHandler {
-    /**
-     * 断开的信号
-     */
-    private final static String FIRST_BREAK_SIGNAL = "01 02 01 02 20 49";
-    /**
-     * 从断开到闭合
-     */
-    private final static String FIRST_LINK_SIGNAL = "01 02 01 03 E1 89";
-
-
-    @Override
-    public RedBrandType brandType() {
-        return RedBrandType.SHANGHAI_YANGBAND_BX;
-    }
-
-    @Override
-    public void handlerMsg(String content) {
-        log.info(RedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "对红外处理消息:{}", content);
-        content = StrUtil.replace(content, " ", "").toUpperCase();
-        //进 被遮挡
-        if (StrUtil.equals(StrUtil.replace(FIRST_BREAK_SIGNAL, " ", ""), content)) {
-            //todo test msg
-        }else if (StrUtil.equals(StrUtil.replace(FIRST_LINK_SIGNAL, " ", ""), content)){
-            EventBus eventBus= SpringUtil.getBean(EventBus.class);
-//            //入红外被挡住
-            eventBus.startEvent(ModuleEnum.INFRARED_MODULE.getModuleEn()+"."+ InfraredAction.IN_BREAK);
-        }
-    }
-
-    @Override
-    public void handlerAction(String action) {
-
-    }
-}

+ 0 - 7
src/main/java/com/gzlh/device/led/client/LedClientHandler.java

@@ -1,19 +1,12 @@
 package com.gzlh.device.led.client;
 
-import com.gzlh.bus.EventConfig;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.device.led.brand.LedBrandType;
-import com.gzlh.entity.DeviceStatus;
 import com.gzlh.utils.DeviceCache;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.List;
-import java.util.stream.Collectors;
-
 @Slf4j
 @ChannelHandler.Sharable
 public class LedClientHandler extends SimpleChannelInboundHandler<String> {

+ 3 - 11
src/main/java/com/gzlh/device/led/client/LedNettyConfig.java

@@ -1,11 +1,9 @@
 package com.gzlh.device.led.client;
 
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.config.netty.NettyDecoder;
-import com.gzlh.device.led.brand.LedBrandType;
-import com.gzlh.entity.DeviceStatus;
 import com.gzlh.utils.DeviceCache;
 import com.gzlh.utils.XorUtils;
 import io.netty.bootstrap.Bootstrap;
@@ -15,20 +13,14 @@ import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.handler.codec.string.StringDecoder;
 import io.netty.handler.codec.string.StringEncoder;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import javax.annotation.Resource;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
-import java.util.List;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
 
 @Configuration
 @Slf4j
@@ -43,7 +35,7 @@ public class LedNettyConfig {
 
     @Bean("ledBootstrap")
     public Bootstrap bootstrap() {
-        SerialSetting serialSetting= EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getLed().getPort();
         if (serialSetting.getLed().getEnable()) {
@@ -76,7 +68,7 @@ public class LedNettyConfig {
     }
 
     public void connect() {
-        SerialSetting serialSetting= EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getLed().getPort();
         ChannelFuture future = bootstrap().connect();

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

@@ -1,16 +1,11 @@
 package com.gzlh.device.led.handler.impl;
 
-import cn.hutool.core.util.StrUtil;
-import com.gzlh.bus.EventConfig;
-import com.gzlh.bus.EventDataManager;
-import com.gzlh.device.led.action.LedAction;
 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.LedOptions;
 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;
@@ -34,9 +29,9 @@ public class LedHandlerYangBandV4d2 implements ILedHandler {
 
     @Override
     public void sendMsg(String content, LedOptions ledOptions) {
-        log.info(RedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "发送消息:{}", content);
+        log.info(LedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "发送消息:{}", content);
         String pack = YangBandPackage.buildPackage(ColorConver.NU_TO_HEX.get(1) + WordHandlerUtils.msgToASCII(content));
-        log.info(RedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "转换后的数据:{}", pack);
+        log.info(LedBrandType.SHANGHAI_YANGBAND_BX.getBrand() + "转换后的数据:{}", pack);
         ledNettyConfig.send(pack);
     }
 

+ 0 - 8
src/main/java/com/gzlh/device/plc/client/PlcClientHandler.java

@@ -1,12 +1,7 @@
 package com.gzlh.device.plc.client;
 
-import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.bus.EventConfig;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.config.SystemObject;
-import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.device.plc.handler.PLCHadnler;
-import com.gzlh.device.plc.service.PLCService;
 import com.gzlh.utils.DeviceCache;
 import com.gzlh.utils.ModbusUtils;
 import io.netty.channel.ChannelHandler;
@@ -15,9 +10,6 @@ import io.netty.channel.SimpleChannelInboundHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.lang.reflect.Field;
-import java.util.*;
-
 @Slf4j
 @ChannelHandler.Sharable
 public class PlcClientHandler extends SimpleChannelInboundHandler<String> {

+ 3 - 6
src/main/java/com/gzlh/device/plc/client/PlcNettyConfig.java

@@ -1,6 +1,6 @@
 package com.gzlh.device.plc.client;
 
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.config.netty.NettyDecoder;
 import com.gzlh.utils.XorUtils;
@@ -17,10 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import javax.annotation.Resource;
 import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 @Configuration
@@ -36,7 +33,7 @@ public class PlcNettyConfig {
 
     @Bean("plcBootstrap")
     public Bootstrap bootstrap() {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getPlc().getPort();
         EventLoopGroup group = new NioEventLoopGroup();
@@ -66,7 +63,7 @@ public class PlcNettyConfig {
     }
 
     public void connect() {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         String host = serialSetting.getHost();
         int port = serialSetting.getPlc().getPort();
         ChannelFuture future = bootstrap().connect();

+ 3 - 7
src/main/java/com/gzlh/device/plc/handler/PLCHadnler.java

@@ -1,13 +1,11 @@
 package com.gzlh.device.plc.handler;
 
 import cn.hutool.core.util.StrUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.device.led.brand.LedBrandType;
 import com.gzlh.device.plc.action.PLCAction;
 import com.gzlh.device.plc.client.PlcNettyConfig;
 import com.gzlh.device.plc.service.PLCService;
-import com.gzlh.entity.DeviceStatus;
 import com.gzlh.utils.DeviceCache;
 import com.gzlh.utils.ModbusUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -16,8 +14,6 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.lang.reflect.Field;
 import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -31,7 +27,7 @@ public class PLCHadnler {
     private PLCService plcService = new PLCService();
 
     public void handlerAction(String action) {
-        SerialSetting serialSetting = EventConfig.serialSetting;
+        SerialSetting serialSetting = SysConfig.serialSetting;
         if (StrUtil.equals(action, PLCAction.RED_LIGHT_ON)) {
             //亮红灯
             String redPoint = serialSetting.getPlc().getOut().getSignalRedPoint();
@@ -91,7 +87,7 @@ public class PLCHadnler {
 
 //        设备信息发生变化时进入
         if (oldPlcInfo!=null&&!newPlcInfo.equals(oldPlcInfo)){
-            SerialSetting.PlcDTO.StatusDTO status = EventConfig.serialSetting.getPlc().getStatus();
+            SerialSetting.PlcDTO.StatusDTO status = SysConfig.serialSetting.getPlc().getStatus();
 
             String newReverse = new StringBuffer(newPlcInfo).reverse().toString();
             String oldReverse = new StringBuffer(oldPlcInfo).reverse().toString();

+ 4 - 7
src/main/java/com/gzlh/device/plc/service/PLCService.java

@@ -3,15 +3,12 @@ package com.gzlh.device.plc.service;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.gzlh.bus.EventBus;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.bus.EventDataManager;
 import com.gzlh.config.ModuleEnum;
-import com.gzlh.config.SystemObject;
 import com.gzlh.config.dto.SerialSetting;
 import com.gzlh.device.capture.event.CaptureEvent;
 import com.gzlh.device.electron.job.ElectronReadJob;
-import com.gzlh.device.led.event.LedDefaultEvent;
-import com.gzlh.device.led.utils.LedOptions;
 import com.gzlh.device.plc.event.PLCEvent;
 import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
 import com.gzlh.entity.ReqBO;
@@ -34,7 +31,7 @@ public class PLCService {
             return;
         }
         //向总线发送抓拍到车牌事件
-        SerialSetting.PlcDTO.StatusDTO status = EventConfig.serialSetting.getPlc().getStatus();
+        SerialSetting.PlcDTO.StatusDTO status = SysConfig.serialSetting.getPlc().getStatus();
 //        将plc设备信息的字符串反转
         plcInfo = new StringBuffer(plcInfo).reverse().toString();
         String newStatus = null;
@@ -74,7 +71,7 @@ public class PLCService {
 
     public void radarTrigger() throws InterruptedException {
         EventBus eventBus = SpringUtil.getBean(EventBus.class);
-        SerialSetting.PlcDTO.StatusDTO status = EventConfig.serialSetting.getPlc().getStatus();
+        SerialSetting.PlcDTO.StatusDTO status = SysConfig.serialSetting.getPlc().getStatus();
         //读取电子车牌
         if(DeviceCache.getTime(status.getFRedPoint())==null){
             ElectronReadJob job=   new ElectronReadJob("4002FEC0");
@@ -119,7 +116,7 @@ public class PLCService {
     public void upTrigger() throws InterruptedException {
         EventBus eventBus = SpringUtil.getBean(EventBus.class);
         //向总线发送抓拍到车牌事件
-        SerialSetting.PlcDTO.StatusDTO status = EventConfig.serialSetting.getPlc().getStatus();
+        SerialSetting.PlcDTO.StatusDTO status = SysConfig.serialSetting.getPlc().getStatus();
 //        将plc设备信息的字符串反转
         String newStatus = null;
         String downPoint = null;

+ 11 - 9
src/main/java/com/gzlh/device/weighbridge/client/WeighbridgeNettyConfig.java

@@ -1,6 +1,7 @@
 package com.gzlh.device.weighbridge.client;
 
-import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
+import com.gzlh.bus.SysConfig;
+import com.gzlh.config.dto.SerialSetting;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.nio.NioEventLoopGroup;
@@ -13,15 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import javax.annotation.Resource;
 import java.util.concurrent.TimeUnit;
 
 @Configuration
 @Slf4j
 public class WeighbridgeNettyConfig {
 
-    @Resource
-    private WeighbridgePropertiesConfig propertiesConfig;
 
     @Autowired
     private WeighbridgeClientHandler nettyClientHandler;
@@ -30,9 +28,11 @@ public class WeighbridgeNettyConfig {
 
     @Bean("weighbridge")
     public Bootstrap bootstrap() {
-        String host = propertiesConfig.getHost();
-        int port = propertiesConfig.getPort();
-        if (propertiesConfig.isEnable()) {
+        SerialSetting serialSetting = SysConfig.serialSetting;
+        String host = serialSetting.getHost();
+        SerialSetting.Weighbridge weighbridge = serialSetting.getWeighbridge();
+        int port = weighbridge.getPort();
+        if (weighbridge.getEnable()) {
             log.info("初始化 地磅 ======================:{},{}", host, port);
         }
         EventLoopGroup group = new NioEventLoopGroup();
@@ -62,8 +62,10 @@ public class WeighbridgeNettyConfig {
     }
 
     public void connect() {
-        String host = propertiesConfig.getHost();
-        int port = propertiesConfig.getPort();
+        SerialSetting serialSetting = SysConfig.serialSetting;
+        String host = serialSetting.getHost();
+        SerialSetting.Weighbridge weighbridge = serialSetting.getWeighbridge();
+        int port = weighbridge.getPort();
         ChannelFuture future = bootstrap().connect();
         future.addListener((ChannelFutureListener) future1 -> {
             if (future1.isSuccess()) {

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

@@ -2,14 +2,13 @@ package com.gzlh.device.weighbridge.handler.impl;
 
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.extra.spring.SpringUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.bus.EventDataManager;
 import com.gzlh.config.ApplicationConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.bus.EventBus;
 import com.gzlh.config.SystemObject;
 import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.device.led.factory.LedFactory;
 import com.gzlh.device.led.utils.LedOptions;
 import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
 import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
@@ -60,7 +59,7 @@ public class CommonWeighbridgeHandler {
         public void run() {
             int averaWeight = 0;
             String deviceStatus= null;
-            SerialSetting.PlcDTO.StatusDTO status = EventConfig.serialSetting.getPlc().getStatus();
+            SerialSetting.PlcDTO.StatusDTO status = SysConfig.serialSetting.getPlc().getStatus();
             EventBus eventBus = SpringUtil.getBean(EventBus.class);
             while (time > 0) {
                 time = time - 1000;
@@ -74,10 +73,10 @@ public class CommonWeighbridgeHandler {
                 if (fRed.equals("1")||bRed.equals("1")||radar.equals("1")){
                     DeviceCache.setInterrupt(true);
                     LedOptions options = new LedOptions().setLine("03").setColor("04").setShowType("00");
-                    SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
+                    SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
                             .sendMsg("车辆位置异常或异常跟车",options);
 
-                    SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
+                    SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
                             .sendMsg("请完全退出通道后再次进入通道",options.setLine("04").setColor("01"));
 //                    eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.POSITION_ERROR);
                     return;

+ 0 - 330
src/main/java/com/gzlh/startup/ReaderJavaWDemo.java

@@ -1,330 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.gzlh.startup;
-
-
- import java.net.DatagramSocket; 
-import java.net.InetAddress;
- import java.net.InetSocketAddress; 
- import java.net.SocketAddress; 
- import java.nio.ByteBuffer; 
- import java.nio.CharBuffer; 
- import java.nio.channels.DatagramChannel; 
- import java.nio.channels.SelectionKey; 
- import java.nio.channels.Selector; 
- import java.nio.charset.Charset; 
- import java.util.Iterator; 
- import java.util.Set; 
-
-
-/**
-  * @author 徐辛波(sinpo.xu@hotmail.com) Oct 19, 2008
-  */
- public class ReaderJavaWDemo extends Thread {
- 	public void run() {
- 		//TestOri();//测试原始的
-            
-            TestOrm();//
-            
- 	}
-      
-        public static void Bcd2AscEx(byte asc[], byte bcd[], int len)
-        {
-            int	i, j;
-            int k;
-
-            j = (len + len%2) / 2;
-            k = 3*j;
-            for(i=0; i<j; i++)
-            {
-                    asc[3*i]	= (byte)((bcd[i] >> 4) & 0x0f);
-                    asc[3*i+1]	= (byte)(bcd[i] & 0x0f);
-                    asc[3*i+2]	= 0x20;
-            }
-            for(i=0; i<k; i++)
-            {
-                    if ( (i+1) % 3 == 0 )
-                    {
-                            continue;
-                    }
-                    if( asc[i] > 0x09)
-                    {
-                            asc[i]	= (byte)(0x41 + asc[i] - 0x0a);
-                    }
-                    else	
-                    {
-                            asc[i]	+= 0x30;
-                    }
-            }
-
-            asc[k] = 0;
-            
-        }
-        
-        public static void Bcd2AscEy(char asc[], char bcd[], int len)
-        {
-            int	i, j;
-            int k;
-
-            j = (len + len%2) / 2;
-            k = 3*j;
-            for(i=0; i<j; i++)
-            {
-                    asc[3*i]	= (char)((bcd[i] >> 4) & 0x0f);
-                    asc[3*i+1]	= (char)(bcd[i] & 0x0f);
-                    asc[3*i+2]	= 0x20;
-            }
-            for(i=0; i<k; i++)
-            {
-                    if ( (i+1) % 3 == 0 )
-                    {
-                            continue;
-                    }
-                    if( asc[i] > 0x09)
-                    {
-                            asc[i]	= (char)(0x41 + asc[i] - 0x0a);
-                    }
-                    else	
-                    {
-                            asc[i]	+= 0x30;
-                    }
-            }
-
-            asc[k] = 0;
-            
-        }
-        
-        public static void TestOri(){
-            
-           Selector selector = null;
- 		try {
- 			DatagramChannel channel = DatagramChannel.open();
- 			DatagramSocket socket = channel.socket();
- 			channel.configureBlocking(false);
- 			socket.bind(new InetSocketAddress(5057));
- 
- 			selector = Selector.open();
- 			channel.register(selector, SelectionKey.OP_READ);
- 		} catch (Exception e) {
- 			e.printStackTrace();
- 		}
- 
- 		ByteBuffer byteBuffer = ByteBuffer.allocate(65536);
-                
- 		//while (true) {
-                if (true) {
- 			try {
-                            
-                                byte chTemp[] = new byte[1024];
- 				int eventsCount = selector.select(3000);
- 				if (eventsCount > 0) {
- 					Set selectedKeys = selector.selectedKeys();
- 					Iterator iterator = selectedKeys.iterator();
- 					while (iterator.hasNext()) {
- 						SelectionKey sk = (SelectionKey) iterator.next();
- 						iterator.remove();
- 						if (sk.isReadable()) {
- 							DatagramChannel datagramChannel = (DatagramChannel) sk
- 									.channel();
- 							SocketAddress sa = datagramChannel
- 									.receive(byteBuffer);
- 							byteBuffer.flip();
- 
- 							// 测试:通过将收到的ByteBuffer首先通过缺省的编码解码成CharBuffer 再输出马储油平台
- 							//CharBuffer charBuffer = Charset.defaultCharset().decode(byteBuffer);
-                                                        //ByteBuffer btBuffer = Charset.defaultCharset().decode(byteBuffer);
-                                                        
-                                                        Bcd2AscEx(chTemp, byteBuffer.array(), 8);
- 							//System.out.println("receive message:"+ charBuffer.toString());
-                                                        System.out.println("receive message:"+ String.valueOf(chTemp));
-                                                        
- 							byteBuffer.clear();
- 
- 							//String echo = "This is the reply message from 服务器。";
- 							//ByteBuffer buffer = Charset.defaultCharset()
- 							//		.encode(echo);
-                                                        //chTemp = new char[2];
-                                                        //chTemp[0] = 0x56;
-                                                        //chTemp[1] = 0x78;
-                                                        
-                                                        //ByteBuffer buffer = ByteBuffer.allocate(chTemp.length);
-                                                        //Charset cs = Charset.forName ("UTF-8");
-                                                        //CharBuffer cb = CharBuffer.allocate (chTemp.length);
-                                                        //cb.put (chTemp);
-                                                        //cb.flip ();
-                                                        
-                                                        //ByteBuffer bb = cs.encode (cb);
-
-                                                        
-                                                        
-                                                        //datagramChannel.send(bb, sa);
- 							//datagramChannel.write(buffer);
- 						}
- 					}
- 				}
- 			} catch (Exception e) {
- 				e.printStackTrace();
- 			}
- 		}
- 
-                
-                System.out.println("Program end!\n");
-                 
-        }
-        
-        
-        
-        //连接读写器测试
-        public static void TestOrm(){
-            
-           Selector selector = null;
- 		try {
- 			DatagramChannel channel = DatagramChannel.open();
- 			DatagramSocket socket = channel.socket();
- 			channel.configureBlocking(false);
- 			socket.bind(new InetSocketAddress(5057));
- 
- 			selector = Selector.open();
- 			channel.register(selector, SelectionKey.OP_READ);
-                        
-                        
-                        
-                        //byte[] chTemp = new byte[] {0x40, 0x03, 0x0F, 0x00, (byte)0xAE};
-                        //byte[] chTemp = new byte[] {0x40, 0x02, 0x02, (byte)0xBC};
-                        byte[] chTemp = new byte[] {0x40, 0x02, 0x06, (byte)0xB8};
-                        //chTemp[0] = 0x40;
-                        //chTemp[1] = 0x03;
-                        //chTemp[2] = 0x0F;
-                        //chTemp[3] = 0x00;
-                        //chTemp[4] = (byte)0xAE;
-
-                        
-            ByteBuffer bb = ByteBuffer.allocate (chTemp.length);
-            bb.put (chTemp);
-                        bb.flip ();
-            
-
-
-
-                        
-                        
-                        
-                        //DatagramChannel ch= DatagramChannel.open();
- 			//DatagramSocket so = ch.socket();
-                        //ch.configureBlocking(false);
-                        //SocketAddress sa = so.getLocalSocketAddress();
-                        byte[] bs = new byte[] { (byte) 192, (byte) 168, 1, (byte) 254 };
-                        InetAddress address=InetAddress.getByAddress(bs);
-                        SocketAddress sa = new InetSocketAddress(address, 4002);
-                        
-                     int i=   channel.send(bb, sa);
-            System.out.println("i------------->"+i);
-                        
-                        
- 		} catch (Exception e) {
- 			e.printStackTrace();
- 		}
- 
-                
-                
- 		ByteBuffer byteBuffer = ByteBuffer.allocate(65535);
-                
- 		//while (true) {
-                if (true) {
- 			try {
-                                int iRecvLen = 0;
-                                byte[] chTemp = new byte[4096];
- 				int eventsCount = selector.select(5000);
- 				if (eventsCount > 0) {
- 					Set selectedKeys = selector.selectedKeys();
- 					Iterator iterator = selectedKeys.iterator();
- 					while (iterator.hasNext()) {
- 						SelectionKey sk = (SelectionKey) iterator.next();
- 						iterator.remove();
- 						if (sk.isReadable()) {
-                                                    
- 							DatagramChannel datagramChannel = (DatagramChannel) sk
- 									.channel();
-                                                        byteBuffer.clear();
- 							SocketAddress sa = datagramChannel.receive(byteBuffer);
- 							byteBuffer.flip();
- 
-                                                        
-                                                        iRecvLen = byteBuffer.limit();
- 							// 测试:通过将收到的ByteBuffer首先通过缺省的编码解码成CharBuffer 再输出马储油平台
- 							CharBuffer charBuffer = Charset.forName("UTF-8").decode(byteBuffer);
-                                                        Bcd2AscEx(chTemp, byteBuffer.array(), iRecvLen*2);
- 							//System.out.println("receive message:"+ charBuffer.toString());
-                                                        String s = new String(chTemp, "UTF-8");
-                                                        System.out.println("receive message["+ iRecvLen +"]: "+ s.trim());
-                                                        
- 							byteBuffer.clear();
- 
- 							//String echo = "This is the reply message from 服务器。";
- 							//ByteBuffer buffer = Charset.defaultCharset()
- 							//		.encode(echo);
-                                                        //chTemp = new char[2];
-                                                        //chTemp[0] = 0x56;
-                                                        //chTemp[1] = 0x78;
-                                                        
-                                                        //ByteBuffer buffer = ByteBuffer.allocate(chTemp.length);
-                                                        //Charset cs = Charset.forName ("UTF-8");
-                                                        //CharBuffer cb = CharBuffer.allocate (chTemp.length);
-                                                        //cb.put (chTemp);
-                                                        //cb.flip ();
-                                                        
-                                                        //ByteBuffer bb = cs.encode (cb);
-
-                                                        
-                                                        //要发送就下面打开
-                                                        //datagramChannel.send(bb, sa);
- 							//datagramChannel.write(buffer);
- 						}
- 					}
- 				}
- 			} catch (Exception e) {
- 				e.printStackTrace();
- 			}
- 		}
- 
-                
-                System.out.println("TestOrm end!\n");
-                 
-        }
-        
-        
-        
-        // char转byte
-
-        private byte[] getBytes (char[] chars) {
-        Charset cs = Charset.forName ("UTF-8");
-        CharBuffer cb = CharBuffer.allocate (chars.length);
-        cb.put (chars);
-                        cb.flip ();
-        ByteBuffer bb = cs.encode (cb);
-
-        return bb.array();
-
-        }
-
-        // byte转char
-
-        private char[] getChars (byte[] bytes) {
-            Charset cs = Charset.forName ("UTF-8");
-            ByteBuffer bb = ByteBuffer.allocate (bytes.length);
-            bb.put (bytes);
-                        bb.flip ();
-            CharBuffer cb = cs.decode (bb);
-
-        return cb.array();
-}
-
-
-
-        public static void main(String[] args) {
- 		new ReaderJavaWDemo().start();
- 	}
-        
- }

+ 8 - 19
src/main/java/com/gzlh/startup/StartupRunner.java

@@ -1,39 +1,28 @@
 package com.gzlh.startup;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.extra.spring.SpringUtil;
-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.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
+import com.gzlh.config.dto.CaputreSetting;
 import com.gzlh.config.dto.SerialSetting;
-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.electron.client.ElectronNettyConfig;
 import com.gzlh.device.led.client.LedNettyConfig;
-import com.gzlh.device.infrared.client.RedNettyConfig;
 import com.gzlh.device.plc.client.PlcNettyConfig;
 import com.gzlh.device.plc.event.PLCEvent;
 import com.gzlh.device.weighbridge.client.WeighbridgeNettyConfig;
-import com.gzlh.utils.DeviceCache;
-import com.gzlh.utils.WordHandlerUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
-import org.springframework.core.env.PropertyResolver;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.util.Properties;
 
 @Component
 @Slf4j
@@ -61,7 +50,7 @@ public class StartupRunner implements CommandLineRunner {
     private HCNetSDK hcNetSDK;
     @Override
     public void run(String... args) throws Exception {
-        SerialSetting serialSetting=EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         if (serialSetting.getWeighbridge().getEnable()) {
             ThreadUtil.execute(() -> weighbridgeNettyConfig.connect());
         }
@@ -77,11 +66,11 @@ public class StartupRunner implements CommandLineRunner {
         if (backgroundPropertiesConfig.isEnable()) {
             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);
+        CaputreSetting caputreSetting=SysConfig.caputreSetting;
+        if (caputreSetting.isEnable()){
+            short port= (short) caputreSetting.getPort();
+            String ip=caputreSetting.getHost();
+            int userId = hkUtils.Login_V40(ip, port, caputreSetting.getUsername(), caputreSetting.getPwd(), hcNetSDK);
             if (userId!=-1){
                 log.info("登录海康抓拍设备:{},{}",ip,userId);
                 hkUtils.SetAlarm(hcNetSDK,userId);

+ 7 - 8
src/main/java/com/gzlh/utils/DeviceCache.java

@@ -2,16 +2,15 @@ package com.gzlh.utils;
 
 
 import cn.hutool.json.JSONUtil;
-import com.gzlh.bus.EventConfig;
+import com.gzlh.bus.SysConfig;
 import com.gzlh.config.ModuleEnum;
 import com.gzlh.config.SystemObject;
+import com.gzlh.config.dto.CaputreSetting;
 import com.gzlh.config.dto.SerialSetting;
-import com.gzlh.device.capture.brand.CaptureBrandType;
 import com.gzlh.device.electron.brand.ElectronBrandType;
 import com.gzlh.device.led.brand.LedBrandType;
 import com.gzlh.device.weighbridge.brand.WeighbridgeBrandType;
 import com.gzlh.entity.DeviceStatus;
-import org.springframework.beans.BeanUtils;
 import org.springframework.util.StringUtils;
 
 import java.util.Date;
@@ -54,13 +53,13 @@ public class DeviceCache {
     }
 
     public static void deviceStatusInit(){
-        SerialSetting serialSetting= EventConfig.serialSetting;
+        SerialSetting serialSetting= SysConfig.serialSetting;
         deviceStatus.setChannelCode(SystemObject.applicationConfig.getChannelCode());
         deviceStatus.setChannelName(SystemObject.applicationConfig.getChannelName());
-
-        DeviceStatus.Device capture =  new DeviceStatus.Device(SystemObject.capturePropertiesConfig.getHost(),
-                SystemObject.capturePropertiesConfig.getPort(),
-                LedBrandType.getBrandByCode(SystemObject.capturePropertiesConfig.getBrand()),
+        CaputreSetting caputreSetting=SysConfig.caputreSetting;
+        DeviceStatus.Device capture =  new DeviceStatus.Device(caputreSetting.getHost(),
+                caputreSetting.getPort(),
+                LedBrandType.getBrandByCode(caputreSetting.getBrand()),
                 ModuleEnum.CAPTURE_MODULE.getModuleEn());
         deviceStatus.getDeviceList().add(capture);
 

+ 0 - 37
src/main/resources/application.yml

@@ -5,43 +5,6 @@ application:
   channel-name: "A1地磅通道"
   channel-code: "A1001"
   channel-type: 0
-#地磅配置
-weighbridge:
-  host: 127.0.0.1
-  port: 4005
-  brand: 3001
-  min-kg: 1000
-  enable: true
-#LED配置
-led:
-  host: 192.168.1.254
-  port: 4003
-  brand: 2000
-  enable: true
- #红外
-red:
-    host: 192.168.1.254
-    port: 4004
-    brand: 2000
-    enable: false
-#道闸
-gate:
-  brand: 4000
-  gate-port: 8131
-
-camera:
-  host: 127.0.0.1
-  brand: 1000
-  port: 8888
-  enable: false
-
-capture:
-  brand: 5000
-  host: 192.168.1.11
-  port: 8000
-  username: admin
-  pwd: ap123456
-  enable: true
 
 background:
   host: 192.168.1.3