|
@@ -3,6 +3,7 @@ package data
|
|
import (
|
|
import (
|
|
"eta/eta_api/models/data_manage"
|
|
"eta/eta_api/models/data_manage"
|
|
"eta/eta_api/services/alarm_msg"
|
|
"eta/eta_api/services/alarm_msg"
|
|
|
|
+ "eta/eta_api/services/sandbox"
|
|
"eta/eta_api/utils"
|
|
"eta/eta_api/utils"
|
|
"fmt"
|
|
"fmt"
|
|
"time"
|
|
"time"
|
|
@@ -10,13 +11,20 @@ import (
|
|
|
|
|
|
// SaveChartEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
// SaveChartEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo) (err error) {
|
|
func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo) (err error) {
|
|
|
|
+ //更新指标刷新状态为启用
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, chartInfo.ChartInfoId, utils.EDB_RELATION_CHART, chartInfo.Source)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// saveEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
|
|
+func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType int) (err error) {
|
|
// 实现添加引用记录的逻辑
|
|
// 实现添加引用记录的逻辑
|
|
if len(edbInfoIds) == 0 {
|
|
if len(edbInfoIds) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
- tips := "SaveChartEdbInfoRelation-添加/编辑图表指标引用关联记录失败, ErrMsg:\n" + err.Error()
|
|
|
|
|
|
+ tips := "实现添加引用记录的逻辑-添加/编辑图表指标引用关联记录失败, ErrMsg:\n" + err.Error()
|
|
utils.FileLog.Info(tips)
|
|
utils.FileLog.Info(tips)
|
|
go alarm_msg.SendAlarmMsg(tips, 3)
|
|
go alarm_msg.SendAlarmMsg(tips, 3)
|
|
}
|
|
}
|
|
@@ -41,7 +49,7 @@ func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo
|
|
}
|
|
}
|
|
// 循转组装引用
|
|
// 循转组装引用
|
|
// 查询已有的引用关系
|
|
// 查询已有的引用关系
|
|
- existList, e := data_manage.GetEdbInfoRelationByReferObjectId(chartInfo.ChartInfoId, utils.EDB_RELATION_CHART)
|
|
|
|
|
|
+ existList, e := data_manage.GetEdbInfoRelationByReferObjectId(objectId, objectType)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = fmt.Errorf("查询已有的引用关系失败,%s", e.Error())
|
|
err = fmt.Errorf("查询已有的引用关系失败,%s", e.Error())
|
|
return
|
|
return
|
|
@@ -65,9 +73,9 @@ func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo
|
|
delete(deleteMap, edbInfo.EdbInfoId)
|
|
delete(deleteMap, edbInfo.EdbInfoId)
|
|
} else {
|
|
} else {
|
|
tmp := &data_manage.EdbInfoRelation{
|
|
tmp := &data_manage.EdbInfoRelation{
|
|
- ReferObjectId: chartInfo.ChartInfoId,
|
|
|
|
- ReferObjectType: utils.EDB_RELATION_CHART,
|
|
|
|
- ReferObjectSubType: chartInfo.Source,
|
|
|
|
|
|
+ ReferObjectId: objectId,
|
|
|
|
+ ReferObjectType: objectType,
|
|
|
|
+ ReferObjectSubType: objectSubType,
|
|
EdbInfoId: edbInfo.EdbInfoId,
|
|
EdbInfoId: edbInfo.EdbInfoId,
|
|
EdbName: edbInfo.EdbName,
|
|
EdbName: edbInfo.EdbName,
|
|
Source: edbInfo.Source,
|
|
Source: edbInfo.Source,
|
|
@@ -91,3 +99,17 @@ func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// SaveSandBoxEdbInfoRelation 添加/编辑 eta逻辑图指标引用
|
|
|
|
+func SaveSandBoxEdbInfoRelation(sandBoxId int, sandBoxContent string) (err error) {
|
|
|
|
+ edbInfoIds, err := sandbox.GetSandBoxEdbIdsByContent(sandBoxContent)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(edbInfoIds) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //更新指标刷新状态为启用
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, sandBoxId, utils.EDB_RELATION_SANDBOX, 0)
|
|
|
|
+ return
|
|
|
|
+}
|