|
@@ -2,6 +2,7 @@ package data
|
|
|
|
|
|
import (
|
|
|
"eta/eta_api/models/data_manage"
|
|
|
+ excelModel "eta/eta_api/models/data_manage/excel"
|
|
|
"eta/eta_api/models/fe_calendar"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
|
"eta/eta_api/services/sandbox"
|
|
@@ -523,3 +524,67 @@ func GetCalculateEdbInfoByEdbInfoId(edbInfoId int, hasFindMap map[int]struct{},
|
|
|
hasFindMap[edbInfoId] = struct{}{}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// SaveExcelEdbInfoRelation 添加/编辑表格时同步修改指标引用关联记录
|
|
|
+func SaveExcelEdbInfoRelation(excelInfoId, source int, addChildExcel bool) (err error) {
|
|
|
+ //查询和指标相关的时间序列表格和混合表格
|
|
|
+ if !utils.InArrayByInt([]int{utils.TIME_TABLE, utils.MIXED_TABLE, utils.BALANCE_TABLE}, source) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if addChildExcel && source == utils.BALANCE_TABLE {
|
|
|
+ //查询excel信息,
|
|
|
+ excelInfoList, e := excelModel.GetChildExcelInfoByParentId(excelInfoId)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询excel信息失败,错误:%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询
|
|
|
+ if len(excelInfoList) > 0 {
|
|
|
+ //汇总表格ID
|
|
|
+ excelIds := make([]int, 0)
|
|
|
+ for _, v := range excelInfoList {
|
|
|
+ if v.BalanceType == 0 {
|
|
|
+ excelIds = append(excelIds, v.ExcelInfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mappingList, e := excelModel.GetAllExcelEdbMappingByExcelInfoIds(excelIds)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询和指标相关的表格失败,错误:%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //整理map
|
|
|
+ mappingMap := make(map[int][]int)
|
|
|
+ for _, v := range mappingList {
|
|
|
+ mappingMap[v.ExcelInfoId] = append(mappingMap[v.ExcelInfoId], v.EdbInfoId)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加指标引用
|
|
|
+ for _, v := range excelInfoList {
|
|
|
+ edbInfoIds, ok := mappingMap[v.ExcelInfoId]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, v.ExcelInfoId, utils.EDB_RELATION_TABLE, source)
|
|
|
+ }
|
|
|
+ //更新
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mappingList, err := excelModel.GetAllExcelEdbMappingByExcelInfoId(excelInfoId)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("查询和指标相关的表格失败,错误:%s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //查询指标ID
|
|
|
+ edbInfoIds := make([]int, 0)
|
|
|
+ for k := range mappingList {
|
|
|
+ edbInfoIds = append(edbInfoIds, k)
|
|
|
+ }
|
|
|
+ //查询指标引用关联记录
|
|
|
+ //更新指标刷新状态为启用
|
|
|
+ if len(edbInfoIds) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, excelInfoId, utils.EDB_RELATION_TABLE, source)
|
|
|
+ return
|
|
|
+}
|