|
@@ -15,7 +15,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
// GetKplerDataByApi 获取开普勒数据
|
|
// GetKplerDataByApi 获取开普勒数据
|
|
-func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string) (indexes []*models.KplerIndexItem, terminalInfo *models.EdbTerminal, err error) {
|
|
|
|
|
|
+func GetKplerDataByApi(params models.KplerSearchEdbReq, terminalCode string) (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, err = getKplerDataByApi(params, terminal.ServerUrl)
|
|
|
|
|
|
+ indexes, apiQueryUrl, err = getKplerDataByApi(params, terminal.ServerUrl)
|
|
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, err error) {
|
|
|
|
|
|
+func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (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)
|
|
@@ -127,10 +127,10 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
|
|
list = append(list, v)
|
|
list = append(list, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return list, nil
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
-func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSearchEdbReq, 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)
|
|
errMsgList := make([]string, 0)
|
|
defer func() {
|
|
defer func() {
|
|
if len(errMsgList) > 0 {
|
|
if len(errMsgList) > 0 {
|
|
@@ -168,7 +168,6 @@ 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.FromZoneName = req.FromZoneNames
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
@@ -176,6 +175,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
indexObj.Split = req.Split
|
|
indexObj.Split = req.Split
|
|
indexObj.Unit = req.Unit
|
|
indexObj.Unit = req.Unit
|
|
indexObj.Sort = maxSort
|
|
indexObj.Sort = maxSort
|
|
|
|
+ indexObj.ApiQueryUrl = ApiQueryUrl
|
|
indexObj.ModifyTime = time.Now()
|
|
indexObj.ModifyTime = time.Now()
|
|
indexObj.CreateTime = time.Now()
|
|
indexObj.CreateTime = time.Now()
|
|
indexObj.TerminalCode = terminalCode
|
|
indexObj.TerminalCode = terminalCode
|
|
@@ -208,6 +208,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
indexObj.Granularity = req.Granularity
|
|
indexObj.Granularity = req.Granularity
|
|
indexObj.Split = req.Split
|
|
indexObj.Split = req.Split
|
|
indexObj.Unit = req.Unit
|
|
indexObj.Unit = req.Unit
|
|
|
|
+ indexObj.ApiQueryUrl = ApiQueryUrl
|
|
indexObj.ModifyTime = time.Now()
|
|
indexObj.ModifyTime = time.Now()
|
|
|
|
|
|
//修改数据
|
|
//修改数据
|
|
@@ -838,21 +839,42 @@ func InitKplerZone() (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
// 批量插入区域表中
|
|
// 批量插入区域表中
|
|
|
|
+ zoneMap := make(map[int]*models.BaseFromKplerZone)
|
|
for _, v := range libResp.Data {
|
|
for _, v := range libResp.Data {
|
|
zoneObj := new(models.BaseFromKplerZone)
|
|
zoneObj := new(models.BaseFromKplerZone)
|
|
- zoneObj.ZoneName = v.AncestorName
|
|
|
|
- zoneObj.ZoneType = v.AncestorType
|
|
|
|
- zoneObj.AncestorId, _ = strconv.Atoi(v.AncestorId)
|
|
|
|
- zoneObj.AncestorType = v.AncestorType
|
|
|
|
- zoneObj.AncestorName = v.AncestorName
|
|
|
|
- zoneObj.DescendantId, _ = strconv.Atoi(v.DescendantId)
|
|
|
|
- zoneObj.DescendantName = v.DescendantName
|
|
|
|
- zoneObj.ModifyTime = time.Now()
|
|
|
|
- zoneObj.CreateTime = time.Now()
|
|
|
|
- _, err = zoneObj.Add()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("新增开普勒区域库失败", err)
|
|
|
|
- utils.FileLog.Info("新增开普勒区域库失败", err)
|
|
|
|
|
|
+ descendantId, _ := strconv.Atoi(v.DescendantId)
|
|
|
|
+ ancestorId, _ := strconv.Atoi(v.AncestorId)
|
|
|
|
+ if _, ok := zoneMap[descendantId]; !ok {
|
|
|
|
+ zoneObj.ZoneName = v.DescendantName
|
|
|
|
+ //zoneObj.ZoneType = v.DescendantType
|
|
|
|
+ zoneObj.AncestorId = ancestorId
|
|
|
|
+ zoneObj.AncestorType = v.AncestorType
|
|
|
|
+ zoneObj.AncestorName = v.AncestorName
|
|
|
|
+ zoneObj.DescendantId = descendantId
|
|
|
|
+ zoneObj.DescendantName = v.DescendantName
|
|
|
|
+ zoneObj.ModifyTime = time.Now()
|
|
|
|
+ zoneObj.CreateTime = time.Now()
|
|
|
|
+ _, err = zoneObj.Add()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("新增开普勒区域库失败", err)
|
|
|
|
+ utils.FileLog.Info("新增开普勒区域库失败", err)
|
|
|
|
+ }
|
|
|
|
+ zoneMap[descendantId] = zoneObj
|
|
|
|
+ if _, ok := zoneMap[ancestorId]; !ok {
|
|
|
|
+ zoneObj := new(models.BaseFromKplerZone)
|
|
|
|
+ zoneObj.ZoneName = v.AncestorName
|
|
|
|
+ zoneObj.ZoneType = v.AncestorType
|
|
|
|
+ zoneObj.DescendantId = ancestorId
|
|
|
|
+ zoneObj.DescendantName = v.AncestorName
|
|
|
|
+ zoneObj.ModifyTime = time.Now()
|
|
|
|
+ zoneObj.CreateTime = time.Now()
|
|
|
|
+ _, err = zoneObj.Add()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("新增开普勒区域库失败", err)
|
|
|
|
+ utils.FileLog.Info("新增开普勒区域库失败", err)
|
|
|
|
+ }
|
|
|
|
+ zoneMap[ancestorId] = zoneObj
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
return
|