| | |
| | | // @Summary 获取工艺模型列表 |
| | | // @Produce application/json |
| | | // @Param object query request.ProcessModelList true "查询参数" |
| | | // @Success 200 {object} contextx.Response{data=response.TaskCountdown} "成功" |
| | | // @Success 200 {object} contextx.Response{data=[]model.ProcessModel} "成功" |
| | | // @Router /v1/processModel/list [get] |
| | | func (slf *ProcessModelApi) List(c *gin.Context) { |
| | | var params request.ProcessModelList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | procedure, code := service.NewTaskService().GetProcedureById(params.ProcedureId) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | | } |
| | | |
| | | order, err := service.NewTaskService().GetOrderByWorkOrderId(procedure.WorkOrderID) |
| | | if err != nil { |
| | | ctx.Fail(ecode.DBErr) |
| | | return |
| | | } |
| | | |
| | |
| | | ctx.Fail(ecode.DBErr) |
| | | return |
| | | } |
| | | oldProcessModel, _ := service.GetProcessModelByNumber(params.Number) |
| | | for _, processModel := range list { |
| | | if processModel.Procedure == procedure.ProceduresInfo.ProcedureName && processModel.Product == order.ProductName { |
| | | if processModel.Procedure == oldProcessModel.Procedure && processModel.Product == oldProcessModel.Product { |
| | | processModel.IsUpdate = processModel.Number != params.Number |
| | | } |
| | | if processModel.IsUpdate { |
| | | |
| | | processModel.NewNumber, processModel.NewParamsMap = processModel.Number, processModel.ParamsMap |
| | | processModel.Number, processModel.ParamsMap = oldProcessModel.Number, oldProcessModel.ParamsMap |
| | | } |
| | | } |
| | | |
| | | ctx.ResultList(list, total) |
| | |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.TaskCountdown" |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ProcessModel" |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ProcessModel": { |
| | | "type": "object", |
| | | "properties": { |
| | | "deviceId": { |
| | | "description": "用于过滤获取nsq消息", |
| | | "type": "string" |
| | | }, |
| | | "isUpdate": { |
| | | "description": "前端用", |
| | | "type": "boolean" |
| | | }, |
| | | "newNumber": { |
| | | "type": "string" |
| | | }, |
| | | "newParamsMap": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | }, |
| | | "number": { |
| | | "description": "工艺模型编号", |
| | | "type": "string" |
| | | }, |
| | | "params": { |
| | | "type": "string" |
| | | }, |
| | | "paramsMap": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | }, |
| | | "procedure": { |
| | | "description": "工序", |
| | | "type": "string" |
| | | }, |
| | | "product": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddPlcBrand": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.TaskCountdown" |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ProcessModel" |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ProcessModel": { |
| | | "type": "object", |
| | | "properties": { |
| | | "deviceId": { |
| | | "description": "用于过滤获取nsq消息", |
| | | "type": "string" |
| | | }, |
| | | "isUpdate": { |
| | | "description": "前端用", |
| | | "type": "boolean" |
| | | }, |
| | | "newNumber": { |
| | | "type": "string" |
| | | }, |
| | | "newParamsMap": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | }, |
| | | "number": { |
| | | "description": "工艺模型编号", |
| | | "type": "string" |
| | | }, |
| | | "params": { |
| | | "type": "string" |
| | | }, |
| | | "paramsMap": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | }, |
| | | "procedure": { |
| | | "description": "工序", |
| | | "type": "string" |
| | | }, |
| | | "product": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddPlcBrand": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | status: |
| | | $ref: '#/definitions/model.ProcedureStatus' |
| | | type: object |
| | | model.ProcessModel: |
| | | properties: |
| | | deviceId: |
| | | description: 用于过滤获取nsq消息 |
| | | type: string |
| | | isUpdate: |
| | | description: 前端用 |
| | | type: boolean |
| | | newNumber: |
| | | type: string |
| | | newParamsMap: |
| | | additionalProperties: true |
| | | type: object |
| | | number: |
| | | description: 工艺模型编号 |
| | | type: string |
| | | params: |
| | | type: string |
| | | paramsMap: |
| | | additionalProperties: true |
| | | type: object |
| | | procedure: |
| | | description: 工序 |
| | | type: string |
| | | product: |
| | | description: 产品名称 |
| | | type: string |
| | | type: object |
| | | request.AddPlcBrand: |
| | | properties: |
| | | id: |
| | |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.TaskCountdown' |
| | | items: |
| | | $ref: '#/definitions/model.ProcessModel' |
| | | type: array |
| | | type: object |
| | | summary: 获取工艺模型列表 |
| | | tags: |
| | |
| | | Params string `gorm:"type:text;comment:工艺参数键值对json串"` |
| | | ParamsMap map[string]interface{} `json:"paramsMap" gorm:"-"` |
| | | DeviceId string `json:"deviceId" gorm:"-"` //用于过滤获取nsq消息 |
| | | IsNew bool `json:"isNew" gorm:"column:is_new;comment:是否最新的"` //是否最新的 |
| | | IsNew bool `json:"-" gorm:"column:is_new;comment:是否最新的"` //是否最新的 |
| | | IsUpdate bool `json:"isUpdate" gorm:"-"` //前端用 |
| | | NewParamsMap map[string]interface{} `json:"newParamsMap" gorm:"-"` |
| | | NewNumber string `json:"newNumber" gorm:"-"` |
| | | } |
| | | |
| | | ProcessModelSearch struct { |
| | |
| | | SetPage(page, pageSize).SetProcedures(device.ProceduresArr).Find() |
| | | return |
| | | } |
| | | |
| | | func GetProcessModelByNumber(num string) (record *model.ProcessModel, err error) { |
| | | return model.NewProcessModelSearch().SetNumber(num).First() |
| | | } |