|
@@ -13,7 +13,7 @@ import (
|
|
|
|
|
|
// InitMysteelChemicalIndex
|
|
|
// 初始化钢联化工指标数据(添加到数据源)
|
|
|
-func InitMysteelChemicalIndex(filePath string) {
|
|
|
+func InitMysteelChemicalIndex(filePath string, isApi bool) {
|
|
|
var err error
|
|
|
|
|
|
defer func() {
|
|
@@ -31,6 +31,7 @@ func InitMysteelChemicalIndex(filePath string) {
|
|
|
dir := filepath.Dir(path)
|
|
|
fmt.Println("dir:" + dir)
|
|
|
dataPath := dir + filePath
|
|
|
+ //dataPath = "./docs/gl_api_test.xlsx"
|
|
|
fmt.Println("dataPath:" + dataPath)
|
|
|
f, err := excelize.OpenFile(dataPath)
|
|
|
if err != nil {
|
|
@@ -50,6 +51,7 @@ func InitMysteelChemicalIndex(filePath string) {
|
|
|
}
|
|
|
classifyMethod := "mysteel_chemical/mysteel_classify/get_or_add"
|
|
|
indexMethod := "mysteel_chemical/add/mysteel/index"
|
|
|
+ apiHandleMethod := "mysteel_chemical/handle/api/mysteel/index"
|
|
|
fmt.Println("rows len:", len(rows))
|
|
|
for rk, row := range rows {
|
|
|
if rk > 0 {
|
|
@@ -184,6 +186,39 @@ func InitMysteelChemicalIndex(filePath string) {
|
|
|
}
|
|
|
}
|
|
|
fmt.Println("add index success:" + indexCode)
|
|
|
+
|
|
|
+ // 请求API初始化数据
|
|
|
+ if !isApi {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ fmt.Println("请求API刷新数据")
|
|
|
+
|
|
|
+ handleReq := make(map[string][]map[string]interface{})
|
|
|
+ handleMap := make(map[string]interface{})
|
|
|
+ handleMap["IndexCode"] = indexCode
|
|
|
+ handleReq["List"] = append(handleReq["List"], handleMap)
|
|
|
+ res, e := PostHandleMysteelIndexEdbLib(handleReq, apiHandleMethod)
|
|
|
+ if e != nil {
|
|
|
+ tips := fmt.Sprintf("PostHandleMysteelIndexEdbLib写入指标失败, code: %s, err: %v, result: %s", indexCode, e, string(res))
|
|
|
+ fmt.Println(tips)
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ handleResp := new(models.EdbInfoResp)
|
|
|
+ if e = json.Unmarshal(res, &handleResp); e != nil {
|
|
|
+ tips := fmt.Sprintf("PostHandleMysteelIndexEdbLib解析resp失败, code: %s, err: %v, result: %s", indexCode, e, string(res))
|
|
|
+ fmt.Println(tips)
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if handleResp.Ret != 200 {
|
|
|
+ tips := fmt.Sprintf("PostHandleMysteelIndexEdbLib写入指标失败, code: %s, Msg: %s, ErrMsg: %s", indexCode, handleResp.Msg, handleResp.ErrMsg)
|
|
|
+ fmt.Println(tips)
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("handle index success:" + indexCode)
|
|
|
} else {
|
|
|
fmt.Println("data is empty")
|
|
|
fmt.Println(classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source)
|