BigScreenLayer.cs 31 KB

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