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