瀏覽代碼

Merge branch 'dev' of http://192.168.1.43:3000/v2/zd-parents into dev

chaiyunlong 3 年之前
父節點
當前提交
cd885a65fe
共有 100 個文件被更改,包括 2523 次插入1469 次删除
  1. 1 1
      ArcFace64.dat
  2. 15 14
      pom.xml
  3. 0 44
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/netty/feign/RemoteNettyService.java
  4. 0 36
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/netty/feign/fallback/RemoteNettyFallbackFactory.java
  5. 197 0
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/domain/entity/HardwareRfid.java
  6. 149 0
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/domain/vo/HardwareRfidVo.java
  7. 44 0
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/feign/RemoteRfidService.java
  8. 36 0
      zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/feign/fallback/RemoteRfidFallbackFactory.java
  9. 1 1
      zd-api/zd-algorithm-api/src/main/resources/META-INF/spring.factories
  10. 1 1
      zd-api/zd-base-api/src/main/java/com/zd/base/api/feign/RemoteFileService.java
  11. 2 2
      zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteLaboratoryFallbackFactory.java
  12. 2 11
      zd-auth/pom.xml
  13. 2 2
      zd-auth/src/main/java/com/zd/auth/ZdAuthApplication.java
  14. 0 74
      zd-auth/src/main/resources/logback.xml
  15. 1 1
      zd-common/common-core/src/main/java/com/zd/common/core/annotation/EnableRyFeignClients.java
  16. 10 8
      zd-common/common-core/src/main/java/com/zd/common/core/aspect/PreAuthorizeAspect.java
  17. 64 0
      zd-common/common-core/src/main/java/com/zd/common/core/aspect/ResponseAdvice.java
  18. 1 1
      zd-common/common-core/src/main/java/com/zd/common/core/exception/GlobalExceptionHandler.java
  19. 5 1
      zd-common/common-core/src/main/java/com/zd/common/core/launch/StartEventListener.java
  20. 2 6
      zd-common/common-core/src/main/java/com/zd/common/core/launch/ZdStartApplication.java
  21. 8 2
      zd-common/common-core/src/main/java/com/zd/common/core/utils/ExcelUtil.java
  22. 54 9
      zd-common/common-core/src/main/java/com/zd/common/core/utils/FileConfigUtils.java
  23. 13 0
      zd-common/common-core/src/main/java/com/zd/common/core/web/controller/BaseController.java
  24. 0 7
      zd-gateway/pom.xml
  25. 2 2
      zd-gateway/src/main/java/com/zd/gateway/config/SwaggerProvider.java
  26. 0 16
      zd-gateway/src/main/resources/bootstrap.yml
  27. 5 0
      zd-model/pom.xml
  28. 0 10
      zd-model/src/main/java/com/zd/model/constant/ApplicationConstants.java
  29. 2 0
      zd-model/src/main/java/com/zd/model/constant/MqttConstants.java
  30. 6 0
      zd-model/src/main/java/com/zd/model/domain/per/PerPrefix.java
  31. 194 0
      zd-model/src/main/java/com/zd/model/entity/HardwareRfidDto.java
  32. 12 4
      zd-model/src/main/java/com/zd/model/entity/InventoryTag.java
  33. 29 0
      zd-model/src/main/java/com/zd/model/enums/DeviceOnOffEnum.java
  34. 30 0
      zd-model/src/main/java/com/zd/model/enums/DeviceStatusEnum.java
  35. 8 8
      zd-gateway/src/main/resources/logback.xml
  36. 3 3
      zd-modules/zd-airbottle/pom.xml
  37. 2 2
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/ZdAirbottleApplication.java
  38. 8 0
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpBottleStorageController.java
  39. 3 1
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpQualificationApplyManageController.java
  40. 12 0
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpRfidTagController.java
  41. 3 1
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpUsegasApplyManageController.java
  42. 2 2
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/IAlarmRecordService.java
  43. 5 0
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/IQpBottleStorageService.java
  44. 13 12
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/AlarmRecordServiceImpl.java
  45. 42 1
      zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/QpBottleStorageServiceImpl.java
  46. 0 74
      zd-modules/zd-airbottle/src/main/resources/logback.xml
  47. 1 1
      zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/QpBottleStorageMapper.xml
  48. 5 0
      zd-modules/zd-algorithm/pom.xml
  49. 6 4
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/AlgorithmApplication.java
  50. 1 4
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/conf/SipConfig.java
  51. 0 48
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/utils/IpUtil.java
  52. 0 59
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/NettyStartListener.java
  53. 0 249
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/WuYuanRFIDServiceImpl.java
  54. 0 28
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/IFridService.java
  55. 0 30
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/IService.java
  56. 0 59
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/impl/FridServiceImpl.java
  57. 29 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/base/MyBatisPlusConfig.java
  58. 4 4
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/base/FridConsumer.java
  59. 1 1
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/constant/RfidConstants.java
  60. 96 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/controller/HardwareRfidController.java
  61. 23 15
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/controller/FridDeviceController.java
  62. 9 9
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/enums/ManufacturerTypeEnum.java
  63. 1 1
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/handler/SocketHandler.java
  64. 51 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/init/RfidStartListener.java
  65. 2 2
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/SocketInitializer.java
  66. 3 3
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/SocketServer.java
  67. 19 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/mapper/HardwareRfidMapper.java
  68. 37 37
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/DeJuRFIDClientImpl.java
  69. 61 56
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/DeJuRFIDServerImpl.java
  70. 508 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/sdk/RfidClientImpl.java
  71. 249 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/sdk/WuYuanRFIDServiceImpl.java
  72. 47 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/HardwareRfidService.java
  73. 31 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/IRfidService.java
  74. 3 2
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/ISendService.java
  75. 34 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/IService.java
  76. 103 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/impl/HardwareRfidServiceImpl.java
  77. 57 0
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/impl/RfidServiceImpl.java
  78. 17 22
      zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/impl/SendServiceImpl.java
  79. 0 74
      zd-modules/zd-algorithm/src/main/resources/logback.xml
  80. 56 0
      zd-modules/zd-algorithm/src/main/resources/mapper/rfid/HardwareRfidMapper.xml
  81. 8 12
      zd-modules/zd-base/pom.xml
  82. 2 4
      zd-modules/zd-base/src/main/java/com/zd/base/BaseApplicaion.java
  83. 14 14
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/controller/UploadController.java
  84. 0 75
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/RestApiResponse.java
  85. 0 29
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BaseErrorCode.java
  86. 0 42
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessErrorCode.java
  87. 0 34
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessException.java
  88. 3 5
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/IUploadService.java
  89. 10 36
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/impl/UploadServiceImpl.java
  90. 21 11
      zd-modules/zd-base/src/main/java/com/zd/base/files/file/config/ResourcesConfig.java
  91. 2 0
      zd-modules/zd-base/src/main/java/com/zd/base/files/file/controller/SysFileController.java
  92. 3 20
      zd-modules/zd-base/src/main/java/com/zd/base/files/file/service/LocalSysFileServiceImpl.java
  93. 2 13
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ActionEnter.java
  94. 13 31
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ConfigManager.java
  95. 0 23
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/SpringUtil.java
  96. 2 22
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/contorller/UeditorController.java
  97. 0 8
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionMap.java
  98. 0 8
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionState.java
  99. 0 17
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/AppInfo.java
  100. 0 0
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/FileType.java

文件差異過大導致無法顯示
+ 1 - 1
ArcFace64.dat


+ 15 - 14
pom.xml

@@ -9,8 +9,7 @@
     <version>3.1.0</version>
     <packaging>pom</packaging>
     <name>zd</name>
-    <url>http://www.zd.vip</url>
-    <description>云微服务系统</description>
+    <description>忠德智能监控系统</description>
 
     <modules>
         <module>zd-auth</module>
@@ -23,7 +22,7 @@
     </modules>
 
     <properties>
-        <zd.version>${version}</zd.version>
+        <zd.version>${project.version}</zd.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
@@ -53,22 +52,12 @@
         <face.version>3.0.0.0</face.version>
         <bce.version>0.10.154</bce.version>
         <pinyin4j.version>2.5.1</pinyin4j.version>
-
-        <!-- docker -->
-        <docker.maven.verion>0.40.2</docker.maven.verion>
-        <docker.registry>registry.cn-hangzhou.aliyuncs.com</docker.registry>
-        <docker.registry.username>zd-push@1603061150808095.onaliyun.com</docker.registry.username>
-        <docker.registry.password>zd123456..</docker.registry.password>
-        <nacos.host>192.168.1.88</nacos.host>
-        <redis.host>192.168.1.43</redis.host>
-        <docker.namespace>zd-yun</docker.namespace>
-        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
+        <mybatis-plus.version>3.5.2</mybatis-plus.version>
     </properties>
 
     <!-- 依赖声明 -->
     <dependencyManagement>
         <dependencies>
-
             <!-- SpringCloud 微服务 -->
             <dependency>
                 <groupId>org.springframework.cloud</groupId>
@@ -124,6 +113,18 @@
                 <version>${spring-boot.mybatis}</version>
             </dependency>
 
+            <!-- mybatis-plus 依赖配置 -->
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus-boot-starter</artifactId>
+                <version>${mybatis-plus.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus-annotation</artifactId>
+                <version>${mybatis-plus.version}</version>
+            </dependency>
+
             <!-- Swagger 依赖配置 -->
             <dependency>
                 <groupId>io.swagger</groupId>

+ 0 - 44
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/netty/feign/RemoteNettyService.java

@@ -1,44 +0,0 @@
-package com.zd.algorithm.api.netty.feign;
-
-import com.zd.algorithm.api.netty.feign.fallback.RemoteNettyFallbackFactory;
-import com.zd.model.constant.ApplicationConstants;
-import com.zd.model.domain.R;
-import com.zd.model.entity.RemoteLabHardware;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-/**
- * @author Administrator
- */
-@FeignClient(contextId = "remoteNettyService", value = ApplicationConstants.ALGORITHM_SERVICE, fallbackFactory = RemoteNettyFallbackFactory.class)
-public interface RemoteNettyService {
-    /**
-     * 断开设备连接
-     * @param hardware 设备对象
-     * @return 结果
-     */
-    @ApiOperation("断开设备连接")
-    @PostMapping("/rfid/disconnect")
-    R<Boolean> disconnect(@RequestBody RemoteLabHardware hardware);
-
-    /**
-     * 信道启动FRID扫描监控
-     * @param hardware 设备对象
-     * @return 结果
-     */
-    @ApiOperation("信道启动FRID扫描监控")
-    @PostMapping("/frid/startMonitorChannels")
-    R<Boolean> startMonitorChannels(@RequestBody RemoteLabHardware hardware);
-
-    /**
-     * 开启设备警报
-     * @param hardware 设备参数
-     * @return R
-     */
-    @ApiOperation("开启设备警报")
-    @PostMapping("/frid/alarm")
-    R<Boolean> alarm(@RequestBody RemoteLabHardware hardware);
-
-}

+ 0 - 36
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/netty/feign/fallback/RemoteNettyFallbackFactory.java

@@ -1,36 +0,0 @@
-package com.zd.algorithm.api.netty.feign.fallback;
-
-import com.zd.algorithm.api.netty.feign.RemoteNettyService;
-import com.zd.model.domain.R;
-import com.zd.model.entity.RemoteLabHardware;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RemoteNettyFallbackFactory implements FallbackFactory<RemoteNettyService> {
-
-    private static final Logger log = LoggerFactory.getLogger(RemoteNettyFallbackFactory.class);
-
-    @Override
-    public RemoteNettyService create(Throwable throwable) {
-        log.error("netty服务调用失败:{}", throwable.getMessage());
-        return new RemoteNettyService() {
-            @Override
-            public R<Boolean> disconnect(RemoteLabHardware hardware) {
-                return  R.fail("停止扫描失败:" + throwable.getMessage());
-            }
-
-            @Override
-            public R<Boolean> startMonitorChannels(RemoteLabHardware hardware) {
-                return  R.fail("启动扫描失败:" + throwable.getMessage());
-            }
-
-            @Override
-            public R<Boolean> alarm(RemoteLabHardware hardware) {
-                return  R.fail("开启警报失败:" + throwable.getMessage());
-            }
-        };
-    }
-}

+ 197 - 0
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/domain/entity/HardwareRfid.java

@@ -0,0 +1,197 @@
+package com.zd.algorithm.api.rfid.domain.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @创建人 hzw
+ * @描述 RFID硬件表
+ * @创建时间 2022/11/15
+ */
+@ApiModel(value = "RFID硬件表实体类")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class HardwareRfid implements Serializable {
+    /**
+     * 主键id
+     */
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键id")
+    private Long id;
+
+    /**
+     * 设备名称
+     */
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    /**
+     * 设备类型(7,RFID识别器)
+     */
+    @ApiModelProperty(value = "设备类型(7,RFID识别器)")
+    private Integer deviceType;
+
+    /**
+     * 供应商类型
+     */
+    @ApiModelProperty(value = "供应商类型")
+    private Integer manufacturerType;
+
+    /**
+     * 设备编码
+     */
+    @ApiModelProperty(value = "设备编码")
+    private String hardwareNum;
+
+    /**
+     * ip地址
+     */
+    @ApiModelProperty(value = "ip地址")
+    private String ipAddress;
+
+    /**
+     * 设备端口号
+     */
+    @ApiModelProperty(value = "设备端口号")
+    private Integer port;
+
+    /**
+     * 天线功率
+     */
+    @ApiModelProperty(value = "天线功率")
+    private String uniformPower;
+
+    /**
+     * 设备推送频率,0最大,2最小
+     */
+    @ApiModelProperty(value = "设备推送频率,0最大,2最小")
+    private Integer sessionIndex;
+
+    /**
+     * 1通道、4通道、8通道、16通道
+     */
+    @ApiModelProperty(value = "1通道、4通道、8通道、16通道")
+    private Integer channels;
+
+    /**
+     * 设备启用停用(0是停用,1是启用)
+     */
+    @ApiModelProperty(value = "设备启用停用(0是停用,1是启用)")
+    private Integer onOff;
+
+    /**
+     * 设备状态(0离线,1在线,2异常)
+     */
+    @ApiModelProperty(value = "设备状态(0离线,1在线,2异常)")
+    private Integer deviceStatus;
+
+    /**
+     * 所属实验室id
+     */
+    @ApiModelProperty(value = "所属实验室id")
+    private Long subjectId;
+
+    /**
+     * 部门id
+     */
+    @ApiModelProperty(value = "部门id")
+    private Long deptId;
+
+    /**
+     * 部门名称
+     */
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    /**
+     * 创建人(用于数据权限)
+     */
+    @ApiModelProperty(value = "创建人(用于数据权限)")
+    private Long userId;
+
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 修改人
+     */
+    @ApiModelProperty(value = "修改人")
+    private String updateBy;
+
+    /**
+     * 修改时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private LocalDateTime updateTime;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    private static final long serialVersionUID = 1L;
+
+    public static final String COL_ID = "id";
+
+    public static final String COL_DEVICE_NAME = "device_name";
+
+    public static final String COL_DEVICE_TYPE = "device_type";
+
+    public static final String COL_MANUFACTURER_TYPE = "manufacturer_type";
+
+    public static final String COL_HARDWARE_NUM = "hardware_num";
+
+    public static final String COL_IP_ADDRESS = "ip_address";
+
+    public static final String COL_PORT = "port";
+
+    public static final String COL_UNIFORM_POWER = "uniform_power";
+
+    public static final String COL_SESSION_INDEX = "session_index";
+
+    public static final String COL_CHANNELS = "channels";
+
+    public static final String COL_SWITCH = "switch";
+
+    public static final String COL_DEVICE_STATUS = "device_status";
+
+    public static final String COL_SUBJECT_ID = "subject_id";
+
+    public static final String COL_DEPT_ID = "dept_id";
+
+    public static final String COL_DEPT_NAME = "dept_name";
+
+    public static final String COL_USER_ID = "user_id";
+
+    public static final String COL_CREATE_BY = "create_by";
+
+    public static final String COL_CREATE_TIME = "create_time";
+
+    public static final String COL_UPDATE_BY = "update_by";
+
+    public static final String COL_UPDATE_TIME = "update_time";
+
+    public static final String COL_REMARK = "remark";
+}

+ 149 - 0
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/domain/vo/HardwareRfidVo.java

@@ -0,0 +1,149 @@
+package com.zd.algorithm.api.rfid.domain.vo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @创建人 hzw
+ * @描述
+ * @创建时间 2022/11/15
+ */
+@Data
+public class HardwareRfidVo {
+
+    /**
+     * 主键id
+     */
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键id")
+    private Long id;
+    /**
+     * 设备名称
+     */
+//    @NotBlank(message = "设备名称不能为空!")
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    /**
+     * 设备类型(7,RFID识别器)
+     */
+    @ApiModelProperty(value = "设备类型(7,RFID识别器)")
+    private Integer deviceType;
+
+    /**
+     * 供应商类型
+     */
+    @ApiModelProperty(value = "供应商类型")
+    private Integer manufacturerType;
+
+    /**
+     * 设备编码
+     */
+    @NotBlank(message = "设备编码不能为空!")
+    @ApiModelProperty(value = "设备编码")
+    private String hardwareNum;
+
+    /**
+     * ip地址
+     */
+    @NotBlank(message = "ip地址不能为空!")
+    @ApiModelProperty(value = "ip地址")
+    private String ipAddress;
+
+    /**
+     * 设备端口号
+     */
+    @ApiModelProperty(value = "设备端口号")
+    private Integer port;
+
+    /**
+     * 天线功率
+     */
+    @ApiModelProperty(value = "天线功率")
+    private String uniformPower;
+
+    /**
+     * 设备推送频率,0最大,2最小
+     */
+    @ApiModelProperty(value = "设备推送频率,0最大,2最小")
+    private Integer sessionIndex;
+
+    /**
+     * 1通道、4通道、8通道、16通道
+     */
+    @ApiModelProperty(value = "1通道、4通道、8通道、16通道")
+    private Integer channels;
+
+    /**
+     * 设备启用停用(0是停用,1是启用)
+     */
+    @ApiModelProperty(value = "设备启用停用(0是停用,1是启用)")
+    private Integer onOff;
+
+    /**
+     * 设备状态(0离线,1在线,2异常)
+     */
+    @ApiModelProperty(value = "设备状态(0离线,1在线,2异常)")
+    private Integer deviceStatus;
+
+    /**
+     * 所属实验室id
+     */
+    @NotNull(message = "所属实验室id不能为空!")
+    @ApiModelProperty(value = "所属实验室id")
+    private Long subjectId;
+
+    /**
+     * 部门id
+     */
+    @ApiModelProperty(value = "部门id")
+    private String deptId;
+
+    /**
+     * 部门名称
+     */
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    /**
+     * 创建人(用于数据权限)
+     */
+    @ApiModelProperty(value = "创建人(用于数据权限)")
+    private Long userId;
+
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 查询参数
+     */
+    @ApiModelProperty(value = "查询参数")
+    private String searchValue;
+
+    /**
+     * 当前页
+     */
+    @ApiModelProperty(value = "当前页")
+    private Integer pageNum;
+
+    /**
+     * 每页记录条数
+     */
+    @ApiModelProperty(value = "每页记录条数")
+    private Integer pageSize;
+
+}

+ 44 - 0
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/feign/RemoteRfidService.java

@@ -0,0 +1,44 @@
+package com.zd.algorithm.api.rfid.feign;
+
+import com.zd.algorithm.api.rfid.feign.fallback.RemoteRfidFallbackFactory;
+import com.zd.model.constant.ApplicationConstants;
+import com.zd.model.domain.R;
+import com.zd.model.entity.HardwareRfidDto;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * @author Administrator
+ */
+@FeignClient(contextId = "remoteRfidService", value = ApplicationConstants.ALGORITHM_SERVICE, fallbackFactory = RemoteRfidFallbackFactory.class)
+public interface RemoteRfidService {
+    /**
+     * 断开设备连接
+     * @param hardwareRfidDto 设备对象
+     * @return 结果
+     */
+    @ApiOperation("断开设备连接")
+    @PostMapping("/rfid/disconnect")
+    R<Boolean> disconnect(@RequestBody HardwareRfidDto hardwareRfidDto);
+
+    /**
+     * 信道启动RFID扫描监控
+     * @param hardwareRfidDto 设备对象
+     * @return 结果
+     */
+    @ApiOperation("信道启动RFID扫描监控")
+    @PostMapping("/rfid/startMonitorChannels")
+    R<Boolean> startMonitorChannels(@RequestBody HardwareRfidDto hardwareRfidDto);
+
+    /**
+     * 开启设备警报
+     * @param hardwareRfidDto 设备参数
+     * @return R
+     */
+    @ApiOperation("开启设备警报")
+    @PostMapping("/rfid/alarm")
+    R<Boolean> alarm(@RequestBody HardwareRfidDto hardwareRfidDto);
+
+}

+ 36 - 0
zd-api/zd-algorithm-api/src/main/java/com/zd/algorithm/api/rfid/feign/fallback/RemoteRfidFallbackFactory.java

@@ -0,0 +1,36 @@
+package com.zd.algorithm.api.rfid.feign.fallback;
+
+import com.zd.algorithm.api.rfid.feign.RemoteRfidService;
+import com.zd.model.domain.R;
+import com.zd.model.entity.HardwareRfidDto;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RemoteRfidFallbackFactory implements FallbackFactory<RemoteRfidService> {
+
+    private static final Logger log = LoggerFactory.getLogger(RemoteRfidFallbackFactory.class);
+
+    @Override
+    public RemoteRfidService create(Throwable throwable) {
+        log.error("Rfid门禁服务调用失败:{}", throwable.getMessage());
+        return new RemoteRfidService() {
+            @Override
+            public R<Boolean> disconnect(HardwareRfidDto hardwareRfidDto) {
+                return  R.fail("停止扫描失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public R<Boolean> startMonitorChannels(HardwareRfidDto hardwareRfidDto) {
+                return  R.fail("启动扫描失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public R<Boolean> alarm(HardwareRfidDto hardwareRfidDto) {
+                return  R.fail("开启警报失败:" + throwable.getMessage());
+            }
+        };
+    }
+}

+ 1 - 1
zd-api/zd-algorithm-api/src/main/resources/META-INF/spring.factories

@@ -3,7 +3,7 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   com.zd.algorithm.api.camera.feign.fallback.RemoteCameraFallBackFactory,\
   com.zd.algorithm.api.face.feign.fallback.RemoteFaceFallbackFactory,\
   com.zd.algorithm.api.forward.feign.fallback.RemoteForwardFallbackFactory,\
-  com.zd.algorithm.api.netty.feign.fallback.RemoteNettyFallbackFactory,\
+  com.zd.algorithm.api.rfid.feign.fallback.RemoteRfidFallbackFactory,\
   com.zd.algorithm.api.smartlock.feign.fallback.RemoteSmartlockFallbackFactory,\
   com.zd.algorithm.api.speaker.feign.fallback.RemoteSpeakFallbackFactory
 

+ 1 - 1
zd-api/zd-base-api/src/main/java/com/zd/base/api/feign/RemoteFileService.java

@@ -24,7 +24,7 @@ public interface RemoteFileService {
      * @param file 文件信息
      * @return 结果
      */
-    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    @PostMapping(value = "/file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
 
 

+ 2 - 2
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteLaboratoryFallbackFactory.java

@@ -408,7 +408,7 @@ public class RemoteLaboratoryFallbackFactory implements FallbackFactory<RemoteLa
 
             @Override
             public R<List<RemoteLabHardware>> listStart() {
-                return R.fail("查询FRID设备失败:" + cause.getMessage());
+                return R.fail("查询RFID设备失败:" + cause.getMessage());
             }
 
             @Override
@@ -418,7 +418,7 @@ public class RemoteLaboratoryFallbackFactory implements FallbackFactory<RemoteLa
 
             @Override
             public R<Integer> update(@RequestParam("operate") HardwareOperate operate, String ipAddress) {
-                return R.fail("FRID设备状态修改失败:" + cause.getMessage());
+                return R.fail("RFID设备状态修改失败:" + cause.getMessage());
             }
 
         };

+ 2 - 11
zd-auth/pom.xml

@@ -25,10 +25,10 @@
         </dependency>
 
         <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
+        <!--<dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
+        </dependency>-->
 
         <!-- zd Common Security-->
         <dependency>
@@ -89,15 +89,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
 </project>

+ 2 - 2
zd-auth/src/main/java/com/zd/auth/ZdAuthApplication.java

@@ -1,6 +1,6 @@
 package com.zd.auth;
 
-import com.zd.common.core.annotation.EnableRyFeignClients;
+import com.zd.common.core.annotation.EnableZdFeignClients;
 import com.zd.common.core.launch.ZdStartApplication;
 import com.zd.model.constant.ApplicationConstants;
 import com.zd.model.constant.BaseConstants;
@@ -13,7 +13,7 @@ import org.springframework.context.annotation.ComponentScan;
  *
  * @author zd
  */
-@EnableRyFeignClients
+@EnableZdFeignClients
 @ComponentScan(basePackages = BaseConstants.BASE_PACKAGE)
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 public class ZdAuthApplication {

+ 0 - 74
zd-auth/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-	<property name="log.path" value="logs/zd-auth" />
-   <!-- 日志输出格式 -->
-	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
-
-    <!-- 控制台输出 -->
-	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-	</appender>
-
-    <!-- 系统日志输出 -->
-	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-			<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
-		</rollingPolicy>
-		<encoder>
-			<pattern>${log.pattern}</pattern>
-		</encoder>
-		<filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-	</appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-			<!-- 日志最大的历史 60天 -->
-			<maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-			<!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-			<!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-	<logger name="com.zd" level="info" />
-	<!-- Spring日志级别控制  -->
-	<logger name="org.springframework" level="warn" />
-
-	<root level="info">
-		<appender-ref ref="console" />
-	</root>
-
-	<!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info" />
-        <appender-ref ref="file_error" />
-    </root>
-</configuration>

+ 1 - 1
zd-common/common-core/src/main/java/com/zd/common/core/annotation/EnableRyFeignClients.java

@@ -13,7 +13,7 @@ import java.lang.annotation.*;
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @EnableFeignClients
-public @interface EnableRyFeignClients {
+public @interface EnableZdFeignClients {
     String[] value() default {};
 
     String[] basePackages() default {"com.zd"};

+ 10 - 8
zd-common/common-core/src/main/java/com/zd/common/core/aspect/PreAuthorizeAspect.java

@@ -1,6 +1,7 @@
 package com.zd.common.core.aspect;
 
 import com.zd.common.core.annotation.PreAuthorize;
+import com.zd.common.core.exception.PreAuthorizeException;
 import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.model.entity.LoginUser;
@@ -14,8 +15,10 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.PatternMatchUtils;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.util.Collection;
+import java.util.Set;
 
 /**
  * 自定义权限实现
@@ -52,38 +55,37 @@ public class PreAuthorizeAspect {
         if (annotation == null) {
             return point.proceed();
         }
-
-
+        //权限验证
         if (StringUtils.isNotEmpty(annotation.hasPermi())) {
             if (hasPermi(annotation.hasPermi())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         } else if (StringUtils.isNotEmpty(annotation.lacksPermi())) {
             if (lacksPermi(annotation.lacksPermi())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         } else if (ARRAY_EMPTY < annotation.hasAnyPermi().length) {
             if (hasAnyPermi(annotation.hasAnyPermi())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         } else if (StringUtils.isNotEmpty(annotation.hasRole())) {
             if (hasRole(annotation.hasRole())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         } else if (StringUtils.isNotEmpty(annotation.lacksRole())) {
             if (lacksRole(annotation.lacksRole())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         } else if (ARRAY_EMPTY < annotation.hasAnyRoles().length) {
             if (hasAnyRoles(annotation.hasAnyRoles())) {
                 return point.proceed();
             }
-            throw new RuntimeException();
+            throw new PreAuthorizeException();
         }
 
         return point.proceed();

+ 64 - 0
zd-common/common-core/src/main/java/com/zd/common/core/aspect/ResponseAdvice.java

@@ -0,0 +1,64 @@
+package com.zd.common.core.aspect;
+
+import com.zd.model.domain.AjaxResult;
+import com.zd.model.domain.R;
+import com.zd.model.domain.ResultData;
+import com.zd.model.page.TableDataInfo;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
+import org.springframework.core.MethodParameter;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
+
+import java.util.Map;
+
+/**
+ * 返回值增强器
+ *
+ * @Author: zhoupan
+ * @Date: 2021/09/09/10:34
+ * @Description:
+ */
+@RestControllerAdvice
+@ConditionalOnMissingClass("ZdGatewayApplication")
+public class ResponseAdvice implements ResponseBodyAdvice<Object> {
+
+    static AntPathMatcher antPathMatcher = new AntPathMatcher();
+
+    @Override
+    public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
+        return true;
+    }
+
+    @Override
+    public Object beforeBodyWrite(Object o,
+                                  MethodParameter methodParameter, MediaType mediaType,
+                                  Class<? extends HttpMessageConverter<?>> aClass,
+                                  ServerHttpRequest serverHttpRequest,
+                                  ServerHttpResponse serverHttpResponse) {
+
+
+        if(o instanceof TableDataInfo || o instanceof AjaxResult || o instanceof ResultData
+                || o instanceof R || o instanceof String){
+            return o;
+        }
+
+        //swagger 不包装
+        boolean match = antPathMatcher.match("/**/api-docs", serverHttpRequest.getURI().getPath());
+        boolean match1 = antPathMatcher.match("/swagger-resources/**", serverHttpRequest.getURI().getPath());
+        boolean match2 = antPathMatcher.match("/actuator/health/**", serverHttpRequest.getURI().getPath());
+        boolean match3 = antPathMatcher.match("/actuator/**", serverHttpRequest.getURI().getPath());
+        if (match || match1 || match2 || match3) {
+            return o;
+        }
+
+        if (methodParameter.getMethod().getName().equals("error")) {
+            return ResultData.fail(((Map<String, Object>) o).get("error").toString());
+        }
+        return ResultData.success(o);
+    }
+}

+ 1 - 1
zd-common/common-core/src/main/java/com/zd/common/core/exception/GlobalExceptionHandler.java

@@ -32,7 +32,7 @@ public class GlobalExceptionHandler {
     public AjaxResult handlePreAuthorizeException(PreAuthorizeException e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
-        return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
+        return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员");
     }
 
     /**

+ 5 - 1
zd-common/common-core/src/main/java/com/zd/common/core/launch/StartEventListener.java

@@ -25,6 +25,10 @@ public class StartEventListener {
         String appName = environment.getProperty("spring.application.name").toUpperCase();
         int localPort = event.getWebServer().getPort();
         String profile = StringUtils.arrayToCommaDelimitedString(environment.getActiveProfiles());
-        log.info("============ [{}]---服务启动完成,当前使用的端口:[{}],环境变量:[{}] ============", appName, localPort, profile);
+        log.info("============ [{}]---服务已启动完成,当前使用的端口号:[{}],环境变量:[{}] ============", appName, localPort, profile);
+        //监听Nacos配置
+        String addr = environment.getProperty("spring.cloud.nacos.config.server-addr");
+        String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
+        log.info("============ Nacos配置,server-addr:[{}],namespace:[{}] ============", addr, namespace);
     }
 }

+ 2 - 6
zd-common/common-core/src/main/java/com/zd/common/core/launch/ZdStartApplication.java

@@ -19,8 +19,6 @@ import java.util.function.Function;
  * @date 10/17/2022
  */
 public class ZdStartApplication {
-    private static final Logger log = LoggerFactory.getLogger(ZdStartApplication.class);
-
     public ZdStartApplication() {}
 
     /**
@@ -67,9 +65,8 @@ public class ZdStartApplication {
             }
             profile = activeProfileList.get(0);
         }
-        String startJarPath = Objects.requireNonNull(ZdStartApplication.class.getResource("/")).getPath().split("!")[0];
-        String activePros = joinFun.apply(activeProfileList.toArray());
-        System.out.printf("============ 启动中,读取到的环境变量:[%s],jar地址:[%s]============ %n", activePros, startJarPath);
+        //String startJarPath = Objects.requireNonNull(ZdStartApplication.class.getResource("/")).getPath().split("!")[0];
+        //String activePros = joinFun.apply(activeProfileList.toArray());
         Properties props = System.getProperties();
         props.setProperty("spring.application.name", appName);
         props.setProperty("spring.profiles.active", profile);
@@ -92,7 +89,6 @@ public class ZdStartApplication {
         props.setProperty("spring.cloud.nacos.config.prefix", appName);
         props.setProperty("spring.cloud.nacos.config.file-extension", "yml");
         props.setProperty("spring.cloud.nacos.config.shared-configs", "application.yml");
-        log.info("============ nacos配置信息 addr:[{}], namespace:[{}] ===========", new Object[]{addr, nameSpace});
         return builder;
     }
 

+ 8 - 2
zd-common/common-core/src/main/java/com/zd/common/core/utils/ExcelUtil.java

@@ -1,12 +1,12 @@
 package com.zd.common.core.utils;
 
+import com.zd.common.core.utils.file.FileTypeUtils;
+import com.zd.common.core.utils.file.ImageUtils;
 import com.zd.common.core.utils.reflect.ReflectUtils;
 import com.zd.model.annotation.Excel;
 import com.zd.model.annotation.Excel.ColumnType;
 import com.zd.model.annotation.Excel.Type;
 import com.zd.model.annotation.Excels;
-import com.zd.common.core.utils.file.FileTypeUtils;
-import com.zd.common.core.utils.file.ImageUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressList;
@@ -16,6 +16,7 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFDataValidation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
@@ -560,6 +561,7 @@ public class ExcelUtil<T> {
      */
     public void setCellVo(Object value, Excel attr, Cell cell) {
         if (ColumnType.STRING == attr.cellType()) {
+
             cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
         } else if (ColumnType.NUMERIC == attr.cellType()) {
             if (StringUtils.isNotNull(value)) {
@@ -945,6 +947,10 @@ public class ExcelUtil<T> {
         } else {
             wb.setSheetName(index, sheetName + index);
         }
+        CellStyle style = wb.createCellStyle();
+        DataFormat format = wb.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        sheet.setDefaultColumnStyle(index, style);
     }
 
     /**

+ 54 - 9
zd-common/common-core/src/main/java/com/zd/common/core/utils/FileConfigUtils.java

@@ -1,26 +1,55 @@
 package com.zd.common.core.utils;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.annotation.Configuration;
-
+import org.springframework.stereotype.Component;
 /**
  * 系统文件配置类
  */
 
-@RefreshScope
-@Configuration
-@ConfigurationProperties(prefix = "sys.file")
+@Component
 public class FileConfigUtils {
-    /**
-     * 文件本地地址
-     */
+
+    /**文件本地地址*/
+    @Value("${sys.file.localUrl}")
     private String localUrl;
+
+    /**文件远程地址*/
+    @Value("${sys.file.remoteUrl}")
+    private String remoteUrl;
+
+    /** 是否代理管理端 */
+    @Value("${sys.file.isAgentAdmin}")
+    private Boolean isAgentAdmin;
+
+    /** 是否代理APP端 */
+    @Value("${sys.file.isAgentApp}")
+    private Boolean isAgentApp;
+
+
     /**
-     * 文件远程地址
+     * 获取管理端文件域名
+     * @return
      */
-    private String remoteUrl;
+    public String getFileDomainAdmin() {
+        if (isAgentAdmin == null || !isAgentAdmin) {
+            return localUrl;
+        }
+        return remoteUrl;
+    }
 
+    /**
+     * 获取App端文件域名
+     * @return
+     */
+    public String getFileDomainApp() {
+        if (isAgentApp == null || !isAgentApp) {
+            return localUrl;
+        }
+        return remoteUrl;
+    }
 
     public String getLocalUrl() {
         return localUrl;
@@ -37,4 +66,20 @@ public class FileConfigUtils {
     public void setRemoteUrl(String remoteUrl) {
         this.remoteUrl = remoteUrl;
     }
+
+    public Boolean getAgentAdmin() {
+        return isAgentAdmin;
+    }
+
+    public Boolean getAgentApp() {
+        return isAgentApp;
+    }
+
+    public void setAgentAdmin(Boolean agentAdmin) {
+        isAgentAdmin = agentAdmin;
+    }
+
+    public void setAgentApp(Boolean agentApp) {
+        isAgentApp = agentApp;
+    }
 }

+ 13 - 0
zd-common/common-core/src/main/java/com/zd/common/core/web/controller/BaseController.java

@@ -96,6 +96,19 @@ public class BaseController<T> {
         return rspData;
     }
 
+    /**
+     * 响应请求分页数据 传入总数
+     */
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected TableDataInfo<T> getDataTable(List<? extends T> list,Long total) {
+        TableDataInfo<T> rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setRows(list);
+        rspData.setMsg("查询成功");
+        rspData.setTotal(total);
+        return rspData;
+    }
+
 
     /**
      * 响应请求分页数据

+ 0 - 7
zd-gateway/pom.xml

@@ -85,13 +85,6 @@
             </exclusions>
         </dependency>
 
-        <!-- Swagger -->
-        <!--<dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>${swagger.fox.version}</version>
-        </dependency>-->
-
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-spring-ui</artifactId>

+ 2 - 2
zd-gateway/src/main/java/com/zd/gateway/config/SwaggerProvider.java

@@ -82,8 +82,8 @@ public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigu
     @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {
         /** swagger-ui 地址 */
-        registry.addResourceHandler("/swagger-ui/**")
-                .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
+//        registry.addResourceHandler("/swagger-ui/**")
+//                .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
 
         registry.addResourceHandler(localFilePrefix + "/**")
                 .addResourceLocations("file:" + localFilePath + File.separator);

+ 0 - 16
zd-gateway/src/main/resources/bootstrap.yml

@@ -5,19 +5,3 @@ server:
 spring:
   main:
     allow-bean-definition-overriding: true
-  cloud:
-    sentinel:
-      # 取消控制台懒加载
-      eager: true
-      transport:
-        # 控制台地址
-        dashboard: 127.0.0.1:8718
-      # nacos配置持久化
-      datasource:
-        ds1:
-          nacos:
-            server-addr: ${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}
-            dataId: sentinel-zd-gateway
-            groupId: DEFAULT_GROUP
-            data-type: json
-            rule-type: flow

+ 5 - 0
zd-model/pom.xml

@@ -71,5 +71,10 @@
             <groupId>com.github.pagehelper</groupId>
             <artifactId>pagehelper-spring-boot-starter</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-annotation</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 0 - 10
zd-model/src/main/java/com/zd/model/constant/ApplicationConstants.java

@@ -42,11 +42,6 @@ public interface ApplicationConstants {
     String LABORATORY_SERVICE = "zd-laboratory";
 
     /**
-     * 人脸识别service
-     */
-    String CAMERA_SERVICE="zd-camera";
-
-    /**
      * 化学品模块service
      */
     String CHEMICAL_SERVICE="zd-chemical";
@@ -61,9 +56,4 @@ public interface ApplicationConstants {
      */
     String BOTTLE_SERVICE = "zd-bottle";
 
-    /**
-     * 小程序服务
-     */
-    String APP_SERVICE = "zd-app";
-
 }

+ 2 - 0
zd-model/src/main/java/com/zd/model/constant/MqttConstants.java

@@ -77,4 +77,6 @@ public interface MqttConstants {
 
     // 柜锁操作成功topic  lab/cabinetLock/{subId}/{lockId}
     String TOPIC_CABINET_LOCK = "lab/cabinetLock/";
+
+    String TOPIC_FIRE_DEVICE = "lab/fireDevice/";
 }

+ 6 - 0
zd-model/src/main/java/com/zd/model/domain/per/PerPrefix.java

@@ -758,4 +758,10 @@ public class PerPrefix {
 
     /*****************************智能门锁******************************/
     public static final String SMARTLOCK_OPENDOORAPPLY = "smartlock:openDoorApply:";
+
+
+    /**
+     * 实验室项目:灭火设备
+     */
+    public static final String LABORATORY_FIREDEVICE = "laboratory:firedevice:";
 }

+ 194 - 0
zd-model/src/main/java/com/zd/model/entity/HardwareRfidDto.java

@@ -0,0 +1,194 @@
+package com.zd.model.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @创建人 hzw
+ * @描述 RFID硬件表
+ * @创建时间 2022/11/15
+ */
+@ApiModel(value = "RFID硬件表实体类")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class HardwareRfidDto implements Serializable {
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(value = "主键id")
+    private Long id;
+
+    /**
+     * 设备名称
+     */
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    /**
+     * 设备类型(7,RFID识别器)
+     */
+    @ApiModelProperty(value = "设备类型(7,RFID识别器)")
+    private Integer deviceType;
+
+    /**
+     * 供应商类型
+     */
+    @ApiModelProperty(value = "供应商类型")
+    private Integer manufacturerType;
+
+    /**
+     * 设备编码
+     */
+    @ApiModelProperty(value = "设备编码")
+    private String hardwareNum;
+
+    /**
+     * ip地址
+     */
+    @ApiModelProperty(value = "ip地址")
+    private String ipAddress;
+
+    /**
+     * 设备端口号
+     */
+    @ApiModelProperty(value = "设备端口号")
+    private Integer port;
+
+    /**
+     * 天线功率
+     */
+    @ApiModelProperty(value = "天线功率")
+    private String uniformPower;
+
+    /**
+     * 设备推送频率,0最大,2最小
+     */
+    @ApiModelProperty(value = "设备推送频率,0最大,2最小")
+    private Boolean sessionIndex;
+
+    /**
+     * 1通道、4通道、8通道、16通道
+     */
+    @ApiModelProperty(value = "1通道、4通道、8通道、16通道")
+    private Integer channels;
+
+    /**
+     * 设备启用停用(0是停用,1是启用)
+     */
+    @ApiModelProperty(value = "设备启用停用(0是停用,1是启用)")
+    private Integer onOff;
+
+    /**
+     * 设备状态(0离线,1在线,2异常)
+     */
+    @ApiModelProperty(value = "设备状态(0离线,1在线,2异常)")
+    private Integer deviceStatus;
+
+    /**
+     * 所属实验室id
+     */
+    @ApiModelProperty(value = "所属实验室id")
+    private Long subjectId;
+
+    /**
+     * 部门id
+     */
+    @ApiModelProperty(value = "部门id")
+    private Long deptId;
+
+    /**
+     * 部门名称
+     */
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    /**
+     * 创建人(用于数据权限)
+     */
+    @ApiModelProperty(value = "创建人(用于数据权限)")
+    private Long userId;
+
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 修改人
+     */
+    @ApiModelProperty(value = "修改人")
+    private String updateBy;
+
+    /**
+     * 修改时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private LocalDateTime updateTime;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    private static final long serialVersionUID = 1L;
+
+    public static final String COL_ID = "id";
+
+    public static final String COL_DEVICE_NAME = "device_name";
+
+    public static final String COL_DEVICE_TYPE = "device_type";
+
+    public static final String COL_MANUFACTURER_TYPE = "manufacturer_type";
+
+    public static final String COL_HARDWARE_NUM = "hardware_num";
+
+    public static final String COL_IP_ADDRESS = "ip_address";
+
+    public static final String COL_PORT = "port";
+
+    public static final String COL_UNIFORM_POWER = "uniform_power";
+
+    public static final String COL_SESSION_INDEX = "session_index";
+
+    public static final String COL_CHANNELS = "channels";
+
+    public static final String COL_SWITCH = "switch";
+
+    public static final String COL_DEVICE_STATUS = "device_status";
+
+    public static final String COL_SUBJECT_ID = "subject_id";
+
+    public static final String COL_DEPT_ID = "dept_id";
+
+    public static final String COL_DEPT_NAME = "dept_name";
+
+    public static final String COL_USER_ID = "user_id";
+
+    public static final String COL_CREATE_BY = "create_by";
+
+    public static final String COL_CREATE_TIME = "create_time";
+
+    public static final String COL_UPDATE_BY = "update_by";
+
+    public static final String COL_UPDATE_TIME = "update_time";
+
+    public static final String COL_REMARK = "remark";
+}

+ 12 - 4
zd-model/src/main/java/com/zd/model/entity/InventoryTag.java

@@ -17,9 +17,12 @@ public class InventoryTag {
      */
     private String epc;
     /**
-     * 设备索引,从0开始
+     * 天线设备索引,从0开始
      */
     private int antId;
+    /**
+     * 信号强度
+     */
     private int rssi;
     /**
      * 相位值
@@ -29,11 +32,16 @@ public class InventoryTag {
      * 频点
      */
     private String freq;
-
     /**
      * 设备码
      */
     private String serialNumber;
-
-    private RemoteLabHardware remoteLabHardware;
+    /**
+     * 硬件信息
+     */
+//    private RemoteLabHardware remoteLabHardware;
+    /**
+     * rfid新硬件信息
+     */
+    private HardwareRfidDto hardwareRfidDto;
 }

+ 29 - 0
zd-model/src/main/java/com/zd/model/enums/DeviceOnOffEnum.java

@@ -0,0 +1,29 @@
+package com.zd.model.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Description 公共设备开关枚举类
+ * @Author hzw
+ * @Date 2022/11/17 16:45
+ * @Version 2.0
+ */
+@Getter
+@AllArgsConstructor
+public enum DeviceOnOffEnum {
+    OFF(0, "关闭"),
+    ON(1,"打开");
+
+    private  Integer code;
+    private  String name;
+
+    public static String getValue(Integer code) {
+        for (DeviceOnOffEnum deviceOnOffEnum : values()) {
+            if (deviceOnOffEnum.getCode().equals(code)) {
+                return deviceOnOffEnum.getName();
+            }
+        }
+        return null;
+    }
+}

+ 30 - 0
zd-model/src/main/java/com/zd/model/enums/DeviceStatusEnum.java

@@ -0,0 +1,30 @@
+package com.zd.model.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author hzw
+ * @描述 设备状态枚举类
+ * @创建时间 2022/11/16
+ */
+
+@Getter
+@AllArgsConstructor
+public enum DeviceStatusEnum {
+    OFF_LINE(0, "离线"),
+    ON_LINE(1, "在线"),
+    EXCEPTION(2, "异常");
+
+    private Integer code;
+    private String name;
+
+    public static String getValue(Integer code) {
+        for (DeviceStatusEnum deviceStatusEnum : values()) {
+            if (deviceStatusEnum.getCode().equals(code)) {
+                return deviceStatusEnum.getName();
+            }
+        }
+        return null;
+    }
+}

+ 8 - 8
zd-gateway/src/main/resources/logback.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
     <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-gateway"/>
+    <property name="log.path" value="./zd-logs"/>
     <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
+    <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{20} - [%method,%line] - %msg%n"/>
 
     <!-- 控制台输出 -->
     <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
@@ -14,13 +14,13 @@
 
     <!-- 系统日志输出 -->
     <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
+        <file>${log.path}/${spring.application.name}-info.log</file>
         <!-- 循环政策:基于时间创建日志文件 -->
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${log.path}/${spring.application.name}-info.%d{yyyy-MM-dd}.log</fileNamePattern>
             <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
+            <maxHistory>7</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>
@@ -36,13 +36,13 @@
     </appender>
 
     <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
+        <file>${log.path}/${spring.application.name}-error.log</file>
         <!-- 循环政策:基于时间创建日志文件 -->
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${log.path}/${spring.application.name}-error.%d{yyyy-MM-dd}.log</fileNamePattern>
             <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
+            <maxHistory>7</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>

+ 3 - 3
zd-modules/zd-airbottle/pom.xml

@@ -34,16 +34,16 @@
         </dependency>
 
         <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
+        <!--<dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
         </dependency>
 
-        <!-- SpringBoot Actuator -->
+        &lt;!&ndash; SpringBoot Actuator &ndash;&gt;
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
+        </dependency>-->
 
         <!-- Mysql Connector -->
         <dependency>

+ 2 - 2
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/ZdAirbottleApplication.java

@@ -2,7 +2,7 @@ package com.zd.airbottle;
 
 import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
 import com.zd.common.core.annotation.EnableCustomConfig;
-import com.zd.common.core.annotation.EnableRyFeignClients;
+import com.zd.common.core.annotation.EnableZdFeignClients;
 import com.zd.common.core.launch.ZdStartApplication;
 import com.zd.model.constant.ApplicationConstants;
 import com.zd.model.constant.BaseConstants;
@@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
  * @date 2022/5/9
  */
 @EnableCustomConfig
-@EnableRyFeignClients
+@EnableZdFeignClients
 @SpringBootApplication
 @EnableScheduling
 @NacosPropertySource(dataId = "zd-airbottle", autoRefreshed = true)

+ 8 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpBottleStorageController.java

@@ -239,6 +239,14 @@ public class QpBottleStorageController extends BaseController {
         return ResultData.result(qpBottleStorageService.bottleStorageBinding(qpBottleStorage));
     }
 
+    @ApiOperation(value = "电子标签更换")
+    //@PreAuthorize(hasPermi = "airbottle:storage:edit")
+    @Log(title = "电子标签更换", businessType = BusinessType.UPDATE)
+    @GetMapping(value = "/change")
+    public ResultData<Boolean> change(String newTag, Long id) {
+        return ResultData.result(qpBottleStorageService.bottleStorageChange(newTag,id));
+    }
+
     /***
      * 供应商首页待办事项列表
      * @param storageInfoVo

+ 3 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpQualificationApplyManageController.java

@@ -195,7 +195,9 @@ public class QpQualificationApplyManageController extends BaseController
             if(1 == qpQualificationApply.getLeadAuditStatus()){
             //查询登录用户是否有实验中心审核资格
             QpFlowDetail flowDetail = qpFlowDetailService.selectZgCenterByUserIdIs(sysUser.getUserId());
-            if(flowDetail!=null){
+            if(flowDetail==null){
+                audit=false;
+            }else{
                 audit=true;
             }
         }

+ 12 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpRfidTagController.java

@@ -4,8 +4,10 @@ import com.zd.airbottle.domain.QpRfidTag;
 import com.zd.airbottle.service.IQpRfidTagService;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
+import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.log.BusinessType;
 import com.zd.common.core.utils.ExcelUtil;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
@@ -102,6 +104,16 @@ public class QpRfidTagController extends BaseController<QpRfidTag> {
     @Log(title = "RFID标签管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public ResultData<Boolean> remove(@PathVariable Long[] ids) {
+        StringBuilder strTag = new StringBuilder();
+        for(int i=0;i<ids.length;i++){
+            QpRfidTag tag =  qpRfidTagService.selectQpRfidTagById(ids[i]);
+            if(1==tag.getIsBind()){
+                strTag.append(tag.getTagCode()+",");
+            }
+        }
+        if(StringUtils.isNotNull(strTag)){
+            throw new ServiceException(strTag+"已被绑定");
+        }
         return ResultData.result(qpRfidTagService.deleteQpRfidTagByIds(ids));
     }
 }

+ 3 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/QpUsegasApplyManageController.java

@@ -175,7 +175,9 @@ public class QpUsegasApplyManageController extends BaseController
         if(1 == qpUsegasApply.getLeadAuditStaus()){
             //查询登录用户是否有实验中心审核资格
             QpFlowDetail flowDetail = qpFlowDetailService.selectYqCenterByUserIdIs(sysUser.getUserId());
-            if(flowDetail!=null){
+            if(flowDetail==null){
+                audit=false;
+            }else{
                 audit=true;
             }
         }

+ 2 - 2
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/IAlarmRecordService.java

@@ -3,8 +3,8 @@ package com.zd.airbottle.service;
 import com.zd.airbottle.domain.AlarmRecord;
 import com.zd.airbottle.domain.vo.AlarmRecordVo;
 import com.zd.airbottle.domain.vo.BottleStorageInfoVo;
+import com.zd.model.entity.HardwareRfidDto;
 import com.zd.model.entity.InventoryTag;
-import com.zd.model.entity.RemoteLabHardware;
 
 import java.util.List;
 
@@ -36,7 +36,7 @@ public interface IAlarmRecordService {
      * @param hardware RFID设备信息
      * @return 结果
      */
-    int insertAlarmRecord(AlarmRecord alarmRecord, RemoteLabHardware hardware);
+    int insertAlarmRecord(AlarmRecord alarmRecord, HardwareRfidDto hardwareRfidDto);
 
     /**
      * 获取拓展信息

+ 5 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/IQpBottleStorageService.java

@@ -130,6 +130,11 @@ public interface IQpBottleStorageService {
     int bottleStorageBinding(QpBottleStorage qpBottleStorage);
 
     /**
+     * 更换
+     */
+    int bottleStorageChange(String newTag,Long id);
+
+    /**
      * 根据对象参数查询入库气瓶信息
      * @param bottleStorage 气瓶参数
      * @return 集合对象

+ 13 - 12
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/AlarmRecordServiceImpl.java

@@ -13,7 +13,7 @@ import com.zd.algorithm.api.alarm.entity.AlarmEntrty;
 import com.zd.algorithm.api.alarm.entity.Routes;
 import com.zd.algorithm.api.alarm.entity.SendTypes;
 import com.zd.algorithm.api.alarm.feign.RemoteAlarmService;
-import com.zd.algorithm.api.netty.feign.RemoteNettyService;
+import com.zd.algorithm.api.rfid.feign.RemoteRfidService;
 import com.zd.base.api.feign.RemoteMessageService;
 import com.zd.common.core.redis.RedisService;
 import com.zd.common.core.utils.StringUtils;
@@ -23,6 +23,7 @@ import com.zd.laboratory.api.feign.RemoteSubQueryService;
 import com.zd.model.constant.HttpStatus;
 import com.zd.model.domain.AjaxResult;
 import com.zd.model.domain.R;
+import com.zd.model.entity.HardwareRfidDto;
 import com.zd.model.entity.InventoryTag;
 import com.zd.model.entity.RemoteLabHardware;
 import com.zd.model.entity.TemplateResult;
@@ -64,9 +65,9 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
     @Resource
     private RemoteMessageService messageService;
     @Resource
-    private RemoteNettyService remoteNettyService;
+    private RemoteRfidService remoteRfidService;
 
-    private static final String FRID_CODE = "FRID:";
+    private static final String RFID_CODE = "RFID:";
 
     /**
      * 查询报警记录列表
@@ -92,24 +93,24 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
      * 默认新增气瓶报警记录
      *
      * @param alarmRecord 报警记录
-     * @param hardware RFID 设备数据
+     * @param hardwareRfidDto RFID 设备数据
      * @return 结果
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int insertAlarmRecord(AlarmRecord alarmRecord, RemoteLabHardware hardware) {
+    public int insertAlarmRecord(AlarmRecord alarmRecord, HardwareRfidDto hardwareRfidDto) {
         String electronicTag = alarmRecord.getElectronicTag();
         QpBottleStorageRVo storageRVo = storageService.getByElectronicTag(electronicTag);
         if (storageRVo != null) {
-            if (hardware!=null){
+            if (hardwareRfidDto!=null){
                 //RFID设备报警
-                R<Boolean> alarm = remoteNettyService.alarm(hardware);
+                R<Boolean> alarm = remoteRfidService.alarm(hardwareRfidDto);
                 log.info("==================>{},{}",alarm.getCode(),alarm.getMsg());
             }
             Long id = storageRVo.getId();
-            String key = FRID_CODE + electronicTag + id;
-            String frid = redisService.getCacheObject(key);
-            if (frid != null) {
+            String key = RFID_CODE + electronicTag + id;
+            String rfid = redisService.getCacheObject(key);
+            if (rfid != null) {
                 return 1;
             }
             // 发送报警消息
@@ -121,7 +122,7 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
                     .setProductType(1);
             return alarmRecordMapper.insertAlarmRecord(alarmRecord);
         }else {
-            if (hardware!=null){
+            if (hardwareRfidDto!=null){
                 log.info("==================>{},{}",alarmRecord.getElectronicTag(),"标签无数据");
             }
         }
@@ -245,7 +246,7 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean remoteAdd(InventoryTag tag) {
-        return insertAlarmRecord(new AlarmRecord().setElectronicTag(tag.getEpc()),tag.getRemoteLabHardware())==1;
+        return insertAlarmRecord(new AlarmRecord().setElectronicTag(tag.getEpc()),tag.getHardwareRfidDto())==1;
     }
 
     @Override

+ 42 - 1
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/QpBottleStorageServiceImpl.java

@@ -107,7 +107,10 @@ public class QpBottleStorageServiceImpl implements IQpBottleStorageService {
             qpBottleStorage.setRejectionApplyTime(new Date());
         } else if (qpBottleStorage.getAirStatus() == 0) {
             //入库
-
+            QpBottleStorage qs = qpBottleStorageMapper.getByElectronicTag(qpBottleStorage.getElectronicTag());
+            if(qs!=null){
+                throw new ServiceException("该标签已被使用!");
+            }
             //查询标签信息
             QpRfidTag rfidTag = qpRfidTagService.selectByTag(qpBottleStorage.getElectronicTag());
             if (rfidTag == null) {
@@ -348,6 +351,44 @@ public class QpBottleStorageServiceImpl implements IQpBottleStorageService {
         return flg;
     }
 
+    /**
+     * 更换
+     *
+     * @param newTag
+     * @param id
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int bottleStorageChange(String newTag, Long id) {
+        //查询新标签信息
+        QpRfidTag rfidTag = qpRfidTagService.selectByTag(newTag);
+        if(rfidTag==null){
+            throw new ServiceException("该标签不存在!");
+        }else if(1==rfidTag.getIsBind() ){
+            throw new ServiceException("该标签已绑定!");
+        }
+
+        //查询标签入库信息
+        QpBottleStorageVO vo = qpBottleStorageMapper.selectQpBottleStorageById(id);
+
+        //查询旧标签信息
+        QpRfidTag rfidTagOld = qpRfidTagService.selectByTag(vo.getElectronicTag());
+        //刷新 旧标签状态,解绑
+        rfidTagOld.setIsBind(0);
+        qpRfidTagService.updateQpRfidTag(rfidTagOld);
+
+        //刷新 新标签状态,绑定
+        QpRfidTag tag = qpRfidTagService.selectQpRfidTagById(rfidTag.getId());
+        tag.setIsBind(1);
+        qpRfidTagService.updateQpRfidTag(tag);
+
+        //标签更换
+        vo.setElectronicTag(newTag);
+        qpBottleStorageMapper.updateQpBottleStorage(vo);
+
+        return 1;
+    }
+
     @Override
     public List<QpBottleStorage> getList(QpBottleStorage bottleStorage) {
         return qpBottleStorageMapper.getList(bottleStorage);

+ 0 - 74
zd-modules/zd-airbottle/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-airbottle"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="info"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="error"/>
-
-    <root level="info">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 1 - 1
zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/QpBottleStorageMapper.xml

@@ -641,7 +641,7 @@
         <if test="confirm == false ">and bs.rejection_userid is null</if>
     </select>
 
-    <!-- 查询入库的气瓶-->
+    <!-- 查询实验室负责人-->
     <select id="selectSubectDetalsById" resultType="java.util.Map">
         select admin_id adminId from lab_subject where id= #{subjectId};
     </select>

+ 5 - 0
zd-modules/zd-algorithm/pom.xml

@@ -58,6 +58,11 @@
             <artifactId>okhttp</artifactId>
             <version>3.10.0</version>
         </dependency>
+        <!-- mybatis plus -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
 
         <!-- 人脸对接  -->
         <dependency>

+ 6 - 4
zd-modules/zd-algorithm/src/main/java/com/zd/alg/AlgorithmApplication.java

@@ -4,12 +4,12 @@ package com.zd.alg;
 import com.zd.alg.forward.config.AlgorithmYml;
 import com.zd.alg.forward.properties.FireProperties;
 import com.zd.common.core.annotation.EnableCustomConfig;
-import com.zd.common.core.annotation.EnableRyFeignClients;
+import com.zd.common.core.annotation.EnableZdFeignClients;
 import com.zd.common.core.launch.ZdStartApplication;
 import com.zd.common.mqtt.model.MqttProperties;
 import com.zd.model.constant.ApplicationConstants;
 import com.zd.model.constant.BaseConstants;
-import org.springframework.boot.SpringApplication;
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.web.servlet.ServletComponentScan;
@@ -20,15 +20,17 @@ import org.springframework.context.ConfigurableApplicationContext;
  */
 @ServletComponentScan("com.zd.alg.iot.vmp.conf")
 @EnableCustomConfig
-@EnableRyFeignClients
+@EnableZdFeignClients
 @SpringBootApplication(scanBasePackages = BaseConstants.BASE_PACKAGE)
 @EnableConfigurationProperties({MqttProperties.class, AlgorithmYml.class, FireProperties.class})
+@MapperScan(value = {"com.zd.**.mapper"})
 public class AlgorithmApplication {
 
     private static String[] args;
     private static ConfigurableApplicationContext context;
+
     public static void main(String[] args) {
-        AlgorithmApplication.args=args;
+        AlgorithmApplication.args = args;
         AlgorithmApplication.context = ZdStartApplication.run(ApplicationConstants.ALGORITHM_SERVICE, AlgorithmApplication.class, args);
     }
 

+ 1 - 4
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/conf/SipConfig.java

@@ -1,13 +1,10 @@
 package com.zd.alg.iot.vmp.conf;
 
-
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 
 @Component
-@ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true)
+@ConfigurationProperties(prefix = "camera.sip", ignoreInvalidFields = true)
 public class SipConfig {
 
 	private String ip;

+ 0 - 48
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/utils/IpUtil.java

@@ -1,48 +0,0 @@
-package com.zd.alg.iot.vmp.utils;
-
-
-import javax.servlet.http.HttpServletRequest;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class IpUtil {
-    public static String getIpAddr(HttpServletRequest request) {
-        String ipAddress = null;
-        try {
-            ipAddress = request.getHeader("x-forwarded-for");
-            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-                ipAddress = request.getHeader("Proxy-Client-IP");
-            }
-            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-                ipAddress = request.getHeader("WL-Proxy-Client-IP");
-            }
-            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
-                ipAddress = request.getRemoteAddr();
-                if (ipAddress.equals("127.0.0.1")) {
-                    // 根据网卡取本机配置的IP
-                    InetAddress inet = null;
-                    try {
-                        inet = InetAddress.getLocalHost();
-                    } catch (UnknownHostException e) {
-                        e.printStackTrace();
-                    }
-                    ipAddress = inet.getHostAddress();
-                }
-            }
-            // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
-            if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
-                // = 15
-                if (ipAddress.indexOf(",") > 0) {
-                    ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
-                }
-            }
-        } catch (Exception e) {
-            ipAddress="";
-        }
-        // ipAddress = this.getRequest().getRemoteAddr();
-
-        return ipAddress;
-    }
-}
-
-

+ 0 - 59
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/NettyStartListener.java

@@ -1,59 +0,0 @@
-package com.zd.alg.netty.init;
-
-import com.zd.alg.netty.service.IFridService;
-import com.zd.laboratory.api.feign.RemoteLaboratoryService;
-import com.zd.model.constant.HttpStatus;
-import com.zd.model.domain.R;
-import com.zd.model.entity.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * 监听Spring容器启动完成,完成后启动Netty服务器
- *
- * @author dgs
- **/
-@Component
-@Slf4j
-public class NettyStartListener implements ApplicationRunner {
-    @Resource
-    private IFridService fridService;
-    @Resource
-    private RemoteLaboratoryService laboratoryService;
-    @Resource
-    private SocketServer socketServer;
-
-
-    @Override
-    public void run(ApplicationArguments args) {
-        R<List<RemoteLabHardware>> listStart = laboratoryService.listStart();
-        synchronized (this){
-            while (listStart.getCode() != HttpStatus.SUCCESS) {
-                try {
-                    log.error("com.zd.system.api.laboratory.RemoteLaboratoryService:远程接口调用异常");
-                    //防止laboratory模块未启动完成,故每30秒执行一次程序,直到接口可以正常访问
-                    this.wait(30 * 1000L);
-                    NettyStartListener.this.run(args);
-                } catch (InterruptedException e) {
-                    Thread.currentThread().interrupt();
-                }
-            }
-            List<RemoteLabHardware> unitVos = listStart.getData();
-            if (!unitVos.isEmpty()) {
-                try {
-                    unitVos.stream()
-                            .filter(u -> StringUtils.hasLength(u.getIpAddress()))
-                            .forEach(u -> fridService.start(u));
-                } catch (Exception e) {
-                    e.fillInStackTrace();
-                }
-            }
-        }
-    }
-}

+ 0 - 249
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/WuYuanRFIDServiceImpl.java

@@ -1,249 +0,0 @@
-package com.zd.alg.netty.sdk;
-
-import com.payne.connect.net.NetworkHandle;
-import com.payne.reader.Reader;
-import com.payne.reader.base.BaseInventory;
-import com.payne.reader.bean.config.AntennaCount;
-import com.payne.reader.bean.config.ProfileId;
-import com.payne.reader.bean.config.Session;
-import com.payne.reader.bean.receive.Failure;
-import com.payne.reader.bean.receive.Success;
-import com.payne.reader.bean.send.*;
-import com.payne.reader.process.ReaderImpl;
-import com.zd.alg.netty.base.FridConsumer;
-import com.zd.alg.netty.service.ISendService;
-import com.zd.alg.netty.service.IService;
-import com.zd.common.core.exception.ServiceException;
-import com.zd.laboratory.api.feign.RemoteLaboratoryService;
-import com.zd.model.entity.RemoteLabHardware;
-import com.zd.model.enums.HardwareOperate;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.annotation.Resource;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Slf4j
-@Service
-public class WuYuanRFIDServiceImpl implements IService {
-
-    private final Map<String, Reader> readerMap = new ConcurrentHashMap<>();
-    private final Map<String, NetworkHandle> handleMap = new ConcurrentHashMap<>();
-    private static final String MSG = "请先连接设备";
-    private static final String SCANNER_MSG = "服务已断开,请检查连接状态正常后重启程序:";
-    @Resource
-    private FridConsumer fridConsumer;
-    @Resource
-    private ISendService sendService;
-    @Resource
-    private RemoteLaboratoryService laboratoryService;
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
-        if (!StringUtils.hasLength(ipAddress)){
-            return;
-        }
-        Integer channels = hardware.getChannels();
-        channels=channels==null?1:channels;
-        Byte sessionIndex = hardware.getSessionIndex();
-        sessionIndex=sessionIndex==null?0:sessionIndex;
-        if (Boolean.FALSE.equals(deviceStatus(hardware))){
-            connect(hardware);
-            setDevice(hardware);
-        }
-
-        Reader reader;
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        } else {
-            throw new ServiceException(MSG);
-        }
-        if (reader == null || !reader.isConnected()) {
-            throw new ServiceException(MSG);
-        }
-        stopMonitor(hardware);
-        Session session = Session.valueOf(sessionIndex);
-        BaseInventory inventory;
-        switch (channels){
-            case 4:
-                inventory=new FastSwitchFourAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 8:
-                inventory=new FastSwitchEightAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 16:
-                inventory=new FastSwitchSixteenAntennaInventory.Builder().session(session)
-                        .build();
-                break;
-            case 1:
-            default:
-                inventory=new FastSwitchSingleAntennaInventory.Builder().session(session)
-                        .build();
-
-        }
-        log.info("============================>" + session);
-
-        Byte index = sessionIndex;
-        InventoryConfig config = new InventoryConfig.Builder()
-                .setInventory(inventory)
-                .setOnInventoryTagSuccess(fridConsumer)
-                //读取失败
-                .setOnFailure(failure -> errorMsg(failure, index, SCANNER_MSG, hardware))
-                .build();
-        reader.setInventoryConfig(config);
-        //true -- 开启循环调用
-        reader.startInventory(true);
-        laboratoryService.update(HardwareOperate.OPEN,ipAddress);
-    }
-
-    @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        stopMonitor(hardware);
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        if (reader != null && reader.isConnected()) {
-            reader.disconnect();
-        }
-
-        handleMap.remove(ipAddress);
-        readerMap.remove(ipAddress);
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-        // TODO document why this method is empty
-        return false;
-    }
-
-    public Boolean deviceStatus(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        return reader != null && reader.isConnected();
-    }
-
-    public void connect(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String host = hardware.getIpAddress();
-        Integer port = hardware.getPort();
-        if (readerMap.containsKey(host)) {
-            reader = readerMap.get(host);
-        }
-        if (reader != null && reader.isConnected()) {
-            throw new ServiceException("设备已连接");
-        }
-        if (reader == null) {
-            reader = ReaderImpl.create(AntennaCount.FOUR_CHANNELS);
-        }
-        NetworkHandle handle;
-        if (handleMap.containsKey(host)) {
-            handle = handleMap.get(host);
-        } else {
-            handle = new NetworkHandle(host, port);
-            handleMap.put(host, handle);
-        }
-        if (reader.connect(handle)) {
-            reader.getFirmwareVersion(version -> log.info("==========================reader1 version:\t" + version.getVersion()),
-                    failure -> errorMsg(failure, (byte) -1, "版本获取异常:", hardware));
-        } else {
-            throw new ServiceException("读写器连接失败");
-        }
-        if (!readerMap.containsKey(host)) {
-            readerMap.put(host, reader);
-        }
-    }
-
-    public void setDevice(RemoteLabHardware hardware) {
-        Reader reader;
-        String ipAddress = hardware.getIpAddress();
-        int power=33;
-        String uniformPower = hardware.getUniformPower();
-        String index = uniformPower.split(",")[0].split(":")[0];
-        if (StringUtils.hasLength(index)){
-            power= Integer.parseInt(index);
-        }
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        } else {
-            throw new ServiceException(MSG);
-        }
-
-        stopMonitor(hardware);
-        reader.setOutputPowerUniformly(
-                (byte) Integer.parseInt(Integer.toHexString(power)),
-                true,
-                success -> successMsg(success, "设置读写器的射频输出功率"),
-                failure -> errorMsg(failure, (byte) -1, "设置读写器的射频输出功率失败:", hardware));
-
-        reader.setOutputPower(
-                OutputPowerConfig.outputPower(new PowerFourAntenna.Builder().build()),
-                success -> successMsg(success, "设置每个天线的射频输出功率"),
-                failure -> errorMsg(failure, (byte) -1, "设置每个天线的射频输出功率失败:", hardware));
-
-        reader.setFrequencyRegion(
-                new FreqNormal.Builder().build(),
-                success -> successMsg(success, "设置读写器的工作频率范围"),
-                failure -> errorMsg(failure, (byte) -1, "设置读写器的工作频率范围失败:", hardware));
-
-        reader.setRfLinkProfile(
-                ProfileId.Profile1,
-                success -> successMsg(success, "设置射频链路配置"),
-                failure -> errorMsg(failure, (byte) -1, "设置射频链路配置失败:", hardware));
-
-    }
-
-    private void errorMsg(Failure failure, byte index, String msg, RemoteLabHardware hardware) {
-        byte errorCode = failure.getErrorCode();
-        if (errorCode == -34 && msg.equals(SCANNER_MSG) && index != -1) {
-            deviceRestart(hardware);
-        }
-        if (errorCode == -79) {
-            sendService.sendError(msg + "\t" + failure);
-            stopMonitor(hardware);
-            disconnect(hardware);
-            if (index != -1) {
-                deviceRestart(hardware);
-            }
-        }
-    }
-
-    public void deviceRestart(RemoteLabHardware hardware) {
-        connect(hardware);
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            Reader reader = readerMap.get(ipAddress);
-            if (reader.isConnected()) {
-                sendService.sendError("重连成功");
-                start(hardware);
-            }
-            return;
-        }
-        throw new ServiceException("设备未连接");
-    }
-
-    public void stopMonitor(RemoteLabHardware hardware) {
-        Reader reader = null;
-        String ipAddress = hardware.getIpAddress();
-        if (readerMap.containsKey(ipAddress)) {
-            reader = readerMap.get(ipAddress);
-        }
-        if (reader != null && reader.isConnected()) {
-            reader.stopInventory();
-        }
-        laboratoryService.update(HardwareOperate.CLOSE,ipAddress);
-    }
-
-    private void successMsg(Success success, String msg) {
-        log.info("=========================={}:\t {}", msg, success.toString());
-    }
-}

+ 0 - 28
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/IFridService.java

@@ -1,28 +0,0 @@
-package com.zd.alg.netty.service;
-
-
-import com.zd.model.entity.RemoteLabHardware;
-
-/**
- * @author Administrator
- */
-public interface IFridService {
-    /**
-     * 启动RFID扫描器
-     * @param hardware 设备数据
-     */
-    void start(RemoteLabHardware hardware);
-
-    /**
-     * 关闭RFID扫描器
-     * @param hardware  设备数据
-     */
-    void stop(RemoteLabHardware hardware);
-
-    /**
-     * 启动警报
-     * @param hardware 设备数据
-     * @return boolean
-     */
-    boolean alarm(RemoteLabHardware hardware);
-}

+ 0 - 30
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/IService.java

@@ -1,30 +0,0 @@
-package com.zd.alg.netty.service;
-
-
-import com.zd.model.entity.RemoteLabHardware;
-
-/**
- * RFID接口类
- * @author Administrator
- */
-public interface IService {
-
-    /**
-     * 启动RFID读写器
-     * @param hardware 设备数据
-     */
-    void start(RemoteLabHardware hardware);
-
-    /**
-     * 断开RFID读写器
-     * @param hardware 设备数据
-     */
-    void disconnect(RemoteLabHardware hardware);
-
-    /**
-     * 启动警报
-     * @param hardware 设备数据
-     * @return boolean
-     */
-    boolean alarm(RemoteLabHardware hardware);
-}

+ 0 - 59
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/impl/FridServiceImpl.java

@@ -1,59 +0,0 @@
-package com.zd.alg.netty.service.impl;
-
-import com.zd.alg.netty.enums.ManufacturerTypeEnum;
-import com.zd.alg.netty.service.IFridService;
-import com.zd.alg.netty.service.IService;
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.model.entity.RemoteLabHardware;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.zd.model.constant.BaseConstants.MAP_INIT_SIZE;
-
-
-/**
- * @author Administrator
- */
-@Service
-@Slf4j
-public class FridServiceImpl implements IFridService {
-
-    private final ThreadPoolTaskExecutor taskExecutor = SpringUtils.getBean("taskExecutor");
-
-    private final Map<String, Thread> threadMap = new HashMap<>(MAP_INIT_SIZE);
-
-    private IService rfidService(Integer type) {
-        return SpringUtils.getBean(ManufacturerTypeEnum.matchByValue(type).getService());
-    }
-
-    @Override
-    public void start(RemoteLabHardware hardware) {
-        synchronized (this){
-            taskExecutor.execute(() -> {
-                rfidService(hardware.getManufacturerType()).start(hardware);
-                log.info("===================thread name:{}===============", Thread.currentThread().getName());
-                threadMap.computeIfAbsent(hardware.getIpAddress(), f -> Thread.currentThread());
-                log.info("==============>线程数量:{}",threadMap.size());
-            });
-        }
-    }
-
-    @Override
-    public void stop(RemoteLabHardware hardware) {
-        rfidService(hardware.getManufacturerType()).disconnect(hardware);
-        Thread thread = threadMap.get(hardware.getIpAddress());
-        if (thread != null && thread.isAlive()) {
-            thread.interrupt();
-            threadMap.remove(hardware.getIpAddress());
-        }
-    }
-
-    @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-       return rfidService(hardware.getManufacturerType()).alarm(hardware);
-    }
-}

+ 29 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/base/MyBatisPlusConfig.java

@@ -0,0 +1,29 @@
+package com.zd.alg.rfid.base;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@MapperScan("com.cn.springbootmybatisplus06.mapper")
+@EnableTransactionManagement//自动管理事务
+@Configuration // 配置类
+public class MyBatisPlusConfig {
+
+    /**
+     * 新版
+     */
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
+        //配置乐观锁
+        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
+        //配置分页插件
+        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return mybatisPlusInterceptor;
+    }
+}

+ 4 - 4
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/base/FridConsumer.java

@@ -1,8 +1,8 @@
-package com.zd.alg.netty.base;
+package com.zd.alg.rfid.base;
 
 import com.payne.reader.base.Consumer;
 import com.payne.reader.bean.receive.InventoryTag;
-import com.zd.alg.netty.service.ISendService;
+import com.zd.alg.rfid.service.ISendService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeansException;
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
  */
 @Slf4j
 @Component
-public class FridConsumer implements Consumer<InventoryTag> {
+public class RfidConsumer implements Consumer<InventoryTag> {
 
     @Autowired
     private ISendService sendService;
@@ -23,7 +23,7 @@ public class FridConsumer implements Consumer<InventoryTag> {
     public void accept(InventoryTag tag) {
         try {
             tag.setEpc(tag.getEpc().replace(" ", ""));
-            com.zd.model.entity.InventoryTag  inventoryTag = new com.zd.model.entity.InventoryTag ();
+            com.zd.model.entity.InventoryTag inventoryTag = new com.zd.model.entity.InventoryTag();
             BeanUtils.copyProperties(tag,inventoryTag);
             sendService.send(inventoryTag);
         } catch (BeansException e) {

+ 1 - 1
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/constant/RfidConstants.java

@@ -1,4 +1,4 @@
-package com.zd.alg.netty.constant;
+package com.zd.alg.rfid.constant;
 
 import java.util.ArrayList;
 import java.util.HashMap;

+ 96 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/controller/HardwareRfidController.java

@@ -0,0 +1,96 @@
+package com.zd.alg.rfid.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zd.alg.rfid.service.HardwareRfidService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.algorithm.api.rfid.domain.vo.HardwareRfidVo;
+import com.zd.common.core.annotation.Log;
+import com.zd.common.core.annotation.PreAuthorize;
+import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.utils.BeanUtils;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.model.domain.ResultData;
+import com.zd.model.domain.per.PerFun;
+import com.zd.model.domain.per.PerPrefix;
+import com.zd.model.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author: hzw
+ * @date: 2022/11/15 17:47
+ */
+@Api(tags = "RFID硬件信息")
+@RestController
+@RequestMapping("/hardwareRfid")
+public class HardwareRfidController extends BaseController<HardwareRfid> {
+
+    @Autowired
+    private HardwareRfidService hardwareRfidService;
+
+
+    /**
+     * 新增RFID硬件信息
+     */
+    @Log(title = "新增RFID硬件", businessType = BusinessType.INSERT)
+    @ApiOperation("新增RFID硬件")
+    @PreAuthorize(hasAnyPermi = {PerPrefix.LABORATORY_HARDWARE7 + PerFun.ADD})
+    @PostMapping("/save")
+    public ResultData save(@Validated @RequestBody HardwareRfidVo hardwareRfidVo) {
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidVo, hardwareRfid);
+        return hardwareRfidService.saveHardwareRfid(hardwareRfid);
+    }
+
+    /**
+     * 修改RFID硬件信息
+     */
+    @Log(title = "修改RFID硬件", businessType = BusinessType.UPDATE)
+    @ApiOperation("修改RFID硬件")
+    @PreAuthorize(hasAnyPermi = {PerPrefix.LABORATORY_HARDWARE7 + PerFun.EDIT})
+    @PutMapping("/update")
+    public ResultData update(@Validated @RequestBody HardwareRfidVo hardwareRfidVo) {
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidVo, hardwareRfid);
+        return hardwareRfidService.updateHardwareRfid(hardwareRfid);
+    }
+
+    /**
+     * 删除RFID硬件信息
+     */
+    @Log(title = "删除RFID硬件", businessType = BusinessType.DELETE)
+    @ApiOperation("删除RFID硬件")
+    @PreAuthorize(hasAnyPermi = {PerPrefix.LABORATORY_HARDWARE7 + PerFun.REMOVE})
+    @DeleteMapping("/delete/{id}")
+    public ResultData delete(@PathVariable("id") Long id) {
+        return ResultData.result(hardwareRfidService.removeById(id));
+    }
+
+    /**
+     * 查询RFID硬件信息
+     */
+    @Log(title = "查询RFID硬件", businessType = BusinessType.OTHER)
+    @ApiOperation("查询RFID硬件")
+    @PreAuthorize(hasAnyPermi = {PerPrefix.LABORATORY_HARDWARE7 + PerFun.QUERY})
+    @GetMapping("/query")
+    public TableDataInfo query(HardwareRfidVo hardwareRfidVo) {
+        Page<HardwareRfid> pages = hardwareRfidService.search(new Page(hardwareRfidVo.getPageNum(), hardwareRfidVo.getPageSize()), hardwareRfidVo);
+        return getDataTable(pages.getRecords(),pages.getTotal());
+    }
+
+    /**
+     * 启动/停止RFID硬件
+     */
+    @Log(title = "启动/停止RFID硬件", businessType = BusinessType.UPDATE)
+    @ApiOperation("启动/停止RFID硬件")
+    @PreAuthorize(hasAnyPermi = {PerPrefix.LABORATORY_HARDWARE7 + PerFun.CHANGESTATUS})
+    @ApiImplicitParam(name = "id",value = "硬件Id",dataType = "Long")
+    @PutMapping("/startOrStop/{id}")
+    public ResultData startOrStop(@PathVariable("id") Long id) {
+        return hardwareRfidService.startOrStop(id);
+    }
+}

+ 23 - 15
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/controller/FridDeviceController.java

@@ -1,9 +1,11 @@
-package com.zd.alg.netty.controller;
+package com.zd.alg.rfid.controller;
 
-import com.zd.alg.netty.constant.RfidConstants;
-import com.zd.alg.netty.service.IFridService;
+import com.zd.alg.rfid.constant.RfidConstants;
+import com.zd.alg.rfid.service.IRfidService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.common.core.utils.BeanUtils;
 import com.zd.model.domain.R;
-import com.zd.model.entity.RemoteLabHardware;
+import com.zd.model.entity.HardwareRfidDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
@@ -18,22 +20,24 @@ import java.util.Map;
 @Api(tags = {"RFID设备控制器"})
 @RestController
 @RequestMapping("/rfid")
-public class FridDeviceController {
+public class RfidDeviceController {
 
     @Resource
-    private IFridService service;
+    private IRfidService service;
 
     /**
-     * 启动FRID扫描监控
+     * 启动RFID扫描监控
      *         Session.S0 高频循环返回在辐射区域的数据,距离越近频次越高
      *         Session.S1 次高频循环返回在辐射区域数据,距离越近频次越高
      *         Session.S2 在辐射范围内重复出现或停止不动的有且仅返回一次数据,当设备离开辐射区域后重置缓存记录,根据厂商提供的文档和本人结合业务应用实际测试,推荐使用此session
      *         Session.S3 这个暂时没搞懂,选择此session的时候在没有标签在辐射区域会报错,不知道是因为识别设备不够四个还是其他问题,待确定
      */
-    @ApiOperation("信道启动FRID扫描监控")
+    @ApiOperation("信道启动RFID扫描监控")
     @PostMapping("/startMonitorChannels")
-    public R<Boolean> startMonitorChannels(@RequestBody RemoteLabHardware hardware) {
-        service.start(hardware);
+    public R<Boolean> startMonitorChannels(@RequestBody HardwareRfidDto hardwareRfidDto) {
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidDto,hardwareRfid);
+        service.start(hardwareRfid);
         return R.ok();
     }
 
@@ -42,8 +46,10 @@ public class FridDeviceController {
      */
     @ApiOperation("断开设备连接")
     @PostMapping("/disconnect")
-    public R<Boolean> disconnect(@RequestBody RemoteLabHardware hardware) {
-        service.stop(hardware);
+    public R<Boolean> disconnect(@RequestBody HardwareRfidDto hardwareRfidDto) {
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidDto,hardwareRfid);
+        service.stop(hardwareRfid);
         return R.ok();
     }
 
@@ -52,12 +58,14 @@ public class FridDeviceController {
      */
     @ApiOperation("开启设备警报")
     @PostMapping("/alarm")
-    public R<Boolean> alarm(@RequestBody RemoteLabHardware hardware) {
-        return R.ok(service.alarm(hardware));
+    public R<Boolean> alarm(@RequestBody HardwareRfidDto hardwareRfidDto) {
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidDto,hardwareRfid);
+        return R.ok(service.alarm(hardwareRfid));
     }
 
     /**
-     * 开启设备警报
+     * 获取RFID配置
      */
     @ApiOperation("获取RFID配置")
     @GetMapping("/config")

+ 9 - 9
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/enums/ManufacturerTypeEnum.java

@@ -1,9 +1,8 @@
-package com.zd.alg.netty.enums;
+package com.zd.alg.rfid.enums;
 
-import com.zd.alg.netty.sdk.DeJuRFIDClientImpl;
-import com.zd.alg.netty.service.IService;
-import com.zd.alg.netty.sdk.DeJuRFIDServerImpl;
-import com.zd.alg.netty.sdk.WuYuanRFIDServiceImpl;
+import com.zd.alg.rfid.sdk.DeJuRFIDServerImpl;
+import com.zd.alg.rfid.sdk.RfidClientImpl;
+import com.zd.alg.rfid.service.IService;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
@@ -18,9 +17,10 @@ public enum ManufacturerTypeEnum {
     /**
      * 枚举常量
      */
-    WU_WEI(1,"无源", WuYuanRFIDServiceImpl.class),
+//    WU_WEI(1,"无源", WuYuanRFIDServiceImpl.class),
     DE_JU(2,"惠州德聚服务端", DeJuRFIDServerImpl.class),
-    DE_JU2(3,"惠州德聚客户端", DeJuRFIDClientImpl.class);
+//    DE_JU2(3,"惠州德聚客户端", DeJuRFIDClientImpl.class);
+    DE_JU2(3,"惠州德聚客户端", RfidClientImpl.class);
 
     /**
      * 字典码
@@ -48,7 +48,7 @@ public enum ManufacturerTypeEnum {
                 return item;
             }
         }
-        return WU_WEI;
+        return DE_JU2;
     }
 
     /**
@@ -63,6 +63,6 @@ public enum ManufacturerTypeEnum {
                 return item;
             }
         }
-        return WU_WEI;
+        return DE_JU2;
     }
 }

+ 1 - 1
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/handler/SocketHandler.java

@@ -1,4 +1,4 @@
-package com.zd.alg.netty.handler;
+package com.zd.alg.rfid.handler;
 
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.Channel;
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.ChannelHandlerContext;

+ 51 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/init/RfidStartListener.java

@@ -0,0 +1,51 @@
+package com.zd.alg.rfid.init;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zd.alg.rfid.service.HardwareRfidService;
+import com.zd.alg.rfid.service.IRfidService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.laboratory.api.feign.RemoteLaboratoryService;
+import com.zd.model.enums.DeviceOnOffEnum;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 监听Spring容器启动完成,完成后启动Netty服务器
+ *
+ * @author dgs
+ **/
+@Component
+@Slf4j
+public class RfidStartListener implements ApplicationRunner {
+    @Resource
+    private IRfidService rfidService;
+    @Resource
+    private RemoteLaboratoryService laboratoryService;
+    @Resource
+    private SocketServer socketServer;
+
+    @Autowired
+    private HardwareRfidService hardwareRfidService;
+
+
+    @Override
+    public void run(ApplicationArguments args) {
+        List<HardwareRfid> list = hardwareRfidService.list(new LambdaQueryWrapper<HardwareRfid>().eq(HardwareRfid::getOnOff, DeviceOnOffEnum.ON.getCode()));
+        synchronized (this) {
+            if (!list.isEmpty()) {
+                try {
+                    list.stream().filter(u -> StringUtils.hasLength(u.getIpAddress())).forEach(u -> rfidService.start(u));
+                } catch (Exception e) {
+                    log.error("启动操作失败!{}", e);
+                }
+            }
+        }
+    }
+}

+ 2 - 2
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/SocketInitializer.java

@@ -1,4 +1,4 @@
-package com.zd.alg.netty.init;
+package com.zd.alg.rfid.init;
 
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.ChannelInitializer;
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.ChannelPipeline;
@@ -6,7 +6,7 @@ import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.socket.Soc
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.FixedLengthFrameDecoder;
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.bytes.ByteArrayDecoder;
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.bytes.ByteArrayEncoder;
-import com.zd.alg.netty.handler.SocketHandler;
+import com.zd.alg.rfid.handler.SocketHandler;
 import org.springframework.stereotype.Component;
 
 /**

+ 3 - 3
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/init/SocketServer.java

@@ -1,4 +1,4 @@
-package com.zd.alg.netty.init;
+package com.zd.alg.rfid.init;
 
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.bootstrap.ServerBootstrap;
 import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup;
@@ -30,12 +30,12 @@ public class SocketServer {
     /**
      * netty服务监听端口
      */
-    @Value("${netty.port:6453}")
+    @Value("${rfid.port:6453}")
     private int port;
     /**
      * 主线程组数量
      */
-    @Value("${netty.bossThread:1}")
+    @Value("${rfid.bossThread:1}")
     private int bossThread;
 
     /**

+ 19 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/mapper/HardwareRfidMapper.java

@@ -0,0 +1,19 @@
+package com.zd.alg.rfid.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+  * @创建人 hzw
+  * @描述
+  * @创建时间  2022/11/15
+ */
+@Mapper
+public interface HardwareRfidMapper extends BaseMapper<HardwareRfid> {
+    int batchInsert(@Param("list") List<HardwareRfid> list);
+
+}

+ 37 - 37
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/DeJuRFIDClientImpl.java

@@ -1,15 +1,15 @@
-package com.zd.alg.netty.sdk;
+package com.zd.alg.rfid.sdk;
 
 import com.gg.reader.api.dal.GClient;
 import com.gg.reader.api.dal.GServer;
 import com.gg.reader.api.protocol.gx.MsgBaseInventoryEpc;
 import com.gg.reader.api.protocol.gx.MsgBaseSetBaseband;
 import com.gg.reader.api.protocol.gx.MsgBaseSetPower;
-import com.zd.alg.netty.service.IService;
+import com.zd.alg.rfid.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.SpringUtils;
 import com.zd.laboratory.api.feign.RemoteLaboratoryService;
-import com.zd.model.entity.RemoteLabHardware;
 import com.zd.model.enums.HardwareOperate;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -36,13 +36,13 @@ public class DeJuRFIDClientImpl implements IService {
     private DeJuRFIDServerImpl service;
 
     @Resource
-    private RedisTemplate<String, RemoteLabHardware> redisTemplate;
+    private RedisTemplate<String, HardwareRfid> redisTemplate;
 
     private static final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
 
     @Override
-    public void start(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
+    public void start(HardwareRfid hardwareRfid) {
+        String ipAddress = hardwareRfid.getIpAddress();
         GServer server;
         if (serverMap.containsKey(ipAddress)) {
             server = serverMap.get(ipAddress);
@@ -61,7 +61,7 @@ public class DeJuRFIDClientImpl implements IService {
         }
         if (server.open(port)) {
             log.info("开始监听:"+ipAddress);
-            subscribeServerHandler(server, hardware);
+            subscribeServerHandler(server, hardwareRfid);
         } else {
             log.info("监听失败:"+ipAddress);
             throw new ServiceException("监听失败,请稍后进行设备重连。。。");
@@ -69,11 +69,11 @@ public class DeJuRFIDClientImpl implements IService {
     }
 
     @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
+    public void disconnect(HardwareRfid hardwareRfid) {
+        String ipAddress = hardwareRfid.getIpAddress();
         if (serverMap.containsKey(ipAddress)) {
             GServer server = serverMap.get(ipAddress);
-            service.close(hardware);
+            service.close(hardwareRfid);
             server.close();
             serverMap.remove(ipAddress);
             log.info(ipAddress + "---监听结束");
@@ -81,26 +81,26 @@ public class DeJuRFIDClientImpl implements IService {
     }
 
     @Override
-    public boolean alarm(RemoteLabHardware hardware) {
-        return service.alarm(hardware);
+    public boolean alarm(HardwareRfid hardwareRfid) {
+        return service.alarm(hardwareRfid);
     }
 
     /**
      * 订阅监听上报
      *
      * @param server   服务对象
-     * @param hardware 设备对象
+     * @param hardwareRfid 设备对象
      */
-    public void subscribeServerHandler(GServer server, RemoteLabHardware hardware) {
+    public void subscribeServerHandler(GServer server, HardwareRfid hardwareRfid) {
         server.onGClientConnected = (client, serialNumber) -> {
-            redisTemplate.opsForValue().set(client.getSerialNumber(),hardware);
+            redisTemplate.opsForValue().set(client.getSerialNumber(),hardwareRfid);
             client.setSendHeartBeat(true);//开启心跳检测Tcp连接状态
             subscribeTcpHandler(client);//订阅Tcp断连上报
             client.setPrint(true);
-            reSet(hardware, client);
-            service.subscribeHandler(client, hardware);
+            reSet(hardwareRfid, client);
+            service.subscribeHandler(client, hardwareRfid);
             subscribeHandlerTagEpcOver(client);
-            remoteLaboratoryService.update(HardwareOperate.OPEN, hardware.getIpAddress());
+            remoteLaboratoryService.update(HardwareOperate.OPEN, hardwareRfid.getIpAddress());
             log.info(client.getName() + "---监听成功");
         };
     }
@@ -113,43 +113,43 @@ public class DeJuRFIDClientImpl implements IService {
     public void subscribeHandlerTagEpcOver(GClient client) {
         client.onTagEpcOver= (s, logBaseEpcInfo) -> {
             log.info("HandlerTagEpcOver:"+s);
-            RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
-            if (labHardware==null){
+            HardwareRfid hardwareRfid = redisTemplate.opsForValue().get(client.getSerialNumber());
+            if (hardwareRfid==null){
                 return;
             }
-            disconnect(labHardware);
-            start(labHardware);
+            disconnect(hardwareRfid);
+            start(hardwareRfid);
         };
     }
 
-    private void reSet(RemoteLabHardware hardware, GClient client) {
-        MsgBaseSetBaseband msgBaseSetBaseband = DeJuRFIDServerImpl.setSession(hardware, client);
+    private void reSet(HardwareRfid hardwareRfid, GClient client) {
+        MsgBaseSetBaseband msgBaseSetBaseband = DeJuRFIDServerImpl.setSession(hardwareRfid, client);
         if (0 != msgBaseSetBaseband.getRtCode()) {
             log.error("Session configuration error.");
-            reConnect(hardware, client);
+            reConnect(hardwareRfid, client);
             return;
         }
-        MsgBaseSetPower msgBaseSetPower = DeJuRFIDServerImpl.setPower(hardware, client);
+        MsgBaseSetPower msgBaseSetPower = DeJuRFIDServerImpl.setPower(hardwareRfid, client);
         if (0 != msgBaseSetPower.getRtCode()) {
             log.error("Power configuration error.");
-            reConnect(hardware, client);
+            reConnect(hardwareRfid, client);
             return;
         }
-        MsgBaseInventoryEpc msgBaseInventoryEpc = DeJuRFIDServerImpl.setInventory(hardware, client);
+        MsgBaseInventoryEpc msgBaseInventoryEpc = DeJuRFIDServerImpl.setInventory(hardwareRfid, client);
         if (0 != msgBaseInventoryEpc.getRtCode()) {
             log.error("Inventory epc error.");
-            reConnect(hardware, client);
+            reConnect(hardwareRfid, client);
             return;
         }
         boolean changeGpi = DeJuRFIDServerImpl.setGpi(client);
         if (!changeGpi){
-            reConnect(hardware,client);
+            reConnect(hardwareRfid,client);
         }
     }
 
-    private void reConnect(RemoteLabHardware hardware, GClient client) {
+    private void reConnect(HardwareRfid hardwareRfid, GClient client) {
         DeJuRFIDServerImpl.stopMsg(client);
-        reSet(hardware, client);
+        reSet(hardwareRfid, client);
     }
 
     /**
@@ -158,14 +158,14 @@ public class DeJuRFIDClientImpl implements IService {
      * @param client   客户端对象
      */
     private void subscribeTcpHandler(GClient client) {
-        RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
+        HardwareRfid hardwareRfid = redisTemplate.opsForValue().get(client.getSerialNumber());
         client.onDisconnected = s -> {
             log.info("连接" + s + "已断开");
-            if (labHardware!=null){
-                disconnect(labHardware);
-                remoteLaboratoryService.update(HardwareOperate.CLOSE, labHardware.getIpAddress());
+            if (hardwareRfid!=null){
+                disconnect(hardwareRfid);
+                remoteLaboratoryService.update(HardwareOperate.CLOSE, hardwareRfid.getIpAddress());
                 log.info("连接" + s + "重连中。。。");
-                scheduledExecutorService.schedule(()-> start(labHardware),30, TimeUnit.SECONDS);
+                scheduledExecutorService.schedule(()-> start(hardwareRfid),30, TimeUnit.SECONDS);
             }
         };
     }

+ 61 - 56
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/sdk/DeJuRFIDServerImpl.java

@@ -1,14 +1,15 @@
-package com.zd.alg.netty.sdk;
+package com.zd.alg.rfid.sdk;
 
 import com.gg.reader.api.dal.GClient;
 import com.gg.reader.api.protocol.gx.*;
-import com.zd.alg.netty.service.ISendService;
-import com.zd.alg.netty.service.IService;
+import com.zd.alg.rfid.service.ISendService;
+import com.zd.alg.rfid.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.SpringUtils;
 import com.zd.laboratory.api.feign.RemoteLaboratoryService;
+import com.zd.model.entity.HardwareRfidDto;
 import com.zd.model.entity.InventoryTag;
-import com.zd.model.entity.RemoteLabHardware;
 import com.zd.model.enums.HardwareOperate;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -43,19 +44,19 @@ public class DeJuRFIDServerImpl implements IService {
     private static final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
 
     @Resource
-    private RedisTemplate<String, RemoteLabHardware> redisTemplate;
+    private RedisTemplate<String, HardwareRfid> redisTemplate;
 
     @Resource
     private RemoteLaboratoryService remoteLaboratoryService;
 
     @Override
-    public void start(RemoteLabHardware hardware) {
-        open(hardware);
+    public void start(HardwareRfid hardwareRfid) {
+        open(hardwareRfid);
     }
 
-    private void open(RemoteLabHardware hardware) {
+    private void open(HardwareRfid hardwareRfid) {
         GClient client;
-        String ipAddress = hardware.getIpAddress();
+        String ipAddress = hardwareRfid.getIpAddress();
         if (clientMap.containsKey(ipAddress)) {
             client = clientMap.get(ipAddress);
         } else {
@@ -72,41 +73,41 @@ public class DeJuRFIDServerImpl implements IService {
             boolean change = setGpi(client);
             if (!change){
                 log.info("GPI epc error.");
-                close(hardware);
-                open(hardware);
+                close(hardwareRfid);
+                open(hardwareRfid);
                 return;
             }
-            MsgBaseSetBaseband msgBaseSetBaseband = setSession(hardware, client);
+            MsgBaseSetBaseband msgBaseSetBaseband = setSession(hardwareRfid, client);
             if (0 != msgBaseSetBaseband.getRtCode()) {
                 log.info("Session epc error.");
-                close(hardware);
-                open(hardware);
+                close(hardwareRfid);
+                open(hardwareRfid);
                 return;
             }
             // 功率配置, 将4个天线功率都设置为30dBm.
-            MsgBaseSetPower msgBaseSetPower = setPower(hardware, client);
+            MsgBaseSetPower msgBaseSetPower = setPower(hardwareRfid, client);
             if (0 != msgBaseSetPower.getRtCode()) {
                 log.info("Power configuration error.");
-                close(hardware);
-                open(hardware);
+                close(hardwareRfid);
+                open(hardwareRfid);
                 return;
             }
             //天线读卡, 读取EPC数据区以及TID数据区
-            MsgBaseInventoryEpc msgBaseInventoryEpc = setInventory(hardware, client);
+            MsgBaseInventoryEpc msgBaseInventoryEpc = setInventory(hardwareRfid, client);
             if (0 != msgBaseInventoryEpc.getRtCode()) {
                 log.info("Inventory epc error.");
-                close(hardware);
-                open(hardware);
+                close(hardwareRfid);
+                open(hardwareRfid);
                 return;
             }
 
             // 订阅标签上报事件
-            subscribeHandler(client, hardware);
-            subscribeHandlerTagEpcOver(client,hardware);
+            subscribeHandler(client, hardwareRfid);
+            subscribeHandlerTagEpcOver(client,hardwareRfid);
             subscribeTcpHandler(client);
             String serialNumber = client.getSerialNumber();
             if (StringUtils.hasLength(serialNumber)){
-                redisTemplate.opsForValue().set(serialNumber, hardware);
+                redisTemplate.opsForValue().set(serialNumber, hardwareRfid);
             }
         } else {
             throw new ServiceException("Connect failure.");
@@ -119,21 +120,21 @@ public class DeJuRFIDServerImpl implements IService {
      * @param client   客户端对象
      */
     public void subscribeTcpHandler(GClient client) {
-        RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
+        HardwareRfid hardwareRfid = redisTemplate.opsForValue().get(client.getSerialNumber());
         client.onDisconnected = s -> {
             log.info("连接" + s + "已断开");
-            if (labHardware!=null){
+            if (hardwareRfid!=null){
                 client.close();
-                remoteLaboratoryService.update(HardwareOperate.CLOSE, labHardware.getIpAddress());
+                remoteLaboratoryService.update(HardwareOperate.CLOSE, hardwareRfid.getIpAddress());
                 log.info("连接" + s + "重连中。。。");
-                start(labHardware);
+                start(hardwareRfid);
             }
         };
     }
 
-    public static MsgBaseInventoryEpc setInventory(RemoteLabHardware hardware, GClient client) {
+    public static MsgBaseInventoryEpc setInventory(HardwareRfid hardwareRfid, GClient client) {
         MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc();
-        switch (hardware.getChannels()) {
+        switch (hardwareRfid.getChannels()) {
             case 4:
                 msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4);
                 break;
@@ -156,30 +157,30 @@ public class DeJuRFIDServerImpl implements IService {
         return msgBaseInventoryEpc;
     }
 
-    public static MsgBaseSetPower setPower(RemoteLabHardware hardware, GClient client) {
-        String uniformPower = hardware.getUniformPower();
+    public static MsgBaseSetPower setPower(HardwareRfid hardwareRfid, GClient client) {
+        String uniformPower = hardwareRfid.getUniformPower();
         MsgBaseGetPower msgBaseGetPower = new MsgBaseGetPower();
         client.sendSynMsg(msgBaseGetPower);
         MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower();
         if (0 == msgBaseGetPower.getRtCode()) {
-            sendPower(hardware, client, uniformPower, msgBaseGetPower, msgBaseSetPower);
+            sendPower(hardwareRfid, client, uniformPower, msgBaseGetPower, msgBaseSetPower);
         } else {
             log.info("==============获取输出功率失败==============");
         }
         return msgBaseSetPower;
     }
 
-    private static void sendPower(RemoteLabHardware hardware, GClient client, String uniformPower, MsgBaseGetPower msgBaseGetPower, MsgBaseSetPower msgBaseSetPower) {
+    private static void sendPower(HardwareRfid hardwareRfid, GClient client, String uniformPower, MsgBaseGetPower msgBaseGetPower, MsgBaseSetPower msgBaseSetPower) {
         if (StringUtils.hasLength(uniformPower)) {
-            editAndSendPower(hardware, client, uniformPower, msgBaseSetPower, msgBaseGetPower);
+            editAndSendPower(hardwareRfid, client, uniformPower, msgBaseSetPower, msgBaseGetPower);
         } else {
             msgBaseSetPower.setRtCode((byte) 0);
         }
     }
 
-    private static void editAndSendPower(RemoteLabHardware hardware, GClient client, String uniformPower, MsgBaseSetPower msgBaseSetPower, MsgBaseGetPower msgBaseGetPower) {
+    private static void editAndSendPower(HardwareRfid hardwareRfid, GClient client, String uniformPower, MsgBaseSetPower msgBaseSetPower, MsgBaseGetPower msgBaseGetPower) {
         Hashtable<Integer, Integer> dicPower = msgBaseGetPower.getDicPower();
-        Integer channels = hardware.getChannels();
+        Integer channels = hardwareRfid.getChannels();
         String[] uniformPowers = uniformPower.split(",");
         for (int i = 1; i <= channels; i++) {
             Integer power = dicPower.get(i);
@@ -199,15 +200,15 @@ public class DeJuRFIDServerImpl implements IService {
         }
     }
 
-    public static MsgBaseSetBaseband setSession(RemoteLabHardware hardware, GClient client) {
+    public static MsgBaseSetBaseband setSession(HardwareRfid hardwareRfid, GClient client) {
         MsgBaseGetBaseband msgBaseGetBaseband = new MsgBaseGetBaseband();
         MsgBaseSetBaseband msgBaseSetBaseband = new MsgBaseSetBaseband();
         client.sendSynMsg(msgBaseGetBaseband);
         if (0 == msgBaseGetBaseband.getRtCode()) {
             int session = msgBaseGetBaseband.getSession();
             log.info("Session index is:==============》{}", session);
-            if (session != hardware.getSessionIndex()) {
-                msgBaseSetBaseband.setSession(hardware.getSessionIndex());
+            if (session != hardwareRfid.getSessionIndex()) {
+                msgBaseSetBaseband.setSession(hardwareRfid.getSessionIndex());
                 client.sendSynMsg(msgBaseSetBaseband);
                 if (0 != msgBaseSetBaseband.getRtCode()) {
                     log.info("Session epc error.");
@@ -253,14 +254,14 @@ public class DeJuRFIDServerImpl implements IService {
     }
 
     @Override
-    public void disconnect(RemoteLabHardware hardware) {
-        close(hardware);
+    public void disconnect(HardwareRfid hardwareRfid) {
+        close(hardwareRfid);
     }
 
     @Override
-    public boolean alarm(RemoteLabHardware hardware) {
+    public boolean alarm(HardwareRfid hardwareRfid) {
         //灯带设置
-        String ipAddress = hardware.getIpAddress();
+        String ipAddress = hardwareRfid.getIpAddress();
         if (clientMap.containsKey(ipAddress)) {
             GClient client = clientMap.get(ipAddress);
             boolean alarm = false;
@@ -271,15 +272,15 @@ public class DeJuRFIDServerImpl implements IService {
                 log.info("报警状态:==============》{},设备IP:{}", alarm, ipAddress);
                 if (!alarm) {
                     alarmMap.putIfAbsent(ipAddress,true);
-                    return changeGpo(ipAddress, 1, client, 10);
+                    return changeGpo(ipAddress, 1, client, 1);
                 }
             }
         }
         return false;
     }
 
-    public void close(RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
+    public void close(HardwareRfid hardwareRfid) {
+        String ipAddress = hardwareRfid.getIpAddress();
         if (clientMap.containsKey(ipAddress)) {
             GClient client = clientMap.get(ipAddress);
             changeGpo(ipAddress, 0, client, 0);
@@ -342,10 +343,10 @@ public class DeJuRFIDServerImpl implements IService {
      * 订阅6c标签信息上报
      *
      * @param client   客户端
-     * @param hardware 设备数据
+     * @param hardwareRfid 设备数据
      */
-    public void subscribeHandler(GClient client, RemoteLabHardware hardware) {
-        String ipAddress = hardware.getIpAddress();
+    public void subscribeHandler(GClient client, HardwareRfid hardwareRfid) {
+        String ipAddress = hardwareRfid.getIpAddress();
         clientMap.computeIfAbsent(ipAddress, f -> client);
         String serialNumber = client.getSerialNumber();
         client.onTagEpcLog = (s, logBaseEpcInfo) -> {
@@ -355,17 +356,21 @@ public class DeJuRFIDServerImpl implements IService {
                 String key=epc+antId;
                 if (Boolean.FALSE.equals(redisTemplate.hasKey(key))){
                     log.info("===========》{},index: {}", epc, antId);
-                    redisTemplate.opsForValue().set(key,hardware,30,TimeUnit.SECONDS);
+                    redisTemplate.opsForValue().set(key,hardwareRfid,30,TimeUnit.SECONDS);
                     scheduledExecutorService.execute(()->{
                         InventoryTag tag = new InventoryTag();
                         BeanUtils.copyProperties(logBaseEpcInfo, tag);
                         String readerSerialNumber = logBaseEpcInfo.getReaderSerialNumber();
                         log.info("===========》读取器设备编码:{}", readerSerialNumber);
+                        HardwareRfidDto hardwareRfidDto = new HardwareRfidDto();
                         if (StringUtils.hasLength(serialNumber)){
                             tag.setSerialNumber(serialNumber);
-                            tag.setRemoteLabHardware(redisTemplate.opsForValue().get(serialNumber));
+//                            tag.setRemoteLabHardware(redisTemplate.opsForValue().get(serialNumber));
+                            BeanUtils.copyProperties(redisTemplate.opsForValue().get(serialNumber),hardwareRfidDto);
+                            tag.setHardwareRfidDto(hardwareRfidDto);
                         }else {
-                            tag.setRemoteLabHardware(hardware);
+                            BeanUtils.copyProperties(hardwareRfid,hardwareRfidDto);
+                            tag.setHardwareRfidDto(hardwareRfidDto);
                         }
                         sendService.send(tag);
                     });
@@ -378,13 +383,13 @@ public class DeJuRFIDServerImpl implements IService {
      * 订阅6c标签信息上报停止事件
      *
      * @param client   客户端
-     * @param hardware 设备数据
+     * @param hardwareRfid 设备数据
      */
-    public void subscribeHandlerTagEpcOver(GClient client, RemoteLabHardware hardware) {
+    public void subscribeHandlerTagEpcOver(GClient client, HardwareRfid hardwareRfid) {
         client.onTagEpcOver= (s, logBaseEpcInfo) -> {
             log.info("HandlerTagEpcOver:"+s);
-            close(hardware);
-            open(hardware);
+            close(hardwareRfid);
+            open(hardwareRfid);
         };
     }
 }

+ 508 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/sdk/RfidClientImpl.java

@@ -0,0 +1,508 @@
+package com.zd.alg.rfid.sdk;
+
+import com.gg.reader.api.dal.*;
+import com.gg.reader.api.protocol.gx.*;
+import com.zd.alg.rfid.service.HardwareRfidService;
+import com.zd.alg.rfid.service.ISendService;
+import com.zd.alg.rfid.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.common.core.utils.SpringUtils;
+import com.zd.model.entity.HardwareRfidDto;
+import com.zd.model.entity.InventoryTag;
+import com.zd.model.enums.DeviceStatusEnum;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @创建人 hzw
+ * @描述 rfid客户端实现类
+ * @创建时间 2022/11/15
+ */
+@Slf4j
+@Service
+public class RfidClientImpl implements IService {
+    private static final ISendService sendService = SpringUtils.getBean("sendService");
+    private static final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
+    private static final Map<String, GServer> serverMap = new ConcurrentHashMap<>();
+    private static final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
+    @Resource
+    private RedisTemplate<String, HardwareRfid> redisTemplate;
+    @Autowired
+    private HardwareRfidService hardwareRfidService;
+
+    /**
+     * 启动读写器
+     *
+     * @Param [hardwareRfid 硬件信息]
+     * @Return void
+     **/
+    @Override
+    public void start(HardwareRfid hardwareRfid) {
+        GServer server = new GServer();
+        int port = getPort(hardwareRfid.getIpAddress());
+        if (server.open(port)) {
+            log.info("【RFID门禁机】开始监听");
+            subscribeServerHandler(hardwareRfid, server);
+        } else {
+            log.info("【RFID门禁机】监听失败,请检查端口号是否被占用!");
+        }
+    }
+
+    /**
+     * 订阅监听上报
+     */
+    private void subscribeServerHandler(HardwareRfid hardwareRfid, GServer server) {
+        //TCP 处于监听状态,远程读写设备主动连接上位机时,会触发此事件上报
+        server.onGClientConnected = new HandlerGClientConnected() {
+            @Override
+            public void log(GClient client, String serialNumber) {
+                try {
+                    log.info("监听到远程读写设备主动连接...");
+                    //初始化服务map
+                    initServicesMap(client, server, hardwareRfid);
+                    //开启心跳检测Tcp连接状态
+                    client.setSendHeartBeat(true);
+                    client.setPrint(true);
+                    //订阅Tcp断连上报
+                    subscribeTcpHandler(client, hardwareRfid);
+                    //设置rfid初始化参数
+                    setConfig(client, hardwareRfid);
+                    //订阅报告启动事件
+                    subscribeReportedStartEvents(client, hardwareRfid);
+                    //订阅报告结束事件
+                    subscribeReportedOverEvents(client, hardwareRfid);
+                    //修改设备状态
+                    changStatus(hardwareRfid, DeviceStatusEnum.ON_LINE);
+                    log.info("【RFID门禁机】监听成功!{}", client.getName());
+                } catch (Exception e) {
+                    changStatus(hardwareRfid, DeviceStatusEnum.EXCEPTION);
+                    log.error("远程读写设备主动连接报错,请联系管理员!{}", e);
+                }
+            }
+        };
+    }
+
+    /**
+     * 初始化保存客户端/服务端
+     *
+     * @param client       客户端
+     * @param server       服务端
+     * @param hardwareRfid 设备信息
+     */
+    private void initServicesMap(GClient client, GServer server, HardwareRfid hardwareRfid) {
+        String hardwareNum = hardwareRfid.getHardwareNum();
+        if (StringUtils.isBlank(hardwareNum)) {
+            log.info("设备编码为空!");
+            return;
+        }
+        if (clientMap.containsKey(hardwareNum)) {
+            log.info("此序列编号已存在客户端,删除已存在客户端!");
+            clientMap.remove(hardwareNum);
+        }
+        if (serverMap.containsKey(hardwareNum)) {
+            log.info("此序列编号已存在服务端,删除已存在服务端!");
+            serverMap.remove(hardwareNum);
+        }
+        //存储客户端
+        clientMap.put(hardwareNum, client);
+        //储存服务端
+        serverMap.put(hardwareNum, server);
+    }
+
+    /**
+     * 订阅TCP断开连接上报
+     */
+    private void subscribeTcpHandler(GClient client, HardwareRfid hardwareRfid) {
+        client.onDisconnected = new HandlerTcpDisconnected() {
+            @Override
+            public void log(String ipPort) {
+                log.info("【RFID门禁机】连接已断开:{}", ipPort);
+                changStatus(hardwareRfid, DeviceStatusEnum.OFF_LINE);
+                //释放当前连接资源
+                client.close();
+                //删除客户端map数据
+                clientMap.remove(hardwareRfid.getHardwareNum());
+            }
+        };
+    }
+
+    /**
+     * 订阅报告启动事件
+     *
+     * @param client       客户端
+     * @param hardwareRfid 硬件信息
+     */
+    private void subscribeReportedStartEvents(GClient client, HardwareRfid hardwareRfid) {
+        // 订阅标签上报事件
+        client.onTagEpcLog = new HandlerTagEpcLog() {
+            @Override
+            public void log(String readName, LogBaseEpcInfo logBaseEpcInfo) {
+                // 回调内部如有阻塞,会影响 API 正常使用
+                // 标签回调数量较多,请将标签数据先缓存起来再作业务处理
+                if (null != logBaseEpcInfo && 0 == logBaseEpcInfo.getResult()) {
+                    log.info("接收到RFID读写器消息:{}", logBaseEpcInfo);
+                    // redis是否存在此标签
+                    int antId = logBaseEpcInfo.getAntId();
+                    String epc = logBaseEpcInfo.getEpc();
+                    if (Boolean.FALSE.equals(redisTemplate.hasKey(logBaseEpcInfo.getEpc() + antId))) {
+                        //不存在缓存,设置间隔30s调用
+                        redisTemplate.opsForValue().set(logBaseEpcInfo.getEpc() + antId, hardwareRfid, 30, TimeUnit.SECONDS);
+                        scheduledExecutorService.execute(() -> {
+                            InventoryTag tag = new InventoryTag();
+                            BeanUtils.copyProperties(logBaseEpcInfo, tag);
+                            HardwareRfidDto hardwareRfidDto = new HardwareRfidDto();
+                            BeanUtils.copyProperties(hardwareRfid, hardwareRfidDto);
+                            tag.setHardwareRfidDto(hardwareRfidDto);
+                            sendService.send(tag);
+                        });
+                    } else {
+                        //标签存在缓存,间隔30s调用
+                        log.info("标签操作频繁,请间隔30s调用!");
+                    }
+                }
+            }
+        };
+    }
+
+    /**
+     * 订阅报告结束事件
+     *
+     * @param client       客户端
+     * @param hardwareRfid 硬件信息
+     */
+    private void subscribeReportedOverEvents(GClient client, HardwareRfid hardwareRfid) {
+        client.onTagEpcOver = new HandlerTagEpcOver() {
+            @Override
+            public void log(String s, LogBaseEpcOver logBaseEpcOver) {
+                log.info("【RFID门禁机】已离线!");
+                hardwareRfid.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getCode());
+                hardwareRfidService.updateHardwareRfid(hardwareRfid);
+            }
+        };
+    }
+
+    /**
+     * 设置rfid初始化参数
+     *
+     * @param client       客户顿
+     * @param hardwareRfid 硬件信息
+     */
+    private void setConfig(GClient client, HardwareRfid hardwareRfid) {
+        try {
+            // 读写器停止读写卡
+            if (stopMsg(client)) {
+                //设置GPI
+                if (!setGpi(client)) {
+                    return;
+                }
+                //设置session
+                if (!setSession(client)) {
+                    return;
+                }
+                // 天线功率配置(将4个天线功率都设置为30dBm)
+                if (!setPower(client, hardwareRfid)) {
+                    return;
+                }
+                //天线读卡, 读取EPC数据区以及TID数据区
+                setInventory(client, hardwareRfid);
+            }
+        } catch (Exception e) {
+            changStatus(hardwareRfid, DeviceStatusEnum.EXCEPTION);
+            log.error("设置门禁机参数异常,请联系管理员!");
+        }
+    }
+
+    /**
+     * 修改RFID硬件状态
+     *
+     * @param hardwareRfid     硬件信息
+     * @param deviceStatusEnum 设备状态枚举类
+     */
+    private void changStatus(HardwareRfid hardwareRfid, DeviceStatusEnum deviceStatusEnum) {
+        hardwareRfid.setDeviceStatus(deviceStatusEnum.getCode());
+        hardwareRfidService.updateHardwareRfid(hardwareRfid);
+    }
+
+    public boolean setGpi(GClient client) {
+        MsgAppGetGpiState gpiState = new MsgAppGetGpiState();
+        client.sendSynMsg(gpiState);
+        HashMap<Integer, Integer> hashMap = gpiState.getHpGpiState();
+        boolean change = true;
+        for (Map.Entry<Integer, Integer> entry : hashMap.entrySet()) {
+            Integer k = entry.getKey();
+            MsgAppGetGpiTrigger getGpiTrigger = new MsgAppGetGpiTrigger();
+            getGpiTrigger.setGpiPort(k - 1);
+            client.sendSynMsg(getGpiTrigger);
+            if (getGpiTrigger.getRtCode() == 0) {
+                int triggerOver = getGpiTrigger.getTriggerOver();
+                int triggerStart = getGpiTrigger.getTriggerStart();
+                if (triggerStart != 0 || triggerOver != 0) {
+                    MsgAppSetGpiTrigger gpiTrigger = new MsgAppSetGpiTrigger();
+                    gpiTrigger.setGpiPort(getGpiTrigger.getGpiPort());
+                    gpiTrigger.setTriggerOver(0);
+                    gpiTrigger.setTriggerStart(0);
+                    client.sendSynMsg(gpiTrigger);
+                    if (0 != gpiTrigger.getRtCode()) {
+                        log.error("GPI epc error.");
+                        change = false;
+                    }
+                }
+            }
+        }
+        log.info("【RFID门禁机】GPI配置成功!");
+        return change;
+    }
+
+    public boolean setSession(GClient client) {
+        MsgBaseGetBaseband msgBaseGetBaseband = new MsgBaseGetBaseband();
+        MsgBaseSetBaseband msgBaseSetBaseband = new MsgBaseSetBaseband();
+        client.sendSynMsg(msgBaseGetBaseband);
+        if (0 == msgBaseGetBaseband.getRtCode()) {
+            int session = msgBaseGetBaseband.getSession();
+            if (session == 0) {
+                log.info("【RFID门禁机】Session已配置成功!");
+                return true;
+            } else {
+                msgBaseSetBaseband.setSession(0);
+                client.sendSynMsg(msgBaseSetBaseband);
+                if (0 == msgBaseSetBaseband.getRtCode()) {
+                    log.info("【RFID门禁机】Session配置成功!");
+                    return true;
+                }
+            }
+        }
+        log.error("【RFID门禁机】Session配置失败!");
+        return false;
+    }
+
+    public boolean setPower(GClient client, HardwareRfid hardwareRfid) {
+        MsgBaseGetPower msgBaseGetPower = new MsgBaseGetPower();
+        client.sendSynMsg(msgBaseGetPower);
+        if (0 == msgBaseGetPower.getRtCode()) {
+            return sendPower(client, hardwareRfid, msgBaseGetPower);
+        } else {
+            log.error("【RFID门禁机】获取天线功率失败!{}", msgBaseGetPower.getRtMsg());
+            return false;
+        }
+    }
+
+    public boolean setInventory(GClient client, HardwareRfid hardwareRfid) {
+        //几路天线读卡和通道数保持一致。
+        if (hardwareRfid.getChannels() == null) {
+            log.error("【RFID门禁机】通道配置为空!");
+            return false;
+        }
+        // 4个天线读卡, 读取 EPC 数据区以及 TID 数据区 默认只读 EPC
+        MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc();
+        switch (hardwareRfid.getChannels()) {
+            case 4:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4);
+                break;
+            case 8:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8);
+                break;
+            case 16:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8 | EnumG.AntennaNo_9 | EnumG.AntennaNo_10 | EnumG.AntennaNo_11 | EnumG.AntennaNo_12 | EnumG.AntennaNo_13 | EnumG.AntennaNo_14 | EnumG.AntennaNo_15 | EnumG.AntennaNo_16);
+                break;
+            case 1:
+            default:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1);
+        }
+        msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
+        client.sendSynMsg(msgBaseInventoryEpc);
+        if (0 == msgBaseInventoryEpc.getRtCode()) {
+            log.info("【RFID门禁机】Inventory epc配置成功!");
+            return true;
+        } else {
+            log.error("【RFID门禁机】Inventory epc配置失败!");
+            return false;
+        }
+    }
+
+
+    private boolean sendPower(GClient client, HardwareRfid hardwareRfid, MsgBaseGetPower msgBaseGetPower) {
+        //根据硬件配置参数配置设备功率
+        if (!hardwareRfid.getUniformPower().isEmpty() && hardwareRfid.getChannels() != null) {
+            Hashtable<Integer, Integer> dicPower = msgBaseGetPower.getDicPower();
+            Integer channels = hardwareRfid.getChannels();
+            String[] uniformPowers = hardwareRfid.getUniformPower().split(",");
+            for (int i = 1; i <= channels; i++) {
+                Integer power = dicPower.get(i);
+                String tempUniformPower = uniformPowers[i - 1];
+                String[] tempUniformPowers = tempUniformPower.split(":");
+                String temp = tempUniformPowers[0];
+                if (power == null || !Objects.equals(power, Integer.valueOf(temp))) {
+                    dicPower.put(i, Integer.valueOf(temp));
+                }
+            }
+            MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower();
+            msgBaseSetPower.setDicPower(dicPower);
+            client.sendSynMsg(msgBaseSetPower);
+            if (0 == msgBaseSetPower.getRtCode()) {
+                log.info("【RFID门禁机】设置天线功率成功!");
+                return true;
+            } else {
+                log.error("【RFID门禁机】设置天线功率失败!{}", msgBaseSetPower.getRtMsg());
+                return false;
+            }
+        } else {
+            log.error("设备输出频率或通道参数配置为空,UniformPower={},Channels={}", hardwareRfid.getUniformPower(), hardwareRfid.getChannels());
+            return false;
+        }
+    }
+
+
+    /**
+     * @param client    客户端
+     * @param state     报警状态(0不报警,1报警)
+     * @param delayTime 报警持续时间(单位:秒)
+     * @return
+     */
+    private boolean changeGpo(GClient client, int state, int delayTime) {
+        log.info("进入控制报警方法!是否开启={}", state);
+        MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
+        msgAppSetGpo.setGpo1(state);
+        msgAppSetGpo.setGpo2(state);
+        msgAppSetGpo.setGpo3(state);
+        msgAppSetGpo.setGpo4(state);
+        client.sendSynMsg(msgAppSetGpo);//发送响铃之后,进入下方if,开启定时线程
+        String status = state == 1 ? "开启" : "关闭";
+        if (0 == msgAppSetGpo.getRtCode()) {
+            log.info("【RFID门禁机】灯带报警{}成功!", status);
+            if (state == 1) {
+                stopGpo(client, delayTime);
+            }
+            return true;
+        }
+        log.info("【RFID门禁机】灯带报警{}失败!", status);
+        return false;
+
+    }
+
+    /**
+     * 断开设备链接
+     *
+     * @param hardwareRfid 设备数据
+     */
+    @Override
+    public void disconnect(HardwareRfid hardwareRfid) {
+        String hardwareNum = hardwareRfid.getHardwareNum();
+        if (clientMap.containsKey(hardwareNum)) {
+            GClient client = clientMap.get(hardwareNum);
+            GServer server = serverMap.get(hardwareNum);
+            //关闭报警
+            changeGpo(client, 0, 0);
+            //停止读写卡
+            stopMsg(client);
+            //客户端资源释放
+            client.close();
+            //服务端接口释放
+            server.close();
+            //客户端清除
+            clientMap.remove(hardwareNum);
+            //服务端缓存清除
+            serverMap.remove(hardwareNum);
+            log.info("【RFID门禁机】关闭成功!");
+        }
+
+    }
+
+    /**
+     * 停止读写卡
+     *
+     * @param client 客户端
+     * @return
+     */
+    public boolean stopMsg(GClient client) {
+        // 停止指令,空闲态
+        MsgBaseStop msgBaseStop = new MsgBaseStop();
+        client.sendSynMsg(msgBaseStop);
+        if (0x00 == msgBaseStop.getRtCode()) {
+            log.info("【RFID门禁机】停止读写成功!");
+            return true;
+        } else {
+            log.error("【RFID门禁机】停止读写失败!{}", msgBaseStop.getRtMsg());
+            return false;
+        }
+    }
+
+    /**
+     * 报警实现
+     *
+     * @param hardwareRfid 硬件信息
+     * @return
+     */
+    @Override
+    public boolean alarm(HardwareRfid hardwareRfid) {
+        log.info("收到调用报警!");
+        //灯带设置
+        String hardwareNum = hardwareRfid.getHardwareNum();
+        if (clientMap.containsKey(hardwareNum)) {
+            GClient client = clientMap.get(hardwareNum);
+            synchronized (this) {
+                //设置开始报警、报警时长
+                return changeGpo(client, 1, 1);
+            }
+        }
+        return false;
+    }
+
+    /**
+     * @param client    客户端
+     * @param delayTime 报警持续时间(单位:秒)
+     */
+    public void stopGpo(GClient client, int delayTime) {
+        scheduledExecutorService.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                changeGpo(client, 0, 0);
+            }
+        }, delayTime, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 去掉端口号,只获取ip
+     */
+    private static String getIp(HardwareRfid hardwareRfid) {
+        String ipAddress;
+        if (Objects.isNull(hardwareRfid) || StringUtils.isBlank(hardwareRfid.getIpAddress())) {
+            log.error("RFID配置ip为空!");
+        }
+        String[] ipPort = hardwareRfid.getIpAddress().split(":");
+        if (ipPort.length > 1) {
+            ipAddress = ipPort[0];
+        } else {
+            ipAddress = hardwareRfid.getIpAddress();
+        }
+        return ipAddress;
+    }
+
+    /**
+     * 获取端口号 未配置端口号默认给到8160
+     *
+     * @Param [ipPort]
+     * @Return int
+     **/
+    private static int getPort(String ipPort) {
+        //默认给到8160
+        int port = 8160;
+        if (null == ipPort || "".equals(ipPort)) {
+            return port;
+        }
+        String[] split = ipPort.split(":");
+        if (split.length > 1) {
+            port = Integer.valueOf(split[1]);
+        }
+        return port;
+    }
+}

+ 249 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/sdk/WuYuanRFIDServiceImpl.java

@@ -0,0 +1,249 @@
+//package com.zd.alg.rfid.sdk;
+//
+//import com.payne.connect.net.NetworkHandle;
+//import com.payne.reader.Reader;
+//import com.payne.reader.base.BaseInventory;
+//import com.payne.reader.bean.config.AntennaCount;
+//import com.payne.reader.bean.config.ProfileId;
+//import com.payne.reader.bean.config.Session;
+//import com.payne.reader.bean.receive.Failure;
+//import com.payne.reader.bean.receive.Success;
+//import com.payne.reader.bean.send.*;
+//import com.payne.reader.process.ReaderImpl;
+//import com.zd.alg.rfid.base.RfidConsumer;
+//import com.zd.alg.rfid.service.ISendService;
+//import com.zd.alg.rfid.service.IService;
+//import com.zd.common.core.exception.ServiceException;
+//import com.zd.laboratory.api.feign.RemoteLaboratoryService;
+//import com.zd.model.entity.RemoteLabHardware;
+//import com.zd.model.enums.HardwareOperate;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.stereotype.Service;
+//import org.springframework.util.StringUtils;
+//
+//import javax.annotation.Resource;
+//import java.util.Map;
+//import java.util.concurrent.ConcurrentHashMap;
+//
+//@Slf4j
+//@Service
+//public class WuYuanRFIDServiceImpl implements IService {
+//
+//    private final Map<String, Reader> readerMap = new ConcurrentHashMap<>();
+//    private final Map<String, NetworkHandle> handleMap = new ConcurrentHashMap<>();
+//    private static final String MSG = "请先连接设备";
+//    private static final String SCANNER_MSG = "服务已断开,请检查连接状态正常后重启程序:";
+//    @Resource
+//    private RfidConsumer rfidConsumer;
+//    @Resource
+//    private ISendService sendService;
+//    @Resource
+//    private RemoteLaboratoryService laboratoryService;
+//
+//    @Override
+//    public void start(RemoteLabHardware hardware) {
+//        String ipAddress = hardware.getIpAddress();
+//        if (!StringUtils.hasLength(ipAddress)){
+//            return;
+//        }
+//        Integer channels = hardware.getChannels();
+//        channels=channels==null?1:channels;
+//        Byte sessionIndex = hardware.getSessionIndex();
+//        sessionIndex=sessionIndex==null?0:sessionIndex;
+//        if (Boolean.FALSE.equals(deviceStatus(hardware))){
+//            connect(hardware);
+//            setDevice(hardware);
+//        }
+//
+//        Reader reader;
+//        if (readerMap.containsKey(ipAddress)) {
+//            reader = readerMap.get(ipAddress);
+//        } else {
+//            throw new ServiceException(MSG);
+//        }
+//        if (reader == null || !reader.isConnected()) {
+//            throw new ServiceException(MSG);
+//        }
+//        stopMonitor(hardware);
+//        Session session = Session.valueOf(sessionIndex);
+//        BaseInventory inventory;
+//        switch (channels){
+//            case 4:
+//                inventory=new FastSwitchFourAntennaInventory.Builder().session(session)
+//                        .build();
+//                break;
+//            case 8:
+//                inventory=new FastSwitchEightAntennaInventory.Builder().session(session)
+//                        .build();
+//                break;
+//            case 16:
+//                inventory=new FastSwitchSixteenAntennaInventory.Builder().session(session)
+//                        .build();
+//                break;
+//            case 1:
+//            default:
+//                inventory=new FastSwitchSingleAntennaInventory.Builder().session(session)
+//                        .build();
+//
+//        }
+//        log.info("============================>" + session);
+//
+//        Byte index = sessionIndex;
+//        InventoryConfig config = new InventoryConfig.Builder()
+//                .setInventory(inventory)
+//                .setOnInventoryTagSuccess(rfidConsumer)
+//                //读取失败
+//                .setOnFailure(failure -> errorMsg(failure, index, SCANNER_MSG, hardware))
+//                .build();
+//        reader.setInventoryConfig(config);
+//        //true -- 开启循环调用
+//        reader.startInventory(true);
+//        laboratoryService.update(HardwareOperate.OPEN,ipAddress);
+//    }
+//
+//    @Override
+//    public void disconnect(RemoteLabHardware hardware) {
+//        Reader reader = null;
+//        String ipAddress = hardware.getIpAddress();
+//        stopMonitor(hardware);
+//        if (readerMap.containsKey(ipAddress)) {
+//            reader = readerMap.get(ipAddress);
+//        }
+//        if (reader != null && reader.isConnected()) {
+//            reader.disconnect();
+//        }
+//
+//        handleMap.remove(ipAddress);
+//        readerMap.remove(ipAddress);
+//    }
+//
+//    @Override
+//    public boolean alarm(RemoteLabHardware hardware) {
+//        // TODO document why this method is empty
+//        return false;
+//    }
+//
+//    public Boolean deviceStatus(RemoteLabHardware hardware) {
+//        Reader reader = null;
+//        String ipAddress = hardware.getIpAddress();
+//        if (readerMap.containsKey(ipAddress)) {
+//            reader = readerMap.get(ipAddress);
+//        }
+//        return reader != null && reader.isConnected();
+//    }
+//
+//    public void connect(RemoteLabHardware hardware) {
+//        Reader reader = null;
+//        String host = hardware.getIpAddress();
+//        Integer port = hardware.getPort();
+//        if (readerMap.containsKey(host)) {
+//            reader = readerMap.get(host);
+//        }
+//        if (reader != null && reader.isConnected()) {
+//            throw new ServiceException("设备已连接");
+//        }
+//        if (reader == null) {
+//            reader = ReaderImpl.create(AntennaCount.FOUR_CHANNELS);
+//        }
+//        NetworkHandle handle;
+//        if (handleMap.containsKey(host)) {
+//            handle = handleMap.get(host);
+//        } else {
+//            handle = new NetworkHandle(host, port);
+//            handleMap.put(host, handle);
+//        }
+//        if (reader.connect(handle)) {
+//            reader.getFirmwareVersion(version -> log.info("==========================reader1 version:\t" + version.getVersion()),
+//                    failure -> errorMsg(failure, (byte) -1, "版本获取异常:", hardware));
+//        } else {
+//            throw new ServiceException("读写器连接失败");
+//        }
+//        if (!readerMap.containsKey(host)) {
+//            readerMap.put(host, reader);
+//        }
+//    }
+//
+//    public void setDevice(RemoteLabHardware hardware) {
+//        Reader reader;
+//        String ipAddress = hardware.getIpAddress();
+//        int power=33;
+//        String uniformPower = hardware.getUniformPower();
+//        String index = uniformPower.split(",")[0].split(":")[0];
+//        if (StringUtils.hasLength(index)){
+//            power= Integer.parseInt(index);
+//        }
+//        if (readerMap.containsKey(ipAddress)) {
+//            reader = readerMap.get(ipAddress);
+//        } else {
+//            throw new ServiceException(MSG);
+//        }
+//
+//        stopMonitor(hardware);
+//        reader.setOutputPowerUniformly(
+//                (byte) Integer.parseInt(Integer.toHexString(power)),
+//                true,
+//                success -> successMsg(success, "设置读写器的射频输出功率"),
+//                failure -> errorMsg(failure, (byte) -1, "设置读写器的射频输出功率失败:", hardware));
+//
+//        reader.setOutputPower(
+//                OutputPowerConfig.outputPower(new PowerFourAntenna.Builder().build()),
+//                success -> successMsg(success, "设置每个天线的射频输出功率"),
+//                failure -> errorMsg(failure, (byte) -1, "设置每个天线的射频输出功率失败:", hardware));
+//
+//        reader.setFrequencyRegion(
+//                new FreqNormal.Builder().build(),
+//                success -> successMsg(success, "设置读写器的工作频率范围"),
+//                failure -> errorMsg(failure, (byte) -1, "设置读写器的工作频率范围失败:", hardware));
+//
+//        reader.setRfLinkProfile(
+//                ProfileId.Profile1,
+//                success -> successMsg(success, "设置射频链路配置"),
+//                failure -> errorMsg(failure, (byte) -1, "设置射频链路配置失败:", hardware));
+//
+//    }
+//
+//    private void errorMsg(Failure failure, byte index, String msg, RemoteLabHardware hardware) {
+//        byte errorCode = failure.getErrorCode();
+//        if (errorCode == -34 && msg.equals(SCANNER_MSG) && index != -1) {
+//            deviceRestart(hardware);
+//        }
+//        if (errorCode == -79) {
+//            sendService.sendError(msg + "\t" + failure);
+//            stopMonitor(hardware);
+//            disconnect(hardware);
+//            if (index != -1) {
+//                deviceRestart(hardware);
+//            }
+//        }
+//    }
+//
+//    public void deviceRestart(RemoteLabHardware hardware) {
+//        connect(hardware);
+//        String ipAddress = hardware.getIpAddress();
+//        if (readerMap.containsKey(ipAddress)) {
+//            Reader reader = readerMap.get(ipAddress);
+//            if (reader.isConnected()) {
+//                sendService.sendError("重连成功");
+//                start(hardware);
+//            }
+//            return;
+//        }
+//        throw new ServiceException("设备未连接");
+//    }
+//
+//    public void stopMonitor(RemoteLabHardware hardware) {
+//        Reader reader = null;
+//        String ipAddress = hardware.getIpAddress();
+//        if (readerMap.containsKey(ipAddress)) {
+//            reader = readerMap.get(ipAddress);
+//        }
+//        if (reader != null && reader.isConnected()) {
+//            reader.stopInventory();
+//        }
+//        laboratoryService.update(HardwareOperate.CLOSE,ipAddress);
+//    }
+//
+//    private void successMsg(Success success, String msg) {
+//        log.info("=========================={}:\t {}", msg, success.toString());
+//    }
+//}

+ 47 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/HardwareRfidService.java

@@ -0,0 +1,47 @@
+package com.zd.alg.rfid.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.algorithm.api.rfid.domain.vo.HardwareRfidVo;
+import com.zd.model.domain.ResultData;
+
+import java.util.List;
+
+/**
+ * @创建人 hzw
+ * @描述 rfid硬件接口
+ * @创建时间 2022/11/15
+ */
+public interface HardwareRfidService extends IService<HardwareRfid> {
+
+    int batchInsert(List<HardwareRfid> list);
+
+    /**
+     * 新增rfid硬件信息
+     * @Param [hardwareRfid]
+     * @Return com.zd.model.domain.ResultData
+     **/
+    ResultData saveHardwareRfid(HardwareRfid hardwareRfid);
+
+    /**
+     * 修改rfid硬件信息
+     * @Param [hardwareRfid]
+     * @Return com.zd.model.domain.ResultData
+     **/
+    ResultData updateHardwareRfid(HardwareRfid hardwareRfid);
+
+    /**
+     * 分页查询rfid硬件信息
+     * @Param [page, hardwareRfidVo]
+     * @Return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.zd.algorithm.api.rfid.domain.entity.HardwareRfid>
+     **/
+    Page<HardwareRfid> search(Page<HardwareRfid> page, HardwareRfidVo hardwareRfidVo);
+
+    /**
+     * 根据硬件Id 打开/关闭rfid硬件设备
+     * @Param [id]
+     * @Return com.zd.model.domain.ResultData
+     **/
+    ResultData startOrStop(Long id);
+}

+ 31 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/IRfidService.java

@@ -0,0 +1,31 @@
+package com.zd.alg.rfid.service;
+
+
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+
+/**
+ * @author Administrator
+ */
+public interface IRfidService {
+    /**
+     * 启动RFID扫描器
+     * @param hardware 设备数据
+     */
+//    void start(RemoteLabHardware hardware);
+    void start(HardwareRfid hardwareRfid);
+
+    /**
+     * 关闭RFID扫描器
+     * @param hardware  设备数据
+     */
+//    void stop(RemoteLabHardware hardware);
+    void stop(HardwareRfid hardwareRfid);
+
+    /**
+     * 启动警报
+     * @param hardwareRfid 设备数据
+     * @return boolean
+     */
+//    boolean alarm(RemoteLabHardware hardware);
+    boolean alarm(HardwareRfid hardwareRfid);
+}

+ 3 - 2
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/ISendService.java

@@ -1,4 +1,4 @@
-package com.zd.alg.netty.service;
+package com.zd.alg.rfid.service;
 
 
 import com.zd.model.entity.InventoryTag;
@@ -11,13 +11,14 @@ public interface ISendService {
     /**
      * 发送读取到的编码
      *
-     * @param tag    frid数据
+     * @param tag rfid数据
      * @return boolean
      */
     boolean send(InventoryTag tag);
 
     /**
      * 发送异常信息
+     *
      * @param msg 异常消息
      */
     void sendError(String msg);

+ 34 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/IService.java

@@ -0,0 +1,34 @@
+package com.zd.alg.rfid.service;
+
+
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+
+/**
+ * RFID接口类
+ *
+ * @author Administrator
+ */
+public interface IService {
+
+    /**
+     * 启动RFID读写器
+     *
+     * @param hardwareRfid 设备数据
+     */
+    void start(HardwareRfid hardwareRfid);
+
+    /**
+     * 断开RFID读写器
+     *
+     * @param hardwareRfid 设备数据
+     */
+    void disconnect(HardwareRfid hardwareRfid);
+
+    /**
+     *报警
+     *
+     * @Param [hardwareRfid]
+     * @Return boolean
+     **/
+    boolean alarm(HardwareRfid hardwareRfid);
+}

+ 103 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/impl/HardwareRfidServiceImpl.java

@@ -0,0 +1,103 @@
+package com.zd.alg.rfid.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zd.alg.rfid.enums.ManufacturerTypeEnum;
+import com.zd.alg.rfid.mapper.HardwareRfidMapper;
+import com.zd.alg.rfid.service.HardwareRfidService;
+import com.zd.alg.rfid.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.algorithm.api.rfid.domain.vo.HardwareRfidVo;
+import com.zd.common.core.security.TokenService;
+import com.zd.common.core.utils.BeanUtils;
+import com.zd.common.core.utils.SecurityUtils;
+import com.zd.common.core.utils.SpringUtils;
+import com.zd.model.domain.ResultData;
+import com.zd.model.enums.DeviceOnOffEnum;
+import com.zd.model.enums.DeviceStatusEnum;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @创建人 hzw
+ * @描述
+ * @创建时间 2022/11/15
+ */
+@Service
+@Transactional
+public class HardwareRfidServiceImpl extends ServiceImpl<HardwareRfidMapper, HardwareRfid> implements HardwareRfidService {
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Override
+    public int batchInsert(List<HardwareRfid> list) {
+        return baseMapper.batchInsert(list);
+    }
+
+    @Override
+    public ResultData saveHardwareRfid(HardwareRfid hardwareRfid) {
+        if (baseMapper.selectCount(new LambdaQueryWrapper<HardwareRfid>().eq(HardwareRfid::getHardwareNum, hardwareRfid.getHardwareNum())) > 0) {
+            return ResultData.fail("设备编码已存在!");
+        }
+        tokenService.getLoginUser().getSysUser();
+        hardwareRfid.setCreateBy(SecurityUtils.getUsername());
+        hardwareRfid.setUserId(SecurityUtils.getUserId());
+        return ResultData.result(baseMapper.insert(hardwareRfid));
+    }
+
+    @Override
+    public ResultData updateHardwareRfid(HardwareRfid hardwareRfid) {
+        if (hardwareRfid.getId() == null) {
+            return ResultData.fail("设备id不存在!");
+        }
+        if (baseMapper.selectCount(new LambdaQueryWrapper<HardwareRfid>().eq(HardwareRfid::getHardwareNum, hardwareRfid.getHardwareNum()).ne(HardwareRfid::getId, hardwareRfid.getId())) > 0) {
+            return ResultData.fail("设备编码已存在!");
+        }
+        hardwareRfid.setUpdateBy(SecurityUtils.getUsername());
+        return ResultData.result(baseMapper.updateById(hardwareRfid));
+    }
+
+    @Override
+    public Page<HardwareRfid> search(Page<HardwareRfid> page, HardwareRfidVo hardwareRfidVo) {
+        if (StringUtils.isNotBlank(hardwareRfidVo.getSearchValue())) {
+            return baseMapper.selectPage(page, new LambdaQueryWrapper<HardwareRfid>().like(HardwareRfid::getHardwareNum, hardwareRfidVo.getSearchValue()).or().like(HardwareRfid::getDeptName, hardwareRfidVo.getSearchValue()).orderByDesc(HardwareRfid::getCreateTime));
+        }
+        HardwareRfid hardwareRfid = new HardwareRfid();
+        BeanUtils.copyProperties(hardwareRfidVo, hardwareRfid);
+        return baseMapper.selectPage(page, new LambdaQueryWrapper<HardwareRfid>().setEntity(hardwareRfid).orderByDesc(HardwareRfid::getCreateTime));
+    }
+
+    @Override
+    public ResultData startOrStop(Long id) {
+        HardwareRfid hardwareRfid = baseMapper.selectById(id);
+        if (Objects.isNull(hardwareRfid)) {
+            log.error("未查询到相关配置!");
+        }
+        if (DeviceOnOffEnum.ON.getCode().equals(hardwareRfid.getOnOff())) {
+            //开启状态 断开
+            rfidService(hardwareRfid.getManufacturerType()).disconnect(hardwareRfid);
+            hardwareRfid.setOnOff(DeviceOnOffEnum.OFF.getCode());
+            hardwareRfid.setDeviceStatus(DeviceStatusEnum.OFF_LINE.getCode());
+        } else {
+            //关闭状态 打开设备开关 启动
+            rfidService(hardwareRfid.getManufacturerType()).start(hardwareRfid);
+            hardwareRfid.setOnOff(DeviceOnOffEnum.ON.getCode());
+            hardwareRfid.setDeviceStatus(DeviceStatusEnum.ON_LINE.getCode());
+        }
+        if (baseMapper.updateById(hardwareRfid) > 0) {
+            return ResultData.success(hardwareRfid.getOnOff(), "设备已" + DeviceOnOffEnum.getValue(hardwareRfid.getOnOff()));
+        }
+        return ResultData.fail("开启或关闭失败!");
+    }
+
+    private IService rfidService(Integer type) {
+        return SpringUtils.getBean(ManufacturerTypeEnum.matchByValue(type).getService());
+    }
+}

+ 57 - 0
zd-modules/zd-algorithm/src/main/java/com/zd/alg/rfid/service/impl/RfidServiceImpl.java

@@ -0,0 +1,57 @@
+package com.zd.alg.rfid.service.impl;
+
+import com.zd.alg.rfid.enums.ManufacturerTypeEnum;
+import com.zd.alg.rfid.service.IRfidService;
+import com.zd.alg.rfid.service.IService;
+import com.zd.algorithm.api.rfid.domain.entity.HardwareRfid;
+import com.zd.common.core.utils.SpringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.zd.model.constant.BaseConstants.MAP_INIT_SIZE;
+
+
+/**
+ * @author Administrator
+ */
+@Service
+@Slf4j
+public class RfidServiceImpl implements IRfidService {
+
+    private final ThreadPoolTaskExecutor taskExecutor = SpringUtils.getBean("taskExecutor");
+    private final Map<String, Thread> threadMap = new HashMap<>(MAP_INIT_SIZE);
+
+    @Override
+    public void start(HardwareRfid hardwareRfid) {
+        synchronized (this){
+            taskExecutor.execute(() -> {
+                rfidService(hardwareRfid.getManufacturerType()).start(hardwareRfid);
+                log.info("===============thread name:{}===============", Thread.currentThread().getName());
+                threadMap.computeIfAbsent(hardwareRfid.getIpAddress(), f -> Thread.currentThread());
+                log.info("==============>线程数量:{}",threadMap.size());
+            });
+        }
+    }
+
+    @Override
+    public void stop(HardwareRfid hardwareRfid) {
+        rfidService(hardwareRfid.getManufacturerType()).disconnect(hardwareRfid);
+        Thread thread = threadMap.get(hardwareRfid.getIpAddress());
+        if (thread != null && thread.isAlive()) {
+            thread.interrupt();
+            threadMap.remove(hardwareRfid.getIpAddress());
+        }
+    }
+
+    @Override
+    public boolean alarm(HardwareRfid hardwareRfid) {
+       return rfidService(hardwareRfid.getManufacturerType()).alarm(hardwareRfid);
+    }
+    private IService rfidService(Integer type) {
+        return SpringUtils.getBean(ManufacturerTypeEnum.matchByValue(type).getService());
+    }
+}

+ 17 - 22
zd-modules/zd-algorithm/src/main/java/com/zd/alg/netty/service/impl/SendServiceImpl.java

@@ -1,11 +1,12 @@
-package com.zd.alg.netty.service.impl;
+package com.zd.alg.rfid.service.impl;
 
 import com.zd.airbottle.api.feign.RemoteAirBottleService;
-import com.zd.alg.netty.service.ISendService;
+import com.zd.alg.rfid.service.ISendService;
 import com.zd.bottle.feign.service.RemoteBottleService;
 import com.zd.chemical.api.fegin.RemoteStockService;
 import com.zd.model.constant.HttpStatus;
 import com.zd.model.domain.R;
+import com.zd.model.entity.HardwareRfidDto;
 import com.zd.model.entity.InventoryTag;
 import com.zd.model.entity.RemoteLabHardware;
 import lombok.extern.slf4j.Slf4j;
@@ -15,7 +16,7 @@ import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 
-import static com.zd.alg.netty.constant.RfidConstants.*;
+import static com.zd.alg.rfid.constant.RfidConstants.*;
 
 /**
  * @author Administrator
@@ -37,21 +38,15 @@ public class SendServiceImpl implements ISendService {
 
     @Override
     public boolean send(InventoryTag tag) {
-        String serialNumber = tag.getSerialNumber();
-        RemoteLabHardware hardware = tag.getRemoteLabHardware();
-        if (StringUtils.hasLength(serialNumber)){
-            log.info("===============》设备编码:{}",serialNumber);
-            hardware = redisTemplate.opsForValue().get(serialNumber);
-        }
-        if (hardware!=null){
-            log.info("=========ip:{},设备编码:{}=========",hardware.getIpAddress(),serialNumber);
+        HardwareRfidDto hardwareRfidDto = tag.getHardwareRfidDto();
+        if (hardwareRfidDto != null) {
             int antId = tag.getAntId();
-            String uniformPower = hardware.getUniformPower();
+            String uniformPower = hardwareRfidDto.getUniformPower();
             String[] uniformPowers = uniformPower.split(",");
             return handleTag(tag, antId, uniformPowers);
         }
-        log.info("=========未获取到设备信息=========");
-        return sendTag(tag,null);
+        log.error("未获取到设备信息");
+        return sendTag(tag, null);
     }
 
     private boolean handleTag(InventoryTag tag, int antId, String[] uniformPowers) {
@@ -74,14 +69,14 @@ public class SendServiceImpl implements ISendService {
     private boolean sendTag(InventoryTag tag, String temp) {
         if (temp == null) {
             boolean b = sendBottle(tag);
-            if (b){
+            if (b) {
                 return true;
             }
             return sendStock(tag);
         }
         if (ALL_TYPE.equals(temp)) {
             boolean b = sendBottle(tag);
-            if (b){
+            if (b) {
                 return true;
             }
             return sendStock(tag);
@@ -115,19 +110,19 @@ public class SendServiceImpl implements ISendService {
     private boolean sendBottle(InventoryTag tag) {
         R<Boolean> result;
         try {
-            log.info("=====================》气瓶服务开始调用");
+            log.info("======》气瓶服务开始调用");
             result = bottleService.remoteAdd(tag);
-            log.info("气瓶服务调用:" + result.getData());
+            log.info("======》气瓶服务调用结果:{},(true开启报警,false不报警)", result.getData());
             if (result.getCode() == HttpStatus.SUCCESS) {
-               return result.getData();
+                return result.getData();
             }
         } catch (Exception e) {
-            log.info("气瓶服务异常:" + e.getMessage());
+            log.info("气瓶服务异常:{}", e.getMessage());
         }
         try {
-            log.info("=====================》气瓶服务开始调用");
+            log.info("======》气瓶服务开始调用");
             result = remoteBottleService.remoteAdd(tag);
-            log.info("气瓶服务调用:" + result.getData());
+            log.info("======》新气瓶服务调用结果:{},(true开启报警,false不报警)",result.getData());
             if (result.getCode() == HttpStatus.SUCCESS) {
                 return result.getData();
             }

+ 0 - 74
zd-modules/zd-algorithm/src/main/resources/logback.xml

@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <!-- 日志存放路径 -->
-    <property name="log.path" value="logs/zd-algorithm"/>
-    <!-- 日志输出格式 -->
-    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
-
-    <!-- 控制台输出 -->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 系统日志输出 -->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/info.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>INFO</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
-        <!-- 循环政策:基于时间创建日志文件 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- 日志文件名格式 -->
-            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <!-- 过滤的级别 -->
-            <level>ERROR</level>
-            <!-- 匹配时的操作:接收(记录) -->
-            <onMatch>ACCEPT</onMatch>
-            <!-- 不匹配时的操作:拒绝(不记录) -->
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <!-- 系统模块日志级别控制  -->
-    <logger name="com.zd" level="debug"/>
-    <!-- Spring日志级别控制  -->
-    <logger name="org.springframework" level="info"/>
-
-    <root level="debug">
-        <appender-ref ref="console"/>
-    </root>
-
-    <!--系统操作日志-->
-    <root level="info">
-        <appender-ref ref="file_info"/>
-        <appender-ref ref="file_error"/>
-    </root>
-</configuration>

+ 56 - 0
zd-modules/zd-algorithm/src/main/resources/mapper/rfid/HardwareRfidMapper.xml

@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zd.alg.rfid.mapper.HardwareRfidMapper">
+    <resultMap id="BaseResultMap" type="com.zd.algorithm.api.rfid.domain.entity.HardwareRfid">
+        <!--@mbg.generated-->
+        <!--@Table hardware_rfid-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
+        <result column="device_type" jdbcType="TINYINT" property="deviceType"/>
+        <result column="manufacturer_type" jdbcType="TINYINT" property="manufacturerType"/>
+        <result column="hardware_num" jdbcType="VARCHAR" property="hardwareNum"/>
+        <result column="ip_address" jdbcType="VARCHAR" property="ipAddress"/>
+        <result column="port" jdbcType="INTEGER" property="port"/>
+        <result column="uniform_power" jdbcType="VARCHAR" property="uniformPower"/>
+        <result column="session_index" jdbcType="TINYINT" property="sessionIndex"/>
+        <result column="channels" jdbcType="TINYINT" property="channels"/>
+        <result column="on_off" jdbcType="TINYINT" property="onOff"/>
+        <result column="device_status" jdbcType="TINYINT" property="deviceStatus"/>
+        <result column="subject_id" jdbcType="BIGINT" property="subjectId"/>
+        <result column="dept_id" jdbcType="BIGINT" property="deptId"/>
+        <result column="dept_name" jdbcType="VARCHAR" property="deptName"/>
+        <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id, device_name, device_type, manufacturer_type, hardware_num, ip_address, port,
+        uniform_power, session_index, channels, switch, device_status, subject_id, dept_id,
+        dept_name, user_id, create_by, create_time, update_by, update_time, remark
+    </sql>
+    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+        <!--@mbg.generated-->
+        insert into hardware_rfid
+                (device_name, device_type, manufacturer_type, hardware_num, ip_address, port, uniform_power,
+                 session_index, channels, switch, device_status, subject_id, dept_id, dept_name,
+                 user_id, create_by, create_time, update_by, update_time, remark)
+                values
+        <foreach collection="list" item="item" separator=",">
+            (#{item.deviceName,jdbcType=VARCHAR}, #{item.deviceType,jdbcType=SMALLINT},
+             #{item.manufacturerType,jdbcType=TINYINT},
+             #{item.hardwareNum,jdbcType=VARCHAR}, #{item.ipAddress,jdbcType=VARCHAR}, #{item.port,jdbcType=INTEGER},
+             #{item.uniformPower,jdbcType=VARCHAR}, #{item.sessionIndex,jdbcType=BOOLEAN},
+             #{item.channels,jdbcType=TINYINT},
+             #{item.onOff,jdbcType=SMALLINT}, #{item.deviceStatus,jdbcType=SMALLINT}, #{item.subjectId,jdbcType=BIGINT},
+             #{item.deptId,jdbcType=CHAR}, #{item.deptName,jdbcType=VARCHAR}, #{item.userId,jdbcType=BIGINT},
+             #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
+             #{item.updateBy,jdbcType=VARCHAR},
+             #{item.updateTime,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR})
+        </foreach>
+    </insert>
+</mapper>

+ 8 - 12
zd-modules/zd-base/pom.xml

@@ -25,10 +25,10 @@
         </dependency>
 
         <!-- SpringCloud Alibaba Sentinel -->
-        <dependency>
+        <!--<dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
-        </dependency>
+        </dependency>-->
 
         <!-- Mysql Connector -->
         <dependency>
@@ -37,6 +37,11 @@
         </dependency>
 
         <dependency>
+            <groupId>com.zd.swagger</groupId>
+            <artifactId>common-swagger</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>com.zd.core</groupId>
             <artifactId>common-core</artifactId>
             <exclusions>
@@ -137,15 +142,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- 打包时跳过test插件,不运行test测试用例 -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${maven-surefire-plugin.version}</version>
-                <configuration>
-                    <skipTests>true</skipTests>
-                </configuration>
-            </plugin>
         </plugins>
     </build>
-</project>
+</project>

+ 2 - 4
zd-modules/zd-base/src/main/java/com/zd/base/BaseApplicaion.java

@@ -2,18 +2,16 @@ package com.zd.base;
 
 
 import com.zd.common.core.annotation.EnableCustomConfig;
-import com.zd.common.core.annotation.EnableRyFeignClients;
+import com.zd.common.core.annotation.EnableZdFeignClients;
 import com.zd.common.core.launch.ZdStartApplication;
 import com.zd.model.constant.ApplicationConstants;
 import com.zd.model.constant.BaseConstants;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 @EnableCustomConfig
-@EnableRyFeignClients
+@EnableZdFeignClients
 @SpringBootApplication
 @EnableScheduling
 @ComponentScan(basePackages = BaseConstants.BASE_PACKAGE)

+ 14 - 14
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/controller/UploadController.java

@@ -3,8 +3,8 @@ package com.zd.base.files.bigupload.controller;
 
 import com.zd.base.files.bigupload.dto.FileChunkDTO;
 import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
-import com.zd.base.files.bigupload.response.RestApiResponse;
 import com.zd.base.files.bigupload.service.IUploadService;
+import com.zd.model.domain.ResultData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
  * @Version 1.0
  **/
 @RestController
-@RequestMapping("upload")
+@RequestMapping("/file/upload")
 public class UploadController {
 
     @Autowired
@@ -25,14 +25,14 @@ public class UploadController {
      *
      * @return
      */
-    @GetMapping("chunk")
-    public RestApiResponse<Object> checkChunkExist(FileChunkDTO chunkDTO) {
+    @GetMapping("/chunk")
+    public ResultData<Object> checkChunkExist(FileChunkDTO chunkDTO) {
         FileChunkResultDTO fileChunkCheckDTO;
         try {
             fileChunkCheckDTO = uploadService.checkChunkExist(chunkDTO);
-            return RestApiResponse.success(fileChunkCheckDTO);
+            return ResultData.success(fileChunkCheckDTO);
         } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
+            return ResultData.fail(e.getMessage());
         }
     }
 
@@ -43,13 +43,13 @@ public class UploadController {
      * @param chunkDTO
      * @return
      */
-    @PostMapping("chunk")
-    public RestApiResponse<Object> uploadChunk(FileChunkDTO chunkDTO) {
+    @PostMapping("/chunk")
+    public ResultData<Object> uploadChunk(FileChunkDTO chunkDTO) {
         try {
             uploadService.uploadChunk(chunkDTO);
-            return RestApiResponse.success(chunkDTO.getIdentifier());
+            return ResultData.success(chunkDTO.getIdentifier());
         } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
+            return ResultData.fail(e.getMessage());
         }
     }
 
@@ -59,13 +59,13 @@ public class UploadController {
      * @param chunkDTO
      * @return
      */
-    @PostMapping("merge")
-    public RestApiResponse<Object> mergeChunks(@RequestBody FileChunkDTO chunkDTO) {
+    @PostMapping("/merge")
+    public ResultData<Object> mergeChunks(@RequestBody FileChunkDTO chunkDTO) {
         try {
             String filePath = uploadService.mergeChunk(chunkDTO.getIdentifier(), chunkDTO.getFilename(), chunkDTO.getTotalChunks());
-            return RestApiResponse.success(filePath);
+            return ResultData.success(filePath);
         } catch (Exception e) {
-            return RestApiResponse.error(e.getMessage());
+            return ResultData.fail(e.getMessage());
         }
     }
 

+ 0 - 75
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/RestApiResponse.java

@@ -1,75 +0,0 @@
-package com.zd.base.files.bigupload.response;
-
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:37
- * @Version 1.0
- **/
-public class RestApiResponse<T> {
-
-    private int code;
-
-    /**
-     * 是否成功
-     */
-    private boolean success;
-
-    /**
-     * 响应数据
-     */
-    private T data;
-
-    public boolean isSuccess() {
-        return success;
-    }
-
-    public void setSuccess(boolean success) {
-        this.success = success;
-    }
-
-    public T getData() {
-        return data;
-    }
-
-    public void setData(T data) {
-        this.data = data;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public void setCode(int code) {
-        this.code = code;
-    }
-
-    public static <T> RestApiResponse<T> success(T data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = true;
-        result.code=200;
-        result.data = data;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> success() {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = true;
-        result.code=200;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> error(T data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = false;
-        result.code=500;
-        result.data = data;
-        return result;
-    }
-
-    public static <T> RestApiResponse<T> flag(boolean data) {
-        RestApiResponse<T> result = new RestApiResponse<>();
-        result.success = data;
-        return result;
-    }
-}

+ 0 - 29
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BaseErrorCode.java

@@ -1,29 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:40
- * @Version 1.0
- **/
-public interface BaseErrorCode {
-    /**
-     * 获取错误码
-     *
-     * @return
-     */
-    int getErrorCode();
-
-    /**
-     * 获取错误信息
-     *
-     * @return
-     */
-    String getErrorMsg();
-
-    /**
-     * 设置错误信息
-     *
-     * @param errorMsg
-     */
-    void setErrorMsg(String errorMsg);
-}

+ 0 - 42
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessErrorCode.java

@@ -1,42 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:49
- * @Version 1.0
- **/
-public enum BusinessErrorCode implements BaseErrorCode {
-
-    USER_NOT_LOGIN(10001, "用户未登入"),
-    INVALID_PARAMETER(10002, "参数错误");
-
-    /**
-     * 错误消息
-     */
-    private String errorMsg;
-    /**
-     * 错误码
-     */
-    private Integer errorCode;
-
-    BusinessErrorCode(Integer errorCode, String errorMsg) {
-        this.errorMsg = errorMsg;
-        this.errorCode = errorCode;
-    }
-
-    @Override
-    public int getErrorCode() {
-        return this.errorCode;
-    }
-
-    @Override
-    public String getErrorMsg() {
-        return this.errorMsg;
-    }
-
-    @Override
-    public void setErrorMsg(String errorMsg) {
-        this.errorMsg = errorMsg;
-    }
-
-}

+ 0 - 34
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessException.java

@@ -1,34 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:45
- * @Version 1.0
- **/
-public class BusinessException extends Exception {
-
-    private BaseErrorCode errorCode;
-
-    public BusinessException(BaseErrorCode errorCode) {
-        super(errorCode.getErrorMsg());
-        this.errorCode = errorCode;
-    }
-
-    public BusinessException(BaseErrorCode errorCode, String customizedErrorMsg) {
-        super(customizedErrorMsg);
-        this.errorCode = errorCode;
-        errorCode.setErrorMsg(customizedErrorMsg);
-    }
-
-    public static void main(String[] args) throws BusinessException {
-        throw new BusinessException(BusinessErrorCode.USER_NOT_LOGIN);
-    }
-
-    public BaseErrorCode getErrorCode() {
-        return errorCode;
-    }
-
-    public void setErrorCode(BaseErrorCode errorCode) {
-        this.errorCode = errorCode;
-    }
-}

+ 3 - 5
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/IUploadService.java

@@ -3,7 +3,6 @@ package com.zd.base.files.bigupload.service;
 
 import com.zd.base.files.bigupload.dto.FileChunkDTO;
 import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
-import com.zd.base.files.bigupload.response.error.BusinessException;
 
 import java.io.IOException;
 
@@ -21,7 +20,7 @@ public interface IUploadService {
      * @param chunkDTO
      * @return
      */
-    FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException;
+    FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) ;
 
 
     /**
@@ -29,7 +28,7 @@ public interface IUploadService {
      *
      * @param chunkDTO
      */
-    void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException, IOException;
+    void uploadChunk(FileChunkDTO chunkDTO) throws IOException;
 
 
     /**
@@ -39,8 +38,7 @@ public interface IUploadService {
      * @param fileName
      * @param totalChunks
      * @return
-     * @throws BusinessException
      * @throws IOException
      */
-    String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException;
+    String mergeChunk(String identifier, String fileName, Integer totalChunks) throws IOException;
 }

+ 10 - 36
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/impl/UploadServiceImpl.java

@@ -3,15 +3,12 @@ package com.zd.base.files.bigupload.service.impl;
 
 import com.zd.base.files.bigupload.dto.FileChunkDTO;
 import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
-import com.zd.base.files.bigupload.response.error.BusinessErrorCode;
-import com.zd.base.files.bigupload.response.error.BusinessException;
 import com.zd.base.files.bigupload.service.IUploadService;
 import com.zd.base.files.bigupload.utils.FileUtils;
+import com.zd.base.files.file.config.ResourcesConfig;
 import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
@@ -19,6 +16,7 @@ import org.springframework.util.StringUtils;
 import javax.annotation.Resource;
 import java.io.*;
 import java.net.UnknownHostException;
+import java.rmi.ServerException;
 import java.util.*;
 
 
@@ -40,37 +38,13 @@ public class UploadServiceImpl implements IUploadService {
     private RedisTemplate<String, Object> redisTemplate;
 
     /**
-     * 域名或本机访问地址
-     */
-    @Value("${file.domain}")
-    public String domain;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String uploadFolder;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String filePrefix;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.bigFile}")
-    public String bigFile;
-
-    /**
      * 检查文件是否存在,如果存在则跳过该文件的上传,如果不存在,返回需要上传的分片集合
      *
      * @param chunkDTO
      * @return
      */
     @Override
-    public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException {
+    public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) {
         //1.检查文件是否已上传过
         //1.1)检查在磁盘中是否存在
         String fileFolderPath = getFileFolderPath(chunkDTO.getIdentifier());
@@ -99,7 +73,7 @@ public class UploadServiceImpl implements IUploadService {
      * @param chunkDTO
      */
     @Override
-    public void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException {
+    public void uploadChunk(FileChunkDTO chunkDTO) throws ServerException {
         //分块的目录
         String chunkFileFolderPath = getChunkFileFolderPath(chunkDTO.getIdentifier());
         logger.info("分块的目录 -> {}", chunkFileFolderPath);
@@ -118,13 +92,13 @@ public class UploadServiceImpl implements IUploadService {
             //将该分片写入redis
             long size = saveToRedis(chunkDTO);
         } catch (Exception e) {
-            throw new BusinessException(BusinessErrorCode.INVALID_PARAMETER, e.getMessage());
+            throw new ServerException("参数错误" + e.getMessage());
         }
     }
 
 
     @Override
-    public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException {
+    public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws IOException {
         String suffix = fileName.substring(fileName.lastIndexOf("."));
         if(null==suffix){
             throw new RuntimeException("文件格式有误");
@@ -194,7 +168,7 @@ public class UploadServiceImpl implements IUploadService {
             urlPrefix = urlPrefix.replace(localIP, ip);
         }
         String url = urlPrefix + filePrefix+"/"+bigFile+"/"+ FileUtils.getFormatter() + "/" + fileName;*/
-        String url = filePrefix+"/"+bigFile+"/"+ FileUtils.getFormatter() + "/" + fileName;
+        String url = ResourcesConfig.filePrefix+"/bigFile/"+ FileUtils.getFormatter() + "/" + fileName;
         return url.replace("//","/").replace("./",".//");
     }
 
@@ -252,7 +226,7 @@ public class UploadServiceImpl implements IUploadService {
      */
     private String getFilePath(String identifier, String filename) {
         String ext = filename.substring(filename.lastIndexOf("."));
-        String filePath=uploadFolder +"/"+bigFile+"/"+ FileUtils.getFormatter();
+        String filePath= ResourcesConfig.filePath +"/bigFile/"+ FileUtils.getFormatter();
         File file = new File(filePath);
         if (!file.exists()) {
             file.mkdirs();
@@ -289,7 +263,7 @@ public class UploadServiceImpl implements IUploadService {
 
 
     private String getPrefixFileFolderPath(String identifier) {
-        String prefixFile=uploadFolder +"/"+filePrefix+"/"+bigFile +"/"+identifier.substring(0, 1);
+        String prefixFile=ResourcesConfig.filePath +"/"+ResourcesConfig.filePrefix+"/bigFile/"+identifier.substring(0, 1);
         return prefixFile.replace("//","/");
     }
 
@@ -300,7 +274,7 @@ public class UploadServiceImpl implements IUploadService {
      * @return
      */
     private String getFileFolderPath(String identifier) {
-        String fileFolderPath=uploadFolder+"/"+filePrefix+"/"+bigFile+"/"+identifier.substring(0, 1) + File.separator +
+        String fileFolderPath=ResourcesConfig.filePath +"/"+ResourcesConfig.filePrefix+"/bigFile/"+identifier.substring(0, 1) + File.separator +
                 identifier.substring(1, 2) + File.separator +
                 identifier + File.separator;
         return fileFolderPath.replace("//","/");

+ 21 - 11
zd-modules/zd-base/src/main/java/com/zd/base/files/file/config/ResourcesConfig.java

@@ -17,23 +17,33 @@ import java.io.File;
 @Configuration
 @RefreshScope
 public class ResourcesConfig implements WebMvcConfigurer {
-    /**
-     * 上传文件存储在本地的根路径
-     */
+
+    public static String filePath;
+
+    public static String filePrefix;
+
+    public static String fileDomain;
+
     @Value("${file.path}")
-    private String localFilePath;
+    public void setFilePath(String filePath) {
+        ResourcesConfig.filePath = filePath;
+    }
 
-    /**
-     * 资源映射路径 前缀
-     */
     @Value("${file.prefix}")
-    public String localFilePrefix;
+    public void setFilePrefix(String filePrefix) {
+        ResourcesConfig.filePrefix = filePrefix;
+    }
+
+    @Value("${file.domain}")
+    public void setFileDomain(String fileDomain) {
+        ResourcesConfig.fileDomain = fileDomain;
+    }
 
     @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {
         /** 本地文件上传路径 */
-        registry.addResourceHandler(localFilePrefix + "/**")
-                .addResourceLocations("file:" + localFilePath + File.separator);
+        registry.addResourceHandler(ResourcesConfig.filePrefix + "/**")
+                .addResourceLocations("file:" + ResourcesConfig.filePath + File.separator);
     }
 
     /**
@@ -42,7 +52,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
     @Override
     public void addCorsMappings(CorsRegistry registry) {
         // 设置允许跨域的路由
-        registry.addMapping(localFilePrefix + "/**")
+        registry.addMapping(ResourcesConfig.filePrefix + "/**")
                 // 设置允许跨域请求的域名
                 .allowedOrigins("*")
                 // 设置允许的方法

+ 2 - 0
zd-modules/zd-base/src/main/java/com/zd/base/files/file/controller/SysFileController.java

@@ -8,6 +8,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -17,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
  * @author zd
  */
 @RestController
+@RequestMapping("/file")
 public class SysFileController {
     private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
 

+ 3 - 20
zd-modules/zd-base/src/main/java/com/zd/base/files/file/service/LocalSysFileServiceImpl.java

@@ -1,8 +1,8 @@
 package com.zd.base.files.file.service;
 
 
+import com.zd.base.files.file.config.ResourcesConfig;
 import com.zd.base.files.file.utils.FileUploadUtils;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -15,23 +15,6 @@ import org.springframework.web.multipart.MultipartFile;
 @Primary
 @Service
 public class LocalSysFileServiceImpl implements ISysFileService {
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-    /**
-     * 域名或本机访问地址
-     */
-    @Value("${file.domain}")
-    public String domain;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
 
     /**
      * 本地文件上传接口
@@ -42,7 +25,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
      */
     @Override
     public String uploadFile(MultipartFile file) throws Exception {
-        String name = FileUploadUtils.upload(localFilePath, file);
+        String name = FileUploadUtils.upload(ResourcesConfig.filePath, file);
         //TODO 去掉拼接前缀
 //        String urlPrefix = domain;
 //        String localIP = "127.0.0.1";
@@ -50,7 +33,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
 //            String ip = InetAddress.getLocalHost().getHostAddress();;
 //            urlPrefix = urlPrefix.replace(localIP, ip);
 //        }
-        String url =localFilePrefix + name;
+        String url =ResourcesConfig.filePrefix + name;
         return url;
     }
 }

+ 2 - 13
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ActionEnter.java

@@ -13,28 +13,17 @@ import java.util.Map;
 
 public class ActionEnter {
     private HttpServletRequest request;
-    private String rootPath;
-    private String contextPath;
     private String actionType;
-    private String localFilePath;
     private String localFilePrefix;
     private String domain;
     private ConfigManager configManager;
 
-    public ActionEnter(HttpServletRequest request, String rootPath,String localFilePath,String localFilePrefix,String domain) {
-        this.request = null;
-        this.rootPath = null;
-        this.contextPath = null;
-        this.actionType = null;
-        this.configManager = null;
-        this.localFilePath=localFilePath;
+    public ActionEnter(HttpServletRequest request, String localFilePath,String localFilePrefix,String domain) {
         this.localFilePrefix=localFilePrefix;
         this.domain=domain;
         this.request = request;
-        this.rootPath = rootPath;
         this.actionType = request.getParameter("action");
-        this.contextPath = request.getContextPath();
-        this.configManager = ConfigManager.getInstance(this.rootPath, this.contextPath, request.getRequestURI(),localFilePath);
+        this.configManager = ConfigManager.getInstance(localFilePath);
     }
 
     public String exec() {

+ 13 - 31
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ConfigManager.java

@@ -2,39 +2,26 @@ package com.zd.base.files.ueditor;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+
 import java.io.*;
 import java.util.HashMap;
 import java.util.Map;
 
 public class ConfigManager {
     private String rootPath;
-    private String originalPath;
-    private String contextPath;
-    private String realPath;
-    private static String configFileName = "config.json";
-    private String parentPath;
+    private String localPath;
     private JSONObject jsonConfig;
-    private static String SCRAWL_FILE_NAME = "scrawl";
-    private static String REMOTE_FILE_NAME = "remote";
 
-    private ConfigManager(String rootPath, String contextPath, String uri,String realPath) throws FileNotFoundException, IOException {
-        this.parentPath = null;
-        this.jsonConfig = null;
-        rootPath = rootPath.replace("\\", "/");
-        this.rootPath = rootPath;
-        this.realPath = realPath;
-        this.contextPath = contextPath;
-        if (contextPath.length() > 0) {
-            this.originalPath = this.rootPath + uri.substring(contextPath.length());
-        } else {
-            this.originalPath = this.rootPath + uri;
-        }
+    private ConfigManager(String localPath) throws IOException {
+        this.rootPath = this.getClass().getClassLoader().getResource("ueditor").getPath();
+
+        this.localPath = localPath;
         this.initEnv();
     }
 
-    public static ConfigManager getInstance(String rootPath, String contextPath, String uri,String realPath) {
+    public static ConfigManager getInstance(String realPath) {
         try {
-            return new ConfigManager(rootPath, contextPath, uri,realPath);
+            return new ConfigManager(realPath);
         } catch (Exception e) {
             return null;
         }
@@ -49,7 +36,7 @@ public class ConfigManager {
     }
 
     public Map<String, Object> getConfig(int type) {
-        Map<String, Object> conf = new HashMap<String, Object>();
+        Map<String, Object> conf = new HashMap<>();
         String savePath = null;
         switch (type) {
             case 4: {
@@ -106,16 +93,11 @@ public class ConfigManager {
             }
         }
         conf.put("savePath", savePath);
-        conf.put("rootPath", this.realPath);
+        conf.put("rootPath", this.localPath);
         return conf;
     }
 
-    private void initEnv() throws FileNotFoundException, IOException {
-        File file = new File(this.originalPath);
-        if (!file.isAbsolute()) {
-            file = new File(file.getAbsolutePath());
-        }
-        this.parentPath = file.getParent();
+    private void initEnv() throws IOException {
         String configContent = this.readFile(this.getConfigPath());
         try {
             JSONObject jsonConfig = JSONObject.parseObject(configContent);
@@ -126,7 +108,7 @@ public class ConfigManager {
     }
 
     private String getConfigPath() {
-        return String.valueOf(this.parentPath) + File.separator + "config.json";
+        return this.rootPath + File.separator + "config.json";
     }
 
     private String[] getArray(String key) {
@@ -143,7 +125,7 @@ public class ConfigManager {
         try {
             InputStreamReader reader = new InputStreamReader(new FileInputStream(path), "UTF-8");
             BufferedReader bfReader = new BufferedReader(reader);
-            String tmpContent = null;
+            String tmpContent ;
             while ((tmpContent = bfReader.readLine()) != null) {
                 builder.append(tmpContent);
             }

+ 0 - 23
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/SpringUtil.java

@@ -1,23 +0,0 @@
-package com.zd.base.files.ueditor;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SpringUtil implements ApplicationContextAware {
-
-    private static ApplicationContext applicationContext;
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        if (SpringUtil.applicationContext == null) {
-            SpringUtil.applicationContext = applicationContext;
-        }
-    }
-
-    public static ApplicationContext getApplicationContext() {
-        return applicationContext;
-    }
-}

+ 2 - 22
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/contorller/UeditorController.java

@@ -1,8 +1,8 @@
 package com.zd.base.files.ueditor.contorller;
 
 import com.alibaba.fastjson.JSONException;
+import com.zd.base.files.file.config.ResourcesConfig;
 import com.zd.base.files.ueditor.ActionEnter;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -19,32 +19,12 @@ import java.io.PrintWriter;
 @Controller
 public class UeditorController {
 
-    @Value("${file.config}")
-    private String rootConfig;
-
-    /**
-     * 上传文件存储在本地的根路径
-     */
-    @Value("${file.path}")
-    private String localFilePath;
-
-    /**
-     * 资源映射路径 前缀
-     */
-    @Value("${file.prefix}")
-    public String localFilePrefix;
-
-
-    @Value("${file.domain}")
-    public String domain;
-
-
     @RequestMapping("exec")
     public void getConfigInfo(HttpServletRequest request, HttpServletResponse response) {
         try {
             request.setCharacterEncoding("utf-8");
             response.setContentType("application/json");
-            String exec = new ActionEnter(request, rootConfig,localFilePath,localFilePrefix,domain).exec();
+            String exec = new ActionEnter(request, ResourcesConfig.filePath , ResourcesConfig.filePrefix, ResourcesConfig.fileDomain).exec();
             PrintWriter writer = response.getWriter();
             writer.write(exec);
             writer.flush();

+ 0 - 8
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionMap.java

@@ -5,14 +5,6 @@ import java.util.Map;
 
 public final class ActionMap {
     public static final Map<String, Integer> mapping;
-    public static final int CONFIG = 0;
-    public static final int UPLOAD_IMAGE = 1;
-    public static final int UPLOAD_SCRAWL = 2;
-    public static final int UPLOAD_VIDEO = 3;
-    public static final int UPLOAD_FILE = 4;
-    public static final int CATCH_IMAGE = 5;
-    public static final int LIST_FILE = 6;
-    public static final int LIST_IMAGE = 7;
 
     static {
         mapping = new HashMap<String, Integer>() {

+ 0 - 8
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionState.java

@@ -1,8 +0,0 @@
-package com.zd.base.files.ueditor.define;
-
-public enum ActionState {
-    UNKNOW_ERROR("UNKNOW_ERROR", 0);
-
-    private ActionState(String s,int n) {
-    }
-}

+ 0 - 17
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/AppInfo.java

@@ -4,23 +4,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 public final class AppInfo {
-    public static final int SUCCESS = 0;
-    public static final int MAX_SIZE = 1;
-    public static final int PERMISSION_DENIED = 2;
-    public static final int FAILED_CREATE_FILE = 3;
-    public static final int IO_ERROR = 4;
-    public static final int NOT_MULTIPART_CONTENT = 5;
-    public static final int PARSE_REQUEST_ERROR = 6;
-    public static final int NOTFOUND_UPLOAD_DATA = 7;
-    public static final int NOT_ALLOW_FILE_TYPE = 8;
-    public static final int INVALID_ACTION = 101;
-    public static final int CONFIG_ERROR = 102;
-    public static final int PREVENT_HOST = 201;
-    public static final int CONNECTION_ERROR = 202;
-    public static final int REMOTE_FAIL = 203;
-    public static final int NOT_DIRECTORY = 301;
-    public static final int NOT_EXIST = 302;
-    public static final int ILLEGAL = 401;
     public static Map<Integer, String> info;
 
     static {

+ 0 - 0
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/FileType.java


部分文件因文件數量過多而無法顯示