瀏覽代碼

Merge branch 'feature/eta1.8.5_excel_balance' into debug

xyxie 10 月之前
父節點
當前提交
805c08f4cf

+ 6 - 0
controllers/data_manage/excel/balance_table.go

@@ -20,6 +20,7 @@ import (
 	"github.com/tealeg/xlsx"
 	"io/ioutil"
 	"os"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -982,6 +983,11 @@ func (c *ExcelInfoController) BalanceSeasonChartLegendPreview() {
 		dataList = append(dataList, tmp)
 	}
 
+	// 对dataList 根据dataTimestamp 进行排序
+	sort.Slice(dataList, func(i, j int) bool {
+		return dataList[i].DataTimestamp < dataList[j].DataTimestamp
+	})
+
 	list, err, errMsg := data.GetBalanceExcelSeasonChartLegendPreview(dataList, req.Calendar, req.SeasonExtraConfig)
 	if err != nil {
 		if errMsg != "" {

+ 1 - 1
models/data_manage/excel/excel_chart_data.go

@@ -50,7 +50,7 @@ func GetExcelChartDataByExcelInfoId(excelInfoId int) (list []*ExcelChartData, er
 	sql := ` SELECT *
              FROM excel_chart_data
 			 WHERE excel_info_id=? 
-             ORDER BY excel_chart_edb_id ASC, excel_chart_data_id ASC `
+             ORDER BY excel_chart_edb_id ASC, data_time desc, excel_chart_data_id ASC `
 	_, err = o.Raw(sql, excelInfoId).QueryRows(&list)
 	return
 }

+ 5 - 0
services/data/chart_info_excel_balance.go

@@ -12,6 +12,7 @@ import (
 	"eta/eta_api/utils"
 	"fmt"
 	"math"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -884,6 +885,10 @@ func GetBalanceExcelEdbDataMapList(chartInfoId, chartType int, calendar, startDa
 		dataListTmp, ok := dataListMap[v.EdbInfoId]
 		if ok {
 			dataList = dataListTmp
+			// 对dataList 根据dataTimestamp 进行排序
+			sort.Slice(dataList, func(i, j int) bool {
+				return dataList[i].DataTimestamp < dataList[j].DataTimestamp
+			})
 		} else {
 			//err = errors.New(fmt.Sprint("获取失败,指标类型异常", v.EdbInfoId))
 			utils.FileLog.Info(fmt.Sprintf("获取失败,指标数据异常 %d", v.EdbInfoId))