فهرست منبع

Merge branch 'feature/eta2.6.5_kpler' into debug

xyxie 1 هفته پیش
والد
کامیت
e66df2892f
1فایلهای تغییر یافته به همراه21 افزوده شده و 6 حذف شده
  1. 21 6
      services/base_from_kpler.go

+ 21 - 6
services/base_from_kpler.go

@@ -54,14 +54,14 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string) (list
 	fromZoneNamesStr := params.FromZoneNames
 	toZoneNamesStr := params.ToZoneNames
 	
-
+	granularity := GetKplerGranularity(params.Granularity)
 	libreq := new(models.KplerFlowDataLibReq)
 	libreq.Products = productNamesStr
 	libreq.FromZones = fromZoneNamesStr
 	libreq.ToZones = toZoneNamesStr
 	libreq.Split = params.Split
 	libreq.FlowDirection = params.FlowDirection
-	libreq.Granularity = params.Granularity
+	libreq.Granularity = granularity
 	libreq.Unit = params.Unit
 	libreq.WithIntraRegion = "true"
 	libreq.WithForecast = "true"
@@ -171,7 +171,7 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
 			indexObj.FromZoneName = req.FromZoneNames
 			indexObj.ToZoneName = req.ToZoneNames
 			indexObj.FlowDirection = req.FlowDirection
-			indexObj.Granularity = req.Granularity
+			indexObj.Granularity = GetKplerGranularity(req.Granularity)
 			indexObj.Split = req.Split
 			indexObj.Unit = req.Unit
 			indexObj.Sort = maxSort
@@ -751,18 +751,33 @@ func HttpPost(url, postData string, params ...string) ([]byte, error) {
 
 func getKplerFrequency(granularity string) (frequency string) {
 	switch granularity {
-	case "daily", "day":
+	case "daily", "days":
 		return "日度"
 	case "weekly", "weeks":
 		return "周度"
-	case "monthly", "month":
+	case "monthly", "months":
 		return "月度"
-	case "yearly", "year":
+	case "yearly", "years":
 		return "年度"
 	}
 	return ""
 }
 
+func GetKplerGranularity(frequency string) (granularity string) {
+	switch frequency {
+	case "daily", "Daily":
+		return "days"
+	case "weekly", "Weekly":
+		return "weeks"
+	case "monthly", "Monthly":
+		return "months"
+	case "yearly", "Yearly":
+		return "years"
+	case "quarterly", "Quarters":
+		return "quarters"
+	}
+	return ""
+}
 
 func InitKplerProduct ()(err error) {
 	libUrl := "http://127.0.0.1:8915"