ai_predict_model_classify.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. package services
  2. import (
  3. "errors"
  4. aiPredictModel "eta/eta_api/models/ai_predict_model"
  5. "eta/eta_api/models/data_manage"
  6. "eta/eta_api/models/system"
  7. "eta/eta_api/utils"
  8. "fmt"
  9. "time"
  10. )
  11. // AiPredictModelMoveClassify 移动分类
  12. func AiPredictModelMoveClassify(req aiPredictModel.AiPredictModelClassifyMoveReq, sysUser *system.Admin) (err error, errMsg string) {
  13. classifyId := req.ClassifyId
  14. parentClassifyId := req.ParentClassifyId
  15. prevClassifyId := req.PrevClassifyId
  16. nextClassifyId := req.NextClassifyId
  17. itemId := req.ItemId
  18. prevItemId := req.PrevItemId
  19. nextItemId := req.NextItemId
  20. //首先确定移动的对象是分类还是指标
  21. //判断上一个节点是分类还是指标
  22. //判断下一个节点是分类还是指标
  23. //同时更新分类目录下的分类sort和指标sort
  24. //更新当前移动的分类或者指标sort
  25. classifyOb := new(aiPredictModel.AiPredictModelClassify)
  26. indexOb := new(aiPredictModel.AiPredictModelIndex)
  27. var parentClassify *aiPredictModel.AiPredictModelClassify
  28. if parentClassifyId > 0 {
  29. parentClassify, err = classifyOb.GetItemById(parentClassifyId)
  30. if err != nil {
  31. errMsg = "移动失败"
  32. err = errors.New("获取上级分类信息失败,Err:" + err.Error())
  33. return
  34. }
  35. }
  36. //如果有传入 上一个兄弟节点分类id
  37. var (
  38. edbClassifyInfo *aiPredictModel.AiPredictModelClassify
  39. prevClassify *aiPredictModel.AiPredictModelClassify
  40. nextClassify *aiPredictModel.AiPredictModelClassify
  41. edbInfo *aiPredictModel.AiPredictModelIndex
  42. prevEdbInfo *aiPredictModel.AiPredictModelIndex
  43. nextEdbInfo *aiPredictModel.AiPredictModelIndex
  44. prevSort int
  45. nextSort int
  46. )
  47. // 移动对象为分类, 判断权限
  48. if itemId == 0 {
  49. edbClassifyInfo, err = classifyOb.GetItemById(classifyId)
  50. if err != nil {
  51. if err.Error() == utils.ErrNoRow() {
  52. errMsg = "当前分类不存在"
  53. err = errors.New("获取分类信息失败,Err:" + err.Error())
  54. return
  55. }
  56. errMsg = "移动失败"
  57. err = errors.New("获取分类信息失败,Err:" + err.Error())
  58. return
  59. }
  60. if parentClassifyId > 0 && parentClassify.Level == 6 {
  61. errMsg = "最高只支持添加6级分类"
  62. err = errors.New(errMsg)
  63. return
  64. }
  65. // 如果是移动目录, 那么校验一下父级目录下是否有重名目录
  66. exists, e := data_manage.GetEdbClassifyByParentIdAndName(parentClassifyId, edbClassifyInfo.ClassifyName, classifyId)
  67. if e != nil && e.Error() != utils.ErrNoRow() {
  68. errMsg = "移动失败"
  69. err = fmt.Errorf("获取父级分类下的同名分类失败, Err: %s", e.Error())
  70. return
  71. }
  72. if exists != nil {
  73. errMsg = "移动失败,分类名称已存在"
  74. return
  75. }
  76. } else {
  77. edbInfo, err = indexOb.GetItemById(req.ItemId)
  78. if err != nil {
  79. if err.Error() == utils.ErrNoRow() {
  80. errMsg = "当前指标不存在"
  81. err = errors.New("获取分类信息失败,Err:" + err.Error())
  82. return
  83. }
  84. errMsg = "移动失败"
  85. err = errors.New("获取分类信息失败,Err:" + err.Error())
  86. return
  87. }
  88. if parentClassifyId == 0 {
  89. errMsg = "移动失败,指标必须挂在分类下"
  90. err = errors.New(errMsg)
  91. return
  92. }
  93. //// 移动权限校验
  94. //button := GetEdbOpButton(sysUser, edbInfo.SysUserId, edbInfo.EdbType, edbInfo.EdbInfoType, haveOperaAuth)
  95. //if !button.MoveButton {
  96. // errMsg = "无操作权限"
  97. // err = errors.New(errMsg)
  98. // return
  99. //}
  100. }
  101. if prevClassifyId > 0 {
  102. prevClassify, err = classifyOb.GetItemById(prevClassifyId)
  103. if err != nil {
  104. errMsg = "移动失败"
  105. err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + err.Error())
  106. return
  107. }
  108. prevSort = prevClassify.Sort
  109. } else if prevItemId > 0 {
  110. prevEdbInfo, err = indexOb.GetItemById(prevItemId)
  111. if err != nil {
  112. errMsg = "移动失败"
  113. err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + err.Error())
  114. return
  115. }
  116. prevSort = prevEdbInfo.Sort
  117. }
  118. if nextClassifyId > 0 {
  119. //下一个兄弟节点
  120. nextClassify, err = classifyOb.GetItemById(nextClassifyId)
  121. if err != nil {
  122. errMsg = "移动失败"
  123. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error())
  124. return
  125. }
  126. nextSort = nextClassify.Sort
  127. } else if nextItemId > 0 {
  128. //下一个兄弟节点
  129. nextEdbInfo, err = indexOb.GetItemById(nextItemId)
  130. if err != nil {
  131. errMsg = "移动失败"
  132. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error())
  133. return
  134. }
  135. nextSort = nextEdbInfo.Sort
  136. }
  137. err, errMsg = moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, nextClassify, edbInfo, prevEdbInfo, nextEdbInfo, parentClassifyId, prevSort, nextSort)
  138. return
  139. }
  140. // moveAiPredictModelClassify 移动指标分类
  141. func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, nextClassify *aiPredictModel.AiPredictModelClassify, edbInfo, prevEdbInfo, nextEdbInfo *aiPredictModel.AiPredictModelIndex, parentClassifyId int, prevSort, nextSort int) (err error, errMsg string) {
  142. updateCol := make([]string, 0)
  143. // 移动对象为分类, 判断分类是否存在
  144. if edbClassifyInfo != nil {
  145. oldParentId := edbClassifyInfo.ParentId
  146. oldLevel := edbClassifyInfo.Level
  147. var classifyIds []int
  148. if oldParentId != parentClassifyId {
  149. //更新子分类对应的level
  150. childList, e, m := GetAiPredictModelChildClassifyByClassifyId(edbClassifyInfo.AiPredictModelClassifyId)
  151. if e != nil {
  152. errMsg = "移动失败"
  153. err = errors.New("查询子分类失败,Err:" + e.Error() + m)
  154. return
  155. }
  156. if len(childList) > 0 {
  157. for _, v := range childList {
  158. if v.AiPredictModelClassifyId == edbClassifyInfo.AiPredictModelClassifyId {
  159. continue
  160. }
  161. classifyIds = append(classifyIds, v.AiPredictModelClassifyId)
  162. }
  163. }
  164. }
  165. //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  166. if edbClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
  167. if edbClassifyInfo.Level != parentClassify.Level+1 { //禁止层级调整
  168. errMsg = "移动失败"
  169. err = errors.New("不支持目录层级变更")
  170. return
  171. }
  172. edbClassifyInfo.ParentId = parentClassify.AiPredictModelClassifyId
  173. edbClassifyInfo.RootId = parentClassify.RootId
  174. edbClassifyInfo.Level = parentClassify.Level + 1
  175. edbClassifyInfo.ModifyTime = time.Now()
  176. // 更改层级路径
  177. edbClassifyInfo.LevelPath = fmt.Sprintf("%s,%d", parentClassify.LevelPath, edbClassifyInfo.AiPredictModelClassifyId)
  178. updateCol = append(updateCol, "ParentId", "RootId", "Level", "ModifyTime", "LevelPath")
  179. } else if edbClassifyInfo.ParentId != parentClassifyId && parentClassifyId == 0 {
  180. errMsg = "移动失败"
  181. err = errors.New("不支持目录层级变更")
  182. return
  183. }
  184. if prevSort > 0 {
  185. //如果是移动在两个兄弟节点之间
  186. if nextSort > 0 {
  187. //下一个兄弟节点
  188. //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  189. if prevSort == nextSort || prevSort == edbClassifyInfo.Sort {
  190. //变更兄弟节点的排序
  191. updateSortStr := `sort + 2`
  192. //变更分类
  193. if prevClassify != nil {
  194. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, prevClassify.AiPredictModelClassifyId, prevClassify.Sort, updateSortStr)
  195. } else {
  196. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, prevSort, updateSortStr)
  197. }
  198. //变更指标
  199. if prevEdbInfo != nil {
  200. //变更兄弟节点的排序
  201. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, prevEdbInfo.AiPredictModelIndexId, updateSortStr)
  202. } else {
  203. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, 0, updateSortStr)
  204. }
  205. } else {
  206. //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  207. if nextSort-prevSort == 1 {
  208. //变更兄弟节点的排序
  209. updateSortStr := `sort + 1`
  210. //变更分类
  211. if prevClassify != nil {
  212. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, prevClassify.AiPredictModelClassifyId, prevSort, updateSortStr)
  213. } else {
  214. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, prevSort, updateSortStr)
  215. }
  216. //变更指标
  217. if prevEdbInfo != nil {
  218. //变更兄弟节点的排序
  219. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, prevEdbInfo.AiPredictModelIndexId, updateSortStr)
  220. } else {
  221. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, 0, updateSortStr)
  222. }
  223. }
  224. }
  225. }
  226. edbClassifyInfo.Sort = prevSort + 1
  227. edbClassifyInfo.ModifyTime = time.Now()
  228. updateCol = append(updateCol, "Sort", "ModifyTime")
  229. } else if prevClassify == nil && nextClassify == nil && prevEdbInfo == nil && nextEdbInfo == nil && parentClassifyId > 0 {
  230. //处理只拖动到目录里,默认放到目录底部的情况
  231. var maxSort int
  232. maxSort, err = GetAiPredictModelClassifyMaxSort(parentClassifyId)
  233. if err != nil {
  234. errMsg = "移动失败"
  235. err = errors.New("查询组内排序信息失败,Err:" + err.Error())
  236. return
  237. }
  238. edbClassifyInfo.Sort = maxSort + 1 //那就是排在组内最后一位
  239. edbClassifyInfo.ModifyTime = time.Now()
  240. updateCol = append(updateCol, "Sort", "ModifyTime")
  241. } else {
  242. // 拖动到父级分类的第一位
  243. firstClassify, tmpErr := aiPredictModel.GetFirstAiPredictModelClassifyByParentId(parentClassifyId)
  244. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  245. errMsg = "移动失败"
  246. err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
  247. return
  248. }
  249. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  250. if firstClassify != nil && firstClassify.Sort == 0 {
  251. updateSortStr := ` sort + 1 `
  252. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, firstClassify.AiPredictModelClassifyId-1, 0, updateSortStr)
  253. //该分类下的所有指标也需要+1
  254. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, 0, updateSortStr)
  255. } else {
  256. //如果该分类下存在指标,且第一个指标的排序等于0,那么需要调整排序
  257. firstEdb, tErr := aiPredictModel.GetFirstAiPredictModelIndexByClassifyId(parentClassifyId)
  258. if tErr != nil && tErr.Error() != utils.ErrNoRow() {
  259. errMsg = "移动失败"
  260. err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tErr.Error())
  261. return
  262. }
  263. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  264. if firstEdb != nil && firstEdb.Sort == 0 {
  265. updateSortStr := ` sort + 1 `
  266. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, firstEdb.AiPredictModelIndexId-1, updateSortStr)
  267. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, 0, updateSortStr)
  268. }
  269. }
  270. edbClassifyInfo.Sort = 0 //那就是排在第一位
  271. edbClassifyInfo.ModifyTime = time.Now()
  272. updateCol = append(updateCol, "Sort", "ModifyTime")
  273. }
  274. //更新
  275. if len(updateCol) > 0 {
  276. err = edbClassifyInfo.Update(updateCol)
  277. if err != nil {
  278. errMsg = "移动失败"
  279. err = errors.New("修改失败,Err:" + err.Error())
  280. return
  281. }
  282. //更新对应分类的root_id和层级
  283. if oldParentId != parentClassifyId {
  284. if len(classifyIds) > 0 {
  285. levelStep := edbClassifyInfo.Level - oldLevel
  286. err = aiPredictModel.UpdateAiPredictModelClassifyChildByParentClassifyId(classifyIds, edbClassifyInfo.RootId, levelStep)
  287. if err != nil {
  288. errMsg = "移动失败"
  289. err = errors.New("更新子分类失败,Err:" + err.Error())
  290. return
  291. }
  292. }
  293. }
  294. }
  295. } else {
  296. if edbInfo == nil {
  297. errMsg = "当前指标不存在"
  298. err = errors.New(errMsg)
  299. return
  300. }
  301. //如果改变了分类,那么移动该指标数据
  302. if edbInfo.ClassifyId != parentClassifyId {
  303. edbInfo.ClassifyId = parentClassifyId
  304. edbInfo.ModifyTime = time.Now()
  305. updateCol = append(updateCol, "ClassifyId", "ModifyTime")
  306. }
  307. if prevSort > 0 {
  308. //如果是移动在两个兄弟节点之间
  309. if nextSort > 0 {
  310. //下一个兄弟节点
  311. //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  312. if prevSort == nextSort || prevSort == edbInfo.Sort {
  313. //变更兄弟节点的排序
  314. updateSortStr := `sort + 2`
  315. //变更分类
  316. if prevClassify != nil {
  317. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, prevClassify.AiPredictModelClassifyId, prevClassify.Sort, updateSortStr)
  318. } else {
  319. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, prevSort, updateSortStr)
  320. }
  321. //变更指标
  322. if prevEdbInfo != nil {
  323. //变更兄弟节点的排序
  324. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, prevEdbInfo.AiPredictModelIndexId, updateSortStr)
  325. } else {
  326. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, 0, updateSortStr)
  327. }
  328. } else {
  329. //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  330. if nextSort-prevSort == 1 {
  331. //变更兄弟节点的排序
  332. updateSortStr := `sort + 1`
  333. //变更分类
  334. if prevClassify != nil {
  335. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, prevClassify.AiPredictModelClassifyId, prevSort, updateSortStr)
  336. } else {
  337. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, prevSort, updateSortStr)
  338. }
  339. //变更指标
  340. if prevEdbInfo != nil {
  341. //变更兄弟节点的排序
  342. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, prevEdbInfo.AiPredictModelIndexId, updateSortStr)
  343. } else {
  344. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, prevSort, 0, updateSortStr)
  345. }
  346. }
  347. }
  348. }
  349. edbInfo.Sort = prevSort + 1
  350. edbInfo.ModifyTime = time.Now()
  351. updateCol = append(updateCol, "Sort", "ModifyTime")
  352. } else if prevClassify == nil && nextClassify == nil && prevEdbInfo == nil && nextEdbInfo == nil && parentClassifyId > 0 {
  353. //处理只拖动到目录里,默认放到目录底部的情况
  354. var maxSort int
  355. classifyOb := new(aiPredictModel.AiPredictModelClassify)
  356. maxSort, err = classifyOb.GetSortMax(parentClassifyId)
  357. if err != nil {
  358. errMsg = "移动失败"
  359. err = errors.New("查询组内排序信息失败,Err:" + err.Error())
  360. return
  361. }
  362. edbInfo.Sort = maxSort + 1 //那就是排在组内最后一位
  363. edbInfo.ModifyTime = time.Now()
  364. updateCol = append(updateCol, "Sort", "ModifyTime")
  365. } else {
  366. // 拖动到父级分类的第一位
  367. firstClassify, tmpErr := aiPredictModel.GetFirstAiPredictModelClassifyByParentId(parentClassifyId)
  368. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  369. errMsg = "移动失败"
  370. err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
  371. return
  372. }
  373. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  374. if firstClassify != nil && firstClassify.Sort == 0 {
  375. updateSortStr := ` sort + 1 `
  376. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, firstClassify.AiPredictModelClassifyId-1, 0, updateSortStr)
  377. //该分类下的所有指标也需要+1
  378. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, 0, updateSortStr)
  379. } else {
  380. //如果该分类下存在指标,且第一个指标的排序等于0,那么需要调整排序
  381. firstEdb, tErr := aiPredictModel.GetFirstAiPredictModelIndexByClassifyId(parentClassifyId)
  382. if tErr != nil && tErr.Error() != utils.ErrNoRow() {
  383. errMsg = "移动失败"
  384. err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tErr.Error())
  385. return
  386. }
  387. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  388. if firstEdb != nil && firstEdb.Sort == 0 {
  389. updateSortStr := ` sort + 1 `
  390. _ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, firstEdb.AiPredictModelIndexId-1, updateSortStr)
  391. _ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, 0, updateSortStr)
  392. }
  393. }
  394. edbInfo.Sort = 0 //那就是排在第一位
  395. edbInfo.ModifyTime = time.Now()
  396. updateCol = append(updateCol, "Sort", "ModifyTime")
  397. }
  398. //更新
  399. if len(updateCol) > 0 {
  400. err = edbInfo.Update(updateCol)
  401. if err != nil {
  402. errMsg = "移动失败"
  403. err = errors.New("修改失败,Err:" + err.Error())
  404. return
  405. }
  406. }
  407. }
  408. return
  409. }
  410. func GetAiPredictModelChildClassifyByClassifyId(targetClassifyId int) (targetList []*aiPredictModel.AiPredictModelClassify, err error, errMsg string) {
  411. classifyOb := new(aiPredictModel.AiPredictModelClassify)
  412. //判断是否是挂在顶级目录下
  413. targetClassify, err := classifyOb.GetItemById(targetClassifyId)
  414. if err != nil {
  415. if err.Error() == utils.ErrNoRow() {
  416. errMsg = "当前分类不存在"
  417. err = errors.New(errMsg)
  418. return
  419. }
  420. errMsg = "获取失败"
  421. err = errors.New("获取分类信息失败,Err:" + err.Error())
  422. return
  423. }
  424. orderStr := ` order by level asc, sort asc, ai_predict_model_classify_id asc`
  425. tmpList, err := aiPredictModel.GetAiPredictModelClassifyByRootIdLevel(targetClassify.RootId, orderStr)
  426. if err != nil && err.Error() != utils.ErrNoRow() {
  427. errMsg = "获取失败"
  428. err = errors.New("获取数据失败,Err:" + err.Error())
  429. return
  430. }
  431. idMap := make(map[int]struct{})
  432. if len(tmpList) > 0 {
  433. for _, v := range tmpList {
  434. if v.AiPredictModelClassifyId == targetClassify.AiPredictModelClassifyId {
  435. idMap[v.AiPredictModelClassifyId] = struct{}{}
  436. }
  437. }
  438. for _, v := range tmpList {
  439. if _, ok := idMap[v.ParentId]; ok {
  440. idMap[v.AiPredictModelClassifyId] = struct{}{}
  441. }
  442. }
  443. for _, v := range tmpList {
  444. if _, ok := idMap[v.AiPredictModelClassifyId]; ok {
  445. targetItem := new(aiPredictModel.AiPredictModelClassify)
  446. targetItem.AiPredictModelClassifyId = v.AiPredictModelClassifyId
  447. targetItem.ParentId = v.ParentId
  448. targetItem.RootId = v.RootId
  449. //targetItem.UniqueCode = v.UniqueCode
  450. targetItem.Level = v.Level
  451. targetItem.ClassifyName = v.ClassifyName
  452. //targetItem.IsJoinPermission = v.IsJoinPermission
  453. targetList = append(targetList, targetItem)
  454. }
  455. }
  456. }
  457. return
  458. }
  459. func GetAiPredictModelClassifyMaxSort(parentId int) (maxSort int, err error) {
  460. //获取该层级下最大的排序数
  461. classifyOb := new(aiPredictModel.AiPredictModelClassify)
  462. classifyMaxSort, err := classifyOb.GetSortMax(parentId)
  463. if err != nil {
  464. return
  465. }
  466. maxSort = classifyMaxSort
  467. edbMaxSort, err := data_manage.GetThsHfIndexMaxSortByClassifyId(parentId)
  468. if err != nil {
  469. return
  470. }
  471. if maxSort < edbMaxSort {
  472. maxSort = edbMaxSort
  473. }
  474. return
  475. }