From 5e538429fe5a230344bbb1906ec58577cc2684e3 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期五, 10 十一月 2023 21:06:52 +0800
Subject: [PATCH] 提交配置

---
 /dev/null                                                                   |  126 -------------------------------
 src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java                   |    2 
 src/main/resources/logback-spring.xml                                       |    4 
 src/main/resources/application-proGateway.yml                               |   41 +++++----
 src/main/java/com/fzzy/gateway/GatewayUtils.java                            |   19 ++++
 src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java     |    2 
 pom.xml                                                                     |   12 --
 src/main/java/com/fzzy/api/data/GatewayDeviceType.java                      |    2 
 src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java |   15 +++
 src/main/resources/application.yml                                          |    2 
 10 files changed, 61 insertions(+), 164 deletions(-)

diff --git a/pom.xml b/pom.xml
index 42d0362..07b8061 100644
--- a/pom.xml
+++ b/pom.xml
@@ -357,6 +357,7 @@
 			<plugin>
 				<groupId>org.springframework.boot</groupId>
 				<artifactId>spring-boot-maven-plugin</artifactId>
+				<version>2.7.9</version>
 				<executions>
 					<execution>
 						<goals>
@@ -365,17 +366,6 @@
 					</execution>
 				</executions>
 			</plugin>
-<!--			<plugin>-->
-<!--				<groupId>org.springframework.boot</groupId>-->
-<!--				<artifactId>spring-boot-maven-plugin</artifactId>-->
-<!--				<executions>-->
-<!--					<execution>-->
-<!--						<goals>-->
-<!--							<goal>repackage</goal>-->
-<!--						</goals>-->
-<!--					</execution>-->
-<!--				</executions>-->
-<!--			</plugin>-->
 
 		</plugins>
 
diff --git a/src/main/java/com/fzzy/api/data/GatewayDeviceType.java b/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
index 41243a7..db840d4 100644
--- a/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
+++ b/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
@@ -19,6 +19,7 @@
     TYPE_06("TYPE_06", "瑙嗛瀹夐槻鎽勫儚澶�"),
     TYPE_07("TYPE_07", "绮儏鍒嗘満"),
     TYPE_08("TYPE_08", "妗岄潰鎶撴媿鎽勫儚澶�"),
+    TYPE_09("TYPE_09", "搴撳尯姘旇薄绔�"),
     TYPE_99("TYPE_99", "鐙珛IOT");
 
 
@@ -36,6 +37,7 @@
         list.add(new ApiTrigger(TYPE_06.getCode(), TYPE_06.getName()));
         list.add(new ApiTrigger(TYPE_07.getCode(), TYPE_07.getName()));
         list.add(new ApiTrigger(TYPE_08.getCode(), TYPE_08.getName()));
+        list.add(new ApiTrigger(TYPE_09.getCode(), TYPE_09.getName()));
         list.add(new ApiTrigger(TYPE_99.getCode(), TYPE_99.getName()));
         return list;
     }
diff --git a/src/main/java/com/fzzy/gateway/GatewayUtils.java b/src/main/java/com/fzzy/gateway/GatewayUtils.java
index dbecd80..7704a2f 100644
--- a/src/main/java/com/fzzy/gateway/GatewayUtils.java
+++ b/src/main/java/com/fzzy/gateway/GatewayUtils.java
@@ -1,13 +1,17 @@
 package com.fzzy.gateway;
 
 import com.fzzy.gateway.entity.GatewayDevice;
+import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
  * 甯搁噺
  */
+@Component
 public class GatewayUtils {
 
 
@@ -41,6 +45,21 @@
         return cacheMapDeviceSn.get(deviceSn);
     }
 
+    public static List<GatewayDevice> getCacheByDeviceType(String deviceType) {
+        List<GatewayDevice> result = new ArrayList<>();
+        for (GatewayDevice device : cacheMapDeviceId.values()) {
+            if (deviceType.equals(device.getType())) result.add(device);
+        }
+        return result;
+    }
+
+    public static GatewayDevice getCacheByDeviceTypeOne(String deviceType) {
+        for (GatewayDevice device : cacheMapDeviceId.values()) {
+            if (deviceType.equals(device.getType())) return device;
+        }
+        return null;
+    }
+
 
     public static void removeCache(GatewayDevice data) {
         cacheMapDeviceId.remove(data.getDeviceId());
diff --git a/src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java b/src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java
index 90a1c85..6bde012 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java
@@ -22,7 +22,7 @@
 
     private String timestamp;
 
-    private GrainOutPut outPut;
+    private GrainOutPut output;
 
     private GrainWeather weatherStation;
 
diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java b/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java
index e7b4560..6c32715 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java
@@ -63,11 +63,11 @@
         syncReqData.setAutoReplay(true);
         syncReqData.setDevice(device);
 
-
         BaseResp resp;
         if (GatewayDeviceProtocol.DEVICE_TEST.getCode().equals(device.getSyncProtocol())) {
             resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(syncReqData);
         } else {
+            syncReqData.setAutoReplay(false);
             resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain(syncReqData);
         }
 
diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java b/src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java
index 7cfcb3e..3bd840c 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/service/ScGatewayTestServiceImpl.java
@@ -1,12 +1,13 @@
 package com.fzzy.gateway.hx2023.service;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.fzzy.api.data.GatewayDeviceType;
 import com.fzzy.api.data.PushProtocol;
 import com.fzzy.api.utils.DateUtil;
 import com.fzzy.api.utils.NumberUtil;
 import com.fzzy.async.fzzy40.Fzzy40CommonService;
 import com.fzzy.async.fzzy40.entity.Fz40Grain;
-import com.fzzy.gateway.api.GatewayDeviceReportService;
+import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.api.GatewayDeviceTestService;
 import com.fzzy.gateway.data.BaseReqData;
 import com.fzzy.gateway.data.BaseResp;
@@ -341,12 +342,20 @@
 
         outPut.setTemperature(temperature);
 
-        grain.setOutPut(outPut);
+        grain.setOutput(outPut);
+
+
+        GatewayDevice gatewayDeviceWeather = GatewayUtils.getCacheByDeviceTypeOne(GatewayDeviceType.TYPE_09.getCode());
 
         //姘旇薄淇℃伅
         GrainWeather weatherStation = new GrainWeather();
         weatherStation.setMessageId(ScConstant.getMessageId());
-        weatherStation.setId(device.getDeviceId());
+
+        if (null != gatewayDeviceWeather) {
+            weatherStation.setId(gatewayDeviceWeather.getDeviceId());
+        } else {
+            weatherStation.setId(device.getDeviceId());
+        }
         weatherStation.setAirPressure(weather.getPressure());
         weatherStation.setHumidity(weather.getHumidity());
         weatherStation.setPm(weather.getAir_pm25());
diff --git a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageReport.java b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageReport.java
deleted file mode 100644
index a59ba47..0000000
--- a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageReport.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.fzzy.gateway.hx2023.websocket;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-
-
-/**
- * 涓嬪彂璋冪敤绮俯妫�娴嬫帴鍙f寚浠� topic
- */
-@Slf4j
-@Component
-@ServerEndpoint(value = "/{productId}/{deviceId}/properties/report")
-public class WebSockDeviceMessageReport {
-
-    @OnOpen
-    public void onOpen(Session session,
-                       @PathParam("productId") String productId,
-                       @PathParam("deviceId") String deviceId
-    ) throws Exception {
-
-        log.info("--------涓嬪彂璋冪敤绮俯妫�娴嬫帴鍙f寚浠� topic------");
-    }
-
-    @OnClose
-    public void onClose() {
-
-        log.info("WebSocket杩炴帴鍏抽棴={}");
-    }
-
-    /**
-     * 鏀跺埌鍓嶇鍙戦�佺殑淇℃伅
-     *
-     * @param message
-     * @param session
-     */
-    @OnMessage
-    public void onMessage(String message, Session session) {
-
-        log.info("鏉ヨ嚜鍓嶇鐨勪俊鎭�:\n" + message);
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        log.error("鍙戠敓閿欒");
-    }
-}
diff --git a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageSender.java b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageSender.java
deleted file mode 100644
index a1fbce5..0000000
--- a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSockDeviceMessageSender.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.fzzy.gateway.hx2023.websocket;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-
-
-/**
- * 涓嬪彂璋冪敤绮俯妫�娴嬫帴鍙f寚浠� topic
- */
-@Slf4j
-@Component
-@ServerEndpoint(value = "/device-message-sender/{productId}/{deviceId}")
-public class WebSockDeviceMessageSender {
-
-    @OnOpen
-    public void onOpen(Session session,
-                       @PathParam("productId") String productId,
-                       @PathParam("deviceId") String deviceId
-    ) throws Exception {
-
-        log.info("--------涓嬪彂璋冪敤绮俯妫�娴嬫帴鍙f寚浠� topic------");
-    }
-
-    @OnClose
-    public void onClose() {
-
-        log.info("WebSocket杩炴帴鍏抽棴={}");
-    }
-
-    /**
-     * 鏀跺埌鍓嶇鍙戦�佺殑淇℃伅
-     *
-     * @param message
-     * @param session
-     */
-    @OnMessage
-    public void onMessage(String message, Session session) {
-
-        log.info("鏉ヨ嚜鍓嶇鐨勪俊鎭�:\n" + message);
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        log.error("鍙戠敓閿欒");
-    }
-}
diff --git a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java
deleted file mode 100644
index 6edc518..0000000
--- a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.fzzy.gateway.hx2023.websocket;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fzzy.gateway.GatewayUtils;
-import com.fzzy.gateway.hx2023.data.WebSocketPacket;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.stereotype.Component;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 鍩轰簬鍓嶇 websocket 璁㈤槄鍦扮鏁版嵁 topic:
- */
-@Slf4j
-@Component
-@ServerEndpoint(value = "/device/{productId}/{deviceId}/message/property/report")
-public class WebSocketDeviceReport {
-
-    private static Map<String, Session> sessionPool = new ConcurrentHashMap<>();
-    private static Map<String, String> sessionIds = new ConcurrentHashMap<>();
-
-    // 涓庢煇涓鎴风鐨勮繛鎺ヤ細璇濓紝闇�瑕侀�氳繃瀹冩潵缁欏鎴风鍙戦�佹暟鎹�
-    private Session session;
-
-
-    @OnOpen
-    public void onOpen(Session session,
-                       @PathParam("productId") String productId,
-                       @PathParam("deviceId") String deviceId,
-                       @PathParam("clientId") String clientId
-    ) throws Exception {
-
-        this.session = session;
-
-        String key = productId + "-" + deviceId;
-
-        sessionPool.put(key, session);
-        sessionIds.put(session.getId(), key);
-
-        GatewayUtils.updateOnline(deviceId);
-
-        log.info("new webSocket,clientId={}", key);
-    }
-
-    @OnClose
-    public void onClose() {
-
-        String key = sessionIds.get(session.getId());
-
-        String deviceId = key.substring(key.indexOf("-"));
-
-        GatewayUtils.updateOffOnline(deviceId);
-
-        sessionPool.remove(key);
-        sessionIds.remove(session.getId());
-
-        log.info("WebSocket杩炴帴鍏抽棴={}", key);
-
-    }
-
-    /**
-     * 鏀跺埌鍓嶇鍙戦�佺殑淇℃伅
-     *
-     * @param message
-     * @param session
-     */
-    @OnMessage
-    public void onMessage(String message, Session session) {
-
-        log.info("鏉ヨ嚜瀹㈡埛绔俊鎭�:\n" + message);
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        log.error("鍙戠敓閿欒");
-
-        String key = sessionIds.get(session.getId());
-
-        String deviceId = key.substring(key.indexOf("-"));
-
-        GatewayUtils.updateOffOnline(deviceId);
-
-        sessionPool.remove(key);
-        sessionIds.remove(session.getId());
-        error.printStackTrace();
-    }
-
-
-    /**
-     * 鎺ㄩ�佷俊鎭埌鍓嶇
-     *
-     * @param packet
-     */
-    public void sendByPacket(WebSocketPacket packet) {
-        if (StringUtils.isEmpty(packet.getDeviceId())) {
-            log.error("WebSocket淇℃伅鎺ㄩ�佸け璐ワ紝璁惧缂栫爜涓虹┖銆�");
-            return;
-        }
-
-        String tag = packet.getDeviceId();
-
-        // 閬嶅巻鎺ㄩ��
-        Session session;
-        String productId;
-        for (String key : sessionPool.keySet()) {
-
-            productId = key.substring(0, key.indexOf("-"));
-
-            packet.getHeaders().setProductId(productId);
-
-            log.debug("----------websocket杩斿洖淇℃伅-----{}", packet);
-
-            if (key.indexOf(tag) != -1) {
-                session = sessionPool.get(key);
-                session.getAsyncRemote().sendText(JSONObject.toJSONString(packet));
-            }
-        }
-    }
-
-
-}
diff --git a/src/main/resources/application-proGateway.yml b/src/main/resources/application-proGateway.yml
index 8d688f9..5f33262 100644
--- a/src/main/resources/application-proGateway.yml
+++ b/src/main/resources/application-proGateway.yml
@@ -5,13 +5,13 @@
   datasource:
     #涓绘暟鎹簮
     primary:
-      url: jdbc:mysql://127.0.0.1:3306/igds_api_5012?useUnicode=true&useSSL=false&characterEncoding=utf-8
+      url: jdbc:mysql://127.0.0.1:3306/igds_api_2023?useUnicode=true&useSSL=false&characterEncoding=utf-8
       username: root
       password: Abc123..
       driver-class-name: com.mysql.jdbc.Driver
     #娆℃暟鎹簮
     secondary:
-      url: jdbc:mysql://127.0.0.1:3306/igds_5012?useUnicode=true&useSSL=false&characterEncoding=utf-8
+      url: jdbc:mysql://127.0.0.1:3306/igds_v4?useUnicode=true&useSSL=false&characterEncoding=utf-8
 
       username: root
       password: Abc123..
@@ -38,7 +38,7 @@
     database: 5
     host: 127.0.0.1
     port: 6379
-    password: Redispwd..
+    password:
     # 杩炴帴姹犳渶澶ц繛鎺ユ暟锛堜娇鐢ㄨ礋鍊艰〃绀烘病鏈夐檺鍒讹級
     pool:
       max-active: 200
@@ -48,11 +48,6 @@
       timeout: 6000
   kafka:
     bootstrap-servers: 103.203.217.16:9092
-    security-protocol: SASL_PLAINTEXT
-    sasl-mechanism: PLAIN
-    sasl-jaas-config: org.apache.kafka.common.security.scram.ScramLoginModule required username=\"{username}\" password=\"{password}\";"
-    sasl-username: sc001
-    sasl-password: wCV0ISwmoKwbx1lpBKMW
     producer:
       retries: 0
       acks: 1
@@ -60,6 +55,12 @@
       buffer-memory: 33554432
       key-serializer: org.apache.kafka.common.serialization.StringSerializer
       value-serializer: org.apache.kafka.common.serialization.StringSerializer
+    properties:
+      security.protocol: SASL_PLAINTEXT
+      sasl.mechanism: PLAIN
+      sasl.username: sc001
+      sasl.password: wCV0ISwmoKwbx1lpBKMW
+      sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username='sc001' password='wCV0ISwmoKwbx1lpBKMW';
     consumer:
       group-id: fzzygroup
       enable-auto-commit: true
@@ -68,14 +69,16 @@
       key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
       value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
 
-mqtt:
-  host: tcp://10.13.4.84:11883
-  client-id:
-  client-username:
-  client-password:
-  client-timeout: 10
-  client-alive-time: 20
-  client-max-connect-times: 5
-  client-topics:
-  client-qos: 0
-  isOpen: false
+  mqtt:
+    host: tcp://127.0.0.1:1883
+    username: admin
+    password: admin123321
+    client-inId: fzzy_client_id_in_igds_api
+    client-outId: fzzy_client_id_out_igds_api
+    completionTimeout: 3000
+    keep-alive-interval: 2
+    max-connect-times: 5
+    qos: 0
+    isOpen: false
+    default-topic: mqtt/+/test1
+    topics: /device-message-sender/#
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 55d6b10..89ffd19 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -34,4 +34,4 @@
   default:
     companyId: 5326
   file-path: C:/app/igds-api
-  img-path: D:/IGDS/FILE/
\ No newline at end of file
+  img-path: D:/IGDS/FILE/
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
index 6c4d4fd..5078c54 100644
--- a/src/main/resources/logback-spring.xml
+++ b/src/main/resources/logback-spring.xml
@@ -6,9 +6,9 @@
 	<property name="APP_MODEL" value="igds-api" />
 
 	<!-- dev鏂囦欢璺緞 涓�鑸笉闇�瑕侀厤缃� -->
-	<property name="DEV_LOG_HOME" value="C:/app/igds-api/log"/>\
+	<property name="DEV_LOG_HOME" value="D:/app/igds-api/log"/>\
 	<!-- pro鏂囦欢璺緞 -->
-	<property name="PRO_LOG_HOME" value="C:/app/igds-api/log" />
+	<property name="PRO_LOG_HOME" value="D:/app/igds-api/log" />
 	<!-- linux鏂囦欢璺緞 -->
 	<property name="PRO_LINUX_HOME" value="/usr/local/fzzy/igds-api/log" />
 

--
Gitblit v1.9.3