|
@@ -10,6 +10,7 @@ import (
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -852,3 +853,51 @@ func sandboxClassifyHaveChildV2(allNode []*sandbox.SandboxClassifyItems, node *s
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func ReplaceEdbInSandbox(oldEdbInfoId, newEdbInfoId int) (err error) {
|
|
|
+ //分页处理沙盘表
|
|
|
+ //查询沙盘总数
|
|
|
+ total, err := sandbox.GetSandboxListCountByCondition("", []interface{}{})
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("查询沙盘总数失败 Err:%s", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据沙盘列表总数,分页查询
|
|
|
+ // 计算总页数
|
|
|
+ totalPage := (total + 99) / 100 // 使用整数除法,并添加一页以防有余数
|
|
|
+ updateSandBox := make([]sandbox.Sandbox, 0)
|
|
|
+ //查询沙盘列表
|
|
|
+ for i := 0; i < totalPage; i += 1 {
|
|
|
+ startSize := i * 100
|
|
|
+ list, e := sandbox.GetSandboxListByCondition("", []interface{}{}, startSize, 100)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询沙盘列表失败 Err:%s", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ sandOldEdbId := fmt.Sprintf(`"RId":"1-%d","Id":%d,`, oldEdbInfoId, oldEdbInfoId)
|
|
|
+ if strings.Contains(v.Content, sandOldEdbId) {
|
|
|
+ sandNewEdbId := fmt.Sprintf(`"RId":"1-%d","Id":%d,`, newEdbInfoId, newEdbInfoId)
|
|
|
+ v.Sandbox.Content = strings.ReplaceAll(v.Content, sandOldEdbId, sandNewEdbId)
|
|
|
+ updateSandBox = append(updateSandBox, v.Sandbox)
|
|
|
+ if len(updateSandBox) > 100 {
|
|
|
+ err = sandbox.UpdateSandboxContent(updateSandBox)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("更新沙盘表失败 Err:%s", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ updateSandBox = make([]sandbox.Sandbox, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(updateSandBox) > 0 {
|
|
|
+ err = sandbox.UpdateSandboxContent(updateSandBox)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("更新沙盘表失败 Err:%s", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|