Sfoglia il codice sorgente

fix:预测指标频度新增旬度、季度,半年度

Roc 1 anno fa
parent
commit
33b8e052ff
1 ha cambiato i file con 33 aggiunte e 0 eliminazioni
  1. 33 0
      services/data/predict_edb_info.go

+ 33 - 0
services/data/predict_edb_info.go

@@ -374,6 +374,15 @@ func getPredictEdbDayList(startDate, endDate time.Time, frequency string) (dayLi
 		for currDate := startDate.AddDate(0, 0, 7); currDate.Before(endDate) || currDate.Equal(endDate); currDate = currDate.AddDate(0, 0, 7) {
 			dayList = append(dayList, currDate)
 		}
+	case "旬度":
+		for currDate := startDate.AddDate(0, 0, 1); currDate.Before(endDate) || currDate.Equal(endDate); {
+			nextDate := currDate.AddDate(0, 0, 1)
+			//每个月的10号、20号、最后一天,那么就写入
+			if nextDate.Day() == 11 || nextDate.Day() == 21 || nextDate.Day() == 1 {
+				dayList = append(dayList, currDate)
+			}
+			currDate = nextDate
+		}
 	case "月度":
 		for currDate := startDate; currDate.Before(endDate) || currDate.Equal(endDate); {
 			currDate = time.Date(currDate.Year(), currDate.Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
@@ -382,6 +391,30 @@ func getPredictEdbDayList(startDate, endDate time.Time, frequency string) (dayLi
 			}
 			currDate = currDate.AddDate(0, 0, 1)
 		}
+	case "季度":
+		for currDate := startDate; currDate.Before(endDate) || currDate.Equal(endDate); {
+			// 每月的最后一天
+			currDate = time.Date(currDate.Year(), currDate.Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+			if !currDate.After(endDate) && !currDate.Equal(startDate) {
+				// 季度日期就写入,否则不写入
+				if currDate.Month() == 3 || currDate.Month() == 6 || currDate.Month() == 9 || currDate.Month() == 12 {
+					dayList = append(dayList, currDate)
+				}
+			}
+			currDate = currDate.AddDate(0, 0, 1)
+		}
+	case "半年度":
+		for currDate := startDate; currDate.Before(endDate) || currDate.Equal(endDate); {
+			// 每月的最后一天
+			currDate = time.Date(currDate.Year(), currDate.Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+			if !currDate.After(endDate) && !currDate.Equal(startDate) {
+				// 半年度日期就写入,否则不写入
+				if currDate.Month() == 6 || currDate.Month() == 12 {
+					dayList = append(dayList, currDate)
+				}
+			}
+			currDate = currDate.AddDate(0, 0, 1)
+		}
 	case "年度":
 		for currDate := startDate; currDate.Before(endDate) || currDate.Equal(endDate); {
 			currDate = time.Date(currDate.Year()+1, 12, 31, 0, 0, 0, 0, time.Now().Location())