fix
zhangqian
2023-10-19 cab6eea89a0d82710369604ecb51f1cdb122e433
service/device_plc.go
@@ -8,7 +8,7 @@
   "apsClient/pkg/structx"
   "encoding/json"
   "errors"
   "gorm.io/gorm"
   "github.com/jinzhu/gorm"
)
type DevicePlcService struct{}
@@ -21,7 +21,6 @@
   DevicePlc, err := model.NewDevicePlcSearch().SetOrder("id desc").First()
   if err == gorm.ErrRecordNotFound {
      return &model.DevicePlc{
         Id:         0,
         Brand:      "",
         Method:     "",
         Address:    "",
@@ -42,11 +41,11 @@
func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) {
   plcConfig, code := slf.GetDevicePlc()
   if code != ecode.OK || plcConfig.Id == 0 {
      return 0, errors.New("请先配置PLC")
   if code != ecode.OK || plcConfig.ID == 0 {
      return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!")
   }
   if len(plcConfig.Details) == 0 {
      return 0, errors.New("请先配置PLC")
      return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!")
   }
   return len(plcConfig.Details) / 2, nil
}