XunJianDataManager.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. using LitJson;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using UnityEngine;
  8. using XRTool.Util;
  9. using static easyar.ImageTargetController;
  10. public class XunJianDataManager : Singleton<XunJianDataManager>
  11. {
  12. public XunJianListData chooseXunJian;
  13. public List<XunJianListData> xjDataList = new List<XunJianListData>();
  14. public void GetXunJianList(Action<List<XunJianListData>> callback)
  15. {
  16. WindowsManager.Instance.StartCoroutine(testBack(callback));
  17. }
  18. XunJianListData testData()
  19. {
  20. XunJianListData xj = new XunJianListData();
  21. xj.id = "saotu";
  22. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  23. xj.projectname = "工厂巡检";
  24. xj.inarea = "杨浦区";
  25. xj.updateState = "新项目";
  26. xj.projectState = "测试巡检 ";
  27. xj.projectType = "未开始 ";
  28. xj.projectTime = "2023/11/23 10:53 ";
  29. xj.renwuModelType = RenWuModelType.SaoTu;
  30. xj.itemList = getRenwuData();
  31. return xj;
  32. }
  33. XunJianListData testData2()
  34. {
  35. XunJianListData xj = new XunJianListData();
  36. xj.id = "saotu";
  37. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  38. xj.projectname = "办公室巡检";
  39. xj.inarea = "杨浦区";
  40. xj.updateState = "新项目";
  41. xj.projectState = "测试巡检 ";
  42. xj.projectType = "未开始 ";
  43. xj.projectTime = "2023/11/23 10:53 ";
  44. xj.renwuModelType = RenWuModelType.DianYun;
  45. xj.itemList = getRenwuData();
  46. return xj;
  47. }
  48. XunJianListData testData3()
  49. {
  50. XunJianListData xj = new XunJianListData();
  51. xj.id = "saotu";
  52. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  53. xj.projectname = "机房巡检";
  54. xj.inarea = "杨浦区";
  55. xj.updateState = "新项目";
  56. xj.projectState = "巡检 ";
  57. xj.projectType = "未开始 ";
  58. xj.projectTime = "2023/11/23 10:53 ";
  59. xj.renwuModelType = RenWuModelType.None;
  60. xj.itemList = getRenwuData();
  61. return xj;
  62. }
  63. List<RenWuItem> getRenwuData()
  64. {
  65. List < RenWuItem > itemlist = new List<RenWuItem>();
  66. for (int j = 0; j < 7; j++)
  67. {
  68. RenWuItem rw = new RenWuItem();
  69. rw.imageUrl ="";
  70. //任务id
  71. rw.id = j.ToString();
  72. RenWuTypeModel rwtm = new RenWuTypeModel();
  73. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  74. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  75. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  76. //任务索引
  77. rw.index = j;
  78. switch(j)
  79. {
  80. case 0:
  81. //任务路线 (空间定位时才有)
  82. rw.roadList = new List<Vector3>();
  83. rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
  84. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
  85. rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
  86. rw.info = "请检查机房空调温度是否正常";
  87. //单个任务素材
  88. rw.typeList = new List<RenWuTypeModel>();
  89. rwtm.id = "1";
  90. rwtm.type = RenWuType.Image;
  91. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  92. rw.typeList.Add(rwtm);
  93. rwtm4.id = "4";
  94. rwtm4.type = RenWuType.Text;
  95. rwtm4.info = "通常要求机房长期工作环境温度: 0'C'4S'C; 短期工作环境温度: -5C~SSC";
  96. rw.typeList.Add(rwtm4);
  97. break;
  98. case 1:
  99. //任务路线 (空间定位时才有)
  100. rw.roadList = new List<Vector3>();
  101. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
  102. rw.info = "请检查机房湿度是否正常";
  103. //单个任务素材
  104. rw.typeList = new List<RenWuTypeModel>();
  105. rwtm4.id = "4";
  106. rwtm4.type = RenWuType.Text;
  107. rwtm4.info = "通常机房的长期工作环境相对漫庭应在5%RH~85%RH之间,不结露;短期工作环境相对湿度应在0%RH~95%RH之间,不结露.";
  108. rw.typeList.Add(rwtm4);
  109. rwtm.id = "1";
  110. rwtm.type = RenWuType.Image;
  111. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  112. rw.typeList.Add(rwtm);
  113. break;
  114. case 2:
  115. //任务路线 (空间定位时才有)
  116. rw.roadList = new List<Vector3>();
  117. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
  118. rw.info = "请检查服务器电源灯是否正常";
  119. //单个任务素材
  120. rw.typeList = new List<RenWuTypeModel>();
  121. rwtm.id = "1";
  122. rwtm.type = RenWuType.Image;
  123. rwtm.url = Application.streamingAssetsPath + "/Demo1/服务器指示灯.png";
  124. rw.typeList.Add(rwtm);
  125. rwtm3.id = "3";
  126. rwtm3.type = RenWuType.Model;
  127. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  128. rw.typeList.Add(rwtm3);
  129. break;
  130. case 3:
  131. //任务路线 (空间定位时才有)
  132. rw.roadList = new List<Vector3>();
  133. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  134. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  135. rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
  136. rw.info = "请检查服务器告警灯状态是否正常";
  137. //单个任务素材
  138. rw.typeList = new List<RenWuTypeModel>();
  139. rwtm3.id = "3";
  140. rwtm3.type = RenWuType.Model;
  141. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  142. rw.typeList.Add(rwtm3);
  143. rwtm2.id = "2";
  144. rwtm2.type = RenWuType.Video;
  145. rwtm2.url = Application.streamingAssetsPath + "/Demo1/服务器告警灯2.mp4";
  146. rw.typeList.Add(rwtm2);
  147. break;
  148. case 4:
  149. //任务路线 (空间定位时才有)
  150. rw.roadList = new List<Vector3>();
  151. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  152. rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
  153. rw.info = "请检查服务器网线连接是否正常";
  154. //单个任务素材
  155. rw.typeList = new List<RenWuTypeModel>();
  156. rwtm2.id = "2";
  157. rwtm2.type = RenWuType.Video;
  158. rwtm2.url = Application.streamingAssetsPath + "/Demo1/网线.mp4";
  159. rw.typeList.Add(rwtm2);
  160. break;
  161. case 5:
  162. //任务路线 (空间定位时才有)
  163. rw.roadList = new List<Vector3>();
  164. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  165. rw.info = "机房室内消防设施是否齐全";
  166. //单个任务素材
  167. rw.typeList = new List<RenWuTypeModel>();
  168. rwtm.id = "1";
  169. rwtm.type = RenWuType.Image;
  170. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施巡检.jpeg";
  171. rw.typeList.Add(rwtm);
  172. break;
  173. case 6:
  174. //任务路线 (空间定位时才有)
  175. rw.roadList = new List<Vector3>();
  176. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  177. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  178. rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
  179. rw.info = "机房室内消防设施摆放是否规范";
  180. //单个任务素材
  181. rw.typeList = new List<RenWuTypeModel>();
  182. rwtm.id = "1";
  183. rwtm.type = RenWuType.Image;
  184. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施摆放.jpeg";
  185. rw.typeList.Add(rwtm);
  186. break;
  187. }
  188. //任务介绍
  189. //拍照按钮
  190. int randomInt = UnityEngine.Random.Range(0, 10);
  191. rw.isPaiZhao = randomInt > 5 ? true : false;
  192. //RTC按钮
  193. int randomInt2 = UnityEngine.Random.Range(0, 10);
  194. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  195. itemlist.Add(rw);
  196. }
  197. return itemlist;
  198. }
  199. IEnumerator testBack(Action<List<XunJianListData>> callback)
  200. {
  201. yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, "", (string msg) =>
  202. {
  203. Debug.Log("DGJ ===>InspectionList " + msg);
  204. JObject jObject = JObject.Parse(msg);
  205. if (jObject["code"].ToString() == "200")
  206. {
  207. List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
  208. if(WindowsManager.Instance.isTest)
  209. {
  210. xjDataList.Add(testData3());
  211. xjDataList.Add(testData());
  212. xjDataList.Add(testData2());
  213. }
  214. xjDataList.AddRange(XunJianDataParetListData(data));
  215. callback(xjDataList);
  216. }
  217. else
  218. {
  219. Debug.LogError("获取巡检列表失败 " + jObject["code"].ToString());
  220. xjDataList = new List<XunJianListData>();
  221. if (WindowsManager.Instance.isTest)
  222. {
  223. xjDataList.Add(testData3());
  224. xjDataList.Add(testData());
  225. xjDataList.Add(testData2());
  226. }
  227. callback(xjDataList);
  228. }
  229. }));
  230. }
  231. List<XunJianListData> XunJianDataParetListData(List<XunJianData> data)
  232. {
  233. List<XunJianListData> listData = new List<XunJianListData>();
  234. for (int i = 0; i < data.Count; i++)
  235. {
  236. XunJianListData xj = new XunJianListData();
  237. xj.id = data[i].id.ToString();
  238. xj.projectname = data[i].name;
  239. xj.inarea = data[i].regionName;
  240. xj.projectState = ((ProjectStatus)data[i].status).ToString();
  241. xj.projectType = ((ProjectType)data[i].type).ToString();
  242. xj.projectTime = data[i].inspectionTime.ToString();
  243. xj.updateState = data[i].status > 2 ? "已更新" : "新项目";
  244. listData.Add(xj);
  245. }
  246. return listData;
  247. }
  248. public class XunJianListData
  249. {
  250. public int nowIndex = 0;
  251. public string id;
  252. public string projectname;
  253. public string inarea; // 所在区域
  254. public string updateState; // 这个参数目前本地自己判断
  255. public string projectState;
  256. public string projectType;
  257. public string projectTime;
  258. public List<RenWuItem> itemList;
  259. public RenWuModelType renwuModelType;
  260. public string url;
  261. }
  262. public class XunJianData
  263. {
  264. public int id { get; set; }
  265. public string name { get; set; }
  266. public string regionId { get; set; }
  267. public string regionName { get; set; }
  268. public int type { get; set; }
  269. public int status { get; set; }
  270. public int inspectionTime { get; set; }
  271. public List<EmployeesData> listEmployees { get; set; }
  272. }
  273. public class EmployeesData
  274. {
  275. public int id { get; set; }
  276. public string name { get; set; }
  277. public string number { get; set; }
  278. }
  279. public void GotoXunJian(XunJianListData xjld)
  280. {
  281. chooseXunJian = xjld;
  282. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  283. JinRuRenwu.Instance.initStart();
  284. }
  285. public void gotoNext()
  286. {
  287. if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  288. {
  289. chooseXunJian.nowIndex++;
  290. if (JinRuRenwu.Instance != null)
  291. {
  292. JinRuRenwu.Instance.UpdateData();
  293. }
  294. if (RenWuListWindow.Instance != null)
  295. {
  296. RenWuListWindow.Instance.UpdateData();
  297. }
  298. if (CaoZuoLanManager.Instance)
  299. CaoZuoLanManager.Instance.nextInteractable(false);
  300. }
  301. else
  302. {
  303. List<string> backTip = new List<string>();
  304. JsonData data = new JsonData();
  305. data["type"] = "30001";
  306. backTip.Add("1");
  307. backTip.Add(data.ToJson());
  308. backTip.Add("3");
  309. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
  310. }
  311. }
  312. public void chooseItem(int i)
  313. {
  314. chooseXunJian.nowIndex = i;
  315. if (JinRuRenwu.Instance != null)
  316. {
  317. JinRuRenwu.Instance.UpdateData();
  318. }
  319. if (RenWuListWindow.Instance != null)
  320. {
  321. RenWuListWindow.Instance.UpdateData();
  322. }
  323. }
  324. public class RenWuItem
  325. {
  326. public string id;
  327. public int index;
  328. public bool isPaiZhao;
  329. public bool isYuanCheng;
  330. public string info;
  331. public List<RenWuTypeModel> typeList;
  332. public List<Vector3> roadList;
  333. public string imageUrl;
  334. public ImageFileSourceData imageData;
  335. public RenWuState state = RenWuState.None;
  336. }
  337. public class RenWuTypeModel
  338. {
  339. public RenWuType type;
  340. public string id;
  341. public string url;
  342. public string info;
  343. }
  344. public enum RenWuState
  345. {
  346. None = 100001, // 未处理
  347. Success = 100002, // 成功
  348. Fail = 100003, // 失败
  349. }
  350. public enum RenWuType
  351. {
  352. Text = 100001, // 文字
  353. Image = 100002, // 图片
  354. Video = 100003, // 视频
  355. Model = 100004, // 模型
  356. }
  357. public enum RenWuModelType
  358. {
  359. SaoTu = 100001, // 扫图
  360. DingWeiBan = 100002, // 定位板
  361. DianYun = 100003, // 点云
  362. None = 100004, // 无
  363. }
  364. public enum ProjectType
  365. {
  366. 常规 =1,
  367. 异常 = 2
  368. }
  369. public enum ProjectStatus
  370. {
  371. 未开始 = 1,
  372. 即将开始 =2,
  373. 已逾期 = 3,
  374. 进行中 = 4,
  375. 已完成=5
  376. }
  377. }