| | |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/model/common" |
| | | "apsClient/model/request" |
| | | "apsClient/model/response" |
| | | "apsClient/nsq" |
| | | "apsClient/pkg/contextx" |
| | |
| | | // @Tags Task |
| | | // @Summary 获取任务 |
| | | // @Produce application/json |
| | | // @Param object query request.TaskList true "查询参数" |
| | | // @Success 200 {object} contextx.Response{data=response.TaskData} "成功" |
| | | // @Router /v1/task/get [get] |
| | | func (slf *TaskApi) TaskGet(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | var params request.TaskList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | if params.Page <= 0 { |
| | | params.Page = 1 |
| | | } |
| | | if params.PageSize <= 0 { |
| | | params.PageSize = 1 |
| | | } |
| | | |
| | | taskData, code := service.NewTaskService().GetTask() |
| | | taskDataList, count, code := service.NewTaskService().GetTask(params.Page, params.PageSize) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | | } |
| | | ctx.OkWithDetailed(taskData) |
| | | taskResponse := &response.TaskResponse{ |
| | | Tasks: taskDataList, |
| | | TaskCount: count, |
| | | } |
| | | ctx.OkWithDetailed(taskResponse) |
| | | } |
| | | |
| | | // GetProcessParams |
| | |
| | | // @Tags Task |
| | | // @Summary 下发工艺参数(开始任务) |
| | | // @Produce application/json |
| | | // @Param id path int true "工序id" |
| | | // @Param object body request.SendProcessParams true "查询参数" |
| | | // @Success 200 {object} contextx.Response{service.GetProcessModel} "成功" |
| | | // @Router /v1/task/sendProcessParams/{id} [post] |
| | | func (slf *TaskApi) TaskStart(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | var params request.SendProcessParams |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | idx := c.Param("id") |
| | | if idx == "" { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | return |
| | | } |
| | | id := convertx.Atoi(idx) |
| | | taskService := service.NewTaskService() |
| | | procedure, code := taskService.GetProcedureById(id) |
| | | procedure, code := taskService.GetProcedureById(params.ProcedureId) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | |
| | | } |
| | | |
| | | err = model.WithTransaction(func(db *gorm.DB) error { |
| | | err = taskService.UpdateProcedureStatus(db, id, model.ProcedureStatusProcessing) |
| | | err = taskService.UpdateProcedureStatusAndPosition(db, params.ProcedureId, model.ProcedureStatusProcessing, params.Position) |
| | | if err != nil { |
| | | return err |
| | | } |