BigScreenLayer.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. using Newtonsoft.Json.Linq;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.Networking;
  8. using UnityEngine.Serialization;
  9. using UnityEngine.UI;
  10. using System.Threading.Tasks;
  11. using UnityAsync;
  12. using WaitUntil = UnityAsync.WaitUntil;
  13. using System.Reflection;
  14. using XCharts.Runtime;
  15. [System.Serializable]
  16. public class FloodGate
  17. {
  18. [FormerlySerializedAs("GateNumber")] public int sensor_id;
  19. [FormerlySerializedAs("IsOpen")] public bool gate_open;
  20. //public float CurrentFlow;
  21. [FormerlySerializedAs("CurrentOpening")] public float opening_degree;
  22. public bool gate_breakdown;
  23. public string updateTime=>GetTime();
  24. public long record_ts;
  25. public string station_name;
  26. private string GetTime()
  27. {
  28. DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(record_ts);
  29. return dtDateTime.ToString("s");
  30. }
  31. }
  32. [System.Serializable]
  33. public class FloodGateLocationData
  34. {
  35. public FloodGate[] FloodGates;
  36. }
  37. [System.Serializable]
  38. public class FloodGateStatusData
  39. {
  40. [FormerlySerializedAs("BuYuan")] public FloodGate[] buYuan;
  41. [FormerlySerializedAs("TaoKou")] public FloodGate[] taoKou;
  42. public string taoKouSW;
  43. public string buYuanSW;
  44. public bool success = false;
  45. public int BuYuanTotalGates => buYuan.Length;
  46. public int BuYuanOperationalGates => CountOperationalGates(buYuan);
  47. public int TaoKouTotalGates => taoKou.Length;
  48. public int TaoKouOperationalGates => CountOperationalGates(taoKou);
  49. private int CountOperationalGates(FloodGate[] gates)
  50. {
  51. int count = 0;
  52. foreach (var gate in gates)
  53. {
  54. if (!gate.gate_breakdown) count++;
  55. }
  56. return count;
  57. }
  58. }
  59. [System.Serializable]
  60. public class LocationWeatherData
  61. {
  62. public float currentWaterLevel;
  63. public float rainfall;
  64. public float floodDischarge;
  65. public float temperature;
  66. public string weather;
  67. }
  68. [System.Serializable]
  69. public class StationInspection
  70. {
  71. public InspectionDaily daily;
  72. public InspectionDaily monthly;
  73. public InspectionDaily yearly;
  74. }
  75. [System.Serializable]
  76. public class InspectionDaily
  77. {
  78. public int operationStaffCount;
  79. public int inspectionTasksCount;
  80. public int inspectionKilometers;
  81. public int faultHazardCount;
  82. public int processedFaultCount;
  83. public int engineeringMaintenanceCount;
  84. }
  85. [System.Serializable]
  86. public class AlertData
  87. {
  88. public bool success = false;
  89. public Alerts alerts;
  90. }
  91. [System.Serializable]
  92. public class Alerts
  93. {
  94. public List<AlertDataEvent> warningEvents = new List<AlertDataEvent>();
  95. public List<AlertDataEvent> floodForecasts = new List<AlertDataEvent>();
  96. public List<AlertDataEvent> weatherForecasts = new List<AlertDataEvent>();
  97. public List<AlertDataEvent> threeLineWarnings = new List<AlertDataEvent>();
  98. }
  99. [System.Serializable]
  100. public class AlertDataEvent
  101. {
  102. public int id;
  103. public string title;
  104. public string location;
  105. public string time;
  106. }
  107. public class BigScreenLayer : MonoBehaviour
  108. {
  109. public VerticalLayoutGroup content;
  110. public RectTransform znz;
  111. public Button gkButton;
  112. public Button normalButton;
  113. public Button clearBtn;
  114. public Button exitBtn;
  115. public Button exitJJBtn;
  116. public Button ddysButton;
  117. public Button exit_ddysButton;
  118. public GameObject gk;
  119. public GameObject normal;
  120. public YZTLayer zTLayer;
  121. public RectTransform miniMap;
  122. public RectTransform rightContent;
  123. public RingChart floodRingChart;
  124. public Button floodButton;
  125. public Text[] floodTexts;
  126. public RectTransform popWindow;
  127. public GameObject floodDataPrefab;
  128. public Button[] floodListBtns;
  129. public GridLayoutGroup[] floodLists;
  130. public Button floodListExitBtn;
  131. public Text swValue1;
  132. public Text swValue2;
  133. public Text swValue3;
  134. public Text swValue4;
  135. public Text swValue5;
  136. public Dropdown swDrop0;
  137. public Text yunValue1;
  138. public Text yunValue2;
  139. public Text yunValue3;
  140. public Text yunValue4;
  141. public Text yunValue5;
  142. public Text yunValue6;
  143. public int currentYunIndex = 0;
  144. public Dropdown yunDrop0;
  145. public Dropdown yunDrop1;
  146. List<LayerBtn> layerBtns = new List<LayerBtn>();
  147. // Start is called before the first frame update
  148. public GameObject obsItemPrefab;
  149. private List<ObsItem> obsItemList = new List<ObsItem>();
  150. private Transform obsItemContent;
  151. public ObsPlayerPanel obsPlayerPanel;
  152. private InputField _obsSearchInputField;
  153. public GameObject WaterRangeCtrlPanel;
  154. public GameObject sunshigaikuangPanel;
  155. public GameObject yjPrefab;
  156. public Button[] yjBtns;
  157. public GridLayoutGroup[] yjLayout;
  158. public Sprite[] sprites;
  159. public Text ymmjText;
  160. public Text ymgdText;
  161. public Text yxrkText;
  162. public Text ccssText;
  163. public VerticalLayoutGroup shuiShiliebiaoParent;
  164. public List<ShuiShiLieBiaoItem> shuiShiLieBiaoItems = new List<ShuiShiLieBiaoItem>();
  165. public ShuiShiLieBiaoItem shuiShiLieBiaoItem;
  166. public WaterRangeCtrlTool mTools;
  167. async void Start()
  168. {
  169. CameraManager.SwitchCamera(0);
  170. StaticLod.instance.OnFoucusStatic(0);
  171. InitButton();
  172. obsPlayerPanel = this.transform.Find("ObsPlayerPanel").GetComponent<ObsPlayerPanel>();
  173. obsPlayerPanel.gameObject.SetActive(false);
  174. obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content");
  175. _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent<InputField>();
  176. _obsSearchInputField.onValueChanged.AddListener(SearchObsItem);
  177. InitFloodGateData();
  178. InitHydrologicalData();
  179. InitLayerBtns();
  180. InitObsItems();
  181. InitInspectionStatistics();
  182. InitAlert();
  183. InitData();
  184. }
  185. public async void InitData()
  186. {
  187. WWW www = new WWW(Application.streamingAssetsPath + "/areaBaseData.json");
  188. await new UnityAsync.WaitUntil(() => { return www.isDone; });
  189. string areaBaseDataContent = www.text;
  190. GlobalData.areaFHXSDatas = JsonConvert.DeserializeObject<List<AreaFHXSData>>(areaBaseDataContent);
  191. for (int i = 0; i < GlobalData.areaFHXSDatas.Count; i++)
  192. {
  193. ShuiShiLieBiaoItem tempItem = Instantiate(shuiShiLieBiaoItem);
  194. shuiShiLieBiaoItems.Add(tempItem);
  195. tempItem.transform.SetParent(shuiShiliebiaoParent.transform);
  196. tempItem.transform.localScale = Vector3.one;
  197. tempItem.SetData(GlobalData.areaFHXSDatas[i]);
  198. tempItem.Evaluate(1);
  199. }
  200. mTools.onCtrlChange = (float value) =>
  201. {
  202. float ymmj = 0;
  203. float ymgd = 0;
  204. float yxrk = 0;
  205. float ccss = 0;
  206. for (int i = 0; i < shuiShiLieBiaoItems.Count; i++)
  207. {
  208. shuiShiLieBiaoItems[i].Evaluate(value);
  209. ymmj += shuiShiLieBiaoItems[i].currentMianJi;
  210. ymgd += shuiShiLieBiaoItems[i].currentGenDi;
  211. yxrk += shuiShiLieBiaoItems[i].currentRenKou;
  212. ccss += shuiShiLieBiaoItems[i].currentCaiChan;
  213. }
  214. ymmjText.text = ymmj.ToString("0.00") + "<color=#A5BFE2>平方公里</color>";
  215. ymgdText.text = ymgd.ToString("0.0") + "<color=#A5BFE2>亩</color>";
  216. yxrkText.text = yxrk.ToString("0") + "<color=#A5BFE2>个</color>";
  217. ccssText.text = ccss.ToString("0.00") + "<color=#A5BFE2>亿元</color>";
  218. };
  219. }
  220. void InitButton()
  221. {
  222. normalButton.onClick.AddListener(() =>
  223. {
  224. normal.gameObject.SetActive(true);
  225. gk.gameObject.SetActive(false);
  226. });
  227. gkButton.onClick.AddListener(() =>
  228. {
  229. gk.gameObject.SetActive(true);
  230. miniMap.gameObject.SetActive(true);
  231. rightContent.parent.gameObject.SetActive(false);
  232. normal.gameObject.SetActive(false);
  233. });
  234. clearBtn.onClick.AddListener(() =>
  235. {
  236. normal.gameObject.SetActive(false);
  237. gk.gameObject.SetActive(false);
  238. exitBtn.gameObject.SetActive(true);
  239. normalButton.gameObject.SetActive(false);
  240. gkButton.gameObject.SetActive(false);
  241. clearBtn.gameObject.SetActive(false);
  242. ddysButton.gameObject.SetActive(false);
  243. });
  244. exitBtn.onClick.AddListener(() =>
  245. {
  246. normal.gameObject.SetActive(true);
  247. gk.gameObject.SetActive(false);
  248. exitBtn.gameObject.SetActive(false);
  249. normalButton.gameObject.SetActive(true);
  250. gkButton.gameObject.SetActive(true);
  251. clearBtn.gameObject.SetActive(true);
  252. ddysButton.gameObject.SetActive(true);
  253. });
  254. exitJJBtn.onClick.AddListener(() =>
  255. {
  256. normal.gameObject.SetActive(true);
  257. gk.gameObject.SetActive(false);
  258. });
  259. ddysButton.onClick.AddListener(() =>
  260. {
  261. StaticLod.instance.OnFoucusStatic("Bird0");
  262. normal.gameObject.SetActive(false);
  263. gk.gameObject.SetActive(false);
  264. normalButton.gameObject.SetActive(false);
  265. gkButton.gameObject.SetActive(false);
  266. clearBtn.gameObject.SetActive(false);
  267. WaterRangeCtrlPanel.SetActive(true);
  268. sunshigaikuangPanel.SetActive(true);
  269. });
  270. exit_ddysButton.onClick.AddListener(() =>
  271. {
  272. StaticLod.instance.OnFoucusStatic(0);
  273. WaterRangeCtrlPanel.SetActive(false);
  274. normal.gameObject.SetActive(true);
  275. gk.gameObject.SetActive(false);
  276. exitBtn.gameObject.SetActive(false);
  277. normalButton.gameObject.SetActive(true);
  278. gkButton.gameObject.SetActive(true);
  279. clearBtn.gameObject.SetActive(true);
  280. ddysButton.gameObject.SetActive(true);
  281. sunshigaikuangPanel.SetActive(false);
  282. });
  283. // public Button ddysButton;
  284. // public Button exit_ddysButton;
  285. }
  286. private async Task InitAlert()
  287. {
  288. await new WaitUntil(() =>
  289. {
  290. return GlobalData.alertData.success;
  291. });
  292. for (int i = 0; i < yjLayout.Length; i++)
  293. {
  294. yjLayout[i].transform.parent.parent.parent.gameObject.SetActive(false);
  295. }
  296. yjLayout[0].transform.parent.parent.parent.gameObject.SetActive(true);
  297. for (int i = 0; i < GlobalData.alertData.alerts.warningEvents.Count; i++)
  298. {
  299. GameObject obj = Instantiate(yjPrefab);
  300. obj.transform.SetParent(yjLayout[0].transform);
  301. obj.transform.localScale = Vector3.one;
  302. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].id.ToString();
  303. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].title.ToString();
  304. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].location.ToString();
  305. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].time.ToString();
  306. }
  307. for (int i = 0; i < GlobalData.alertData.alerts.floodForecasts.Count; i++)
  308. {
  309. GameObject obj = Instantiate(yjPrefab);
  310. obj.transform.SetParent(yjLayout[1].transform);
  311. obj.transform.localScale = Vector3.one;
  312. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].id.ToString();
  313. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].title.ToString();
  314. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].location.ToString();
  315. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].time.ToString();
  316. }
  317. for (int i = 0; i < GlobalData.alertData.alerts.weatherForecasts.Count; i++)
  318. {
  319. GameObject obj = Instantiate(yjPrefab);
  320. obj.transform.SetParent(yjLayout[2].transform);
  321. obj.transform.localScale = Vector3.one;
  322. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].id.ToString();
  323. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].title.ToString();
  324. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].location.ToString();
  325. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].time.ToString();
  326. }
  327. for (int i = 0; i < GlobalData.alertData.alerts.threeLineWarnings.Count; i++)
  328. {
  329. GameObject obj = Instantiate(yjPrefab);
  330. obj.transform.SetParent(yjLayout[3].transform);
  331. obj.transform.localScale = Vector3.one;
  332. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].id.ToString();
  333. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].title.ToString();
  334. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].location.ToString();
  335. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].time.ToString();
  336. }
  337. for (int i = 0; i < yjBtns.Length; i++)
  338. {
  339. int temp = i;
  340. yjBtns[i].onClick.AddListener(() =>
  341. {
  342. for (int j = 0; j < yjBtns.Length; j++)
  343. {
  344. yjBtns[j].transform.GetChild(0).GetComponent<Text>().color = Color.gray;
  345. }
  346. yjBtns[temp].transform.GetChild(0).GetComponent<Text>().color = Color.white;
  347. for (int j = 0; j < yjLayout.Length; j++)
  348. {
  349. yjLayout[j].transform.parent.parent.parent.gameObject.SetActive(false);
  350. }
  351. yjLayout[temp].transform.parent.parent.parent.gameObject.SetActive(true);
  352. });
  353. }
  354. }
  355. private async Task InitHydrologicalData()
  356. {
  357. await new WaitUntil(() =>
  358. {
  359. return GlobalData.locationWeatherData.Count > 0;
  360. });
  361. ChangeLocationWeatherData(0);
  362. swDrop0.onValueChanged.AddListener((index) =>
  363. {
  364. ChangeLocationWeatherData(index);
  365. });
  366. }
  367. private void ChangeLocationWeatherData(int index)
  368. {
  369. swValue1.text = GlobalData.locationWeatherData[index].currentWaterLevel.ToString();
  370. swValue2.text = GlobalData.locationWeatherData[index].rainfall.ToString();
  371. swValue3.text = GlobalData.locationWeatherData[index].temperature.ToString();
  372. swValue4.text = GlobalData.locationWeatherData[index].weather.ToString();
  373. swValue5.text = GlobalData.locationWeatherData[index].floodDischarge.ToString();
  374. }
  375. private async Task InitFloodGateData()
  376. {
  377. await new WaitUntil(() =>
  378. {
  379. return GlobalData.floorGateData.success;
  380. });
  381. await new WaitUntil(() =>
  382. {
  383. return GlobalData.buYuanSensorData.data.Count>0&&GlobalData.taoKouSensorData.data.Count>0;
  384. });
  385. floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  386. floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  387. floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString();
  388. floodButton.onClick.AddListener(() =>
  389. {
  390. popWindow.gameObject.SetActive(true);
  391. });
  392. floodListExitBtn.onClick.AddListener(() =>
  393. {
  394. popWindow.gameObject.SetActive(false);
  395. });
  396. floodListBtns[0].onClick.AddListener(() =>
  397. {
  398. floodListBtns[0].GetComponent<Image>().sprite = sprites[0];
  399. floodListBtns[1].GetComponent<Image>().sprite = sprites[1];
  400. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true);
  401. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false);
  402. });
  403. floodListBtns[1].onClick.AddListener(() =>
  404. {
  405. floodListBtns[0].GetComponent<Image>().sprite = sprites[1];
  406. floodListBtns[1].GetComponent<Image>().sprite = sprites[0];
  407. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false);
  408. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true);
  409. });
  410. var buyuanData = GlobalData.buYuanSensorData.data;
  411. for (int i = 0; i < buyuanData.Count; i++)
  412. {
  413. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  414. floodGateDataObj.transform.SetParent(floodLists[0].transform);
  415. floodGateDataObj.transform.localScale = Vector3.one;
  416. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  417. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = buyuanData[i].gate_opening ? "开启" : "关闭";
  418. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  419. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  420. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = buyuanData[i].opening_degree*0.01 + "m";
  421. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = buyuanData[i].gate_breakdown ? "故障":"正常";
  422. }
  423. var taokouData = GlobalData.taoKouSensorData.data;
  424. for (int i = 0; i < taokouData.Count; i++)
  425. {
  426. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  427. floodGateDataObj.transform.SetParent(floodLists[1].transform);
  428. floodGateDataObj.transform.localScale = Vector3.one;
  429. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  430. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = taokouData[i].gate_opening ? "开启" : "关闭";
  431. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  432. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  433. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = taokouData[i].opening_degree*0.01 + "m";
  434. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = taokouData[i].gate_breakdown ? "故障":"正常";
  435. }
  436. // for (int i = 0; i < GlobalData.floorGateData.BuYuan.FloodGates.Length; i++)
  437. // {
  438. // GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  439. // floodGateDataObj.transform.SetParent(floodLists[0].transform);
  440. // floodGateDataObj.transform.localScale = Vector3.one;
  441. // floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  442. // floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].IsOpen ? "开启" : "关闭";
  443. // floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentFlow + "m³/s";
  444. // floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.CurrentWaterLevel + "m";
  445. // floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentOpening + "°";
  446. // switch (GlobalData.floorGateData.BuYuan.FloodGates[i].Status)
  447. // {
  448. // case 0:
  449. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  450. // break;
  451. // case 1:
  452. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  453. // break;
  454. // }
  455. // }
  456. // for (int i = 0; i < GlobalData.floorGateData.TaoKou.FloodGates.Length; i++)
  457. // {
  458. // GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  459. // floodGateDataObj.transform.SetParent(floodLists[1].transform);
  460. // floodGateDataObj.transform.localScale = Vector3.one;
  461. // floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  462. // floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].IsOpen ? "开启" : "关闭";
  463. // floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentFlow + "m³/s";
  464. // floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.CurrentWaterLevel + "m";
  465. // floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentOpening + "°";
  466. // switch (GlobalData.floorGateData.TaoKou.FloodGates[i].Status)
  467. // {
  468. // case 0:
  469. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  470. // break;
  471. // case 1:
  472. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  473. // break;
  474. // }
  475. // }
  476. List<double> doubles = new List<double>();
  477. doubles.Add(90);
  478. doubles.Add(100);
  479. floodRingChart.UpdateData(0, 0, doubles);
  480. }
  481. private async Task InitInspectionStatistics()
  482. {
  483. await new WaitUntil(() =>
  484. {
  485. return GlobalData.InspectionStat.Count > 0;
  486. });
  487. currentYunIndex = 0;
  488. yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString();
  489. yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString();
  490. yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString();
  491. yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString();
  492. yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString();
  493. yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString();
  494. yunDrop0.onValueChanged.AddListener((index) =>
  495. {
  496. currentYunIndex = index;
  497. SwitchStationStat(yunDrop1.value);
  498. });
  499. yunDrop1.onValueChanged.AddListener((index) =>
  500. {
  501. SwitchStationStat(index);
  502. });
  503. }
  504. void SwitchStationStat(int index)
  505. {
  506. switch (index)
  507. {
  508. case 0:
  509. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString();
  510. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString();
  511. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString();
  512. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString();
  513. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString();
  514. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString();
  515. break;
  516. case 1:
  517. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString();
  518. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString();
  519. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString();
  520. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString();
  521. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString();
  522. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString();
  523. break;
  524. case 2:
  525. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString();
  526. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString();
  527. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString();
  528. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString();
  529. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString();
  530. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString();
  531. break;
  532. }
  533. }
  534. private async Task InitLayerBtns()
  535. {
  536. await new WaitUntil(() =>
  537. {
  538. return GlobalData.layerUnitDatas.Count > 0;
  539. });
  540. layerBtns = new List<LayerBtn>();
  541. for (int i = 0; i < zTLayer.layerDatas.Length; i++)
  542. {
  543. LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab);
  544. layerBtn.SetUseful(false);
  545. int index = i;
  546. int num = 0;
  547. if (i == 0)
  548. {
  549. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  550. for (int j = 0; j < tempDatas.Count; j++)
  551. {
  552. if (tempDatas[j].special == "1")
  553. {
  554. int tempJ = j;
  555. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  556. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  557. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  558. secLayerBtn.btn.onClick.AddListener(() =>
  559. {
  560. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  561. miniMap.gameObject.SetActive(false);
  562. ChangeRightContent(tempJ);
  563. });
  564. num++;
  565. }
  566. }
  567. layerBtn.secContent.gameObject.SetActive(true);
  568. }
  569. else
  570. {
  571. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  572. for (int j = 0; j < tempDatas.Count; j++)
  573. {
  574. Debug.Log(zTLayer.layerDatas.Length);
  575. Debug.Log(i);
  576. if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID)
  577. {
  578. int tempJ = j;
  579. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  580. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  581. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  582. secLayerBtn.btn.onClick.AddListener(() =>
  583. {
  584. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  585. miniMap.gameObject.SetActive(false);
  586. ChangeRightContent(tempJ);
  587. });
  588. num++;
  589. }
  590. }
  591. }
  592. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  593. {
  594. for (int j = 0; j < layerBtns.Count; j++)
  595. {
  596. layerBtns[j].SetUseful(false);
  597. layerBtns[j].secContent.gameObject.SetActive(false);
  598. }
  599. layerBtns[index].SetUseful(true);
  600. layerBtns[index].secContent.gameObject.SetActive(true);
  601. });
  602. layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
  603. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  604. layerBtn.transform.localScale = Vector3.one;
  605. layerBtns.Add(layerBtn);
  606. }
  607. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  608. layerBtns[0].SetUseful(true);
  609. }
  610. void ChangeRightContent(int index)
  611. {
  612. rightContent.parent.gameObject.SetActive(true);
  613. for (int i = 0; i < rightContent.childCount; i++)
  614. {
  615. rightContent.GetChild(i).gameObject.SetActive(false);
  616. }
  617. rightContent.GetChild(index).gameObject.SetActive(true);
  618. }
  619. // Update is called once per frame
  620. void Update()
  621. {
  622. znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
  623. }
  624. public async Task InitObsItems()
  625. {
  626. await new WaitUntil(() =>
  627. {
  628. return GlobalData.obsDatas_by.Count > 0&& GlobalData.obsDatas_tk.Count>0;
  629. });
  630. for (int i = 0; i < obsItemList.Count; i++)
  631. {
  632. Destroy(obsItemList[i].gameObject);
  633. }
  634. obsItemList.Clear();
  635. var obsDatasBy = GlobalData.obsDatas_by;
  636. for (int i = 0; i < obsDatasBy.Count; i++)
  637. {
  638. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  639. tempObj.SetData(obsDatasBy[i]);
  640. tempObj._button.onClick.AddListener(() =>
  641. {
  642. ShowObsPanel(tempObj._data);
  643. });
  644. obsItemList.Add(tempObj);
  645. }
  646. var obsDatasTk = GlobalData.obsDatas_tk;
  647. for (int i = 0; i < obsDatasTk.Count; i++)
  648. {
  649. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  650. tempObj.SetData(obsDatasTk[i]);
  651. tempObj._button.onClick.AddListener(() =>
  652. {
  653. ShowObsPanel(tempObj._data);
  654. });
  655. obsItemList.Add(tempObj);
  656. }
  657. }
  658. public void SearchObsItem(string s_name)
  659. {
  660. if (s_name.Equals(""))
  661. {
  662. for (int i = 0; i < obsItemList.Count; i++)
  663. {
  664. obsItemList[i].gameObject.SetActive(true);
  665. }
  666. }
  667. else
  668. {
  669. for (int i = 0; i < obsItemList.Count; i++)
  670. {
  671. obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
  672. }
  673. }
  674. }
  675. public void ShowObsPanel(ObsData _data)
  676. {
  677. obsPlayerPanel.gameObject.SetActive(true);
  678. obsPlayerPanel.SetObsData(_data);
  679. obsPlayerPanel.SetTitle(_data.name);
  680. }
  681. }