Browse Source

新增数据刷新点

hongze 3 years ago
parent
commit
aebac4d25a
2 changed files with 34 additions and 12 deletions
  1. 30 6
      services/data_manage/edb_info.go
  2. 4 6
      services/task.go

+ 30 - 6
services/data_manage/edb_info.go

@@ -27,9 +27,15 @@ func RefreshDataFromThs() (err error) {
 		return errors.New("GetEdbInfoByCondition:" + err.Error())
 	}
 
+	now := time.Now()
+	var endDate string
+	if now.Hour() == 0 {
+		endDate = time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	} else {
+		endDate = time.Now().Format(utils.FormatDate)
+	}
 	for _, v := range items {
 		startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
-		endDate := time.Now().Format(utils.FormatDate)
 		err = SyncEdbDataByThs(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
 		if err != nil {
 			return errors.New("SyncEdbDataByThs:" + err.Error())
@@ -74,10 +80,15 @@ func RefreshDataFromWind() (err error) {
 		return err
 	}
 
-	for k, v := range items {
-		fmt.Println("line 67:", k, v.EdbCode)
+	now := time.Now()
+	var endDate string
+	if now.Hour() == 0 {
+		endDate = time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	} else {
+		endDate = time.Now().Format(utils.FormatDate)
+	}
+	for _, v := range items {
 		startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
-		endDate := time.Now().Format(utils.FormatDate)
 		err = SyncEdbDataByWind(int64(v.EdbInfoId), v.EdbCode, startDate, endDate)
 		if err != nil {
 			return err
@@ -113,9 +124,15 @@ func RefreshDataFromPb() (err error) {
 		return errors.New("GetEdbInfoByCondition:" + err.Error())
 	}
 
+	now := time.Now()
+	var endDate string
+	if now.Hour() == 0 {
+		endDate = time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	} else {
+		endDate = time.Now().Format(utils.FormatDate)
+	}
 	for _, v := range items {
 		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 {
@@ -190,9 +207,16 @@ func RefreshDataFromCalculate() (err error) {
 	if err != nil {
 		return err
 	}
+
+	now := time.Now()
+	var endDate string
+	if now.Hour() == 0 {
+		endDate = time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	} else {
+		endDate = time.Now().Format(utils.FormatDate)
+	}
 	for _, v := range items {
 		startDate := v.EndDate.AddDate(0, 0, -3).Format(utils.FormatDate)
-		endDate := time.Now().Format(utils.FormatDate)
 		var edbInfoIdBytes []string
 		calculateMap, err := data_manage.GetEdbInfoCalculateDetail(int(v.EdbInfoId))
 		if err != nil {

+ 4 - 6
services/task.go

@@ -1,12 +1,12 @@
 package services
 
 import (
+	"context"
 	"fmt"
 	"github.com/beego/beego/v2/task"
-	"hongze/hongze_task/services/data_manage"
 	"hongze/hongze_task/services/company_contract"
+	"hongze/hongze_task/services/data_manage"
 	"hongze/hongze_task/utils"
-	"context"
 )
 
 func Task() {
@@ -85,11 +85,11 @@ func releaseTask() {
 	task.AddTask("潜在客户", freeViewerDetail)
 
 	//刷新指标数据
-	refreshData := task.NewTask("refreshData", "0 0 18 * * *", RefreshData)
+	refreshData := task.NewTask("refreshData", "0 1 0,19 * * *", RefreshData)
 	task.AddTask("refreshData", refreshData)
 
 	//刷新计算指标数据
-	refreshCalculateData := task.NewTask("refreshCalculateData", "0 10 18 * * *", RefreshCalculateData)
+	refreshCalculateData := task.NewTask("refreshCalculateData", "0 10 0,19 * * *", RefreshCalculateData)
 	task.AddTask("refreshCalculateData", refreshCalculateData)
 
 	checkDataInterface := task.NewTask("checkDataInterface", "0 */2 * * * * ", data_manage.CheckDataInterface)
@@ -110,8 +110,6 @@ func TaskTest() {
 
 func Task123() {
 	fmt.Println("start")
-	//FreeViewerDetail()
-	HongzeUsers()
 	fmt.Println("end")
 	return
 }