rdluck 3 лет назад
Родитель
Сommit
0ec1eda41c
4 измененных файлов с 10 добавлено и 7 удалено
  1. 1 0
      models/db.go
  2. 2 1
      services/data_manage/data_pb.go
  3. 5 5
      services/data_manage/edb_info.go
  4. 2 1
      utils/constants.go

+ 1 - 0
models/db.go

@@ -63,5 +63,6 @@ func init() {
 		new(company_approval.CompanyApproval),
 		new(data_manage.EdbDataWind),
 		new(data_manage.EdbDataThs),
+		new(data_manage.EdbDataPb),
 	)
 }

+ 2 - 1
services/data_manage/data_pb.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_task/models/data_manage"
 	"hongze/hongze_task/utils"
+	"net/url"
 	"rdluck_tools/http"
 	"time"
 )
@@ -23,7 +24,7 @@ func SyncEdbDataByPb(edbInfoId int64, edbCode, startDate, endDate string) (err e
 			fmt.Println("SyncEdbDataByPb Err:" + err.Error())
 		}
 	}()
-
+	edbCode=url.QueryEscape(edbCode)
 	pbUrl := utils.Hz_Data_PB_Url + `edbInfo/pb?EdbCode=%s&StartDate=%s&EndDate=%s`
 	pbUrl = fmt.Sprintf(pbUrl, edbCode, startDate, endDate)
 	utils.FileLog.Info("pbUrl:%s", pbUrl)

+ 5 - 5
services/data_manage/edb_info.go

@@ -84,7 +84,6 @@ func RefreshDataFromWind() (err error) {
 	return err
 }
 
-
 //刷新彭博数据
 func RefreshDataFromPb() (err error) {
 	defer func() {
@@ -103,13 +102,14 @@ func RefreshDataFromPb() (err error) {
 	}
 
 	for _, v := range items {
-		startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
-		endDate := time.Now().Format(utils.FormatDate)
+		startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDateUnSpace)
+		endDate := time.Now().Format(utils.FormatDateUnSpace)
+		fmt.Println(startDate, endDate)
 		err = SyncEdbDataByPb(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
 		if err != nil {
 			return errors.New("SyncEdbDataByPb:" + err.Error())
 		}
-		minDate, maxDate, err := data_manage.GetEdbDataThsMaxOrMinDate(v.EdbInfoId)
+		minDate, maxDate, err := data_manage.GetEdbDataPbMaxOrMinDate(v.EdbInfoId)
 		if err != nil {
 			return errors.New("GetEdbDataThsMaxOrMinDate:" + err.Error())
 		}
@@ -128,7 +128,7 @@ func CheckDataInterface() (err error) {
 	if err != nil {
 		go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 	}
-	result:=string(body)
+	result := string(body)
 	if result != "1" {
 		go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"检测数据接口:失败提醒", "CheckDataInterface ErrMsg:"+string(body), utils.EmailSendToUsers)
 	}

+ 2 - 1
utils/constants.go

@@ -8,6 +8,7 @@ const (
 const (
 	FormatTime            = "15:04:05"                //时间格式
 	FormatDate            = "2006-01-02"              //日期格式
+	FormatDateUnSpace     = "20060102"                //日期格式
 	FormatDateTime        = "2006-01-02 15:04:05"     //完整时间格式
 	HlbFormatDateTime     = "2006-01-02_15:04:05.999" //完整时间格式
 	FormatDateTimeUnSpace = "20060102150405"          //完整时间格式
@@ -72,4 +73,4 @@ const (
 const (
 	Hz_Data_Url    = "http://datawind.hzinsights.com:8040/" //同花顺,万得接口服务地址
 	Hz_Data_PB_Url = "http://datapb.hzinsights.com:8040/"   //彭博接口地址
-)
+)