fix: 更新通道没保存过滤标记问题

This commit is contained in:
ydajiang
2025-10-31 17:58:47 +08:00
parent f351a10819
commit 3b4999f3d1

View File

@@ -308,6 +308,33 @@ func (d *Device) SaveChannels(list []*CatalogResponse) ([]*dao.ChannelModel, err
}
}
// 过滤通道
device, _ := dao.Device.QueryDevice(d.DeviceID)
var dropChannelType string
if device.DropChannelType != "" {
dropChannelType = strings.TrimSpace(device.DropChannelType)
} else {
dropChannelType = strings.TrimSpace(common.Config.GlobalDropChannelType)
}
if dropChannelType != "" {
var dropChannelTypes []int
for _, code := range strings.Split(dropChannelType, ",") {
if code != "" {
typeCode, _ := strconv.Atoi(code)
dropChannelTypes = append(dropChannelTypes, typeCode)
}
}
for _, channel := range channels {
for _, dropType := range dropChannelTypes {
if dropType == channel.TypeCode {
channel.DropMark = 1
}
}
}
}
err := dao.Channel.SaveChannels(channels)
if err != nil {
log.Sugar.Errorf("save channels failed, device: %s, err: %s", d.DeviceID, err.Error())