Browse Source

修改隆众数据获取

longyu 3 năm trước cách đây
mục cha
commit
3327ab5e23
1 tập tin đã thay đổi với 9 bổ sung4 xóa
  1. 9 4
      services/data_source_longzhong.go

+ 9 - 4
services/data_source_longzhong.go

@@ -15,6 +15,7 @@ import (
 	"github.com/rdlucklib/rdluck_tools/http"
 	"strconv"
 	"strings"
+	"sync"
 	"time"
 )
 
@@ -1050,10 +1051,13 @@ func GetLzSurveyProduct(cont context.Context) (err error) {
 	return
 }
 
+var lzLock sync.Mutex
+
 //隆众-调研指标数据
 func GetLzSurveyProductData(cont context.Context) (err error) {
+	lzLock.Lock()
 	utils.FileLogLz.Info("GetLzSurveyProductData start:" + time.Now().Format(utils.FormatDateTime))
-	go utils.SendEmail("隆众数据开始获取"+time.Now().Format("2006-01-02 15:04:05"),time.Now().Format("2006-01-02 15:04:05"), utils.EmailSendToUsers)
+	go utils.SendEmail("隆众数据开始获取"+time.Now().Format("2006-01-02 15:04:05"), time.Now().Format("2006-01-02 15:04:05"), utils.EmailSendToUsers)
 	var msg string
 	defer func() {
 		go utils.SendEmail("隆众数据获取完成"+time.Now().Format("2006-01-02 15:04:05"), ";msg:"+msg, utils.EmailSendToUsers)
@@ -1099,9 +1103,9 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
 		//	startDate = endDateTime.UnixNano() / 1e6
 		//}
 		if startDate < 0 {
-			startDate = time.Now().AddDate(-4, 0, 0).UnixNano() / 1e6
+			startDate = time.Now().AddDate(0, -6, 0).UnixNano() / 1e6
 		}
-		fmt.Println("startDate:" + time.Now().AddDate(-4, 0, 0).Format(utils.FormatDate))
+		fmt.Println("startDate:" + time.Now().AddDate(0, -6, 0).Format(utils.FormatDate))
 		fmt.Println("endDate:" + time.Now().Format(utils.FormatDate))
 
 		for {
@@ -1125,7 +1129,7 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
 				return err
 			}
 			utils.FileLogLz.Info("GetLzSurveyProductData:" + string(body))
-			fmt.Println("result:"+string(body))
+			fmt.Println("result:" + string(body))
 			if !strings.Contains(string(body), "<html>") {
 				dataList := new(models.LzSurveyData)
 				err = json.Unmarshal(body, &dataList)
@@ -1214,5 +1218,6 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
 		}
 		time.Sleep(2 * time.Second)
 	}
+	lzLock.Unlock()
 	return
 }