Эх сурвалжийг харах

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

# Conflicts:
#	routers/commentsRouter.go
Roc 3 сар өмнө
parent
commit
9680b212d1

+ 182 - 80
controllers/data_manage/collect_edb.go

@@ -5,11 +5,13 @@ 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/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"sort"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -375,83 +377,183 @@ func (this *EdbCollectController) Move() {
 // @Param	request	body data_manage.EdbCollectReq true "type json string"
 // @Success Ret=200 保存成功
 // @router /edb_collect/batch_collect [post]
-//func (this *EdbCollectController) BatchCollect() {
-//	br := new(models.BaseResponse).Init()
-//	defer func() {
-//		if br.ErrMsg == "" {
-//			br.IsSendEmail = false
-//		}
-//		this.Data["json"] = br
-//		this.ServeJSON()
-//	}()
-//	sysUser := this.SysUser
-//	if sysUser == nil {
-//		br.Msg = "请登录"
-//		br.ErrMsg = "请登录,SysUser Is Empty"
-//		br.Ret = 408
-//		return
-//	}
-//	var req data_manage.BatchEdbCollectReq
-//	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
-//		br.Msg = "参数解析异常"
-//		br.ErrMsg = fmt.Sprintf("参数解析异常: %v", e)
-//		return
-//	}
-//	if len(req.EdbInfoIdList) <= 0 {
-//		br.Msg = "请选择指标"
-//		br.IsSendEmail = false
-//		return
-//	}
-//	if len(req.ClassifyIdList) <= 0 {
-//		br.Msg = "请选择需要收藏的分类"
-//		br.IsSendEmail = false
-//		return
-//	}
-//
-//	// 获取es搜索参数
-//	source, frequency, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, searchUserId, err, errMsg := data.GetGeneralEdbEsSearchParams(edbTypeStr, this.SysUser.AdminId, edbAuth, edbCollect, classifyId)
-//
-//	edbItemList, e := data_manage.GetEdbInfoListByEdbInfoId(req.EdbInfoIdList)
-//	if e != nil {
-//		if utils.IsErrNoRow(e) {
-//			br.Msg = "指标不存在, 请刷新页面"
-//			return
-//		}
-//		br.Msg = "操作失败"
-//		br.ErrMsg = fmt.Sprintf("获取指标信息失败: %v", e)
-//		return
-//	}
-//
-//	collectOb := new(data_manage.EdbCollect)
-//
-//	// 待添加的分类配置
-//	addList := make([]*data_manage.EdbCollect, 0)
-//	for _, classifyId := range req.ClassifyIdList {
-//		addList = append(addList, &data_manage.EdbCollect{
-//			EdbCollectClassifyId: classifyId,
-//			EdbInfoId:            req.EdbInfoId,
-//			EdbCode:              edbItem.EdbCode,
-//			SysUserId:            sysUser.AdminId,
-//			SysRealName:          sysUser.RealName,
-//			CreateTime:           time.Now().Local(),
-//			ModifyTime:           time.Now().Local(),
-//		})
-//
-//	}
-//
-//	cond := fmt.Sprintf(" %s = ? AND %s = ?", collectOb.Cols().SysUserId, collectOb.Cols().EdbInfoId)
-//	pars := make([]interface{}, 0)
-//	pars = append(pars, sysUser.AdminId, req.EdbInfoId)
-//
-//	// 清除原有保存收藏配置,并新增保存收藏
-//	e = collectOb.RemoveAndCreateMulti(cond, pars, addList)
-//	if e != nil {
-//		br.Msg = "操作失败"
-//		br.ErrMsg = fmt.Sprintf("新增指标收藏失败: %v", e)
-//		return
-//	}
-//
-//	br.Ret = 200
-//	br.Success = true
-//	br.Msg = "操作成功"
-//}
+func (this *EdbCollectController) BatchCollect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req request.BatchEdbCollectReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = fmt.Sprintf("参数解析异常: %v", err)
+		return
+	}
+	cacheKey := "CACHE_EDB_INFO_COLLECT_" + strconv.Itoa(sysUser.AdminId)
+	if !utils.Rc.SetNX(cacheKey, 1, 30*time.Second) {
+		br.Msg = "系统处理中,请稍后重试!"
+		br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
+		return
+	}
+	defer func() {
+		utils.Rc.Delete(cacheKey)
+	}()
+
+	if len(req.CollectClassifyIdList) <= 0 {
+		br.Msg = "请选择需要收藏的分类"
+		br.IsSendEmail = false
+		return
+	}
+	// 选中的指标id列表
+	edbInfoList := make([]*data_manage.EdbInfoList, 0)
+
+	// 选择所有指标,所以需要通过es获取数据
+	if req.IsSelectAll {
+		tmpEdbInfoList, err, errMsg := data.GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(req.GeneralEdbEsSearchReq, this.SysUser.AdminId)
+		if err != nil {
+			br.Msg = "获取指标列表失败!"
+			if errMsg != `` {
+				br.Msg = errMsg
+			}
+			br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
+			return
+		}
+
+		// 如果有过滤指标,那么就过滤吧
+		if len(req.NoEdbIdList) > 0 {
+			noEdbIdMap := make(map[int]bool)
+			for _, v := range req.NoEdbIdList {
+				noEdbIdMap[v] = true
+			}
+
+			for _, v := range tmpEdbInfoList {
+				if _, ok := noEdbIdMap[v.EdbInfoId]; !ok {
+					// 如果不在未选中的指标id列表中,那么就加入到选中的指标id列表
+					edbInfoList = append(edbInfoList, v)
+				}
+			}
+		} else {
+			edbInfoList = tmpEdbInfoList
+		}
+
+		// 因为是ES查找的,所以需要重新查一下指标的信息,主要是为了把是否授权字段找出来
+		if len(edbInfoList) > 0 {
+
+			edbInfoIdList := make([]int, 0)
+			for _, v := range edbInfoList {
+				v.ConvertToResp()
+				v.EdbNameAlias = v.EdbName
+				v.HaveOperaAuth = true
+				edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
+			}
+
+			tmpEdbList, err := data_manage.GetEdbInfoByIdList(edbInfoIdList)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取所有有权限的指标失败,Err:" + err.Error()
+				return
+			}
+			edbInfoMap := make(map[int]*data_manage.EdbInfo)
+			for _, v := range tmpEdbList {
+				edbInfoMap[v.EdbInfoId] = v
+			}
+
+			for _, v := range edbInfoList {
+				tmpEdbInfo, ok := edbInfoMap[v.EdbInfoId]
+				if !ok {
+					continue
+				}
+				v.IsJoinPermission = tmpEdbInfo.IsJoinPermission
+			}
+		}
+	} else {
+		// 因为是ES查找的,所以需要重新查一下指标的信息,主要是为了把是否授权字段找出来
+		if len(req.EdbIdList) > 0 {
+			edbInfoList, err = data_manage.GetEdbInfoListByCond(` AND edb_info_id in (?) `, []interface{}{req.EdbIdList})
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取所有有权限的指标失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+
+	if len(edbInfoList) <= 0 {
+		br.Msg = `请选择指标`
+		return
+	}
+
+	edbInfoIdList := make([]int, 0)
+	for _, v := range edbInfoList {
+		edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
+	}
+
+	collectOb := new(data_manage.EdbCollect)
+
+	cond := fmt.Sprintf(" AND %s = ? AND %s in (?) ", collectOb.Cols().SysUserId, collectOb.Cols().EdbInfoId)
+	pars := make([]interface{}, 0)
+	pars = append(pars, sysUser.AdminId, edbInfoIdList)
+
+	collectList, err := collectOb.GetItemsByCondition(cond, pars, []string{}, ``)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取收藏列表列表,Err:" + err.Error()
+		return
+	}
+	collectEdbClassifyMap := make(map[int]map[int]bool)
+	for _, v := range collectList {
+		edbClassifyMap, ok := collectEdbClassifyMap[v.EdbInfoId]
+		if !ok {
+			edbClassifyMap = make(map[int]bool)
+		}
+		edbClassifyMap[v.EdbCollectClassifyId] = true
+		collectEdbClassifyMap[v.EdbInfoId] = edbClassifyMap
+	}
+
+	// 待添加的分类配置
+	addList := make([]*data_manage.EdbCollect, 0)
+	for _, edbInfo := range edbInfoList {
+		for _, classifyId := range req.CollectClassifyIdList {
+			edbClassifyMap, ok := collectEdbClassifyMap[edbInfo.EdbInfoId]
+			if ok {
+				if _, ok2 := edbClassifyMap[classifyId]; ok2 {
+					// 如果当前收藏分类下,存在该指标的收藏记录,那么就跳过
+					continue
+				}
+			}
+			addList = append(addList, &data_manage.EdbCollect{
+				EdbCollectClassifyId: classifyId,
+				EdbInfoId:            edbInfo.EdbInfoId,
+				EdbCode:              edbInfo.EdbCode,
+				SysUserId:            sysUser.AdminId,
+				SysRealName:          sysUser.RealName,
+				CreateTime:           time.Now().Local(),
+				ModifyTime:           time.Now().Local(),
+			})
+		}
+
+	}
+
+	// 并新增保存收藏
+	err = collectOb.CreateMulti(addList)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("新增指标批量收藏失败: %v", err)
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 7 - 7
controllers/data_manage/edb_info.go

@@ -1736,13 +1736,13 @@ func (this *EdbInfoController) EdbInfoFilter() {
 // EdbInfoFilterByEs
 // @Title 指标筛选接口
 // @Description 指标筛选接口
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   KeyWord   query   string  false       "搜索关键词:指标ID/指标名称"
 // @Param   FilterSource   query   int  false       "搜索来源:1:其他搜索,2:累计值转月值搜索,3:变频,4:基础指标,5:同比"
 // @Param   Frequency   query   string  false       "频度"
-// @Param   IsAddPredictEdb   query   bool  false       "是否查询添加预测指标"
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   EdbType   query   int  false       "指标类型:0-基础和计算;1-基础指标;2-计算指标;3-衍生指标"
+// @Param   Source   query   int  true       "来源"
+// @Param   EdbType   query   string  false       "指标类型:0-基础和计算;1-基础指标;2-计算指标;3-衍生指标"
 // @Param   EdbAuth   query   int  false       "指标权限:0-全部;1-我的;2-公共"
 // @Param   EdbCollect   query   int  false       "指标收藏状态:0-全部;1-已收藏"
 // @Param   ClassifyId   query   int  false       "父级分类id"
@@ -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

+ 19 - 6
models/data_manage/request/collect_edb.go

@@ -2,10 +2,23 @@ package request
 
 // BatchEdbCollectReq 批量加入收藏
 type BatchEdbCollectReq struct {
-	EdbIdList             []int  `description:"选中的指标id列表"`
-	NoEdbIdList           []int  `description:"未选中的指标id列表"`
-	IsSelectAll           bool   `description:"是否选择所有指标"`
-	ClassifyId            int    `description:"分类ID"`
-	Keyword               string `description:"关键字"`
-	CollectClassifyIdList []int  `description:"收藏分类ID列表"`
+	GeneralEdbEsSearchReq
+	EdbIdList             []int `description:"选中的指标id列表"`
+	NoEdbIdList           []int `description:"未选中的指标id列表"`
+	IsSelectAll           bool  `description:"是否选择所有指标"`
+	CollectClassifyIdList []int `description:"收藏分类ID列表"`
+}
+
+// GeneralEdbEsSearchReq 指标通用es搜索参数
+type GeneralEdbEsSearchReq struct {
+	FilterSource int    `description:"搜索来源:1:其他搜索,2:累计值转月值搜索,3:变频,4:基础指标,5:同比"`
+	ClassifyId   int    `description:"父级分类id"`
+	Source       int    `description:"来源"`
+	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:"关键字"`
 }

+ 9 - 0
routers/commentsRouter.go

@@ -3985,6 +3985,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers/data_manage:EdbCollectController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers/data_manage:EdbCollectController"],
+        beego.ControllerComments{
+            Method: "BatchCollect",
+            Router: `/edb_collect/batch_collect`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta_gn/eta_api/controllers/data_manage:EdbCollectController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers/data_manage:EdbCollectController"],
         beego.ControllerComments{
             Method: "CancelCollect",

+ 1 - 1
services/data/chart_classify.go

@@ -1497,7 +1497,7 @@ func GetAllChartChildClassifyByParentId(parentId int) (targetList []*data_manage
 		err = errors.New("获取分类信息失败,Err:" + err.Error())
 		return
 	}
-	orderStr := ` order by level asc, sort asc, classify_id asc`
+	orderStr := ` order by level asc, sort asc, chart_classify_id asc`
 
 	targetList, err = data_manage.GetChildChartClassifyListByParentId(fmt.Sprint(parentClassify.ChartClassifyIdPath, ",%"), orderStr)
 

+ 119 - 1
services/data/edb_info_es.go

@@ -2,10 +2,12 @@ package data
 
 import (
 	"eta_gn/eta_api/models/data_manage"
+	"eta_gn/eta_api/models/data_manage/request"
 	"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"
 	"strconv"
 	"strings"
 )
@@ -58,7 +60,27 @@ func DeleteEdbInfoToEs(edbInfoId int) {
 	go elastic.EsDeleteEdbInfoData(utils.DATA_INDEX_NAME, strconv.Itoa(edbInfoId))
 }
 
-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) {
+// GetGeneralEdbEsSearchParams
+// @Description: 指标通用es搜索参数匹配
+// @author: Roc
+// @datetime 2024-12-23 11:10:42
+// @param edbTypeStr string 指标类型:0-基础和计算;1-基础指标;2-计算指标;3-预测指标
+// @param sysUserId int
+// @param reqEdbAuth int 指标权限范围,0-全部;1-我的;2-公共
+// @param edbCollect int 指标收藏状态:0-全部;1-已收藏
+// @param classifyId int
+// @return noPermissionEdbInfoIdList []int
+// @return noPermissionEdbClassifyIdList []int
+// @return collectEdbInfoIdList []int
+// @return searchClassifyIdList []int
+// @return searchPublicClassifyIdList []int
+// @return edbTypeList []int
+// @return edbInfoType 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) (noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, searchUserId int, err error, errMsg string) {
 	// 指标类型数组:1-基础指标;2-计算指标;3-预测指标
 	edbTypeList = make([]int, 0)
 	edbInfoType = -1 // 指标范围
@@ -169,3 +191,99 @@ func GetGeneralEdbEsSearchParams(edbTypeStr string, sysUserId, reqEdbAuth, edbCo
 
 	return
 }
+
+// GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq
+// @Description: 获取所有指标列表(通用)
+// @author: Roc
+// @datetime 2024-12-23 11:31:51
+// @param req request.GeneralEdbEsSearchReq
+// @param userId int
+// @return edbInfoList []*data_manage.EdbInfoList
+// @return err error
+// @return errMsg string
+func GetAllGeneralEdbInfoListByGeneralEdbEsSearchReq(req request.GeneralEdbEsSearchReq, userId int) (edbInfoList []*data_manage.EdbInfoList, err error, errMsg string) {
+	keyword := req.Keyword
+	if keyword == `` {
+		keyword = req.KeyWord
+	}
+
+	// 获取es搜索参数
+	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
+	}
+
+	sortMap := make(map[string]string)
+	// 如果没有搜索关键词,则默认根据指标编码倒序排序
+	if keyword == `` {
+		sortMap["EdbInfoId"] = `desc`
+	}
+
+	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
+	}
+
+	return
+}
+
+// getAllEdbInfoDataByGeneralEdbEsSearch
+// @Description: 获取所有的指标列表(通用es搜索接口)
+// @author: Roc
+// @datetime 2024-12-23 11:30:33
+// @param keyword string
+// @param currPage int
+// @param filterSource int
+// @param source int
+// @param frequency string
+// @param noPermissionEdbInfoIdList []int
+// @param noPermissionEdbClassifyIdList []int
+// @param collectEdbInfoIdList []int
+// @param searchClassifyIdList []int
+// @param searchPublicClassifyIdList []int
+// @param edbTypeList []int
+// @param edbInfoType int
+// @param edbAuth int
+// @param sysUserId int
+// @param sortMap map[string]string
+// @return total int64
+// @return list []*data_manage.EdbInfoList
+// @return 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
+	var startSize int
+	if currPage <= 0 {
+		currPage = 1
+	}
+	startSize = paging.StartIndex(currPage, pageSize)
+
+	// 普通的搜索
+	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, frequencyList, notFrequencyList, noPermissionEdbInfoIdList, noPermissionEdbClassifyIdList, collectEdbInfoIdList, searchClassifyIdList, searchPublicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+
+		list = append(list, nextList...)
+	}
+
+	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)

+ 195 - 13
services/elastic/edb_info.go

@@ -144,6 +144,157 @@ func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shou
 	return
 }
 
+// searchGeneralEdbInfoDataTotal
+// @Description: 查询es中的指标数量(通用)
+// @author: Roc
+// @datetime 2024-12-23 11:17:35
+// @param indexName string
+// @param mustMap []interface{}
+// @param mustNotMap []interface{}
+// @param shouldMapList []map[string]interface{}
+// @return total int64
+// @return err error
+func searchGeneralEdbInfoDataTotal(indexName string, mustMap, mustNotMap []interface{}, shouldMapList []map[string]interface{}) (total int64, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("searchGeneralEdbInfoDataTotal Err:", err.Error())
+		}
+	}()
+	client := utils.EsClient
+
+	//关键字匹配
+	for _, shouldMap := range shouldMapList {
+		mustMap = append(mustMap, map[string]interface{}{
+			"bool": shouldMap,
+		})
+	}
+
+	queryMap := map[string]interface{}{
+		"query": map[string]interface{}{
+			"bool": map[string]interface{}{
+				"must":     mustMap,
+				"must_not": mustNotMap,
+				//"should":   shouldMap,
+			},
+		},
+	}
+
+	//根据条件数量统计
+	requestTotalHits := client.Count(indexName).BodyJson(queryMap)
+	total, err = requestTotalHits.Do(context.Background())
+
+	return
+}
+
+// searchGeneralEdbInfoDataList
+// @Description: 查询es中的指标明细数据(通用)
+// @author: Roc
+// @datetime 2024-12-23 11:18:04
+// @param indexName string
+// @param mustMap []interface{}
+// @param mustNotMap []interface{}
+// @param shouldMapList []map[string]interface{}
+// @param sortList []interface{}
+// @param from int
+// @param size int
+// @return list []*data_manage.EdbInfoList
+// @return err error
+func searchGeneralEdbInfoDataList(indexName string, mustMap, mustNotMap []interface{}, shouldMapList []map[string]interface{}, sortList []interface{}, from, size int) (list []*data_manage.EdbInfoList, err error) {
+	list = make([]*data_manage.EdbInfoList, 0)
+	defer func() {
+		if err != nil {
+			fmt.Println("searchGeneralEdbInfoDataList Err:", err.Error())
+		}
+	}()
+	client := utils.EsClient
+
+	highlight := elastic.NewHighlight()
+	highlight = highlight.Fields(elastic.NewHighlighterField("EdbCode"), elastic.NewHighlighterField("EdbName"))
+	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
+
+	//query := elastic.RawStringQuery(`{"match_all":{}}`)
+
+	//关键字匹配
+	for _, shouldMap := range shouldMapList {
+		mustMap = append(mustMap, map[string]interface{}{
+			"bool": shouldMap,
+		})
+	}
+
+	queryMap := map[string]interface{}{
+		"query": map[string]interface{}{
+			"bool": map[string]interface{}{
+				"must":     mustMap,
+				"must_not": mustNotMap,
+				//"should":   shouldMap,
+			},
+		},
+	}
+
+	queryMap["from"] = from
+	queryMap["size"] = size
+
+	// 如果有指定排序,那么就按照排序来
+	if len(sortList) > 0 {
+		queryMap["sort"] = sortList
+	}
+
+	jsonBytes, _ := json.Marshal(queryMap)
+	fmt.Println(string(jsonBytes))
+
+	//queryString := elastic.NewMatchQuery("EdbCode", keywordStr)
+	//request := client.Search(indexName).Highlight(highlight).From(from).Size(size).Query(queryString)
+
+	request := client.Search(indexName).Highlight(highlight).Source(queryMap) // sets the JSON request
+
+	//requestJson, err := json.Marshal(request)
+	//if err != nil {
+	//	fmt.Println("requestJson err:", err)
+	//}
+	//fmt.Println("requestJson ", string(requestJson))
+	searchMap := make(map[string]string)
+
+	searchResp, err := request.Do(context.Background())
+	if err != nil {
+		return
+	}
+	fmt.Println(searchResp)
+	fmt.Println(searchResp.Status)
+	if searchResp.Status != 0 {
+		return
+	}
+	//total = searchResp.TotalHits()
+	if searchResp.Hits != nil {
+		for _, v := range searchResp.Hits.Hits {
+			if _, ok := searchMap[v.Id]; !ok {
+				itemJson, tmpErr := v.Source.MarshalJSON()
+				if tmpErr != nil {
+					err = tmpErr
+					fmt.Println("movieJson err:", err)
+					return
+				}
+				edbInfoItem := new(data_manage.EdbInfoList)
+				tmpErr = json.Unmarshal(itemJson, &edbInfoItem)
+				if tmpErr != nil {
+					fmt.Println("json.Unmarshal movieJson err:", tmpErr)
+					err = tmpErr
+					return
+				}
+				if len(v.Highlight["EdbCode"]) > 0 {
+					edbInfoItem.EdbCode = v.Highlight["EdbCode"][0]
+				}
+				if len(v.Highlight["EdbName"]) > 0 {
+					edbInfoItem.EdbCode = v.Highlight["EdbName"][0]
+				}
+				list = append(list, edbInfoItem)
+				searchMap[v.Id] = v.Id
+			}
+		}
+	}
+
+	return
+}
+
 // SearchEdbInfoData
 // @Description: 查询es中的指标数据
 // @author: Roc
@@ -153,7 +304,8 @@ func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shou
 // @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
@@ -164,7 +316,7 @@ func searchEdbInfoData(indexName string, mustMap, mustNotMap []interface{}, shou
 // @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() {
@@ -214,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,
 			},
 		})
 	}
@@ -391,14 +549,28 @@ func SearchEdbInfoData(keywordStr string, from, size, filterSource, source int,
 		sortList = append(sortList, sortEdbInfoId)
 	}
 
-	return searchEdbInfoData(indexName, mustMap, mustNotMap, shouldMapList, sortList, from, size)
+	total, err = searchGeneralEdbInfoDataTotal(indexName, mustMap, mustNotMap, shouldMapList)
+	if err != nil {
+		return
+	}
+
+	list, err = searchGeneralEdbInfoDataList(indexName, mustMap, mustNotMap, shouldMapList, sortList, from, size)
+
+	return
 }
 
-// searchEdbInfoData 查询es中的指标数量
+// searchEdbInfoDataTotal
+// @Description: 查询es中的指标数量
+// @author: Roc
+// @datetime 2024-12-23 11:19:04
+// @param indexName string
+// @param query elastic.Query
+// @return total int64
+// @return err error
 func searchEdbInfoDataTotal(indexName string, query elastic.Query) (total int64, err error) {
 	defer func() {
 		if err != nil {
-			fmt.Println("searchEdbInfoDataV2 Err:", err.Error())
+			fmt.Println("searchEdbInfoDataTotal Err:", err.Error())
 		}
 	}()
 	client := utils.EsClient
@@ -413,12 +585,22 @@ func searchEdbInfoDataTotal(indexName string, query elastic.Query) (total int64,
 	return
 }
 
-// searchEdbInfoData 查询es中的指标数据
+// searchEdbInfoDataList
+// @Description: 查询es中的指标明细数据
+// @author: Roc
+// @datetime 2024-12-23 11:18:48
+// @param indexName string
+// @param query elastic.Query
+// @param sortList []*elastic.FieldSort
+// @param from int
+// @param size int
+// @return list []*data_manage.EdbInfoList
+// @return err error
 func searchEdbInfoDataList(indexName string, query elastic.Query, sortList []*elastic.FieldSort, from, size int) (list []*data_manage.EdbInfoList, err error) {
 	list = make([]*data_manage.EdbInfoList, 0)
 	defer func() {
 		if err != nil {
-			fmt.Println("searchEdbInfoDataV2 Err:", err.Error())
+			fmt.Println("searchEdbInfoDataList Err:", err.Error())
 		}
 	}()
 	client := utils.EsClient
@@ -480,7 +662,7 @@ func searchEdbInfoDataList(indexName string, query elastic.Query, sortList []*el
 	return
 }
 
-// searchEdbInfoData 查询es中的指标数据
+// searchEdbInfoDataV2 查询es中的指标数据
 func searchEdbInfoDataV2(indexName string, query elastic.Query, sortList []*elastic.FieldSort, from, size int) (total int64, list []*data_manage.EdbInfoList, err error) {
 	total, err = searchEdbInfoDataTotal(indexName, query)
 	if err != nil {