using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Serialization; using UnityEngine.UI; using System.Threading.Tasks; using UnityAsync; using WaitUntil = UnityAsync.WaitUntil; using System.Reflection; using XCharts.Runtime; [System.Serializable] public class FloodGate { [FormerlySerializedAs("GateNumber")] public int sensor_id; [FormerlySerializedAs("IsOpen")] public bool gate_open; //public float CurrentFlow; [FormerlySerializedAs("CurrentOpening")] public float opening_degree; public bool gate_breakdown; public string updateTime=>GetTime(); public long record_ts; public string station_name; private string GetTime() { DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(record_ts); return dtDateTime.ToString("s"); } } [System.Serializable] public class FloodGateLocationData { public FloodGate[] FloodGates; } [System.Serializable] public class FloodGateStatusData { [FormerlySerializedAs("BuYuan")] public FloodGate[] buYuan; [FormerlySerializedAs("TaoKou")] public FloodGate[] taoKou; public string taoKouSW; public string buYuanSW; public bool success = false; public int BuYuanTotalGates => buYuan.Length; public int BuYuanOperationalGates => CountOperationalGates(buYuan); public int TaoKouTotalGates => taoKou.Length; public int TaoKouOperationalGates => CountOperationalGates(taoKou); private int CountOperationalGates(FloodGate[] gates) { int count = 0; foreach (var gate in gates) { if (!gate.gate_breakdown) count++; } return count; } } [System.Serializable] public class LocationWeatherData { public float currentWaterLevel; public float rainfall; public float floodDischarge; public float temperature; public string weather; } [System.Serializable] public class StationInspection { public InspectionDaily daily; public InspectionDaily monthly; public InspectionDaily yearly; } [System.Serializable] public class InspectionDaily { public int operationStaffCount; public int inspectionTasksCount; public int inspectionKilometers; public int faultHazardCount; public int processedFaultCount; public int engineeringMaintenanceCount; } [System.Serializable] public class AlertData { public bool success = false; public Alerts alerts; } [System.Serializable] public class Alerts { public List warningEvents = new List(); public List floodForecasts = new List(); public List weatherForecasts = new List(); public List threeLineWarnings = new List(); } [System.Serializable] public class AlertDataEvent { public int id; public string title; public string location; public string time; } public class BigScreenLayer : MonoBehaviour { public VerticalLayoutGroup content; public RectTransform znz; public Button gkButton; public Button normalButton; public Button clearBtn; public Button exitBtn; public Button exitJJBtn; public Button ddysButton; public Button exit_ddysButton; public GameObject gk; public GameObject normal; public YZTLayer zTLayer; public RectTransform miniMap; public RectTransform rightContent; public RingChart floodRingChart; public Button floodButton; public Text[] floodTexts; public RectTransform popWindow; public GameObject floodDataPrefab; public Button[] floodListBtns; public GridLayoutGroup[] floodLists; public Button floodListExitBtn; public Text swValue1; public Text swValue2; public Text swValue3; public Text swValue4; public Text swValue5; public Dropdown swDrop0; public Text yunValue1; public Text yunValue2; public Text yunValue3; public Text yunValue4; public Text yunValue5; public Text yunValue6; public int currentYunIndex = 0; public Dropdown yunDrop0; public Dropdown yunDrop1; List layerBtns = new List(); // Start is called before the first frame update public GameObject obsItemPrefab; private List obsItemList = new List(); private Transform obsItemContent; public ObsPlayerPanel obsPlayerPanel; private InputField _obsSearchInputField; public GameObject WaterRangeCtrlPanel; public GameObject sunshigaikuangPanel; public GameObject yjPrefab; public Button[] yjBtns; public GridLayoutGroup[] yjLayout; public Sprite[] sprites; public Text ymmjText; public Text ymgdText; public Text yxrkText; public Text ccssText; public VerticalLayoutGroup shuiShiliebiaoParent; public List shuiShiLieBiaoItems = new List(); public ShuiShiLieBiaoItem shuiShiLieBiaoItem; public WaterRangeCtrlTool mTools; async void Start() { CameraManager.SwitchCamera(0); StaticLod.instance.OnFoucusStatic(0); InitButton(); obsPlayerPanel = this.transform.Find("ObsPlayerPanel").GetComponent(); obsPlayerPanel.gameObject.SetActive(false); obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content"); _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent(); _obsSearchInputField.onValueChanged.AddListener(SearchObsItem); InitFloodGateData(); InitHydrologicalData(); InitLayerBtns(); InitObsItems(); InitInspectionStatistics(); InitAlert(); InitData(); } public async void InitData() { WWW www = new WWW(Application.streamingAssetsPath + "/areaBaseData.json"); await new UnityAsync.WaitUntil(() => { return www.isDone; }); string areaBaseDataContent = www.text; GlobalData.areaFHXSDatas = JsonConvert.DeserializeObject>(areaBaseDataContent); for (int i = 0; i < GlobalData.areaFHXSDatas.Count; i++) { ShuiShiLieBiaoItem tempItem = Instantiate(shuiShiLieBiaoItem); shuiShiLieBiaoItems.Add(tempItem); tempItem.transform.SetParent(shuiShiliebiaoParent.transform); tempItem.transform.localScale = Vector3.one; tempItem.SetData(GlobalData.areaFHXSDatas[i]); tempItem.Evaluate(1); } mTools.onCtrlChange = (float value) => { float ymmj = 0; float ymgd = 0; float yxrk = 0; float ccss = 0; for (int i = 0; i < shuiShiLieBiaoItems.Count; i++) { shuiShiLieBiaoItems[i].Evaluate(value); ymmj += shuiShiLieBiaoItems[i].currentMianJi; ymgd += shuiShiLieBiaoItems[i].currentGenDi; yxrk += shuiShiLieBiaoItems[i].currentRenKou; ccss += shuiShiLieBiaoItems[i].currentCaiChan; } ymmjText.text = ymmj.ToString("0.00") + "平方公里"; ymgdText.text = ymgd.ToString("0.0") + "亩"; yxrkText.text = yxrk.ToString("0") + "个"; ccssText.text = ccss.ToString("0.00") + "亿元"; }; } void InitButton() { normalButton.onClick.AddListener(() => { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); }); gkButton.onClick.AddListener(() => { gk.gameObject.SetActive(true); miniMap.gameObject.SetActive(true); rightContent.parent.gameObject.SetActive(false); normal.gameObject.SetActive(false); }); clearBtn.onClick.AddListener(() => { normal.gameObject.SetActive(false); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(true); normalButton.gameObject.SetActive(false); gkButton.gameObject.SetActive(false); clearBtn.gameObject.SetActive(false); ddysButton.gameObject.SetActive(false); }); exitBtn.onClick.AddListener(() => { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(false); normalButton.gameObject.SetActive(true); gkButton.gameObject.SetActive(true); clearBtn.gameObject.SetActive(true); ddysButton.gameObject.SetActive(true); }); exitJJBtn.onClick.AddListener(() => { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); }); ddysButton.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic("Bird0"); normal.gameObject.SetActive(false); gk.gameObject.SetActive(false); normalButton.gameObject.SetActive(false); gkButton.gameObject.SetActive(false); clearBtn.gameObject.SetActive(false); WaterRangeCtrlPanel.SetActive(true); sunshigaikuangPanel.SetActive(true); }); exit_ddysButton.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(0); WaterRangeCtrlPanel.SetActive(false); normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(false); normalButton.gameObject.SetActive(true); gkButton.gameObject.SetActive(true); clearBtn.gameObject.SetActive(true); ddysButton.gameObject.SetActive(true); sunshigaikuangPanel.SetActive(false); }); // public Button ddysButton; // public Button exit_ddysButton; } private async Task InitAlert() { await new WaitUntil(() => { return GlobalData.alertData.success; }); for (int i = 0; i < yjLayout.Length; i++) { yjLayout[i].transform.parent.parent.parent.gameObject.SetActive(false); } yjLayout[0].transform.parent.parent.parent.gameObject.SetActive(true); for (int i = 0; i < GlobalData.alertData.alerts.warningEvents.Count; i++) { GameObject obj = Instantiate(yjPrefab); obj.transform.SetParent(yjLayout[0].transform); obj.transform.localScale = Vector3.one; obj.transform.GetChild(0).GetComponent().text = GlobalData.alertData.alerts.warningEvents[i].id.ToString(); obj.transform.GetChild(1).GetComponent().text = GlobalData.alertData.alerts.warningEvents[i].title.ToString(); obj.transform.GetChild(2).GetComponent().text = GlobalData.alertData.alerts.warningEvents[i].location.ToString(); obj.transform.GetChild(3).GetComponent().text = GlobalData.alertData.alerts.warningEvents[i].time.ToString(); } for (int i = 0; i < GlobalData.alertData.alerts.floodForecasts.Count; i++) { GameObject obj = Instantiate(yjPrefab); obj.transform.SetParent(yjLayout[1].transform); obj.transform.localScale = Vector3.one; obj.transform.GetChild(0).GetComponent().text = GlobalData.alertData.alerts.floodForecasts[i].id.ToString(); obj.transform.GetChild(1).GetComponent().text = GlobalData.alertData.alerts.floodForecasts[i].title.ToString(); obj.transform.GetChild(2).GetComponent().text = GlobalData.alertData.alerts.floodForecasts[i].location.ToString(); obj.transform.GetChild(3).GetComponent().text = GlobalData.alertData.alerts.floodForecasts[i].time.ToString(); } for (int i = 0; i < GlobalData.alertData.alerts.weatherForecasts.Count; i++) { GameObject obj = Instantiate(yjPrefab); obj.transform.SetParent(yjLayout[2].transform); obj.transform.localScale = Vector3.one; obj.transform.GetChild(0).GetComponent().text = GlobalData.alertData.alerts.weatherForecasts[i].id.ToString(); obj.transform.GetChild(1).GetComponent().text = GlobalData.alertData.alerts.weatherForecasts[i].title.ToString(); obj.transform.GetChild(2).GetComponent().text = GlobalData.alertData.alerts.weatherForecasts[i].location.ToString(); obj.transform.GetChild(3).GetComponent().text = GlobalData.alertData.alerts.weatherForecasts[i].time.ToString(); } for (int i = 0; i < GlobalData.alertData.alerts.threeLineWarnings.Count; i++) { GameObject obj = Instantiate(yjPrefab); obj.transform.SetParent(yjLayout[3].transform); obj.transform.localScale = Vector3.one; obj.transform.GetChild(0).GetComponent().text = GlobalData.alertData.alerts.threeLineWarnings[i].id.ToString(); obj.transform.GetChild(1).GetComponent().text = GlobalData.alertData.alerts.threeLineWarnings[i].title.ToString(); obj.transform.GetChild(2).GetComponent().text = GlobalData.alertData.alerts.threeLineWarnings[i].location.ToString(); obj.transform.GetChild(3).GetComponent().text = GlobalData.alertData.alerts.threeLineWarnings[i].time.ToString(); } for (int i = 0; i < yjBtns.Length; i++) { int temp = i; yjBtns[i].onClick.AddListener(() => { for (int j = 0; j < yjBtns.Length; j++) { yjBtns[j].transform.GetChild(0).GetComponent().color = Color.gray; } yjBtns[temp].transform.GetChild(0).GetComponent().color = Color.white; for (int j = 0; j < yjLayout.Length; j++) { yjLayout[j].transform.parent.parent.parent.gameObject.SetActive(false); } yjLayout[temp].transform.parent.parent.parent.gameObject.SetActive(true); }); } } private async Task InitHydrologicalData() { await new WaitUntil(() => { return GlobalData.locationWeatherData.Count > 0; }); ChangeLocationWeatherData(0); swDrop0.onValueChanged.AddListener((index) => { ChangeLocationWeatherData(index); }); } private void ChangeLocationWeatherData(int index) { swValue1.text = GlobalData.locationWeatherData[index].currentWaterLevel.ToString(); swValue2.text = GlobalData.locationWeatherData[index].rainfall.ToString(); swValue3.text = GlobalData.locationWeatherData[index].temperature.ToString(); swValue4.text = GlobalData.locationWeatherData[index].weather.ToString(); swValue5.text = GlobalData.locationWeatherData[index].floodDischarge.ToString(); } private async Task InitFloodGateData() { await new WaitUntil(() => { return GlobalData.floorGateData.success; }); await new WaitUntil(() => { return GlobalData.buYuanSensorData.data.Count>0&&GlobalData.taoKouSensorData.data.Count>0; }); floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString(); floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString(); floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString(); floodButton.onClick.AddListener(() => { popWindow.gameObject.SetActive(true); }); floodListExitBtn.onClick.AddListener(() => { popWindow.gameObject.SetActive(false); }); floodListBtns[0].onClick.AddListener(() => { floodListBtns[0].GetComponent().sprite = sprites[0]; floodListBtns[1].GetComponent().sprite = sprites[1]; floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true); floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false); }); floodListBtns[1].onClick.AddListener(() => { floodListBtns[0].GetComponent().sprite = sprites[1]; floodListBtns[1].GetComponent().sprite = sprites[0]; floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false); floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true); }); var buyuanData = GlobalData.buYuanSensorData.data; for (int i = 0; i < buyuanData.Count; i++) { GameObject floodGateDataObj = Instantiate(floodDataPrefab); floodGateDataObj.transform.SetParent(floodLists[0].transform); floodGateDataObj.transform.localScale = Vector3.one; floodGateDataObj.transform.GetChild(1).GetComponent().text = (i + 1).ToString("00") + "号闸门"; floodGateDataObj.transform.GetChild(7).GetComponent().text = buyuanData[i].gate_opening ? "开启" : "关闭"; floodGateDataObj.transform.GetChild(8).GetComponent().text = "- m³/s"; floodGateDataObj.transform.GetChild(9).GetComponent().text = "m"; floodGateDataObj.transform.GetChild(10).GetComponent().text = buyuanData[i].opening_degree*0.01 + "m"; floodGateDataObj.transform.GetChild(11).GetComponent().text = buyuanData[i].gate_breakdown ? "故障":"正常"; } var taokouData = GlobalData.taoKouSensorData.data; for (int i = 0; i < taokouData.Count; i++) { GameObject floodGateDataObj = Instantiate(floodDataPrefab); floodGateDataObj.transform.SetParent(floodLists[1].transform); floodGateDataObj.transform.localScale = Vector3.one; floodGateDataObj.transform.GetChild(1).GetComponent().text = (i + 1).ToString("00") + "号闸门"; floodGateDataObj.transform.GetChild(7).GetComponent().text = taokouData[i].gate_opening ? "开启" : "关闭"; floodGateDataObj.transform.GetChild(8).GetComponent().text = "- m³/s"; floodGateDataObj.transform.GetChild(9).GetComponent().text = "m"; floodGateDataObj.transform.GetChild(10).GetComponent().text = taokouData[i].opening_degree*0.01 + "m"; floodGateDataObj.transform.GetChild(11).GetComponent().text = taokouData[i].gate_breakdown ? "故障":"正常"; } // for (int i = 0; i < GlobalData.floorGateData.BuYuan.FloodGates.Length; i++) // { // GameObject floodGateDataObj = Instantiate(floodDataPrefab); // floodGateDataObj.transform.SetParent(floodLists[0].transform); // floodGateDataObj.transform.localScale = Vector3.one; // floodGateDataObj.transform.GetChild(1).GetComponent().text = (i + 1).ToString("00") + "号闸门"; // floodGateDataObj.transform.GetChild(7).GetComponent().text = GlobalData.floorGateData.BuYuan.FloodGates[i].IsOpen ? "开启" : "关闭"; // floodGateDataObj.transform.GetChild(8).GetComponent().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentFlow + "m³/s"; // floodGateDataObj.transform.GetChild(9).GetComponent().text = GlobalData.floorGateData.BuYuan.CurrentWaterLevel + "m"; // floodGateDataObj.transform.GetChild(10).GetComponent().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentOpening + "°"; // switch (GlobalData.floorGateData.BuYuan.FloodGates[i].Status) // { // case 0: // floodGateDataObj.transform.GetChild(11).GetComponent().text = "故障"; // break; // case 1: // floodGateDataObj.transform.GetChild(11).GetComponent().text = "正常"; // break; // } // } // for (int i = 0; i < GlobalData.floorGateData.TaoKou.FloodGates.Length; i++) // { // GameObject floodGateDataObj = Instantiate(floodDataPrefab); // floodGateDataObj.transform.SetParent(floodLists[1].transform); // floodGateDataObj.transform.localScale = Vector3.one; // floodGateDataObj.transform.GetChild(1).GetComponent().text = (i + 1).ToString("00") + "号闸门"; // floodGateDataObj.transform.GetChild(7).GetComponent().text = GlobalData.floorGateData.TaoKou.FloodGates[i].IsOpen ? "开启" : "关闭"; // floodGateDataObj.transform.GetChild(8).GetComponent().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentFlow + "m³/s"; // floodGateDataObj.transform.GetChild(9).GetComponent().text = GlobalData.floorGateData.TaoKou.CurrentWaterLevel + "m"; // floodGateDataObj.transform.GetChild(10).GetComponent().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentOpening + "°"; // switch (GlobalData.floorGateData.TaoKou.FloodGates[i].Status) // { // case 0: // floodGateDataObj.transform.GetChild(11).GetComponent().text = "故障"; // break; // case 1: // floodGateDataObj.transform.GetChild(11).GetComponent().text = "正常"; // break; // } // } List doubles = new List(); doubles.Add(90); doubles.Add(100); floodRingChart.UpdateData(0, 0, doubles); } private async Task InitInspectionStatistics() { await new WaitUntil(() => { return GlobalData.InspectionStat.Count > 0; }); currentYunIndex = 0; yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString(); yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString(); yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString(); yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString(); yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString(); yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString(); yunDrop0.onValueChanged.AddListener((index) => { currentYunIndex = index; SwitchStationStat(yunDrop1.value); }); yunDrop1.onValueChanged.AddListener((index) => { SwitchStationStat(index); }); } void SwitchStationStat(int index) { switch (index) { case 0: yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString(); yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString(); yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString(); yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString(); yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString(); yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString(); break; case 1: yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString(); yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString(); yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString(); yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString(); yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString(); yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString(); break; case 2: yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString(); yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString(); yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString(); yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString(); yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString(); yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString(); break; } } private async Task InitLayerBtns() { await new WaitUntil(() => { return GlobalData.layerUnitDatas.Count > 0; }); layerBtns = new List(); for (int i = 0; i < zTLayer.layerDatas.Length; i++) { LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab); layerBtn.SetUseful(false); int index = i; int num = 0; if (i == 0) { List tempDatas = new List(GlobalData.layerUnitDatas); for (int j = 0; j < tempDatas.Count; j++) { if (tempDatas[j].special == "1") { int tempJ = j; SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri); miniMap.gameObject.SetActive(false); ChangeRightContent(tempJ); }); num++; } } layerBtn.secContent.gameObject.SetActive(true); } else { List tempDatas = new List(GlobalData.layerUnitDatas); for (int j = 0; j < tempDatas.Count; j++) { Debug.Log(zTLayer.layerDatas.Length); Debug.Log(i); if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID) { int tempJ = j; SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri); miniMap.gameObject.SetActive(false); ChangeRightContent(tempJ); }); num++; } } } layerBtn.btn.GetComponent