Prechádzať zdrojové kódy

fix:彭博数据刷新时,指标code需要重新编码

Roc 3 rokov pred
rodič
commit
93ed426020
2 zmenil súbory, kde vykonal 9 pridanie a 6 odobranie
  1. 5 1
      controllers/base_from_pb.go
  2. 4 5
      services/base_from_pb.go

+ 5 - 1
controllers/base_from_pb.go

@@ -97,7 +97,11 @@ func (this *PbController) Refresh() {
 	cacheKey = utils.CACHE_EDB_DATA_REFRESH + strconv.Itoa(source) + "_" + req.EdbCode
 	if !utils.Rc.IsExist(cacheKey) {
 		utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
-		dataItem, err := services.GetEdbDataFromPb(req.EdbCode, req.StartDate, utils.BASE_END_DATE_UnSpace)
+
+		//开始日期格式化
+		startDateTime, _ := time.Parse(utils.FormatDate, req.StartDate)
+
+		dataItem, err := services.GetEdbDataFromPb(req.EdbCode, startDateTime.Format(utils.FormatDateUnSpace), utils.BASE_END_DATE_UnSpace)
 		if err != nil {
 			br.Msg = "获取指标信息失败!"
 			br.ErrMsg = "获取指标信息失败 GetEdbDataFromPb,Err:" + err.Error()

+ 4 - 5
services/base_from_pb.go

@@ -3,10 +3,9 @@ package services
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/http"
 	"hongze/hongze_edb_lib/utils"
 	"net/url"
-
-	"github.com/rdlucklib/rdluck_tools/http"
 )
 
 type EdbDataFromPb struct {
@@ -18,20 +17,20 @@ type EdbDataFromPb struct {
 
 // GetEdbDataFromPb 获取Pb数据
 func GetEdbDataFromPb(edbCode, startDate, endDate string) (item *EdbDataFromPb, err error) {
-	edbCode = url.QueryEscape(edbCode)
+	//edbCode = url.QueryEscape(edbCode)
 	bpUrl := utils.Hz_Pb_Data_Url + `edbInfo/pb?EdbCode=%s&StartDate=%s&EndDate=%s`
 	bpUrl = fmt.Sprintf(bpUrl, edbCode, startDate, endDate)
 	utils.FileLog.Info("bpUrl:" + bpUrl)
 	body, err := http.Get(bpUrl)
 	if err != nil {
-		utils.FileLog.Info("GetEdbDataByPb Err:"+err.Error())
+		utils.FileLog.Info("GetEdbDataByPb Err:" + err.Error())
 		return
 	}
 	utils.FileLog.Info("GetEdbDataByPb result:" + string(body))
 	item = new(EdbDataFromPb)
 	err = json.Unmarshal(body, &item)
 	if err != nil {
-		utils.FileLog.Info("GetEdbDataByPb Unmarshal Err:"+err.Error())
+		utils.FileLog.Info("GetEdbDataByPb Unmarshal Err:" + err.Error())
 		return
 	}
 	edbCode, _ = url.QueryUnescape(edbCode)