|
@@ -1326,32 +1326,72 @@ func (this *CorrelationChartInfoController) Copy() {
|
|
}
|
|
}
|
|
|
|
|
|
// 指标系列-图表关联
|
|
// 指标系列-图表关联
|
|
- seriesMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
|
|
|
+ seriesIds := make([]int, 0)
|
|
|
|
+ originChartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
{
|
|
{
|
|
ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
cond := fmt.Sprintf(" AND %s = ?", ob.Cols().ChartInfoId)
|
|
cond := fmt.Sprintf(" AND %s = ?", ob.Cols().ChartInfoId)
|
|
pars := make([]interface{}, 0)
|
|
pars := make([]interface{}, 0)
|
|
pars = append(pars, req.ChartInfoId)
|
|
pars = append(pars, req.ChartInfoId)
|
|
- mappings, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
|
|
|
+ list, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "保存失败"
|
|
br.Msg = "保存失败"
|
|
br.ErrMsg = fmt.Sprintf("获取指标系列-图表关联失败, Err: %v", e)
|
|
br.ErrMsg = fmt.Sprintf("获取指标系列-图表关联失败, Err: %v", e)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- for _, v := range mappings {
|
|
|
|
- seriesMappings = append(seriesMappings, &data_manage.FactorEdbSeriesChartMapping{
|
|
|
|
- FactorEdbSeriesId: v.FactorEdbSeriesId,
|
|
|
|
- ChartInfoId: req.ChartInfoId,
|
|
|
|
- EdbInfoId: v.EdbInfoId,
|
|
|
|
- Source: v.Source,
|
|
|
|
- CreateTime: time.Now().Local(),
|
|
|
|
- ModifyTime: time.Now().Local(),
|
|
|
|
- })
|
|
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ //seriesMappings = append(seriesMappings, &data_manage.FactorEdbSeriesChartMapping{
|
|
|
|
+ // FactorEdbSeriesId: v.FactorEdbSeriesId,
|
|
|
|
+ // ChartInfoId: req.ChartInfoId,
|
|
|
|
+ // EdbInfoId: v.EdbInfoId,
|
|
|
|
+ // Source: v.Source,
|
|
|
|
+ // CreateTime: time.Now().Local(),
|
|
|
|
+ // ModifyTime: time.Now().Local(),
|
|
|
|
+ //})
|
|
|
|
+ if !utils.InArrayByInt(seriesIds, v.FactorEdbSeriesId) {
|
|
|
|
+ seriesIds = append(seriesIds, v.FactorEdbSeriesId)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ originChartMappings = list
|
|
|
|
+ }
|
|
|
|
+ if len(seriesIds) == 0 {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ br.ErrMsg = "源图表系列有误"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 注意此处要复制一份系列及系列关联指标, 不可共用被复制图表的系列
|
|
|
|
+ originSeries := make([]*data_manage.FactorEdbSeries, 0)
|
|
|
|
+ {
|
|
|
|
+ ob := new(data_manage.FactorEdbSeries)
|
|
|
|
+ cond := fmt.Sprintf(" AND %s IN (%s)", ob.Cols().PrimaryId, utils.GetOrmInReplace(len(seriesIds)))
|
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
|
+ pars = append(pars, seriesIds)
|
|
|
|
+ list, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取源图表系列失败, %v", e)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ originSeries = list
|
|
|
|
+ }
|
|
|
|
+ originEdbSeriesMapping := make([]*data_manage.FactorEdbSeriesMapping, 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)
|
|
|
|
+ list, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取源图表系列指标失败, %v", e)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ originEdbSeriesMapping = list
|
|
}
|
|
}
|
|
|
|
|
|
// 新增图表/相关性图表/图表指标关联/指标系列图表关联
|
|
// 新增图表/相关性图表/图表指标关联/指标系列图表关联
|
|
- chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, seriesMappings)
|
|
|
|
|
|
+ chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, originChartMappings, true, originSeries, originEdbSeriesMapping)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "保存失败"
|
|
br.Msg = "保存失败"
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
@@ -2100,6 +2140,10 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
br.Msg = "请选择标的指标"
|
|
br.Msg = "请选择标的指标"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ if len(req.FactorCorrelation.SeriesIds) == 0 {
|
|
|
|
+ br.Msg = "请选择因子指标系列"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if len(req.FactorCorrelation.SeriesEdb) == 0 {
|
|
if len(req.FactorCorrelation.SeriesEdb) == 0 {
|
|
br.Msg = "请选择因子指标"
|
|
br.Msg = "请选择因子指标"
|
|
return
|
|
return
|
|
@@ -2273,27 +2317,19 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
edbMappings = append(edbMappings, m)
|
|
edbMappings = append(edbMappings, m)
|
|
}
|
|
}
|
|
|
|
|
|
- // 指标系列-图表关联
|
|
|
|
- chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
|
- seriesIds := make([]int, 0)
|
|
|
|
- seriesIdExist := make(map[int]bool)
|
|
|
|
|
|
+ // 标记引用的指标
|
|
|
|
+ seriesIds := req.FactorCorrelation.SeriesIds
|
|
edbUsed := make(map[string]bool)
|
|
edbUsed := make(map[string]bool)
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
- if !seriesIdExist[v.SeriesId] {
|
|
|
|
- seriesIds = append(seriesIds, v.SeriesId)
|
|
|
|
- }
|
|
|
|
k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
edbUsed[k] = true
|
|
edbUsed[k] = true
|
|
}
|
|
}
|
|
- if len(seriesIds) == 0 {
|
|
|
|
- br.Msg = "保存失败"
|
|
|
|
- br.ErrMsg = fmt.Sprintf("指标系列异常")
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
+ // 指标系列-图表关联
|
|
|
|
+ chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
|
|
+ {
|
|
ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
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)
|
|
|
|
|
|
+ cond := fmt.Sprintf(" AND %s IN (%s)", ob.Cols().FactorEdbSeriesId, utils.GetOrmInReplace(len(seriesIds)))
|
|
pars := make([]interface{}, 0)
|
|
pars := make([]interface{}, 0)
|
|
pars = append(pars, seriesIds)
|
|
pars = append(pars, seriesIds)
|
|
items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
@@ -2313,8 +2349,41 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
v.ModifyTime = time.Now().Local()
|
|
v.ModifyTime = time.Now().Local()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 另存为
|
|
|
|
+ originSeries := make([]*data_manage.FactorEdbSeries, 0)
|
|
|
|
+ originEdbSeriesMapping := make([]*data_manage.FactorEdbSeriesMapping, 0)
|
|
|
|
+ if req.SaveAs {
|
|
|
|
+ // 注意此处要复制一份系列及系列关联指标, 不可共用被复制图表的系列
|
|
|
|
+ {
|
|
|
|
+ ob := new(data_manage.FactorEdbSeries)
|
|
|
|
+ cond := fmt.Sprintf(" AND %s IN (%s)", ob.Cols().PrimaryId, utils.GetOrmInReplace(len(seriesIds)))
|
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
|
+ pars = append(pars, seriesIds)
|
|
|
|
+ list, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取源图表系列失败, %v", e)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ originSeries = list
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ 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)
|
|
|
|
+ list, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "保存失败"
|
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取源图表系列指标失败, %v", e)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ originEdbSeriesMapping = list
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 新增图表/相关性图表/图表指标关联/指标系列图表关联
|
|
// 新增图表/相关性图表/图表指标关联/指标系列图表关联
|
|
- chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, chartMappings)
|
|
|
|
|
|
+ chartInfoId, e := data_manage.CreateMultiFactorCorrelationChartAndEdb(chartInfo, edbMappings, chartCorrelate, chartMappings, req.SaveAs, originSeries, originEdbSeriesMapping)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "保存失败"
|
|
br.Msg = "保存失败"
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
br.ErrMsg = fmt.Sprintf("新增多因子相关性图表失败, Err: %v", e)
|
|
@@ -2342,6 +2411,7 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
|
|
resp.ChartInfoId = chartInfo.ChartInfoId
|
|
resp.ChartInfoId = chartInfo.ChartInfoId
|
|
resp.UniqueCode = chartInfo.UniqueCode
|
|
resp.UniqueCode = chartInfo.UniqueCode
|
|
resp.ChartType = chartInfo.ChartType
|
|
resp.ChartType = chartInfo.ChartType
|
|
|
|
+ resp.ClassifyId = req.ClassifyId
|
|
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
@@ -2394,6 +2464,10 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
|
|
br.Msg = "请选择标的指标"
|
|
br.Msg = "请选择标的指标"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ if len(req.FactorCorrelation.SeriesIds) == 0 {
|
|
|
|
+ br.Msg = "请选择因子指标系列"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if len(req.FactorCorrelation.SeriesEdb) == 0 {
|
|
if len(req.FactorCorrelation.SeriesEdb) == 0 {
|
|
br.Msg = "请选择因子指标"
|
|
br.Msg = "请选择因子指标"
|
|
return
|
|
return
|
|
@@ -2584,6 +2658,7 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
|
|
edbMappings = append(edbMappings, m)
|
|
edbMappings = append(edbMappings, m)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ seriesIds := req.FactorCorrelation.SeriesIds
|
|
edbUsed := make(map[string]bool)
|
|
edbUsed := make(map[string]bool)
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
for _, v := range req.FactorCorrelation.SeriesEdb {
|
|
k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
k := fmt.Sprintf("%d-%d", v.SeriesId, v.EdbInfoId)
|
|
@@ -2593,9 +2668,9 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
|
|
chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
chartMappings := make([]*data_manage.FactorEdbSeriesChartMapping, 0)
|
|
{
|
|
{
|
|
ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
ob := new(data_manage.FactorEdbSeriesChartMapping)
|
|
- cond := fmt.Sprintf(" AND %s = ?", ob.Cols().ChartInfoId)
|
|
|
|
|
|
+ cond := fmt.Sprintf(" AND %s IN (%s)", ob.Cols().FactorEdbSeriesId, utils.GetOrmInReplace(len(seriesIds)))
|
|
pars := make([]interface{}, 0)
|
|
pars := make([]interface{}, 0)
|
|
- pars = append(pars, chartInfo.ChartInfoId)
|
|
|
|
|
|
+ pars = append(pars, seriesIds)
|
|
items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "保存失败"
|
|
br.Msg = "保存失败"
|
|
@@ -2647,6 +2722,7 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
|
|
resp.ChartInfoId = chartInfo.ChartInfoId
|
|
resp.ChartInfoId = chartInfo.ChartInfoId
|
|
resp.UniqueCode = chartInfo.UniqueCode
|
|
resp.UniqueCode = chartInfo.UniqueCode
|
|
resp.ChartType = chartInfo.ChartType
|
|
resp.ChartType = chartInfo.ChartType
|
|
|
|
+ resp.ClassifyId = req.ClassifyId
|
|
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|