| | |
| | | ctx.OkWithDetailed(taskData) |
| | | } |
| | | |
| | | // TaskStart |
| | | // GetProcessParams |
| | | // @Tags Task |
| | | // @Summary 任务开始 |
| | | // @Summary 任务开始(获取工艺参数) |
| | | // @Produce application/json |
| | | // @Param id path int true "工序id" |
| | | // @Success 200 {object} contextx.Response{data=response.ProcessParamsResponse} "成功" |
| | | // @Router /v1/task/start/{id} [get] |
| | | func (slf *TaskApi) TaskStart(c *gin.Context) { |
| | | func (slf *TaskApi) GetProcessParams(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | |
| | | procedure, code := service.NewTaskService().GetProcedureById(id) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | | } |
| | | if procedure.Status != model.ProcedureStatusWaitProcess { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "该工序状态不是未开始") |
| | | return |
| | | } |
| | | |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // SendProcessParams |
| | | // TaskStart |
| | | // @Tags Task |
| | | // @Summary 下发工艺参数 |
| | | // @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) { |
| | | func (slf *TaskApi) TaskStart(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | |
| | | return |
| | | } |
| | | |
| | | if procedure.Status == model.ProcedureStatusProcessing { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "该工序已开始生产") |
| | | return |
| | | } |
| | | |
| | | caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicProcessParamsRequest, conf.Conf.NsqConf.NodeId), fmt.Sprintf(constvar.NsqTopicProcessParamsResponse, conf.Conf.NsqConf.NodeId)) |
| | | var result common.ResponseProcessParams |
| | | |