Ver código fonte

修改对应实体类的类型

nahida 1 ano atrás
pai
commit
e3a453b828
21 arquivos alterados com 98 adições e 31 exclusões
  1. 5 0
      pole-service/pom.xml
  2. 1 0
      pole-service/src/main/java/com/zksy/pole/MQTTServer/callBack/BootNettyMqttMsgBack.java
  3. 21 0
      pole-service/src/main/java/com/zksy/pole/config/RedissonConfig.java
  4. 1 1
      pole-service/src/main/java/com/zksy/pole/domain/dto/BaseDto.java
  5. 3 3
      pole-service/src/main/java/com/zksy/pole/domain/dto/DelRelayTimingDto.java
  6. 2 2
      pole-service/src/main/java/com/zksy/pole/domain/dto/DelScenarioStrategyDto.java
  7. 1 1
      pole-service/src/main/java/com/zksy/pole/domain/dto/QueryRelayTimingDto.java
  8. 2 2
      pole-service/src/main/java/com/zksy/pole/domain/dto/RelayControlDetailDto.java
  9. 2 2
      pole-service/src/main/java/com/zksy/pole/domain/dto/RelayTimingDetailDto.java
  10. 4 4
      pole-service/src/main/java/com/zksy/pole/domain/dto/RelayTimingDto.java
  11. 1 1
      pole-service/src/main/java/com/zksy/pole/domain/dto/ReportEnvironmentalDataDto.java
  12. 3 3
      pole-service/src/main/java/com/zksy/pole/domain/dto/ScenarioStrategyDetailDto.java
  13. 3 3
      pole-service/src/main/java/com/zksy/pole/domain/dto/ScenarioStrategyDto.java
  14. 1 1
      pole-service/src/main/java/com/zksy/pole/domain/dto/SetGatewayTimeDto.java
  15. 2 0
      pole-service/src/main/java/com/zksy/pole/factory/IHandleCmd.java
  16. 1 0
      pole-service/src/main/java/com/zksy/pole/factory/impl/HandleDgTimelyControlCmd.java
  17. 7 1
      pole-service/src/main/java/com/zksy/pole/service/impl/InstructionIssuanceServerImpl.java
  18. 2 7
      pole-service/src/main/resources/bootstrap.yaml
  19. 6 0
      pom.xml
  20. 5 0
      zksy-common/pom.xml
  21. 25 0
      zksy-common/src/main/java/com/zksy/common/utils/RedisUtils.java

+ 5 - 0
pole-service/pom.xml

@@ -91,6 +91,11 @@
             <groupId>io.netty</groupId>
             <artifactId>netty-all</artifactId>
         </dependency>
+        <!--redisson依赖-->
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 1 - 0
pole-service/src/main/java/com/zksy/pole/MQTTServer/callBack/BootNettyMqttMsgBack.java

@@ -93,6 +93,7 @@ public class BootNettyMqttMsgBack {
         String data = new String(headBytes);
         System.out.println("收到数据-->"+data);
 		String jsonRes = handleCmdFactory.HandleCmd(data);
+
 		//重置读取的指针
 		mqttPublishMessage.payload().resetReaderIndex();
 		//(qos= 0最多一次的传输,1至少一次的传输,2: 只有一次的传输)

+ 21 - 0
pole-service/src/main/java/com/zksy/pole/config/RedissonConfig.java

@@ -0,0 +1,21 @@
+package com.zksy.pole.config;
+
+import org.redisson.Redisson;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RedissonConfig {
+    @Value("${redisson.host}")
+    public String host;
+    @Bean
+    public RedissonClient redissonClient(){
+        Config config = new Config();
+        config.useSingleServer().setAddress(host);
+        return Redisson.create(config);
+    }
+}

+ 1 - 1
pole-service/src/main/java/com/zksy/pole/domain/dto/BaseDto.java

@@ -15,7 +15,7 @@ import lombok.Data;
 @ApiModel(value = "公共参数")
 public abstract class BaseDto {
     @ApiModelProperty(value = "命令")
-    private String cmd;
+    private Integer cmd;
     @ApiModelProperty(value = "包id")
     private String packageId;
     @ApiModelProperty(value = "灯编号")

+ 3 - 3
pole-service/src/main/java/com/zksy/pole/domain/dto/DelRelayTimingDto.java

@@ -17,9 +17,9 @@ import java.util.List;
 @ApiModel(value = "删除继电器定时策略设置dto")
 public class DelRelayTimingDto extends BaseDto{
     @ApiModelProperty(value = "继电器编号")
-    private String index;
+    private Integer index;
     @ApiModelProperty(value = "策略编号")
-    private String id;
+    private Integer id;
     @ApiModelProperty(value = "1代表继电器编号下的所有定时器都删除,0代表只删除上面继电器编号的id=策略编号的定时器")
-    private String tag;
+    private Integer tag;
 }

+ 2 - 2
pole-service/src/main/java/com/zksy/pole/domain/dto/DelScenarioStrategyDto.java

@@ -17,7 +17,7 @@ import java.util.List;
 @ApiModel(value = "删除场景策略设置dto")
 public class DelScenarioStrategyDto extends BaseDto{
     @ApiModelProperty(value = "策略编号")
-    private String id;
+    private Integer id;
     @ApiModelProperty(value = "1代表灯编号下的所有定时器都删除,0代表只删除上面灯编号的id=策略编号的定时器")
-    private String tag;
+    private Integer tag;
 }

+ 1 - 1
pole-service/src/main/java/com/zksy/pole/domain/dto/QueryRelayTimingDto.java

@@ -15,5 +15,5 @@ import lombok.Data;
 @ApiModel(value = "查询继电器定时策略dto")
 public class QueryRelayTimingDto extends BaseDto{
     @ApiModelProperty(value = "继电器编号 1-5")
-    private String index;
+    private Integer index;
 }

+ 2 - 2
pole-service/src/main/java/com/zksy/pole/domain/dto/RelayControlDetailDto.java

@@ -15,7 +15,7 @@ import lombok.Data;
 @ApiModel(value = "继电器控制详情dto")
 public class RelayControlDetailDto {
     @ApiModelProperty(value = "继电器编号")
-    private String index;
+    private Integer index;
     @ApiModelProperty(value = "继电器状态")
-    private String val;
+        private Integer val;
 }

+ 2 - 2
pole-service/src/main/java/com/zksy/pole/domain/dto/RelayTimingDetailDto.java

@@ -17,9 +17,9 @@ import java.util.List;
 @ApiModel(value = "继电器定时策略设置详情dto")
 public class RelayTimingDetailDto {
     @ApiModelProperty(value = "0 断开 1闭合")
-    private String val;
+    private Integer val;
     @ApiModelProperty(value = "bit0-bit6 分别对应周日到周六 循环定时有效")
-    private String week;
+    private Integer week;
     @ApiModelProperty(value = "小时:分,代表5点5分 循环定时有效。\"2020-05-26 15:55\",单次定时有效,time根据策略类型来设置")
     private String time;
 }

+ 4 - 4
pole-service/src/main/java/com/zksy/pole/domain/dto/RelayTimingDto.java

@@ -17,13 +17,13 @@ import java.util.List;
 @ApiModel(value = "继电器定时策略设置dto")
 public class RelayTimingDto extends BaseDto{
     @ApiModelProperty(value = "继电器编号")
-    private String index;
+    private Integer index;
     @ApiModelProperty(value = "策略编号")
-    private String id;
+    private Integer id;
     @ApiModelProperty(value = "策略类型 0循环定时 1单次定时")
-    private String type;
+    private Integer type;
     @ApiModelProperty(value = "策略状态 0禁止 1启用")
-    private String status;
+    private Integer status;
     @ApiModelProperty(value = "策略有效时间年-月-日-小时-分")
     private String startTime;
     @ApiModelProperty(value = "策略失效时间年-月-日-小时-分")

+ 1 - 1
pole-service/src/main/java/com/zksy/pole/domain/dto/ReportEnvironmentalDataDto.java

@@ -15,5 +15,5 @@ import lombok.Data;
 @ApiModel(value = "灯具及时控制参数dto")
 public class ReportEnvironmentalDataDto extends BaseDto{
     @ApiModelProperty(value = "亮度")
-    private String brightness;
+    private Integer brightness;
 }

+ 3 - 3
pole-service/src/main/java/com/zksy/pole/domain/dto/ScenarioStrategyDetailDto.java

@@ -15,12 +15,12 @@ import lombok.Data;
 @ApiModel(value = "场景策略设置明细dto")
 public class ScenarioStrategyDetailDto {
     @ApiModelProperty(value = "亮度值0-100")
-    private String brightness;
+    private Integer brightness;
     @ApiModelProperty(value = "bit0-bit6 分别对应周日到周六 循环定时有效")
-    private String week;
+    private Integer week;
     @ApiModelProperty(value = "小时:分,示例:代表5点5分 循环定时有效。2020-05-26 15:55,单次定时有效,time根据策略类型来设置")
     private String time;
     @ApiModelProperty(value = "分钟,type=2,3有效。正负120分钟内")
-    private String offset;
+    private Integer offset;
     
 }

+ 3 - 3
pole-service/src/main/java/com/zksy/pole/domain/dto/ScenarioStrategyDto.java

@@ -17,11 +17,11 @@ import java.util.List;
 @ApiModel(value = "场景策略设置dto")
 public class ScenarioStrategyDto extends BaseDto{
     @ApiModelProperty(value = "策略编号")
-    private String id;
+    private Integer id;
     @ApiModelProperty(value = "策略类型 0循环定时 1单次定时2日出 3日落")
-    private String type;
+    private Integer type;
     @ApiModelProperty(value = "策略状态 0禁止 1启用")
-    private String status;
+    private Integer status;
     @ApiModelProperty(value = "策略有效时间年-月-日-小时-分")
     private String start_time;
     @ApiModelProperty(value = "策略失效时间年-月-日-小时-分")

+ 1 - 1
pole-service/src/main/java/com/zksy/pole/domain/dto/SetGatewayTimeDto.java

@@ -15,5 +15,5 @@ import lombok.Data;
 @ApiModel(value = "设置网关时间dto")
 public class SetGatewayTimeDto extends BaseDto{
     @ApiModelProperty(value = "时间戳")
-    private String timestamp;
+    private Integer timestamp;
 }

+ 2 - 0
pole-service/src/main/java/com/zksy/pole/factory/IHandleCmd.java

@@ -1,5 +1,7 @@
 package com.zksy.pole.factory;
 
+import cn.hutool.json.JSONObject;
+
 public interface IHandleCmd {
     <T> String HandleCmdMethod(T data);
 }

+ 1 - 0
pole-service/src/main/java/com/zksy/pole/factory/impl/HandleDgTimelyControlCmd.java

@@ -25,4 +25,5 @@ public class HandleDgTimelyControlCmd implements IHandleCmd {
             return null;
         }
     }
+
 }

+ 7 - 1
pole-service/src/main/java/com/zksy/pole/service/impl/InstructionIssuanceServerImpl.java

@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONObject;
 import com.zksy.pole.MQTTServer.request.MqttRequest;
 import com.zksy.pole.MQTTServer.server.MQTTServer;
 import com.zksy.pole.domain.dto.*;
+import com.zksy.pole.factory.HandleCmdFactory;
 import com.zksy.pole.service.InstructionIssuanceServer;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelId;
 import io.netty.handler.codec.mqtt.*;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -25,13 +27,17 @@ import java.util.Map;
 @Service
 public class InstructionIssuanceServerImpl implements InstructionIssuanceServer {
     private static final Map<String,Object> msgMap= new HashMap<>();
-
     @Override
     public String instructionIssuance(ReportEnvironmentalDataDto dto) {
         Map<String, Object> fields = new HashMap<>();
         fields.put("light_nums",dto.getLightNums());
         fields.put("brightness",dto.getBrightness());
         sendMqttMessage(dto,fields);
+        System.out.println("dto------>"+dto.getCmd());
+        System.out.println("dto------>"+dto.getBrightness());
+        System.out.println("dto------>"+dto.getLightNums());
+        System.out.println("dto------>"+dto.getPackageId());
+        System.out.println("f------->"+fields);
         return "ok";
     }
 

+ 2 - 7
pole-service/src/main/resources/bootstrap.yaml

@@ -20,10 +20,5 @@ spring:
           - dataId: pole-service.yaml
           - dataId: zksy-shared-jdbc.yaml
           - dataId: zksy-shared-log.yaml
-  redis:
-    host: 192.168.110.30
-    port: 6379
-
-
-
-
+redisson:
+  host: redis://192.168.110.30:6379

+ 6 - 0
pom.xml

@@ -42,6 +42,7 @@
         <minioutil.version>1.0.0</minioutil.version>
         <mqtt.version>5.5.9</mqtt.version>
         <netty.version>4.1.75.Final</netty.version>
+        <redisson.version>3.13.6</redisson.version>
     </properties>
 
     <dependencyManagement>
@@ -113,6 +114,11 @@
                 <artifactId>netty-all</artifactId>
                 <version>${netty.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.redisson</groupId>
+                <artifactId>redisson</artifactId>
+                <version>${redisson.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 5 - 0
zksy-common/pom.xml

@@ -91,5 +91,10 @@
             <artifactId>jackson-dataformat-xml</artifactId>
             <scope>provided</scope>
         </dependency>
+        <!--redis依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 25 - 0
zksy-common/src/main/java/com/zksy/common/utils/RedisUtils.java

@@ -0,0 +1,25 @@
+package com.zksy.common.utils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RedisUtils {
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+    public void set(String key, Object value) {
+        redisTemplate.opsForValue().set(key, value);
+    }
+    public Object get(String key) {
+        return redisTemplate.opsForValue().get(key);
+    }
+    public void delete(String key) {
+        redisTemplate.delete(key);
+    }
+    public void delete(String... keys) {
+        for (String key : keys) {
+            delete(key);
+        }
+    }
+}