Browse Source

fix:统计分析/统计特征的标准差、百分位图表时间范围与曲线图一致

Roc 1 year ago
parent
commit
7a201bc77b
2 changed files with 8 additions and 6 deletions
  1. 4 2
      controllers/chart_common.go
  2. 4 4
      services/data/line_feature/chart_info.go

+ 4 - 2
controllers/chart_common.go

@@ -396,7 +396,8 @@ func GetLineFeatureChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, ke
 			errMsg = "格式化配置项失败,Err:" + tmpErr.Error()
 			return
 		}
-		edbList, resultResp, err, msg = lineFeatureServ.GetStandardDeviationData(0, edbMapping, calculateValue)
+		startDate, endDate := utils.GetDateByDateType(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate)
+		edbList, resultResp, err, msg = lineFeatureServ.GetStandardDeviationData(chartInfo.ChartInfoId, startDate, endDate, edbMapping, calculateValue)
 	case utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE:
 		var percentileConfig line_featureReq.Percentile
 		err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &percentileConfig)
@@ -405,7 +406,8 @@ func GetLineFeatureChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, ke
 			errMsg = "格式化配置项失败,Err:" + err.Error()
 			return
 		}
-		edbList, resultResp, err, msg = lineFeatureServ.GetPercentileData(0, edbMapping, percentileConfig.CalculateValue, percentileConfig.CalculateUnit)
+		startDate, endDate := utils.GetDateByDateType(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate)
+		edbList, resultResp, err, msg = lineFeatureServ.GetPercentileData(chartInfo.ChartInfoId, startDate, endDate, edbMapping, percentileConfig.CalculateValue, percentileConfig.CalculateUnit)
 	case utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
 		var frequencyDistributionConfig line_featureReq.FrequencyDistribution
 		err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &frequencyDistributionConfig)

+ 4 - 4
services/data/line_feature/chart_info.go

@@ -11,11 +11,11 @@ import (
 )
 
 // GetStandardDeviationData 获取标准差图表的指标数据
-func GetStandardDeviationData(chartInfoId int, mappingInfo *models.ChartEdbInfoMapping, calculateValue int) (edbList []*models.ChartEdbInfoMapping, dataResp response.LineFeatureDataResp, err error, errMsg string) {
+func GetStandardDeviationData(chartInfoId int, startDate, endDate string, mappingInfo *models.ChartEdbInfoMapping, calculateValue int) (edbList []*models.ChartEdbInfoMapping, dataResp response.LineFeatureDataResp, err error, errMsg string) {
 	edbList = make([]*models.ChartEdbInfoMapping, 0)
 
 	// 指标对应的所有数据
-	_, edbList, err = data.GetEdbDataMapList(chartInfoId, 1, `公历`, ``, ``, []*models.ChartEdbInfoMapping{mappingInfo})
+	_, edbList, err = data.GetEdbDataMapList(chartInfoId, 1, `公历`, startDate, endDate, []*models.ChartEdbInfoMapping{mappingInfo})
 	if err != nil {
 		return
 	}
@@ -78,7 +78,7 @@ func GetStandardDeviationData(chartInfoId int, mappingInfo *models.ChartEdbInfoM
 }
 
 // GetPercentileData 获取百分位图表的指标数据
-func GetPercentileData(chartInfoId int, mappingInfo *models.ChartEdbInfoMapping, calculateValue int, calculateUnit string) (edbList []*models.ChartEdbInfoMapping, dataResp response.LineFeatureDataResp, err error, errMsg string) {
+func GetPercentileData(chartInfoId int, startDate, endDate string, mappingInfo *models.ChartEdbInfoMapping, calculateValue int, calculateUnit string) (edbList []*models.ChartEdbInfoMapping, dataResp response.LineFeatureDataResp, err error, errMsg string) {
 	edbList = make([]*models.ChartEdbInfoMapping, 0)
 	moveUnitDays, ok := utils.FrequencyDaysMap[calculateUnit]
 	if !ok {
@@ -88,7 +88,7 @@ func GetPercentileData(chartInfoId int, mappingInfo *models.ChartEdbInfoMapping,
 	}
 	calculateDay := calculateValue * moveUnitDays
 	// 指标对应的所有数据
-	_, edbList, err = data.GetEdbDataMapList(chartInfoId, 1, `公历`, ``, ``, []*models.ChartEdbInfoMapping{mappingInfo})
+	_, edbList, err = data.GetEdbDataMapList(chartInfoId, 1, `公历`, startDate, endDate, []*models.ChartEdbInfoMapping{mappingInfo})
 	if err != nil {
 		return
 	}