Răsfoiți Sursa

对好两个sb接口

Void_F 1 zi în urmă
părinte
comite
ec0245ff3b

+ 35 - 0
Assets/Scripts/HttpGetData.cs

@@ -112,6 +112,14 @@ public class DevicesRequestData
     public string SampleTime;
 }
 
+[Serializable]
+public class PostStatisticsData
+{
+    public string[] timeRange;
+    public string startTime;
+    public string endTime;
+    public string ids;
+}
 
 [Serializable]
 public class GetSingleDeviceData
@@ -333,6 +341,33 @@ public class CharData_water
     public string value;
 }
 
+[Serializable]
+public class B08_StationListData
+{
+    public B08_StationInfo[] data;
+}
+
+[Serializable]
+public class B08_StationInfo
+{
+    public string id;
+    public string code;
+    public string name;
+    public B08_StationInfo[] children;
+}
+[Serializable]
+public class B08_StatisticsInfo
+{
+    public string waitDispatch;
+    public string waitPatrol;
+    public string onPatrol;
+    public string patrolCompleted;
+
+    public List<string> dates;
+    public List<int> valueOfDates;
+}
+
+
 [Serializable]
 public class B08_TaskListInfoData
 {

+ 89 - 1
Assets/Scripts/HttpHelper.cs

@@ -15,6 +15,8 @@ using UnityEngine.Networking;
 using Unity.VisualScripting;
 using static System.Net.WebRequestMethods;
 using System.Linq;
+using UniTask = Cysharp.Threading.Tasks.UniTask;
+using UniTaskVoid = Cysharp.Threading.Tasks.UniTaskVoid;
 
 public class HttpHelper : MonoBehaviour
 {
@@ -55,7 +57,7 @@ public class HttpHelper : MonoBehaviour
         //}
     }
 
-    private async void Awake()
+    private async UniTaskVoid Awake()
     {
         _Instance = this;
 
@@ -131,6 +133,8 @@ public class HttpHelper : MonoBehaviour
 
         if (GlobalData.pageIndex == PageIndex.Page1 || GlobalData.pageIndex == PageIndex.Page2)
         {
+            
+            GetGCYW_Station().Forget();
             Debug.Log("HttpInitGCYWData1");
             //可以并行,无需等待
             InitGCYWData1(0);
@@ -2067,6 +2071,90 @@ public class HttpHelper : MonoBehaviour
         return result;
     }
 
+    public async UniTaskVoid GetGCYW_Station()
+    {
+        Debug.Log("获取B08GCYW 站点列表");
+        using UnityWebRequest www = UnityWebRequest.Get(ServerAddress.API_B08_getStationList);
+        www.downloadHandler = new DownloadHandlerBuffer();
+        www.SetRequestHeader("Content-Type", "application/json");
+        await www.SendWebRequest();
+        if (www.result != UnityWebRequest.Result.Success)
+        {
+            Debug.LogWarning($"获取{ServerAddress.API_B08_getStationList}数据不成功,原因:返request不成功:" + www.downloadHandler.text);
+        }
+        var jsonStr = www.downloadHandler.text;
+        www.Dispose();
+        Debug.Log(jsonStr);
+        var datas = JsonConvert.DeserializeObject<B08_StationListData>(jsonStr);
+        foreach (var data in datas.data)
+        {
+            GlobalData.B08StationList.TryAdd(data.name, data.id);
+            foreach (var chiles in data.children)
+            {
+                GlobalData.B08StationList.TryAdd(chiles.name, chiles.id);
+                foreach (var chilesChile in chiles.children)
+                {
+                    GlobalData.B08StationList.TryAdd(chilesChile.name, chilesChile.id);
+                    foreach (var chilesChilesChild in chiles.children)
+                    {
+                        GlobalData.B08StationList.TryAdd(chilesChilesChild.name, chilesChilesChild.id);
+                        //三层应该没有儿子了吧 拉屎谁不会呢
+                    }
+                }
+            }
+        }
+        //懒得搞直接获取所有属性
+        foreach (var key in GlobalData.B08StationList.Keys)
+        {
+            var StatisticsStr = await GetStatistics(GlobalData.B08StationList[key]);
+            B08_StatisticsInfo saveInfo = new B08_StatisticsInfo();
+            saveInfo.dates = new List<string>();
+            saveInfo.valueOfDates = new List<int>();
+            JObject jsonObject = JObject.Parse(StatisticsStr);
+            // 提取data字段的值
+            JToken dataToken = jsonObject["data"];
+            JToken statusCount = dataToken["statusCount"];
+            saveInfo.waitDispatch = statusCount?["0"] != null ? statusCount["0"].ToString() : "0";
+            saveInfo.waitPatrol = statusCount?["0"] != null ? statusCount["1"].ToString() : "0";
+            saveInfo.onPatrol = statusCount?["0"] != null ? statusCount["2"].ToString() : "0";
+            saveInfo.patrolCompleted = statusCount?["0"] != null ? statusCount["3"].ToString() : "0";
+
+            JObject dailyCountObj=(JObject)dataToken["dailyCount"];
+            foreach (var property in dailyCountObj.Properties())
+            {
+                saveInfo.dates.Add(property.Name);
+                saveInfo.valueOfDates.Add((int)property.Value);
+            }
+            GlobalData.B08StatisticsInfo.TryAdd(key, saveInfo);
+        }
+        Debug.Log("获取站点信息完毕");
+    }
+    
+    public async Cysharp.Threading.Tasks.UniTask<string> GetStatistics(string stationId)
+    {
+        var result="";
+        var sendData = new PostStatisticsData
+        {
+            timeRange = new string[]
+            {
+                "2025-11-13", "2025-11-19"
+            },
+            startTime = "2025-11-13 00:00:00",
+            endTime = "2025-11-19 23:59:59",
+            ids = stationId
+        };
+        string tempStr = JsonConvert.SerializeObject(sendData);
+        var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
+        using UnityWebRequest www = new UnityWebRequest("http://58.19.230.46:9180/prod-api/project/workOrder/statistics","POST");
+        www.uploadHandler = new UploadHandlerRaw(sendByte);
+        www.downloadHandler = new DownloadHandlerBuffer();
+        www.SetRequestHeader("Content-Type", "application/json");
+        await www.SendWebRequest();
+        result = www.downloadHandler.text;
+        www.Dispose();
+        return result;
+    }
+    
 
     /// <summary>
     /// 0 补元 1套口

+ 4 - 4
Assets/Scripts/TextureLoadHelp.cs

@@ -163,12 +163,12 @@ public class TextureLoadHelp : MonoBehaviour
                 {
                     if (targetMat == null)
                     {
-                        Debug.Log($"{fileName} 材质球不存在");
+                        Debug.LogWarning($"{fileName} 材质球不存在");
                     }
 
                     if (tex == null)
                     {
-                        Debug.Log($"{fileName} 图片不存在");
+                        Debug.LogWarning($"{fileName} 图片不存在");
                     }
                 }
 
@@ -210,12 +210,12 @@ public class TextureLoadHelp : MonoBehaviour
                     {
                         if (targetMat == null)
                         {
-                            Debug.Log($"{fileName} 材质球不存在");
+                            Debug.LogWarning($"{fileName} 材质球不存在");
                         }
 
                         if (tex == null)
                         {
-                            Debug.Log($"{fileName} 图片不存在");
+                            Debug.LogWarning($"{fileName} 图片不存在");
                         }
                     }
 

+ 4 - 0
Assets/Scripts/UI/Data/GlobalData.cs

@@ -164,6 +164,10 @@ public class GlobalData
     public static B08_TaskListInfoData B08TaskListData;
     //public static B08_TaskListInfoData[] B08TaskListInfos;
     public static int B08_Type = -1;
+
+    public static Dictionary<string,string> B08StationList=new Dictionary<string, string>();
+    public static Dictionary<string,B08_StatisticsInfo> B08StatisticsInfo=new Dictionary<string, B08_StatisticsInfo>();
+    
     #endregion   
     
     /// <summary>

+ 1 - 0
Assets/Scripts/UI/Tools/ServerAddress.cs

@@ -150,6 +150,7 @@ public class ServerAddress
     public static string API_B08_taskItems = YZTServerAddress + "/project/workOrder";
     public static string API_B08_taskLocation = YZTServerAddress + "/project/workOrder/location/workOrder";
 
+    public static string API_B08_getStationList = "http://58.19.230.46:9180/prod-api/project/xunjianStation/treeList?pageNum=1&pageSize=999";
     
     /// <summary>
     /// 获取站点水位信息(折线图和信息列表)

+ 1 - 0
Assets/Scripts/UI/UIView/GCYW/GCYWLayer.cs

@@ -203,6 +203,7 @@ public class GCYWLayer : YZTRootLayer
 
     private async void OnEnable()
     {
+        
         ChangeData(1);
     }