XunJianDataManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. HttpTool.Instance.Post(HttpEdustryAction.InspectionList, "", (string msg) =>
  18. {
  19. Debug.Log("DGJ ===>InspectionList " + msg);
  20. JObject jObject = JObject.Parse(msg);
  21. if(jObject["code"].ToString()== "200")
  22. {
  23. List<XunJianData> data = JsonConvert.DeserializeObject<List<XunJianData>>(jObject["data"]["list"].ToString());
  24. Debug.Log(data.Count);
  25. callback(XunJianDataParetListData(data));
  26. }
  27. else
  28. {
  29. Debug.LogError("获取巡检列表失败 "+ jObject["code"].ToString());
  30. callback(new List<XunJianListData>());
  31. }
  32. });
  33. }
  34. XunJianListData testData()
  35. {
  36. XunJianListData xj = new XunJianListData();
  37. xj.id = "saotu";
  38. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  39. xj.projectname = "(扫图版本)GHZ-巡检测试";
  40. xj.inarea = "杨浦区";
  41. xj.updateState = "新项目";
  42. xj.projectState = "测试巡检 ";
  43. xj.projectType = "未开始 ";
  44. xj.projectTime = "2023/11/23 10:53 ";
  45. xj.renwuModelType = RenWuModelType.SaoTu;
  46. xj.itemList = getRenwuData();
  47. return xj;
  48. }
  49. XunJianListData testData2()
  50. {
  51. XunJianListData xj = new XunJianListData();
  52. xj.id = "saotu";
  53. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  54. xj.projectname = "(点云版本)GHZ-巡检测试";
  55. xj.inarea = "杨浦区";
  56. xj.updateState = "新项目";
  57. xj.projectState = "测试巡检 ";
  58. xj.projectType = "未开始 ";
  59. xj.projectTime = "2023/11/23 10:53 ";
  60. xj.renwuModelType = RenWuModelType.DianYun;
  61. xj.itemList = getRenwuData();
  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 = Application.streamingAssetsPath + "/ARTargetImage/" + (j + 1) + ".png";
  71. //任务id
  72. rw.id = j.ToString();
  73. //任务索引
  74. rw.index = j;
  75. switch(j)
  76. {
  77. case 0:
  78. //任务路线 (空间定位时才有)
  79. rw.roadList = new List<Vector3>();
  80. rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
  81. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
  82. rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
  83. rw.info = "请检查办公室大门------并拍照/录像记录";
  84. break;
  85. case 1:
  86. //任务路线 (空间定位时才有)
  87. rw.roadList = new List<Vector3>();
  88. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
  89. rw.info = "查看垃圾桶是否有垃圾------并拍照/录像记录";
  90. break;
  91. case 2:
  92. //任务路线 (空间定位时才有)
  93. rw.roadList = new List<Vector3>();
  94. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
  95. rw.info = "检查空调是否正常------并拍照/录像记录";
  96. break;
  97. case 3:
  98. //任务路线 (空间定位时才有)
  99. rw.roadList = new List<Vector3>();
  100. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  101. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  102. rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
  103. rw.info = "请打开窗户并处于通风状态------并拍照/录像记录";
  104. break;
  105. case 4:
  106. //任务路线 (空间定位时才有)
  107. rw.roadList = new List<Vector3>();
  108. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  109. rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
  110. rw.info = "冰箱内是否有过期食品------并拍照/录像记录";
  111. break;
  112. case 5:
  113. //任务路线 (空间定位时才有)
  114. rw.roadList = new List<Vector3>();
  115. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  116. rw.info = "确保所有眼镜都在充电------并拍照/录像记录";
  117. break;
  118. case 6:
  119. //任务路线 (空间定位时才有)
  120. rw.roadList = new List<Vector3>();
  121. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  122. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  123. rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
  124. rw.info = "请回到工位继续工作------并拍照/录像记录";
  125. break;
  126. }
  127. //任务介绍
  128. //拍照按钮
  129. int randomInt = UnityEngine.Random.Range(0, 10);
  130. rw.isPaiZhao = randomInt > 5 ? true : false;
  131. //RTC按钮
  132. int randomInt2 = UnityEngine.Random.Range(0, 10);
  133. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  134. //单个任务素材
  135. rw.typeList = new List<RenWuTypeModel>();
  136. RenWuTypeModel rwtm = new RenWuTypeModel();
  137. rwtm.id = "1";
  138. rwtm.type = RenWuType.Image;
  139. rwtm.url = Application.streamingAssetsPath + "/Art/16:9.jpg";
  140. rw.typeList.Add(rwtm);
  141. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  142. rwtm2.id = "2";
  143. rwtm2.type = RenWuType.Video;
  144. rwtm2.url = Application.streamingAssetsPath + "/Art/Video.mp4";
  145. rw.typeList.Add(rwtm2);
  146. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  147. rwtm3.id = "3";
  148. rwtm3.type = RenWuType.Model;
  149. rwtm3.url = Application.streamingAssetsPath + "/Art/ExampleCar.fbx";
  150. rw.typeList.Add(rwtm3);
  151. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  152. rwtm4.id = "4";
  153. rwtm4.type = RenWuType.Text;
  154. rwtm4.info = rw.info;
  155. rw.typeList.Add(rwtm4);
  156. itemlist.Add(rw);
  157. }
  158. return itemlist;
  159. }
  160. IEnumerator testBack(Action<List<XunJianListData>> callback)
  161. {
  162. xjDataList = new List<XunJianListData>();
  163. xjDataList.Add(testData());
  164. xjDataList.Add(testData2());
  165. yield return null;
  166. callback.Invoke(xjDataList);
  167. }
  168. List<XunJianListData> XunJianDataParetListData(List<XunJianData> data)
  169. {
  170. List<XunJianListData> listData = new List<XunJianListData>();
  171. for (int i = 0; i < data.Count; i++)
  172. {
  173. XunJianListData xj = new XunJianListData();
  174. xj.id = data[i].id.ToString();
  175. xj.projectname = data[i].name;
  176. xj.inarea = data[i].regionName;
  177. xj.projectState = ((ProjectStatus)data[i].status).ToString();
  178. xj.projectType = ((ProjectType)data[i].type).ToString();
  179. xj.projectTime = data[i].inspectionTime.ToString();
  180. xj.updateState = data[i].status > 2 ? "已更新" : "新项目";
  181. listData.Add(xj);
  182. }
  183. return listData;
  184. }
  185. public class XunJianListData
  186. {
  187. public int nowIndex = 0;
  188. public string id;
  189. public string projectname;
  190. public string inarea; // 所在区域
  191. public string updateState; // 这个参数目前本地自己判断
  192. public string projectState;
  193. public string projectType;
  194. public string projectTime;
  195. public List<RenWuItem> itemList;
  196. public RenWuModelType renwuModelType;
  197. public string url;
  198. }
  199. public class XunJianData
  200. {
  201. public int id { get; set; }
  202. public string name { get; set; }
  203. public string regionId { get; set; }
  204. public string regionName { get; set; }
  205. public int type { get; set; }
  206. public int status { get; set; }
  207. public int inspectionTime { get; set; }
  208. public List<EmployeesData> listEmployees { get; set; }
  209. }
  210. public class EmployeesData
  211. {
  212. public int id { get; set; }
  213. public string name { get; set; }
  214. public string number { get; set; }
  215. }
  216. public void GotoXunJian(XunJianListData xjld)
  217. {
  218. chooseXunJian = xjld;
  219. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  220. JinRuRenwu.Instance.initStart();
  221. }
  222. public void gotoNext()
  223. {
  224. if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  225. {
  226. chooseXunJian.nowIndex++;
  227. if (JinRuRenwu.Instance != null)
  228. {
  229. JinRuRenwu.Instance.UpdateData();
  230. }
  231. if (RenWuListWindow.Instance != null)
  232. {
  233. RenWuListWindow.Instance.UpdateData();
  234. }
  235. if (CaoZuoLanManager.Instance)
  236. CaoZuoLanManager.Instance.nextInteractable(false);
  237. }
  238. else
  239. {
  240. List<string> backTip = new List<string>();
  241. JsonData data = new JsonData();
  242. data["type"] = "30001";
  243. backTip.Add("1");
  244. backTip.Add(data.ToJson());
  245. backTip.Add("3");
  246. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
  247. }
  248. }
  249. public void chooseItem(int i)
  250. {
  251. chooseXunJian.nowIndex = i;
  252. if (JinRuRenwu.Instance != null)
  253. {
  254. JinRuRenwu.Instance.UpdateData();
  255. }
  256. if (RenWuListWindow.Instance != null)
  257. {
  258. RenWuListWindow.Instance.UpdateData();
  259. }
  260. }
  261. public class RenWuItem
  262. {
  263. public string id;
  264. public int index;
  265. public bool isPaiZhao;
  266. public bool isYuanCheng;
  267. public string info;
  268. public List<RenWuTypeModel> typeList;
  269. public List<Vector3> roadList;
  270. public string imageUrl;
  271. public ImageFileSourceData imageData;
  272. public RenWuState state = RenWuState.None;
  273. }
  274. public class RenWuTypeModel
  275. {
  276. public RenWuType type;
  277. public string id;
  278. public string url;
  279. public string info;
  280. }
  281. public enum RenWuState
  282. {
  283. None = 100001, // 未处理
  284. Success = 100002, // 成功
  285. Fail = 100003, // 失败
  286. }
  287. public enum RenWuType
  288. {
  289. Text = 100001, // 文字
  290. Image = 100002, // 图片
  291. Video = 100003, // 视频
  292. Model = 100004, // 模型
  293. }
  294. public enum RenWuModelType
  295. {
  296. SaoTu = 100001, // 扫图
  297. DingWeiBan = 100002, // 定位板
  298. DianYun = 100003, // 点云
  299. }
  300. public enum ProjectType
  301. {
  302. 常规 =1,
  303. 异常 = 2
  304. }
  305. public enum ProjectStatus
  306. {
  307. 未开始 = 1,
  308. 即将开始 =2,
  309. 已逾期 = 3,
  310. 进行中 = 4,
  311. 已完成=5
  312. }
  313. }