| | |
| | | "github.com/gin-gonic/gin" |
| | | "gorm.io/gorm" |
| | | "sort" |
| | | "sync" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | |
| | | params.Page = 1 |
| | | |
| | | if params.Page <= 0 { |
| | | if params.PageSize <= 0 { |
| | | params.PageSize = channelAmount |
| | | } |
| | | |
| | |
| | | |
| | | order, err := service.NewTaskService().GetOrderByWorkOrderId(procedure.WorkOrderID) |
| | | if err != nil { |
| | | ctx.Fail(ecode.UnknownErr) |
| | | ctx.Fail(ecode.DBErr) |
| | | return |
| | | } |
| | | |
| | | processModel, err := service.NewTaskService().GetProcessParams(procedure, order) |
| | | if err != nil || processModel == nil || processModel.ParamsMap == nil { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "请先配置工艺参数") |
| | | ctx.FailWithMsg(ecode.ParamsErr, "未获取到工艺参数,请在工艺模型库中上传!") |
| | | return |
| | | } |
| | | |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | var mutex sync.Mutex |
| | | |
| | | // TaskStart |
| | | // @Tags Task |
| | | // @Summary 下发工艺参数(开始任务) |
| | |
| | | // @Success 200 {object} contextx.Response{service.GetProcessModel} "成功" |
| | | // @Router /v1/task/sendProcessParams [post] |
| | | func (slf *TaskApi) TaskStart(c *gin.Context) { |
| | | mutex.Lock() |
| | | defer mutex.Unlock() |
| | | var params request.SendProcessParams |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | |
| | | } |
| | | |
| | | if procedure.Status == model.ProcedureStatusProcessing { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "该工序已开始生产") |
| | | ctx.Ok() |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | return nil |
| | | }) |
| | | ctx.FailWithMsg(ecode.NeedConfirmedErr, "糟糕,工艺下发失败。") |
| | | ctx.FailWithMsg(ecode.NeedConfirmedErr, "PLC请求失败,请检查PLC配置!") |
| | | return |
| | | } |
| | | if code != ecode.OK { |