|
@@ -12,7 +12,8 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- JiaYueSourceMap map[string]int
|
|
|
+ JiaYueSourceMap map[string]int
|
|
|
+ JiaYueFrequencyMap map[string]string
|
|
|
)
|
|
|
|
|
|
func init() {
|
|
@@ -30,6 +31,26 @@ func init() {
|
|
|
JiaYueSourceMap["wind_p"] = 1005
|
|
|
JiaYueSourceMap["wind_stop"] = 1005
|
|
|
JiaYueSourceMap["wind_tmp"] = 1005
|
|
|
+
|
|
|
+ JiaYueFrequencyMap = map[string]string{
|
|
|
+ "日": "日度",
|
|
|
+ "周": "周度",
|
|
|
+ "旬": "旬度",
|
|
|
+ "半月": "旬度",
|
|
|
+ "月": "月度",
|
|
|
+ "季": "季度",
|
|
|
+ "半年": "半年度",
|
|
|
+ "年": "年度",
|
|
|
+ "日度": "日度",
|
|
|
+ "周度": "周度",
|
|
|
+ "旬度": "旬度",
|
|
|
+ "月度": "月度",
|
|
|
+ "季度": "季度",
|
|
|
+ "半年度": "半年度",
|
|
|
+ "年度": "年度",
|
|
|
+ }
|
|
|
+ fmt.Println(JiaYueSourceMap)
|
|
|
+ fmt.Println(JiaYueFrequencyMap)
|
|
|
}
|
|
|
|
|
|
// InitJiaYueIndexData 初始化基础指标数据
|
|
@@ -52,7 +73,7 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
dir := filepath.Dir(path)
|
|
|
dataPath = dir + dataPath
|
|
|
fmt.Println("dataPath:" + dataPath)
|
|
|
- //dataPath := dir + "/docs/东吴ETA同花顺指标20230925.xlsx"
|
|
|
+ //dataPath = "E:\\GoProjects\\src\\eta\\eta_data_init\\docs\\ttt.xlsx"
|
|
|
f, e := excelize.OpenFile(dataPath)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("open file err: %s", e.Error())
|
|
@@ -85,6 +106,9 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
Frequency string
|
|
|
SourceType string
|
|
|
}
|
|
|
+
|
|
|
+ totalIndex := 0
|
|
|
+ repeatCodes := make(map[string]int, 0)
|
|
|
for rk, row := range rows {
|
|
|
if rk <= 0 {
|
|
|
continue
|
|
@@ -176,21 +200,21 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
classifySecondMap["ParentId"] = firstId
|
|
|
classifySecondMap["Level"] = 1
|
|
|
classifySecondMap["ClassifyType"] = 0
|
|
|
- result, e = PostEdbLib(classifySecondMap, method)
|
|
|
+ res2, e := PostEdbLib(classifySecondMap, method)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("ClassifySecond PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- if err = json.Unmarshal(result, &resp); err != nil {
|
|
|
+ resp2 := new(models.ClassifyResp)
|
|
|
+ if err = json.Unmarshal(res2, &resp2); err != nil {
|
|
|
err = fmt.Errorf("ClassifySecond json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Ret != 200 {
|
|
|
- err = fmt.Errorf("ClassifySecond resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ if resp2.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySecond resp msg: %s; errMsg: %s", resp2.Msg, resp2.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- secondId = resp.Data.ClassifyId
|
|
|
+ secondId = resp2.Data.ClassifyId
|
|
|
lastId = secondId
|
|
|
}
|
|
|
|
|
@@ -201,21 +225,21 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
classifyThirdMap["ParentId"] = secondId
|
|
|
classifyThirdMap["Level"] = 2
|
|
|
classifyThirdMap["ClassifyType"] = 0
|
|
|
- result, e = PostEdbLib(classifyThirdMap, method)
|
|
|
+ res3, e := PostEdbLib(classifyThirdMap, method)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("ClassifyThird PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- if err = json.Unmarshal(result, &resp); err != nil {
|
|
|
+ resp3 := new(models.ClassifyResp)
|
|
|
+ if err = json.Unmarshal(res3, &resp3); err != nil {
|
|
|
err = fmt.Errorf("ClassifyThird json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Ret != 200 {
|
|
|
- err = fmt.Errorf("ClassifyThird resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ if resp3.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyThird resp msg: %s; errMsg: %s", resp3.Msg, resp3.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- thirdId = resp.Data.ClassifyId
|
|
|
+ thirdId = resp3.Data.ClassifyId
|
|
|
lastId = thirdId
|
|
|
}
|
|
|
|
|
@@ -226,21 +250,21 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
classifyFourthMap["ParentId"] = thirdId
|
|
|
classifyFourthMap["Level"] = 3
|
|
|
classifyFourthMap["ClassifyType"] = 0
|
|
|
- result, e = PostEdbLib(classifyFourthMap, method)
|
|
|
+ res4, e := PostEdbLib(classifyFourthMap, method)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("ClassifyFourth PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- if err = json.Unmarshal(result, &resp); err != nil {
|
|
|
+ resp4 := new(models.ClassifyResp)
|
|
|
+ if err = json.Unmarshal(res4, &resp4); err != nil {
|
|
|
err = fmt.Errorf("ClassifyFourth json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Ret != 200 {
|
|
|
- err = fmt.Errorf("ClassifyFourth resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ if resp4.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFourth resp msg: %s; errMsg: %s", resp4.Msg, resp4.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- fourthId = resp.Data.ClassifyId
|
|
|
+ fourthId = resp4.Data.ClassifyId
|
|
|
lastId = fourthId
|
|
|
}
|
|
|
|
|
@@ -251,21 +275,21 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
classifyFifthMap["ParentId"] = fourthId
|
|
|
classifyFifthMap["Level"] = 4
|
|
|
classifyFifthMap["ClassifyType"] = 0
|
|
|
- result, e = PostEdbLib(classifyFifthMap, method)
|
|
|
+ res5, e := PostEdbLib(classifyFifthMap, method)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("ClassifyFifth PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- if err = json.Unmarshal(result, &resp); err != nil {
|
|
|
+ resp5 := new(models.ClassifyResp)
|
|
|
+ if err = json.Unmarshal(res5, &resp5); err != nil {
|
|
|
err = fmt.Errorf("ClassifyFifth json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Ret != 200 {
|
|
|
- err = fmt.Errorf("ClassifyFifth resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ if resp5.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFifth resp msg: %s; errMsg: %s", resp5.Msg, resp5.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- fifthId = resp.Data.ClassifyId
|
|
|
+ fifthId = resp5.Data.ClassifyId
|
|
|
lastId = fifthId
|
|
|
}
|
|
|
|
|
@@ -276,21 +300,21 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
classifySixthMap["ParentId"] = fifthId
|
|
|
classifySixthMap["Level"] = 5
|
|
|
classifySixthMap["ClassifyType"] = 0
|
|
|
- result, e = PostEdbLib(classifySixthMap, method)
|
|
|
+ res6, e := PostEdbLib(classifySixthMap, method)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("ClassifySixth PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- if err = json.Unmarshal(result, &resp); err != nil {
|
|
|
+ resp6 := new(models.ClassifyResp)
|
|
|
+ if err = json.Unmarshal(res6, &resp6); err != nil {
|
|
|
err = fmt.Errorf("ClassifySixth json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if resp.Ret != 200 {
|
|
|
- err = fmt.Errorf("ClassifySixth resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ if resp6.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySixth resp msg: %s; errMsg: %s", resp6.Msg, resp6.ErrMsg)
|
|
|
return
|
|
|
}
|
|
|
- lastId = resp.Data.ClassifyId
|
|
|
+ lastId = resp6.Data.ClassifyId
|
|
|
}
|
|
|
|
|
|
// 新增指标
|
|
@@ -299,17 +323,17 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
indexMap["Source"] = sourceId
|
|
|
indexMap["EdbCode"] = edbCode
|
|
|
indexMap["EdbName"] = rowData.IndexName
|
|
|
- indexMap["Frequency"] = rowData.Frequency
|
|
|
+ indexMap["Frequency"] = JiaYueFrequencyMap[rowData.Frequency]
|
|
|
indexMap["Unit"] = rowData.Unit
|
|
|
indexMap["ClassifyId"] = lastId
|
|
|
- result, e = PostEdbLib(indexMap, method)
|
|
|
+ indexRes, e := PostEdbLib(indexMap, method)
|
|
|
if e != nil {
|
|
|
- err = fmt.Errorf("edb add PostEdbLib err: %s; result: %s", e.Error(), string(result))
|
|
|
+ err = fmt.Errorf("edb add PostEdbLib err: %s; result: %s", e.Error(), string(indexRes))
|
|
|
return
|
|
|
}
|
|
|
indexResp := new(models.EdbInfoResp)
|
|
|
- if e = json.Unmarshal(result, &indexResp); e != nil {
|
|
|
- err = fmt.Errorf("edb add unmarshal err: %s; result: %s", e.Error(), string(result))
|
|
|
+ if e = json.Unmarshal(indexRes, &indexResp); e != nil {
|
|
|
+ err = fmt.Errorf("edb add unmarshal err: %s; result: %s", e.Error(), string(indexRes))
|
|
|
return
|
|
|
}
|
|
|
if indexResp.Ret != 200 {
|
|
@@ -321,6 +345,7 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
}
|
|
|
}
|
|
|
fmt.Println("edb add success:" + edbCode)
|
|
|
+ repeatCodes[indexResp.Data.EdbCode] += 1
|
|
|
|
|
|
// 刷新指标
|
|
|
method = "jiayue_index/refresh"
|
|
@@ -333,5 +358,15 @@ func InitJiaYueIndexData(dataPath string) {
|
|
|
if e != nil {
|
|
|
utils.FileLog.Info("edb refresh err: %s; result: %s; IndexCode: %s", e.Error(), string(refreshRes), edbCode)
|
|
|
}
|
|
|
+ totalIndex += 1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 打印重复编码的指标
|
|
|
+ repeatCodeArr := make([]string, 0)
|
|
|
+ for k, v := range repeatCodes {
|
|
|
+ if v > 1 {
|
|
|
+ repeatCodeArr = append(repeatCodeArr, k)
|
|
|
+ }
|
|
|
}
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("初始化指标总数: %d, 重复编码的指标数: %d, 重复编码: %s", totalIndex, len(repeatCodeArr), strings.Join(repeatCodeArr, ",")))
|
|
|
}
|