| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // SetDeviceConfig |
| | | // @Tags 设备 |
| | | // @Summary 设置设备一些配置 |
| | | // @Produce application/json |
| | | // @Param object body request.DeviceConfig true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} "成功" |
| | | // @Router /v1/device/config [post] |
| | | func (slf *DeviceApi) config(c *gin.Context) { |
| | | var params request.DeviceConfig |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | if conf.Conf.CurrentDeviceID == "" { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "当前设备为空,请检查") |
| | | return |
| | | } |
| | | err := service.UpdateDevice(conf.Conf.CurrentDeviceID, params.NeedSetProcessParams) |
| | | if err != nil { |
| | | logx.Errorf("save device config err:%v", err) |
| | | ctx.Fail(ecode.DBErr) |
| | | return |
| | | } |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // DeviceList |
| | | // @Tags 设备 |
| | | // @Summary 获取当前面板绑定的设备列表 |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/v1/device/config": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "设备" |
| | | ], |
| | | "summary": "设置设备一些配置", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeviceConfig" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/v1/device/list": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | "summary": "获取任务", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "deviceID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | "type": "string", |
| | | "enum": [ |
| | | "string", |
| | | "int" |
| | | "int16", |
| | | "int32" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "PlcStartAddressValueTypeString", |
| | | "PlcStartAddressValueTypeInt" |
| | | "PlcStartAddressValueTypeInt16", |
| | | "PlcStartAddressValueTypeInt32" |
| | | ] |
| | | }, |
| | | "constvar.ProblemCode": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeviceConfig": { |
| | | "type": "object", |
| | | "properties": { |
| | | "needSetProcessParams": { |
| | | "description": "是否需要设置工艺参数", |
| | | "type": "boolean" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetProductProgress": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.Device": { |
| | | "type": "object", |
| | | "properties": { |
| | | "deviceID": { |
| | | "type": "string" |
| | | }, |
| | | "deviceName": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.DeviceListResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "当前选定的生产设备", |
| | | "type": "string" |
| | | }, |
| | | "deviceIDList": { |
| | | "deviceList": { |
| | | "description": "生产设备id列表", |
| | | "type": "array", |
| | | "items": { |
| | | "type": "string" |
| | | "$ref": "#/definitions/response.Device" |
| | | } |
| | | }, |
| | | "systemDeviceID": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/v1/device/config": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "设备" |
| | | ], |
| | | "summary": "设置设备一些配置", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeviceConfig" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/v1/device/list": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | "summary": "获取任务", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "deviceID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | |
| | | "type": "string", |
| | | "enum": [ |
| | | "string", |
| | | "int" |
| | | "int16", |
| | | "int32" |
| | | ], |
| | | "x-enum-varnames": [ |
| | | "PlcStartAddressValueTypeString", |
| | | "PlcStartAddressValueTypeInt" |
| | | "PlcStartAddressValueTypeInt16", |
| | | "PlcStartAddressValueTypeInt32" |
| | | ] |
| | | }, |
| | | "constvar.ProblemCode": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeviceConfig": { |
| | | "type": "object", |
| | | "properties": { |
| | | "needSetProcessParams": { |
| | | "description": "是否需要设置工艺参数", |
| | | "type": "boolean" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetProductProgress": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.Device": { |
| | | "type": "object", |
| | | "properties": { |
| | | "deviceID": { |
| | | "type": "string" |
| | | }, |
| | | "deviceName": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "response.DeviceListResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "description": "当前选定的生产设备", |
| | | "type": "string" |
| | | }, |
| | | "deviceIDList": { |
| | | "deviceList": { |
| | | "description": "生产设备id列表", |
| | | "type": "array", |
| | | "items": { |
| | | "type": "string" |
| | | "$ref": "#/definitions/response.Device" |
| | | } |
| | | }, |
| | | "systemDeviceID": { |
| | |
| | | constvar.PlcStartAddressValueType: |
| | | enum: |
| | | - string |
| | | - int |
| | | - int16 |
| | | - int32 |
| | | type: string |
| | | x-enum-varnames: |
| | | - PlcStartAddressValueTypeString |
| | | - PlcStartAddressValueTypeInt |
| | | - PlcStartAddressValueTypeInt16 |
| | | - PlcStartAddressValueTypeInt32 |
| | | constvar.ProblemCode: |
| | | enum: |
| | | - service |
| | |
| | | updatedAt: |
| | | type: string |
| | | type: object |
| | | request.DeviceConfig: |
| | | properties: |
| | | needSetProcessParams: |
| | | description: 是否需要设置工艺参数 |
| | | type: boolean |
| | | type: object |
| | | request.GetProductProgress: |
| | | properties: |
| | | channel: |
| | |
| | | updatedAt: |
| | | type: string |
| | | type: object |
| | | response.Device: |
| | | properties: |
| | | deviceID: |
| | | type: string |
| | | deviceName: |
| | | type: string |
| | | type: object |
| | | response.DeviceListResponse: |
| | | properties: |
| | | clusterNodeQuantity: |
| | |
| | | currentDeviceID: |
| | | description: 当前选定的生产设备 |
| | | type: string |
| | | deviceIDList: |
| | | deviceList: |
| | | description: 生产设备id列表 |
| | | items: |
| | | type: string |
| | | $ref: '#/definitions/response.Device' |
| | | type: array |
| | | systemDeviceID: |
| | | description: 工控机设备ID |
| | |
| | | summary: 更新plc配置 |
| | | tags: |
| | | - Config |
| | | /v1/device/config: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.DeviceConfig' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 设置设备一些配置 |
| | | tags: |
| | | - 设备 |
| | | /v1/device/list: |
| | | get: |
| | | produces: |
| | |
| | | /v1/task/get: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: deviceID |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | |
| | | Procedures string `gorm:"column:procedure;type:varchar(255);not null;default ''" json:"procedures"` //设备支持的工序,用逗号分隔 |
| | | DeviceMac string `gorm:"type:varchar(255);" json:"deviceMac"` //绑定的工控机设备ID |
| | | ProceduresArr []string `gorm:"-" json:"ProceduresArr"` //设备支持的工序切片 |
| | | NeedSetProcessParams bool `gorm:"column:need_set_process_params" json:"needSetProcessParams"` //是否需要设置工艺参数 //设备支持的工序切片 |
| | | } |
| | | |
| | | DeviceSearch struct { |
| | |
| | | type SetCurrentDevice struct { |
| | | CurrentDeviceID string `json:"currentDeviceID,omitempty"` //当前选定的生产设备 |
| | | } |
| | | |
| | | type DeviceConfig struct { |
| | | NeedSetProcessParams bool `json:"needSetProcessParams,omitempty"` //是否需要设置工艺参数 |
| | | } |
| | |
| | | "apsClient/model" |
| | | "apsClient/model/response" |
| | | "apsClient/pkg/logx" |
| | | "errors" |
| | | "github.com/jinzhu/gorm" |
| | | "os" |
| | | "strings" |
| | |
| | | deviceId = strings.Trim(deviceId, "\n") |
| | | return deviceId |
| | | } |
| | | |
| | | func UpdateDevice(deviceId string, needSetProcessParams bool) (err error) { |
| | | device, err := model.NewDeviceSearch().SetDeviceId(deviceId).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | return errors.New("设备不存在") |
| | | } |
| | | device.NeedSetProcessParams = needSetProcessParams |
| | | return model.NewDeviceSearch().SetID(device.ID).Save(device) |
| | | } |