Browse Source

Merge remote-tracking branch 'origin/eta/2.3' into debug

Roc 3 months ago
parent
commit
7bfdb81aaf

+ 0 - 54
controllers/data_manage/chart_classify.go

@@ -21,7 +21,6 @@ type ChartClassifyController struct {
 // ChartClassifyListV2
 // @Title 图表分类列表
 // @Description 图表分类列表接口
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Success 200 {object} data_manage.ChartClassifyListResp
 // @router /chart_classify/list [get]
 func (this *ChartClassifyController) ChartClassifyListV2() {
@@ -47,26 +46,6 @@ func (this *ChartClassifyController) ChartClassifyListV2() {
 		}
 	}
 
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		errMsg, err := getChartClassifyListForMe(*this.SysUser, resp)
-		if err != nil {
-			br.Msg = errMsg
-			br.ErrMsg = err.Error()
-			return
-		}
-		// 移除没有权限的图表
-		allNodes := data.HandleNoPermissionChart(resp.AllNodes, noPermissionChartIdMap, this.SysUser.AdminId)
-		resp.AllNodes = allNodes
-
-		br.Ret = 200
-		br.Success = true
-		br.Msg = "获取成功"
-		br.Data = resp
-		fmt.Println("source my classify")
-		return
-	}
-
 	//判断是否存在缓存,如果存在缓存,那么直接从缓存中获取
 	key := utils.CACHE_CHART_CLASSIFY
 	if utils.Re == nil {
@@ -451,12 +430,6 @@ func (this *ChartClassifyController) DeleteChartClassifyCheck() {
 			br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
 			return
 		}
-		//count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		//if err != nil {
-		//	br.Msg = "删除失败"
-		//	br.ErrMsg = "分类下是否含有指标失败,Err:" + err.Error()
-		//	return
-		//}
 
 		if count > 0 {
 			deleteStatus = 1
@@ -579,12 +552,6 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 			br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
 			return
 		}
-		//count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		//if err != nil && !utils.IsErrNoRow(err) {
-		//	br.Msg = "删除失败"
-		//	br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
-		//	return
-		//}
 
 		if count > 0 {
 			br.Msg = "该目录下存在关联指标,不可删除"
@@ -933,7 +900,6 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 // ChartClassifyChartListV2
 // @Title 根据图表分类获取图表列表
 // @Description 根据图表分类获取图表列表接口
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   ChartClassifyId   query   bool  true       "图片分类id"
 // @Success 200 {object} data_manage.ChartClassifyListResp
 // @router /chart_classify/chart/list [get]
@@ -975,26 +941,6 @@ func (this *ChartClassifyController) ChartClassifyChartListV2() {
 		}
 	}
 
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		allChartInfo, err := data_manage.GetChartInfoByAdminIdAndClassify([]int{utils.CHART_SOURCE_DEFAULT}, sysUser.AdminId, chartClassifyId)
-		if err != nil && !utils.IsErrNoRow(err) {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取全部数据失败,Err:" + err.Error()
-			return
-		}
-		// 移除没有权限的图表
-		allNodes := data.HandleNoPermissionChart(allChartInfo, noPermissionChartIdMap, this.SysUser.AdminId)
-		resp.AllNodes = allNodes
-
-		br.Ret = 200
-		br.Success = true
-		br.Msg = "获取成功"
-		br.Data = resp
-		fmt.Println("source my classify")
-		return
-	}
-
 	allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
 	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"

+ 20 - 32
controllers/data_manage/chart_info.go

@@ -2027,7 +2027,6 @@ func (this *ChartInfoController) ChartInfoEdbInfoDetail() {
 // @Title 图表模糊搜索
 // @Description 图表模糊搜索接口
 // @Param   KeyWord   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search [get]
 func (this *ChartInfoController) ChartInfoSearch() {
@@ -2062,12 +2061,7 @@ func (this *ChartInfoController) ChartInfoSearch() {
 	//		return
 	//	}
 	//}
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	var keyWordArr []string
 	keyWordArr = append(keyWordArr, keyWord)
@@ -2152,7 +2146,6 @@ func (this *ChartInfoController) ChartInfoSearch() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
 func (this *ChartInfoController) ChartInfoSearchByEs() {
@@ -2183,12 +2176,7 @@ func (this *ChartInfoController) ChartInfoSearchByEs() {
 
 	keyword := this.GetString("Keyword")
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	var searchList []*data_manage.ChartInfo
 	var total int64
@@ -3089,26 +3077,26 @@ func (this *ChartInfoController) CopyChartInfo() {
 	//	return
 	//}
 	//判断图表是否存在
-	var condition string
-	var pars []interface{}
-	condition += " AND chart_classify_id=? "
-	pars = append(pars, req.ChartClassifyId)
+	//var condition string
+	//var pars []interface{}
+	//condition += " AND chart_classify_id=? "
+	//pars = append(pars, req.ChartClassifyId)
 
-	condition += " AND chart_name=? AND source = ? "
-	pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT)
-
-	count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
-	if err != nil {
-		br.Msg = "判断图表名称是否存在失败"
-		br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
-		return
-	}
+	//condition += " AND chart_name=? AND source = ? "
+	//pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT)
 
-	if count > 0 {
-		br.Msg = "图表已存在,请重新填写"
-		br.IsSendEmail = false
-		return
-	}
+	//count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
+	//if err != nil {
+	//	br.Msg = "判断图表名称是否存在失败"
+	//	br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
+	//	return
+	//}
+	//
+	//if count > 0 {
+	//	br.Msg = "图表已存在,请重新填写"
+	//	br.IsSendEmail = false
+	//	return
+	//}
 
 	//获取原图表关联的指标信息列表
 	edbMappingList, err := data_manage.GetChartEdbMappingList(req.ChartInfoId)

+ 3 - 14
controllers/data_manage/correlation/correlation_chart_info.go

@@ -459,7 +459,6 @@ func (this *CorrelationChartInfoController) Move() {
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartClassifyId   query   int  true       "分类id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "图表类型,3:相关性,4:滚动相关性"
 // @Success 200 {object} data_manage.ChartListResp
 // @router /chart_info/list [get]
@@ -520,12 +519,8 @@ func (this *CorrelationChartInfoController) List() {
 		condition += ` AND  ( chart_name LIKE '%` + keyword + `%' )`
 	}
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		condition += ` AND sys_user_id = ? `
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += ` AND sys_user_id = ? `
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	noPermissionChartIdList := make([]int, 0)
@@ -1877,7 +1872,6 @@ func (this *CorrelationChartInfoController) EnInfoEdit() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "来源,3:相关性,4:滚动相关性,默认0:全部"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
@@ -1909,12 +1903,7 @@ func (this *CorrelationChartInfoController) SearchByEs() {
 
 	keyword := this.GetString("Keyword")
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	source, _ := this.GetInt("Source")
 	sourceList := make([]int, 0)

+ 3 - 14
controllers/data_manage/cross_variety/chart_info.go

@@ -33,7 +33,6 @@ type ChartInfoController struct {
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartClassifyId   query   int  true       "分类id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "图表类型,10:跨品种分析
 // @Success 200 {object} data_manage.ChartListResp
 // @router /chart_info/list [get]
@@ -94,12 +93,8 @@ func (c *ChartInfoController) List() {
 		condition += ` AND  ( chart_name LIKE '%` + keyword + `%' )`
 	}
 
-	//只看我的
-	isShowMe, _ := c.GetBool("IsShowMe")
-	if isShowMe {
-		condition += ` AND sys_user_id = ? `
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += ` AND sys_user_id = ? `
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	noPermissionChartIdList := make([]int, 0)
@@ -1389,7 +1384,6 @@ func (c *ChartInfoController) DeleteChart() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "来源,3:拟合方程,4:滚动拟合方程,默认0:全部"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
@@ -1424,12 +1418,7 @@ func (c *ChartInfoController) SearchByEs() {
 		keyword = c.GetString("KeyWord")
 	}
 
-	//只看我的
-	isShowMe, _ := c.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	sourceList := []int{utils.CHART_SOURCE_CROSS_HEDGING}
 

+ 3 - 14
controllers/data_manage/line_equation/line_chart_info.go

@@ -537,7 +537,6 @@ func (this *LineEquationChartInfoController) Move() {
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartClassifyId   query   int  true       "分类id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "图表类型,3:拟合方程,4:滚动拟合方程"
 // @Success 200 {object} data_manage.ChartListResp
 // @router /chart_info/list [get]
@@ -598,12 +597,8 @@ func (this *LineEquationChartInfoController) List() {
 		condition += ` AND  ( chart_name LIKE '%` + keyword + `%' )`
 	}
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		condition += ` AND sys_user_id = ? `
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += ` AND sys_user_id = ? `
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	noPermissionChartIdList := make([]int, 0)
@@ -1544,7 +1539,6 @@ func (this *LineEquationChartInfoController) EnInfoEdit() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "来源,3:拟合方程,4:滚动拟合方程,默认0:全部"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
@@ -1576,12 +1570,7 @@ func (this *LineEquationChartInfoController) SearchByEs() {
 
 	keyword := this.GetString("Keyword")
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	sourceList := []int{utils.CHART_SOURCE_LINE_EQUATION}
 

+ 3 - 14
controllers/data_manage/line_feature/chart_info.go

@@ -1586,7 +1586,6 @@ func (this *LineFeaturesChartInfoController) Move() {
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartClassifyId   query   int  true       "分类id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "图表类型,3:统计特征,4:滚动统计特征"
 // @Success 200 {object} data_manage.ChartListResp
 // @router /chart_info/list [get]
@@ -1642,12 +1641,8 @@ func (this *LineFeaturesChartInfoController) List() {
 		condition += ` AND  ( chart_name LIKE '%` + keyword + `%' )`
 	}
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		condition += ` AND sys_user_id = ? `
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += ` AND sys_user_id = ? `
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	noPermissionChartIdList := make([]int, 0)
@@ -2676,7 +2671,6 @@ func (this *LineFeaturesChartInfoController) EnInfoEdit() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "来源,3:统计特征,4:滚动统计特征,默认0:全部"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
@@ -2708,12 +2702,7 @@ func (this *LineFeaturesChartInfoController) SearchByEs() {
 
 	keyword := this.GetString("Keyword")
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	sourceList := []int{utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY}
 

+ 2 - 5
controllers/data_manage/predict_edb_info.go

@@ -56,7 +56,6 @@ func (this *PredictEdbInfoController) EdbChartList() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	adminId, _ := this.GetInt("AdminId")
-	isOnlyMe, _ := this.GetBool("IsOnlyMe")
 
 	var total int
 	page := paging.GetPaging(currentIndex, pageSize, total)
@@ -96,10 +95,8 @@ func (this *PredictEdbInfoController) EdbChartList() {
 		condition += " AND sys_user_id = ? "
 		pars = append(pars, adminId)
 	}
-	if isOnlyMe {
-		condition += " AND sys_user_id = ? "
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += " AND sys_user_id = ? "
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}

+ 3 - 14
controllers/data_manage/range_analysis/chart_info.go

@@ -897,7 +897,6 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartClassifyId   query   int  true       "分类id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "图表类型,3:区间计算,4:滚动区间计算"
 // @Success 200 {object} data_manage.ChartListResp
 // @router /chart_info/list [get]
@@ -964,12 +963,8 @@ func (this *RangeChartChartInfoController) List() {
 		condition += ` )`
 	}
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	if isShowMe {
-		condition += ` AND sys_user_id = ? `
-		pars = append(pars, sysUser.AdminId)
-	}
+	condition += ` AND sys_user_id = ? `
+	pars = append(pars, sysUser.AdminId)
 
 	// 获取当前账号的不可见指标
 	noPermissionChartIdList := make([]int, 0)
@@ -1780,7 +1775,6 @@ func (this *RangeChartChartInfoController) MultipleGraphConfigEdbList() {
 // @Title 图表模糊搜索(从es获取)
 // @Description  图表模糊搜索(从es获取)
 // @Param   Keyword   query   string  true       "图表名称"
-// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
 // @Param   Source   query   int  true       "来源,3:相关性,4:滚动相关性,默认0:全部"
 // @Success 200 {object} data_manage.ChartInfo
 // @router /chart_info/search_by_es [get]
@@ -1812,12 +1806,7 @@ func (this *RangeChartChartInfoController) SearchByEs() {
 
 	keyword := this.GetString("Keyword")
 
-	//只看我的
-	isShowMe, _ := this.GetBool("IsShowMe")
-	showSysId := 0
-	if isShowMe {
-		showSysId = sysUser.AdminId
-	}
+	showSysId := sysUser.AdminId
 
 	sourceList := make([]int, 0)
 	sourceList = append(sourceList, utils.CHART_SOURCE_RANGE_ANALYSIS)

+ 1 - 1
controllers/fix.go

@@ -615,7 +615,7 @@ func createNewChartClassify(userId, parentId, rootId, level int, sysUserName, pa
 		ChartClassifyNamePath: classifyNamePath,
 		ChartClassifyIdPath:   "",
 	}
-	_, err := data_manage.AddChartClassify(classifyInfo)
+	err := data_manage.AddChartClassify(classifyInfo)
 	if err != nil {
 		fmt.Println("创建分类失败:", err.Error())
 		return

+ 60 - 2
models/data_manage/chart_classify.go

@@ -27,12 +27,11 @@ type ChartClassify struct {
 	ChartClassifyIdPath   string    `description:"分类的完整路径,格式为:父级ID,当前ID"`
 }
 
-func AddChartClassify(item *ChartClassify) (lastId int64, err error) {
+func AddChartClassify(item *ChartClassify) (err error) {
 	err = global.DmSQL["data"].Create(item).Error
 	if err != nil {
 		return
 	}
-	lastId = int64(item.ChartClassifyId)
 
 	return
 }
@@ -469,3 +468,62 @@ func DelChartClassifyByIdList(idList []int) (err error) {
 
 	return
 }
+
+// UpdateClassifyNameAndNamePath
+// @Description: 更新分类名称和完整名称路径
+// @author: Roc
+// @receiver chartClassify
+// @datetime 2024-12-09 14:13:05
+// @param cols []string
+// @param oldClassifyNamePath string
+// @param newClassifyNamePath string
+// @return err error
+func (chartClassify *ChartClassify) UpdateClassifyNameAndNamePath(cols []string, oldClassifyNamePath, newClassifyNamePath string) (err error) {
+	tx := global.DmSQL["data"].Begin()
+	defer func() {
+		if err != nil {
+			_ = tx.Rollback()
+			return
+		}
+		_ = tx.Commit()
+	}()
+
+	// 变更分类信息
+	err = tx.Select(cols).Updates(chartClassify).Error
+	if err != nil {
+		return
+	}
+
+	// 更改子分类的完整的路径
+	if oldClassifyNamePath != `` && newClassifyNamePath != `` {
+		sql := `UPDATE chart_classify SET chart_classify_name_path = REPLACE(chart_classify_name_path,?,?) WHERE chart_classify_id_path LIKE ?`
+		err = tx.Exec(sql, oldClassifyNamePath, newClassifyNamePath, fmt.Sprint(chartClassify.ChartClassifyIdPath+`,%`)).Error
+		if err != nil {
+			return
+		}
+	}
+
+	return
+}
+
+// UpdateChartClassifyNameAndNamePathByOldClassifyIdPath
+// @Description: 根据源分类id全路径更新分类名称和子分类的全路径
+// @author: Roc
+// @receiver edbClassify
+// @datetime 2024-11-26 14:39:09
+// @param cols []string
+// @param oldClassifyNamePath string
+// @param newClassifyNamePath string
+// @return err error
+func UpdateChartClassifyNameAndNamePathByOldClassifyIdPath(oldClassifyIdPath, newClassifyIdPath, oldClassifyNamePath, newClassifyNamePath string) (err error) {
+	// 更改子分类的完整的路径
+	if oldClassifyIdPath != `` && newClassifyNamePath != `` && newClassifyIdPath != `` {
+		sql := `UPDATE chart_classify SET chart_classify_id_path = REPLACE(chart_classify_id_path,?,?) ,chart_classify_name_path = REPLACE(chart_classify_name_path,?,?)  WHERE chart_classify_id_path LIKE ?`
+		err = global.DmSQL["data"].Exec(sql, oldClassifyIdPath, newClassifyIdPath, oldClassifyNamePath, newClassifyNamePath, fmt.Sprint(oldClassifyIdPath+`,%`)).Error
+		if err != nil {
+			return
+		}
+	}
+
+	return
+}

+ 515 - 23
services/data/chart_classify.go

@@ -244,6 +244,7 @@ func AddChartClassify(chartClassifyName string, parentId, level, source int, lan
 	}
 	//查询顶级rootId
 	rootId := 0
+	var classifyNamePath, classifyIdPath string
 	if parentId > 0 {
 		parentClassify, tErr := data_manage.GetChartClassifyById(parentId)
 		if tErr != nil {
@@ -257,6 +258,10 @@ func AddChartClassify(chartClassifyName string, parentId, level, source int, lan
 			return
 		}
 		rootId = parentClassify.RootId
+		classifyNamePath = fmt.Sprint(parentClassify.ChartClassifyNamePath, "|", chartClassifyName)
+		classifyIdPath = fmt.Sprint(parentClassify.ChartClassifyIdPath, ",")
+	} else {
+		classifyNamePath = chartClassifyName
 	}
 
 	classifyInfo = new(data_manage.ChartClassify)
@@ -274,18 +279,24 @@ func AddChartClassify(chartClassifyName string, parentId, level, source int, lan
 	classifyInfo.Sort = maxSort + 1
 	classifyInfo.Source = source
 	classifyInfo.RootId = rootId
+	classifyInfo.ChartClassifyNamePath = classifyNamePath
 
-	newId, err := data_manage.AddChartClassify(classifyInfo)
+	err = data_manage.AddChartClassify(classifyInfo)
 	if err != nil {
 		return
 	}
+
+	// 更改分类id完整路径path
+	updateCols := []string{"ClassifyIdPath"}
+	classifyInfo.ChartClassifyIdPath = fmt.Sprint(classifyIdPath, classifyInfo.ChartClassifyId)
 	if parentId == 0 { //一级目录的rootId等于自己本身
-		classifyInfo.RootId = int(newId)
-		err = classifyInfo.Update([]string{"RootId"})
-		if err != nil {
-			errMsg = "更新分类失败"
-			return
-		}
+		classifyInfo.RootId = classifyInfo.ChartClassifyId
+		updateCols = append(updateCols, "RootId")
+	}
+	err = classifyInfo.Update(updateCols)
+	if err != nil {
+		errMsg = "更新分类失败"
+		return
 	}
 
 	//// 目前只有ETA图库需要继承分类权限
@@ -329,6 +340,8 @@ func EditChartClassify(chartClassifyId, source int, chartClassifyName, lang stri
 
 	// 需要变更的字段
 	updateCols := make([]string, 0)
+	// 旧完整路径  , 新的完整路径
+	var oldClassifyNamePath, newClassifyNamePath string
 
 	// 语言版本校验
 	switch lang {
@@ -353,27 +366,41 @@ func EditChartClassify(chartClassifyId, source int, chartClassifyName, lang stri
 		}
 	default:
 		if classifyInfo.ChartClassifyName != chartClassifyName {
-			count, tmpErr := data_manage.GetChartClassifyCount(chartClassifyName, classifyInfo.ParentId, source)
-			if tmpErr != nil {
-				errMsg = "判断名称是否已存在失败"
-				err = errors.New("判断名称是否已存在失败,Err:" + tmpErr.Error())
-				return
-			}
-			if count > 0 {
-				errMsg = "分类名称已存在,请重新输入"
-				err = errors.New(errMsg)
-				isSendEmail = false
-				return
+			//count, tmpErr := data_manage.GetChartClassifyCount(chartClassifyName, classifyInfo.ParentId, source)
+			//if tmpErr != nil {
+			//	errMsg = "判断名称是否已存在失败"
+			//	err = errors.New("判断名称是否已存在失败,Err:" + tmpErr.Error())
+			//	return
+			//}
+			//if count > 0 {
+			//	errMsg = "分类名称已存在,请重新输入"
+			//	err = errors.New(errMsg)
+			//	isSendEmail = false
+			//	return
+			//}
+			// 旧完整路径
+			oldClassifyNamePath = classifyInfo.ChartClassifyNamePath
+
+			if classifyInfo.ParentId > 0 {
+				parentItem, tmpErr := data_manage.GetChartClassifyById(classifyInfo.ParentId)
+				if tmpErr != nil {
+					err = tmpErr
+					return
+				}
+				newClassifyNamePath = fmt.Sprint(parentItem.ChartClassifyNamePath, "|", chartClassifyName)
+			} else {
+				newClassifyNamePath = chartClassifyName
 			}
 
 			classifyInfo.ChartClassifyName = chartClassifyName
 			classifyInfo.ModifyTime = time.Now()
-			updateCols = append(updateCols, "ChartClassifyName", "ModifyTime")
+			classifyInfo.ChartClassifyNamePath = newClassifyNamePath
+			updateCols = append(updateCols, "ChartClassifyName", "ModifyTime", "ChartClassifyNamePath")
 		}
 	}
 
 	if len(updateCols) > 0 {
-		err = classifyInfo.Update(updateCols)
+		err = classifyInfo.UpdateClassifyNameAndNamePath(updateCols, oldClassifyNamePath, newClassifyNamePath)
 	}
 
 	return
@@ -546,12 +573,298 @@ func MoveChartClassify(req data_manage.MoveChartClassifyReq, sysUser *system.Adm
 		nextSort = nextChartInfo.Sort
 	}
 
-	err, errMsg = moveChartClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify, chartInfo, prevChartInfo, nextChartInfo, parentClassifyId, prevSort, nextSort, source)
+	err, errMsg = moveChartOrClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify, chartInfo, prevChartInfo, nextChartInfo, parentClassifyId, prevSort, nextSort, source)
 	return
 }
 
-// moveChartClassify 移动图表分类
-func moveChartClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify *data_manage.ChartClassify, chartInfo, prevChartInfo, nextChartInfo *data_manage.ChartInfo, parentClassifyId, prevSort, nextSort, source int) (err error, errMsg string) {
+func moveChartOrClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify *data_manage.ChartClassify, chartInfo, prevChartInfo, nextChartInfo *data_manage.ChartInfo, parentClassifyId, prevSort, nextSort, source int) (err error, errMsg string) {
+	updateCol := make([]string, 0)
+
+	// 移动对象为分类, 判断分类是否存在
+	if chartClassifyInfo != nil {
+		oldParentId := chartClassifyInfo.ParentId
+		oldLevel := chartClassifyInfo.Level
+		var classifyIds []int
+		if oldParentId != parentClassifyId {
+			//更新子分类对应的level
+			childList, e, m := GetChildChartClassifyByClassifyId(chartClassifyInfo.ChartClassifyId)
+			if e != nil {
+				errMsg = "移动失败"
+				err = errors.New("查询子分类失败,Err:" + e.Error() + m)
+				return
+			}
+
+			if len(childList) > 0 {
+				for _, v := range childList {
+					if v.ChartClassifyId == chartClassifyInfo.ChartClassifyId {
+						continue
+					}
+					classifyIds = append(classifyIds, v.ChartClassifyId)
+				}
+			}
+		}
+		//判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
+		if chartClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
+			if chartClassifyInfo.Level != parentChartClassifyInfo.Level+1 { //禁止层级调整
+				errMsg = "移动失败"
+				err = errors.New("不支持目录层级变更")
+				return
+			}
+			chartClassifyInfo.ParentId = parentChartClassifyInfo.ChartClassifyId
+			chartClassifyInfo.RootId = parentChartClassifyInfo.RootId
+			chartClassifyInfo.Level = parentChartClassifyInfo.Level + 1
+			chartClassifyInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "ParentId", "RootId", "Level", "ModifyTime")
+		} else if chartClassifyInfo.ParentId != parentClassifyId && parentClassifyId == 0 {
+			errMsg = "移动失败"
+			err = errors.New("不支持目录层级变更")
+			return
+		}
+
+		if prevSort > 0 {
+			//如果是移动在两个兄弟节点之间
+			if nextSort > 0 {
+				//下一个兄弟节点
+				//如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
+				if prevSort == nextSort || prevSort == chartClassifyInfo.Sort {
+					//变更兄弟节点的排序
+					updateSortStr := `sort + 2`
+
+					//变更分类
+					if prevClassify != nil {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevClassify.Sort, updateSortStr, source)
+					} else {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+					}
+
+					//变更图表
+					if prevChartInfo != nil {
+						//变更兄弟节点的排序
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+					} else {
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+					}
+				} else {
+					//如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
+					if nextSort-prevSort == 1 {
+						//变更兄弟节点的排序
+						updateSortStr := `sort + 1`
+
+						//变更分类
+						if prevClassify != nil {
+							_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevSort, updateSortStr, source)
+						} else {
+							_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+						}
+
+						//变更图表
+						if prevChartInfo != nil {
+							//变更兄弟节点的排序
+							_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+						} else {
+							_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+						}
+
+					}
+				}
+			}
+
+			chartClassifyInfo.Sort = prevSort + 1
+			chartClassifyInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		} else if prevClassify == nil && nextClassify == nil && prevChartInfo == nil && nextChartInfo == nil && parentClassifyId > 0 {
+			//处理只拖动到目录里,默认放到目录底部的情况
+			var maxSort int
+			maxSort, err = GetChartClassifyMaxSort(parentClassifyId, source)
+			if err != nil {
+				errMsg = "移动失败"
+				err = errors.New("查询组内排序信息失败,Err:" + err.Error())
+				return
+			}
+			chartClassifyInfo.Sort = maxSort + 1 //那就是排在组内最后一位
+			chartClassifyInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		} else {
+			// 拖动到父级分类的第一位
+			firstClassify, tmpErr := data_manage.GetFirstChartClassifyByParentId(parentClassifyId)
+			if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
+				errMsg = "移动失败"
+				err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
+				return
+			}
+
+			//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+			if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
+				updateSortStr := ` sort + 1 `
+				_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, firstClassify.ChartClassifyId-1, 0, updateSortStr, source)
+				//该分类下的所有图表也需要+1
+				_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, 0, updateSortStr)
+			} else {
+				//如果该分类下存在图表,且第一个图表的排序等于0,那么需要调整排序
+				firstEdb, tErr := data_manage.GetFirstChartInfoByClassifyId(parentClassifyId)
+				if tErr != nil && !utils.IsErrNoRow(tErr) {
+					errMsg = "移动失败"
+					err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tErr.Error())
+					return
+				}
+
+				//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+				if firstEdb != nil && firstEdb.ChartClassifyId > 0 && firstEdb.Sort == 0 {
+					updateSortStr := ` sort + 1 `
+					_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, firstEdb.ChartInfoId-1, updateSortStr)
+					_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, 0, updateSortStr, source)
+				}
+			}
+
+			chartClassifyInfo.Sort = 0 //那就是排在第一位
+			chartClassifyInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		}
+
+		//更新
+		if len(updateCol) > 0 {
+			err = chartClassifyInfo.Update(updateCol)
+			if err != nil {
+				errMsg = "移动失败"
+				err = errors.New("修改失败,Err:" + err.Error())
+				return
+			}
+			//更新对应分类的root_id和层级
+			if oldParentId != parentClassifyId {
+				if len(classifyIds) > 0 {
+					levelStep := chartClassifyInfo.Level - oldLevel
+					err = data_manage.UpdateEdbClassifyChildByParentClassifyId(classifyIds, chartClassifyInfo.RootId, levelStep)
+					if err != nil {
+						errMsg = "移动失败"
+						err = errors.New("更新子分类失败,Err:" + err.Error())
+						return
+					}
+				}
+			}
+		}
+	} else {
+		if chartInfo == nil {
+			errMsg = "当前图表不存在"
+			err = errors.New(errMsg)
+			return
+		}
+		//如果改变了分类,那么移动该图表数据
+		if chartInfo.ChartClassifyId != parentClassifyId {
+			chartInfo.ChartClassifyId = parentClassifyId
+			chartInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "ChartClassifyId", "ModifyTime")
+		}
+		if prevSort > 0 {
+			//如果是移动在两个兄弟节点之间
+			if nextSort > 0 {
+				//下一个兄弟节点
+				//如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
+				if prevSort == nextSort || prevSort == chartInfo.Sort {
+					//变更兄弟节点的排序
+					updateSortStr := `sort + 2`
+
+					//变更分类
+					if prevClassify != nil {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevClassify.Sort, updateSortStr, source)
+					} else {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+					}
+
+					//变更图表
+					if prevChartInfo != nil {
+						//变更兄弟节点的排序
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+					} else {
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+					}
+				} else {
+					//如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
+					if nextSort-prevSort == 1 {
+						//变更兄弟节点的排序
+						updateSortStr := `sort + 1`
+						//变更分类
+						if prevClassify != nil {
+							_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevSort, updateSortStr, source)
+						} else {
+							_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+						}
+
+						//变更图表
+						if prevChartInfo != nil {
+							//变更兄弟节点的排序
+							_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+						} else {
+							_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+						}
+					}
+				}
+			}
+
+			chartInfo.Sort = prevSort + 1
+			chartInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		} else if prevClassify == nil && nextClassify == nil && prevChartInfo == nil && nextChartInfo == nil && parentClassifyId > 0 {
+			//处理只拖动到目录里,默认放到目录底部的情况
+			var maxSort int
+			maxSort, err = GetChartClassifyMaxSort(parentClassifyId, source)
+			if err != nil {
+				errMsg = "移动失败"
+				err = errors.New("查询组内排序信息失败,Err:" + err.Error())
+				return
+			}
+			chartInfo.Sort = maxSort + 1 //那就是排在组内最后一位
+			chartInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		} else {
+			// 拖动到父级分类的第一位
+			firstClassify, tmpErr := data_manage.GetFirstChartClassifyByParentId(parentClassifyId)
+			if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
+				errMsg = "移动失败"
+				err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
+				return
+			}
+
+			//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+			if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
+				updateSortStr := ` sort + 1 `
+				_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, firstClassify.ChartClassifyId-1, 0, updateSortStr, source)
+				//该分类下的所有图表也需要+1
+				_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, 0, updateSortStr)
+			} else {
+				//如果该分类下存在图表,且第一个图表的排序等于0,那么需要调整排序
+				firstEdb, tErr := data_manage.GetFirstChartInfoByClassifyId(parentClassifyId)
+				if tErr != nil && !utils.IsErrNoRow(tErr) {
+					errMsg = "移动失败"
+					err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tErr.Error())
+					return
+				}
+
+				//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+				if firstEdb != nil && firstEdb.ChartClassifyId > 0 && firstEdb.Sort == 0 {
+					updateSortStr := ` sort + 1 `
+					_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, firstEdb.ChartInfoId-1, updateSortStr)
+					_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, 0, updateSortStr, source)
+				}
+			}
+
+			chartInfo.Sort = 0 //那就是排在第一位
+			chartInfo.ModifyTime = time.Now()
+			updateCol = append(updateCol, "Sort", "ModifyTime")
+		}
+
+		//更新
+		if len(updateCol) > 0 {
+			err = chartInfo.Update(updateCol)
+			if err != nil {
+				errMsg = "移动失败"
+				err = errors.New("修改失败,Err:" + err.Error())
+				return
+			}
+		}
+	}
+	return
+}
+func moveChart(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify *data_manage.ChartClassify, chartInfo, prevChartInfo, nextChartInfo *data_manage.ChartInfo, parentClassifyId, prevSort, nextSort, source int) (err error, errMsg string) {
 	updateCol := make([]string, 0)
 
 	// 移动对象为分类, 判断分类是否存在
@@ -839,6 +1152,185 @@ func moveChartClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify,
 	return
 }
 
+// moveChartClassify 移动图表分类
+func moveChartClassify(parentChartClassifyInfo, chartClassifyInfo, prevClassify, nextClassify *data_manage.ChartClassify, prevChartInfo, nextChartInfo *data_manage.ChartInfo, parentClassifyId, prevSort, nextSort, source int) (err error, errMsg string) {
+	updateCol := make([]string, 0)
+
+	oldParentId := chartClassifyInfo.ParentId
+	oldLevel := chartClassifyInfo.Level
+	var classifyIds []int
+	if oldParentId != parentClassifyId {
+		//更新子分类对应的level
+		childList, e, m := GetChildChartClassifyByClassifyId(chartClassifyInfo.ChartClassifyId)
+		if e != nil {
+			errMsg = "移动失败"
+			err = errors.New("查询子分类失败,Err:" + e.Error() + m)
+			return
+		}
+
+		if len(childList) > 0 {
+			for _, v := range childList {
+				if v.ChartClassifyId == chartClassifyInfo.ChartClassifyId {
+					continue
+				}
+				classifyIds = append(classifyIds, v.ChartClassifyId)
+			}
+		}
+	}
+	//判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
+	if chartClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
+		if chartClassifyInfo.Level != parentChartClassifyInfo.Level+1 { //禁止层级调整
+			errMsg = "移动失败"
+			err = errors.New("不支持目录层级变更")
+			return
+		}
+		chartClassifyInfo.ParentId = parentChartClassifyInfo.ChartClassifyId
+		chartClassifyInfo.RootId = parentChartClassifyInfo.RootId
+		chartClassifyInfo.Level = parentChartClassifyInfo.Level + 1
+		chartClassifyInfo.ModifyTime = time.Now()
+		updateCol = append(updateCol, "ParentId", "RootId", "Level", "ModifyTime")
+	} else if chartClassifyInfo.ParentId != parentClassifyId && parentClassifyId == 0 {
+		errMsg = "移动失败"
+		err = errors.New("不支持目录层级变更")
+		return
+	}
+
+	if prevSort > 0 {
+		//如果是移动在两个兄弟节点之间
+		if nextSort > 0 {
+			//下一个兄弟节点
+			//如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
+			if prevSort == nextSort || prevSort == chartClassifyInfo.Sort {
+				//变更兄弟节点的排序
+				updateSortStr := `sort + 2`
+
+				//变更分类
+				if prevClassify != nil {
+					_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevClassify.Sort, updateSortStr, source)
+				} else {
+					_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+				}
+
+				//变更图表
+				if prevChartInfo != nil {
+					//变更兄弟节点的排序
+					_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+				} else {
+					_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+				}
+			} else {
+				//如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
+				if nextSort-prevSort == 1 {
+					//变更兄弟节点的排序
+					updateSortStr := `sort + 1`
+
+					//变更分类
+					if prevClassify != nil {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, prevClassify.ChartClassifyId, prevSort, updateSortStr, source)
+					} else {
+						_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, prevSort, updateSortStr, source)
+					}
+
+					//变更图表
+					if prevChartInfo != nil {
+						//变更兄弟节点的排序
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, prevChartInfo.ChartInfoId, updateSortStr)
+					} else {
+						_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, prevSort, 0, updateSortStr)
+					}
+
+				}
+			}
+		}
+
+		chartClassifyInfo.Sort = prevSort + 1
+		chartClassifyInfo.ModifyTime = time.Now()
+		updateCol = append(updateCol, "Sort", "ModifyTime")
+	} else if prevClassify == nil && nextClassify == nil && prevChartInfo == nil && nextChartInfo == nil && parentClassifyId > 0 {
+		//处理只拖动到目录里,默认放到目录底部的情况
+		var maxSort int
+		maxSort, err = GetChartClassifyMaxSort(parentClassifyId, source)
+		if err != nil {
+			errMsg = "移动失败"
+			err = errors.New("查询组内排序信息失败,Err:" + err.Error())
+			return
+		}
+		chartClassifyInfo.Sort = maxSort + 1 //那就是排在组内最后一位
+		chartClassifyInfo.ModifyTime = time.Now()
+		updateCol = append(updateCol, "Sort", "ModifyTime")
+	} else {
+		// 拖动到父级分类的第一位
+		firstClassify, tmpErr := data_manage.GetFirstChartClassifyByParentId(parentClassifyId)
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
+			errMsg = "移动失败"
+			err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
+			return
+		}
+
+		//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+		if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
+			updateSortStr := ` sort + 1 `
+			_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, firstClassify.ChartClassifyId-1, 0, updateSortStr, source)
+			//该分类下的所有图表也需要+1
+			_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, 0, updateSortStr)
+		} else {
+			//如果该分类下存在图表,且第一个图表的排序等于0,那么需要调整排序
+			firstEdb, tErr := data_manage.GetFirstChartInfoByClassifyId(parentClassifyId)
+			if tErr != nil && !utils.IsErrNoRow(tErr) {
+				errMsg = "移动失败"
+				err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tErr.Error())
+				return
+			}
+
+			//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
+			if firstEdb != nil && firstEdb.ChartClassifyId > 0 && firstEdb.Sort == 0 {
+				updateSortStr := ` sort + 1 `
+				_ = data_manage.UpdateChartInfoSortByClassifyIdV2(parentClassifyId, 0, firstEdb.ChartInfoId-1, updateSortStr)
+				_ = data_manage.UpdateChartClassifySortByParentIdAndSource(parentClassifyId, 0, 0, updateSortStr, source)
+			}
+		}
+
+		chartClassifyInfo.Sort = 0 //那就是排在第一位
+		chartClassifyInfo.ModifyTime = time.Now()
+		updateCol = append(updateCol, "Sort", "ModifyTime")
+	}
+
+	oldClassifyIdPath := chartClassifyInfo.ChartClassifyIdPath
+	oldClassifyNamePath := chartClassifyInfo.ChartClassifyNamePath
+	newClassifyNamePath := fmt.Sprint(chartClassifyInfo.ChartClassifyNamePath, `|`, chartClassifyInfo.ChartClassifyName)
+	newClassifyIdPath := fmt.Sprint(chartClassifyInfo.ChartClassifyIdPath, `,`, chartClassifyInfo.ChartClassifyId)
+
+	//更新
+	if len(updateCol) > 0 {
+		err = chartClassifyInfo.Update(updateCol)
+		if err != nil {
+			errMsg = "移动失败"
+			err = errors.New("修改失败,Err:" + err.Error())
+			return
+		}
+		//更新对应分类的root_id和层级
+		if oldParentId != parentClassifyId {
+			if len(classifyIds) > 0 {
+				levelStep := chartClassifyInfo.Level - oldLevel
+				err = data_manage.UpdateEdbClassifyChildByParentClassifyId(classifyIds, chartClassifyInfo.RootId, levelStep)
+				if err != nil {
+					errMsg = "移动失败"
+					err = errors.New("更新子分类失败,Err:" + err.Error())
+					return
+				}
+			}
+
+			// 更改了上级分类,那么需要同步去更改自己的分类全路径
+			tmpErr := data_manage.UpdateChartClassifyNameAndNamePathByOldClassifyIdPath(oldClassifyIdPath, newClassifyIdPath, oldClassifyNamePath, newClassifyNamePath)
+			if tmpErr != nil {
+				utils.FileLog.Error(fmt.Sprintf("更新图表分类全路径失败,分类id:%d;失败原因Err:%s", chartClassifyInfo.ChartClassifyId, tmpErr.Error()))
+			}
+		}
+	}
+
+	return
+}
+
 func GetChildChartClassifyByClassifyId(targetClassifyId int) (targetList []*data_manage.ChartClassifyIdItems, err error, errMsg string) {
 	//判断是否是挂在顶级目录下
 	targetClassify, err := data_manage.GetChartClassifyById(targetClassifyId)

+ 12 - 12
services/data/edb_classify.go

@@ -442,18 +442,18 @@ func EditEdbClassify(classifyId int, classifyName, lang string, sysUser *system.
 			return
 		}
 
-		// 判断名称是否已存在
-		count, tmpErr := data_manage.GetEdbClassifyCount(classifyName, item.ParentId, sysUser.AdminId, item.ClassifyType)
-		if tmpErr != nil {
-			err = tmpErr
-			errMsg = "判断名称是否已存在失败"
-			return
-		}
-		if count > 0 {
-			errMsg = "分类名称已存在,请重新输入"
-			err = errors.New(errMsg)
-			return
-		}
+		//// 判断名称是否已存在
+		//count, tmpErr := data_manage.GetEdbClassifyCount(classifyName, item.ParentId, sysUser.AdminId, item.ClassifyType)
+		//if tmpErr != nil {
+		//	err = tmpErr
+		//	errMsg = "判断名称是否已存在失败"
+		//	return
+		//}
+		//if count > 0 {
+		//	errMsg = "分类名称已存在,请重新输入"
+		//	err = errors.New(errMsg)
+		//	return
+		//}
 
 		// 旧完整路径
 		oldClassifyNamePath = item.ClassifyNamePath

+ 0 - 6
services/data/edb_public_classify.go

@@ -836,12 +836,6 @@ func moveEdbPublicClassify(parentEdbClassifyInfo, edbClassifyInfo, prevClassify,
 					return
 				}
 			}
-
-			// 更改了上级分类,那么需要同步去更改自己的分类全路径
-			tmpErr := data_manage.UpdateEdbClassifyNameAndNamePathByOldClassifyIdPath(oldClassifyIdPath, newClassifyIdPath, oldClassifyNamePath, newClassifyNamePath)
-			if tmpErr != nil {
-				utils.FileLog.Error(fmt.Sprintf("更新分类全路径失败,分类id:%d;失败原因Err:%s", edbClassifyInfo.ClassifyId, tmpErr.Error()))
-			}
 		}
 
 	}