package routers import ( "github.com/gin-gonic/gin" "kpt.xdmy/apiserver/model/liugong" "kpt.xdmy/pkg/app" "kpt.xdmy/pkg/e" "strconv" "strings" ) //func GetLiuGongToken(c *gin.Context) { // resp, err := svc.GetLiuGongToken() // if err != nil { // c.JSON(500, resp) // return // } // c.JSON(200, resp) //} // //func EditVehicle(c *gin.Context) { // p := new(liugong.PushEquipmentInfoReq) // if !Bind(c, p) { // return // } // hrp := new(http.Response) // resp, err := svc.LGPushEquipmentInfo(p) // if err != nil || len(resp) > 0 { // hrp.Code = 500 // hrp.Message = strings.Join(resp, ";") // hrp.Msg = strings.Join(resp, ";") // c.JSON(500, hrp) // return // } // hrp.Code = 200 // hrp.Message = "上传成功!" // hrp.Msg = "上传成功!" // c.JSON(200, hrp) //} // //func GetVehicleList(c *gin.Context) { // p := new(liugong.GetVehicleListReq) // hrp := new(http.Response) // //c.BindQuery(p) // p.PastureId = c.Query("pastureId") // p.StartTime = c.Query("startTime") // p.EndTime = c.Query("endTime") // p.Offset, _ = strconv.Atoi(c.Query("offset")) // p.PageCount, _ = strconv.Atoi(c.Query("pageCount")) // // fmt.Println(p) // resp, count, err := svc.GetVehicleList(p) // if err != nil { // hrp.Code = 500 // hrp.Message = err.Error() // hrp.Msg = err.Error() // c.JSON(500, hrp) // return // } // hrp.Data = resp // hrp.Code = 200 // hrp.Count = count // hrp.Offset = p.Offset // hrp.PageCount = p.PageCount // c.JSON(200, hrp) //} //GetVehicle func EditVehicle(c *gin.Context) { appG := app.Gin{C: c} dataList := make([]*liugong.EditVehicleReq, 0) if err := c.ShouldBind(&dataList); err != nil { appG.Response(500, e.ERROR, "数据格式不正确!") return } errs := svc.EditVehicle(dataList) if len(errs) > 0 { appG.Response(500, e.ERROR, strings.Join(errs, ",")) return } appG.Response(200, e.SUCCESS, true) } func GetVehicle(c *gin.Context) { appG := app.Gin{C: c} pastureId := c.Query("pastureId") offsetStr := c.Query("offset") pagecountStr := c.Query("pagecount") startdate := c.Query("startTime") enddate := c.Query("endTime") eqCode := c.Query("eqCode") eqName := c.Query("eqName") departmentId := c.Query("departmentId") offset, _ := strconv.Atoi(offsetStr) pagecount, _ := strconv.Atoi(pagecountStr) data, err := svc.GetVehicle(pastureId, startdate, enddate, eqCode, eqName, departmentId, offset, pagecount) if err != nil { appG.Response(500, e.ERROR, err) return } appG.Response(200, e.SUCCESS, data) } func GetWorkClass(c *gin.Context) { appG := app.Gin{C: c} dataList := []string{"饲喂车", "推料车", "上料装载机", "卧床疏松车", "吸污车", "推粪装载机", "卧床抛料车", "消毒车", "淘牛车", "剩料收集车", "青贮倒运车", "沼渣倒运装载机", "沼渣倒运自卸车", "沼渣晾晒拖拉机", "犊牛转运车", "兽医装载机", "装卸装载机", "装卸叉车", "犊牛喂奶车", "犊牛垫料装载机", "颗粒撒料车", "其他车辆"} appG.Response(200, e.SUCCESS, dataList) } func GetRunningRateDetail(c *gin.Context) { appG := app.Gin{C: c} pastureId := c.Query("pastureId") offsetStr := c.Query("offset") pagecountStr := c.Query("pagecount") date := c.Query("date") eqCode := c.Query("eqCode") offset, _ := strconv.Atoi(offsetStr) pagecount, _ := strconv.Atoi(pagecountStr) data, err := svc.GetRunningRateDetail(date, pastureId, eqCode, offset, pagecount) if err != nil { appG.Response(500, e.ERROR, err) return } appG.Response(200, e.SUCCESS, data) }