From e5ee9138c720e48f7447be486f247e765b3f1e46 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 18 八月 2023 11:20:02 +0800 Subject: [PATCH] 增加参数下发接口 --- api/v1/task.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 56 insertions(+), 2 deletions(-) diff --git a/api/v1/task.go b/api/v1/task.go index cc746f2..2e01370 100644 --- a/api/v1/task.go +++ b/api/v1/task.go @@ -8,7 +8,9 @@ "apsClient/pkg/ecode" "apsClient/pkg/logx" "apsClient/service" + "fmt" "github.com/gin-gonic/gin" + "time" ) type TaskApi struct{} @@ -34,7 +36,7 @@ } // TaskStart -// @Tags Base +// @Tags Task // @Summary 浠诲姟寮�濮� // @Produce application/json // @Param id path int true "宸ュ簭id" @@ -82,7 +84,7 @@ } // TaskFinish -// @Tags Base +// @Tags Task // @Summary 浠诲姟缁撴潫 // @Produce application/json // @Param id path int true "宸ュ簭id" @@ -112,3 +114,55 @@ } ctx.Ok() } + +// SendProcessParams +// @Tags Task +// @Summary 涓嬪彂宸ヨ壓鍙傛暟 +// @Produce application/json +// @Param id path int true "宸ュ簭id" +// @Success 200 {object} contextx.Response{service.GetProcessModel} "鎴愬姛" +// @Router /v1/task/sendProcessParams/{id} [post] +func (slf *TaskApi) SendProcessParams(c *gin.Context) { + ctx, ok := contextx.NewContext(c, nil) + if !ok { + return + } + idx := c.Param("id") + if idx == "" { + ctx.Fail(ecode.ParamsErr) + return + } + id := convertx.Atoi(idx) + procedure, code := service.NewTaskService().GetProcedureById(id) + if code != ecode.OK { + ctx.Fail(code) + return + } + order, err := service.NewTaskService().GetOrderByOrderId(procedure.OrderID) + if err != nil { + ctx.Fail(ecode.UnknownErr) + return + } + + params := service.GetProcessModelParams{ + WorkOrder: "", + OrderId: procedure.OrderID, + Product: order.ProductName, + Procedure: procedure.ProceduresInfo.ProcedureName, + Device: procedure.ProceduresInfo.DeviceID, + } + + resp, err := service.ProcessModel{}.GetProcessModel(params) + if err != nil { + logx.Errorf("SendProcessModel GetProcessModel err: %v", err.Error()) + ctx.Fail(ecode.UnknownErr) + return + } + fmt.Println("----------------寮�濮嬩笅鍙戝伐鑹哄弬鏁�-----------------") + for k, v := range resp.ParamsMap { + fmt.Println(fmt.Sprintf("%v : %v", k, v)) + time.Sleep(time.Millisecond * 300) + } + fmt.Println("----------------涓嬪彂宸ヨ壓鍙傛暟瀹屾瘯-----------------") + ctx.Ok() +} -- Gitblit v1.8.0