| | |
| | | "apsClient/pkg/ecode" |
| | | "apsClient/pkg/logx" |
| | | "apsClient/service" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "time" |
| | | ) |
| | | |
| | | type TaskApi struct{} |
| | |
| | | } |
| | | |
| | | // TaskStart |
| | | // @Tags Base |
| | | // @Tags Task |
| | | // @Summary 任务开始 |
| | | // @Produce application/json |
| | | // @Param id path int true "工序id" |
| | |
| | | } |
| | | |
| | | // TaskFinish |
| | | // @Tags Base |
| | | // @Tags Task |
| | | // @Summary 任务结束 |
| | | // @Produce application/json |
| | | // @Param id path int true "工序id" |
| | |
| | | } |
| | | 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() |
| | | } |