Browse Source

分析来源

wangshan 2 months ago
parent
commit
bfad45ac32
1 changed files with 27 additions and 23 deletions
  1. 27 23
      marketanalysis/marketanalysis.go

+ 27 - 23
marketanalysis/marketanalysis.go

@@ -147,6 +147,7 @@ type AnalysisEntity struct {
 	Source        string
 	Mgo           *mongodb.MongodbSim
 	MySql         *mysql.Mysql
+	Rs            int //分析来源
 }
 
 type projectInfo struct {
@@ -178,37 +179,40 @@ func (a *AnalysisEntity) ForMatData() error {
 		return fmt.Errorf("请选择关键词组")
 	}
 	var flag bool
-	// 判断关键词是不是为空
-	for i := 0; i < len(a.FormatParam.KeysItems); i++ {
-		items := a.FormatParam.KeysItems[i]
-		for j := 0; j < len(items.A_Key); j++ {
-			AKey := items.A_Key[j]
-			if len(AKey.Keyword) > 0 {
-				var keys []string
-				for _, kv := range AKey.Keyword {
-					if strings.TrimSpace(kv) != "" {
-						keys = append(keys, kv)
+	if a.Rs == 0 { //普通分析(非pdf)
+		// 判断关键词是不是为空
+		for i := 0; i < len(a.FormatParam.KeysItems); i++ {
+			items := a.FormatParam.KeysItems[i]
+			for j := 0; j < len(items.A_Key); j++ {
+				AKey := items.A_Key[j]
+				if len(AKey.Keyword) > 0 {
+					var keys []string
+					for _, kv := range AKey.Keyword {
+						if strings.TrimSpace(kv) != "" {
+							keys = append(keys, kv)
+						}
+					}
+					AKey.Keyword = []string{}
+					if len(keys) > 0 {
+						AKey.Keyword = keys
+						flag = true
+						break
 					}
 				}
-				AKey.Keyword = []string{}
-				if len(keys) > 0 {
-					AKey.Keyword = keys
-					flag = true
-					break
+				if len(AKey.Keyword) == 0 {
+					items.A_Key = append(items.A_Key[:j], items.A_Key[j+1:]...)
 				}
 			}
-			if len(AKey.Keyword) == 0 {
-				items.A_Key = append(items.A_Key[:j], items.A_Key[j+1:]...)
+			if flag {
+				break
 			}
+			a.FormatParam.KeysItems = append(a.FormatParam.KeysItems[:i], a.FormatParam.KeysItems[i+1:]...)
 		}
-		if flag {
-			break
+		if !flag {
+			return fmt.Errorf("请选择关键词组")
 		}
-		a.FormatParam.KeysItems = append(a.FormatParam.KeysItems[:i], a.FormatParam.KeysItems[i+1:]...)
-	}
-	if !flag {
-		return fmt.Errorf("请选择关键词组")
 	}
+
 	//格式化时间段
 	if timeArr := strings.Split(a.BaseParam.RangeTime, "-"); len(timeArr) == 2 {
 		a.FormatParam.STime = common.Int64All(timeArr[0])