|
@@ -411,7 +411,7 @@ func ProfitChartChartData(baseDataList []*models.EdbDataList, futureGoodEdbInfoM
|
|
|
xEdbInfoIdList := make([]int, 0)
|
|
|
|
|
|
|
|
|
- realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, baseDataList, baseEdbDateData)
|
|
|
+ realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, baseDataList, baseEdbDateData, edbDataMap)
|
|
|
if tmpErr != nil {
|
|
|
err = tmpErr
|
|
|
return
|
|
@@ -437,7 +437,9 @@ func ProfitChartChartData(baseDataList []*models.EdbDataList, futureGoodEdbInfoM
|
|
|
|
|
|
|
|
|
|
|
|
- tmpN := (currDate.Year()-findDateTime.Year())*12 + int(currDate.Month()-findDateTime.Month())
|
|
|
+
|
|
|
+
|
|
|
+ tmpN := (currDate.Year()-realDateTime.Year())*12 + int(currDate.Month()-realDateTime.Month())
|
|
|
if tmpN <= 0 {
|
|
|
continue
|
|
|
}
|
|
@@ -834,7 +836,7 @@ func GetFormulaMap() map[string]string {
|
|
|
}
|
|
|
|
|
|
|
|
|
-func GetNeedDateData(needDateTime time.Time, dataList []*models.EdbDataList, edbDataMap map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
|
|
|
+func GetNeedDateData(needDateTime time.Time, dataList []*models.EdbDataList, edbDataMap map[string]float64, allEdbDataMap map[int]map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
|
|
|
|
|
|
if len(dataList) <= 0 {
|
|
|
|
|
@@ -847,18 +849,43 @@ func GetNeedDateData(needDateTime time.Time, dataList []*models.EdbDataList, edb
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ maxCount := 1
|
|
|
+
|
|
|
for tmpDateTime := needDateTime; tmpDateTime.After(minDateTime) || tmpDateTime.Equal(minDateTime); tmpDateTime = tmpDateTime.AddDate(0, 0, -1) {
|
|
|
tmpDate := tmpDateTime.Format(utils.FormatDate)
|
|
|
- if tmpValue, ok := edbDataMap[tmpDate]; ok {
|
|
|
-
|
|
|
- if tmpValue == 0 {
|
|
|
- return
|
|
|
+ tmpValue, ok := edbDataMap[tmpDate]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ count := 0
|
|
|
+
|
|
|
+ for _, currEdbDataMap := range allEdbDataMap {
|
|
|
+ _, tmpIsFind := currEdbDataMap[tmpDate]
|
|
|
+ if tmpIsFind {
|
|
|
+ count++
|
|
|
+ if count >= maxCount {
|
|
|
+ continue
|
|
|
+ }
|
|
|
}
|
|
|
- findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
|
|
|
- findDataValue = tmpValue
|
|
|
- isFind = true
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if count < maxCount {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if tmpValue == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
|
|
|
+ findDataValue = tmpValue
|
|
|
+ isFind = true
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
return
|