浏览代码

Merge branch 'chart/14.8' into debug

Roc 1 年之前
父节点
当前提交
b8bddc5b46
共有 1 个文件被更改,包括 35 次插入0 次删除
  1. 35 0
      models/edb_info.go

+ 35 - 0
models/edb_info.go

@@ -724,6 +724,8 @@ func GetChartPredictEdbInfoDataListByConfList(predictEdbConfList []*PredictEdbCo
 	return
 }
 
+// GetPredictEdbDayList 获取预测指标日期列表
+
 // GetPredictEdbDayList 获取预测指标日期列表
 func getPredictEdbDayList(startDate, endDate time.Time, frequency string) (dayList []time.Time) {
 	//if !utils.InArrayByStr([]string{"日度", "周度", "月度"}, frequency)
@@ -741,6 +743,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)
@@ -749,6 +760,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())