feed_formula.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package group
  2. import (
  3. "net/http"
  4. "tmr-watch/models"
  5. "tmr-watch/pkg/app"
  6. "tmr-watch/pkg/e"
  7. "tmr-watch/service/group"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // DistributeFeedFormula 饲料配方下发
  11. func DistributeFeedFormula(c *gin.Context) {
  12. appG := app.Gin{C: c}
  13. var req models.PastureBodyRequest
  14. if err := c.BindJSON(&req); err != nil {
  15. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  16. return
  17. }
  18. if len(req.Body) <= 0 {
  19. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  20. }
  21. if err := group.DistributeFeedFormulaService(&req); err != nil {
  22. appG.Response(http.StatusBadRequest, e.ERROR_ADD_FAIL, nil)
  23. return
  24. }
  25. appG.Response(http.StatusOK, e.SUCCESS, map[string]bool{
  26. "success": true,
  27. })
  28. }
  29. // AnalysisAccuracy 准确性分析
  30. func AnalysisAccuracy(c *gin.Context) {
  31. appG := app.Gin{C: c}
  32. var req models.AnalysisAccuracyRequest
  33. if err := c.BindJSON(&req); err != nil {
  34. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  35. return
  36. }
  37. if res, err := group.AnalysisAccuracyService(&req); err != nil {
  38. appG.Response(http.StatusBadRequest, e.ERROR_GET_S_FAIL, map[string]interface{}{
  39. "error": err,
  40. })
  41. } else {
  42. appG.Response(http.StatusOK, e.SUCCESS, res)
  43. }
  44. }
  45. // ProcessAnalysis 过程分析
  46. func ProcessAnalysis(c *gin.Context) {
  47. appG := app.Gin{C: c}
  48. var req models.AnalysisAccuracyRequest
  49. if err := c.BindJSON(&req); err != nil {
  50. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  51. return
  52. }
  53. if res, err := group.ProcessAnalysisService(&req); err != nil {
  54. appG.Response(http.StatusBadRequest, e.ERROR_GET_S_FAIL, map[string]interface{}{
  55. "error": err,
  56. })
  57. } else {
  58. appG.Response(http.StatusOK, e.SUCCESS, res)
  59. }
  60. }
  61. // SprinkleStatistics 撒料统计
  62. func SprinkleStatistics(c *gin.Context) {
  63. appG := app.Gin{C: c}
  64. var req models.SprinkleStatisticsRequest
  65. if err := c.BindJSON(&req); err != nil {
  66. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  67. return
  68. }
  69. if res, err := group.SprinkleStatisticsService(&req); err != nil {
  70. appG.Response(http.StatusBadRequest, e.ERROR_GET_S_FAIL, map[string]interface{}{
  71. "error": err,
  72. })
  73. } else {
  74. appG.Response(http.StatusOK, e.SUCCESS, res)
  75. }
  76. }