Explorar o código

修改数据获取bug

longyu %!s(int64=3) %!d(string=hai) anos
pai
achega
e027b3d520
Modificáronse 1 ficheiros con 12 adicións e 5 borrados
  1. 12 5
      services/data_source_longzhong.go

+ 12 - 5
services/data_source_longzhong.go

@@ -1034,6 +1034,8 @@ func GetLzSurveyProduct(cont context.Context) (err error) {
 					models.ModifLongzhongSurveyProductCode(lzCode, surveyProductId)
 				}
 			} else {
+				item.StartDate = "2018-01-01"
+				item.EndDate = "2018-01-01"
 				lastId, err := models.AddLongzhongSurveyProduct(item)
 				if err != nil {
 					msg = "新增隆众价格指标失败:err " + err.Error()
@@ -1085,9 +1087,9 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
 	paramMap["passWord"] = password
 	paramMap["pageSize"] = 100
 
-	//startDate := time.Now().AddDate(-4, 0, 0).UnixNano() / 1e6
-	startDateTime, _ := time.Parse(utils.FormatDate, "2021-12-01")
-	startDate := startDateTime.UnixNano() / 1e6
+	startDate := time.Now().AddDate(-4, 0, 0).UnixNano() / 1e6
+	//startDateTime, _ := time.Parse(utils.FormatDate, "2021-12-01")
+	//startDate := startDateTime.UnixNano() / 1e6
 	endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).UnixNano() / 1e6
 
 	for k, v := range priceInfoList {
@@ -1102,10 +1104,15 @@ func GetLzSurveyProductData(cont context.Context) (err error) {
 		//	endDateTime, _ := time.Parse(utils.FormatDate, v.EndDate)
 		//	startDate = endDateTime.UnixNano() / 1e6
 		//}
+		if v.EndDate != "" {
+			endDateTime, _ := time.Parse(utils.FormatDate, v.EndDate)
+			startDate = endDateTime.AddDate(0, -8, 0).UnixNano() / 1e6
+		}
+
 		if startDate < 0 {
-			startDate = time.Now().AddDate(0, -4, 0).UnixNano() / 1e6
+			startDate = time.Now().AddDate(0, -8, 0).UnixNano() / 1e6
 		}
-		fmt.Println("startDate:" + time.Now().AddDate(0, -4, 0).Format(utils.FormatDate))
+
 		fmt.Println("endDate:" + time.Now().Format(utils.FormatDate))
 
 		for {