| | |
| | | |
| | | import ( |
| | | "apsClient/constvar" |
| | | "apsClient/model/request" |
| | | "apsClient/model/response" |
| | | _ "apsClient/model/response" |
| | | "apsClient/pkg/contextx" |
| | |
| | | // @Tags 生产数量 |
| | | // @Summary 获取生产进度 |
| | | // @Produce application/json |
| | | // @Param object body request.SendProcessParams true "查询参数" |
| | | // @Success 200 {object} contextx.Response{data=response.ProductProgress} "成功" |
| | | // @Router /v1/plc/productProgress [get] |
| | | func (slf *PlcApi) GetProductProgress(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | var params request.SendProcessParams |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | |
| | | // @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.UpdateProcedureStatus(db, params.ProcedureId, model.ProcedureStatusProcessing) |
| | | if err != nil { |
| | | return err |
| | | } |
| | |
| | | "生产数量" |
| | | ], |
| | | "summary": "获取生产进度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SendProcessParams" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | |
| | | "summary": "下发工艺参数(开始任务)", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "工序id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SendProcessParams" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SendProcessParams": { |
| | | "type": "object", |
| | | "required": [ |
| | | "procedureId" |
| | | ], |
| | | "properties": { |
| | | "position": { |
| | | "type": "integer" |
| | | }, |
| | | "procedureId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdatePlc": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "生产数量" |
| | | ], |
| | | "summary": "获取生产进度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SendProcessParams" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | |
| | | "summary": "下发工艺参数(开始任务)", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "工序id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SendProcessParams" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SendProcessParams": { |
| | | "type": "object", |
| | | "required": [ |
| | | "procedureId" |
| | | ], |
| | | "properties": { |
| | | "position": { |
| | | "type": "integer" |
| | | }, |
| | | "procedureId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdatePlc": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.SendProcessParams: |
| | | properties: |
| | | position: |
| | | type: integer |
| | | procedureId: |
| | | type: integer |
| | | required: |
| | | - procedureId |
| | | type: object |
| | | request.UpdatePlc: |
| | | properties: |
| | | address: |
| | |
| | | - Config |
| | | /v1/plc/productProgress: |
| | | get: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.SendProcessParams' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | /v1/task/sendProcessParams/{id}: |
| | | post: |
| | | parameters: |
| | | - description: 工序id |
| | | in: path |
| | | name: id |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | type: integer |
| | | schema: |
| | | $ref: '#/definitions/request.SendProcessParams' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | type TaskList struct { |
| | | PageInfo |
| | | } |
| | | |
| | | type SendProcessParams struct { |
| | | ProcedureId int `json:"procedureId" binding:"required"` |
| | | Position int `json:"position"` |
| | | } |
| | | |
| | | type GetProductProgress struct { |
| | | ProcedureId int `json:"procedureId" binding:"required"` |
| | | Position int `json:"position"` |
| | | } |
| | |
| | | taskApi := new(v1.TaskApi) |
| | | taskGroup := v1Group.Group("task") |
| | | { |
| | | taskGroup.GET("countdown", taskApi.TaskCountdown) // 新任务倒计时 |
| | | taskGroup.GET("get", taskApi.TaskGet) // 获取工序 |
| | | taskGroup.GET("start/:id", taskApi.GetProcessParams) // 获取工艺参数 |
| | | taskGroup.POST("sendProcessParams/:id", taskApi.TaskStart) // 下发工艺参数并开始工序 |
| | | taskGroup.PUT("finish/:id", taskApi.TaskFinish) // 完成工序 |
| | | taskGroup.GET("countdown", taskApi.TaskCountdown) // 新任务倒计时 |
| | | taskGroup.GET("get", taskApi.TaskGet) // 获取工序 |
| | | taskGroup.GET("start/:id", taskApi.GetProcessParams) // 获取工艺参数 |
| | | taskGroup.POST("sendProcessParams", taskApi.TaskStart) // 下发工艺参数并开始工序 |
| | | taskGroup.PUT("finish/:id", taskApi.TaskFinish) // 完成工序 |
| | | } |
| | | |
| | | configApi := new(v1.ConfigApi) |