123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- using LitJson;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- using static easyar.ImageTargetController;
- public class XunJianDataManager : Singleton<XunJianDataManager>
- {
- public XunJianListData chooseXunJian;
- public List<XunJianListData> xjDataList = new List<XunJianListData>();
- public void GetXunJianList(Action<List<XunJianListData>> callback)
- {
- WindowsManager.Instance.StartCoroutine(testBack(callback));
-
- }
- XunJianListData testData()
- {
- XunJianListData xj = new XunJianListData();
- xj.id = "saotu";
- xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
- xj.projectname = "工厂巡检";
- xj.inarea = "杨浦区";
- xj.updateState = "新项目";
- xj.projectState = "测试巡检 ";
- xj.projectType = "未开始 ";
- xj.projectTime = "2023/11/23 10:53 ";
- xj.renwuModelType = RenWuModelType.SaoTu;
- xj.itemList = getRenwuData();
- return xj;
- }
- XunJianListData testData2()
- {
- XunJianListData xj = new XunJianListData();
- xj.id = "saotu";
- xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
- xj.projectname = "办公室巡检";
- xj.inarea = "杨浦区";
- xj.updateState = "新项目";
- xj.projectState = "测试巡检 ";
- xj.projectType = "未开始 ";
- xj.projectTime = "2023/11/23 10:53 ";
- xj.renwuModelType = RenWuModelType.DianYun;
- xj.itemList = getRenwuData();
- return xj;
- }
- XunJianListData testData3()
- {
- XunJianListData xj = new XunJianListData();
- xj.id = "saotu";
- xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
- xj.projectname = "机房巡检";
- xj.inarea = "杨浦区";
- xj.updateState = "新项目";
- xj.projectState = "巡检 ";
- xj.projectType = "未开始 ";
- xj.projectTime = "2023/11/23 10:53 ";
- xj.renwuModelType = RenWuModelType.None;
- xj.itemList = getRenwuData();
- return xj;
- }
- List<RenWuItem> getRenwuData()
- {
- List < RenWuItem > itemlist = new List<RenWuItem>();
- for (int j = 0; j < 7; j++)
- {
- RenWuItem rw = new RenWuItem();
- rw.imageUrl ="";
-
- rw.id = j.ToString();
- RenWuTypeModel rwtm = new RenWuTypeModel();
- RenWuTypeModel rwtm2 = new RenWuTypeModel();
- RenWuTypeModel rwtm3 = new RenWuTypeModel();
- RenWuTypeModel rwtm4 = new RenWuTypeModel();
-
- rw.index = j;
- switch(j)
- {
- case 0:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
- rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
- rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
- rw.info = "请检查机房空调温度是否正常";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm.id = "1";
- rwtm.type = RenWuType.Image;
- rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
- rw.typeList.Add(rwtm);
- rwtm4.id = "4";
- rwtm4.type = RenWuType.Text;
- rwtm4.info = "通常要求机房长期工作环境温度: 0'C'4S'C; 短期工作环境温度: -5C~SSC";
- rw.typeList.Add(rwtm4);
- break;
- case 1:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
- rw.info = "请检查机房湿度是否正常";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm4.id = "4";
- rwtm4.type = RenWuType.Text;
- rwtm4.info = "通常机房的长期工作环境相对漫庭应在5%RH~85%RH之间,不结露;短期工作环境相对湿度应在0%RH~95%RH之间,不结露.";
- rw.typeList.Add(rwtm4);
- rwtm.id = "1";
- rwtm.type = RenWuType.Image;
- rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
- rw.typeList.Add(rwtm);
- break;
- case 2:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
- rw.info = "请检查服务器电源灯是否正常";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm.id = "1";
- rwtm.type = RenWuType.Image;
- rwtm.url = Application.streamingAssetsPath + "/Demo1/服务器指示灯.png";
- rw.typeList.Add(rwtm);
- rwtm3.id = "3";
- rwtm3.type = RenWuType.Model;
- rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
- rw.typeList.Add(rwtm3);
- break;
- case 3:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
- rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
- rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
- rw.info = "请检查服务器告警灯状态是否正常";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm3.id = "3";
- rwtm3.type = RenWuType.Model;
- rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
- rw.typeList.Add(rwtm3);
- rwtm2.id = "2";
- rwtm2.type = RenWuType.Video;
- rwtm2.url = Application.streamingAssetsPath + "/Demo1/服务器告警灯2.mp4";
- rw.typeList.Add(rwtm2);
- break;
- case 4:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
- rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
- rw.info = "请检查服务器网线连接是否正常";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm2.id = "2";
- rwtm2.type = RenWuType.Video;
- rwtm2.url = Application.streamingAssetsPath + "/Demo1/网线.mp4";
- rw.typeList.Add(rwtm2);
- break;
- case 5:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
- rw.info = "机房室内消防设施是否齐全";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm.id = "1";
- rwtm.type = RenWuType.Image;
- rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施巡检.jpeg";
- rw.typeList.Add(rwtm);
- break;
- case 6:
-
- rw.roadList = new List<Vector3>();
- rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
- rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
- rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
- rw.info = "机房室内消防设施摆放是否规范";
-
- rw.typeList = new List<RenWuTypeModel>();
- rwtm.id = "1";
- rwtm.type = RenWuType.Image;
- rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施摆放.jpeg";
- rw.typeList.Add(rwtm);
- break;
- }
-
-
- int randomInt = UnityEngine.Random.Range(0, 10);
- rw.isPaiZhao = randomInt > 5 ? true : false;
-
- int randomInt2 = UnityEngine.Random.Range(0, 10);
- rw.isYuanCheng = randomInt2 > 5 ? true : false;
- itemlist.Add(rw);
- }
- return itemlist;
- }
- IEnumerator testBack(Action<List<XunJianListData>> callback)
- {
- yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, "", (string msg) =>
- {
- Debug.Log("DGJ ===>InspectionList " + msg);
- JObject jObject = JObject.Parse(msg);
- if (jObject["code"].ToString() == "200")
- {
- List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
- if(WindowsManager.Instance.isTest)
- {
- xjDataList.Add(testData3());
- xjDataList.Add(testData());
- xjDataList.Add(testData2());
- }
- xjDataList.AddRange(XunJianDataParetListData(data));
- callback(xjDataList);
- }
- else
- {
- Debug.LogError("获取巡检列表失败 " + jObject["code"].ToString());
- xjDataList = new List<XunJianListData>();
- if (WindowsManager.Instance.isTest)
- {
- xjDataList.Add(testData3());
- xjDataList.Add(testData());
- xjDataList.Add(testData2());
- }
- callback(xjDataList);
- }
- }));
- }
- List<XunJianListData> XunJianDataParetListData(List<XunJianData> data)
- {
- List<XunJianListData> listData = new List<XunJianListData>();
- for (int i = 0; i < data.Count; i++)
- {
- XunJianListData xj = new XunJianListData();
- xj.id = data[i].id.ToString();
- xj.projectname = data[i].name;
- xj.inarea = data[i].regionName;
- xj.projectState = ((ProjectStatus)data[i].status).ToString();
- xj.projectType = ((ProjectType)data[i].type).ToString();
- xj.projectTime = data[i].inspectionTime.ToString();
- xj.updateState = data[i].status > 2 ? "已更新" : "新项目";
- listData.Add(xj);
- }
- return listData;
- }
- public class XunJianListData
- {
- public int nowIndex = 0;
- public string id;
- public string projectname;
- public string inarea;
- public string updateState;
- public string projectState;
- public string projectType;
- public string projectTime;
- public List<RenWuItem> itemList;
- public RenWuModelType renwuModelType;
- public string url;
- }
- public class XunJianData
- {
- public int id { get; set; }
- public string name { get; set; }
- public string regionId { get; set; }
- public string regionName { get; set; }
- public int type { get; set; }
- public int status { get; set; }
- public int inspectionTime { get; set; }
- public List<EmployeesData> listEmployees { get; set; }
- }
- public class EmployeesData
- {
- public int id { get; set; }
- public string name { get; set; }
- public string number { get; set; }
- }
- public void GotoXunJian(XunJianListData xjld)
- {
- chooseXunJian = xjld;
- WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
- JinRuRenwu.Instance.initStart();
- }
- public void gotoNext()
- {
- if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
- {
- chooseXunJian.nowIndex++;
- if (JinRuRenwu.Instance != null)
- {
- JinRuRenwu.Instance.UpdateData();
- }
- if (RenWuListWindow.Instance != null)
- {
- RenWuListWindow.Instance.UpdateData();
- }
- if (CaoZuoLanManager.Instance)
- CaoZuoLanManager.Instance.nextInteractable(false);
- }
- else
- {
- List<string> backTip = new List<string>();
- JsonData data = new JsonData();
- data["type"] = "30001";
- backTip.Add("1");
- backTip.Add(data.ToJson());
- backTip.Add("3");
- WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
- }
- }
- public void chooseItem(int i)
- {
- chooseXunJian.nowIndex = i;
- if (JinRuRenwu.Instance != null)
- {
- JinRuRenwu.Instance.UpdateData();
- }
- if (RenWuListWindow.Instance != null)
- {
- RenWuListWindow.Instance.UpdateData();
- }
- }
- public class RenWuItem
- {
- public string id;
- public int index;
- public bool isPaiZhao;
- public bool isYuanCheng;
- public string info;
- public List<RenWuTypeModel> typeList;
- public List<Vector3> roadList;
- public string imageUrl;
- public ImageFileSourceData imageData;
- public RenWuState state = RenWuState.None;
- }
- public class RenWuTypeModel
- {
- public RenWuType type;
- public string id;
- public string url;
- public string info;
- }
- public enum RenWuState
- {
- None = 100001,
- Success = 100002,
- Fail = 100003,
- }
- public enum RenWuType
- {
- Text = 100001,
- Image = 100002,
- Video = 100003,
- Model = 100004,
- }
- public enum RenWuModelType
- {
- SaoTu = 100001,
- DingWeiBan = 100002,
- DianYun = 100003,
- None = 100004,
- }
- public enum ProjectType
- {
- 常规 =1,
- 异常 = 2
- }
- public enum ProjectStatus
- {
- 未开始 = 1,
- 即将开始 =2,
- 已逾期 = 3,
- 进行中 = 4,
- 已完成=5
- }
- }
|