瀏覽代碼

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

Roc 4 月之前
父節點
當前提交
ef43aaf37b

+ 40 - 2
controllers/data_manage/chart_classify.go

@@ -426,8 +426,8 @@ func (this *ChartClassifyController) DeleteChartClassifyCheck() {
 		}
 		count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
 		if err != nil {
-			br.Msg = "判断图表名称是否存在失败"
-			br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
+			br.Msg = "判断分类下是否存在图表失败"
+			br.ErrMsg = "判断分类下是否存在图表失败,Err:" + err.Error()
 			return
 		}
 
@@ -448,6 +448,26 @@ func (this *ChartClassifyController) DeleteChartClassifyCheck() {
 			deleteStatus = 2
 			tipsMsg = "确认删除当前目录及包含的子目录吗"
 		}
+	} else if req.ChartInfoId > 0 {
+		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
+		if err != nil {
+			br.Msg = "获取图表信息失败"
+			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+			return
+		}
+
+		// 公开状态校验
+		switch chartInfo.PublicStatus {
+		case utils.DataPublicSuccess:
+			deleteStatus = 1
+			tipsMsg = "当前图表已经公开,请撤销公开后删除"
+			return
+		case utils.DataPublicCommit:
+			deleteStatus = 1
+			tipsMsg = "当前图表已经提交申请公开,请撤销审批单后删除"
+			return
+		}
+
 	}
 	if deleteStatus == 0 {
 		tipsMsg = "可删除,进行删除操作"
@@ -589,6 +609,24 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 			return
 		}
 
+		if chartInfo.SysUserId != this.SysUser.AdminId {
+			br.Msg = "没有该图表的操作权限"
+			br.IsSendEmail = false
+			return
+		}
+
+		// 公开状态校验
+		switch chartInfo.PublicStatus {
+		case utils.DataPublicSuccess:
+			br.Msg = "当前图表已经公开,请撤销公开后删除"
+			br.IsSendEmail = false
+			return
+		case utils.DataPublicCommit:
+			br.Msg = "当前图表已经提交申请公开,请撤销审批单后删除"
+			br.IsSendEmail = false
+			return
+		}
+
 		chartClassifyItem, err := data_manage.GetChartClassifyById(chartInfo.ChartClassifyId)
 		if err != nil {
 			br.Msg = "获取失败"

+ 182 - 11
controllers/data_manage/edb_info_share.go

@@ -17,6 +17,8 @@ import (
 	"strings"
 )
 
+// TODO 取消共享的时候,需要清除对应用户的收藏状态
+
 // EdbInfoShareController 数据管理
 type EdbInfoShareController struct {
 	controllers.BaseAuthController
@@ -131,6 +133,54 @@ func (c *EdbInfoShareController) Save() {
 		return
 	}
 
+	// 如果指标未公开,则判断是否被其他用户使用
+	if edbItem.PublicStatus != utils.DataPublicSuccess {
+		checkUserIdList := []int{sysUser.AdminId}
+		if len(req.UserIdList) > 0 {
+			checkUserIdList = append(checkUserIdList, req.UserIdList...)
+		}
+		noReferenced, otherUserIdList, err, tips := data.CheckEdbReferencedByOthers(edbItem.EdbInfoType, []int{edbItem.EdbInfoId}, checkUserIdList)
+		if err != nil {
+			br.Msg = "保存失败"
+			if tips != "" {
+				br.Msg = tips
+			}
+			br.ErrMsg = "设置指标共享失败,查找指标的关联用户失败,Err:" + err.Error()
+			return
+		}
+
+		if !noReferenced {
+			userNameStr := ``
+			if len(otherUserIdList) > 0 {
+				userNameList := make([]string, 0)
+				userList, err := system.GetAdminListByIdList(otherUserIdList)
+				if err != nil {
+					br.Msg = "保存失败"
+					if tips != "" {
+						br.Msg = tips
+					}
+					br.ErrMsg = "设置指标共享失败,查找用户信息失败,Err:" + err.Error()
+					return
+				}
+				for _, userInfo := range userList {
+					userNameList = append(userNameList, userInfo.RealName)
+				}
+				userNameStr = strings.Join(userNameList, ",")
+			}
+			msg := `指标被其他用户使用,无法设置共享`
+			if userNameStr != "" {
+				msg = fmt.Sprintf(`指标被用户%s使用,无法设置共享`, userNameStr)
+			}
+			if tips != "" {
+				msg = fmt.Sprintf(`%s,用户为:%s,无法设置共享`, tips, userNameStr)
+			}
+			br.Msg = msg
+			br.ErrMsg = "指标被其他用户共享,无法设置共享,EdbInfoId:" + strconv.Itoa(req.EdbInfoId)
+			br.IsSendEmail = false
+			return
+		}
+	}
+
 	obj := data_manage.EdbInfoShare{}
 	err = obj.SaveEdbInfoShare([]int{req.EdbInfoId}, req.UserIdList, req.ShareType)
 	if err != nil {
@@ -602,26 +652,147 @@ func (c *EdbInfoShareController) BatchSave() {
 	}
 
 	num := len(selectEdbInfoIdList)
+	if num <= 0 {
+		br.Msg = `请选择指标`
+		br.IsSendEmail = false
+		return
+	}
 	if num > 30 {
 		br.Msg = `指标数量不能超过30个`
 		br.IsSendEmail = false
 		return
 	}
 
-	// 设置
-	if num > 0 {
-		obj := data_manage.EdbInfoShare{}
-		err = obj.SaveEdbInfoShare(selectEdbInfoIdList, req.UserIdList, req.ShareType)
-		if err != nil {
-			br.Msg = `保存失败`
-			br.ErrMsg = `保存失败:` + err.Error()
-			return
+	edbInfoList, err := data_manage.GetEdbInfoListByEdbInfoId(selectEdbInfoIdList)
+	if err != nil {
+		br.Msg = "设置失败!"
+		br.ErrMsg = "设置失败,Err:" + err.Error()
+		return
+	}
+
+	{
+		checkBaseEdbInfoIdList := make([]int, 0)
+		checkCalculateEdbInfoIdList := make([]int, 0)
+
+		for _, edbItem := range edbInfoList {
+			// 设置公开的可以忽略
+			if edbItem.PublicStatus == utils.DataPublicSuccess {
+				continue
+			}
+
+			if edbItem.EdbInfoType == utils.EDB_INFO_TYPE {
+				checkBaseEdbInfoIdList = append(checkBaseEdbInfoIdList, edbItem.EdbInfoId)
+			} else if edbItem.EdbInfoType == utils.PREDICT_EDB_INFO_TYPE {
+				checkCalculateEdbInfoIdList = append(checkCalculateEdbInfoIdList, edbItem.EdbInfoId)
+			}
 		}
 
-		// 更新es
-		for _, edbInfoId := range selectEdbInfoIdList {
-			data.AddOrEditEdbInfoToEs(edbInfoId)
+		checkUserIdList := []int{sysUser.AdminId}
+		if len(req.UserIdList) > 0 {
+			checkUserIdList = append(checkUserIdList, req.UserIdList...)
 		}
+
+		// 普通指标
+		{
+			noReferenced, otherUserIdList, err, tips := data.CheckEdbReferencedByOthers(utils.EDB_INFO_TYPE, checkBaseEdbInfoIdList, checkUserIdList)
+			if err != nil {
+				br.Msg = "保存失败"
+				if tips != "" {
+					br.Msg = tips
+				}
+				br.ErrMsg = "设置指标共享失败,查找指标的关联用户失败,Err:" + err.Error()
+				return
+			}
+
+			if !noReferenced {
+				userNameStr := ``
+				if len(otherUserIdList) > 0 {
+					userNameList := make([]string, 0)
+					userList, err := system.GetAdminListByIdList(otherUserIdList)
+					if err != nil {
+						br.Msg = "保存失败"
+						if tips != "" {
+							br.Msg = tips
+						}
+						br.ErrMsg = "设置指标共享失败,查找用户信息失败,Err:" + err.Error()
+						return
+					}
+					for _, userInfo := range userList {
+						userNameList = append(userNameList, userInfo.RealName)
+					}
+					userNameStr = strings.Join(userNameList, ",")
+				}
+				msg := `指标被其他用户使用,无法设置共享`
+				if userNameStr != "" {
+					msg = fmt.Sprintf(`指标被用户%s使用,无法设置共享`, userNameStr)
+				}
+				if tips != "" {
+					msg = fmt.Sprintf(`%s,用户为:%s,无法设置共享`, tips, userNameStr)
+				}
+				br.Msg = msg
+				br.ErrMsg = "指标被其他用户共享,无法设置共享"
+				br.IsSendEmail = false
+				return
+			}
+		}
+
+		// 预测指标
+		{
+			noReferenced, otherUserIdList, err, tips := data.CheckEdbReferencedByOthers(utils.PREDICT_EDB_INFO_TYPE, checkCalculateEdbInfoIdList, checkUserIdList)
+			if err != nil {
+				br.Msg = "保存失败"
+				if tips != "" {
+					br.Msg = tips
+				}
+				br.ErrMsg = "设置指标共享失败,查找指标的关联用户失败,Err:" + err.Error()
+				return
+			}
+
+			if !noReferenced {
+				userNameStr := ``
+				if len(otherUserIdList) > 0 {
+					userNameList := make([]string, 0)
+					userList, err := system.GetAdminListByIdList(otherUserIdList)
+					if err != nil {
+						br.Msg = "保存失败"
+						if tips != "" {
+							br.Msg = tips
+						}
+						br.ErrMsg = "设置指标共享失败,查找用户信息失败,Err:" + err.Error()
+						return
+					}
+					for _, userInfo := range userList {
+						userNameList = append(userNameList, userInfo.RealName)
+					}
+					userNameStr = strings.Join(userNameList, ",")
+				}
+				msg := `指标被其他用户使用,无法设置共享`
+				if userNameStr != "" {
+					msg = fmt.Sprintf(`指标被用户%s使用,无法设置共享`, userNameStr)
+				}
+				if tips != "" {
+					msg = fmt.Sprintf(`%s,用户为:%s,无法设置共享`, tips, userNameStr)
+				}
+				br.Msg = msg
+				br.ErrMsg = "指标被其他用户共享,无法设置共享"
+				br.IsSendEmail = false
+				return
+			}
+		}
+	}
+
+	// 设置
+	obj := data_manage.EdbInfoShare{}
+	err = obj.SaveEdbInfoShare(selectEdbInfoIdList, req.UserIdList, req.ShareType)
+	if err != nil {
+		br.Msg = `保存失败`
+		br.ErrMsg = `保存失败:` + err.Error()
+		return
+	}
+
+	// 更新es
+	for _, edbInfoId := range selectEdbInfoIdList {
+		data.AddOrEditEdbInfoToEs(edbInfoId)
 	}
 
 	br.Ret = 200

+ 48 - 0
models/data_manage/chart_edb_mapping.go

@@ -1,6 +1,7 @@
 package data_manage
 
 import (
+	sql2 "database/sql"
 	"eta_gn/eta_api/global"
 	"eta_gn/eta_api/utils"
 	"fmt"
@@ -483,3 +484,50 @@ func GetRelationEdbInfoListMappingByCondition(condition string, pars []interface
 
 	return
 }
+
+// GetCountRelationChartEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联图数量
+// @author: Roc
+// @datetime 2024-12-26 10:13:47
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetCountRelationChartEdbInfoListMappingByCondition(condition string, pars []interface{}) (total int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT COUNT(1) total FROM chart_edb_mapping AS a 
+	JOIN chart_info AS b on a.chart_info_id = b.chart_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	var totalNull sql2.NullInt64
+	err = o.Raw(sql, pars...).Scan(&totalNull).Error
+	if err != nil {
+		return
+	}
+	total = int(totalNull.Int64)
+
+	return
+}
+
+// GetUserIdListRelationChartEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联图的用户id列表
+// @author: Roc
+// @datetime 2024-12-26 10:13:47
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetUserIdListRelationChartEdbInfoListMappingByCondition(condition string, pars []interface{}) (userIdList []int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT b.sys_user_id FROM chart_edb_mapping AS a 
+	JOIN chart_info AS b on a.chart_info_id = b.chart_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY b.sys_user_id `
+
+	err = o.Raw(sql, pars...).Scan(&userIdList).Error
+
+	return
+}

+ 48 - 0
models/data_manage/edb_info_calculate_mapping.go

@@ -1,6 +1,7 @@
 package data_manage
 
 import (
+	sql2 "database/sql"
 	"eta_gn/eta_api/global"
 	"eta_gn/eta_api/utils"
 	"time"
@@ -110,3 +111,50 @@ func GetEdbInfoCalculateMappingListByEdbInfoIds(edbInfoIds []int) (items []*EdbI
 
 	return
 }
+
+// GetCountRelationEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联指标数量
+// @author: Roc
+// @datetime 2024-12-26 10:37:48
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetCountRelationEdbInfoListMappingByCondition(condition string, pars []interface{}) (total int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT COUNT(1) total FROM edb_info_calculate_mapping AS a 
+	JOIN edb_info AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	var totalNull sql2.NullInt64
+	err = o.Raw(sql, pars...).Scan(&totalNull).Error
+	if err != nil {
+		return
+	}
+	total = int(totalNull.Int64)
+
+	return
+}
+
+// GetCountRelationEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联指标的用户id列表
+// @author: Roc
+// @datetime 2024-12-26 10:37:48
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetUserIdListRelationEdbInfoListMappingByCondition(condition string, pars []interface{}) (userIdList []int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT b.sys_user_id FROM edb_info_calculate_mapping AS a 
+	JOIN edb_info AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY b.sys_user_id `
+
+	err = o.Raw(sql, pars...).Scan(&userIdList).Error
+
+	return
+}

+ 1 - 1
models/data_manage/edb_info_share.go

@@ -197,7 +197,7 @@ func (m EdbInfoShare) GetAllEditSharedEdbInfoIdListByReceivedUserId(sysUserId in
 	}
 	sql += ` GROUP BY a.edb_info_id `
 
-	err = global.DmSQL["data"].Raw(sql, sysUserId, utils.ShareTypeEdit).Scan(&list).Error
+	err = global.DmSQL["data"].Raw(sql, pars...).Scan(&list).Error
 	return
 }
 

+ 49 - 0
models/data_manage/excel/excel_edb_mapping.go

@@ -1,6 +1,7 @@
 package excel
 
 import (
+	sql2 "database/sql"
 	"eta_gn/eta_api/global"
 	"eta_gn/eta_api/utils"
 	"fmt"
@@ -152,3 +153,51 @@ func GetExcelEdbMappingItemByExcelInfoIdOrKeyword(excelInfoId int, keyword strin
 	err = global.DmSQL["data"].Raw(sql, pars...).Find(&items).Error
 	return
 }
+
+// GetCountRelationExcelEdbInfoListMappingByCondition
+// @Description: 根据条件获取表格关联指标的数量
+// @author: Roc
+// @datetime 2024-12-26 10:37:48
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetCountRelationExcelEdbInfoListMappingByCondition(condition string, pars []interface{}) (total int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT COUNT(1) total FROM excel_edb_mapping AS a 
+	JOIN excel_info AS b on a.excel_info_id = b.excel_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	var totalNull sql2.NullInt64
+	err = o.Raw(sql, pars...).Scan(&totalNull).Error
+	if err != nil {
+		return
+	}
+
+	total = int(totalNull.Int64)
+
+	return
+}
+
+// GetUserIdListRelationExcelEdbInfoListMappingByCondition
+// @Description: 根据条件获取表格关联指标的用户id列表
+// @author: Roc
+// @datetime 2024-12-26 10:37:48
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetUserIdListRelationExcelEdbInfoListMappingByCondition(condition string, pars []interface{}) (userIdList []int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT b.sys_user_id FROM excel_edb_mapping AS a 
+	JOIN excel_info AS b on a.excel_info_id = b.excel_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY b.sys_user_id `
+
+	err = o.Raw(sql, pars...).Scan(&userIdList).Error
+
+	return
+}

+ 48 - 0
models/data_manage/predict_edb_conf.go

@@ -1,6 +1,7 @@
 package data_manage
 
 import (
+	sql2 "database/sql"
 	"eta_gn/eta_api/global"
 	"eta_gn/eta_api/utils"
 	"time"
@@ -169,3 +170,50 @@ func GetGroupPredictEdbInfoIdListBySourceEdbInfoId(sourceEdbInfoId int) (items [
 	err = global.DmSQL["data"].Raw(sql, sourceEdbInfoId).Scan(&items).Error
 	return
 }
+
+// GetCountRelationPredictEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联预测指标数量
+// @author: Roc
+// @datetime 2024-12-26 10:13:47
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetCountRelationPredictEdbInfoListMappingByCondition(condition string, pars []interface{}) (total int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT COUNT(1) total FROM predict_edb_conf AS a 
+	JOIN edb_info AS b on a.predict_edb_info_id = b.edb_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	var totalNull sql2.NullInt64
+	err = o.Raw(sql, pars...).Scan(&totalNull).Error
+	if err != nil {
+		return
+	}
+	total = int(totalNull.Int64)
+
+	return
+}
+
+// GetUserIdListRelationPredictEdbInfoListMappingByCondition
+// @Description: 根据条件获取关联预测指标的用户id列表
+// @author: Roc
+// @datetime 2024-12-26 10:13:47
+// @param condition string
+// @param pars []interface{}
+// @return total int
+// @return err error
+func GetUserIdListRelationPredictEdbInfoListMappingByCondition(condition string, pars []interface{}) (userIdList []int, err error) {
+	o := global.DmSQL["data"]
+	sql := ` SELECT b.sys_user_id FROM predict_edb_conf AS a 
+	JOIN edb_info AS b on a.predict_edb_info_id = b.edb_info_id WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY b.sys_user_id `
+
+	err = o.Raw(sql, pars...).Scan(&userIdList).Error
+
+	return
+}

+ 6 - 0
services/data/data_approve/approve.go

@@ -985,6 +985,12 @@ func DataApproveCancel(DataApproveId, adminId int, adminName string) (msg string
 		return
 	}
 
+	if approveItem.State != DataApproveStatePass {
+		msg = "审批单已通过,不允许撤回"
+		err = fmt.Errorf("审批单已通过,不允许撤回")
+		return
+	}
+
 	// 撤销审批
 	e = cancelDataApprove(approveItem, approveItem.DataType, approveItem.DataApproveId, adminId, adminName)
 	if e != nil {

+ 21 - 0
services/data/edb_classify.go

@@ -613,6 +613,18 @@ func DeleteCheck(classifyId, edbInfoId int, sysUser *system.Admin) (deleteStatus
 			return
 		}
 
+		// 公开状态校验
+		switch edbInfo.PublicStatus {
+		case utils.DataPublicSuccess:
+			deleteStatus = 4
+			tipsMsg = "当前指标已经公开,请撤销公开后删除"
+			return
+		case utils.DataPublicCommit:
+			deleteStatus = 4
+			tipsMsg = "当前指标已经提交申请公开,请撤销审批单后删除"
+			return
+		}
+
 		//判断指标是否用于作图,如果用于作图,则不可删除
 		chartCount, tmpErr := data_manage.GetChartEdbMappingCount(edbInfoId)
 		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
@@ -831,6 +843,15 @@ func Delete(classifyId, edbInfoId int, sysUser *system.Admin, requestBody, reque
 			errMsg = "指标已删除,请刷新页面"
 			return
 		}
+		// 公开状态校验
+		switch edbInfo.PublicStatus {
+		case utils.DataPublicSuccess:
+			errMsg = "当前指标已经公开,请撤销公开后删除"
+			return
+		case utils.DataPublicCommit:
+			errMsg = "当前指标已经提交申请公开,请撤销审批单后删除"
+			return
+		}
 
 		//判断指标是否用于作图,如果用于作图,则不可删除
 		chartCount, tmpErr := data_manage.GetChartEdbMappingCount(edbInfoId)

+ 74 - 0
services/data/edb_info.go

@@ -2052,3 +2052,77 @@ func GetIsSupplierStop(source int, edbCode string) (isSupplierStop int) {
 }
 
 //IsSupplierStop  int    `description:"是否供应商停更:1:停更,0:未停更"`
+
+func CheckEdbReferencedByOthers(edbInfoType int, edbInfoIdList, belongUserIdList []int) (noReferenced bool, otherUserIdList []int, err error, tips string) {
+	otherUserIdList = []int{}
+	//判断指标是否用于作图,如果用于作图,则不可删除
+	{
+		var condition string
+		var pars []interface{}
+		// 关联指标
+		condition += ` AND a.edb_info_id in (?) AND b.sys_user_id not in (?) `
+		pars = append(pars, edbInfoIdList, belongUserIdList)
+		otherUserIdList, err = data_manage.GetUserIdListRelationChartEdbInfoListMappingByCondition(condition, pars)
+		if err != nil {
+			err = errors.New("判断指标是否被用于作图失败,Err:" + err.Error())
+			return
+		}
+		if len(otherUserIdList) > 0 {
+			tips = "当前指标已被其他用户用作画图"
+			return
+		}
+	}
+
+	//如果是普通指标,那么还需要判断是否被预测指标作为源指标
+	if edbInfoType == 0 {
+		condition := ` AND a.source_edb_info_id  in (?) AND b.sys_user_id not in (?) `
+		pars := []interface{}{edbInfoIdList, belongUserIdList}
+		otherUserIdList, err = data_manage.GetUserIdListRelationPredictEdbInfoListMappingByCondition(condition, pars)
+		if err != nil {
+			err = errors.New("判断指标是否被用于预测指标失败,Err:" + err.Error())
+			return
+		}
+		if len(otherUserIdList) > 0 {
+			tips = "当前指标已被其他用户用作预测指标"
+			return
+		}
+	}
+
+	//判断指标是否用作其他指标的计算
+	{
+		condition := ` AND a.from_edb_info_id in (?) AND b.sys_user_id  not in (?) `
+		pars := []interface{}{edbInfoIdList, belongUserIdList}
+		otherUserIdList, err = data_manage.GetUserIdListRelationEdbInfoListMappingByCondition(condition, pars)
+		if err != nil {
+			err = errors.New("判断指标是否被用于计算失败,GetCountRelationEdbInfoListMappingByCondition Err:" + err.Error())
+			return
+		}
+		if len(otherUserIdList) > 0 {
+			tips = "当前指标已被其他用户用作指标运算"
+			return
+		}
+	}
+
+	// 判断指标是否用作表格引用
+	{
+		condition := ` AND a.edb_info_id in (?) AND b.sys_user_id not in (?) `
+		pars := []interface{}{edbInfoIdList, belongUserIdList}
+		otherUserIdList, err = excel.GetUserIdListRelationExcelEdbInfoListMappingByCondition(condition, pars)
+		if err != nil {
+			err = errors.New("判断指标是否用作表格引用,GetCountRelationExcelEdbInfoListMappingByCondition Err:" + err.Error())
+			return
+		}
+		if len(otherUserIdList) > 0 {
+			tips = "当前指标已被其他用户用作表格引用"
+			return
+		}
+	}
+	// 判断指标是否用作跨品种图表使用
+	{
+		// todo 跨品种分析图表就是可以使用其他人配置的指标,理论上是不需要去校验是否被他人引用的,后面如果有涉及到这块的校验再去进行补充
+
+	}
+
+	noReferenced = true
+	return
+}

+ 1 - 4
services/data/public_chart.go

@@ -23,10 +23,7 @@ import (
 // @return err error
 // @return errMsg string
 func DeleteChartPublicCheck(chartInfoId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) {
-	// TODO 操作权限校验
-	{
-
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	// 移除指标
 	if chartInfoId > 0 {

+ 3 - 10
services/data/public_chart_classify.go

@@ -10,8 +10,6 @@ import (
 	"time"
 )
 
-// TODO 分类名称允许在不同人的名下重复
-
 // AddChartPublicClassify
 // @Description: 添加公共指标分类
 // @author: Roc
@@ -141,9 +139,7 @@ func EditChartPublicClassify(classifyId int, classifyName string, sysUser *syste
 		return
 	}
 
-	// TODO 操作权限校验
-	{
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	// 需要变更的字段
 	updateCols := make([]string, 0)
@@ -230,10 +226,7 @@ func GetChartPublicClassifyMaxSort(parentId, source int) (maxSort int, err error
 
 // DeleteChartPublicClassifyCheck 删除检测
 func DeleteChartPublicClassifyCheck(classifyId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, allClassifyIdList []int, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) {
-	// TODO 操作权限校验
-	{
-
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	chartPublicClassifyObj := data_manage.ChartPublicClassify{}
 	// 查找当前分类
@@ -409,8 +402,8 @@ func MoveChartPublicClassify(req data_manage.MoveChartClassifyReq, sysUser *syst
 			return
 		}
 
-		// TODO 移动权限校验
 	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	if prevClassifyId > 0 {
 		prevClassify, err = obj.GetChartClassifyById(prevClassifyId)

+ 1 - 4
services/data/public_edb.go

@@ -23,10 +23,7 @@ import (
 // @return err error
 // @return errMsg string
 func DeleteEdbPublicCheck(edbInfoId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) {
-	// TODO 操作权限校验
-	{
-
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	// 移除指标
 	if edbInfoId > 0 {

+ 3 - 9
services/data/public_edb_classify.go

@@ -140,9 +140,7 @@ func EditEdbPublicClassify(classifyId int, classifyName string, sysUser *system.
 		return
 	}
 
-	// TODO 操作权限校验
-	{
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	// 需要变更的字段
 	updateCols := make([]string, 0)
@@ -229,10 +227,7 @@ func GetEdbPublicClassifyMaxSort(parentId int, classifyType uint8) (maxSort int,
 
 // DeleteEdbPublicClassifyCheck 删除检测
 func DeleteEdbPublicClassifyCheck(classifyId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, allClassifyIdList []int, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) {
-	// TODO 操作权限校验
-	{
-
-	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	edbPublicClassifyObj := data_manage.EdbPublicClassify{}
 	// 查找当前分类
@@ -396,9 +391,8 @@ func MoveEdbPublicClassify(req data_manage.MoveEdbClassifyReq, sysUser *system.A
 			err = errors.New(errMsg)
 			return
 		}
-
-		// TODO 移动权限校验
 	}
+	// 操作权限校验? 应该不需要,理论上来说只要有这个菜单(api)的就有当前权限
 
 	if prevClassifyId > 0 {
 		prevClassify, err = obj.GetEdbClassifyById(prevClassifyId)