InspectionService.cs 2.8 KB

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