|
@@ -41,9 +41,10 @@ type CurrClassify struct {
|
|
|
// @param cont context.Context
|
|
|
// @return err error
|
|
|
func SyncGnIndex(cont context.Context) (err error) {
|
|
|
- fmt.Println("开始同步指标")
|
|
|
+ fmt.Println("准备同步指标")
|
|
|
lockSyncGnIndex.Lock()
|
|
|
errMsgList := make([]string, 0)
|
|
|
+ fmt.Println("开始同步指标")
|
|
|
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -247,13 +248,20 @@ func syncGnIndex(currIndex, pageSize int, baseLastUpdateTimeStr string) (err err
|
|
|
// @return err
|
|
|
func handleIndex(index IndexInfo) (err error) {
|
|
|
// 处理分类(如果不存在就创建)
|
|
|
- _, _, thirdClassifyId, err := handleClassify(index)
|
|
|
+ oneClassifyId, twoClassifyId, thirdClassifyId, err := handleClassify(index)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ classifyId := thirdClassifyId
|
|
|
+ if classifyId <= 0 {
|
|
|
+ classifyId = twoClassifyId
|
|
|
+ }
|
|
|
+ if classifyId <= 0 {
|
|
|
+ classifyId = oneClassifyId
|
|
|
+ }
|
|
|
// 处理指标(如果不存在就创建)
|
|
|
- err = handleEdbInfo(index, thirdClassifyId)
|
|
|
+ err = handleEdbInfo(index, classifyId)
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -266,9 +274,9 @@ func handleIndex(index IndexInfo) (err error) {
|
|
|
// @return thirdClassifyId
|
|
|
// @return err
|
|
|
func handleClassify(index IndexInfo) (firstClassifyId, secondClassifyId, thirdClassifyId int64, err error) {
|
|
|
- firstClassifyName := strings.TrimSpace(index.ClassifyNameOne)
|
|
|
- secondClassifyName := strings.TrimSpace(index.ClassifyNameTwo)
|
|
|
- thirdClassifyName := strings.TrimSpace(index.ClassifyNameThree)
|
|
|
+ firstClassifyName := getClassifyName(index.ClassifyNameOne)
|
|
|
+ secondClassifyName := getClassifyName(index.ClassifyNameTwo)
|
|
|
+ thirdClassifyName := getClassifyName(index.ClassifyNameThree)
|
|
|
|
|
|
var oneLevel, twoLevel, threeLevel int64
|
|
|
oneLevel = 1
|
|
@@ -345,6 +353,10 @@ func handleClassify(index IndexInfo) (firstClassifyId, secondClassifyId, thirdCl
|
|
|
classifyName := secondClassifyName
|
|
|
level := twoLevel
|
|
|
|
|
|
+ if secondClassifyName == `` {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 获取层级下的父级分类map
|
|
|
currParentClassifyMap, ok := CurrLevelParentClassifyMap[level]
|
|
|
if !ok {
|
|
@@ -402,6 +414,10 @@ func handleClassify(index IndexInfo) (firstClassifyId, secondClassifyId, thirdCl
|
|
|
classifyName := thirdClassifyName
|
|
|
level := threeLevel
|
|
|
|
|
|
+ if thirdClassifyName == `` {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 获取层级下的父级分类map
|
|
|
currParentClassifyMap, ok := CurrLevelParentClassifyMap[level]
|
|
|
if !ok {
|
|
@@ -457,6 +473,23 @@ func handleClassify(index IndexInfo) (firstClassifyId, secondClassifyId, thirdCl
|
|
|
|
|
|
}
|
|
|
|
|
|
+func getClassifyName(classifyName string) string {
|
|
|
+ classifyName = strings.TrimSpace(classifyName)
|
|
|
+ if classifyName == `` {
|
|
|
+ return classifyName
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果不是未分类,那么就是处理掉带有序号的、
|
|
|
+ if classifyName != `未分类` {
|
|
|
+ classifyNameList := strings.Split(classifyName, `、`)
|
|
|
+ if len(classifyNameList) > 0 {
|
|
|
+ classifyName = classifyNameList[len(classifyNameList)-1]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return classifyName
|
|
|
+}
|
|
|
+
|
|
|
// handleEdbInfo
|
|
|
// @Description: 处理指标
|
|
|
// @param index
|