waybill_task.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package controller
  2. import (
  3. "cold-delivery/app/admin/model"
  4. "cold-delivery/app/admin/service"
  5. "cold-delivery/app/admin/service/dto"
  6. "cold-delivery/common/nats/nats_server"
  7. "github.com/gin-gonic/gin"
  8. "github.com/gin-gonic/gin/binding"
  9. "gogs.baozhida.cn/zoie/OAuth-core/api"
  10. _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
  11. )
  12. type WaybillTaskController struct {
  13. api.Api
  14. }
  15. // GetPage 获取运单任务列表
  16. // @Summary 获取运单任务列表
  17. // @Description 获取运单任务列表
  18. // @Tags 运单任务
  19. // @Param waybillNo query string true "运单号"
  20. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  21. // @Router /api/waybill-task [get]
  22. // @Security Bearer
  23. func (e WaybillTaskController) GetPage(c *gin.Context) {
  24. s := service.WaybillTask{}
  25. req := dto.WaybillTaskGetPageReq{}
  26. err := e.MakeContext(c).
  27. MakeOrm().
  28. Bind(&req, binding.Query).
  29. MakeService(&s.Service).
  30. Errors
  31. if err != nil {
  32. e.Logger.Error(err)
  33. e.Error(500, err, err.Error())
  34. return
  35. }
  36. list := make([]model.WaybillTask, 0)
  37. var count int64
  38. err = s.GetPage(&req, &list, &count)
  39. if err != nil {
  40. e.Error(500, err, err.Error())
  41. return
  42. }
  43. //e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  44. e.PageOK(list, int(count), 0, 0, "查询成功")
  45. }
  46. // GetData 获取温湿度记录
  47. // @Summary 获取温湿度记录
  48. // @Description 获取温湿度记录
  49. // @Tags 运单任务
  50. // @Accept application/json
  51. // @Product application/json
  52. // @Param data body dto.WaybillTaskGetDataPageReq true "body"
  53. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  54. // @Router /api/waybill-task/data [post]
  55. // @Security Bearer
  56. func (e WaybillTaskController) GetData(c *gin.Context) {
  57. s := service.WaybillTask{}
  58. req := dto.WaybillTaskGetDataPageReq{}
  59. err := e.MakeContext(c).
  60. MakeOrm().
  61. Bind(&req, binding.JSON, nil).
  62. MakeService(&s.Service).
  63. Errors
  64. if err != nil {
  65. e.Logger.Error(err)
  66. e.Error(500, err, err.Error())
  67. return
  68. }
  69. list := make([]nats_server.DeviceData_R, 0)
  70. var count int64
  71. list, count, err = s.GetDataPage(&req)
  72. if err != nil {
  73. e.Error(500, err, err.Error())
  74. return
  75. }
  76. e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  77. }
  78. // GetNewestData 获取最新温湿度记录
  79. // @Summary 获取最新温湿度记录
  80. // @Description 获取最新温湿度记录
  81. // @Tags 运单任务
  82. // @Accept application/json
  83. // @Product application/json
  84. // @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
  85. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  86. // @Router /api/waybill-task/newest-locus [post]
  87. // @Security Bearer
  88. func (e WaybillTaskController) GetNewestData(c *gin.Context) {
  89. s := service.WaybillTask{}
  90. req := dto.WaybillTaskGetNewestDataPageReq{}
  91. err := e.MakeContext(c).
  92. MakeOrm().
  93. Bind(&req, binding.JSON, nil).
  94. MakeService(&s.Service).
  95. Errors
  96. if err != nil {
  97. e.Logger.Error(err)
  98. e.Error(500, err, err.Error())
  99. return
  100. }
  101. data := nats_server.DeviceData_R{}
  102. data, err = s.GetNewestDataPage(&req)
  103. if err != nil {
  104. e.Error(500, err, err.Error())
  105. return
  106. }
  107. e.OK(data, "查询成功")
  108. }
  109. // GetLocus 获取轨迹信息
  110. // @Summary 获取轨迹信息
  111. // @Description 获取轨迹信息
  112. // @Tags 运单任务
  113. // @Accept application/json
  114. // @Product application/json
  115. // @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
  116. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  117. // @Router /api/waybill-task/locus [post]
  118. // @Security Bearer
  119. func (e WaybillTaskController) GetLocus(c *gin.Context) {
  120. s := service.WaybillTask{}
  121. req := dto.WaybillGetLocusReq{}
  122. err := e.MakeContext(c).
  123. MakeOrm().
  124. Bind(&req, binding.Query).
  125. MakeService(&s.Service).
  126. Errors
  127. if err != nil {
  128. e.Logger.Error(err)
  129. e.Error(500, err, err.Error())
  130. return
  131. }
  132. list := make([]nats_server.DeviceData_R2, 0)
  133. list, err = s.GetLocus(&req)
  134. if err != nil {
  135. e.Error(500, err, err.Error())
  136. return
  137. }
  138. e.OK(list, "获取轨迹信息成功")
  139. }