|
@@ -7,6 +7,7 @@ import (
|
|
|
"eta/eta_api/services/google"
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
+ "sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -377,10 +378,12 @@ func GetChartSectionCombineData(chartInfo *data_manage.ChartInfo, mappingList []
|
|
|
Right2Min float64
|
|
|
Right2Max float64
|
|
|
)
|
|
|
+ seriesDataListMap := make(map[string][]float64)
|
|
|
+ seriesNoDataIndexMap := make(map[string][]int)
|
|
|
for _, seriesItem := range extraConfig.SeriesList {
|
|
|
var maxDate time.Time
|
|
|
var minVal, maxVal float64
|
|
|
- noDataEdbIdList := make([]int, 0)
|
|
|
+ noDataEdbIndex := make([]int, 0)
|
|
|
dataList := make([]float64, len(seriesItem.EdbInfoList))
|
|
|
for index, edbConf := range seriesItem.EdbInfoList {
|
|
|
edbInfoId := edbConf.EdbInfoId //X轴的指标
|
|
@@ -461,14 +464,17 @@ func GetChartSectionCombineData(chartInfo *data_manage.ChartInfo, mappingList []
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- noDataEdbIdList = append(noDataEdbIdList, edbInfoId)
|
|
|
+ dataList[index] = 0
|
|
|
+ noDataEdbIndex = append(noDataEdbIndex, index)
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+ seriesDataListMap[seriesItem.SeriesName] = dataList
|
|
|
+ seriesNoDataIndexMap[seriesItem.SeriesName] = noDataEdbIndex
|
|
|
seriesItem.DataList = dataList
|
|
|
seriesItem.MinData = minVal
|
|
|
seriesItem.MaxData = maxVal
|
|
|
- seriesItem.NoDataEdbIdList = noDataEdbIdList
|
|
|
+ seriesItem.NoDataEdbIndex = noDataEdbIndex
|
|
|
if extraConfig.BaseChartSeriesName == seriesItem.SeriesName {
|
|
|
baseSeries = seriesItem
|
|
|
}
|
|
@@ -519,6 +525,21 @@ func GetChartSectionCombineData(chartInfo *data_manage.ChartInfo, mappingList []
|
|
|
err = fmt.Errorf("基准系列不存在")
|
|
|
return
|
|
|
}
|
|
|
+ // 处理系列排序
|
|
|
+ if extraConfig.SortType > 0 {
|
|
|
+ newSeriesDataListMap, newSeriesNoDataIndexMap := sortChartSeriesDataSet(baseSeries.DataList, baseSeries.NoDataEdbIndex, seriesDataListMap, seriesNoDataIndexMap, extraConfig.SortType)
|
|
|
+ for k, item := range extraConfig.SeriesList {
|
|
|
+ dataList, ok := newSeriesDataListMap[item.SeriesName]
|
|
|
+ if ok {
|
|
|
+ extraConfig.SeriesList[k].DataList = dataList
|
|
|
+ }
|
|
|
+ noIndex, ok := newSeriesNoDataIndexMap[item.SeriesName]
|
|
|
+ if ok {
|
|
|
+ extraConfig.SeriesList[k].NoDataEdbIndex = noIndex
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
xDataList := make([]data_manage.XData, 0)
|
|
|
for index, item := range baseSeries.EdbInfoList {
|
|
|
if index == 0 {
|
|
@@ -618,8 +639,6 @@ func GetChartSectionCombineData(chartInfo *data_manage.ChartInfo, mappingList []
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 处理系列排序
|
|
|
-
|
|
|
dataListResp.SeriesList = extraConfig.SeriesList
|
|
|
dataListResp.DateConfList = extraConfig.DateConfList
|
|
|
dataListResp.BaseChartSeriesName = extraConfig.BaseChartSeriesName
|
|
@@ -826,3 +845,73 @@ func handleSystemAppointDateT(currDate time.Time, appointDay, frequency string)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// sortTripleDataSet 以第一组数据为基准,排序之后,空数组的位置也要同步变更
|
|
|
+func sortChartSeriesDataSet(baseDataList []float64, baseSeriesNoDataIndexList []int, dataListMap map[string][]float64, noDataListIndexMap map[string][]int, asc int) (newDataListMap map[string][]float64, newNoDataListIndexMap map[string][]int) {
|
|
|
+ newDataListMap = make(map[string][]float64)
|
|
|
+ newNoDataListIndexMap = make(map[string][]int)
|
|
|
+
|
|
|
+ indices := make([]int, len(baseDataList))
|
|
|
+ newIndices := make([]int, len(baseDataList))
|
|
|
+ // 初始化indices
|
|
|
+ for i := range indices {
|
|
|
+ indices[i] = i
|
|
|
+ }
|
|
|
+ if len(baseSeriesNoDataIndexList) > 0 { //把空值移动到最右边
|
|
|
+ for i, v := range indices {
|
|
|
+ isEmpty := false
|
|
|
+ for k := range baseSeriesNoDataIndexList {
|
|
|
+ if i == k {
|
|
|
+ isEmpty = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isEmpty {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ newIndices[i] = v
|
|
|
+ }
|
|
|
+ newIndices = append(newIndices, baseSeriesNoDataIndexList...)
|
|
|
+ // 根据排序后的indices重新排列所有组的数据
|
|
|
+ for i, idx := range indices {
|
|
|
+ for k, _ := range dataListMap {
|
|
|
+ if utils.InArrayByInt(noDataListIndexMap[k], i) { //如果i位置上的数据为空,那么
|
|
|
+ newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], idx)
|
|
|
+ }
|
|
|
+ newDataListMap[k][i] = dataListMap[k][idx]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataListMap = newDataListMap
|
|
|
+ noDataListIndexMap = newNoDataListIndexMap
|
|
|
+ newDataListMap = make(map[string][]float64)
|
|
|
+ newNoDataListIndexMap = make(map[string][]int)
|
|
|
+ //先把空的数据移动到最后面
|
|
|
+ indices = make([]int, len(baseDataList)-len(baseSeriesNoDataIndexList)) //空值不参与排序
|
|
|
+ // 初始化indices
|
|
|
+ for i := range indices {
|
|
|
+ indices[i] = i
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据Group1的数据进行排序,asc决定是升序还是降序
|
|
|
+ if asc == 1 {
|
|
|
+ sort.Slice(indices, func(i, j int) bool {
|
|
|
+ return baseDataList[i] < baseDataList[j]
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ sort.Slice(indices, func(i, j int) bool {
|
|
|
+ return baseDataList[i] > baseDataList[j]
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据排序后的indices重新排列所有组的数据
|
|
|
+ for i, idx := range indices {
|
|
|
+ for k, _ := range dataListMap {
|
|
|
+ if utils.InArrayByInt(noDataListIndexMap[k], i) { //如果i位置上的数据为空,那么
|
|
|
+ newNoDataListIndexMap[k] = append(newNoDataListIndexMap[k], idx)
|
|
|
+ }
|
|
|
+ newDataListMap[k][i] = dataListMap[k][idx]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|