| | |
| | | } |
| | | |
| | | err = model.WithTransaction(func(db *gorm.DB) error { |
| | | err = taskService.UpdateProcedureStatus(db, params.ProcedureId, model.ProcedureStatusProcessing) |
| | | err = taskService.UpdateProcedureStatusAndPosition(db, params.ProcedureId, model.ProcedureStatusProcessing, params.Position) |
| | | if err != nil { |
| | | return err |
| | | } |
| | |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "position": { |
| | | "description": "每个设备可能有多个机位同时生产,用position表示位置", |
| | | "type": "integer" |
| | | }, |
| | | "procedure": { |
| | | "description": "common.ProductProcedure 对象", |
| | | "allOf": [ |
| | |
| | | "order": { |
| | | "$ref": "#/definitions/model.Order" |
| | | }, |
| | | "position": { |
| | | "description": "当前任务在设备第几个位置", |
| | | "type": "integer" |
| | | }, |
| | | "procedure": { |
| | | "$ref": "#/definitions/model.Procedures" |
| | | } |
| | |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "position": { |
| | | "description": "每个设备可能有多个机位同时生产,用position表示位置", |
| | | "type": "integer" |
| | | }, |
| | | "procedure": { |
| | | "description": "common.ProductProcedure 对象", |
| | | "allOf": [ |
| | |
| | | "order": { |
| | | "$ref": "#/definitions/model.Order" |
| | | }, |
| | | "position": { |
| | | "description": "当前任务在设备第几个位置", |
| | | "type": "integer" |
| | | }, |
| | | "procedure": { |
| | | "$ref": "#/definitions/model.Procedures" |
| | | } |
| | |
| | | type: integer |
| | | id: |
| | | type: integer |
| | | position: |
| | | description: 每个设备可能有多个机位同时生产,用position表示位置 |
| | | type: integer |
| | | procedure: |
| | | allOf: |
| | | - $ref: '#/definitions/common.ProductProcedure' |
| | |
| | | type: integer |
| | | order: |
| | | $ref: '#/definitions/model.Order' |
| | | position: |
| | | description: 当前任务在设备第几个位置 |
| | | type: integer |
| | | procedure: |
| | | $ref: '#/definitions/model.Procedures' |
| | | type: object |
| | |
| | | OrderID string `gorm:"index;type:varchar(191);not null;comment:订单ID" json:"-"` |
| | | DeviceID string `gorm:"index;type:varchar(191);comment:设备ID" json:"deviceId"` |
| | | ProcedureID string `gorm:"index;type:varchar(191);comment:工序ID" json:"procedureId"` |
| | | Position int `gorm:"type:int;comment:工作位置" json:"position"` //每个设备可能有多个机位同时生产,用position表示位置 |
| | | StartTime int64 `gorm:"comment:计划开始时间" json:"startTime"` |
| | | EndTime int64 `gorm:"comment:计划结束时间" json:"endTime"` |
| | | Status ProcedureStatus |
| | |
| | | type TaskData struct { |
| | | Order *model.Order |
| | | Procedure *model.Procedures |
| | | Position int //当前任务在设备第几个位置 |
| | | AllProcedures []string |
| | | CurrentProcedureIndex int |
| | | } |
| | |
| | | } |
| | | for _, procedure := range procedures { |
| | | taskData := response.TaskData{ |
| | | Order: orderMap[procedure.WorkOrderID], |
| | | Procedure: procedure, |
| | | Order: orderMap[procedure.WorkOrderID], |
| | | Procedure: procedure, |
| | | AllProcedures: nil, |
| | | CurrentProcedureIndex: 0, |
| | | Position: procedure.Position, |
| | | } |
| | | taskDataList = append(taskDataList, &taskData) |
| | | } |
| | |
| | | return procedure, ecode.OK |
| | | } |
| | | |
| | | func (slf TaskService) UpdateProcedureStatusAndPosition(db *gorm.DB, id int, status model.ProcedureStatus, position int) error { |
| | | if status == model.ProcedureStatusFinished { |
| | | ProgressCacheUnset() |
| | | } |
| | | return model.NewProceduresSearch(db).SetId(id).UpdateByMap(map[string]interface{}{ |
| | | "status": status, |
| | | "position": position, |
| | | }) |
| | | } |
| | | |
| | | func (slf TaskService) UpdateProcedureStatus(db *gorm.DB, id int, status model.ProcedureStatus) error { |
| | | if status == model.ProcedureStatusFinished { |
| | | ProgressCacheUnset() |