|
@@ -79,7 +79,7 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
|
|
|
return
|
|
|
}
|
|
|
indexes := make([]*models.KplerIndexItem, 0)
|
|
|
- if len(apiResp.Data) == 0 {
|
|
|
+ if len(apiResp.Data.List) == 0 {
|
|
|
utils.FileLog.Info("开普勒指标API-无数据")
|
|
|
return
|
|
|
}
|
|
@@ -92,8 +92,9 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
|
|
|
prefixIndexCode := fmt.Sprintf("k%s%s%s%s", fromZoneNamesStr, flowDirection, toZoneNamesStr, productNamesStr)
|
|
|
// 获取首字母
|
|
|
lastIndexCode := strings.ToUpper(params.Granularity[:1])
|
|
|
+ apiQueryUrl = apiResp.Data.ApiQueryUrl
|
|
|
// Tables中的每一个对应一个证券代码
|
|
|
- for _, v := range apiResp.Data {
|
|
|
+ for _, v := range apiResp.Data.List {
|
|
|
index := new(models.KplerIndexItem)
|
|
|
indexName := ""
|
|
|
indexCode := ""
|
|
@@ -130,7 +131,7 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSearchEdbReq, ApiQueryUrl string, classifyId int, terminalCode string) (err error) {
|
|
|
+func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSearchEdbReq, apiQueryUrl string, classifyId int, terminalCode string) (err error) {
|
|
|
errMsgList := make([]string, 0)
|
|
|
defer func() {
|
|
|
if len(errMsgList) > 0 {
|
|
@@ -162,12 +163,27 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
} else {
|
|
|
isAdd = 1
|
|
|
}
|
|
|
+ fromZoneId := 0
|
|
|
+ toZoneId := 0
|
|
|
+
|
|
|
+ if len(req.FromZoneIds) > 0 {
|
|
|
+ for _, v := range req.FromZoneIds {
|
|
|
+ fromZoneId = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(req.ToZoneIds) > 0 {
|
|
|
+ for _, v := range req.ToZoneIds {
|
|
|
+ toZoneId = v
|
|
|
+ }
|
|
|
+ }
|
|
|
// 批量新增指标
|
|
|
if isAdd == 1 {
|
|
|
indexObj.IndexCode = indexInfo.IndexCode
|
|
|
indexObj.IndexName = indexInfo.IndexName
|
|
|
indexObj.Frequency = indexInfo.Frequency
|
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
+ indexObj.FromZoneId = fromZoneId
|
|
|
+ indexObj.ToZoneId = toZoneId
|
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
@@ -175,7 +191,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
indexObj.Split = req.Split
|
|
|
indexObj.Unit = req.Unit
|
|
|
indexObj.Sort = maxSort
|
|
|
- indexObj.ApiQueryUrl = ApiQueryUrl
|
|
|
+ indexObj.ApiQueryUrl = apiQueryUrl
|
|
|
indexObj.ModifyTime = time.Now()
|
|
|
indexObj.CreateTime = time.Now()
|
|
|
indexObj.TerminalCode = terminalCode
|
|
@@ -208,7 +224,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
indexObj.Granularity = req.Granularity
|
|
|
indexObj.Split = req.Split
|
|
|
indexObj.Unit = req.Unit
|
|
|
- indexObj.ApiQueryUrl = ApiQueryUrl
|
|
|
+ indexObj.ApiQueryUrl = apiQueryUrl
|
|
|
indexObj.ModifyTime = time.Now()
|
|
|
|
|
|
//修改数据
|
|
@@ -223,7 +239,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
updateColsArr = append(updateColsArr, "split")
|
|
|
updateColsArr = append(updateColsArr, "frequency")
|
|
|
updateColsArr = append(updateColsArr, "modify_time")
|
|
|
-
|
|
|
+ updateColsArr = append(updateColsArr, "api_query_url")
|
|
|
e := indexObj.Update(updateColsArr)
|
|
|
if e != nil {
|
|
|
fmt.Println("Index Update Err:" + e.Error())
|
|
@@ -751,13 +767,13 @@ func HttpPost(url, postData string, params ...string) ([]byte, error) {
|
|
|
|
|
|
func getKplerFrequency(granularity string) (frequency string) {
|
|
|
switch granularity {
|
|
|
- case "daily", "days":
|
|
|
+ case "daily", "Daily", "days":
|
|
|
return "日度"
|
|
|
- case "weekly", "weeks":
|
|
|
+ case "weekly", "Weekly", "weeks":
|
|
|
return "周度"
|
|
|
- case "monthly", "months":
|
|
|
+ case "monthly", "Monthly", "months":
|
|
|
return "月度"
|
|
|
- case "yearly", "years":
|
|
|
+ case "yearly", "Yearly", "years":
|
|
|
return "年度"
|
|
|
}
|
|
|
return ""
|