zhangqian
2023-11-25 8cb2727cce6eaaff94df8f5dd2254da2b9870b24
增加校验
2个文件已修改
16 ■■■■■ 已修改文件
api/v1/task.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/device_plc.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/task.go
@@ -268,6 +268,10 @@
        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)
service/device_plc.go
@@ -8,6 +8,7 @@
    "apsClient/pkg/logx"
    "apsClient/pkg/structx"
    "encoding/json"
    "errors"
    "github.com/jinzhu/gorm"
)
@@ -45,14 +46,11 @@
}
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 {