Browse Source

区间计算

xyxie 7 months ago
parent
commit
023726bbd2

+ 6 - 3
models/data_manage/chart_info_range_analysis.go

@@ -40,8 +40,9 @@ type EdbDateConfDateChange struct {
 }
 
 type ChartRangeAnalysisDeleteDataConf struct {
-	Formula string `description:"比较符号:=、>、<、>=、<="`
-	Value   float64
+	Formula      string  `description:"比较符号:=、>、<、>=、<="`
+	Value        float64 `description:"比较的值"`
+	ReplaceValue float64 `description:"替换的值"`
 }
 
 type ChartRangeAnalysisDataConvertConf struct {
@@ -57,7 +58,9 @@ type ChartRangeAnalysisManualDateConf struct { //手工划分
 
 type ChartRangeAnalysisAutoDateConf struct { //智能划分
 	IsAutoStartDate int                                  `description:"起始日期是否是动态设置:0固定,1动态"`
-	StartDate       string                               `description:"起始日期"` //固定模式下,截止日期为指标的最新日期
+	StartDate       string                               `description:"固定模式下的起始日期"`
+	EndDate         string                               `description:"固定模式下的截止日期"`
+	IsAutoEndDate   int                                  `description:"截止日期是否是动态设置:0固定,1动态"`
 	StartDateConf   ChartRangeAnalysisAutoDateChangeConf `description:"动态起始日期配置"`
 	EndDateConf     ChartRangeAnalysisAutoDateChangeConf `description:"动态截止日期配置"`
 }

+ 16 - 7
services/data/range_analysis/chart_info.go

@@ -447,12 +447,9 @@ func getChartDataByEdbInfo(edbInfoMapping *data_manage.ChartEdbInfoMapping, req
 				startDate = "2020-01-01"
 			}
 			startDateTime, _ = time.ParseInLocation(utils.FormatDate, startDate, time.Local)
-			endDateTime = edbEndDateTime
 		} else {
 			startConf := req.AutoDateConf.StartDateConf
-			endConf := req.AutoDateConf.EndDateConf
 			startDate := ""
-			endDate := ""
 			if startConf.BaseDateType == 0 { //
 				startDate = edbEndDate
 			} else if startConf.BaseDateType == 1 {
@@ -468,7 +465,20 @@ func getChartDataByEdbInfo(edbInfoMapping *data_manage.ChartEdbInfoMapping, req
 					return
 				}
 			}
+			startDateTime, _ = time.ParseInLocation(utils.FormatDate, startDate, time.Local)
+		}
 
+		if req.AutoDateConf.IsAutoEndDate == 0 { //固定设置
+			endDate := req.AutoDateConf.EndDate
+			if endDate == "" {
+				err = fmt.Errorf("智能划分截止日期处理失败:请输入截止日期")
+				return
+			}
+			// todo 如果截止日期比指标日期还要大,则用指标的最新日期
+			endDateTime, _ = time.ParseInLocation(utils.FormatDate, endDate, time.Local)
+		} else {
+			endConf := req.AutoDateConf.EndDateConf
+			endDate := ""
 			if endConf.BaseDateType == 0 { //
 				endDate = edbEndDate
 			} else if endConf.BaseDateType == 2 {
@@ -484,10 +494,9 @@ func getChartDataByEdbInfo(edbInfoMapping *data_manage.ChartEdbInfoMapping, req
 					return
 				}
 			}
-
-			startDateTime, _ = time.ParseInLocation(utils.FormatDate, startDate, time.Local)
 			endDateTime, _ = time.ParseInLocation(utils.FormatDate, endDate, time.Local)
 		}
+
 		dateList = append(dateList, &data_manage.ChartRangeAnalysisDateDataItem{
 			StartDate: startDateTime,
 			EndDate:   endDateTime})
@@ -552,7 +561,7 @@ func getChartDataByEdbInfo(edbInfoMapping *data_manage.ChartEdbInfoMapping, req
 		case 2:
 			for i, v := range newDataList {
 				if utils.CompareFloatByOpStrings(req.UnNormalDataConf.Formula, v.Value, req.UnNormalDataConf.Value) {
-					newDataList[i].Value = req.UnNormalDataConf.Value
+					newDataList[i].Value = req.UnNormalDataConf.ReplaceValue
 				}
 			}
 		}
@@ -848,7 +857,7 @@ func AddChartInfo(req data_manage.AddChartInfoReq, source int, sysUser *system.A
 	chartInfo.IsSetName = 0
 	timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
 	chartInfo.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + timestamp)
-	chartInfo.ChartType = 9 // 区间计算图
+	chartInfo.ChartType = 1 // 区间计算图
 	chartInfo.Calendar = "公历"
 	chartInfo.DateType = 6
 	chartInfo.StartDate = req.StartDate