|
@@ -146,15 +146,15 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
resp.OriginEdbInfo.Frequency = edbInfo.Frequency
|
|
|
resp.OriginEdbInfo.Unit = edbInfo.Unit
|
|
|
resp.OriginEdbInfo.DataList = formatEdbData(edbData)
|
|
|
- resp.TrendChartInfo = trendChart
|
|
|
+ resp.TrendChartInfo.DataList = trendChart.DataList
|
|
|
resp.TrendChartInfo.Title = edbInfo.EdbName + "Trend"
|
|
|
resp.TrendChartInfo.Frequency = edbInfo.Frequency
|
|
|
resp.TrendChartInfo.Unit = edbInfo.Unit
|
|
|
- resp.SeasonalChartInfo = seasonalChart
|
|
|
+ resp.SeasonalChartInfo.DataList = seasonalChart.DataList
|
|
|
resp.SeasonalChartInfo.Title = edbInfo.EdbName + "Seasonal"
|
|
|
resp.SeasonalChartInfo.Frequency = edbInfo.Frequency
|
|
|
resp.SeasonalChartInfo.Unit = edbInfo.Unit
|
|
|
- resp.ResidualChartInfo = residualChart
|
|
|
+ resp.ResidualChartInfo.DataList = residualChart.DataList
|
|
|
resp.ResidualChartInfo.Title = edbInfo.EdbName + "Residual"
|
|
|
resp.ResidualChartInfo.Frequency = edbInfo.Frequency
|
|
|
resp.ResidualChartInfo.Unit = edbInfo.Unit
|
|
@@ -163,9 +163,12 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
resp.EvaluationResult.AdfPValue = strconv.FormatFloat(result.AdfPValue, 'f', -1, 64)
|
|
|
resp.EvaluationResult.LjungBoxPValue = strconv.FormatFloat(result.LbTestPValue, 'f', -1, 64)
|
|
|
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_TREND_CACHE+strconv.Itoa(req.CalculateStlConfigId), trendChart, time.Hour)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), seasonalChart, time.Hour)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_RESIDUAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), residualChart, time.Hour)
|
|
|
+ bTrend, _ := json.Marshal(trendChart.DataList)
|
|
|
+ bSeasonal, _ := json.Marshal(seasonalChart.DataList)
|
|
|
+ bResidual, _ := json.Marshal(residualChart.DataList)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_TREND_CACHE+strconv.Itoa(req.CalculateStlConfigId), bTrend, time.Hour*2)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), bSeasonal, time.Hour*2)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_RESIDUAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), bResidual, time.Hour*2)
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -200,8 +203,15 @@ func ParseStlExcel(excelPath string) (TrendChart, SeasonalChart, ResidualChart r
|
|
|
if i == 0 {
|
|
|
continue
|
|
|
}
|
|
|
- date := row.Cells[0].String()
|
|
|
- date = strings.Split(date, " ")[0]
|
|
|
+ var date string
|
|
|
+ if row.Cells[0].Type() == xlsx.CellTypeNumeric {
|
|
|
+ dataNum, _ := strconv.ParseFloat(row.Cells[0].Value, 64)
|
|
|
+ tmpTime := xlsx.TimeFromExcelTime(dataNum, false)
|
|
|
+ date = tmpTime.Format(utils.FormatDate)
|
|
|
+ } else {
|
|
|
+ date = row.Cells[0].String()
|
|
|
+ date = strings.Split(date, " ")[0]
|
|
|
+ }
|
|
|
fv, _ := row.Cells[1].Float()
|
|
|
value := strconv.FormatFloat(fv, 'f', 4, 64)
|
|
|
SeasonalChart.DataList = append(SeasonalChart.DataList, &response.EdbData{DataTime: date, Value: value})
|
|
@@ -211,8 +221,15 @@ func ParseStlExcel(excelPath string) (TrendChart, SeasonalChart, ResidualChart r
|
|
|
if i == 0 {
|
|
|
continue
|
|
|
}
|
|
|
- date := row.Cells[0].String()
|
|
|
- date = strings.Split(date, " ")[0]
|
|
|
+ var date string
|
|
|
+ if row.Cells[0].Type() == xlsx.CellTypeNumeric {
|
|
|
+ dataNum, _ := strconv.ParseFloat(row.Cells[0].Value, 64)
|
|
|
+ tmpTime := xlsx.TimeFromExcelTime(dataNum, false)
|
|
|
+ date = tmpTime.Format(utils.FormatDate)
|
|
|
+ } else {
|
|
|
+ date = row.Cells[0].String()
|
|
|
+ date = strings.Split(date, " ")[0]
|
|
|
+ }
|
|
|
fv, _ := row.Cells[1].Float()
|
|
|
value := strconv.FormatFloat(fv, 'f', 4, 64)
|
|
|
TrendChart.DataList = append(TrendChart.DataList, &response.EdbData{DataTime: date, Value: value})
|
|
@@ -222,8 +239,15 @@ func ParseStlExcel(excelPath string) (TrendChart, SeasonalChart, ResidualChart r
|
|
|
if i == 0 {
|
|
|
continue
|
|
|
}
|
|
|
- date := row.Cells[0].String()
|
|
|
- date = strings.Split(date, " ")[0]
|
|
|
+ var date string
|
|
|
+ if row.Cells[0].Type() == xlsx.CellTypeNumeric {
|
|
|
+ dataNum, _ := strconv.ParseFloat(row.Cells[0].Value, 64)
|
|
|
+ tmpTime := xlsx.TimeFromExcelTime(dataNum, false)
|
|
|
+ date = tmpTime.Format(utils.FormatDate)
|
|
|
+ } else {
|
|
|
+ date = row.Cells[0].String()
|
|
|
+ date = strings.Split(date, " ")[0]
|
|
|
+ }
|
|
|
fv, _ := row.Cells[1].Float()
|
|
|
value := strconv.FormatFloat(fv, 'f', 4, 64)
|
|
|
ResidualChart.DataList = append(ResidualChart.DataList, &response.EdbData{DataTime: date, Value: value})
|
|
@@ -616,7 +640,7 @@ func SaveStlEdbInfo(req *request.SaveStlEdbInfoReq, adminId int, adminRealName,
|
|
|
Value: value,
|
|
|
CreateTime: time.Now(),
|
|
|
ModifyTime: time.Now(),
|
|
|
- DataTimestamp: time.Now().UnixMilli(),
|
|
|
+ DataTimestamp: dataTime.UnixMilli(),
|
|
|
})
|
|
|
}
|
|
|
err = indexObj.BatchInsert(dataList)
|
|
@@ -676,6 +700,8 @@ func SaveStlEdbInfo(req *request.SaveStlEdbInfoReq, adminId int, adminRealName,
|
|
|
edbInfo.MinValue = itemVal.MinValue
|
|
|
}
|
|
|
edbInfo.EdbType = 2
|
|
|
+ edbInfo.Source = source
|
|
|
+ edbInfo.SubSource = subSource
|
|
|
extra, _ := json.Marshal(req)
|
|
|
edbInfo.Extra = string(extra)
|
|
|
edbInfoId, err := data_manage.AddEdbInfo(edbInfo)
|
|
@@ -725,7 +751,7 @@ func SaveStlEdbInfo(req *request.SaveStlEdbInfoReq, adminId int, adminRealName,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- edbCalculateMappingInfo := new(data_manage.EdbInfoCalculateMappingInfo)
|
|
|
+ edbCalculateMappingInfo := new(data_manage.EdbInfoCalculateMapping)
|
|
|
edbCalculateMappingInfo.EdbInfoId = int(edbInfoId)
|
|
|
edbCalculateMappingInfo.Source = source
|
|
|
edbCalculateMappingInfo.SourceName = "STL趋势分解"
|
|
@@ -735,10 +761,6 @@ func SaveStlEdbInfo(req *request.SaveStlEdbInfoReq, adminId int, adminRealName,
|
|
|
edbCalculateMappingInfo.FromEdbName = fromEdbInfo.EdbName
|
|
|
edbCalculateMappingInfo.FromSource = fromEdbInfo.Source
|
|
|
edbCalculateMappingInfo.FromSourceName = fromEdbInfo.SourceName
|
|
|
- edbCalculateMappingInfo.FromEdbType = fromEdbInfo.EdbType
|
|
|
- edbCalculateMappingInfo.FromEdbInfoType = fromEdbInfo.EdbInfoType
|
|
|
- edbCalculateMappingInfo.FromClassifyId = fromEdbInfo.ClassifyId
|
|
|
- edbCalculateMappingInfo.FromUniqueCode = fromEdbInfo.UniqueCode
|
|
|
edbCalculateMappingInfo.CreateTime = time.Now()
|
|
|
edbCalculateMappingInfo.ModifyTime = time.Now()
|
|
|
err = edbCalculateMappingInfo.Insert()
|