wartheking 8 mesiacov pred
rodič
commit
d4686673b1

+ 41 - 3
Assets/Scripts/HttpHelper.cs

@@ -262,10 +262,11 @@ public class HttpHelper : MonoBehaviour
 
     private async Task InitDPSWData()
     {
+        GlobalData.locationWeatherData = new List<LocationWeatherData>();
         bool successInternet = true;
-        UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetHydrologicalData);
+        UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetHydrologicalData + "?projectType=1");
         requestData.timeout = timeOut;
-        await requestData.SendWebRequest();
+        await requestData.SendWebRequest(); 
         try
         {
             if (requestData.result != UnityWebRequest.Result.Success)
@@ -282,7 +283,8 @@ public class HttpHelper : MonoBehaviour
                 JToken codeToken = jsonObject["code"];
                 if (codeToken.ToString() == "200")
                 {
-                    GlobalData.locationWeatherData = JsonConvert.DeserializeObject<List<LocationWeatherData>>(dataToken.ToString());
+                    LocationWeatherData data1 = JsonConvert.DeserializeObject<LocationWeatherData>(dataToken.ToString());
+                    GlobalData.locationWeatherData.Add(data1);
                 }
                 else
                 {
@@ -296,6 +298,42 @@ public class HttpHelper : MonoBehaviour
             successInternet = false;
             Debug.LogWarning("大屏水文数据联网不成功,读本地缓存数据,原因:" + e.ToString());
         }
+
+        UnityWebRequest requestData1 = UnityWebRequest.Get(ServerAddress.APIGetHydrologicalData + "?projectType=2");
+        requestData1.timeout = timeOut;
+        await requestData1.SendWebRequest();
+        try
+        {
+            if (requestData1.result != UnityWebRequest.Result.Success)
+            {
+                Debug.LogWarning("大屏水文数据联网不成功,读本地缓存数据,原因:返request不成功");
+                successInternet = false;
+            }
+            else
+            {
+                JObject jsonObject = JObject.Parse(requestData1.downloadHandler.text);
+
+                // 提取data字段的值
+                JToken dataToken = jsonObject["data"];
+                JToken codeToken = jsonObject["code"];
+                if (codeToken.ToString() == "200")
+                {
+                    LocationWeatherData data2 = JsonConvert.DeserializeObject<LocationWeatherData>(dataToken.ToString());
+                    GlobalData.locationWeatherData.Add(data2);
+                }
+                else
+                {
+                    Debug.LogWarning("大屏水文数据联网不成功,读本地缓存数据,原因:返序列化失败");
+                    successInternet = false;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            successInternet = false;
+            Debug.LogWarning("大屏水文数据联网不成功,读本地缓存数据,原因:" + e.ToString());
+        }
+
         requestData.Dispose();
         if (!successInternet)
         {

+ 3 - 3
Assets/Scripts/UI/Tools/ServerAddress.cs

@@ -27,7 +27,7 @@ public class ServerAddress
     /// <summary>
     /// 获取人口转移所有路径数据
     /// </summary>
-    public static string APIGetGetMovePlans = YZTServerAddress + "/get-move-plans";
+    public static string APIGetGetMovePlans = YZTServerAddress + "/open/transfer";
 
     /// <summary>
     /// 获取人口转移基础数据
@@ -123,12 +123,12 @@ public class ServerAddress
     /// <summary>
     /// 获取大屏的水闸数据
     /// </summary>
-    public static string APIGetFloodGateData = YZTServerAddress + "/open/data/floodGateData";
+    public static string APIGetFloodGateData = YZTServerAddress + "/open/data/gateStatusData";
 
     /// <summary>
     /// 获取大屏的水文数据
     /// </summary>
-    public static string APIGetHydrologicalData = YZTServerAddress + "/open/data/hydrologicalData";
+    public static string APIGetHydrologicalData = YZTServerAddress + "/open/data/shuiwenjiance";
 
 
     /// <summary>

+ 11 - 15
Assets/Scripts/UI/UIView/BigScreen/BigScreenLayer.cs

@@ -59,20 +59,16 @@ public class FloodGateStatusData
 }
 
 
-[System.Serializable]
-public class WeatherData
-{
-    public float Temperature;
-    public string Weather;
-}
+
 
 [System.Serializable]
 public class LocationWeatherData
 {
-    public float CurrentWaterLevel;
-    public float Rainfall;
-    public float FloodDischarge;
-    public WeatherData WeatherData;
+    public float currentWaterLevel;
+    public float rainfall;
+    public float floodDischarge;
+    public float temperature;
+    public string weather;
 }
 
 
@@ -388,11 +384,11 @@ public class BigScreenLayer : MonoBehaviour
 
     private void ChangeLocationWeatherData(int index)
     {
-        swValue1.text = GlobalData.locationWeatherData[index].CurrentWaterLevel.ToString();
-        swValue2.text = GlobalData.locationWeatherData[index].Rainfall.ToString();
-        swValue3.text = GlobalData.locationWeatherData[index].WeatherData.Temperature.ToString();
-        swValue4.text = GlobalData.locationWeatherData[index].WeatherData.Weather.ToString();
-        swValue5.text = GlobalData.locationWeatherData[index].FloodDischarge.ToString();
+        swValue1.text = GlobalData.locationWeatherData[index].currentWaterLevel.ToString();
+        swValue2.text = GlobalData.locationWeatherData[index].rainfall.ToString();
+        swValue3.text = GlobalData.locationWeatherData[index].temperature.ToString();
+        swValue4.text = GlobalData.locationWeatherData[index].weather.ToString();
+        swValue5.text = GlobalData.locationWeatherData[index].floodDischarge.ToString();
     }
     private async Task InitFloodGateData()
     {

+ 10 - 14
Assets/StreamingAssets/hydrologicalData.json

@@ -1,21 +1,17 @@
 [
     {
-      "CurrentWaterLevel": 29.5,
-      "Rainfall": 12,
-      "FloodDischarge": 150,
-      "WeatherData": {
-        "Temperature": 25,
-        "Weather": "晴"
-      }
+      "currentWaterLevel": 29.5,
+      "rainfall": 12,
+      "floodDischarge": 150,
+      "temperature": 25,
+      "weather": "晴"
     },
     {
-      "CurrentWaterLevel": 30.2,
-      "Rainfall": 8,
-      "FloodDischarge": 200,
-      "WeatherData": {
-        "Temperature": 22,
-        "Weather": "晴"
-      }
+      "currentWaterLevel": 30.2,
+      "rainfall": 8,
+      "floodDischarge": 200,
+      "temperature": 22,
+      "weather": "晴"
     }
 ]