|
@@ -111,24 +111,28 @@ func ReplaceMultipleGraphConfigChartEdb(oldEdbInfo, newEdbInfo *EdbInfo) (replac
|
|
|
for _, mv := range multipleGraphConfigList {
|
|
|
if _, ok := configIdMap[mv.MultipleGraphConfigId]; !ok {
|
|
|
//判断如果达到1000个数,则执行更新语句
|
|
|
+ configIds = append(configIds, mv.MultipleGraphConfigId)
|
|
|
+ configIdStr = append(configIdStr, strconv.Itoa(mv.MultipleGraphConfigId))
|
|
|
+ configIdMap[mv.MultipleGraphConfigId] = mv.MultipleGraphConfigId
|
|
|
if len(configIds) >= 1000 {
|
|
|
+ numStr := utils.GetOrmInReplace(len(configIds))
|
|
|
//更新配置中的指标A
|
|
|
- sql := `UPDATE multiple_graph_config SET edb_info_id_a=?, update_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id_a=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql := `UPDATE multiple_graph_config SET edb_info_id_a=?, modify_time=? WHERE edb_info_id_a=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标A关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
//更新配置中的指标B
|
|
|
- sql = `UPDATE multiple_graph_config SET edb_info_id_b=?, update_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id_b=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql = `UPDATE multiple_graph_config SET edb_info_id_b=?, modify_time=? WHERE edb_info_id_b=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标B关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
// 更新指标id
|
|
|
- sql = `UPDATE multiple_graph_config_edb_mapping SET edb_info_id=?, modify_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql = `UPDATE multiple_graph_config_edb_mapping SET edb_info_id=?, modify_time=? WHERE edb_info_id=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标id关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|
|
@@ -137,29 +141,27 @@ func ReplaceMultipleGraphConfigChartEdb(oldEdbInfo, newEdbInfo *EdbInfo) (replac
|
|
|
configIds = make([]int, 0)
|
|
|
configIdStr = make([]string, 0)
|
|
|
}
|
|
|
- configIds = append(configIds, mv.MultipleGraphConfigId)
|
|
|
- configIdStr = append(configIdStr, strconv.Itoa(mv.MultipleGraphConfigId))
|
|
|
- configIdMap[mv.MultipleGraphConfigId] = mv.MultipleGraphConfigId
|
|
|
}
|
|
|
}
|
|
|
- if len(configIds) >= 1000 {
|
|
|
+ if len(configIds) >= 0 {
|
|
|
+ numStr := utils.GetOrmInReplace(len(configIds))
|
|
|
//更新配置中的指标A
|
|
|
- sql := `UPDATE multiple_graph_config SET edb_info_id_a=?, update_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id_a=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql := `UPDATE multiple_graph_config SET edb_info_id_a=?, modify_time=? WHERE edb_info_id_a=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标A关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
//更新配置中的指标B
|
|
|
- sql = `UPDATE multiple_graph_config SET edb_info_id_b=?, update_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id_b=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql = `UPDATE multiple_graph_config SET edb_info_id_b=?, modify_time=? WHERE edb_info_id_b=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标B关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
// 更新指标id
|
|
|
- sql = `UPDATE multiple_graph_config_edb_mapping SET edb_info_id=?, modify_time=? WHERE multiple_graph_config_id IN (?) and edb_info_id=?`
|
|
|
- _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), configIds, oldEdbInfo.EdbInfoId).Exec()
|
|
|
+ sql = `UPDATE multiple_graph_config_edb_mapping SET edb_info_id=?, modify_time=? WHERE edb_info_id=? and multiple_graph_config_id IN (` + numStr + `)`
|
|
|
+ _, err = to.Raw(sql, newEdbInfo.EdbInfoId, time.Now(), oldEdbInfo.EdbInfoId, configIds).Exec()
|
|
|
if err != nil {
|
|
|
errmsg = "更新指标id关联图表配置信息失败:Err:" + err.Error()
|
|
|
return
|