XunJianDataManager.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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. xj.listWall = getWallData();
  62. return xj;
  63. }
  64. List<RenWuItem> getRenwuData()
  65. {
  66. List < RenWuItem > itemlist = new List<RenWuItem>();
  67. for (int j = 0; j < 7; j++)
  68. {
  69. RenWuItem rw = new RenWuItem();
  70. rw.imageUrl ="";
  71. //任务id
  72. rw.id = j.ToString();
  73. RenWuTypeModel rwtm = new RenWuTypeModel();
  74. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  75. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  76. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  77. //任务索引
  78. rw.index = j;
  79. switch(j)
  80. {
  81. case 0:
  82. //任务路线 (空间定位时才有)
  83. rw.roadList = new List<Vector3>();
  84. rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
  85. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
  86. rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
  87. rw.info = "请检查机房空调温度是否正常";
  88. //单个任务素材
  89. rw.typeList = new List<RenWuTypeModel>();
  90. rwtm.id = "1";
  91. rwtm.type = RenWuType.Image;
  92. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  93. rw.typeList.Add(rwtm);
  94. rwtm4.id = "4";
  95. rwtm4.type = RenWuType.Text;
  96. rwtm4.info = "通常要求机房长期工作环境温度: 0'C'4S'C; 短期工作环境温度: -5C~SSC";
  97. rw.typeList.Add(rwtm4);
  98. break;
  99. case 1:
  100. //任务路线 (空间定位时才有)
  101. rw.roadList = new List<Vector3>();
  102. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
  103. rw.info = "请检查机房湿度是否正常";
  104. //单个任务素材
  105. rw.typeList = new List<RenWuTypeModel>();
  106. rwtm4.id = "4";
  107. rwtm4.type = RenWuType.Text;
  108. rwtm4.info = "通常机房的长期工作环境相对漫庭应在5%RH~85%RH之间,不结露;短期工作环境相对湿度应在0%RH~95%RH之间,不结露.";
  109. rw.typeList.Add(rwtm4);
  110. rwtm.id = "1";
  111. rwtm.type = RenWuType.Image;
  112. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  113. rw.typeList.Add(rwtm);
  114. break;
  115. case 2:
  116. //任务路线 (空间定位时才有)
  117. rw.roadList = new List<Vector3>();
  118. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
  119. rw.info = "请检查服务器电源灯是否正常";
  120. //单个任务素材
  121. rw.typeList = new List<RenWuTypeModel>();
  122. rwtm.id = "1";
  123. rwtm.type = RenWuType.Image;
  124. rwtm.url = Application.streamingAssetsPath + "/Demo1/服务器指示灯.png";
  125. rw.typeList.Add(rwtm);
  126. rwtm3.id = "3";
  127. rwtm3.type = RenWuType.Model;
  128. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  129. rw.typeList.Add(rwtm3);
  130. break;
  131. case 3:
  132. //任务路线 (空间定位时才有)
  133. rw.roadList = new List<Vector3>();
  134. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  135. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  136. rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
  137. rw.info = "请检查服务器告警灯状态是否正常";
  138. //单个任务素材
  139. rw.typeList = new List<RenWuTypeModel>();
  140. rwtm3.id = "3";
  141. rwtm3.type = RenWuType.Model;
  142. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  143. rw.typeList.Add(rwtm3);
  144. rwtm2.id = "2";
  145. rwtm2.type = RenWuType.Video;
  146. rwtm2.url = Application.streamingAssetsPath + "/Demo1/服务器告警灯2.mp4";
  147. rw.typeList.Add(rwtm2);
  148. break;
  149. case 4:
  150. //任务路线 (空间定位时才有)
  151. rw.roadList = new List<Vector3>();
  152. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  153. rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
  154. rw.info = "请检查服务器网线连接是否正常";
  155. //单个任务素材
  156. rw.typeList = new List<RenWuTypeModel>();
  157. rwtm2.id = "2";
  158. rwtm2.type = RenWuType.Video;
  159. rwtm2.url = Application.streamingAssetsPath + "/Demo1/网线.mp4";
  160. rw.typeList.Add(rwtm2);
  161. break;
  162. case 5:
  163. //任务路线 (空间定位时才有)
  164. rw.roadList = new List<Vector3>();
  165. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  166. rw.info = "机房室内消防设施是否齐全";
  167. //单个任务素材
  168. rw.typeList = new List<RenWuTypeModel>();
  169. rwtm.id = "1";
  170. rwtm.type = RenWuType.Image;
  171. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施巡检.jpeg";
  172. rw.typeList.Add(rwtm);
  173. break;
  174. case 6:
  175. //任务路线 (空间定位时才有)
  176. rw.roadList = new List<Vector3>();
  177. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  178. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  179. rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
  180. rw.info = "机房室内消防设施摆放是否规范";
  181. //单个任务素材
  182. rw.typeList = new List<RenWuTypeModel>();
  183. rwtm.id = "1";
  184. rwtm.type = RenWuType.Image;
  185. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施摆放.jpeg";
  186. rw.typeList.Add(rwtm);
  187. break;
  188. }
  189. //任务介绍
  190. //拍照按钮
  191. int randomInt = UnityEngine.Random.Range(0, 10);
  192. rw.isPaiZhao = randomInt > 5 ? true : false;
  193. //RTC按钮
  194. int randomInt2 = UnityEngine.Random.Range(0, 10);
  195. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  196. itemlist.Add(rw);
  197. }
  198. return itemlist;
  199. }
  200. List<Wall> getWallData()
  201. {
  202. List<Wall> listWall = new List<Wall>();
  203. for (int i = 0; i < 6; i++)
  204. {
  205. switch (i)
  206. {
  207. case 0:
  208. Wall wall = new Wall();
  209. wall.listPoint.Add(new Vector3(-5, 0, 0.25f));
  210. wall.listPoint.Add(new Vector3(5, 0, 0.25f));
  211. wall.listPoint.Add(new Vector3(5, 0, -0.25f));
  212. wall.listPoint.Add(new Vector3(-5, 0, -0.25f));
  213. listWall.Add(wall);
  214. break;
  215. case 1:
  216. Wall wall1 = new Wall();
  217. wall1.listPoint.Add(new Vector3(-5, 0, -4.75f));
  218. wall1.listPoint.Add(new Vector3(5, 0, -4.75f));
  219. wall1.listPoint.Add(new Vector3(5, 0, -5.25f));
  220. wall1.listPoint.Add(new Vector3(-5, 0, -5.25f));
  221. listWall.Add(wall1);
  222. break;
  223. case 2:
  224. Wall wall2 = new Wall();
  225. wall2.listPoint.Add(new Vector3(-5.25f, 0, 0));
  226. wall2.listPoint.Add(new Vector3(-4.75f, 0, 0));
  227. wall2.listPoint.Add(new Vector3(-4.75f, 0, -5));
  228. wall2.listPoint.Add(new Vector3(-5.25f, 0, -5));
  229. listWall.Add(wall2);
  230. break;
  231. case 3:
  232. Wall wall3 = new Wall();
  233. wall3.listPoint.Add(new Vector3(4.75f, 0, 0));
  234. wall3.listPoint.Add(new Vector3(5.25f, 0, 0));
  235. wall3.listPoint.Add(new Vector3(5.25f, 0, -5));
  236. wall3.listPoint.Add(new Vector3(4.75f, 0, -5));
  237. listWall.Add(wall3);
  238. break;
  239. case 4:
  240. Wall wall4 = new Wall();
  241. wall4.listPoint.Add(new Vector3(-2.75f, 0, -1f));
  242. wall4.listPoint.Add(new Vector3(-2.25f, 0, -1f));
  243. wall4.listPoint.Add(new Vector3(-2.25f, 0, -3f));
  244. wall4.listPoint.Add(new Vector3(-2.75f, 0, -3f));
  245. listWall.Add(wall4);
  246. break;
  247. case 5:
  248. Wall wall5 = new Wall();
  249. wall5.listPoint.Add(new Vector3(2.25f, 0, -2));
  250. wall5.listPoint.Add(new Vector3(2.75f, 0, -2));
  251. wall5.listPoint.Add(new Vector3(2.75f, 0, -4));
  252. wall5.listPoint.Add(new Vector3(2.25f, 0, -4));
  253. listWall.Add(wall5);
  254. break;
  255. default:
  256. break;
  257. }
  258. }
  259. return listWall;
  260. }
  261. IEnumerator testBack(Action<List<XunJianListData>> callback)
  262. {
  263. yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, "", (string msg) =>
  264. {
  265. Debug.Log("DGJ ===>InspectionList " + msg);
  266. JObject jObject = JObject.Parse(msg);
  267. if (jObject["code"].ToString() == "200")
  268. {
  269. List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
  270. if(WindowsManager.Instance.isTest)
  271. {
  272. xjDataList.Add(testData3());
  273. xjDataList.Add(testData());
  274. xjDataList.Add(testData2());
  275. }
  276. xjDataList.AddRange(XunJianDataParetListData(data));
  277. callback(xjDataList);
  278. }
  279. else
  280. {
  281. Debug.LogError("获取巡检列表失败 " + jObject["code"].ToString());
  282. xjDataList = new List<XunJianListData>();
  283. if (WindowsManager.Instance.isTest)
  284. {
  285. xjDataList.Add(testData3());
  286. xjDataList.Add(testData());
  287. xjDataList.Add(testData2());
  288. }
  289. callback(xjDataList);
  290. }
  291. }));
  292. }
  293. List<XunJianListData> XunJianDataParetListData(List<XunJianData> data)
  294. {
  295. List<XunJianListData> listData = new List<XunJianListData>();
  296. for (int i = 0; i < data.Count; i++)
  297. {
  298. XunJianListData xj = new XunJianListData();
  299. xj.id = data[i].id.ToString();
  300. xj.projectname = data[i].name;
  301. xj.inarea = data[i].regionName;
  302. xj.projectState = ((ProjectStatus)data[i].status).ToString();
  303. xj.projectType = ((ProjectType)data[i].type).ToString();
  304. xj.projectTime = data[i].inspectionTime.ToString();
  305. xj.updateState = data[i].status > 2 ? "已更新" : "新项目";
  306. xj.listWall = data[i].listWall;
  307. listData.Add(xj);
  308. }
  309. return listData;
  310. }
  311. public class XunJianListData
  312. {
  313. public int nowIndex = 0;
  314. public string id;
  315. public string projectname;
  316. public string inarea; // 所在区域
  317. public string updateState; // 这个参数目前本地自己判断
  318. public string projectState;
  319. public string projectType;
  320. public string projectTime;
  321. public List<RenWuItem> itemList;
  322. public RenWuModelType renwuModelType;
  323. public string url;
  324. public List<Wall> listWall;
  325. }
  326. public class XunJianData
  327. {
  328. public int id { get; set; }
  329. public string name { get; set; }
  330. public string regionId { get; set; }
  331. public string regionName { get; set; }
  332. public int type { get; set; }
  333. public int status { get; set; }
  334. public int inspectionTime { get; set; }
  335. public List<EmployeesData> listEmployees { get; set; }
  336. public List<Wall> listWall { get; set; }
  337. }
  338. public class EmployeesData
  339. {
  340. public int id { get; set; }
  341. public string name { get; set; }
  342. public string number { get; set; }
  343. }
  344. public void GotoXunJian(XunJianListData xjld)
  345. {
  346. chooseXunJian = xjld;
  347. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  348. JinRuRenwu.Instance.initStart();
  349. }
  350. public void gotoNext()
  351. {
  352. if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  353. {
  354. chooseXunJian.nowIndex++;
  355. if (JinRuRenwu.Instance != null)
  356. {
  357. JinRuRenwu.Instance.UpdateData();
  358. }
  359. if (RenWuListWindow.Instance != null)
  360. {
  361. RenWuListWindow.Instance.UpdateData();
  362. }
  363. if (CaoZuoLanManager.Instance)
  364. CaoZuoLanManager.Instance.nextInteractable(false);
  365. }
  366. else
  367. {
  368. List<string> backTip = new List<string>();
  369. JsonData data = new JsonData();
  370. data["type"] = "30001";
  371. backTip.Add("1");
  372. backTip.Add(data.ToJson());
  373. backTip.Add("3");
  374. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
  375. }
  376. }
  377. public void chooseItem(int i)
  378. {
  379. chooseXunJian.nowIndex = i;
  380. if (JinRuRenwu.Instance != null)
  381. {
  382. JinRuRenwu.Instance.UpdateData();
  383. }
  384. if (RenWuListWindow.Instance != null)
  385. {
  386. RenWuListWindow.Instance.UpdateData();
  387. }
  388. }
  389. public class RenWuItem
  390. {
  391. public string id;
  392. public int index;
  393. public bool isPaiZhao;
  394. public bool isYuanCheng;
  395. public string info;
  396. public List<RenWuTypeModel> typeList;
  397. public List<Vector3> roadList;
  398. public string imageUrl;
  399. public ImageFileSourceData imageData;
  400. public RenWuState state = RenWuState.None;
  401. }
  402. public class RenWuTypeModel
  403. {
  404. public RenWuType type;
  405. public string id;
  406. public string url;
  407. public string info;
  408. }
  409. public class Wall
  410. {
  411. public List<Vector3> listPoint { get; set; }
  412. public Wall()
  413. {
  414. listPoint = new List<Vector3>();
  415. }
  416. }
  417. public enum RenWuState
  418. {
  419. None = 100001, // 未处理
  420. Success = 100002, // 成功
  421. Fail = 100003, // 失败
  422. }
  423. public enum RenWuType
  424. {
  425. Text = 100001, // 文字
  426. Image = 100002, // 图片
  427. Video = 100003, // 视频
  428. Model = 100004, // 模型
  429. }
  430. public enum RenWuModelType
  431. {
  432. SaoTu = 100001, // 扫图
  433. DingWeiBan = 100002, // 定位板
  434. DianYun = 100003, // 点云
  435. None = 100004, // 无
  436. }
  437. public enum ProjectType
  438. {
  439. 常规 =1,
  440. 异常 = 2
  441. }
  442. public enum ProjectStatus
  443. {
  444. 未开始 = 1,
  445. 即将开始 =2,
  446. 已逾期 = 3,
  447. 进行中 = 4,
  448. 已完成=5
  449. }
  450. }