zhangqian
2023-11-06 3fb5f541891e3aa69060a1ea9b3808cc42bbbfa8
add log
1个文件已修改
4 ■■■■ 已修改文件
service/device_plc.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/device_plc.go
@@ -21,6 +21,7 @@
func (slf DevicePlcService) GetDevicePlc() (*model.DevicePlc, int) {
    DevicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First()
    if err == gorm.ErrRecordNotFound {
        logx.Errorf("GetDevicePlc failed:%v", err)
        return &model.DevicePlc{
            DeviceID:   "",
            Brand:      "",
@@ -37,6 +38,7 @@
        }, ecode.OK
    }
    if err != nil {
        logx.Errorf("GetDevicePlc failed:%v", err)
        return nil, ecode.DBErr
    }
@@ -46,9 +48,11 @@
func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) {
    plcConfig, code := slf.GetDevicePlc()
    if code != ecode.OK || plcConfig.ID == 0 {
        logx.Errorf("GetDeviceChannelAmount failed:%v, code:%v", plcConfig, code)
        return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!")
    }
    if len(plcConfig.Details) == 0 {
        logx.Errorf("GetDeviceChannelAmount failed, addressList == 0, %+v", plcConfig)
        return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!")
    }
    return len(plcConfig.Details) / 2, nil