| | |
| | | ctx.Fail(code) |
| | | return |
| | | } |
| | | if procedure.DeviceID != conf.Conf.CurrentDeviceID { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "该任务不属于当前设备") |
| | | return |
| | | } |
| | | order, err := taskService.GetOrderByWorkOrderId(procedure.WorkOrderID) |
| | | if err != nil { |
| | | ctx.Fail(ecode.UnknownErr) |
| | |
| | | "apsClient/pkg/logx" |
| | | "apsClient/pkg/structx" |
| | | "encoding/json" |
| | | "errors" |
| | | "github.com/jinzhu/gorm" |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) { |
| | | plcConfig, code := slf.GetDevicePlc() |
| | | if code != ecode.OK || plcConfig.ID == 0 { |
| | | return 1, nil |
| | | device, err := model.NewDeviceSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() |
| | | if err != nil { |
| | | return 0, errors.New("没有找到当前设备") |
| | | } |
| | | if len(plcConfig.Details) == 0 { |
| | | return 1, nil |
| | | } |
| | | return len(plcConfig.Details) / 2, nil |
| | | return device.ExtChannelAmount + 1, nil |
| | | } |
| | | |
| | | func (DevicePlcService) UpdateDevicePlc(plc *request.UpdatePlc) int { |