InspectionService.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. PlayerPrefs.SetInt("XunJianInspectionInfoID", InspectionInfo.id);
  23. /*
  24. Debug.LogError($"ID:{InspectionInfo.id}");
  25. foreach (var item in InspectionInfo.items)
  26. {
  27. Debug.LogError($"key:{item.Key},Value:{item.Value}");
  28. }
  29. Debug.LogError($"Steps:{InspectionInfo.steps.Count}");
  30. foreach (var item in InspectionInfo.steps)
  31. {
  32. Debug.LogError($"key:{item.Key}");
  33. Debug.LogError($"normal:{item.Value.normal}");
  34. Debug.LogError($"lable:{item.Value.label}");
  35. Debug.LogError($"images:{item.Value.images}");
  36. }
  37. */
  38. }
  39. }));
  40. }
  41. /// <summary>
  42. /// 机房巡检步骤上报
  43. /// </summary>
  44. /// <param name="ItemID">检查项目的编号 1-12</param>
  45. /// <param name="Normal">是否正常</param>
  46. /// <param name="Outliers">标签</param>
  47. /// <param name="InspectionId">巡检编号,巡检开始时返回的id</param>
  48. /// <param name="ImageIds">图片文件ID 最多三个</param>
  49. public void Set(int ItemID, bool Normal, string Outliers, int InspectionId, int[] ImageIds)
  50. {
  51. InspectionStepSet mInspectionStepSet = new InspectionStepSet()
  52. {
  53. itemId = ItemID,
  54. normal = Normal,
  55. outliers = Outliers,
  56. inspectionId = InspectionId,
  57. imageIds = ImageIds
  58. };
  59. string JsonString = JsonConvert.SerializeObject(mInspectionStepSet);
  60. CoroutineSystem.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.inspection_step, JsonString, message =>
  61. {
  62. JObject jobject = JObject.Parse(message);
  63. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
  64. {
  65. //Debug.LogError($"Message:{message}+finished:{jobject["data"]["finished"]}");
  66. }
  67. }));
  68. }
  69. }