|
@@ -105,18 +105,34 @@ func GetChartSectionCombineData(chartInfo *chart_info.ChartInfo, mappingList []*
|
|
|
}
|
|
|
// todo 根据日期变换得到最终日期
|
|
|
edbDataListTmp := make([]*edbDataModel.EdbDataList, 0)
|
|
|
- if dateConfItem.EdbInfoId > 0 {
|
|
|
- edbDataListTmp, ok1 = edbDataListMap[dateConfItem.EdbInfoId]
|
|
|
- if !ok1 {
|
|
|
- err = fmt.Errorf("指标%d的日期数据不存在", dateConfItem.EdbInfoId)
|
|
|
+ if dateConfItem.DateType == 0 {
|
|
|
+ if dateConfItem.EdbInfoId > 0 {
|
|
|
+ edbDataListTmp, ok1 = edbDataListMap[dateConfItem.EdbInfoId]
|
|
|
+ if !ok1 {
|
|
|
+ err = fmt.Errorf("指标%d的日期数据不存在", dateConfItem.EdbInfoId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ findDate, err = GetChartSectionSeriesDateByDateChange(dateConfItem.EdbInfoId, edbDataListTmp, dateConfItem.DateChange, dateConfItem.MoveForward)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("指标%d的日期变换处理失败", dateConfItem.EdbInfoId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err = fmt.Errorf("请选择指标")
|
|
|
return
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- findDate, err = GetChartSectionSeriesDateByDateChange(dateConfItem.EdbInfoId, edbDataListTmp, dateConfItem.DateChange, dateConfItem.MoveForward)
|
|
|
- if err != nil {
|
|
|
- err = fmt.Errorf("指标%d的日期变换处理失败", dateConfItem.EdbInfoId)
|
|
|
- return
|
|
|
+ } else if dateConfItem.DateType == 1 {
|
|
|
+ findDate, err = GetChartSectionSeriesDateByDateChange(dateConfItem.EdbInfoId, edbDataListTmp, dateConfItem.DateChange, dateConfItem.MoveForward)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("指标%d的日期变换处理失败", dateConfItem.EdbInfoId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else if dateConfItem.DateType == 2 {
|
|
|
+ if dateConfItem.StaticDate == "" {
|
|
|
+ err = fmt.Errorf("请输入固定日期")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ findDate = dateConfItem.StaticDate
|
|
|
}
|
|
|
}
|
|
|
findDateTime, _ := time.ParseInLocation(utils.FormatDate, findDate, time.Local)
|
|
@@ -202,9 +218,26 @@ func GetChartSectionCombineData(chartInfo *chart_info.ChartInfo, mappingList []*
|
|
|
err = fmt.Errorf("基准系列不存在")
|
|
|
return
|
|
|
}
|
|
|
+ defaultIndexXDataList := make([]int, 0) //默认排序时的横轴
|
|
|
+ defaultXDataMap := make(map[int]chart_info2.XData) //默认排序时的横轴单位
|
|
|
+ for index, item := range baseSeries.EdbInfoList {
|
|
|
+ if index == 0 {
|
|
|
+ firstUnit = &chart_info2.XData{
|
|
|
+ Name: item.Unit,
|
|
|
+ NameEn: item.UnitEn,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp := chart_info2.XData{
|
|
|
+ Name: item.EdbName,
|
|
|
+ NameEn: item.EdbNameEn,
|
|
|
+ }
|
|
|
+ defaultXDataMap[index] = tmp
|
|
|
+ defaultIndexXDataList = append(defaultIndexXDataList, index)
|
|
|
+ }
|
|
|
// 处理系列排序
|
|
|
if extraConfig.SortType > 0 {
|
|
|
- newSeriesDataListMap, newSeriesNoDataIndexMap := SortChartSeriesDataSet(baseSeries.SeriesName, baseSeries.DataList, baseSeries.NoDataEdbIndex, seriesDataListMap, seriesNoDataIndexMap, extraConfig.SortType)
|
|
|
+ newSeriesDataListMap, newSeriesNoDataIndexMap, newIndexXDataList := SortChartSeriesDataSet(baseSeries.SeriesName, baseSeries.DataList, baseSeries.NoDataEdbIndex, seriesDataListMap, seriesNoDataIndexMap, extraConfig.SortType)
|
|
|
for k, item := range extraConfig.SeriesList {
|
|
|
dataList, ok := newSeriesDataListMap[item.SeriesName]
|
|
|
if ok {
|
|
@@ -215,28 +248,24 @@ func GetChartSectionCombineData(chartInfo *chart_info.ChartInfo, mappingList []*
|
|
|
extraConfig.SeriesList[k].NoDataEdbIndex = noIndex
|
|
|
}
|
|
|
}
|
|
|
+ defaultIndexXDataList = newIndexXDataList
|
|
|
}
|
|
|
|
|
|
xDataList := make([]chart_info2.XData, 0)
|
|
|
- for index, item := range baseSeries.EdbInfoList {
|
|
|
- if index == 0 {
|
|
|
- firstUnit = &chart_info2.XData{
|
|
|
- Name: item.Unit,
|
|
|
- NameEn: item.UnitEn,
|
|
|
- }
|
|
|
- }
|
|
|
- tmp := chart_info2.XData{
|
|
|
- Name: item.EdbName,
|
|
|
- NameEn: item.EdbNameEn,
|
|
|
+ for index, itemIndex := range defaultIndexXDataList {
|
|
|
+ nameItem, ok := defaultXDataMap[itemIndex]
|
|
|
+ if !ok {
|
|
|
+ err = fmt.Errorf("单位不存在")
|
|
|
+ return
|
|
|
}
|
|
|
// 如果已经设置了横轴名称,则用设置的名称替换
|
|
|
if len(extraConfig.XDataList) > index {
|
|
|
newItem := extraConfig.XDataList[index]
|
|
|
if newItem.Name != "" {
|
|
|
- tmp = newItem
|
|
|
+ nameItem = newItem
|
|
|
}
|
|
|
}
|
|
|
- xDataList = append(xDataList, tmp)
|
|
|
+ xDataList = append(xDataList, nameItem)
|
|
|
}
|
|
|
dataListResp.XDataList = xDataList
|
|
|
|
|
@@ -524,7 +553,7 @@ func handleSystemAppointDateT(currDate time.Time, appointDay, frequency string)
|
|
|
}
|
|
|
|
|
|
// sortTripleDataSet 以第一组数据为基准,排序之后,空数组的位置也要同步变更
|
|
|
-func SortChartSeriesDataSet(baseName string, baseDataList []float64, baseSeriesNoDataIndexList []int, dataListMap map[string][]float64, noDataListIndexMap map[string][]int, asc int) (newDataListMap map[string][]float64, newNoDataListIndexMap map[string][]int) {
|
|
|
+func SortChartSeriesDataSet(baseName string, baseDataList []float64, baseSeriesNoDataIndexList []int, dataListMap map[string][]float64, noDataListIndexMap map[string][]int, asc int) (newDataListMap map[string][]float64, newNoDataListIndexMap map[string][]int, newIndexXDataList []int) {
|
|
|
newDataListMap = make(map[string][]float64)
|
|
|
newNoDataListIndexMap = make(map[string][]int)
|
|
|
|
|
@@ -614,5 +643,6 @@ func SortChartSeriesDataSet(baseName string, baseDataList []float64, baseSeriesN
|
|
|
newDataListMap[k][i] = dataListMap[k][idx]
|
|
|
}
|
|
|
}
|
|
|
+ newIndexXDataList = newIndices
|
|
|
return
|
|
|
}
|