|
@@ -935,7 +935,7 @@ func getEdbDataMapListForSeason(chartInfoId, chartType int, calendar, startDate,
|
|
|
err = errors.New("获取农历数据失败,Err:" + tmpErr.Error())
|
|
|
return
|
|
|
}
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
+ quarterDataList, _, _, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
@@ -944,7 +944,7 @@ func getEdbDataMapListForSeason(chartInfoId, chartType int, calendar, startDate,
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDate(newDataList, latestDate, seasonExtraConfig)
|
|
|
+ quarterDataList, _, _, tErr := GetSeasonEdbInfoDataListByXDate(newDataList, latestDate, seasonExtraConfig)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
@@ -1563,6 +1563,14 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
sourceArr = make([]string, 0)
|
|
|
// 指标对应的所有数据
|
|
|
edbDataListMap = make(map[int][]*edbDataModel.EdbDataList)
|
|
|
+ seasonXStartDateWithYear := ""
|
|
|
+ seasonXEndDateWithYear := ""
|
|
|
+ if chartType == 2 {
|
|
|
+ sort.Slice(mappingList, func(i, j int) bool {
|
|
|
+ return mappingList[i].IsAxis > mappingList[j].IsAxis
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
for _, v := range mappingList {
|
|
|
//fmt.Println("v:", v.EdbInfoId)
|
|
|
item := new(chartEdbMappingModel.ChartEdbInfoMappingList)
|
|
@@ -1736,14 +1744,9 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if chartType == 2 && item.IsAxis == 1 {
|
|
|
- //latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
|
|
|
- //if tmpErr != nil {
|
|
|
- // //item.DataList = dataList
|
|
|
- // item.IsNullData = true
|
|
|
- // edbList = append(edbList, item)
|
|
|
- // continue
|
|
|
- //}
|
|
|
+ if chartType == 2 && v.IsAxis == 1 {
|
|
|
+ //latestDateStr := v.LatestDate.Format(utils.FormatDate) //实际数据的截止日期
|
|
|
+ latestDate := v.LatestDate
|
|
|
|
|
|
if calendar == "农历" {
|
|
|
if len(dataList) <= 0 {
|
|
@@ -1755,66 +1758,27 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
err = errors.New("获取农历数据失败,Err:" + tmpErr.Error())
|
|
|
return
|
|
|
}
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, v.LatestDate, seasonExtraConfig, calendarPreYear)
|
|
|
+ quarterDataList, seasonXStartDateWithYearTmp, seasonXEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
item.DataList = quarterDataList
|
|
|
+ seasonXStartDateWithYear = seasonXStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = seasonXEndDateWithYearTmp
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDate(dataList, v.LatestDate, seasonExtraConfig)
|
|
|
+ quarterDataList, seasonXStartDateWithYearTmp, seasonXEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDate(dataList, latestDate, seasonExtraConfig)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
item.DataList = quarterDataList
|
|
|
+ seasonXStartDateWithYear = seasonXStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = seasonXEndDateWithYearTmp
|
|
|
}
|
|
|
-
|
|
|
- } else if chartType == 2 && item.IsAxis == 0 {
|
|
|
- // 右轴数据处理
|
|
|
- xStartDate := "01-01"
|
|
|
-
|
|
|
- jumpYear := 0
|
|
|
- var seasonExtra edbDataModel.SeasonExtraItem
|
|
|
- if seasonExtraConfig != "" {
|
|
|
- err = json.Unmarshal([]byte(seasonExtraConfig), &seasonExtra)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if seasonExtra.XStartDate != "" {
|
|
|
- xStartDate = seasonExtra.XStartDate
|
|
|
- jumpYear = seasonExtra.JumpYear
|
|
|
- }
|
|
|
-
|
|
|
- length := len(dataList)
|
|
|
- if length == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- //latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
|
|
|
- //if tmpErr != nil {
|
|
|
- // //item.DataList = dataList
|
|
|
- // item.IsNullData = true
|
|
|
- // edbList = append(edbList, item)
|
|
|
- // continue
|
|
|
- // err = errors.New(fmt.Sprint("获取最后实际数据的日期失败,Err:" + tmpErr.Error() + ";LatestDate:" + v.LatestDate))
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
- var rightAxisDate time.Time
|
|
|
- if jumpYear == 1 {
|
|
|
- v.LatestDate = v.LatestDate.AddDate(-1, 0, 0)
|
|
|
- latestDateStr := fmt.Sprintf("%d-%s", v.LatestDate.Year(), xStartDate)
|
|
|
- rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- nowYear := time.Now().Year()
|
|
|
+ } else if chartType == 2 && v.IsAxis == 0 { //季节性图的非横轴指标
|
|
|
newDataList := make([]*edbDataModel.EdbDataList, 0)
|
|
|
for _, v := range dataList {
|
|
|
dataTime, e := time.Parse(utils.FormatDate, v.DataTime)
|
|
@@ -1822,11 +1786,9 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
err = errors.New("季节性图处理右轴指标数据转换日期失败,Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- dataTimeT, _ := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
- year := dataTimeT.Year()
|
|
|
- newItemDate := dataTimeT.AddDate(nowYear-year, 0, 0)
|
|
|
- v.DataTimestamp = newItemDate.UnixNano() / 1e6
|
|
|
- if dataTime.Equal(rightAxisDate) || dataTime.After(rightAxisDate) {
|
|
|
+ seasonXStartDateWithYearT, _ := time.Parse(utils.FormatDate, seasonXStartDateWithYear)
|
|
|
+ seasonXEndDateWithYearT, _ := time.Parse(utils.FormatDate, seasonXEndDateWithYear)
|
|
|
+ if dataTime.Equal(seasonXStartDateWithYearT) || (dataTime.After(seasonXStartDateWithYearT) && dataTime.Before(seasonXEndDateWithYearT)) || dataTime.Equal(seasonXEndDateWithYearT) {
|
|
|
newDataList = append(newDataList, v)
|
|
|
}
|
|
|
}
|
|
@@ -1843,7 +1805,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
}
|
|
|
|
|
|
// GetSeasonEdbInfoDataListByXDate 季节性图的指标数据根据横轴展示
|
|
|
-func GetSeasonEdbInfoDataListByXDate(dataList []*edbDataModel.EdbDataList, latestDate time.Time, seasonExtraConfig string) (quarterDataListSort edbDataModel.QuarterDataList, err error) {
|
|
|
+func GetSeasonEdbInfoDataListByXDate(dataList []*edbDataModel.EdbDataList, latestDate time.Time, seasonExtraConfig string) (quarterDataListSort edbDataModel.QuarterDataList, xStartDateWithYear string, xEndDateWithYear string, err error) {
|
|
|
xStartDate := "01-01"
|
|
|
xEndDate := "12-31"
|
|
|
jumpYear := 0
|
|
@@ -1893,7 +1855,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*edbDataModel.EdbDataList, lates
|
|
|
return
|
|
|
}
|
|
|
endYear := lastDateT.Year()
|
|
|
- nowYear := time.Now().Year()
|
|
|
+ nowYear := endYear
|
|
|
chartLegendMaxYear := 0
|
|
|
dataMap := make(map[string]edbDataModel.QuarterXDateItem, 0)
|
|
|
|
|
@@ -1943,6 +1905,8 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*edbDataModel.EdbDataList, lates
|
|
|
dataMap[name] = item
|
|
|
chartLegendMap[name] = idx
|
|
|
idx++
|
|
|
+ xStartDateWithYear = startStr
|
|
|
+ xEndDateWithYear = endStr
|
|
|
if lastDateT.Before(endT) {
|
|
|
//如果最新的日期在起始日之前,则跳出循环
|
|
|
break
|
|
@@ -2036,7 +2000,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*edbDataModel.EdbDataList, lates
|
|
|
}
|
|
|
|
|
|
// GetSeasonEdbInfoDataListByXDateNong 季节性图的指标数据根据横轴选择农历时展示
|
|
|
-func GetSeasonEdbInfoDataListByXDateNong(result *edbDataModel.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear int) (quarterDataListSort edbDataModel.QuarterDataList, err error) {
|
|
|
+func GetSeasonEdbInfoDataListByXDateNong(result *edbDataModel.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear int) (quarterDataListSort edbDataModel.QuarterDataList, xStartDateWithYear string, xEndDateWithYear string, err error) {
|
|
|
xStartDate := "01-01"
|
|
|
xEndDate := "12-31"
|
|
|
jumpYear := 0
|
|
@@ -2088,7 +2052,7 @@ func GetSeasonEdbInfoDataListByXDateNong(result *edbDataModel.EdbDataResult, lat
|
|
|
return
|
|
|
}
|
|
|
endYear := lastDateT.Year()
|
|
|
- nowYear := time.Now().Year()
|
|
|
+ nowYear := endYear
|
|
|
chartLegendMaxYear := 0
|
|
|
dataMap := make(map[string]edbDataModel.QuarterXDateItem, 0)
|
|
|
|
|
@@ -2141,6 +2105,8 @@ func GetSeasonEdbInfoDataListByXDateNong(result *edbDataModel.EdbDataResult, lat
|
|
|
endTmpT = endT
|
|
|
chartLegendMap[showName] = idx
|
|
|
idx++
|
|
|
+ xStartDateWithYear = startStr
|
|
|
+ xEndDateWithYear = endStr
|
|
|
if lastDateT.Before(endT) {
|
|
|
//如果最新的日期在起始日之前,则跳出循环
|
|
|
break
|