|
|
@@ -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套口
|