123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 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)
- }
|