package crontab import ( "kpt-pasture/config" "kpt-pasture/model" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" "gitee.com/xuyiping_admin/pkg/xerr" ) func (e *Entry) NeckRingData() error { cfg := config.Options() limit := cfg.NeckRingLimit if limit <= 0 { limit = 10000 } neckRingList := make([]*model.NeckRingOriginalData, 0) if err := e.DB.Model(new(model.NeckRingOriginalData)). Where("is_show = ?", pasturePb.IsShow_No). Order("id asc").Limit(10000).Find(&neckRingList).Error; err != nil { return xerr.WithStack(err) } if len(neckRingList) <= 0 { return nil } neckRingIds := make([]int64, len(neckRingList)) // 更新已处理过的id defer func() { if len(neckRingIds) > 0 { e.DB.Model(new(model.NeckRingOriginalData)). Where("id IN ?", neckRingIds). Update("is_show", pasturePb.IsShow_Ok) } }() for i, v := range neckRingList { neckRingIds[i] = v.Id if v.Imei == "" { continue } } return nil } func (e *Entry) NeckRingOriginalDataMerge() { }