From 8d60f67b0c224f84f291fabfd796f6f48fedebf2 Mon Sep 17 00:00:00 2001 From: YuleiLan Date: Tue, 1 Sep 2020 19:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BB=E5=8A=A8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/process/workOrder.go | 39 +++++++++++++++++++++++++++++++++++++ router/process/workOrder.go | 1 + 2 files changed, 40 insertions(+) diff --git a/apis/process/workOrder.go b/apis/process/workOrder.go index 79aa52c4..932967af 100644 --- a/apis/process/workOrder.go +++ b/apis/process/workOrder.go @@ -585,3 +585,42 @@ func UrgeWorkOrder(c *gin.Context) { app.OK(c, "", "") } + +// 主动处理 +func ActiveOrder(c *gin.Context) { + var ( + workOrderId string + err error + stateValue []struct { + ID string `json:"id"` + Label string `json:"label"` + ProcessMethod string `json:"process_method"` + Processor []int `json:"processor"` + } + stateValueByte []byte + ) + + workOrderId = c.Param("id") + + err = c.ShouldBind(&stateValue) + if err != nil { + app.Error(c, -1, err, "") + return + } + + stateValueByte, err = json.Marshal(stateValue) + if err != nil { + app.Error(c, -1, fmt.Errorf("转byte失败,%v", err.Error()), "") + return + } + + err = orm.Eloquent.Model(&process.WorkOrderInfo{}). + Where("id = ?", workOrderId). + Update("state", stateValueByte).Error + if err != nil { + app.Error(c, -1, fmt.Errorf("接单失败,%v", err.Error()), "") + return + } + + app.OK(c, "", "接单成功,请及时处理") +} diff --git a/router/process/workOrder.go b/router/process/workOrder.go index b46dcd30..2e20b441 100644 --- a/router/process/workOrder.go +++ b/router/process/workOrder.go @@ -22,5 +22,6 @@ func RegisterWorkOrderRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd workOrderRouter.GET("/unity", process.UnityWorkOrder) workOrderRouter.POST("/inversion", process.InversionWorkOrder) workOrderRouter.GET("/urge", process.UrgeWorkOrder) + workOrderRouter.PUT("/active-order/:id", process.ActiveOrder) } }