|
@@ -364,7 +364,13 @@ func GetEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate string, mappingList []*models.ChartEdbInfoMapping, seasonExtraConfig string) (edbDataListMap map[int][]*models.EdbDataList, edbList []*models.ChartEdbInfoMapping, err error) {
|
|
|
// 指标对应的所有数据
|
|
|
edbDataListMap = make(map[int][]*models.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(models.ChartEdbInfoMapping)
|
|
@@ -555,66 +561,29 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
err = errors.New("获取农历数据失败,Err:" + tmpErr.Error())
|
|
|
return
|
|
|
}
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
+ quarterDataList, xStartDateWithYearTmp, xEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
item.DataList = quarterDataList
|
|
|
+ seasonXStartDateWithYear = xStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = xEndDateWithYearTmp
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDate(dataList, latestDate, seasonExtraConfig)
|
|
|
+ quarterDataList, xStartDateWithYearTmp, xEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDate(dataList, latestDate, seasonExtraConfig)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
item.DataList = quarterDataList
|
|
|
+ seasonXStartDateWithYear = xStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = xEndDateWithYearTmp
|
|
|
}
|
|
|
|
|
|
} else if chartType == 2 && item.IsAxis == 0 {
|
|
|
// 右轴数据处理
|
|
|
- xStartDate := "01-01"
|
|
|
-
|
|
|
- jumpYear := 0
|
|
|
- var seasonExtra models.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 {
|
|
|
- latestDate = latestDate.AddDate(-1, 0, 0)
|
|
|
- }
|
|
|
- latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(), xStartDate)
|
|
|
- rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- nowYear := time.Now().Year()
|
|
|
newDataList := make([]*models.EdbDataList, 0)
|
|
|
for _, v := range dataList {
|
|
|
dataTime, e := time.Parse(utils.FormatDate, v.DataTime)
|
|
@@ -622,11 +591,10 @@ 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.After(seasonXStartDateWithYearT) && dataTime.Before(seasonXEndDateWithYearT)) || dataTime.Equal(seasonXStartDateWithYearT) || dataTime.Equal(seasonXEndDateWithYearT) {
|
|
|
newDataList = append(newDataList, v)
|
|
|
}
|
|
|
}
|
|
@@ -643,7 +611,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
|
|
|
}
|
|
|
|
|
|
// GetSeasonEdbInfoDataListByXDate 季节性图的指标数据根据横轴展示
|
|
|
-func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate time.Time, seasonExtraConfig string) (quarterDataListSort models.QuarterDataList, err error) {
|
|
|
+func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate time.Time, seasonExtraConfig string) (quarterDataListSort models.QuarterDataList, xStartDateWithYear string, xEndDateWithYear string, err error) {
|
|
|
xStartDate := "01-01"
|
|
|
xEndDate := "12-31"
|
|
|
jumpYear := 0
|
|
@@ -693,7 +661,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate
|
|
|
return
|
|
|
}
|
|
|
endYear := lastDateT.Year()
|
|
|
- nowYear := time.Now().Year()
|
|
|
+ nowYear := endYear
|
|
|
chartLegendMaxYear := 0
|
|
|
dataMap := make(map[string]models.QuarterXDateItem, 0)
|
|
|
|
|
@@ -744,6 +712,8 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate
|
|
|
dataMap[name] = item
|
|
|
chartLegendMap[name] = idx
|
|
|
idx++
|
|
|
+ xStartDateWithYear = startStr
|
|
|
+ xEndDateWithYear = endStr
|
|
|
fmt.Println("年份" + showName + "日期" + startStr + " " + endStr)
|
|
|
if lastDateT.Before(endT) {
|
|
|
//如果最新的日期在起始日之前,则跳出循环
|
|
@@ -838,7 +808,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate
|
|
|
}
|
|
|
|
|
|
// GetSeasonEdbInfoDataListByXDateNong 季节性图的指标数据根据横轴选择农历时展示
|
|
|
-func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear int) (quarterDataListSort models.QuarterDataList, err error) {
|
|
|
+func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear int) (quarterDataListSort models.QuarterDataList, xStartDateWithYear string, xEndDateWithYear string, err error) {
|
|
|
xStartDate := "01-01"
|
|
|
xEndDate := "12-31"
|
|
|
jumpYear := 0
|
|
@@ -890,7 +860,7 @@ func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDat
|
|
|
return
|
|
|
}
|
|
|
endYear := lastDateT.Year()
|
|
|
- nowYear := time.Now().Year()
|
|
|
+ nowYear := endYear
|
|
|
chartLegendMaxYear := 0
|
|
|
dataMap := make(map[string]models.QuarterXDateItem, 0)
|
|
|
|
|
@@ -943,6 +913,8 @@ func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDat
|
|
|
endTmpT = endT
|
|
|
chartLegendMap[showName] = idx
|
|
|
idx++
|
|
|
+ xStartDateWithYear = startStr
|
|
|
+ xEndDateWithYear = endStr
|
|
|
if lastDateT.Before(endT) {
|
|
|
//如果最新的日期在起始日之前,则跳出循环
|
|
|
break
|
|
@@ -1009,10 +981,10 @@ func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDat
|
|
|
Value: item.Value,
|
|
|
}
|
|
|
dataTimeT, _ := time.Parse(utils.FormatDate, item.DataTime)
|
|
|
- year := dataTimeT.Year()
|
|
|
- newItemDate := dataTimeT.AddDate(nowYear-year, 0, 0)
|
|
|
- timestamp := newItemDate.UnixNano() / 1e6
|
|
|
- tmpVal.DataTimestamp = timestamp
|
|
|
+ // year := dataTimeT.Year()
|
|
|
+ // newItemDate := dataTimeT.AddDate(nowYear-year, 0, 0)
|
|
|
+ // timestamp := newItemDate.UnixNano() / 1e6
|
|
|
+ // tmpVal.DataTimestamp = timestamp
|
|
|
if (startTmpT.Before(dataTimeT) && endTmpT.After(dataTimeT)) || startTmpT == dataTimeT || endTmpT == dataTimeT {
|
|
|
tmpV := &tmpVal
|
|
|
if findVal, ok := quarterMap[name]; !ok {
|
|
@@ -2545,7 +2517,13 @@ func SeasonChartData(dataList []*models.ChartEdbInfoMapping, seasonExtraConfig s
|
|
|
func getEdbDataMapListForSeason(chartInfoId, chartType int, calendar, startDate, endDate string, mappingList []*models.ChartEdbInfoMapping, seasonExtraConfig string) (edbDataListMap map[int][]*models.EdbDataList, edbList []*models.ChartEdbInfoMapping, err error) {
|
|
|
// 指标对应的所有数据
|
|
|
edbDataListMap = make(map[int][]*models.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(models.ChartEdbInfoMapping)
|
|
@@ -2748,82 +2726,45 @@ func getEdbDataMapListForSeason(chartInfoId, chartType int, calendar, startDate,
|
|
|
err = errors.New("获取农历数据失败,Err:" + tmpErr.Error())
|
|
|
return
|
|
|
}
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
+ quarterDataList, xStartDateWithYearTmp, xEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
+ seasonXStartDateWithYear = xStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = xEndDateWithYearTmp
|
|
|
item.DataList = quarterDataList
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- quarterDataList, tErr := GetSeasonEdbInfoDataListByXDate(newDataList, latestDate, seasonExtraConfig)
|
|
|
+ quarterDataList, xStartDateWithYearTmp, xEndDateWithYearTmp, tErr := GetSeasonEdbInfoDataListByXDate(newDataList, latestDate, seasonExtraConfig)
|
|
|
if tErr != nil {
|
|
|
err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
|
|
|
return
|
|
|
}
|
|
|
+ seasonXStartDateWithYear = xStartDateWithYearTmp
|
|
|
+ seasonXEndDateWithYear = xEndDateWithYearTmp
|
|
|
item.DataList = quarterDataList
|
|
|
}
|
|
|
|
|
|
} else if chartType == 2 && item.IsAxis == 0 {
|
|
|
// 右轴数据处理
|
|
|
- xStartDate := "01-01"
|
|
|
-
|
|
|
- jumpYear := 0
|
|
|
- var seasonExtra models.SeasonExtraItem
|
|
|
- if seasonExtraConfig != "" {
|
|
|
- err = json.Unmarshal([]byte(seasonExtraConfig), &seasonExtra)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if seasonExtra.XStartDate != "" {
|
|
|
- xStartDate = seasonExtra.XStartDate
|
|
|
- jumpYear = seasonExtra.JumpYear
|
|
|
- }
|
|
|
-
|
|
|
- length := len(newDataList)
|
|
|
- if length == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
|
|
|
- if tmpErr != nil {
|
|
|
- //item.DataList = newDataList
|
|
|
- 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 {
|
|
|
- latestDate = latestDate.AddDate(-1, 0, 0)
|
|
|
- }
|
|
|
- latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(), xStartDate)
|
|
|
- rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- nowYear := time.Now().Year()
|
|
|
- newList := make([]*models.EdbDataList, 0)
|
|
|
- for _, v := range newDataList {
|
|
|
+ // 右轴数据处理
|
|
|
+ newDataList := make([]*models.EdbDataList, 0)
|
|
|
+ for _, v := range dataList {
|
|
|
dataTime, e := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
if e != nil {
|
|
|
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) {
|
|
|
- newList = append(newList, v)
|
|
|
+ seasonXStartDateWithYearT, _ := time.Parse(utils.FormatDate, seasonXStartDateWithYear)
|
|
|
+ seasonXEndDateWithYearT, _ := time.Parse(utils.FormatDate, seasonXEndDateWithYear)
|
|
|
+
|
|
|
+ if (dataTime.After(seasonXStartDateWithYearT) && dataTime.Before(seasonXEndDateWithYearT)) || dataTime.Equal(seasonXStartDateWithYearT) || dataTime.Equal(seasonXEndDateWithYearT) {
|
|
|
+ newDataList = append(newDataList, v)
|
|
|
}
|
|
|
}
|
|
|
- item.DataList = newList
|
|
|
+ item.DataList = newDataList
|
|
|
} else if chartType == 7 || chartType == utils.CHART_TYPE_RADAR { //柱方图
|
|
|
//item.DataList = newDataList
|
|
|
} else {
|