|
@@ -291,21 +291,20 @@ func refreshAllCalculateCorrelation(to orm.TxOrmer, edbInfoId, source int, edbIn
|
|
|
removeDateMap[v.DataTime] = ``
|
|
|
}
|
|
|
var correlationConf EdbCalculateFormula
|
|
|
- fmt.Println("calculateFormula:", calculateFormula)
|
|
|
+
|
|
|
err = json.Unmarshal([]byte(calculateFormula), &correlationConf)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- frequencyDaysMap := map[string]int{
|
|
|
- "天": 1, "周": 7, "月": 30, "季": 90, "年": 365,
|
|
|
- }
|
|
|
- moveUnitDays, ok := frequencyDaysMap[correlationConf.BaseCalculateUnit]
|
|
|
- if !ok {
|
|
|
- errMsg = `错误的分析周期`
|
|
|
- err = errors.New(errMsg)
|
|
|
- return
|
|
|
+ aStartDate, _ := time.ParseInLocation(utils.FormatDate, edbInfoA.StartDate, time.Local)
|
|
|
+ bStartDate, _ := time.ParseInLocation(utils.FormatDate, edbInfoB.StartDate, time.Local)
|
|
|
+ var startDateTime time.Time
|
|
|
+ if aStartDate.Before(bStartDate) {
|
|
|
+ startDateTime = aStartDate
|
|
|
+ } else {
|
|
|
+ startDateTime = bStartDate
|
|
|
}
|
|
|
- startDate := time.Now().AddDate(0, 0, -correlationConf.BaseCalculateValue*moveUnitDays).Format(utils.FormatDate)
|
|
|
+ startDate := startDateTime.Format(utils.FormatDate)
|
|
|
endDate := time.Now().Format(utils.FormatDate)
|
|
|
correlationChartDataMap, err := GetRollingCorrelationChartDataByEdbInfo(edbInfoA, edbInfoB, correlationConf.LeadValue, correlationConf.LeadUnit, correlationConf.CalculateValue, correlationConf.CalculateUnit, startDate, endDate)
|
|
|
|