Browse Source

Merge branch 'feature/eta2.1.2_predict_edb' into debug

xyxie 6 months ago
parent
commit
619392d1ce
2 changed files with 5 additions and 75 deletions
  1. 2 0
      models/tables/edb_data/query.go
  2. 3 75
      services/chart/predict_edb_info.go

+ 2 - 0
models/tables/edb_data/query.go

@@ -172,6 +172,8 @@ func GetEdbDataTableName(source, subSource int) (tableName string) {
 		tableName = "edb_data_calculate_zdyfx" // 自定义分析->74
 	case utils.DATA_SOURCE_CALCULATE_RJZ: //日均值->75
 		tableName = "edb_data_calculate_rjz"
+	case utils.DATA_SOURCE_PREDICT: // 基础预测指标->30
+		tableName = "edb_data_predict_base"
 	default:
 		edbSource, _ := edb_source.GetEdbSourceBySource(source)
 		if edbSource != nil {

+ 3 - 75
services/chart/predict_edb_info.go

@@ -352,82 +352,10 @@ func GetPredictDataListByPredictEdbInfoId(edbInfoId int, startDate, endDate stri
 // GetPredictDataListByPredictEdbInfo 根据预测指标信息获取预测指标的数据
 func GetPredictDataListByPredictEdbInfo(edbInfo *edbInfoModel.EdbInfo, startDate, endDate string, isTimeBetween bool) (dataList []*edbDataModel.EdbDataList, sourceEdbInfoItem *edbInfoModel.EdbInfo, predictEdbConf *predictEdbConfModel.PredictEdbConf, err error, errMsg string) {
 	// 非计算指标,直接从表里获取数据
-	if edbInfo.EdbType != 1 {
-		if !isTimeBetween {
-			endDate = ``
-		}
-		return GetPredictCalculateDataListByPredictEdbInfo(edbInfo, startDate, endDate)
+	if !isTimeBetween {
+		endDate = ``
 	}
-	// 查找该预测指标配置
-	predictEdbConfList, err := predictEdbConfModel.GetPredictEdbConfListById(edbInfo.EdbInfoId)
-	if err != nil {
-		errMsg = "获取预测指标配置信息失败"
-		return
-	}
-	if len(predictEdbConfList) == 0 {
-		errMsg = "获取预测指标配置信息失败"
-		err = errors.New(errMsg)
-		return
-	}
-	predictEdbConf = predictEdbConfList[0]
-
-	// 来源指标
-	sourceEdbInfoItem, err = edbInfoModel.GetEdbInfoById(int(predictEdbConf.SourceEdbInfoID))
-	if err != nil {
-		if err == utils.ErrNoRow {
-			errMsg = "找不到来源指标信息"
-			err = errors.New(errMsg)
-		}
-		return
-	}
-
-	allDataList := make([]*edbDataModel.EdbDataList, 0)
-	//获取指标数据(实际已生成)
-	dataList, err = edbDataModel.GetEdbDataList(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, sourceEdbInfoItem.EdbInfoId, startDate, endDate)
-	if err != nil {
-		return
-	}
-	// 如果选择了日期,那么需要筛选所有的数据,用于未来指标的生成
-	if startDate != `` {
-		allDataList, err = edbDataModel.GetEdbDataList(sourceEdbInfoItem.Source, sourceEdbInfoItem.SubSource, sourceEdbInfoItem.EdbInfoId, "", "")
-		if err != nil {
-			return
-		}
-	} else {
-		allDataList = dataList
-	}
-
-	// 获取预测指标未来的数据
-	predictDataList := make([]*edbDataModel.EdbDataList, 0)
-
-	endDateStr := edbInfo.EndDate.Format(utils.FormatDate) //预测指标的结束日期
-
-	if isTimeBetween { //如果是时间区间,那么
-		reqEndDateTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
-		// 如果选择的时间区间结束日期 晚于 当天,那么预测数据截止到当天
-		if reqEndDateTime.Before(edbInfo.EndDate) {
-			endDateStr = endDate
-		}
-	}
-	//predictDataList, err = GetChartPredictEdbInfoDataList(*predictEdbConf, startDate, sourceEdbInfoItem.LatestDate.Format(utils.FormatDate), sourceEdbInfoItem.LatestValue, endDateStr, edbInfo.Frequency)
-	var predictMinValue, predictMaxValue float64
-	predictDataList, predictMinValue, predictMaxValue, err = GetChartPredictEdbInfoDataListByConfList(predictEdbConfList, startDate, sourceEdbInfoItem.LatestDate.Format(utils.FormatDate), endDateStr, edbInfo.Frequency, edbInfo.DataDateType, allDataList)
-	if err != nil {
-		return
-	}
-	dataList = append(dataList, predictDataList...)
-	if len(predictDataList) > 0 {
-		// 如果最小值 大于 预测值,那么将预测值作为最小值数据返回
-		if edbInfo.MinValue > predictMinValue {
-			edbInfo.MinValue = predictMinValue
-		}
-
-		// 如果最大值 小于 预测值,那么将预测值作为最大值数据返回
-		if edbInfo.MaxValue < predictMaxValue {
-			edbInfo.MaxValue = predictMaxValue
-		}
-	}
-	return
+	return GetPredictCalculateDataListByPredictEdbInfo(edbInfo, startDate, endDate)
 }
 
 // GetPredictCalculateDataListByPredictEdbInfo 根据预测运算指标信息获取预测指标的数据