|
@@ -0,0 +1,592 @@
|
|
|
+package area_graph
|
|
|
+
|
|
|
+import (
|
|
|
+ "errors"
|
|
|
+ "eta/eta_mobile/models/data_manage"
|
|
|
+ "eta/eta_mobile/utils"
|
|
|
+ "github.com/shopspring/decimal"
|
|
|
+ "math"
|
|
|
+ "sort"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type InterpolateStrategy struct{}
|
|
|
+
|
|
|
+
|
|
|
+func (i *InterpolateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) (err error) {
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if v.EdbInfoId != tmpConfig.StandardEdbInfoId {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+
|
|
|
+ var replenishDataList []*data_manage.EdbDataList
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ firstData := dataList[0]
|
|
|
+
|
|
|
+ startDataTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
+ firstDataTime, _ := time.ParseInLocation(utils.FormatDate, firstData.DataTime, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !startDataTime.Equal(firstDataTime) {
|
|
|
+ for startDataTime.Before(firstDataTime) {
|
|
|
+
|
|
|
+ nextDay := startDataTime.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: startDataTime.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ startDataTime = startDataTime.AddDate(0, 0, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var startEdbInfoData *data_manage.EdbDataList
|
|
|
+ for index := 0; index < len(dataList); index++ {
|
|
|
+
|
|
|
+ currentIndexData := dataList[index]
|
|
|
+
|
|
|
+
|
|
|
+ if startEdbInfoData == nil {
|
|
|
+ startEdbInfoData = currentIndexData
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ startDataTime, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
|
|
|
+ currDataTime, _ := time.ParseInLocation(utils.FormatDate, currentIndexData.DataTime, time.Local)
|
|
|
+ betweenHour := int(currDataTime.Sub(startDataTime).Hours())
|
|
|
+ betweenDay := betweenHour / 24
|
|
|
+
|
|
|
+
|
|
|
+ if betweenDay <= 1 {
|
|
|
+ startEdbInfoData = currentIndexData
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var a, b float64
|
|
|
+ {
|
|
|
+ coordinateData := make([]utils.Coordinate, 0)
|
|
|
+ tmpCoordinate1 := utils.Coordinate{
|
|
|
+ X: 1,
|
|
|
+ Y: startEdbInfoData.Value,
|
|
|
+ }
|
|
|
+ coordinateData = append(coordinateData, tmpCoordinate1)
|
|
|
+ tmpCoordinate2 := utils.Coordinate{
|
|
|
+ X: float64(betweenDay) + 1,
|
|
|
+ Y: currentIndexData.Value,
|
|
|
+ }
|
|
|
+ coordinateData = append(coordinateData, tmpCoordinate2)
|
|
|
+
|
|
|
+ a, b = utils.GetLinearResult(coordinateData)
|
|
|
+ if math.IsNaN(a) || math.IsNaN(b) {
|
|
|
+ err = errors.New("线性方程公式生成失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for i := 1; i < betweenDay; i++ {
|
|
|
+ tmpDataTime := startDataTime.AddDate(0, 0, i)
|
|
|
+ aDecimal := decimal.NewFromFloat(a)
|
|
|
+ xDecimal := decimal.NewFromInt(int64(i) + 1)
|
|
|
+ bDecimal := decimal.NewFromFloat(b)
|
|
|
+
|
|
|
+ val, _ := aDecimal.Mul(xDecimal).Add(bDecimal).Round(4).Float64()
|
|
|
+ nextDay := tmpDataTime.Format(utils.FormatDate)
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbDataId: currentIndexData.EdbDataId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: tmpDataTime.UnixMilli(),
|
|
|
+ Value: val,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+ }
|
|
|
+ startEdbInfoData = currentIndexData
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ lastData := dataList[len(dataList)-1]
|
|
|
+
|
|
|
+ lastDataTime, _ := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
|
|
|
+ endDataTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !lastDataTime.Equal(endDataTime) {
|
|
|
+
|
|
|
+ for lastDataTime.Before(endDataTime) {
|
|
|
+
|
|
|
+ addDate := lastDataTime.AddDate(0, 0, 1)
|
|
|
+ nextDay := addDate.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: addDate.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ lastDataTime = addDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList = append(dataList, replenishDataList...)
|
|
|
+
|
|
|
+
|
|
|
+ var resultDataList []*data_manage.EdbDataList
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ if _, ok := standardIndexMap[dataObject.DataTime]; ok {
|
|
|
+
|
|
|
+ resultDataList = append(resultDataList, dataObject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sort.Slice(resultDataList, func(i, j int) bool {
|
|
|
+ return resultDataList[i].DataTimestamp < resultDataList[j].DataTimestamp
|
|
|
+ })
|
|
|
+
|
|
|
+ v.DataList = resultDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type FillWithPreviousStrategy struct{}
|
|
|
+
|
|
|
+
|
|
|
+func (f *FillWithPreviousStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) (err error) {
|
|
|
+
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if v.EdbInfoId != tmpConfig.StandardEdbInfoId {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+ var replenishDataList []*data_manage.EdbDataList
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ firstData := dataList[0]
|
|
|
+
|
|
|
+ startDataTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
+ firstDataTime, _ := time.ParseInLocation(utils.FormatDate, firstData.DataTime, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !startDataTime.Equal(firstDataTime) {
|
|
|
+ for startDataTime.Before(firstDataTime) {
|
|
|
+
|
|
|
+ nextDay := startDataTime.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: startDataTime.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ startDataTime = startDataTime.AddDate(0, 0, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for index := 0; index < len(dataList)-1; index++ {
|
|
|
+
|
|
|
+ beforeIndexData := dataList[index]
|
|
|
+ afterIndexData := dataList[index+1]
|
|
|
+
|
|
|
+ for utils.IsMoreThanOneDay(beforeIndexData.DataTime, afterIndexData.DataTime) {
|
|
|
+
|
|
|
+ nextDay := utils.GetNextDay(beforeIndexData.DataTime)
|
|
|
+
|
|
|
+ toTime := utils.StringToTime(nextDay)
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: toTime.UnixMilli(),
|
|
|
+ Value: beforeIndexData.Value,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ beforeIndexData = &replenishIndexData
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ lastData := dataList[len(dataList)-1]
|
|
|
+
|
|
|
+ lastDataTime, _ := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
|
|
|
+ endDataTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !lastDataTime.Equal(endDataTime) {
|
|
|
+
|
|
|
+ for lastDataTime.Before(endDataTime) {
|
|
|
+
|
|
|
+ addDate := lastDataTime.AddDate(0, 0, 1)
|
|
|
+ nextDay := addDate.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: addDate.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ lastDataTime = addDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList = append(dataList, replenishDataList...)
|
|
|
+
|
|
|
+
|
|
|
+ var resultDataList []*data_manage.EdbDataList
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ _, ok = standardIndexMap[dataObject.DataTime]
|
|
|
+ if ok {
|
|
|
+
|
|
|
+ resultDataList = append(resultDataList, dataObject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sort.Slice(resultDataList, func(i, j int) bool {
|
|
|
+ return resultDataList[i].DataTimestamp < resultDataList[j].DataTimestamp
|
|
|
+ })
|
|
|
+
|
|
|
+ v.DataList = resultDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type FillWithNextStrategy struct{}
|
|
|
+
|
|
|
+
|
|
|
+func (f *FillWithNextStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) (err error) {
|
|
|
+
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if v.EdbInfoId != tmpConfig.StandardEdbInfoId {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+
|
|
|
+ var replenishDataList []*data_manage.EdbDataList
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ firstData := dataList[0]
|
|
|
+
|
|
|
+ startDataTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
+ firstDataTime, _ := time.ParseInLocation(utils.FormatDate, firstData.DataTime, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !startDataTime.Equal(firstDataTime) {
|
|
|
+ for !startDataTime.After(firstDataTime) {
|
|
|
+
|
|
|
+ nextDay := startDataTime.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: startDataTime.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ startDataTime = startDataTime.AddDate(0, 0, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ lastData := dataList[len(dataList)-1]
|
|
|
+
|
|
|
+ lastDataTime, _ := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
|
|
|
+ endDataTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !lastDataTime.Equal(endDataTime) {
|
|
|
+
|
|
|
+ for lastDataTime.Before(endDataTime) {
|
|
|
+
|
|
|
+ addDate := lastDataTime.AddDate(0, 0, 1)
|
|
|
+ nextDay := addDate.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: addDate.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ lastDataTime = addDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ reverseSlice(dataList)
|
|
|
+
|
|
|
+
|
|
|
+ for index := 0; index < len(dataList)-1; index++ {
|
|
|
+
|
|
|
+ beforeIndexData := dataList[index]
|
|
|
+ afterIndexData := dataList[index+1]
|
|
|
+
|
|
|
+ for utils.IsMoreThanOneDay(afterIndexData.DataTime, beforeIndexData.DataTime) {
|
|
|
+
|
|
|
+ nextDay := utils.GetNextDay(afterIndexData.DataTime)
|
|
|
+
|
|
|
+ toTime := utils.StringToTime(nextDay)
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: toTime.UnixMilli(),
|
|
|
+ Value: beforeIndexData.Value,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ afterIndexData = &replenishIndexData
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList = append(dataList, replenishDataList...)
|
|
|
+
|
|
|
+
|
|
|
+ var resultDataList []*data_manage.EdbDataList
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ _, ok = standardIndexMap[dataObject.DataTime]
|
|
|
+ if ok {
|
|
|
+
|
|
|
+ resultDataList = append(resultDataList, dataObject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sort.Slice(resultDataList, func(i, j int) bool {
|
|
|
+ return resultDataList[i].DataTimestamp < resultDataList[j].DataTimestamp
|
|
|
+ })
|
|
|
+
|
|
|
+ v.DataList = resultDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type SetToZeroStrategy struct{}
|
|
|
+
|
|
|
+
|
|
|
+func (s *SetToZeroStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) (err error) {
|
|
|
+
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if v.EdbInfoId != tmpConfig.StandardEdbInfoId {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+ var replenishDataList []*data_manage.EdbDataList
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ firstData := dataList[0]
|
|
|
+
|
|
|
+ startDataTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
+ firstDataTime, _ := time.ParseInLocation(utils.FormatDate, firstData.DataTime, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !startDataTime.Equal(firstDataTime) {
|
|
|
+ for startDataTime.Before(firstDataTime) {
|
|
|
+
|
|
|
+ nextDay := startDataTime.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: startDataTime.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ startDataTime = startDataTime.AddDate(0, 0, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for index := 0; index < len(dataList)-1; index++ {
|
|
|
+
|
|
|
+ beforeIndexData := dataList[index]
|
|
|
+ afterIndexData := dataList[index+1]
|
|
|
+
|
|
|
+ for utils.IsMoreThanOneDay(beforeIndexData.DataTime, afterIndexData.DataTime) {
|
|
|
+
|
|
|
+ nextDay := utils.GetNextDay(beforeIndexData.DataTime)
|
|
|
+
|
|
|
+ toTime := utils.StringToTime(nextDay)
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: toTime.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ beforeIndexData = &replenishIndexData
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(dataList) > 0 {
|
|
|
+ lastData := dataList[len(dataList)-1]
|
|
|
+
|
|
|
+ lastDataTime, _ := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
|
|
|
+ endDataTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
|
|
|
+
|
|
|
+
|
|
|
+ if !lastDataTime.Equal(endDataTime) {
|
|
|
+
|
|
|
+ for lastDataTime.Before(endDataTime) {
|
|
|
+
|
|
|
+ addDate := lastDataTime.AddDate(0, 0, 1)
|
|
|
+ nextDay := addDate.Format(utils.FormatDate)
|
|
|
+
|
|
|
+
|
|
|
+ replenishIndexData := data_manage.EdbDataList{
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ DataTime: nextDay,
|
|
|
+ DataTimestamp: addDate.UnixMilli(),
|
|
|
+ Value: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ replenishDataList = append(replenishDataList, &replenishIndexData)
|
|
|
+
|
|
|
+
|
|
|
+ lastDataTime = addDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList = append(dataList, replenishDataList...)
|
|
|
+
|
|
|
+
|
|
|
+ var resultDataList []*data_manage.EdbDataList
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ _, ok = standardIndexMap[dataObject.DataTime]
|
|
|
+ if ok {
|
|
|
+
|
|
|
+ resultDataList = append(resultDataList, dataObject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sort.Slice(resultDataList, func(i, j int) bool {
|
|
|
+ return resultDataList[i].DataTimestamp < resultDataList[j].DataTimestamp
|
|
|
+ })
|
|
|
+
|
|
|
+ v.DataList = resultDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+type DeleteDateStrategy struct{}
|
|
|
+
|
|
|
+
|
|
|
+func (d *DeleteDateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataList []*data_manage.ChartEdbInfoMapping, standardIndexMap map[string]*data_manage.EdbDataList, startDate string, endDate string) error {
|
|
|
+
|
|
|
+
|
|
|
+ timeMap := make(map[string]int)
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ timeMap[dataObject.DataTime]++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+
|
|
|
+ var resultDataList []*data_manage.EdbDataList
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ if timeMap[dataObject.DataTime] == len(edbDataList) {
|
|
|
+
|
|
|
+ resultDataList = append(resultDataList, dataObject)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ v.DataList = resultDataList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func reverseSlice(dataList []*data_manage.EdbDataList) {
|
|
|
+
|
|
|
+ for i, j := 0, len(dataList)-1; i < j; i, j = i+1, j-1 {
|
|
|
+
|
|
|
+ dataList[i], dataList[j] = dataList[j], dataList[i]
|
|
|
+ }
|
|
|
+}
|