fix
zhangqian
2023-11-25 cb7e30bb64945dfbd8288a20156f09c97a052075
fix
5个文件已修改
32 ■■■■■ 已修改文件
api/v1/task.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/device_plc.go 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/msg.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/device_plc.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/task.go
@@ -285,7 +285,7 @@
    var processModelNumber string
    plcConfig, code := service.NewDevicePlcService().GetDevicePlc()
    if code == ecode.OK && plcConfig.ID != 0 {
    if code == ecode.OK && plcConfig.ID != 0 && len(plcConfig.Details) > 0 {
        plcConfig.MaxTryTimes = 2
        device, err := service.GetCurrentDevice()
        if err != nil {
model/device_plc.go
@@ -57,12 +57,15 @@
}
func (slf *DevicePlc) AfterFind(tx *gorm.DB) error {
    details := make([]*DevicePlcAddress, 0)
    err := json.Unmarshal([]byte(slf.Detail), &details)
    if err != nil {
        return err
    if slf.Detail != "" {
        details := make([]*DevicePlcAddress, 0)
        err := json.Unmarshal([]byte(slf.Detail), &details)
        if err != nil {
            return err
        }
        slf.Details = details
    }
    slf.Details = details
    return nil
}
pkg/ecode/code.go
@@ -8,4 +8,5 @@
    RedisErr         = 2003 // redis错误
    ParamsErr        = 2004 // 请求参数错误
    NeedConfirmedErr = 2005 // 需要弹窗确认的错误
    PlcAddressError  = 2006 //缺失加工数和目标数地址配置
)
pkg/ecode/msg.go
@@ -1,10 +1,11 @@
package ecode
var MsgFlags = map[int]string{
    UnknownErr: "未知错误",
    DBErr:      "数据库连接失败,请检查数据库配置!",
    RedisErr:   "redis错误",
    ParamsErr:  "请求参数错误",
    UnknownErr:      "未知错误",
    DBErr:           "数据库连接失败,请检查数据库配置!",
    RedisErr:        "redis错误",
    ParamsErr:       "请求参数错误",
    PlcAddressError: "缺失加工数和目标数地址配置",
}
func GetMsg(errCode int) (errMsg string) {
service/device_plc.go
@@ -19,7 +19,7 @@
}
func (slf DevicePlcService) GetDevicePlc() (*model.DevicePlc, int) {
    DevicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First()
    devicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First()
    if err == gorm.ErrRecordNotFound {
        logx.Errorf("GetDevicePlc failed:%v", err)
        return &model.DevicePlc{
@@ -41,8 +41,11 @@
        logx.Errorf("GetDevicePlc failed:%v", err)
        return nil, ecode.DBErr
    }
    if len(devicePlc.Details) == 0 {
        return nil, ecode.PlcAddressError
    }
    return DevicePlc, ecode.OK
    return devicePlc, ecode.OK
}
func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) {