|
@@ -1537,16 +1537,24 @@ type AnnualValueInversionConf struct {
|
|
|
YearList []int `description:"指定年份列表"`
|
|
|
}
|
|
|
|
|
|
-func getReplaceValue(replaceValueMap map[string]float64, days, dayStep int, currentDate time.Time) (replaceValue decimal.Decimal, success bool) {
|
|
|
+func getReplaceValue(replaceValueMap map[string]float64, days, dayStepForward int,dayStepBack int, currentDate time.Time) (replaceValue decimal.Decimal, success bool) {
|
|
|
nextDateDay := currentDate
|
|
|
+ backDateDay := currentDate
|
|
|
for i := 0; i <= days; i++ {
|
|
|
- replaceDateDayStr := nextDateDay.Format(utils.FormatDate)
|
|
|
- if preValue, ok := replaceValueMap[replaceDateDayStr]; ok { //上一年同期->下一个月找到
|
|
|
+ nextDateDayStr := nextDateDay.Format(utils.FormatDate)
|
|
|
+ if preValue, ok := replaceValueMap[nextDateDayStr]; ok { //上一年同期->下一个月找到
|
|
|
replaceValue = decimal.NewFromFloat(preValue)
|
|
|
success = true
|
|
|
return
|
|
|
}
|
|
|
- nextDateDay = nextDateDay.AddDate(0, 0, dayStep)
|
|
|
+ backDateDayStr := backDateDay.Format(utils.FormatDate)
|
|
|
+ if backValue,ok:=replaceValueMap[backDateDayStr]; ok { //上一年同期->下一个月找到
|
|
|
+ replaceValue = decimal.NewFromFloat(backValue)
|
|
|
+ success = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ nextDateDay = nextDateDay.AddDate(0, 0, dayStepForward)
|
|
|
+ backDateDay = nextDateDay.AddDate(0, 0, dayStepBack)
|
|
|
}
|
|
|
return decimal.NewFromInt(0), false
|
|
|
}
|
|
@@ -1602,14 +1610,8 @@ func GetChartPredictEdbInfoDataListByRuleDynamicYOYComparisonOrDifference(ruleTy
|
|
|
baseDynamicDataList[preDateStr] = decimal.NewFromFloat(preValue)
|
|
|
predictDayList = append(predictDayList, date)
|
|
|
} else {
|
|
|
- if replaceValue, replaceOk := getReplaceValue(existMap, 35, -1, preDate); !replaceOk {
|
|
|
- replaceValue, replaceOk = getReplaceValue(existMap, 35, 1, preDate)
|
|
|
- if !replaceOk {
|
|
|
- continue
|
|
|
- } else {
|
|
|
- baseDynamicDataList[preDateStr] = replaceValue
|
|
|
- predictDayList = append(predictDayList, date)
|
|
|
- }
|
|
|
+ if replaceValue, replaceOk := getReplaceValue(existMap, 35, 1,-1, preDate); !replaceOk {
|
|
|
+ continue
|
|
|
} else {
|
|
|
baseDynamicDataList[preDateStr] = replaceValue
|
|
|
predictDayList = append(predictDayList, date)
|