|
@@ -714,6 +714,7 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
pageNum := (int(totalCount) + 99) / pageSize // 使用整数除法,并添加一页以防有余数
|
|
|
stopRefreshIds := make([]int, 0)
|
|
|
stopRefreshMysteelCode := make([]string, 0)
|
|
|
+ edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
for i := 0; i < pageNum; i++ {
|
|
|
start := i * pageSize
|
|
|
edbItems, e := data_manage.GetEdbInfoPageByCondition(condition, pars, start, pageSize)
|
|
@@ -725,8 +726,11 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
continue
|
|
|
}
|
|
|
edbInfoIds := make([]int, 0)
|
|
|
+ edbInfoList = make([]*data_manage.EdbInfo, 0)
|
|
|
+ edbInfoMap := make(map[int]*data_manage.EdbInfo, 0)
|
|
|
for _, item := range edbItems {
|
|
|
edbInfoIds = append(edbInfoIds, item.EdbInfoId)
|
|
|
+ edbInfoMap[item.EdbInfoId] = item
|
|
|
}
|
|
|
// 查询指标库里这些指标 引用情况
|
|
|
relationList, e := data_manage.GetEdbInfoRelationByEdbInfoIds(edbInfoIds)
|
|
@@ -740,18 +744,38 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
}
|
|
|
for _, item := range edbItems {
|
|
|
if _, ok := edbMap[item.EdbInfoId]; !ok {
|
|
|
+ edbInfo, ok1 := edbInfoMap[item.EdbInfoId]
|
|
|
+ if ok1 {
|
|
|
+ edbInfoList = append(edbInfoList, edbInfo)
|
|
|
+ }
|
|
|
stopRefreshIds = append(stopRefreshIds, item.EdbInfoId)
|
|
|
if item.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
|
|
|
stopRefreshMysteelCode = append(stopRefreshMysteelCode, item.EdbCode)
|
|
|
}
|
|
|
// 更新指标禁止刷新状态
|
|
|
if len(stopRefreshIds) > 100 {
|
|
|
- calculateEdbIds, tmpErr := data_manage.GetAllCalculateEdbIdsByEdbInfoIds(stopRefreshIds)
|
|
|
- if tmpErr != nil {
|
|
|
- err = fmt.Errorf("查询计算指标信息失败:%v", tmpErr)
|
|
|
- return
|
|
|
+ // 查询相关的计算指标
|
|
|
+ calculateEdbIdList := make([]int, 0)
|
|
|
+ if len(edbInfoList) > 0 {
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e1 := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e1 != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败, Err" + e1.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range edbInfoList {
|
|
|
+ childEdbMappingIds, ok2 := calculateEdbMappingIdsMap[v.EdbInfoId]
|
|
|
+ if ok2 {
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok3 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !ok3 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ calculateEdbIdList = append(calculateEdbIdList, childEdbMapping.EdbInfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- err = data_manage.ModifyEdbUpdateStatus(stopRefreshIds, stopRefreshMysteelCode, calculateEdbIds)
|
|
|
+ err = data_manage.ModifyEdbUpdateStatus(stopRefreshIds, stopRefreshMysteelCode, calculateEdbIdList)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("更新指标禁止刷新状态失败:%v", err)
|
|
|
return
|
|
@@ -765,12 +789,28 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
|
|
|
// 更新指标禁止刷新状态
|
|
|
if len(stopRefreshIds) > 0 {
|
|
|
- calculateEdbIds, tmpErr := data_manage.GetAllCalculateEdbIdsByEdbInfoIds(stopRefreshIds)
|
|
|
- if tmpErr != nil {
|
|
|
- err = fmt.Errorf("查询计算指标信息失败:%v", tmpErr)
|
|
|
- return
|
|
|
+ // 查询相关的计算指标
|
|
|
+ calculateEdbIdList := make([]int, 0)
|
|
|
+ if len(edbInfoList) > 0 {
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e1 := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e1 != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败, Err" + e1.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range edbInfoList {
|
|
|
+ childEdbMappingIds, ok2 := calculateEdbMappingIdsMap[v.EdbInfoId]
|
|
|
+ if ok2 {
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok3 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !ok3 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ calculateEdbIdList = append(calculateEdbIdList, childEdbMapping.EdbInfoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- err = data_manage.ModifyEdbUpdateStatus(stopRefreshIds, stopRefreshMysteelCode, calculateEdbIds)
|
|
|
+ err = data_manage.ModifyEdbUpdateStatus(stopRefreshIds, stopRefreshMysteelCode, calculateEdbIdList)
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("更新指标禁止刷新状态失败:%v", err)
|
|
|
return
|