liugong.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package routers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "kpt.xdmy/apiserver/model/liugong"
  5. "kpt.xdmy/pkg/app"
  6. "kpt.xdmy/pkg/e"
  7. "strconv"
  8. "strings"
  9. )
  10. //func GetLiuGongToken(c *gin.Context) {
  11. // resp, err := svc.GetLiuGongToken()
  12. // if err != nil {
  13. // c.JSON(500, resp)
  14. // return
  15. // }
  16. // c.JSON(200, resp)
  17. //}
  18. //
  19. //func EditVehicle(c *gin.Context) {
  20. // p := new(liugong.PushEquipmentInfoReq)
  21. // if !Bind(c, p) {
  22. // return
  23. // }
  24. // hrp := new(http.Response)
  25. // resp, err := svc.LGPushEquipmentInfo(p)
  26. // if err != nil || len(resp) > 0 {
  27. // hrp.Code = 500
  28. // hrp.Message = strings.Join(resp, ";")
  29. // hrp.Msg = strings.Join(resp, ";")
  30. // c.JSON(500, hrp)
  31. // return
  32. // }
  33. // hrp.Code = 200
  34. // hrp.Message = "上传成功!"
  35. // hrp.Msg = "上传成功!"
  36. // c.JSON(200, hrp)
  37. //}
  38. //
  39. //func GetVehicleList(c *gin.Context) {
  40. // p := new(liugong.GetVehicleListReq)
  41. // hrp := new(http.Response)
  42. // //c.BindQuery(p)
  43. // p.PastureId = c.Query("pastureId")
  44. // p.StartTime = c.Query("startTime")
  45. // p.EndTime = c.Query("endTime")
  46. // p.Offset, _ = strconv.Atoi(c.Query("offset"))
  47. // p.PageCount, _ = strconv.Atoi(c.Query("pageCount"))
  48. //
  49. // fmt.Println(p)
  50. // resp, count, err := svc.GetVehicleList(p)
  51. // if err != nil {
  52. // hrp.Code = 500
  53. // hrp.Message = err.Error()
  54. // hrp.Msg = err.Error()
  55. // c.JSON(500, hrp)
  56. // return
  57. // }
  58. // hrp.Data = resp
  59. // hrp.Code = 200
  60. // hrp.Count = count
  61. // hrp.Offset = p.Offset
  62. // hrp.PageCount = p.PageCount
  63. // c.JSON(200, hrp)
  64. //}
  65. //GetVehicle
  66. func EditVehicle(c *gin.Context) {
  67. appG := app.Gin{C: c}
  68. dataList := make([]*liugong.EditVehicleReq, 0)
  69. if err := c.ShouldBind(&dataList); err != nil {
  70. appG.Response(500, e.ERROR, "数据格式不正确!")
  71. return
  72. }
  73. errs := svc.EditVehicle(dataList)
  74. if len(errs) > 0 {
  75. appG.Response(500, e.ERROR, strings.Join(errs, ","))
  76. return
  77. }
  78. appG.Response(200, e.SUCCESS, true)
  79. }
  80. func GetVehicle(c *gin.Context) {
  81. appG := app.Gin{C: c}
  82. pastureId := c.Query("pastureId")
  83. offsetStr := c.Query("offset")
  84. pagecountStr := c.Query("pagecount")
  85. startdate := c.Query("startTime")
  86. enddate := c.Query("endTime")
  87. eqCode := c.Query("eqCode")
  88. eqName := c.Query("eqName")
  89. departmentId := c.Query("departmentId")
  90. offset, _ := strconv.Atoi(offsetStr)
  91. pagecount, _ := strconv.Atoi(pagecountStr)
  92. data, err := svc.GetVehicle(pastureId, startdate, enddate, eqCode, eqName, departmentId, offset, pagecount)
  93. if err != nil {
  94. appG.Response(500, e.ERROR, err)
  95. return
  96. }
  97. appG.Response(200, e.SUCCESS, data)
  98. }
  99. func GetWorkClass(c *gin.Context) {
  100. appG := app.Gin{C: c}
  101. dataList := []string{"饲喂车",
  102. "推料车",
  103. "上料装载机",
  104. "卧床疏松车",
  105. "吸污车",
  106. "推粪装载机",
  107. "卧床抛料车",
  108. "消毒车",
  109. "淘牛车",
  110. "剩料收集车",
  111. "青贮倒运车",
  112. "沼渣倒运装载机",
  113. "沼渣倒运自卸车",
  114. "沼渣晾晒拖拉机",
  115. "犊牛转运车",
  116. "兽医装载机",
  117. "装卸装载机",
  118. "装卸叉车",
  119. "犊牛喂奶车",
  120. "犊牛垫料装载机",
  121. "颗粒撒料车", "其他车辆"}
  122. appG.Response(200, e.SUCCESS, dataList)
  123. }
  124. func GetRunningRateDetail(c *gin.Context) {
  125. appG := app.Gin{C: c}
  126. pastureId := c.Query("pastureId")
  127. offsetStr := c.Query("offset")
  128. pagecountStr := c.Query("pagecount")
  129. date := c.Query("date")
  130. eqCode := c.Query("eqCode")
  131. offset, _ := strconv.Atoi(offsetStr)
  132. pagecount, _ := strconv.Atoi(pagecountStr)
  133. data, err := svc.GetRunningRateDetail(date, pastureId, eqCode, offset, pagecount)
  134. if err != nil {
  135. appG.Response(500, e.ERROR, err)
  136. return
  137. }
  138. appG.Response(200, e.SUCCESS, data)
  139. }