BigScreenLayer.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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. InitPoint();
  209. }
  210. public async void InitData()
  211. {
  212. WWW www = new WWW(Application.streamingAssetsPath + "/areaBaseData.json");
  213. await new UnityAsync.WaitUntil(() => { return www.isDone; });
  214. string areaBaseDataContent = www.text;
  215. GlobalData.areaFHXSDatas = JsonConvert.DeserializeObject<List<AreaFHXSData>>(areaBaseDataContent);
  216. for (int i = 0; i < GlobalData.areaFHXSDatas.Count; i++)
  217. {
  218. ShuiShiLieBiaoItem tempItem = Instantiate(shuiShiLieBiaoItem);
  219. shuiShiLieBiaoItems.Add(tempItem);
  220. tempItem.transform.SetParent(shuiShiliebiaoParent.transform);
  221. tempItem.transform.localScale = Vector3.one;
  222. tempItem.SetData(GlobalData.areaFHXSDatas[i]);
  223. tempItem.Evaluate(1);
  224. }
  225. mTools.onCtrlChange = (float value) =>
  226. {
  227. float ymmj = 0;
  228. float ymgd = 0;
  229. float yxrk = 0;
  230. float ccss = 0;
  231. for (int i = 0; i < shuiShiLieBiaoItems.Count; i++)
  232. {
  233. shuiShiLieBiaoItems[i].Evaluate(value);
  234. ymmj += shuiShiLieBiaoItems[i].currentMianJi;
  235. ymgd += shuiShiLieBiaoItems[i].currentGenDi;
  236. yxrk += shuiShiLieBiaoItems[i].currentRenKou;
  237. ccss += shuiShiLieBiaoItems[i].currentCaiChan;
  238. }
  239. ymmjText.text = ymmj.ToString("0.00") + "<color=#A5BFE2>平方公里</color>";
  240. ymgdText.text = ymgd.ToString("0.0") + "<color=#A5BFE2>亩</color>";
  241. yxrkText.text = yxrk.ToString("0") + "<color=#A5BFE2>个</color>";
  242. ccssText.text = ccss.ToString("0.00") + "<color=#A5BFE2>亿元</color>";
  243. };
  244. }
  245. void InitButton()
  246. {
  247. normalButton.onClick.AddListener(() =>
  248. {
  249. normal.gameObject.SetActive(true);
  250. gk.gameObject.SetActive(false);
  251. });
  252. gkButton.onClick.AddListener(() =>
  253. {
  254. gk.gameObject.SetActive(true);
  255. miniMap.gameObject.SetActive(true);
  256. rightContent.parent.gameObject.SetActive(false);
  257. normal.gameObject.SetActive(false);
  258. });
  259. clearBtn.onClick.AddListener(() =>
  260. {
  261. normal.gameObject.SetActive(false);
  262. gk.gameObject.SetActive(false);
  263. exitBtn.gameObject.SetActive(true);
  264. normalButton.gameObject.SetActive(false);
  265. gkButton.gameObject.SetActive(false);
  266. clearBtn.gameObject.SetActive(false);
  267. ddysButton.gameObject.SetActive(false);
  268. });
  269. exitBtn.onClick.AddListener(() =>
  270. {
  271. normal.gameObject.SetActive(true);
  272. gk.gameObject.SetActive(false);
  273. exitBtn.gameObject.SetActive(false);
  274. normalButton.gameObject.SetActive(true);
  275. gkButton.gameObject.SetActive(true);
  276. clearBtn.gameObject.SetActive(true);
  277. ddysButton.gameObject.SetActive(true);
  278. });
  279. exitJJBtn.onClick.AddListener(() =>
  280. {
  281. normal.gameObject.SetActive(true);
  282. gk.gameObject.SetActive(false);
  283. });
  284. ddysButton.onClick.AddListener(() =>
  285. {
  286. StaticLod.instance.OnFoucusStatic("Bird0");
  287. normal.gameObject.SetActive(false);
  288. gk.gameObject.SetActive(false);
  289. normalButton.gameObject.SetActive(false);
  290. gkButton.gameObject.SetActive(false);
  291. clearBtn.gameObject.SetActive(false);
  292. WaterRangeCtrlPanel.SetActive(true);
  293. sunshigaikuangPanel.SetActive(true);
  294. });
  295. exit_ddysButton.onClick.AddListener(() =>
  296. {
  297. StaticLod.instance.OnFoucusStatic(0);
  298. WaterRangeCtrlPanel.SetActive(false);
  299. normal.gameObject.SetActive(true);
  300. gk.gameObject.SetActive(false);
  301. exitBtn.gameObject.SetActive(false);
  302. normalButton.gameObject.SetActive(true);
  303. gkButton.gameObject.SetActive(true);
  304. clearBtn.gameObject.SetActive(true);
  305. ddysButton.gameObject.SetActive(true);
  306. sunshigaikuangPanel.SetActive(false);
  307. });
  308. // public Button ddysButton;
  309. // public Button exit_ddysButton;
  310. }
  311. public Item0 item0Prefab;
  312. public GameObject item0Parent;
  313. public Sprite[] hotPointSprite;
  314. void OnNewPointClick(HotPointData temp, Item0 item0)
  315. {
  316. CameraManager.SwitchCamera(0);
  317. StaticLod.instance.OnFoucusStatic(item0.staticImp);
  318. }
  319. int FindIndexByLayerUnitName(string name)
  320. {
  321. for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
  322. {
  323. if (GlobalData.layerUnitDatas[i].name == name.Trim())
  324. {
  325. return i;
  326. }
  327. }
  328. return -1;
  329. }
  330. async void InitPoint()
  331. {
  332. await new WaitUntil(() =>
  333. {
  334. return GlobalData.hotPointDatas.Count > 0;
  335. });
  336. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  337. List<Item0> item0s = new List<Item0>();
  338. for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
  339. {
  340. //if()
  341. HotPointData temp = GlobalData.hotPointDatas[i];
  342. int tempI = i;
  343. if ((int)temp.type == 6 || (int)temp.type == 7 || (int)temp.type == 9)
  344. {
  345. int index = FindIndexByLayerUnitName(temp.name);
  346. Item0 item0 = Instantiate(item0Prefab, Vector3.zero, Quaternion.identity);
  347. item0.InitPoint(hotPointSprite[(int)(temp.type)], temp.namePri, temp.name, GlobalData.layerUnitDatas[index].special);
  348. item0s.Add(item0);
  349. item0.onPointClick = () =>
  350. {
  351. OnNewPointClick(temp, item0);
  352. };
  353. }
  354. }
  355. for (int i = 0; i < item0s.Count; i++)
  356. {
  357. if (item0s[i].mSpecial != "1")
  358. item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
  359. }
  360. for (int i = 0; i < item0s.Count; i++)
  361. {
  362. if (item0s[i].mSpecial == "1")
  363. item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
  364. }
  365. }
  366. private async Task InitAlert()
  367. {
  368. await new WaitUntil(() =>
  369. {
  370. return GlobalData.alertData.success;
  371. });
  372. for (int i = 0; i < yjLayout.Length; i++)
  373. {
  374. yjLayout[i].transform.parent.parent.parent.gameObject.SetActive(false);
  375. }
  376. yjLayout[0].transform.parent.parent.parent.gameObject.SetActive(true);
  377. for (int i = 0; i < GlobalData.alertData.alerts.warningEvents.Count; i++)
  378. {
  379. GameObject obj = Instantiate(yjPrefab);
  380. obj.transform.SetParent(yjLayout[0].transform);
  381. obj.transform.localScale = Vector3.one;
  382. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].id.ToString();
  383. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].title.ToString();
  384. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].location.ToString();
  385. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].time.ToString();
  386. }
  387. for (int i = 0; i < GlobalData.alertData.alerts.floodForecasts.Count; i++)
  388. {
  389. GameObject obj = Instantiate(yjPrefab);
  390. obj.transform.SetParent(yjLayout[1].transform);
  391. obj.transform.localScale = Vector3.one;
  392. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].id.ToString();
  393. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].title.ToString();
  394. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].location.ToString();
  395. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].time.ToString();
  396. }
  397. for (int i = 0; i < GlobalData.alertData.alerts.weatherForecasts.Count; i++)
  398. {
  399. GameObject obj = Instantiate(yjPrefab);
  400. obj.transform.SetParent(yjLayout[2].transform);
  401. obj.transform.localScale = Vector3.one;
  402. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].id.ToString();
  403. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].title.ToString();
  404. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].location.ToString();
  405. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].time.ToString();
  406. }
  407. for (int i = 0; i < GlobalData.alertData.alerts.threeLineWarnings.Count; i++)
  408. {
  409. GameObject obj = Instantiate(yjPrefab);
  410. obj.transform.SetParent(yjLayout[3].transform);
  411. obj.transform.localScale = Vector3.one;
  412. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].id.ToString();
  413. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].title.ToString();
  414. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].location.ToString();
  415. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].time.ToString();
  416. }
  417. for (int i = 0; i < yjBtns.Length; i++)
  418. {
  419. int temp = i;
  420. yjBtns[i].onClick.AddListener(() =>
  421. {
  422. for (int j = 0; j < yjBtns.Length; j++)
  423. {
  424. yjBtns[j].transform.GetChild(0).GetComponent<Text>().color = Color.gray;
  425. }
  426. yjBtns[temp].transform.GetChild(0).GetComponent<Text>().color = Color.white;
  427. for (int j = 0; j < yjLayout.Length; j++)
  428. {
  429. yjLayout[j].transform.parent.parent.parent.gameObject.SetActive(false);
  430. }
  431. yjLayout[temp].transform.parent.parent.parent.gameObject.SetActive(true);
  432. });
  433. }
  434. }
  435. private async Task InitHydrologicalData()
  436. {
  437. await new WaitUntil(() =>
  438. {
  439. return GlobalData.swDatas.Count > 0 && GlobalData.sWZDatas.Count > 0;
  440. });
  441. ChangeLocationWeatherData(0);
  442. swDrop0.onValueChanged.AddListener((index) =>
  443. {
  444. ChangeLocationWeatherData(index);
  445. });
  446. }
  447. private void ChangeLocationWeatherData(int index)
  448. {
  449. string swkey = "";
  450. string qxKey = "";
  451. string swKey = "";
  452. if (index == 0)
  453. {
  454. swkey = "补元(上)";
  455. qxKey = "新滩";
  456. swKey = "新滩";
  457. }
  458. else
  459. {
  460. swkey = "套口(上)";
  461. qxKey = "大沙";
  462. swKey = "大沙";
  463. }
  464. string swH = "-";
  465. for (int i = 0; i < GlobalData.swDatas.Count; i++) {
  466. if (GlobalData.swDatas[i].stnm == swkey) {
  467. swH = GlobalData.swDatas[i].upz;
  468. break;
  469. }
  470. }
  471. int qxIndex = 0;
  472. for (int i = 0; i < GlobalData.qXZDatas.Count; i++)
  473. {
  474. if (GlobalData.qXZDatas[i].STNM.Contains(qxKey))
  475. {
  476. qxIndex = i;
  477. break;
  478. }
  479. }
  480. int swIndex = 0;
  481. for (int i = 0; i < GlobalData.sWZDatas.Count; i++)
  482. {
  483. if (GlobalData.sWZDatas[i].STNM.Contains(swKey))
  484. {
  485. swIndex = i;
  486. break;
  487. }
  488. }
  489. swValue1.text = swH.ToString();
  490. swValue2.text = GlobalData.sWZDatas[qxIndex].dropSum6.ToString();
  491. string we = GlobalData.sWZDatas[swIndex].wth.ToString();
  492. string weatherText = "";
  493. switch (we)
  494. {
  495. case "9":
  496. weatherText = "晴天";
  497. break;
  498. case "8":
  499. weatherText = "阴天";
  500. break;
  501. case "7":
  502. weatherText = "雨天";
  503. break;
  504. case "6":
  505. weatherText = "雨夹雪";
  506. break;
  507. case "5":
  508. weatherText = "雪天";
  509. break;
  510. }
  511. swValue4.text = weatherText;
  512. }
  513. private async Task InitFloodAreaData()
  514. {
  515. await new WaitUntil(() =>
  516. {
  517. //Debug.Log(GlobalData.floodStorageArea.done);
  518. return GlobalData.floodStorageArea.done;
  519. });
  520. floodStorageAreaData[0].text = GlobalData.floodStorageArea.area.value + "km²";
  521. floodStorageAreaData[0].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.area.description;
  522. floodStorageAreaData[1].text = GlobalData.floodStorageArea.leveeLength.value + "km";
  523. floodStorageAreaData[1].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.leveeLength.description;
  524. floodStorageAreaData[2].text = GlobalData.floodStorageArea.storageCapacity.value + "亿m³";
  525. floodStorageAreaData[2].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.storageCapacity.description;
  526. floodStorageAreaData[3].text = GlobalData.floodStorageArea.designWaterLevel.value + "m";
  527. floodStorageAreaData[3].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.designWaterLevel.description;
  528. floodStorageAreaData[4].text = GlobalData.floodStorageArea.operationStandard.value + "级";
  529. floodStorageAreaData[4].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.operationStandard.description;
  530. floodStorageAreaData[5].text = GlobalData.floodStorageArea.safetyZones.value + "项";
  531. floodStorageAreaData[5].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.safetyZones.description;
  532. floodStorageAreaData[6].text = GlobalData.floodStorageArea.gateStations.value + "项";
  533. floodStorageAreaData[6].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.gateStations.description;
  534. floodStorageAreaData[7].text = GlobalData.floodStorageArea.pumpStations.value + "项";
  535. floodStorageAreaData[7].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.pumpStations.description;
  536. floodStorageAreaData[8].text = GlobalData.floodStorageArea.drainageStations.value + "项";
  537. floodStorageAreaData[8].transform.parent.GetComponent<TipShower>().data = GlobalData.floodStorageArea.drainageStations.description;
  538. }
  539. private async Task InitFloodGateData()
  540. {
  541. await new WaitUntil(() =>
  542. {
  543. //Debug.Log("GlobalData.floorGateData.success11:" + GlobalData.floorGateData.success);
  544. return GlobalData.floorGateData.success;
  545. });
  546. await new WaitUntil(() =>
  547. {
  548. return GlobalData.buYuanSensorData.data.Count > 0 && GlobalData.taoKouSensorData.data.Count > 0;
  549. });
  550. floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  551. floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  552. floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString();
  553. floodButton.onClick.AddListener(() =>
  554. {
  555. popWindow.gameObject.SetActive(true);
  556. });
  557. floodListExitBtn.onClick.AddListener(() =>
  558. {
  559. popWindow.gameObject.SetActive(false);
  560. });
  561. floodListBtns[0].onClick.AddListener(() =>
  562. {
  563. floodListBtns[0].GetComponent<Image>().sprite = sprites[0];
  564. floodListBtns[1].GetComponent<Image>().sprite = sprites[1];
  565. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true);
  566. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false);
  567. });
  568. floodListBtns[1].onClick.AddListener(() =>
  569. {
  570. floodListBtns[0].GetComponent<Image>().sprite = sprites[1];
  571. floodListBtns[1].GetComponent<Image>().sprite = sprites[0];
  572. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false);
  573. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true);
  574. });
  575. var buyuanData = GlobalData.buYuanSensorData.data;
  576. for (int i = 0; i < buyuanData.Count; i++)
  577. {
  578. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  579. floodGateDataObj.transform.SetParent(floodLists[0].transform);
  580. floodGateDataObj.transform.localScale = Vector3.one;
  581. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "#闸门";
  582. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = buyuanData[i].gate_opening ? "开启" : "关闭";
  583. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  584. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  585. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = buyuanData[i].opening_degree * 0.01 + "m";
  586. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = buyuanData[i].gate_breakdown ? "故障" : "正常";
  587. }
  588. var taokouData = GlobalData.taoKouSensorData.data;
  589. for (int i = 0; i < taokouData.Count; i++)
  590. {
  591. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  592. floodGateDataObj.transform.SetParent(floodLists[1].transform);
  593. floodGateDataObj.transform.localScale = Vector3.one;
  594. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "#闸门";
  595. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = taokouData[i].gate_opening ? "开启" : "关闭";
  596. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  597. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  598. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = taokouData[i].opening_degree * 0.01 + "m";
  599. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = taokouData[i].gate_breakdown ? "故障" : "正常";
  600. }
  601. List<double> doubles = new List<double>();
  602. doubles.Add(90);
  603. doubles.Add(100);
  604. floodRingChart.UpdateData(0, 0, doubles);
  605. }
  606. private async Task InitInspectionStatistics()
  607. {
  608. await new WaitUntil(() =>
  609. {
  610. return GlobalData.InspectionStat.Count > 0;
  611. });
  612. currentYunIndex = 0;
  613. yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString();
  614. yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString();
  615. yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString();
  616. yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString();
  617. yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString();
  618. yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString();
  619. yunDrop0.onValueChanged.AddListener((index) =>
  620. {
  621. currentYunIndex = index;
  622. SwitchStationStat(yunDrop1.value);
  623. });
  624. yunDrop1.onValueChanged.AddListener((index) =>
  625. {
  626. SwitchStationStat(index);
  627. });
  628. }
  629. void SwitchStationStat(int index)
  630. {
  631. switch (index)
  632. {
  633. case 0:
  634. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString();
  635. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString();
  636. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString();
  637. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString();
  638. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString();
  639. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString();
  640. break;
  641. case 1:
  642. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString();
  643. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString();
  644. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString();
  645. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString();
  646. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString();
  647. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString();
  648. break;
  649. case 2:
  650. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString();
  651. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString();
  652. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString();
  653. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString();
  654. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString();
  655. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString();
  656. break;
  657. }
  658. }
  659. private async Task InitLayerBtns()
  660. {
  661. await new WaitUntil(() =>
  662. {
  663. return GlobalData.layerUnitDatas.Count > 0;
  664. });
  665. layerBtns = new List<LayerBtn>();
  666. for (int i = 0; i < zTLayer.layerDatas.Length; i++)
  667. {
  668. LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab);
  669. layerBtn.SetUseful(false);
  670. int index = i;
  671. int num = 0;
  672. if (i == 0)
  673. {
  674. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  675. for (int j = 0; j < tempDatas.Count; j++)
  676. {
  677. if (tempDatas[j].special == "1")
  678. {
  679. int tempJ = j;
  680. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  681. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  682. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  683. secLayerBtn.btn.onClick.AddListener(() =>
  684. {
  685. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  686. miniMap.gameObject.SetActive(false);
  687. ChangeRightContent(tempJ);
  688. });
  689. num++;
  690. }
  691. }
  692. layerBtn.secContent.gameObject.SetActive(true);
  693. }
  694. else
  695. {
  696. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  697. for (int j = 0; j < tempDatas.Count; j++)
  698. {
  699. //Debug.Log(zTLayer.layerDatas.Length);
  700. //Debug.Log(i);
  701. if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID)
  702. {
  703. int tempJ = j;
  704. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  705. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  706. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  707. secLayerBtn.btn.onClick.AddListener(() =>
  708. {
  709. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  710. miniMap.gameObject.SetActive(false);
  711. ChangeRightContent(tempJ);
  712. });
  713. num++;
  714. }
  715. }
  716. }
  717. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  718. {
  719. for (int j = 0; j < layerBtns.Count; j++)
  720. {
  721. layerBtns[j].SetUseful(false);
  722. layerBtns[j].secContent.gameObject.SetActive(false);
  723. }
  724. layerBtns[index].SetUseful(true);
  725. layerBtns[index].secContent.gameObject.SetActive(true);
  726. });
  727. layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
  728. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  729. layerBtn.transform.localScale = Vector3.one;
  730. layerBtns.Add(layerBtn);
  731. }
  732. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  733. layerBtns[0].SetUseful(true);
  734. }
  735. void ChangeRightContent(int index)
  736. {
  737. rightContent.parent.gameObject.SetActive(true);
  738. for (int i = 0; i < rightContent.childCount; i++)
  739. {
  740. rightContent.GetChild(i).gameObject.SetActive(false);
  741. }
  742. rightContent.GetChild(index).gameObject.SetActive(true);
  743. }
  744. // Update is called once per frame
  745. void Update()
  746. {
  747. znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
  748. }
  749. public async Task InitObsItems()
  750. {
  751. await new WaitUntil(() =>
  752. {
  753. return GlobalData.obsDatas_by.Count > 0 && GlobalData.obsDatas_tk.Count > 0;
  754. });
  755. for (int i = 0; i < obsItemList.Count; i++)
  756. {
  757. Destroy(obsItemList[i].gameObject);
  758. }
  759. obsItemList.Clear();
  760. var obsDatasBy = GlobalData.obsDatas_by;
  761. for (int i = 0; i < obsDatasBy.Count; i++)
  762. {
  763. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  764. tempObj.SetData(obsDatasBy[i]);
  765. tempObj._button.onClick.AddListener(() =>
  766. {
  767. ShowObsPanel(tempObj._data);
  768. });
  769. obsItemList.Add(tempObj);
  770. }
  771. var obsDatasTk = GlobalData.obsDatas_tk;
  772. for (int i = 0; i < obsDatasTk.Count; i++)
  773. {
  774. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  775. tempObj.SetData(obsDatasTk[i]);
  776. tempObj._button.onClick.AddListener(() =>
  777. {
  778. ShowObsPanel(tempObj._data);
  779. });
  780. obsItemList.Add(tempObj);
  781. }
  782. }
  783. public void SearchObsItem(string s_name)
  784. {
  785. if (s_name.Equals(""))
  786. {
  787. for (int i = 0; i < obsItemList.Count; i++)
  788. {
  789. obsItemList[i].gameObject.SetActive(true);
  790. }
  791. }
  792. else
  793. {
  794. for (int i = 0; i < obsItemList.Count; i++)
  795. {
  796. obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
  797. }
  798. }
  799. }
  800. public void ShowObsPanel(ObsData _data)
  801. {
  802. obsPlayerPanel.gameObject.SetActive(true);
  803. obsPlayerPanel.SetObsData(_data);
  804. obsPlayerPanel.SetTitle(_data.name);
  805. }
  806. }