|
@@ -267,8 +267,8 @@ func RefreshAllPredictCalculate(edbInfoIdList []*EdbInfo, edbInfoId, source int,
|
|
|
func refreshAllPredictCalculate(to orm.TxOrmer, edbInfoIdList []*EdbInfo, edbInfoId, source int, edbCode, formulaStr, startDate string, edbInfoIdBytes []string) (latestDateStr string, latestValue float64, err error) {
|
|
|
fmt.Println("startDate:", startDate)
|
|
|
|
|
|
- // 最小的结束日期 , 最晚的数据开始日期
|
|
|
- var minLatestDate, maxStartDate time.Time
|
|
|
+ // 实际数据最小的结束日期 ,最小的结束日期 , 最晚的数据开始日期
|
|
|
+ var minLatestDate, minEndDate, maxStartDate time.Time
|
|
|
dateList := make([]string, 0) // 第一个指标的日期数据
|
|
|
|
|
|
realSaveDataMap := make(map[string]map[int]float64)
|
|
@@ -277,7 +277,7 @@ func refreshAllPredictCalculate(to orm.TxOrmer, edbInfoIdList []*EdbInfo, edbInf
|
|
|
for edbInfoIndex, v := range edbInfoIdList {
|
|
|
tmpLatestDate, tmpErr := time.ParseInLocation(utils.FormatDate, v.LatestDate, time.Local)
|
|
|
if tmpErr != nil {
|
|
|
- err = errors.New(`最近的日期格式化失败;日期:` + v.EndDate + `;err:` + tmpErr.Error())
|
|
|
+ err = errors.New(`最近的日期格式化失败;日期:` + v.LatestDate + `;err:` + tmpErr.Error())
|
|
|
return
|
|
|
}
|
|
|
if minLatestDate.IsZero() || tmpLatestDate.Before(minLatestDate) {
|
|
@@ -291,6 +291,14 @@ func refreshAllPredictCalculate(to orm.TxOrmer, edbInfoIdList []*EdbInfo, edbInf
|
|
|
if maxStartDate.IsZero() || maxStartDate.Before(tmpStartDate) {
|
|
|
maxStartDate = tmpStartDate
|
|
|
}
|
|
|
+ tmpEndDate, tmpErr := time.ParseInLocation(utils.FormatDate, v.EndDate, time.Local)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = errors.New(`最近的日期格式化失败;日期:` + v.EndDate + `;err:` + tmpErr.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if minEndDate.IsZero() || tmpEndDate.Before(minEndDate) {
|
|
|
+ minEndDate = tmpEndDate
|
|
|
+ }
|
|
|
|
|
|
// 获取关联指标数据
|
|
|
dataList, tmpErr := GetPredictEdbDataListAllByStartDate(v, 1, startDate)
|
|
@@ -327,7 +335,7 @@ func refreshAllPredictCalculate(to orm.TxOrmer, edbInfoIdList []*EdbInfo, edbInf
|
|
|
}
|
|
|
|
|
|
//数据处理,将日期内不全的数据做填补
|
|
|
- handleDateSaveDataMap(dateList, maxStartDate, minLatestDate, realSaveDataMap, saveDataMap, edbInfoIdList)
|
|
|
+ handleDateSaveDataMap(dateList, maxStartDate, minEndDate, realSaveDataMap, saveDataMap, edbInfoIdList)
|
|
|
|
|
|
formulaMap := utils.CheckFormula(formulaStr)
|
|
|
addSql := ` INSERT INTO edb_data_predict_calculate (edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
|