|
@@ -299,13 +299,13 @@ func refreshAllCalculateCorrelation(to orm.TxOrmer, edbInfoId, source int, edbIn
|
|
|
frequencyDaysMap := map[string]int{
|
|
|
"天": 1, "周": 7, "月": 30, "季": 90, "年": 365,
|
|
|
}
|
|
|
- moveUnitDays, ok := frequencyDaysMap[correlationConf.CalculateUnit]
|
|
|
+ moveUnitDays, ok := frequencyDaysMap[correlationConf.BaseCalculateUnit]
|
|
|
if !ok {
|
|
|
errMsg = `错误的分析周期`
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
- startDate := time.Now().AddDate(0, 0, -correlationConf.CalculateValue*moveUnitDays).Format(utils.FormatDate)
|
|
|
+ startDate := time.Now().AddDate(0, 0, -correlationConf.BaseCalculateValue*moveUnitDays).Format(utils.FormatDate)
|
|
|
endDate := time.Now().Format(utils.FormatDate)
|
|
|
correlationChartDataMap, err := GetRollingCorrelationChartDataByEdbInfo(edbInfoA, edbInfoB, correlationConf.LeadValue, correlationConf.LeadUnit, correlationConf.CalculateValue, correlationConf.CalculateUnit, startDate, endDate)
|
|
|
|
|
@@ -379,6 +379,11 @@ func refreshAllCalculateCorrelation(to orm.TxOrmer, edbInfoId, source int, edbIn
|
|
|
// GetRollingCorrelationChartDataByEdbInfo 滚动相关性计算
|
|
|
func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *EdbInfo, leadValue int, leadUnit string, calculateValue int, calculateUnit string, startDate, endDate string) (dateData map[string]float64, err error) {
|
|
|
dateData = make(map[string]float64)
|
|
|
+
|
|
|
+ // 计算窗口,不包含第一天
|
|
|
+ startDateTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
|
|
|
+ startDate = startDateTime.AddDate(0, 0, 1).Format(utils.FormatDate)
|
|
|
+
|
|
|
baseEdbInfo := edbInfoMappingA
|
|
|
changeEdbInfo := edbInfoMappingB
|
|
|
|
|
@@ -475,7 +480,7 @@ func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *E
|
|
|
if len(coordinateData) > 0 {
|
|
|
ratio = utils.ComputeCorrelation(coordinateData)
|
|
|
}
|
|
|
- dateData[currDay.AddDate(0, 0, calculateDay).Format(utils.FormatDate)] = ratio
|
|
|
+ dateData[currDay.AddDate(0, 0, calculateDay-1).Format(utils.FormatDate)] = ratio
|
|
|
}
|
|
|
}
|
|
|
return
|