Roc 2 months ago
parent
commit
fc02154c79

+ 3 - 3
controllers/data_manage/edb_info.go

@@ -1796,7 +1796,7 @@ func (this *EdbInfoController) EdbInfoFilterByEs() {
 	var err error
 
 	// 获取es搜索参数
-	source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := data.GetGeneralEdbEsSearchParams(edbTypeStr, this.SysUser.AdminId, edbAuth, edbCollect, classifyId)
+	noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := data.GetGeneralEdbEsSearchParams(edbTypeStr, this.SysUser.AdminId, edbAuth, edbCollect, classifyId)
 	if err != nil {
 		br.Msg = "获取失败"
 		if errMsg != `` {
@@ -1813,7 +1813,7 @@ func (this *EdbInfoController) EdbInfoFilterByEs() {
 	}
 
 	// 普通的搜索
-	total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, sortMap)
+	total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, []string{frequency}, []string{}, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, sortMap)
 
 	if err != nil {
 		edbInfoList = make([]*data_manage.EdbInfoList, 0)
@@ -3195,7 +3195,7 @@ func (this *EdbInfoController) AllEdbInfoByEs() {
 		keyWordArr = append(keyWordArr, newKeyWord...)
 
 		// 普通的搜索
-		total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, []int{}, []int{}, []int{}, []int{1, 2}, -1, 0, this.SysUser.AdminId, map[string]string{})
+		total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, []string{frequency}, []string{}, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, []int{}, []int{}, []int{}, []int{1, 2}, -1, 0, this.SysUser.AdminId, map[string]string{})
 		isEs = true
 	} else {
 		var condition string

+ 394 - 120
controllers/data_manage/edb_info_calculate.go

@@ -5,16 +5,17 @@ import (
 	"eta_gn/eta_api/controllers"
 	"eta_gn/eta_api/models"
 	"eta_gn/eta_api/models/data_manage"
+	"eta_gn/eta_api/models/data_manage/request"
 	"eta_gn/eta_api/services/data"
 	"eta_gn/eta_api/services/data/data_manage_permission"
+	"eta_gn/eta_api/services/elastic"
 	"eta_gn/eta_api/utils"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"net/url"
 	"strconv"
 	"strings"
 	"time"
-
-	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // 计算指标
@@ -2091,8 +2092,8 @@ func (this *ChartInfoController) CalculateMultiChoice() {
 	//来源类型,1:中文,2:英文
 	frequency := this.GetString("Frequency")
 	keyword := this.GetString("Keyword")
-	sysUserIds := this.GetString("SysUserIds")
-	classifyIds := this.GetString("ClassifyIds")
+	//sysUserIds := this.GetString("SysUserIds")
+	//classifyIds := this.GetString("ClassifyIds")
 	edbInfoIds := this.GetString("EdbInfoIds")
 	selectAll, _ := this.GetBool("SelectAll")
 	notFrequency := this.GetString("NotFrequency")
@@ -2114,48 +2115,34 @@ func (this *ChartInfoController) CalculateMultiChoice() {
 
 	if selectAll {
 		// 如果勾了列表全选,那么EdbCode传的就是排除的code
-
-		condition := ` AND edb_info_type = ? `
-		pars := make([]interface{}, 0)
-		pars = append(pars, edbInfoType)
-
-		if classifyIds != "" {
-			classifyIdsArr := strings.Split(classifyIds, ",")
-			condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdsArr)) + `) `
-			pars = append(pars, classifyIdsArr)
-		}
-
-		if frequency != "" {
-			frequencyArr := strings.Split(frequency, ",")
-			condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencyArr)) + `) `
-			pars = append(pars, frequencyArr)
-		}
-		if notFrequency != "" {
-			notFrequencyArr := strings.Split(notFrequency, ",")
-			condition += ` AND frequency NOT IN (` + utils.GetOrmInReplace(len(notFrequencyArr)) + `) `
-			pars = append(pars, notFrequencyArr)
-		}
-
-		if sysUserIds != "" {
-			sysUserIdSlice := strings.Split(sysUserIds, ",")
-			condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
-			pars = append(pars, sysUserIdSlice)
-		}
-
-		if keyword != "" {
-			keyWordArr := strings.Split(keyword, " ")
-
-			if len(keyWordArr) > 0 {
-				for _, v := range keyWordArr {
-					condition += ` AND CONCAT(edb_name,edb_code) LIKE ?`
-					pars = append(pars, utils.GetLikeKeyword(v))
-				}
+		edbTypeStr := `0`
+		if edbInfoType == 1 {
+			edbTypeStr = `3`
+		}
+		sortMap := make(map[string]string)
+		// 如果没有搜索关键词,则默认根据指标编码倒序排序
+		if keyword == `` {
+			sortMap["EdbInfoId"] = `desc`
+		}
+		generalEdbEsSearchReq := request.GeneralEdbEsSearchReq{
+			FilterSource: 0,
+			//ClassifyId:   0,
+			Source:       0,
+			EdbAuth:      0,
+			EdbCollect:   0,
+			Frequency:    frequency,
+			NotFrequency: notFrequency,
+			EdbType:      edbTypeStr,
+			Keyword:      keyword,
+			KeyWord:      keyword,
+		}
+		edbList, err, errMsg := data.GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(generalEdbEsSearchReq, this.SysUser.AdminId)
+		if err != nil {
+			br.Msg = "获取指标列表失败!"
+			if errMsg != `` {
+				br.Msg = errMsg
 			}
-		}
-		edbList, e := data_manage.GetEdbInfoListByCond(condition, pars)
-		if e != nil {
-			br.Msg = "获取指标列表失败"
-			br.ErrMsg = "获取指标列表失败,Err:" + e.Error()
+			br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
 			return
 		}
 
@@ -2279,8 +2266,8 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 	//来源类型,1:中文,2:英文
 	frequency := this.GetString("Frequency")
 	keyword := this.GetString("Keyword")
-	sysUserIds := this.GetString("SysUserIds")
-	classifyIds := this.GetString("ClassifyIds")
+	keyword = strings.TrimSpace(keyword)
+	//classifyIds := this.GetString("ClassifyIds")
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -2298,90 +2285,50 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 
 	var edbIdArr []int
 
-	condition := ` AND edb_info_type = ? `
-	pars := make([]interface{}, 0)
-	pars = append(pars, edbInfoType)
-
-	if classifyIds != "" {
-		classifyIdsArr := strings.Split(classifyIds, ",")
-		condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdsArr)) + `) `
-		pars = append(pars, classifyIdsArr)
-	}
-
+	frequencyList := make([]string, 0)
 	if frequency != "" {
-		frequencyArr := strings.Split(frequency, ",")
-		condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencyArr)) + `) `
-		pars = append(pars, frequencyArr)
+		frequencyList = strings.Split(frequency, ",")
 	}
+
+	notFrequencyList := make([]string, 0)
 	if notFrequency != "" {
-		notFrequencyArr := strings.Split(notFrequency, ",")
-		condition += ` AND frequency NOT IN (` + utils.GetOrmInReplace(len(notFrequencyArr)) + `) `
-		pars = append(pars, notFrequencyArr)
+		notFrequencyList = strings.Split(notFrequency, ",")
 	}
-	if sysUserIds != "" {
-		sysUserIdSlice := strings.Split(sysUserIds, ",")
-		condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
-		pars = append(pars, sysUserIdSlice)
-	}
-
-	if keyword != "" {
-		keyWordArr := strings.Split(keyword, " ")
 
-		if len(keyWordArr) > 0 {
-			for _, v := range keyWordArr {
-				condition += ` AND CONCAT(edb_name,edb_code) LIKE ?`
-				pars = append(pars, utils.GetLikeKeyword(v))
-			}
+	source := 0
+	edbAuth := 0
+	edbCollect := 0
+	edbTypeStr := `0`
+	if edbInfoType == 1 {
+		edbTypeStr = `3`
+	}
+	// 获取es搜索参数
+	noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := data.GetGeneralEdbEsSearchParams(edbTypeStr, this.SysUser.AdminId, edbAuth, edbCollect, 0)
+	if err != nil {
+		br.Msg = "获取失败"
+		if errMsg != `` {
+			br.Msg = errMsg
 		}
+		br.ErrMsg = "获取失败:" + err.Error()
+		return
 	}
 
-	total, e := data_manage.GetEdbInfoByConditionCount(condition, pars)
-	if e != nil {
-		br.Msg = "获取指标列表总数失败"
-		br.ErrMsg = "获取指标列表总数失败,Err:" + e.Error()
-		return
+	sortMap := make(map[string]string)
+	// 如果没有搜索关键词,则默认根据指标编码倒序排序
+	if keyword == `` {
+		sortMap["EdbInfoId"] = `desc`
 	}
 
+	// 普通的搜索
+	total, edbList, err := elastic.SearchEdbInfoData(keyword, startSize, pageSize, 0, source, frequencyList, notFrequencyList, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, sortMap)
+
 	searchItemList := make([]data_manage.CalculateMultiEdbSearchItem, 0)
-	page := paging.GetPaging(currentIndex, pageSize, total)
+	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp := new(data_manage.CalculateMultiEdbSearchResp)
 
-	edbList, e := data_manage.GetEdbInfoListByCondition(condition, pars, startSize, pageSize, "")
-	if e != nil {
-		br.Msg = "获取指标列表失败"
-		br.ErrMsg = "获取指标列表失败,Err:" + e.Error()
-		return
-	}
-
 	if len(edbList) > 0 {
-		classifyIdList := make([]int, 0)
 		for _, v := range edbList {
 			edbIdArr = append(edbIdArr, v.EdbInfoId)
-			classifyIdList = append(classifyIdList, v.ClassifyId)
-		}
-
-		// 当前列表中的分类map
-		classifyMap := make(map[int]*data_manage.EdbClassify)
-		{
-			classifyList, err := data_manage.GetEdbClassifyByIdList(classifyIdList)
-			if err != nil {
-				if err != nil {
-					br.Msg = "获取失败"
-					br.ErrMsg = "获取分类列表失败,Err:" + err.Error()
-					return
-				}
-			}
-			for _, v := range classifyList {
-				classifyMap[v.ClassifyId] = v
-			}
-		}
-
-		// 获取所有有权限的指标和分类
-		permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
-			return
 		}
 
 		list, err := data_manage.GetEdbInfoByIdList(edbIdArr)
@@ -2391,10 +2338,6 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 			return
 		}
 		for _, info := range list {
-			var haveOperaAuth bool
-			if currClassify, ok := classifyMap[info.ClassifyId]; ok {
-				haveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(info.IsJoinPermission, currClassify.IsJoinPermission, info.EdbInfoId, info.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
-			}
 			searchItem := data_manage.CalculateMultiEdbSearchItem{
 				Frequency:       info.Frequency,
 				Unit:            info.Unit,
@@ -2407,7 +2350,7 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 				SysUserId:       info.SysUserId,
 				EndDate:         utils.TimeToFormatDate(info.EndDate),
 				EndValue:        info.EndValue,
-				HaveOperaAuth:   haveOperaAuth,
+				HaveOperaAuth:   true,
 				EdbInfoType:     info.EdbInfoType,
 			}
 			searchItemList = append(searchItemList, searchItem)
@@ -2421,3 +2364,334 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+//func (this *ChartInfoController) CalculateMultiChoiceBak() {
+//	br := new(models.BaseResponse).Init()
+//	defer func() {
+//		this.Data["json"] = br
+//		this.ServeJSON()
+//	}()
+//
+//	//来源类型,1:中文,2:英文
+//	frequency := this.GetString("Frequency")
+//	keyword := this.GetString("Keyword")
+//	sysUserIds := this.GetString("SysUserIds")
+//	classifyIds := this.GetString("ClassifyIds")
+//	edbInfoIds := this.GetString("EdbInfoIds")
+//	selectAll, _ := this.GetBool("SelectAll")
+//	notFrequency := this.GetString("NotFrequency")
+//	edbInfoType, _ := this.GetInt("EdbInfoType", 0)
+//	var edbIdArr []int
+//	var filterEdbIds []int
+//	if edbInfoIds != "" {
+//		arr := strings.Split(edbInfoIds, ",")
+//		for _, v := range arr {
+//			t, e := strconv.Atoi(v)
+//			if e != nil {
+//				br.Msg = "参数有误"
+//				br.ErrMsg = fmt.Sprintf("指标ID有误, %s", v)
+//				return
+//			}
+//			filterEdbIds = append(filterEdbIds, t)
+//		}
+//	}
+//
+//	if selectAll {
+//		// 如果勾了列表全选,那么EdbCode传的就是排除的code
+//
+//		condition := ` AND edb_info_type = ? `
+//		pars := make([]interface{}, 0)
+//		pars = append(pars, edbInfoType)
+//
+//		if classifyIds != "" {
+//			classifyIdsArr := strings.Split(classifyIds, ",")
+//			condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdsArr)) + `) `
+//			pars = append(pars, classifyIdsArr)
+//		}
+//
+//		if frequency != "" {
+//			frequencyArr := strings.Split(frequency, ",")
+//			condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencyArr)) + `) `
+//			pars = append(pars, frequencyArr)
+//		}
+//		if notFrequency != "" {
+//			notFrequencyArr := strings.Split(notFrequency, ",")
+//			condition += ` AND frequency NOT IN (` + utils.GetOrmInReplace(len(notFrequencyArr)) + `) `
+//			pars = append(pars, notFrequencyArr)
+//		}
+//
+//		if sysUserIds != "" {
+//			sysUserIdSlice := strings.Split(sysUserIds, ",")
+//			condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
+//			pars = append(pars, sysUserIdSlice)
+//		}
+//
+//		if keyword != "" {
+//			keyWordArr := strings.Split(keyword, " ")
+//
+//			if len(keyWordArr) > 0 {
+//				for _, v := range keyWordArr {
+//					condition += ` AND CONCAT(edb_name,edb_code) LIKE ?`
+//					pars = append(pars, utils.GetLikeKeyword(v))
+//				}
+//			}
+//		}
+//		edbList, e := data_manage.GetEdbInfoListByCond(condition, pars)
+//		if e != nil {
+//			br.Msg = "获取指标列表失败"
+//			br.ErrMsg = "获取指标列表失败,Err:" + e.Error()
+//			return
+//		}
+//
+//		filterLen := len(filterEdbIds)
+//		for _, v := range edbList {
+//			// 全选-排除传入的指标
+//			if filterLen > 0 && utils.InArrayByInt(filterEdbIds, v.EdbInfoId) {
+//				continue
+//			}
+//			edbIdArr = append(edbIdArr, v.EdbInfoId)
+//		}
+//	} else {
+//		//未勾选全选EdbCode就是需要的code
+//		edbIdStrArr := strings.Split(edbInfoIds, ",")
+//		for _, v := range edbIdStrArr {
+//			id, e := strconv.Atoi(v)
+//			if e != nil {
+//				br.Msg = "获取指标列表失败"
+//				br.ErrMsg = "获取指标列表失败,Err:" + e.Error()
+//				return
+//			}
+//			edbIdArr = append(edbIdArr, id)
+//		}
+//	}
+//
+//	if len(edbIdArr) > 100 {
+//		br.Msg = "最多只能选择100个指标"
+//		return
+//	}
+//
+//	if len(edbIdArr) <= 0 {
+//		br.Msg = "无符合指标或指标代码错误"
+//		return
+//	}
+//
+//	list, err := data_manage.GetEdbInfoByIdList(edbIdArr)
+//	if err != nil && !utils.IsErrNoRow(err) {
+//		br.Msg = "获取指标列表失败"
+//		br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
+//		return
+//	}
+//
+//	searchItemList := make([]data_manage.EdbInfoBase, 0)
+//
+//	resp := new(data_manage.CalculateMultiChoiceResp)
+//
+//	if len(list) > 0 {
+//		// 当前列表中的分类map
+//		classifyMap := make(map[int]*data_manage.EdbClassify)
+//		{
+//			classifyIdList := make([]int, 0)
+//			for _, info := range list {
+//				classifyIdList = append(classifyIdList, info.ClassifyId)
+//			}
+//			classifyList, err := data_manage.GetEdbClassifyByIdList(classifyIdList)
+//			if err != nil {
+//				if err != nil {
+//					br.Msg = "获取失败"
+//					br.ErrMsg = "获取分类列表失败,Err:" + err.Error()
+//					return
+//				}
+//			}
+//
+//			for _, v := range classifyList {
+//				classifyMap[v.ClassifyId] = v
+//			}
+//		}
+//
+//		// 获取所有有权限的指标和分类
+//		permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
+//		if err != nil {
+//			br.Msg = "获取失败"
+//			br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
+//			return
+//		}
+//		for _, info := range list {
+//			var haveOperaAuth bool
+//			if currClassify, ok := classifyMap[info.ClassifyId]; ok {
+//				haveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(info.IsJoinPermission, currClassify.IsJoinPermission, info.EdbInfoId, info.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
+//			}
+//			searchItem := data_manage.EdbInfoBase{
+//				Frequency:     info.Frequency,
+//				Unit:          info.Unit,
+//				UnitEn:        info.UnitEn,
+//				EdbName:       info.EdbName,
+//				EdbNameEn:     info.EdbNameEn,
+//				EdbInfoId:     info.EdbInfoId,
+//				ClassifyId:    info.ClassifyId,
+//				HaveOperaAuth: haveOperaAuth,
+//				EdbInfoType:   info.EdbInfoType,
+//			}
+//			searchItemList = append(searchItemList, searchItem)
+//		}
+//	}
+//
+//	resp.SearchItem = searchItemList
+//
+//	br.Ret = 200
+//	br.Success = true
+//	br.Msg = "获取成功"
+//	br.Data = resp
+//}
+
+//func (this *ChartInfoController) CalculateMultiSearchBak() {
+//	br := new(models.BaseResponse).Init()
+//	defer func() {
+//		this.Data["json"] = br
+//		this.ServeJSON()
+//	}()
+//
+//	//来源类型,1:中文,2:英文
+//	frequency := this.GetString("Frequency")
+//	keyword := this.GetString("Keyword")
+//	sysUserIds := this.GetString("SysUserIds")
+//	classifyIds := this.GetString("ClassifyIds")
+//
+//	pageSize, _ := this.GetInt("PageSize")
+//	currentIndex, _ := this.GetInt("CurrentIndex")
+//	notFrequency := this.GetString("NotFrequency")
+//	edbInfoType, _ := this.GetInt("EdbInfoType", 0)
+//
+//	var startSize int
+//	if pageSize <= 0 {
+//		pageSize = utils.PageSize50
+//	}
+//	if currentIndex <= 0 {
+//		currentIndex = 1
+//	}
+//	startSize = utils.StartIndex(currentIndex, pageSize)
+//
+//	var edbIdArr []int
+//
+//	condition := ` AND edb_info_type = ? `
+//	pars := make([]interface{}, 0)
+//	pars = append(pars, edbInfoType)
+//
+//	if classifyIds != "" {
+//		classifyIdsArr := strings.Split(classifyIds, ",")
+//		condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdsArr)) + `) `
+//		pars = append(pars, classifyIdsArr)
+//	}
+//
+//	if frequency != "" {
+//		frequencyArr := strings.Split(frequency, ",")
+//		condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencyArr)) + `) `
+//		pars = append(pars, frequencyArr)
+//	}
+//	if notFrequency != "" {
+//		notFrequencyArr := strings.Split(notFrequency, ",")
+//		condition += ` AND frequency NOT IN (` + utils.GetOrmInReplace(len(notFrequencyArr)) + `) `
+//		pars = append(pars, notFrequencyArr)
+//	}
+//	if sysUserIds != "" {
+//		sysUserIdSlice := strings.Split(sysUserIds, ",")
+//		condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
+//		pars = append(pars, sysUserIdSlice)
+//	}
+//
+//	if keyword != "" {
+//		keyWordArr := strings.Split(keyword, " ")
+//
+//		if len(keyWordArr) > 0 {
+//			for _, v := range keyWordArr {
+//				condition += ` AND CONCAT(edb_name,edb_code) LIKE ?`
+//				pars = append(pars, utils.GetLikeKeyword(v))
+//			}
+//		}
+//	}
+//
+//	total, e := data_manage.GetEdbInfoByConditionCount(condition, pars)
+//	if e != nil {
+//		br.Msg = "获取指标列表总数失败"
+//		br.ErrMsg = "获取指标列表总数失败,Err:" + e.Error()
+//		return
+//	}
+//
+//	searchItemList := make([]data_manage.CalculateMultiEdbSearchItem, 0)
+//	page := paging.GetPaging(currentIndex, pageSize, total)
+//	resp := new(data_manage.CalculateMultiEdbSearchResp)
+//
+//	edbList, e := data_manage.GetEdbInfoListByCondition(condition, pars, startSize, pageSize, "")
+//	if e != nil {
+//		br.Msg = "获取指标列表失败"
+//		br.ErrMsg = "获取指标列表失败,Err:" + e.Error()
+//		return
+//	}
+//
+//	if len(edbList) > 0 {
+//		classifyIdList := make([]int, 0)
+//		for _, v := range edbList {
+//			edbIdArr = append(edbIdArr, v.EdbInfoId)
+//			classifyIdList = append(classifyIdList, v.ClassifyId)
+//		}
+//
+//		// 当前列表中的分类map
+//		classifyMap := make(map[int]*data_manage.EdbClassify)
+//		{
+//			classifyList, err := data_manage.GetEdbClassifyByIdList(classifyIdList)
+//			if err != nil {
+//				if err != nil {
+//					br.Msg = "获取失败"
+//					br.ErrMsg = "获取分类列表失败,Err:" + err.Error()
+//					return
+//				}
+//			}
+//			for _, v := range classifyList {
+//				classifyMap[v.ClassifyId] = v
+//			}
+//		}
+//
+//		// 获取所有有权限的指标和分类
+//		permissionEdbIdList, permissionClassifyIdList, err := data_manage_permission.GetUserEdbAndClassifyPermissionList(this.SysUser.AdminId, 0, 0)
+//		if err != nil {
+//			br.Msg = "获取失败"
+//			br.ErrMsg = "获取所有有权限的指标和分类失败,Err:" + err.Error()
+//			return
+//		}
+//
+//		list, err := data_manage.GetEdbInfoByIdList(edbIdArr)
+//		if err != nil && !utils.IsErrNoRow(err) {
+//			br.Msg = "获取指标列表失败"
+//			br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
+//			return
+//		}
+//		for _, info := range list {
+//			var haveOperaAuth bool
+//			if currClassify, ok := classifyMap[info.ClassifyId]; ok {
+//				haveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(info.IsJoinPermission, currClassify.IsJoinPermission, info.EdbInfoId, info.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
+//			}
+//			searchItem := data_manage.CalculateMultiEdbSearchItem{
+//				Frequency:       info.Frequency,
+//				Unit:            info.Unit,
+//				UnitEn:          info.UnitEn,
+//				EdbName:         info.EdbName,
+//				EdbNameEn:       info.EdbNameEn,
+//				EdbInfoId:       info.EdbInfoId,
+//				ClassifyId:      info.ClassifyId,
+//				SysUserRealName: info.SysUserRealName,
+//				SysUserId:       info.SysUserId,
+//				EndDate:         utils.TimeToFormatDate(info.EndDate),
+//				EndValue:        info.EndValue,
+//				HaveOperaAuth:   haveOperaAuth,
+//				EdbInfoType:     info.EdbInfoType,
+//			}
+//			searchItemList = append(searchItemList, searchItem)
+//		}
+//	}
+//
+//	resp.SearchItem = searchItemList
+//	resp.Paging = page
+//	br.Ret = 200
+//	br.Success = true
+//	br.Msg = "获取成功"
+//	br.Data = resp
+//}

+ 1 - 1
controllers/data_manage/predict_edb_info.go

@@ -1101,7 +1101,7 @@ func (this *PredictEdbInfoController) FilterByEs() {
 		newKeyWord := strings.Split(keyWord, " ")
 		keyWordArr = append(keyWordArr, newKeyWord...)
 
-		total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, []int{}, []int{}, []int{}, []int{1, 2}, 1, 0, this.SysUser.AdminId, map[string]string{})
+		total, edbInfoList, err = elastic.SearchEdbInfoData(keyWord, startSize, pageSize, filterSource, source, []string{frequency}, []string{}, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, []int{}, []int{}, []int{}, []int{1, 2}, 1, 0, this.SysUser.AdminId, map[string]string{})
 
 		isEs = true
 	} else {

+ 1 - 1
models/data_manage/data_approve/data_approve.go

@@ -225,7 +225,7 @@ func GetApplyDataApprovePageList(cond string, pars []interface{}, orderRule stri
 	if orderRule != "" {
 		order = ` ORDER BY ` + orderRule
 	}
-	sql := fmt.Sprintf(`SELECT a.* FROM data_approve AS a WHERE 1 = 1 %s %s LIMIT ?,?`, cond, order)
+	sql := fmt.Sprintf(`SELECT a.*,a.approve_time as handle_time,a.state as record_state FROM data_approve AS a WHERE 1 = 1 %s %s LIMIT ?,?`, cond, order)
 	pars = append(pars, startSize, pageSize)
 	err = global.DmSQL["data"].Raw(sql, pars...).Find(&items).Error
 	return

+ 1 - 0
models/data_manage/request/collect_edb.go

@@ -17,6 +17,7 @@ type GeneralEdbEsSearchReq struct {
 	EdbAuth      int    `description:"指标权限范围,0-全部;1-我的;2-公共"`
 	EdbCollect   int    `description:"指标收藏状态:0-全部;1-已收藏"`
 	Frequency    string `description:"频度"`
+	NotFrequency string `description:"不需要的频度"`
 	EdbType      string `description:"指标类型:0-基础和计算;1-基础指标;2-计算指标;3-预测指标"`
 	Keyword      string `description:"关键字"`
 	KeyWord      string `description:"关键字"`

+ 19 - 12
services/data/edb_info_es.go

@@ -64,13 +64,11 @@ func DeleteEdbInfoToEs(edbInfoId int) {
 // @Description: 指标通用es搜索参数匹配
 // @author: Roc
 // @datetime 2024-12-23 11:10:42
-// @param edbTypeStr string
+// @param edbTypeStr string 指标类型:0-基础和计算;1-基础指标;2-计算指标;3-预测指标
 // @param sysUserId int
-// @param reqEdbAuth int
-// @param edbCollect int
+// @param reqEdbAuth int 指标权限范围,0-全部;1-我的;2-公共
+// @param edbCollect int 指标收藏状态:0-全部;1-已收藏
 // @param classifyId int
-// @return source int
-// @return frequency string
 // @return noPermissionEdbInfoIdList []int
 // @return noPermissionEdbClassifyIdList []int
 // @return collectEdbInfoIdList []int
@@ -78,11 +76,11 @@ func DeleteEdbInfoToEs(edbInfoId int) {
 // @return searchPublicClassifyIdList []int
 // @return edbTypeList []int
 // @return edbInfoType int
-// @return edbAuth int
+// @return edbAuth int 指标权限范围,0-全部;1-我的;2-公共
 // @return searchUserId int
 // @return err error
 // @return errMsg string
-func GetGeneralEdbEsSearchParams(edbTypeStr string, sysUserId, reqEdbAuth, edbCollect, classifyId int) (source int, frequency string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, searchUserId int, err error, errMsg string) {
+func GetGeneralEdbEsSearchParams(edbTypeStr string, sysUserId, reqEdbAuth, edbCollect, classifyId int) (noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, searchUserId int, err error, errMsg string) {
 	// 指标类型数组:1-基础指标;2-计算指标;3-预测指标
 	edbTypeList = make([]int, 0)
 	edbInfoType = -1 // 指标范围
@@ -210,7 +208,7 @@ func GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(req request.GeneralEdbEsSea
 	}
 
 	// 获取es搜索参数
-	source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := GetGeneralEdbEsSearchParams(req.EdbType, userId, req.EdbAuth, req.EdbCollect, req.ClassifyId)
+	noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := GetGeneralEdbEsSearchParams(req.EdbType, userId, req.EdbAuth, req.EdbCollect, req.ClassifyId)
 	if err != nil {
 		return
 	}
@@ -221,7 +219,16 @@ func GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(req request.GeneralEdbEsSea
 		sortMap["EdbInfoId"] = `desc`
 	}
 
-	_, edbInfoList, err = getAllEdbInfoDataByGeneralEdbEsSearch(keyword, 1, req.FilterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, sortMap)
+	frequencyList := make([]string, 0)
+	if req.Frequency != "" {
+		frequencyList = strings.Split(req.Frequency, ",")
+	}
+	notFrequencyList := make([]string, 0)
+	if req.NotFrequency != "" {
+		notFrequencyList = strings.Split(req.NotFrequency, ",")
+	}
+
+	_, edbInfoList, err = getAllEdbInfoDataByGeneralEdbEsSearch(keyword, 1, req.FilterSource, req.Source, frequencyList, notFrequencyList, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, sortMap)
 	if err != nil {
 		return
 	}
@@ -251,7 +258,7 @@ func GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(req request.GeneralEdbEsSea
 // @return total int64
 // @return list []*data_manage.EdbInfoList
 // @return err error
-func getAllEdbInfoDataByGeneralEdbEsSearch(keyword string, currPage, filterSource, source int, frequency string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
+func getAllEdbInfoDataByGeneralEdbEsSearch(keyword string, currPage, filterSource, source int, frequencyList, notFrequencyList []string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
 
 	// 每页获取数据的数量
 	pageSize := 5000
@@ -262,14 +269,14 @@ func getAllEdbInfoDataByGeneralEdbEsSearch(keyword string, currPage, filterSourc
 	startSize = paging.StartIndex(currPage, pageSize)
 
 	// 普通的搜索
-	total, list, err = elastic.SearchEdbInfoData(keyword, startSize, pageSize, filterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
+	total, list, err = elastic.SearchEdbInfoData(keyword, startSize, pageSize, filterSource, source, frequencyList, notFrequencyList, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
 	if err != nil {
 		return
 	}
 
 	page := paging.GetPaging(currPage, pageSize, int(total))
 	if !page.IsEnd {
-		_, nextList, tmpErr := getAllEdbInfoDataByGeneralEdbEsSearch(keyword, page.NextIndex, filterSource, source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
+		_, nextList, tmpErr := getAllEdbInfoDataByGeneralEdbEsSearch(keyword, page.NextIndex, filterSource, source, frequencyList, notFrequencyList, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
 		if tmpErr != nil {
 			err = tmpErr
 			return

+ 1 - 1
services/elastic/chart.go

@@ -505,7 +505,7 @@ func searchChartInfoDataList(indexName string, query elastic.Query, sortList []*
 				itemJson, tmpErr := v.Source.MarshalJSON()
 				if tmpErr != nil {
 					err = tmpErr
-					fmt.Println("movieJson err:", err)
+					fmt.Println("MarshalJSON err:", err)
 					return
 				}
 				chartInfoItem := new(data_manage.ChartInfoView)

+ 14 - 7
services/elastic/edb_info.go

@@ -304,7 +304,8 @@ func searchGeneralEdbInfoDataList(indexName string, mustMap, mustNotMap []interf
 // @param size int
 // @param filterSource int
 // @param source int
-// @param frequency string
+// @param frequencyList []string
+// @param notFrequencyList []string
 // @param noPermissionEdbInfoIdList []int
 // @param noPermissionEdbClassifyIdList []int
 // @param collectEdbInfoIdList []int
@@ -315,7 +316,7 @@ func searchGeneralEdbInfoDataList(indexName string, mustMap, mustNotMap []interf
 // @return total int64
 // @return list []*data_manage.EdbInfoList
 // @return err error
-func SearchEdbInfoData(keywordStr string, from, size, filterSource, source int, frequency string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
+func SearchEdbInfoData(keywordStr string, from, size, filterSource, source int, frequencyList, notFrequencyList []string, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
 	indexName := utils.DATA_INDEX_NAME
 	list = make([]*data_manage.EdbInfoList, 0)
 	defer func() {
@@ -365,16 +366,22 @@ func SearchEdbInfoData(keywordStr string, from, size, filterSource, source int,
 		mustMap = append(mustMap, map[string]interface{}{
 			"term": map[string]interface{}{
 				"Source": source,
-				//"Frequency.keyword": "月度",
 			},
 		})
 	}
 
-	if frequency != "" {
+	if len(frequencyList) > 0 {
 		mustMap = append(mustMap, map[string]interface{}{
-			"term": map[string]interface{}{
-				"Frequency.keyword": frequency,
-				//"Frequency.keyword": "月度",
+			"terms": map[string]interface{}{
+				"Frequency.keyword": frequencyList,
+			},
+		})
+	}
+
+	if len(notFrequencyList) > 0 {
+		mustNotMap = append(mustNotMap, map[string]interface{}{
+			"terms": map[string]interface{}{
+				"Frequency.keyword": notFrequencyList,
 			},
 		})
 	}