chart.go 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. package routers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "kpt.xdmy/pkg/app"
  5. "kpt.xdmy/pkg/e"
  6. )
  7. func GetWaterYieldByPasture(c *gin.Context) {
  8. appG := app.Gin{C: c}
  9. center := c.Query("center")
  10. startTime := c.Query("startTime")
  11. endTime := c.Query("endTime")
  12. startTime = startTime + "-01"
  13. endTime = endTime + "-01"
  14. data, err := svc.GetWaterYieldByPasture(center, startTime, endTime)
  15. if err != nil {
  16. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  17. return
  18. }
  19. appG.Response(200, e.SUCCESS, data)
  20. }
  21. func GetWaterSingleCowByPasture(c *gin.Context) {
  22. appG := app.Gin{C: c}
  23. center := c.Query("center")
  24. startTime := c.Query("startTime")
  25. endTime := c.Query("endTime")
  26. startTime = startTime + "-01"
  27. endTime = endTime + "-01"
  28. data, err := svc.GetWaterSingleCowByPasture(center, startTime, endTime)
  29. if err != nil {
  30. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  31. return
  32. }
  33. appG.Response(200, e.SUCCESS, data)
  34. }
  35. func GetWaterRateByPasture(c *gin.Context) {
  36. appG := app.Gin{C: c}
  37. center := c.Query("center")
  38. startTime := c.Query("startTime")
  39. endTime := c.Query("endTime")
  40. startTime = startTime + "-01"
  41. endTime = endTime + "-01"
  42. data, err := svc.GetWaterRateByPasture(center, startTime, endTime)
  43. if err != nil {
  44. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  45. return
  46. }
  47. appG.Response(200, e.SUCCESS, data)
  48. }
  49. func GetWaterRateCompleteByPasture(c *gin.Context) {
  50. appG := app.Gin{C: c}
  51. center := c.Query("center")
  52. startTime := c.Query("startTime")
  53. endTime := c.Query("endTime")
  54. startTime = startTime + "-01"
  55. endTime = endTime + "-01"
  56. data, err := svc.GetWaterRateCompleteByPasture(center, startTime, endTime)
  57. if err != nil {
  58. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  59. return
  60. }
  61. appG.Response(200, e.SUCCESS, data)
  62. }
  63. func GetWaterPerHeadByPasture(c *gin.Context) {
  64. appG := app.Gin{C: c}
  65. pastureId := c.Query("pastureId")
  66. startTime := c.Query("startTime")
  67. endTime := c.Query("endTime")
  68. startTime = startTime + "-01"
  69. endTime = endTime + "-01"
  70. data, err := svc.GetWaterPerHeadByPasture(pastureId, startTime, endTime)
  71. if err != nil {
  72. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  73. return
  74. }
  75. appG.Response(200, e.SUCCESS, data)
  76. }
  77. func GetElectricityYieldByPasture(c *gin.Context) {
  78. appG := app.Gin{C: c}
  79. center := c.Query("center")
  80. startTime := c.Query("startTime")
  81. endTime := c.Query("endTime")
  82. startTime = startTime + "-01"
  83. endTime = endTime + "-01"
  84. data, err := svc.GetElectricityYieldByPasture(center, startTime, endTime)
  85. if err != nil {
  86. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  87. return
  88. }
  89. appG.Response(200, e.SUCCESS, data)
  90. }
  91. func GetElectricitySingleCowByPasture(c *gin.Context) {
  92. appG := app.Gin{C: c}
  93. center := c.Query("center")
  94. startTime := c.Query("startTime")
  95. endTime := c.Query("endTime")
  96. startTime = startTime + "-01"
  97. endTime = endTime + "-01"
  98. data, err := svc.GetElectricitySingleCowByPasture(center, startTime, endTime)
  99. if err != nil {
  100. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  101. return
  102. }
  103. appG.Response(200, e.SUCCESS, data)
  104. }
  105. func GetElectricityRateByPasture(c *gin.Context) {
  106. appG := app.Gin{C: c}
  107. center := c.Query("center")
  108. startTime := c.Query("startTime")
  109. endTime := c.Query("endTime")
  110. startTime = startTime + "-01"
  111. endTime = endTime + "-01"
  112. data, err := svc.GetElectricityRateByPasture(center, startTime, endTime)
  113. if err != nil {
  114. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  115. return
  116. }
  117. appG.Response(200, e.SUCCESS, data)
  118. }
  119. func GetElectricityRateCompleteByPasture(c *gin.Context) {
  120. appG := app.Gin{C: c}
  121. center := c.Query("center")
  122. startTime := c.Query("startTime")
  123. endTime := c.Query("endTime")
  124. startTime = startTime + "-01"
  125. endTime = endTime + "-01"
  126. data, err := svc.GetElectricityRateCompleteByPasture(center, startTime, endTime)
  127. if err != nil {
  128. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  129. return
  130. }
  131. appG.Response(200, e.SUCCESS, data)
  132. }
  133. func GetElectricityPerHeadByPasture(c *gin.Context) {
  134. appG := app.Gin{C: c}
  135. pastureId := c.Query("pastureId")
  136. startTime := c.Query("startTime")
  137. endTime := c.Query("endTime")
  138. startTime = startTime + "-01"
  139. endTime = endTime + "-01"
  140. data, err := svc.GetElectricityPerHeadByPasture(pastureId, startTime, endTime)
  141. if err != nil {
  142. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  143. return
  144. }
  145. appG.Response(200, e.SUCCESS, data)
  146. }
  147. func GetWxYieldByPasture(c *gin.Context) {
  148. appG := app.Gin{C: c}
  149. center := c.Query("center")
  150. departmentName := c.Query("departmentName")
  151. startTime := c.Query("startTime")
  152. endTime := c.Query("endTime")
  153. startTime = startTime + "-01"
  154. endTime = endTime + "-01"
  155. data, err := svc.GetWxYieldByPasture(departmentName, center, startTime, endTime)
  156. if err != nil {
  157. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  158. return
  159. }
  160. appG.Response(200, e.SUCCESS, data)
  161. }
  162. func GetWxSingleCowByPasture(c *gin.Context) {
  163. appG := app.Gin{C: c}
  164. center := c.Query("center")
  165. startTime := c.Query("startTime")
  166. endTime := c.Query("endTime")
  167. startTime = startTime + "-01"
  168. endTime = endTime + "-01"
  169. data, err := svc.GetWxSingleCowByPasture(center, startTime, endTime)
  170. if err != nil {
  171. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  172. return
  173. }
  174. appG.Response(200, e.SUCCESS, data)
  175. }
  176. func GetWxPerHeadByPasture(c *gin.Context) {
  177. appG := app.Gin{C: c}
  178. pastureId := c.Query("pastureId")
  179. startTime := c.Query("startTime")
  180. endTime := c.Query("endTime")
  181. startTime = startTime + "-01"
  182. endTime = endTime + "-01"
  183. data, err := svc.GetWxPerHeadByPasture(pastureId, startTime, endTime)
  184. if err != nil {
  185. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  186. return
  187. }
  188. appG.Response(200, e.SUCCESS, data)
  189. }
  190. //各牧场年度燃动费对比
  191. func GetIgnitionYieldByPasture(c *gin.Context) {
  192. appG := app.Gin{C: c}
  193. pastureId := c.Query("pastureId")
  194. startTime := c.Query("startTime")
  195. endTime := c.Query("endTime")
  196. startTime = startTime + "-01"
  197. endTime = endTime + "-01"
  198. data, err := svc.GetIgnitionYieldByPasture(pastureId, startTime, endTime)
  199. if err != nil {
  200. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  201. return
  202. }
  203. appG.Response(200, e.SUCCESS, data)
  204. }
  205. //各牧场年度柴油对比
  206. func GetDieselYieldByPasture(c *gin.Context) {
  207. appG := app.Gin{C: c}
  208. pastureId := c.Query("pastureId")
  209. startTime := c.Query("startTime")
  210. endTime := c.Query("endTime")
  211. startTime = startTime + "-01"
  212. endTime = endTime + "-01"
  213. data, err := svc.GetDieselYieldByPasture(pastureId, startTime, endTime)
  214. if err != nil {
  215. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  216. return
  217. }
  218. appG.Response(200, e.SUCCESS, data)
  219. }
  220. //单头牛柴油
  221. func GetDieselRateByPasture(c *gin.Context) {
  222. appG := app.Gin{C: c}
  223. pastureId := c.Query("pastureId")
  224. startTime := c.Query("startTime")
  225. endTime := c.Query("endTime")
  226. startTime = startTime + "-01"
  227. endTime = endTime + "-01"
  228. data, err := svc.GetDieselRateByPasture(pastureId, startTime, endTime)
  229. if err != nil {
  230. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  231. return
  232. }
  233. appG.Response(200, e.SUCCESS, data)
  234. }
  235. //单头牛燃动费
  236. func GetIgnitionRateByPasture(c *gin.Context) {
  237. appG := app.Gin{C: c}
  238. pastureId := c.Query("pastureId")
  239. startTime := c.Query("startTime")
  240. endTime := c.Query("endTime")
  241. startTime = startTime + "-01"
  242. endTime = endTime + "-01"
  243. data, err := svc.GetIgnitionRateByPasture(pastureId, startTime, endTime)
  244. if err != nil {
  245. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  246. return
  247. }
  248. appG.Response(200, e.SUCCESS, data)
  249. }
  250. //单头牛燃动费
  251. func GetDieselPerHeadByPasture(c *gin.Context) {
  252. appG := app.Gin{C: c}
  253. pastureId := c.Query("pastureId")
  254. startTime := c.Query("startTime")
  255. endTime := c.Query("endTime")
  256. startTime = startTime + "-01"
  257. endTime = endTime + "-01"
  258. data, err := svc.GetDieselPerHeadByPasture(pastureId, startTime, endTime)
  259. if err != nil {
  260. c.JSON(200, map[string]interface{}{"code": 200, "data": err.Error(), "msg": "fail"})
  261. return
  262. }
  263. appG.Response(200, e.SUCCESS, data)
  264. }