XunJianDataManager.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  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 System.Linq;
  8. using UnityEngine;
  9. using XRTool.Util;
  10. using static easyar.ImageTargetController;
  11. public class XunJianDataManager : Singleton<XunJianDataManager>
  12. {
  13. public XunJianListData chooseXunJian;
  14. public List<XunJianListData> xjDataList = new List<XunJianListData>();
  15. public int page = 1;
  16. public void GetXunJianList(Action<List<XunJianListData>> callback,int count)
  17. {
  18. WindowsManager.Instance.StartCoroutine(getList(callback, count));
  19. }
  20. public void GetXunJianCount(Action<int> callback)
  21. {
  22. WindowsManager.Instance.StartCoroutine(getListCount(callback));
  23. }
  24. public string nowArea = "全部";
  25. public void GetAreaList(string area, Action<List<XunJianListData>> callback)
  26. {
  27. nowArea = area;
  28. List<XunJianListData> data = new List<XunJianListData>();
  29. if (areaList.ContainsKey(area))
  30. {
  31. for (int i = 0; i < areaList[area].Count; i++)
  32. {
  33. Debug.Log(nowPeople == areaList[area][i].people);
  34. Debug.Log(!peopleList.ContainsKey(nowPeople));
  35. if (nowPeople == areaList[area][i].people || !peopleList.ContainsKey(nowPeople))
  36. {
  37. data.Add(areaList[area][i]);
  38. }
  39. }
  40. callback.Invoke(data);
  41. }
  42. else
  43. {
  44. for (int i = 0; i < xjDataList.Count; i++)
  45. {
  46. if (nowPeople == xjDataList[i].people || !peopleList.ContainsKey(nowPeople))
  47. {
  48. data.Add(xjDataList[i]);
  49. }
  50. }
  51. callback.Invoke(data);
  52. }
  53. }
  54. public string nowPeople="全部";
  55. public void GetPeopleList(string people, Action<List<XunJianListData>> callback)
  56. {
  57. nowPeople = people;
  58. List<XunJianListData> data = new List<XunJianListData>();
  59. if (peopleList.ContainsKey(people))
  60. {
  61. for (int i = 0; i < peopleList[people].Count; i++)
  62. {
  63. if(nowArea == peopleList[people][i].inarea||!areaList.ContainsKey(nowArea))
  64. {
  65. data.Add(peopleList[people][i]);
  66. }
  67. }
  68. callback.Invoke(data);
  69. }else
  70. {
  71. for (int i = 0; i < xjDataList.Count; i++)
  72. {
  73. if (nowArea == xjDataList[i].inarea || !areaList.ContainsKey(nowArea))
  74. {
  75. data.Add(xjDataList[i]);
  76. }
  77. }
  78. callback.Invoke(data);
  79. }
  80. }
  81. XunJianListData testData()
  82. {
  83. XunJianListData xj = new XunJianListData();
  84. xj.id = "saotu";
  85. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  86. xj.projectname = "工厂巡检";
  87. xj.inarea = "杨浦区";
  88. xj.updateState = "新项目";
  89. xj.projectState = "测试巡检 ";
  90. xj.projectType = "未开始 ";
  91. xj.projectTime = "2023/11/23 10:53 ";
  92. xj.renwuModelType = RenWuModelType.SaoTu;
  93. // xj.itemList = getRenwuData();
  94. xj.tasksList = new List<XunJianTasks>();
  95. xj.people = "员工A";
  96. return xj;
  97. }
  98. XunJianListData testData2()
  99. {
  100. XunJianListData xj = new XunJianListData();
  101. xj.id = "saotu";
  102. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  103. xj.projectname = "办公室巡检";
  104. xj.inarea = "杨浦区";
  105. xj.updateState = "新项目";
  106. xj.projectState = "测试巡检 ";
  107. xj.projectType = "未开始 ";
  108. xj.projectTime = "2023/11/23 10:53 ";
  109. xj.renwuModelType = RenWuModelType.DianYun;
  110. // xj.itemList = getRenwuData();
  111. xj.tasksList = new List<XunJianTasks>();
  112. xj.people = "员工B";
  113. return xj;
  114. }
  115. XunJianListData testData3()
  116. {
  117. XunJianListData xj = new XunJianListData();
  118. xj.id = "saotu";
  119. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  120. xj.projectname = "机房巡检";
  121. xj.inarea = "杨浦区";
  122. xj.updateState = "新项目";
  123. xj.projectState = "巡检 ";
  124. xj.projectType = "未开始 ";
  125. xj.projectTime = "2023/11/23 10:53 ";
  126. xj.renwuModelType = RenWuModelType.None;
  127. // xj.itemList = getRenwuData();
  128. xj.tasksList = new List<XunJianTasks>();
  129. xj.people = "员工C";
  130. xj.listWall = getWallData();
  131. return xj;
  132. }
  133. List<RenWuItem> getRenwuData()
  134. {
  135. List < RenWuItem > itemlist = new List<RenWuItem>();
  136. for (int j = 0; j < 7; j++)
  137. {
  138. RenWuItem rw = new RenWuItem();
  139. rw.imageUrl ="";
  140. //任务id
  141. rw.id = j.ToString();
  142. RenWuTypeModel rwtm = new RenWuTypeModel();
  143. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  144. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  145. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  146. //任务索引
  147. rw.index = j;
  148. switch(j)
  149. {
  150. case 0:
  151. //任务路线 (空间定位时才有)
  152. rw.roadList = new List<Vector3>();
  153. rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
  154. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
  155. rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
  156. rw.info = "请检查机房空调温度是否正常";
  157. //单个任务素材
  158. rw.typeList = new List<RenWuTypeModel>();
  159. rwtm.id = "1";
  160. rwtm.type = RenWuType.Image;
  161. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  162. rw.typeList.Add(rwtm);
  163. rwtm4.id = "4";
  164. rwtm4.type = RenWuType.Text;
  165. rwtm4.info = "通常要求机房长期工作环境温度: 0'C'4S'C; 短期工作环境温度: -5C~SSC";
  166. rw.typeList.Add(rwtm4);
  167. break;
  168. case 1:
  169. //任务路线 (空间定位时才有)
  170. rw.roadList = new List<Vector3>();
  171. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
  172. rw.info = "请检查机房湿度是否正常";
  173. //单个任务素材
  174. rw.typeList = new List<RenWuTypeModel>();
  175. rwtm4.id = "4";
  176. rwtm4.type = RenWuType.Text;
  177. rwtm4.info = "通常机房的长期工作环境相对漫庭应在5%RH~85%RH之间,不结露;短期工作环境相对湿度应在0%RH~95%RH之间,不结露.";
  178. rw.typeList.Add(rwtm4);
  179. rwtm.id = "1";
  180. rwtm.type = RenWuType.Image;
  181. rwtm.url = Application.streamingAssetsPath + "/Demo1/温湿度.jpeg";
  182. rw.typeList.Add(rwtm);
  183. break;
  184. case 2:
  185. //任务路线 (空间定位时才有)
  186. rw.roadList = new List<Vector3>();
  187. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
  188. rw.info = "请检查服务器电源灯是否正常";
  189. //单个任务素材
  190. rw.typeList = new List<RenWuTypeModel>();
  191. rwtm.id = "1";
  192. rwtm.type = RenWuType.Image;
  193. rwtm.url = Application.streamingAssetsPath + "/Demo1/服务器指示灯.png";
  194. rw.typeList.Add(rwtm);
  195. rwtm3.id = "3";
  196. rwtm3.type = RenWuType.Model;
  197. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  198. rw.typeList.Add(rwtm3);
  199. break;
  200. case 3:
  201. //任务路线 (空间定位时才有)
  202. rw.roadList = new List<Vector3>();
  203. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  204. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  205. rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
  206. rw.info = "请检查服务器告警灯状态是否正常";
  207. //单个任务素材
  208. rw.typeList = new List<RenWuTypeModel>();
  209. rwtm3.id = "3";
  210. rwtm3.type = RenWuType.Model;
  211. rwtm3.url = Application.streamingAssetsPath + "/Demo1/dell poweredge.fbx";
  212. rw.typeList.Add(rwtm3);
  213. rwtm2.id = "2";
  214. rwtm2.type = RenWuType.Video;
  215. rwtm2.url = Application.streamingAssetsPath + "/Demo1/服务器告警灯2.mp4";
  216. rw.typeList.Add(rwtm2);
  217. break;
  218. case 4:
  219. //任务路线 (空间定位时才有)
  220. rw.roadList = new List<Vector3>();
  221. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  222. rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
  223. rw.info = "请检查服务器网线连接是否正常";
  224. //单个任务素材
  225. rw.typeList = new List<RenWuTypeModel>();
  226. rwtm2.id = "2";
  227. rwtm2.type = RenWuType.Video;
  228. rwtm2.url = Application.streamingAssetsPath + "/Demo1/网线.mp4";
  229. rw.typeList.Add(rwtm2);
  230. break;
  231. case 5:
  232. //任务路线 (空间定位时才有)
  233. rw.roadList = new List<Vector3>();
  234. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  235. rw.info = "机房室内消防设施是否齐全";
  236. //单个任务素材
  237. rw.typeList = new List<RenWuTypeModel>();
  238. rwtm.id = "1";
  239. rwtm.type = RenWuType.Image;
  240. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施巡检.jpeg";
  241. rw.typeList.Add(rwtm);
  242. break;
  243. case 6:
  244. //任务路线 (空间定位时才有)
  245. rw.roadList = new List<Vector3>();
  246. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  247. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  248. rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
  249. rw.info = "机房室内消防设施摆放是否规范";
  250. //单个任务素材
  251. rw.typeList = new List<RenWuTypeModel>();
  252. rwtm.id = "1";
  253. rwtm.type = RenWuType.Image;
  254. rwtm.url = Application.streamingAssetsPath + "/Demo1/机房消防设施摆放.jpeg";
  255. rw.typeList.Add(rwtm);
  256. break;
  257. }
  258. //任务介绍
  259. //拍照按钮
  260. int randomInt = UnityEngine.Random.Range(0, 10);
  261. rw.isPaiZhao = randomInt > 5 ? true : false;
  262. //RTC按钮
  263. int randomInt2 = UnityEngine.Random.Range(0, 10);
  264. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  265. itemlist.Add(rw);
  266. }
  267. return itemlist;
  268. }
  269. public Dictionary<string, List<XunJianListData>> areaList = new Dictionary<string, List<XunJianListData>>();
  270. public Dictionary<string, List<XunJianListData>> peopleList = new Dictionary<string, List<XunJianListData>>();
  271. List<Wall> getWallData()
  272. {
  273. List<Wall> listWall = new List<Wall>();
  274. for (int i = 0; i < 6; i++)
  275. {
  276. switch (i)
  277. {
  278. case 0:
  279. Wall wall = new Wall();
  280. wall.listPoint.Add(new Vector3(-5, 0, 0.25f));
  281. wall.listPoint.Add(new Vector3(5, 0, 0.25f));
  282. wall.listPoint.Add(new Vector3(5, 0, -0.25f));
  283. wall.listPoint.Add(new Vector3(-5, 0, -0.25f));
  284. listWall.Add(wall);
  285. break;
  286. case 1:
  287. Wall wall1 = new Wall();
  288. wall1.listPoint.Add(new Vector3(-5, 0, -4.75f));
  289. wall1.listPoint.Add(new Vector3(5, 0, -4.75f));
  290. wall1.listPoint.Add(new Vector3(5, 0, -5.25f));
  291. wall1.listPoint.Add(new Vector3(-5, 0, -5.25f));
  292. listWall.Add(wall1);
  293. break;
  294. case 2:
  295. Wall wall2 = new Wall();
  296. wall2.listPoint.Add(new Vector3(-5.25f, 0, 0));
  297. wall2.listPoint.Add(new Vector3(-4.75f, 0, 0));
  298. wall2.listPoint.Add(new Vector3(-4.75f, 0, -5));
  299. wall2.listPoint.Add(new Vector3(-5.25f, 0, -5));
  300. listWall.Add(wall2);
  301. break;
  302. case 3:
  303. Wall wall3 = new Wall();
  304. wall3.listPoint.Add(new Vector3(4.75f, 0, 0));
  305. wall3.listPoint.Add(new Vector3(5.25f, 0, 0));
  306. wall3.listPoint.Add(new Vector3(5.25f, 0, -5));
  307. wall3.listPoint.Add(new Vector3(4.75f, 0, -5));
  308. listWall.Add(wall3);
  309. break;
  310. case 4:
  311. Wall wall4 = new Wall();
  312. wall4.listPoint.Add(new Vector3(-2.75f, 0, -1f));
  313. wall4.listPoint.Add(new Vector3(-2.25f, 0, -1f));
  314. wall4.listPoint.Add(new Vector3(-2.25f, 0, -3f));
  315. wall4.listPoint.Add(new Vector3(-2.75f, 0, -3f));
  316. listWall.Add(wall4);
  317. break;
  318. case 5:
  319. Wall wall5 = new Wall();
  320. wall5.listPoint.Add(new Vector3(2.25f, 0, -2));
  321. wall5.listPoint.Add(new Vector3(2.75f, 0, -2));
  322. wall5.listPoint.Add(new Vector3(2.75f, 0, -4));
  323. wall5.listPoint.Add(new Vector3(2.25f, 0, -4));
  324. listWall.Add(wall5);
  325. break;
  326. default:
  327. break;
  328. }
  329. }
  330. return listWall;
  331. }
  332. IEnumerator getListCount(Action<int> callback)
  333. {
  334. JsonData jsonData = new JsonData();
  335. jsonData["page"] = page++;
  336. jsonData["limit"] = 10;
  337. Debug.Log(jsonData.ToJson());
  338. yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, jsonData.ToJson(), (string msg) =>
  339. {
  340. try
  341. {
  342. JObject jObject = JObject.Parse(msg);
  343. int listConunt = int.Parse(jObject["data"]["count"].ToString());
  344. callback.Invoke(listConunt);
  345. }
  346. catch
  347. {
  348. callback.Invoke(0);
  349. }
  350. }));
  351. }
  352. int getMaxCount = 10;
  353. IEnumerator getList(Action<List<XunJianListData>> callback,int count)
  354. {
  355. xjDataList.Clear();
  356. for (int i = 1; i < (count/ getMaxCount) +2; i++)
  357. {
  358. JsonData jsonData = new JsonData();
  359. jsonData["page"] = i;
  360. jsonData["limit"] = getMaxCount;
  361. Debug.Log(jsonData.ToJson());
  362. yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, jsonData.ToJson(), (string msg) =>
  363. {
  364. Debug.Log("msg===>"+ msg);
  365. JObject jObject = JObject.Parse(msg);
  366. int listConunt = int.Parse(jObject["data"]["count"].ToString());
  367. List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
  368. xjDataList.AddRange(XunJianDataParetListData(data));
  369. callback.Invoke(xjDataList);
  370. }));
  371. }
  372. }
  373. IEnumerator testBack(Action<List<XunJianListData>> callback)
  374. {
  375. // 加入分页查询
  376. JsonData jsonData = new JsonData();
  377. jsonData["page"] = page++;
  378. jsonData["limit"] = 10;
  379. Debug.Log(jsonData.ToJson());
  380. yield return WindowsManager.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpEdustryAction.InspectionList, jsonData.ToJson(), (string msg) =>
  381. {
  382. Debug.Log("DGJ ===>InspectionList " + msg);
  383. JObject jObject = JObject.Parse(msg);
  384. if (jObject["code"].ToString() == "200")
  385. {
  386. List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
  387. if(data==null||data.Count<1)
  388. {
  389. page = -1;
  390. }
  391. int listConunt = int.Parse(jObject["data"]["count"].ToString());
  392. Debug.Log(HttpEdustryAction.InspectionList +" Count " +listConunt);
  393. if(WindowsManager.Instance.isTest)
  394. {
  395. //xjDataList.Add(testData3());
  396. //xjDataList.Add(testData());
  397. //xjDataList.Add(testData2());
  398. }
  399. #region old 排序
  400. // /*
  401. // * 1是否为异常巡检>2是否逾期>3是否更新>4接收时间
  402. // 1. 异常巡检项目>常规巡检项目
  403. // 2. 已逾期>即将开始>未到逾期提醒>进行中>已完成
  404. // 3. 新项目>已更新>未更新项目
  405. // 4. 新接收时间>老接收时间
  406. // 新项目 : 接受发布时间在24小时内
  407. //*/
  408. // // 排序
  409. // // var data2 = data.OrderBy(XunJianData => XunJianData.projectType);
  410. // // .ThenBy(XunJianData => XunJianData.projectState)
  411. // // .ThenBy(XunJianData => XunJianData.projectTime);
  412. //for (int i = 0; i < data.Count; i++)
  413. //{
  414. // int sortStatus = 10;
  415. // switch (data[i].status)
  416. // {
  417. // case 1:
  418. // sortStatus = 3;
  419. // break;
  420. // case 2:
  421. // sortStatus = 2;
  422. // break;
  423. // case 3:
  424. // sortStatus = 1;
  425. // break;
  426. // case 4:
  427. // sortStatus = 4;
  428. // break;
  429. // case 5:
  430. // sortStatus = 5;
  431. // break;
  432. // default:
  433. // break;
  434. // }
  435. // int sortType = 10;
  436. // if (data[i].publishTime == data[i].firstPublishTime)
  437. // {
  438. // DateTime publishTime = UnixTimeStampToDateTime(data[i].publishTime);
  439. // DateTime nowTime = UnixTimeStampToDateTime(GetHttpTimer.Instance.timestamp);
  440. // if (IsWithin24Hours(publishTime, nowTime))
  441. // {
  442. // sortType = 1;
  443. // }
  444. // else
  445. // {
  446. // sortType = 3;
  447. // }
  448. // }
  449. // else
  450. // {
  451. // sortType = 2;
  452. // }
  453. // data[i].sort_projectStatus = sortStatus;
  454. // data[i].sort_status = sortStatus;
  455. //}
  456. // }
  457. // var data2 = data.OrderByDescending(XunJianData => XunJianData.type)
  458. // .ThenBy(XunJianData => XunJianData.sort_status)
  459. // .ThenBy(XunJianData => XunJianData.sort_projectStatus)
  460. // .ThenByDescending(XunJianData => XunJianData.publishTime);
  461. // List<XunJianData> data3 = new List<XunJianData>();
  462. // foreach (XunJianData item in data2)
  463. // {
  464. // data3.Add(item);
  465. // }
  466. // Debug.Log("DGJ ===> 排序后 " + JsonConvert.SerializeObject(data3));
  467. // xjDataList.AddRange(XunJianDataParetListData(data3));
  468. #endregion
  469. xjDataList.AddRange(XunJianDataParetListData(data));
  470. peopleList = new Dictionary<string, List<XunJianListData>>();
  471. areaList = new Dictionary<string, List<XunJianListData>>();
  472. for (int i = 0; i < xjDataList.Count; i++)
  473. {
  474. if (areaList.ContainsKey(xjDataList[i].inarea))
  475. {
  476. areaList[xjDataList[i].inarea].Add(xjDataList[i]);
  477. }
  478. else
  479. {
  480. areaList.Add(xjDataList[i].inarea, new List<XunJianListData>());
  481. areaList[xjDataList[i].inarea].Add(xjDataList[i]);
  482. }
  483. if (peopleList.ContainsKey(xjDataList[i].people))
  484. {
  485. peopleList[xjDataList[i].people].Add(xjDataList[i]);
  486. }
  487. else
  488. {
  489. peopleList.Add(xjDataList[i].people, new List<XunJianListData>());
  490. peopleList[xjDataList[i].people].Add(xjDataList[i]);
  491. }
  492. }
  493. callback(xjDataList);
  494. }
  495. else
  496. {
  497. Debug.LogError("获取巡检列表失败 " + jObject["code"].ToString());
  498. xjDataList = new List<XunJianListData>();
  499. if (WindowsManager.Instance.isTest)
  500. {
  501. xjDataList.Add(testData3());
  502. xjDataList.Add(testData());
  503. xjDataList.Add(testData2());
  504. }
  505. callback(xjDataList);
  506. }
  507. }));
  508. }
  509. List<XunJianListData> XunJianDataParetListData(List<XunJianData> data)
  510. {
  511. List<XunJianListData> listData = new List<XunJianListData>();
  512. for (int i = 0; i < data.Count; i++)
  513. {
  514. XunJianListData xj = new XunJianListData();
  515. xj.id = data[i].id.ToString();
  516. xj.projectname = data[i].name;
  517. xj.inarea = data[i].regionName;
  518. xj.projectState = ((ProjectStatus)data[i].status).ToString();
  519. xj.projectType = ((ProjectType)data[i].type).ToString();
  520. DateTime dateTimes = UnixTimeStampToDateTime(data[i].inspectionTime);
  521. long notime = GetHttpTimer.Instance.timestamp;
  522. if (PlayerPrefs.HasKey("project_" + data[i].id))
  523. {
  524. long projectOld = long.Parse(PlayerPrefs.GetString("project_" + data[i].id));
  525. float chaju = projectOld - data[i].inspectionTime;
  526. xj.updateState = chaju < 86400 ? "已更新" : "---";
  527. }
  528. else
  529. {
  530. xj.updateState = "新项目";// chaju < 86400 ? "已更新" : "新项目";
  531. PlayerPrefs.SetString("project_" + data[i].id, notime.ToString());
  532. }
  533. xj.projectTime = dateTimes.Year.ToString() + "/" + dateTimes.Month.ToString() + "/" + dateTimes.Day.ToString() + " " + dateTimes.Hour.ToString() + ":" + dateTimes.Minute.ToString();
  534. xj.listWall = data[i].listWall;
  535. switch (data[i].status)
  536. {
  537. case 1:
  538. xj.projectState = "已完成";
  539. break;
  540. case 2:
  541. xj.projectState = "进行中";
  542. break;
  543. case 3:
  544. xj.projectState = "未开始";
  545. break;
  546. case 4:
  547. xj.projectState = "即将开始";
  548. break;
  549. case 5:
  550. xj.projectState = "已逾期";
  551. break;
  552. default:
  553. break;
  554. }
  555. switch (data[i].regionMapType)
  556. {
  557. case 0:
  558. xj.renwuModelType = RenWuModelType.None;
  559. break;
  560. case 1:
  561. xj.renwuModelType = RenWuModelType.None;
  562. break;
  563. case 2:
  564. xj.renwuModelType = RenWuModelType.DianYun;
  565. break;
  566. default:
  567. break;
  568. }
  569. listData.Add(xj);
  570. }
  571. return listData;
  572. }
  573. // 将Unix时间戳转换为DateTime对象
  574. DateTime UnixTimeStampToDateTime(long unixTimeStamp)
  575. {
  576. DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  577. return epoch.AddSeconds(unixTimeStamp).ToLocalTime();
  578. }
  579. public string StampToDateTime(string timeStamp)
  580. {
  581. DateTime startTime = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//获取时间戳
  582. DateTime dt = startTime.AddSeconds(double.Parse(timeStamp));
  583. return dt.ToString("yyyy/MM/dd");//转化为日期时间
  584. }
  585. // 判断两个时间是否相差在24小时以内
  586. bool IsWithin24Hours(DateTime dateTime1, DateTime dateTime2)
  587. {
  588. TimeSpan difference = dateTime2 - dateTime1;
  589. return Math.Abs(difference.TotalHours) <= 24;
  590. }
  591. public class XunJianListData
  592. {
  593. public int nowIndex = 0;
  594. public string id;
  595. public string projectname;
  596. public string inarea; // 所在区域
  597. public string updateState; // 这个参数目前本地自己判断
  598. public string projectState;
  599. public string projectType;
  600. public string projectTime;
  601. // public List<RenWuItem> itemList;
  602. public List<XunJianTasks> tasksList;
  603. public RenWuModelType renwuModelType;
  604. public int regionMapType;
  605. public string url;
  606. public string people = "未知员工";
  607. public List<Wall> listWall;
  608. /// <summary>
  609. /// 当前未完成任务的开始下标
  610. /// </summary>
  611. public int rwIndex = 0;
  612. }
  613. public class XunJianData
  614. {
  615. public int id { get; set; }
  616. public string name { get; set; }
  617. public string regionId { get; set; }
  618. public string regionName { get; set; }
  619. public int type { get; set; }
  620. public int status { get; set; }
  621. public int inspectionTime { get; set; }
  622. /// <summary>
  623. /// 第一次发布时间
  624. /// </summary>
  625. public int firstPublishTime { get; set; }
  626. /// <summary>
  627. /// 当前发布时间
  628. /// </summary>
  629. public int publishTime { get; set; }
  630. /// <summary>
  631. /// 排序用的 状态 已逾期>即将开始>未到逾期提醒>进行中>已完成
  632. /// </summary>
  633. public int sort_status { get; set; }
  634. /// <summary>
  635. /// 当前项目状态 新项目>已更新>未更新项目
  636. /// </summary>
  637. public int sort_projectStatus { get; set; }
  638. /// <summary>
  639. /// 区域地图类型 默认0 1:2d 2:3d 点云
  640. /// </summary>
  641. public int regionMapType { get; set; }
  642. public List<EmployeesData> listEmployees { get; set; }
  643. public List<Wall> listWall { get; set; }
  644. }
  645. public class EmployeesData
  646. {
  647. public int id { get; set; }
  648. public string name { get; set; }
  649. public string number { get; set; }
  650. }
  651. public void GotoXunJian(XunJianListData xjld)
  652. {
  653. xjld.projectState = "进行中";
  654. chooseXunJian = xjld;
  655. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  656. TopManager.Instance.gameObject.SetActive(false);
  657. JinRuRenwu.Instance.initStart();
  658. }
  659. public void gotoNext()
  660. {
  661. Debug.Log("DGj ===>gotoNext " + chooseXunJian.nowIndex);
  662. // if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  663. if (chooseXunJian.tasksList.Count > chooseXunJian.nowIndex)
  664. {
  665. if (JinRuRenwu.Instance != null)
  666. {
  667. JinRuRenwu.Instance.UpdateData();
  668. }
  669. if (RenWuListWindow.Instance != null)
  670. {
  671. RenWuListWindow.Instance.UpdateData();
  672. }
  673. if (CaoZuoLanManager.Instance)
  674. CaoZuoLanManager.Instance.nextInteractable(!chooseXunJian.tasksList[chooseXunJian.nowIndex].confirmNormal);
  675. }
  676. else
  677. {
  678. List<string> backTip = new List<string>();
  679. JsonData data = new JsonData();
  680. data["type"] = "30001";
  681. backTip.Add("1");
  682. backTip.Add(data.ToJson());
  683. backTip.Add("3");
  684. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
  685. chooseXunJian.projectState = "已完成";
  686. }
  687. chooseXunJian.nowIndex++;
  688. }
  689. public void chooseItem(int i)
  690. {
  691. chooseXunJian.nowIndex = i;
  692. if (JinRuRenwu.Instance != null)
  693. {
  694. JinRuRenwu.Instance.UpdateData();
  695. }
  696. if (RenWuListWindow.Instance != null)
  697. {
  698. RenWuListWindow.Instance.UpdateData();
  699. }
  700. }
  701. public class RenWuItem
  702. {
  703. public string id;
  704. public int index;
  705. public bool isPaiZhao;
  706. public bool isYuanCheng;
  707. public string info;
  708. public List<RenWuTypeModel> typeList;
  709. public List<Vector3> roadList;
  710. public string imageUrl;
  711. public ImageFileSourceData imageData;
  712. public RenWuState state = RenWuState.None;
  713. }
  714. public class XunJianTasks
  715. {
  716. /// <summary>
  717. /// // 任务ID
  718. /// </summary>
  719. public int id { get; set; }
  720. /// <summary>
  721. /// 任务类型
  722. /// </summary>
  723. public int type { get; set; }
  724. /// <summary>
  725. /// 任务标题
  726. /// </summary>
  727. public string title { get; set; }
  728. /// <summary>
  729. /// 任务详情描述
  730. /// </summary>
  731. public string description { get; set; }
  732. /// <summary>
  733. /// 定位方式 1:标识图 2:定位器 目前两个都走一套逻辑
  734. /// </summary>
  735. public int targetingMethod { get; set; }
  736. /// <summary>
  737. /// 定位器编号
  738. /// </summary>
  739. public string locatorNumber { get; set; }
  740. /// <summary>
  741. /// 确认状态 如果是true 可以直接点下一步
  742. /// </summary>
  743. public bool confirmNormal { get; set; }
  744. /// <summary>
  745. /// 识别图列表
  746. /// </summary>
  747. public List<MinioResources> diagram { get; set; }
  748. /// <summary>
  749. /// 资源文件列表
  750. /// </summary>
  751. public List<MinioResources> resources { get; set; }
  752. /// <summary>
  753. /// 项目ID
  754. /// </summary>
  755. public int projectId { get; set; }
  756. public int projectInspectionId { get; set; }
  757. public List<MinioResources> data { get; set; }
  758. /// <summary>
  759. /// 状态 0:未完成 1:正常 2:异常
  760. /// </summary>
  761. public int status { get; set; }
  762. /// <summary>
  763. /// 完成时间
  764. /// </summary>
  765. public long completionTime { get; set; }
  766. /// <summary>
  767. /// 执行顺序
  768. /// </summary>
  769. public int sort { get; set; }
  770. /// <summary>
  771. /// 当前项目任务下标
  772. /// </summary>
  773. // public int index { get; set; }
  774. /// <summary>
  775. /// 任务路径
  776. /// </summary>
  777. public List<Vector3> roadList { get; set; }
  778. public ImageFileSourceData imageData { get; set; }
  779. public RenWuState state = RenWuState.None;
  780. public List<int> listUpload = new List<int>();
  781. /// <summary>
  782. /// 任务开始时间
  783. /// </summary>
  784. public float startTime { get; set; }
  785. }
  786. public class MinioResources
  787. {
  788. public int id { get; set; }
  789. public string path { get; set; }
  790. public string uuid { get; set; }
  791. public int loadingMethod { get; set; }
  792. // public string name { get; set; }
  793. public string info { get; set; }
  794. }
  795. public class RenWuTypeModel
  796. {
  797. public RenWuType type;
  798. public string id;
  799. public string url;
  800. public string info;
  801. }
  802. public class Wall
  803. {
  804. public List<Vector3> listPoint { get; set; }
  805. public Wall()
  806. {
  807. listPoint = new List<Vector3>();
  808. }
  809. }
  810. public enum RenWuState
  811. {
  812. None = 100001, // 未处理
  813. Success = 100002, // 成功
  814. Fail = 100003, // 失败
  815. }
  816. public enum RenWuType
  817. {
  818. Text = 100001, // 文字
  819. Image = 100002, // 图片
  820. Video = 100003, // 视频
  821. Model = 100004, // 模型
  822. }
  823. public enum RenWuModelType
  824. {
  825. SaoTu = 100001, // 扫图
  826. DingWeiBan = 100002, // 定位板
  827. DianYun = 100003, // 点云
  828. None = 100004, // 无
  829. }
  830. public enum ProjectType
  831. {
  832. 常规 =1,
  833. 异常 = 2
  834. }
  835. public enum ProjectStatus
  836. {
  837. 未开始 = 1,
  838. 即将开始 =2,
  839. 已逾期 = 3,
  840. 进行中 = 4,
  841. 已完成=5
  842. }
  843. }