浏览代码

接口大更新,做一点提交一点,免得翻车

lantiannb 1 周之前
父节点
当前提交
bdff99a920

文件差异内容过多而无法显示
+ 126 - 125
Assets/Prefabs/UI/XHYZT/YZT.prefab


文件差异内容过多而无法显示
+ 98 - 2
Assets/Scene 1.unity


+ 202 - 2
Assets/Scripts/HttpHelper.cs

@@ -421,6 +421,7 @@ public class HttpHelper : MonoBehaviour
         InitYZTData_BY_Obs(); //已完成迁移
         InitYZTData_TK_Obs(); //新增
         InitYZTData3(); //已完成迁移
+        InitGCGKData();
     }
 
     public async Task InitYZTData1()
@@ -617,7 +618,7 @@ public class HttpHelper : MonoBehaviour
                     {
                         ObsData obsData = new ObsData();
                         string originName = serverObsDatas.list[i].name;
-                        Debug.Log("111111111111111:" + originName);
+                        //Debug.Log("111111111111111:" + originName);
                         obsData.name = "套口-" + serverObsDatas.list[i].name;
                         if (GlobalData.obsCameraLib.TryGetValue(obsData.name, out var value))
                         {
@@ -801,6 +802,58 @@ public class HttpHelper : MonoBehaviour
         }
     }
 
+    /// <summary>
+    /// 一张图首页工程概况
+    /// </summary>
+    /// <returns></returns>
+    public async Task InitGCGKData()
+    {
+        bool successInternet = true;
+        UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetWaterGaiKuang);
+        requestData.timeout = timeOut;
+        await requestData.SendWebRequest();
+        try
+        {
+            if (requestData.result != UnityWebRequest.Result.Success)
+            {
+                Debug.LogWarning("GCGK联网不成功,读本地缓存数据,原因:返request不成功");
+                successInternet = false;
+            }
+            else
+            {
+                string postResult = requestData.downloadHandler.text;
+                if (useAes)
+                {
+                    postResult = AESCrypto.Decrypt(postResult);
+
+                }
+                JObject jsonObject = JObject.Parse(postResult);
+
+           
+                JToken dataToken = jsonObject["data"];
+                //Debug.Log(dataToken.ToString());
+                JToken codeToken = jsonObject["code"];
+                if (codeToken.ToString() == "200")
+                {
+                    //Debug.Log("1111111111:" + dataToken.ToString());
+                    GlobalData.gcgkContents = JsonConvert.DeserializeObject<List<GCGKData>>(dataToken.ToString());
+                }
+                else
+                {
+                    Debug.LogWarning("GCGK联网不成功,读本地缓存数据,原因:返序列化失败");
+                    successInternet = false;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            successInternet = false;
+            Debug.LogWarning("GCGK联网不成功,读本地缓存数据,原因:" + e.ToString());
+        }
+
+        requestData.Dispose();
+    }
+
     public async Task InitGCJKData()
     {
         bool successInternet = true;
@@ -952,15 +1005,22 @@ public class HttpHelper : MonoBehaviour
 
         await InitSWYJData1();
         await InitSWYJData2();
+        await InitSWYJData3();
         OnSWYJRefresh?.Invoke();
     }
 
-
+    /// <summary>
+    /// 获取补元的水位
+    /// </summary>
+    /// <returns></returns>
     public async Task InitSWYJData1()
     {
         var devicesInfo = _devicesIdDatas["上游水位计"];
         string sw1Result = await GetSingleDevicesInfo(2, devicesInfo.dataGid.ToString(), devicesInfo.dataSid.ToString(),
             "d", 10000);
+        Debug.Log(devicesInfo.dataGid.ToString());
+        Debug.Log(devicesInfo.dataSid.ToString());
+        //Debug.Log("sw1Resultsw1Resultsw1Result上游水位计:" + sw1Result);
         try
         {
             GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(sw1Result);
@@ -999,6 +1059,7 @@ public class HttpHelper : MonoBehaviour
         var devicesInfo1 = _devicesIdDatas["下游水位计"];
         string sw2Result = await GetSingleDevicesInfo(2, devicesInfo1.dataGid.ToString(), devicesInfo1.dataSid.ToString(),
             "d", 100000);
+        Debug.Log("sw1Resultsw1Resultsw1Result下游水位计:" + sw2Result);
         try
         {
             GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(sw2Result);
@@ -1092,6 +1153,144 @@ public class HttpHelper : MonoBehaviour
     }
 
     public async Task InitSWYJData2()
+    {
+        var devicesInfo = _devicesIdDatas["SWJ01YQ"];
+        Debug.Log(devicesInfo.dataGid);
+        Debug.Log(devicesInfo.dataSid);
+        string sw1Result = await GetSingleDevicesInfo(1, devicesInfo.dataGid.ToString(), devicesInfo.dataSid.ToString(), "d", 10000);
+        try
+        {
+            GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(sw1Result);
+            if (tempData != null)
+            {
+                bool findData = false;
+                foreach (var VARIABLE in GlobalData.TaoKouShuiWeiDataList)
+                {
+                    if (VARIABLE.name.Equals("套口上游水位"))
+                    {
+                        VARIABLE.value = float.Parse(tempData.data[0].avgS1);
+                        VARIABLE.datas = tempData.data.ToArray();
+                        findData = true;
+                    }
+                }
+                if (!findData)
+                {
+                    GlobalData.TaoKouShuiWeiDataList.Add(new ShuiWeiData()
+                    {
+                        name = "套口上游水位",
+                        targetName = "TK_ShuiWei_Up",
+                        value = float.Parse(tempData.data[0].avgS1),
+                        type = shuiWeiType.TaoKouShuiWei,
+                        datas = tempData.data.ToArray(),
+                        sid = devicesInfo.dataSid.ToString(),
+                        gid = devicesInfo.dataGid.ToString()
+                    });
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogWarning("套口上游水位不成功,原因:" + e.ToString());
+        }
+
+        var devicesInfo1 = _devicesIdDatas["SWJ02YQ"];
+        string sw2Result = await GetSingleDevicesInfo(1, devicesInfo1.dataGid.ToString(), devicesInfo1.dataSid.ToString(),
+            "d", 100000);
+        //Debug.Log("sw1Resultsw1Resultsw1Result下游水位计:" + sw2Result);
+        try
+        {
+            GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(sw2Result);
+            if (tempData != null)
+            {
+                bool findData = false;
+                foreach (var VARIABLE in GlobalData.TaoKouShuiWeiDataList)
+                {
+                    if (VARIABLE.name.Equals("套口下游水位"))
+                    {
+                        VARIABLE.value = float.Parse(tempData.data[0].avgS1);
+                        VARIABLE.datas = tempData.data.ToArray();
+                        findData = true;
+                    }
+                }
+                if (!findData)
+                {
+                    GlobalData.TaoKouShuiWeiDataList.Add(new ShuiWeiData()
+                    {
+                        name = "套口下游水位",
+                        targetName = "TK_ShuiWei_Down",
+                        value = float.Parse(tempData.data[0].avgS1),
+                        type = shuiWeiType.TaoKouShuiWei,
+                        datas = tempData.data.ToArray(),
+                        sid = devicesInfo.dataSid.ToString(),
+                        gid = devicesInfo.dataGid.ToString()
+                    });
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogWarning("套口下游水位不成功,原因:" + e.ToString());
+        }
+
+        string dayResult = await GetSingleDevicesInfo(1, devicesInfo.dataGid.ToString(), devicesInfo.dataSid.ToString(),
+            "d", 6);
+        try
+        {
+            GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(dayResult);
+            GlobalData.taoKouShuiWei_day = new ShuiWeiBianHuaData();
+            GlobalData.taoKouShuiWei_day.name = new string[tempData.data.Count];
+            GlobalData.taoKouShuiWei_day.value = new double[tempData.data.Count];
+            for (int i = 0; i < tempData.data.Count; i++)
+            {
+                GlobalData.taoKouShuiWei_day.name[i] = tempData.data[i].timeGroup;
+                GlobalData.taoKouShuiWei_day.value[i] = double.Parse(tempData.data[i].avgS1);
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogWarning("获取6天平均数据不成功,原因:" + e.ToString());
+        }
+
+        string monthResult = await GetSingleDevicesInfo(1, devicesInfo.dataGid.ToString(), devicesInfo.dataSid.ToString(),
+            "d", 90);
+        try
+        {
+            GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(monthResult);
+            GlobalData.taoKouShuiWei_month = new ShuiWeiBianHuaData();
+            GlobalData.taoKouShuiWei_month.name = new string[tempData.data.Count];
+            GlobalData.taoKouShuiWei_month.value = new double[tempData.data.Count];
+            for (int i = 0; i < tempData.data.Count; i++)
+            {
+                GlobalData.taoKouShuiWei_month.name[i] = tempData.data[i].timeGroup;
+                GlobalData.taoKouShuiWei_month.value[i] = double.Parse(tempData.data[i].avgS1);
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogWarning("获取6月平均数据不成功,原因:" + e.ToString());
+        }
+
+        string hourResult = await GetSingleDevicesInfo(1, devicesInfo.dataGid.ToString(), devicesInfo.dataSid.ToString(),
+            "h", 6);
+        try
+        {
+            GetSingleDevicesRequest tempData = JsonConvert.DeserializeObject<GetSingleDevicesRequest>(hourResult);
+            GlobalData.taoKouShuiWei_hour = new ShuiWeiBianHuaData();
+            GlobalData.taoKouShuiWei_hour.name = new string[tempData.data.Count];
+            GlobalData.taoKouShuiWei_hour.value = new double[tempData.data.Count];
+            for (int i = 0; i < tempData.data.Count; i++)
+            {
+                GlobalData.taoKouShuiWei_hour.name[i] = tempData.data[i].timeGroup;
+                GlobalData.taoKouShuiWei_hour.value[i] = double.Parse(tempData.data[i].avgS1);
+            }
+        }
+        catch (Exception e)
+        {
+            Debug.LogWarning("获取6小时平均数据不成功,原因:" + e.ToString());
+        }
+    }
+
+    public async Task InitSWYJData3()
     {
         bool successInternet = true;
         UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeSWData);
@@ -1193,6 +1392,7 @@ public class HttpHelper : MonoBehaviour
             successInternet = false;
             Debug.LogWarning("三线水位联网不成功,原因:" + e.ToString());
         }
+     
     }
 
     public async Task SendBuYuan_GetSensorData()

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

@@ -16,6 +16,12 @@ public class GlobalData
     public static List<LayerUnitData> layerUnitDatas = new List<LayerUnitData>();
 
 
+    /// <summary>
+    /// 一张图第二页数据
+    /// </summary>
+    public static List<GCGKData> gcgkContents = new List<GCGKData>();
+
+
     /// <summary>
     /// 一张图第一页热点数据
     /// </summary>
@@ -153,6 +159,9 @@ public class GlobalData
     public static ShuiWeiBianHuaData buYuanShuiWei_day;
     public static ShuiWeiBianHuaData buYuanShuiWei_month;
 
+    public static ShuiWeiBianHuaData taoKouShuiWei_hour;
+    public static ShuiWeiBianHuaData taoKouShuiWei_day;
+    public static ShuiWeiBianHuaData taoKouShuiWei_month;
 
     public static PageIndex pageIndex;
 }

+ 3 - 3
Assets/Scripts/UI/Data/ShuiWeiData.cs

@@ -14,9 +14,9 @@ public enum shuiWeiType
 public class ThreeLevelShuiWeiData
 {
     public string location;
-    public float flood_protection_level;
-    public float warning_level;
-    public float guarantee_level;
+    public float floodProtectionLevel;
+    public float warningLevel;
+    public float guaranteeLevel;
 }
 
 

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

@@ -16,6 +16,12 @@ public class ServerAddress
     /// </summary>
     public static string APIGetWaterManagerProject = YZTServerAddress + "/open/data/projects";
 
+
+    /// <summary>
+    /// 获取一张图工程概况
+    /// </summary>
+    public static string APIGetWaterGaiKuang = YZTServerAddress + "/open/projectStat/gaikuang";
+
     /// <summary>
     /// 获取一张图所有热点数据
     /// </summary>
@@ -55,7 +61,7 @@ public class ServerAddress
     /// <summary>
     /// 获取三线水位数据
     /// </summary>
-    public static string APIGetThreeLevel = YZTServerAddress + "/get-swyj-base-data";
+    public static string APIGetThreeLevel = YZTServerAddress + "/open/data/swyjBase";
 
     /// <summary>
     /// 获取蓄洪概况图片位置

+ 27 - 12
Assets/Scripts/UI/UIView/SWYJ/SWYJLayer.cs

@@ -200,20 +200,35 @@ public class StationData:IComparable
 
             float value1 = GlobalData.BuYuanShuiWeiDataList[0].value;
             float value2 = GlobalData.BuYuanShuiWeiDataList[1].value;
-            _pingJunShuiWeiText.text = $"{((value1 + value2)/2).ToString("0.00")} <color=#A5BBE2>m</color>";
-            _sheFangShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].flood_protection_level} m";
-            _jingJieShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].warning_level} m";
-            _baoZhengShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].guarantee_level} m";
+            if (value1 > 1000) {
+                value1 = value1 / 100.0f;
+            }
+            if (value2 > 1000)
+            {
+                value2 = value2 / 100.0f;
+            }
+            _pingJunShuiWeiText.text = $"{((value1 + value2) / 2).ToString("0.00")} <color=#A5BBE2>m</color>";
+            _sheFangShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].floodProtectionLevel} m";
+            _jingJieShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].warningLevel} m";
+            _baoZhengShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[0].guaranteeLevel} m";
             _shuiWeiText.text = $"{value1.ToString("0.00")}";
         }
         else
         {
-            float value1 = GlobalData.BuYuanShuiWeiDataList[0].value;
-            float value2 = GlobalData.BuYuanShuiWeiDataList[1].value;
+            float value1 = GlobalData.TaoKouShuiWeiDataList[0].value;
+            float value2 = GlobalData.TaoKouShuiWeiDataList[1].value;
+            if (value1 > 1000)
+            {
+                value1 = value1 / 100.0f;
+            }
+            if (value2 > 1000)
+            {
+                value2 = value2 / 100.0f;
+            }
             _pingJunShuiWeiText.text = $"{((value1 + value2) / 2).ToString("0.00")} <color=#A5BBE2>m</color>";
-            _sheFangShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].flood_protection_level} m";
-            _jingJieShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].warning_level} m";
-            _baoZhengShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].guarantee_level} m";
+            _sheFangShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].floodProtectionLevel} m";
+            _jingJieShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].warningLevel} m";
+            _baoZhengShuiWeiText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].guaranteeLevel} m";
             _shuiWeiText.text = $"{value1.ToString("0.00")}";
 
         }
@@ -402,13 +417,13 @@ public class StationData:IComparable
             switch (value)
             {
                 case 0:
-                    SetShuiWeiTongJiBarChart(ShuiWeiBianHuaData_TK_Month);
+                    SetShuiWeiTongJiBarChart(GlobalData.taoKouShuiWei_month);
                     break;
                 case 1:
-                    SetShuiWeiTongJiBarChart(ShuiWeiBianHuaData_TK_Day);
+                    SetShuiWeiTongJiBarChart(GlobalData.taoKouShuiWei_day);
                     break;
                 case 2:
-                    SetShuiWeiTongJiBarChart(ShuiWeiBianHuaData_TK_Hour);
+                    SetShuiWeiTongJiBarChart(GlobalData.taoKouShuiWei_hour);
                     break;
             }
         }

+ 20 - 0
Assets/Scripts/UI/UIView/YZT/YZTLayer.cs

@@ -31,6 +31,13 @@ public enum LayerUnitType
     QT
 }
 
+public class GCGKData
+{
+    public string name;
+    public string type;
+    public int count;
+}
+
 [System.Serializable]
 public class LayerUnitData
 {
@@ -169,6 +176,11 @@ public class YZTLayer : YZTRootLayer
     public Item0 item0Prefab;
     public GameObject item0Parent;
 
+    public Text normalCount;
+    public Text badCount;
+    public Text stopCount;
+    public Text allCount;
+
     async void Awake()
     {
         viewMode = ViewMode.miniMap;
@@ -180,6 +192,7 @@ public class YZTLayer : YZTRootLayer
         InitLayerInfo();
         InitLayerBtns();
         InitReturnBtn();
+        InitGCGKData();
         InitRainInfo();
         InitSWHeightInfo();
         await InitPointData();
@@ -187,6 +200,13 @@ public class YZTLayer : YZTRootLayer
 
     }
 
+    void InitGCGKData() {
+        normalCount.text = GlobalData.gcgkContents[0].count.ToString() + "个";
+        badCount.text = GlobalData.gcgkContents[1].count.ToString() + "个";
+        stopCount.text = GlobalData.gcgkContents[2].count.ToString() + "个";
+        allCount.text = (GlobalData.gcgkContents[0].count + GlobalData.gcgkContents[1].count + GlobalData.gcgkContents[2].count).ToString() + "个";
+    }
+
     void InitLeftBtn()
     {
         for (int i = 0; i < leftButtons.Length; i++)

部分文件因为文件数量过多而无法显示