|
@@ -564,11 +564,13 @@ func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *d
|
|
|
}
|
|
|
|
|
|
// ChartInfoRefresh 图表刷新
|
|
|
-func ChartInfoRefresh(chartInfoId int) (err error) {
|
|
|
+func ChartInfoRefresh(chartInfoId int, uniqueCode string) (isAsync bool, err error) {
|
|
|
var errMsg string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- go alarm_msg.SendAlarmMsg("CorrelationChartInfoRefresh: "+errMsg, 3)
|
|
|
+ tips := fmt.Sprintf("CorrelationChartInfoRefresh: %s", errMsg)
|
|
|
+ utils.FileLog.Info(tips)
|
|
|
+ go alarm_msg.SendAlarmMsg(tips, 3)
|
|
|
}
|
|
|
}()
|
|
|
correlationChart := new(data_manage.ChartInfoCorrelation)
|
|
@@ -577,6 +579,53 @@ func ChartInfoRefresh(chartInfoId int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 多因子刷新-异步
|
|
|
+ if correlationChart.AnalysisMode == 1 {
|
|
|
+ isAsync = true
|
|
|
+
|
|
|
+ go func() {
|
|
|
+ // 1.刷新图表关联的指标
|
|
|
+ mappings, e := data_manage.GetChartEdbMappingList(chartInfoId)
|
|
|
+ if e != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("获取图表关联指标失败, err: %v", e))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(mappings) == 0 {
|
|
|
+ utils.FileLog.Info("图表无关联指标")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var edbIds []int
|
|
|
+ for _, v := range mappings {
|
|
|
+ edbIds = append(edbIds, v.EdbInfoId)
|
|
|
+ }
|
|
|
+ if e, _ = data.EdbInfoRefreshAllFromBaseV3(edbIds, false, true, false); e != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("批量刷新指标失败, err: %v", e))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.刷新指标系列计算数据
|
|
|
+ for _, v := range mappings {
|
|
|
+ _, e = data.PostRefreshFactorEdbRecalculate(v.EdbInfoId, v.EdbCode)
|
|
|
+ if e != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("PostRefreshFactorEdbRecalculate err: %v", e))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.刷新图表矩阵
|
|
|
+ _, e = data.PostRefreshFactorEdbChartRecalculate(chartInfoId)
|
|
|
+ if e != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("PostRefreshFactorEdbRecalculate err: %v", e))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4.清除图表缓存
|
|
|
+ key := utils.HZ_CHART_LIB_DETAIL + uniqueCode
|
|
|
+ _ = utils.Rc.Delete(key)
|
|
|
+ }()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 批量刷新ETA指标
|
|
|
err, _ = data.EdbInfoRefreshAllFromBaseV3([]int{correlationChart.EdbInfoIdFirst, correlationChart.EdbInfoIdSecond}, false, true, false)
|
|
|
if err != nil {
|
|
@@ -1241,16 +1290,20 @@ func GetFactorChartDataByChartId(chartInfoId int, extraConfig string) (xEdbIdVal
|
|
|
}
|
|
|
|
|
|
// 获取图表引用到的系列指标
|
|
|
- edbMappings, e := data_manage.GetChartUsedFactorSeriesEdb(chartInfoId)
|
|
|
+ chartMappingOb := new(data_manage.FactorEdbSeriesChartMapping)
|
|
|
+ cond := fmt.Sprintf(" AND %s = ? AND %s = 1", chartMappingOb.Cols().ChartInfoId, chartMappingOb.Cols().EdbUsed)
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, chartInfoId)
|
|
|
+ chartMappings, e := chartMappingOb.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
if e != nil {
|
|
|
- err = fmt.Errorf("获取图表引用系列指标失败, err: %v", e)
|
|
|
+ err = fmt.Errorf("获取图表引用系列指标失败")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 取出计算结果
|
|
|
yDataList = make([]data_manage.YData, 0)
|
|
|
yDate := "0000-00-00"
|
|
|
- for k, m := range edbMappings {
|
|
|
+ for k, m := range chartMappings {
|
|
|
var values []data_manage.FactorEdbSeriesCorrelationMatrixValues
|
|
|
if m.CalculateData != "" {
|
|
|
e = json.Unmarshal([]byte(m.CalculateData), &values)
|