123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package services
- import (
- "fmt"
- )
- func Task() {
- fmt.Println("task start")
- //手工数据表格导入后的指标库刷新
- // go ImportManualDataRefresh()
- // // 指标刷新
- // go data.HandleEdbRefreshQueue()
- // // 进行指标替换操作
- // go DealReplaceEdbCache()
- // 修复分类LevelPath
- //FixClassifyLevelPath()
- fmt.Println("task end")
- }
- // // ImportManualDataRefresh 导入手工数据后的刷新
- // func ImportManualDataRefresh() {
- // defer func() {
- // if err := recover(); err != nil {
- // fmt.Println("[ImportManualDataRefresh]", err)
- // }
- // }()
- // for {
- // utils.Rc.Brpop(utils.CACHE_IMPORT_MANUAL_DATA, func(b []byte) {
- // edbCode := string(b)
- // edbCode = strings.TrimPrefix(edbCode, `"`)
- // edbCode = strings.TrimSuffix(edbCode, `"`)
- // data.RefreshManualData(edbCode)
- // })
- // }
- // }
- // func FixClassifyLevelPath() {
- // var err error
- // defer func() {
- // if err != nil {
- // fmt.Println(err)
- // }
- // }()
- // classifyOb := new(models.Classify)
- // classifies, e := classifyOb.GetItemsByCondition("", []interface{}{}, []string{}, "")
- // if e != nil {
- // err = fmt.Errorf("获取分类列表失败, %v", e)
- // return
- // }
- // fmt.Println("开始修复")
- // // 先更新所有一级分类
- // for _, v := range classifies {
- // if v.ParentId > 0 {
- // continue
- // }
- // v.LevelPath = strconv.Itoa(v.Id)
- // if e = v.UpdateClassify([]string{"LevelPath"}); e != nil {
- // err = fmt.Errorf("更新LevelPath失败, ID: %d", v.Id)
- // return
- // }
- // }
- // // 再更新二级
- // parentMap := make(map[int]string)
- // for _, v := range classifies {
- // if v.Level != 2 {
- // continue
- // }
- // v.LevelPath = fmt.Sprintf("%d,%d", v.ParentId, v.Id)
- // if e = v.UpdateClassify([]string{"LevelPath"}); e != nil {
- // err = fmt.Errorf("更新二级LevelPath失败, ID: %d", v.Id)
- // return
- // }
- // parentMap[v.Id] = v.LevelPath
- // }
- // // 再更新三级,没四级了
- // for _, v := range classifies {
- // if v.Level != 3 {
- // continue
- // }
- // str := parentMap[v.ParentId]
- // if str == "" {
- // err = fmt.Errorf("二级LevelPath为空, ID: %d", v.ParentId)
- // return
- // }
- // v.LevelPath = fmt.Sprintf("%s,%d", str, v.Id)
- // if e = v.UpdateClassify([]string{"LevelPath"}); e != nil {
- // err = fmt.Errorf("更新三级LevelPath失败, ID: %d", v.Id)
- // return
- // }
- // }
- // fmt.Println("修复成功")
- // }
|