BigScreenLayer.cs 33 KB

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