|
@@ -1070,11 +1070,19 @@ func (this *CorrelationChartInfoController) Refresh() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if e := correlationServ.ChartInfoRefresh(chartInfo.ChartInfoId); e != nil {
|
|
|
+ isAsync, e := correlationServ.ChartInfoRefresh(chartInfo.ChartInfoId, chartInfo.UniqueCode)
|
|
|
+ if e != nil {
|
|
|
br.Msg = "刷新失败"
|
|
|
br.ErrMsg = "刷新相关性图表失败, Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ if isAsync {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "刷新时间较长, 请10分钟后查看"
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
|
|
|
{
|
|
@@ -2146,7 +2154,7 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
|
}()
|
|
|
|
|
|
chartType := 9
|
|
|
- chartSource := utils.CHART_SOURCE_CORRELATION
|
|
|
+ chartSource := utils.CHART_SOURCE_CORRELATION
|
|
|
startDate := time.Now().AddDate(0, 0, -calculateDays).Format(utils.FormatDate)
|
|
|
endDate := time.Now().Format(utils.FormatDate)
|
|
|
mappingEdbIds := make([]int, 0)
|
|
@@ -2266,19 +2274,47 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- seriesMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
+ chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
+ seriesIds := make([]int, 0)
|
|
|
+ seriesIdExist := make(map[int]bool)
|
|
|
+ edbUsed := make(map[string]bool)
|
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
|
- seriesMappings = append(seriesMappings, &data_manage.FactorEdbSeriesChartMapping{
|
|
|
- FactorEdbSeriesId: v.SeriesId,
|
|
|
- EdbInfoId: v.EdbInfoId,
|
|
|
- Source: chartSource,
|
|
|
- CreateTime: time.Now().Local(),
|
|
|
- ModifyTime: time.Now().Local(),
|
|
|
- })
|
|
|
+ if !seriesIdExist[v.SeriesId] {
|
|
|
+ seriesIds = append(seriesIds, v.SeriesId)
|
|
|
+ }
|
|
|
+ k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
|
+ edbUsed[k] = true
|
|
|
+ }
|
|
|
+ if len(seriesIds) == 0 {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("指标系列异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ {
|
|
|
+
|
|
|
+ ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
|
+ cond := fmt.Sprintf(" AND %s IN (%s) AND %s = 0", ob.Cols().FactorEdbSeriesId, utils.GetOrmInReplace(len(seriesIds)), ob.Cols().ChartInfoId)
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, seriesIds)
|
|
|
+ items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取指标系列图表关联失败, Err: %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chartMappings = items
|
|
|
+ }
|
|
|
+ for _, v := range chartMappings {
|
|
|
+ v.Source = chartSource
|
|
|
+ k := fmt.Sprintf("%d-%d", v.FactorEdbSeriesId, v.EdbInfoId)
|
|
|
+ if edbUsed[k] {
|
|
|
+ v.EdbUsed = 1
|
|
|
+ }
|
|
|
+ v.ModifyTime = time.Now().Local()
|
|
|
}
|
|
|
|
|
|
|
|
|
- chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, seriesMappings)
|
|
|
+ chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, chartMappings)
|
|
|
if e != nil {
|
|
|
br.Msg = "保存失败"
|
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
@@ -2548,20 +2584,37 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
|
|
|
edbMappings = append(edbMappings, m)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- seriesMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
+ edbUsed := make(map[string]bool)
|
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
|
- seriesMappings = append(seriesMappings, &data_manage.FactorEdbSeriesChartMapping{
|
|
|
- FactorEdbSeriesId: v.SeriesId,
|
|
|
- EdbInfoId: v.EdbInfoId,
|
|
|
- Source: chartSource,
|
|
|
- CreateTime: time.Now().Local(),
|
|
|
- ModifyTime: time.Now().Local(),
|
|
|
- })
|
|
|
+ k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
|
+ edbUsed[k] = true
|
|
|
+ }
|
|
|
+
|
|
|
+ chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
+ {
|
|
|
+ ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
|
+ cond := fmt.Sprintf(" AND %s = ?", ob.Cols().ChartInfoId)
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, chartInfo.ChartInfoId)
|
|
|
+ items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取指标系列图表关联失败, Err: %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chartMappings = items
|
|
|
+ }
|
|
|
+ for _, v := range chartMappings {
|
|
|
+ k := fmt.Sprintf("%d-%d", v.FactorEdbSeriesId, v.EdbInfoId)
|
|
|
+ v.EdbUsed = 0
|
|
|
+ if edbUsed[k] {
|
|
|
+ v.EdbUsed = 1
|
|
|
+ }
|
|
|
+ v.ModifyTime = time.Now().Local()
|
|
|
}
|
|
|
|
|
|
|
|
|
- e = data_manage.UpdateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, seriesMappings, chartUpdateCols, correlateUpdateCols)
|
|
|
+ e = data_manage.UpdateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, chartMappings, chartUpdateCols, correlateUpdateCols)
|
|
|
if e != nil {
|
|
|
br.Msg = "保存失败"
|
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
@@ -2694,16 +2747,14 @@ func (this *CorrelationChartInfoController) MultiFactorDetail() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- factorUsed := make(map[string]bool)
|
|
|
seriesIds := make([]int, 0)
|
|
|
seriesIdExist := make(map[int]bool)
|
|
|
+ edbInfoIds := make([]int, 0)
|
|
|
for _, v := range chartMappings {
|
|
|
- s := fmt.Sprintf("%d-%d", v.FactorEdbSeriesId, v.EdbInfoId)
|
|
|
- factorUsed[s] = true
|
|
|
if !seriesIdExist[v.FactorEdbSeriesId] {
|
|
|
seriesIds = append(seriesIds, v.FactorEdbSeriesId)
|
|
|
}
|
|
|
+ edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
|
}
|
|
|
if len(seriesIds) == 0 {
|
|
|
br.Msg = "因子指标系列异常"
|
|
@@ -2739,26 +2790,6 @@ func (this *CorrelationChartInfoController) MultiFactorDetail() {
|
|
|
correlateConf.CalculateUnit = chartCorrelate.CalculateUnit
|
|
|
correlateConf.CalculateValue = chartCorrelate.CalculateValue
|
|
|
|
|
|
-
|
|
|
- edbMappings := make([]*data_manage.FactorEdbSeriesMapping, 0)
|
|
|
- edbInfoIds := make([]int, 0)
|
|
|
- {
|
|
|
- ob := new(data_manage.FactorEdbSeriesMapping)
|
|
|
- cond := fmt.Sprintf(" AND %s IN (%s)", ob.Cols().FactorEdbSeriesId, utils.GetOrmInReplace(len(seriesIds)))
|
|
|
- pars := make([]interface{}, 0)
|
|
|
- pars = append(pars, seriesIds)
|
|
|
- order := fmt.Sprintf("%s ASC, %s ASC", ob.Cols().FactorEdbSeriesId, ob.Cols().EdbInfoId)
|
|
|
- items, e := ob.GetItemsByCondition(cond, pars, []string{}, order)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取因子指标关联失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range items {
|
|
|
- edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
|
- }
|
|
|
- edbMappings = items
|
|
|
- }
|
|
|
edbIdItem := make(map[int]*data_manage.EdbInfo)
|
|
|
edbItems, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
|
|
|
if e != nil {
|
|
@@ -2773,7 +2804,7 @@ func (this *CorrelationChartInfoController) MultiFactorDetail() {
|
|
|
|
|
|
seriesEdb := make(map[int][]*data_manage.FactorEdbSeriesMappingItem)
|
|
|
var matrixItems []data_manage.FactorEdbSeriesCorrelationMatrixItem
|
|
|
- for _, v := range edbMappings {
|
|
|
+ for _, v := range chartMappings {
|
|
|
edbItem := edbIdItem[v.EdbInfoId]
|
|
|
if edbItem == nil {
|
|
|
continue
|
|
@@ -2794,8 +2825,9 @@ func (this *CorrelationChartInfoController) MultiFactorDetail() {
|
|
|
}
|
|
|
sort.Sort(data_manage.FactorEdbSeriesCorrelationMatrixOrder(values))
|
|
|
item.Values = values
|
|
|
- s := fmt.Sprintf("%d-%d", v.FactorEdbSeriesId, v.EdbInfoId)
|
|
|
- item.Used = factorUsed[s]
|
|
|
+ if v.EdbUsed == 1 {
|
|
|
+ item.Used = true
|
|
|
+ }
|
|
|
item.SourceName = edbItem.SourceName
|
|
|
matrixItems = append(matrixItems, item)
|
|
|
|