ソースを参照

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/service/dataprocess/dataclean/impl/WifiEvnSevenInOne.java
黄渊昊 3 週間 前
コミット
569626ee95

+ 32 - 46
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/bi/utils/CloudApiService.java

@@ -1,8 +1,5 @@
 package vip.xiaonuo.coldchain.modular.bi.utils;
 
-import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.lang.Assert;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
@@ -10,18 +7,16 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
 @Slf4j
 public class CloudApiService {
 
     //根据设备 SN 号获取设备最新数据
-    private static String sensorUrl = "https://cloudapi.369clouds.com/openapi/sensor/data?key={}&sn={}";
+    private static final String sensorUrl = "https://cloudapi.369clouds.com/openapi/sensor/data?key={}&sn={}";
 
-    private static String APIKey = "0790e453ac85424bbea92c68da10f7ff";
+    private static final String APIKey = "0790e453ac85424bbea92c68da10f7ff";
 
     /**
      * 根据设备 SN 号获取设备最新数据
@@ -41,24 +36,28 @@ public class CloudApiService {
      * 11: "授权超时",
      * 12: "应急尝试",
      *
-     * @param codes 代码
+     * @param code 代码
      * @return {@link List }<{@link String }>
      */
     public static String getCloudSensorData(String code) {
         //2.获取数据
-        if (StrUtil.isNotBlank(APIKey) && StrUtil.isNotBlank(code)) {
-            String data = HttpUtil.get(StrUtil.format(sensorUrl, APIKey, code));
-            log.info("获取设备数据 url={} \n apikey={} \n param={} \nresult={}", sensorUrl, APIKey, code, data);
-            JSONObject sensorJsonObject = JSONUtil.parseObj(data);
-            Map dataMap = sensorJsonObject.getByPath("data.items.datas", Map.class);
-            return MapUtil.getStr(dataMap, "lockstate", "0");
-        }
+       try {
+           if (StrUtil.isNotBlank(APIKey) && StrUtil.isNotBlank(code)) {
+               String data = HttpUtil.get(StrUtil.format(sensorUrl, APIKey, code));
+               log.info("获取设备数据 url={} \n apikey={} \n param={} \nresult={}", sensorUrl, APIKey, code, data);
+               JSONObject sensorJsonObject = JSONUtil.parseObj(data);
+               Map dataMap = sensorJsonObject.getByPath("data.items.datas", Map.class);
+               return MapUtil.getStr(dataMap, "lockstate", "0");
+           }
+       }catch (Exception e){
+           log.error("设备锁平台接口调用失败",e);
+       }
         return "0";
     }
 
-    public static void main(String[] args) {
-        System.out.println(getCloudSensorData("29107790"));
-    }
+//    public static void main(String[] args) {
+//        System.out.println(getCloudSensorData("29107790"));
+//    }
 
     public static String resolveLockStatus(String status) {
         /**
@@ -75,34 +74,21 @@ public class CloudApiService {
          *      * 	11: "授权超时",
          *      * 	12: "应急尝试",
          */
-        switch (status) {
-            case "1":
-                return "关门操作";
-            case "2":
-                return "刷卡开门";
-            case "3":
-                return "钥匙开门";
-            case "4":
-                return "未授权刷卡";
-            case "5":
-                return "异常开门";
-            case "6":
-                return "开门超时";
-            case "7":
-                return "刷卡未开门";
-            case "8":
-                return "撬锁";
-            case "9":
-                return "撬锁后恢复";
-            case "10":
-                return "无效卡";
-            case "11":
-                return "授权超时";
-            case "12":
-                return "应急尝试";
-            default:
-                return "关";
-        }
+        return switch (status) {
+            case "1" -> "关门操作";
+            case "2" -> "刷卡开门";
+            case "3" -> "钥匙开门";
+            case "4" -> "未授权刷卡";
+            case "5" -> "异常开门";
+            case "6" -> "开门超时";
+            case "7" -> "刷卡未开门";
+            case "8" -> "撬锁";
+            case "9" -> "撬锁后恢复";
+            case "10" -> "无效卡";
+            case "11" -> "授权超时";
+            case "12" -> "应急尝试";
+            default -> "关";
+        };
     }
 
 }

+ 1 - 1
snowy-web-app/src/main/resources/logback-spring.xml

@@ -107,7 +107,7 @@
         </appender>
 
         <!--记录到文件时,记录两类一类是error日志,一个是所有日志-->
-        <root level="warn">
+        <root level="info">
             <appender-ref ref="STDOUT"/>
             <appender-ref ref="FILE_ERROR"/>
             <appender-ref ref="FILE_ALL"/>