Browse Source

fix:修复预测指标,倒序问题

Roc 2 years ago
parent
commit
eca54c4793
1 changed files with 17 additions and 3 deletions
  1. 17 3
      models/edb_info.go

+ 17 - 3
models/edb_info.go

@@ -728,7 +728,7 @@ func GetPredictDataListByPredictEdbInfo(edbInfo *EdbInfo, order int, startDate s
 	}
 	// 如果选择了日期,那么需要筛选所有的数据,用于未来指标的生成
 	if startDate != `` {
-		allDataList, err = GetEdbDataListAll(" AND edb_info_id=? ", []interface{}{sourceEdbInfoItem.EdbInfoId}, sourceEdbInfoItem.Source, 1)
+		allDataList, err = GetEdbDataListAll(" AND edb_info_id=? ", []interface{}{sourceEdbInfoItem.EdbInfoId}, sourceEdbInfoItem.Source, order)
 		if err != nil {
 			return
 		}
@@ -748,7 +748,21 @@ func GetPredictDataListByPredictEdbInfo(edbInfo *EdbInfo, order int, startDate s
 	if err != nil {
 		return
 	}
-	dataList = append(dataList, predictDataList...)
+
+	//order:1升序,其余值为降序
+	if order == 1 {
+		dataList = append(dataList, predictDataList...)
+	}else{
+		lenPredictDataList := len(predictDataList)
+		if lenPredictDataList >0 {
+			tmpDataList :=make([]*EdbInfoSearchData,0)
+			for k,_:=range predictDataList{
+				tmpDataList = append(tmpDataList,predictDataList[lenPredictDataList-k-1])
+			}
+			tmpDataList = append(tmpDataList,dataList...)
+			dataList = tmpDataList
+		}
+	}
 	if len(predictDataList) > 0 {
 		// 如果最小值 大于 预测值,那么将预测值作为最小值数据返回
 		if edbInfo.MinValue > predictMinValue {
@@ -780,7 +794,7 @@ func GetPredictEdbDataListAll(edbInfo *EdbInfo, order int) (items []*EdbInfoSear
 // GetPredictEdbDataListAllByStartDate 根据开始日期获取该预测指标所有的数据 ,order:1升序,其余值为降序
 func GetPredictEdbDataListAllByStartDate(edbInfo *EdbInfo, order int, startDate string) (items []*EdbInfoSearchData, err error) {
 	if edbInfo.Source == utils.DATA_SOURCE_PREDICT { //普通的预测指标是没有入库数据的,直接往配置里面获取
-		items, _, _, err, _ = GetPredictDataListByPredictEdbInfo(edbInfo, 1, startDate)
+		items, _, _, err, _ = GetPredictDataListByPredictEdbInfo(edbInfo, order, startDate)
 	} else {
 		var condition string
 		var pars []interface{}