|
@@ -15,7 +15,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
// GetKplerDataByApi 获取开普勒数据
|
|
// GetKplerDataByApi 获取开普勒数据
|
|
-func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string) (indexes []*models.KplerIndexItem, apiQueryUrl string, terminalInfo *models.EdbTerminal, err error) {
|
|
|
|
|
|
+func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string, isRefresh bool) (indexes []*models.KplerIndexItem, apiQueryUrl string, terminalInfo *models.EdbTerminal, err error) {
|
|
terminal, e := GetApiTerminal(utils.DATA_SOURCE_KPLER, terminalCode)
|
|
terminal, e := GetApiTerminal(utils.DATA_SOURCE_KPLER, terminalCode)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = fmt.Errorf("获取开普勒终端配置失败, %v", e)
|
|
err = fmt.Errorf("获取开普勒终端配置失败, %v", e)
|
|
@@ -29,7 +29,7 @@ func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string) (in
|
|
|
|
|
|
// 走API
|
|
// 走API
|
|
if terminal.IsApi == 1 {
|
|
if terminal.IsApi == 1 {
|
|
- indexes, apiQueryUrl, err = getKplerDataByApi(params, terminal.ServerUrl)
|
|
|
|
|
|
+ indexes, apiQueryUrl, err = getKplerDataByApi(params, terminal.ServerUrl, isRefresh)
|
|
if err != nil {
|
|
if err != nil {
|
|
err = fmt.Errorf("获取开普勒指标数据失败, %v", err)
|
|
err = fmt.Errorf("获取开普勒指标数据失败, %v", err)
|
|
return
|
|
return
|
|
@@ -41,7 +41,7 @@ func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string) (in
|
|
}
|
|
}
|
|
|
|
|
|
// getEdbDataFromThsHfHttp API-获取高频指标数据
|
|
// getEdbDataFromThsHfHttp API-获取高频指标数据
|
|
-func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list []*models.KplerIndexItem, apiQueryUrl string, err error) {
|
|
|
|
|
|
+func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string, isRefresh bool) (list []*models.KplerIndexItem, apiQueryUrl string, err error) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
tips := fmt.Sprintf("开普勒指标API-getKplerDataByApi err: %v", err)
|
|
tips := fmt.Sprintf("开普勒指标API-getKplerDataByApi err: %v", err)
|
|
@@ -121,10 +121,10 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
|
|
for _, v := range existList {
|
|
for _, v := range existList {
|
|
existIndexCodeMap[v.IndexCode] = true
|
|
existIndexCodeMap[v.IndexCode] = true
|
|
}
|
|
}
|
|
- // 过滤已经存在的指标
|
|
|
|
|
|
+ // 过滤已经存在的指标, 如果是刷新指标,则无需过滤
|
|
list = make([]*models.KplerIndexItem, 0)
|
|
list = make([]*models.KplerIndexItem, 0)
|
|
for _, v := range indexes {
|
|
for _, v := range indexes {
|
|
- if _, ok := existIndexCodeMap[v.IndexCode]; !ok {
|
|
|
|
|
|
+ if _, ok := existIndexCodeMap[v.IndexCode]; !ok || isRefresh {
|
|
list = append(list, v)
|
|
list = append(list, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -182,6 +182,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
indexObj.IndexName = indexInfo.IndexName
|
|
indexObj.IndexName = indexInfo.IndexName
|
|
indexObj.Frequency = indexInfo.Frequency
|
|
indexObj.Frequency = indexInfo.Frequency
|
|
indexObj.ClassifyId = int(classifyId)
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
|
+ indexObj.ProductNames = req.ProductNames
|
|
indexObj.FromZoneId = fromZoneId
|
|
indexObj.FromZoneId = fromZoneId
|
|
indexObj.ToZoneId = toZoneId
|
|
indexObj.ToZoneId = toZoneId
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
@@ -221,7 +222,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
- indexObj.Granularity = req.Granularity
|
|
|
|
|
|
+ indexObj.Granularity = GetKplerGranularity(req.Granularity)
|
|
indexObj.Split = req.Split
|
|
indexObj.Split = req.Split
|
|
indexObj.Unit = req.Unit
|
|
indexObj.Unit = req.Unit
|
|
indexObj.ApiQueryUrl = apiQueryUrl
|
|
indexObj.ApiQueryUrl = apiQueryUrl
|
|
@@ -781,15 +782,15 @@ func getKplerFrequency(granularity string) (frequency string) {
|
|
|
|
|
|
func GetKplerGranularity(frequency string) (granularity string) {
|
|
func GetKplerGranularity(frequency string) (granularity string) {
|
|
switch frequency {
|
|
switch frequency {
|
|
- case "daily", "Daily":
|
|
|
|
|
|
+ case "daily", "Daily", "days":
|
|
return "days"
|
|
return "days"
|
|
- case "weekly", "Weekly":
|
|
|
|
|
|
+ case "weekly", "Weekly", "weeks":
|
|
return "weeks"
|
|
return "weeks"
|
|
- case "monthly", "Monthly":
|
|
|
|
|
|
+ case "monthly", "Monthly", "months":
|
|
return "months"
|
|
return "months"
|
|
- case "yearly", "Yearly":
|
|
|
|
|
|
+ case "yearly", "Yearly", "years":
|
|
return "years"
|
|
return "years"
|
|
- case "quarterly", "Quarters":
|
|
|
|
|
|
+ case "quarterly", "Quarters", "quarters":
|
|
return "quarters"
|
|
return "quarters"
|
|
}
|
|
}
|
|
return ""
|
|
return ""
|