Roc 1 年之前
父节点
当前提交
006c63f0bf
共有 3 个文件被更改,包括 28 次插入10 次删除
  1. 2 0
      .gitignore
  2. 22 9
      services/init_base_index.go
  3. 4 1
      services/task.go

+ 2 - 0
.gitignore

@@ -4,3 +4,5 @@
 /binlog
 /conf
 /*.exe
+/main
+/.DS_Store

+ 22 - 9
services/init_base_index.go

@@ -11,7 +11,7 @@ import (
 	"strings"
 )
 
-// 初始化基础指标数据
+// InitBaseIndexData 初始化基础指标数据
 func InitBaseIndexData() {
 	var err error
 
@@ -148,8 +148,14 @@ func InitBaseIndexData() {
 					return
 				}
 				method = "edb_info/add"
+				sourceId, ok := IndexSourceMap[source]
+				if !ok {
+					fmt.Println("source is not defined")
+					fmt.Println(classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source)
+					continue
+				}
 				indexMap := make(map[string]interface{})
-				indexMap["Source"] = IndexSourceMap[source]
+				indexMap["Source"] = sourceId
 				indexMap["EdbCode"] = indexCode
 				indexMap["EdbName"] = indexName
 				indexMap["Frequency"] = frequency
@@ -180,14 +186,21 @@ func InitBaseIndexData() {
 				fmt.Println("add index success:" + indexCode)
 
 				//刷新指标
-				if source == "wind" {
-					method = "wind/refresh"
+				{
+					switch source {
+					case "wind":
+						method = "wind/refresh"
+					case "ths", "同花顺":
+						method = "ths/refresh"
+					}
+					if method != `` {
+						refreshMap := make(map[string]interface{})
+						refreshMap["EdbInfoId"] = indexResp.Data.EdbInfoId
+						refreshMap["EdbCode"] = indexCode
+						refreshMap["StartDate"] = "1990-01-01"
+						PostEdbLib(refreshMap, method)
+					}
 				}
-				refreshMap := make(map[string]interface{})
-				refreshMap["EdbInfoId"] = indexResp.Data.EdbInfoId
-				refreshMap["EdbCode"] = indexCode
-				refreshMap["StartDate"] = "1990-01-01"
-				PostEdbLib(refreshMap, method)
 			} else {
 				fmt.Println("data is empty")
 				fmt.Println(classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source)

+ 4 - 1
services/task.go

@@ -20,13 +20,16 @@ func Task() {
 
 	IndexSourceMap = make(map[string]int)
 	IndexSourceMap["ths"] = utils.DATA_SOURCE_THS
+	IndexSourceMap["同花顺"] = utils.DATA_SOURCE_THS
 	IndexSourceMap["wind"] = utils.DATA_SOURCE_WIND
 	IndexSourceMap["钢联"] = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
 
 	time.Sleep(3 * time.Second)
 
 	fmt.Println("start InitCalculateIndex")
-	InitBaseIndexDataFromMysteel()
+	//InitBaseIndexDataFromMysteel()
+	InitMysteelIndex()
+	//InitBaseIndexData()
 	fmt.Println("end InitCalculateIndex")
 
 	fmt.Println("task end")