InspectionService.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Blue;
  2. using LitJson;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Linq;
  5. using UnityEngine;
  6. public class InspectionService : IInspectionService
  7. {
  8. public InspectionInfo InspectionInfo { get; private set; }
  9. public void OnInit()
  10. {
  11. }
  12. public void Get()
  13. {
  14. CoroutineSystem.Instance.StartCoroutine(
  15. HttpTool.Instance.SendHttp(HttpActionLang.inspection_begin, "", message =>
  16. {
  17. JObject jobject = JObject.Parse(message);
  18. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
  19. {
  20. Debug.LogError("data:" + jobject["data"].ToString());
  21. InspectionInfo = JsonConvert.DeserializeObject<InspectionInfo>(jobject["data"].ToString());
  22. if(PlayerPrefs.GetInt("XunJianInspectionInfoID")!= InspectionInfo.id)
  23. PlayerPrefs.SetInt("ShowXunJianStep", 1);
  24. PlayerPrefs.SetInt("XunJianInspectionInfoID", InspectionInfo.id);
  25. /*
  26. Debug.LogError($"ID:{InspectionInfo.id}");
  27. foreach (var item in InspectionInfo.items)
  28. {
  29. Debug.LogError($"key:{item.Key},Value:{item.Value}");
  30. }
  31. Debug.LogError($"Steps:{InspectionInfo.steps.Count}");
  32. foreach (var item in InspectionInfo.steps)
  33. {
  34. Debug.LogError($"key:{item.Key}");
  35. Debug.LogError($"normal:{item.Value.normal}");
  36. Debug.LogError($"lable:{item.Value.label}");
  37. Debug.LogError($"images:{item.Value.images}");
  38. }
  39. */
  40. }
  41. }));
  42. }
  43. /// <summary>
  44. /// 机房巡检步骤上报
  45. /// </summary>
  46. /// <param name="ItemID">检查项目的编号 1-12</param>
  47. /// <param name="Normal">是否正常</param>
  48. /// <param name="Outliers">标签</param>
  49. /// <param name="InspectionId">巡检编号,巡检开始时返回的id</param>
  50. /// <param name="ImageIds">图片文件ID 最多三个</param>
  51. public void Set(int ItemID, bool Normal, string Outliers, int InspectionId, int[] ImageIds)
  52. {
  53. InspectionStepSet mInspectionStepSet = new InspectionStepSet()
  54. {
  55. itemId = ItemID,
  56. normal = Normal,
  57. outliers = Outliers,
  58. inspectionId = InspectionId,
  59. imageIds = ImageIds
  60. };
  61. string JsonString = JsonConvert.SerializeObject(mInspectionStepSet);
  62. CoroutineSystem.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.inspection_step, JsonString, message =>
  63. {
  64. JObject jobject = JObject.Parse(message);
  65. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
  66. {
  67. //Debug.LogError($"Message:{message}+finished:{jobject["data"]["finished"]}");
  68. }
  69. }));
  70. }
  71. }