BigScreenLayer.cs 37 KB

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