Forráskód Böngészése

Merge branch 'master' into feature/eta_2.5.4_report_free_layout

kobe6258 4 napja
szülő
commit
0e733239b9

+ 2 - 1
.gitignore

@@ -19,4 +19,5 @@ eta_api.exe
 eta_api.exe~
 /static/tmpFile/*
 etalogs/
-/.vscode
+/.vscode
+/fix

+ 31 - 2
controllers/data_manage/ai_predict_model/classify.go

@@ -8,6 +8,7 @@ import (
 	"eta/eta_api/models/data_manage"
 	dataSourceModel "eta/eta_api/models/data_source"
 	"eta/eta_api/services"
+	"eta/eta_api/services/data"
 	"eta/eta_api/services/elastic"
 	"eta/eta_api/utils"
 	"fmt"
@@ -444,15 +445,36 @@ func (this *AiPredictModelClassifyController) Remove() {
 			br.ErrMsg = fmt.Sprintf("获取标的信息失败, %v", e)
 			return
 		}
+		if aiIndex != nil && aiIndex.AiPredictModelIndexId <= 0 {
+			br.Ret = 200
+			br.Msg = "删除成功"
+			br.Success = true
+			return
+		}
+
+		// 获取指标图表
+		var chartIds []int
+		chartTypes := []int{utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY, utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY}
+		for _, v := range chartTypes {
+			ct, e := data_manage.GetAiPredictChartInfoByIndexId(v, req.IndexId)
+			if e != nil && !utils.IsErrNoRow(e) {
+				br.Msg = "操作失败"
+				br.ErrMsg = fmt.Sprintf("获取标的图表信息失败, %v", e)
+				return
+			}
+			if ct != nil && ct.ChartInfoId > 0 {
+				chartIds = append(chartIds, ct.ChartInfoId)
+			}
+		}
 
 		// 删除标的及数据
-		if e = indexOb.RemoveIndexAndData(req.IndexId); e != nil {
+		if e = indexOb.RemoveIndexAndData(req.IndexId, chartIds); e != nil {
 			br.Msg = "操作失败"
 			br.ErrMsg = fmt.Sprintf("删除标的及数据失败, %v", e)
 			return
 		}
 
-		// ES标记删除
+		// ES标记标的/图表删除
 		go func() {
 			indexItem := new(dataSourceModel.SearchDataSource)
 			indexItem.PrimaryId = aiIndex.AiPredictModelIndexId
@@ -470,6 +492,13 @@ func (this *AiPredictModelClassifyController) Remove() {
 				utils.FileLog.Info("AI预测模型-标记删除es失败, %v", e)
 				return
 			}
+
+			if len(chartIds) == 0 {
+				return
+			}
+			for _, v := range chartIds {
+				data.EsDeleteChartInfo(v)
+			}
 		}()
 	}
 

+ 147 - 1
controllers/data_manage/ai_predict_model/index.go

@@ -5,9 +5,11 @@ import (
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	aiPredictModel "eta/eta_api/models/ai_predict_model"
+	"eta/eta_api/models/data_manage"
 	dataSourceModel "eta/eta_api/models/data_source"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
+	"eta/eta_api/services/data"
 	"eta/eta_api/services/elastic"
 	"eta/eta_api/utils"
 	"fmt"
@@ -583,7 +585,7 @@ func (this *AiPredictModelIndexController) Import() {
 	}
 
 	// 导入指标
-	if e = services.ImportAiPredictModelIndexAndData(importIndexes); e != nil {
+	if e = services.ImportAiPredictModelIndexAndData(importIndexes, sysUser.AdminId, sysUser.RealName); e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = fmt.Sprintf("导入指标数据失败, %v", e)
 		return
@@ -984,3 +986,147 @@ func (this *AiPredictModelIndexController) DashboardDetail() {
 	br.Success = true
 	br.Msg = "获取成功"
 }
+
+// SearchByEs
+// @Title 图表模糊搜索(从es获取)
+// @Description  图表模糊搜索(从es获取)
+// @Param   Keyword   query   string  true       "图表名称"
+// @Param   IsShowMe   query   bool  true       "是否只看我的,true、false"
+// @Param   Source   query   int  true       "来源,14:日度预测,15:月度预测,默认0:全部14+15"
+// @Success 200 {object} data_manage.ChartInfo
+// @router /chart/search_by_es [get]
+func (this *AiPredictModelIndexController) SearchByEs() {
+	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
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	keyword := this.GetString("Keyword")
+	keyword = strings.TrimSpace(keyword)
+	if keyword == "" {
+		keyword = this.GetString("KeyWord")
+		keyword = strings.TrimSpace(keyword)
+	}
+
+	//只看我的
+	isShowMe, _ := this.GetBool("IsShowMe")
+	showSysId := 0
+	if isShowMe {
+		showSysId = sysUser.AdminId
+	}
+
+	source, _ := this.GetInt("Source")
+	sourceList := make([]int, 0)
+	if source <= 0 {
+		sourceList = append(sourceList, utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY, utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY)
+	} else {
+		sourceList = append(sourceList, source)
+	}
+
+	var searchList []*data_manage.ChartInfoMore
+	var total int64
+	var err error
+
+	// 获取当前账号的不可见指标(AI预测的指标为标的均可见)
+	noPermissionChartIdList := make([]int, 0)
+	//{
+	//	obj := data_manage.EdbInfoNoPermissionAdmin{}
+	//	confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
+	//	if err != nil && !utils.IsErrNoRow(err) {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	for _, v := range confList {
+	//		noPermissionChartIdList = append(noPermissionChartIdList, v.ChartInfoId)
+	//	}
+	//}
+
+	if keyword != "" {
+		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
+	} else {
+		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
+		if err != nil && !utils.IsErrNoRow(err) {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	finalList := make([]*data_manage.ChartInfoMore, 0)
+	if len(searchList) > 0 {
+		chartInfoIds := ""
+		chartEdbMap := make(map[int][]*data_manage.ChartEdbInfoMapping)
+		for _, v := range searchList {
+			chartInfoIds += strconv.Itoa(v.ChartInfoId) + ","
+		}
+		if chartInfoIds != "" {
+			chartInfoIds = strings.Trim(chartInfoIds, ",")
+			//判断是否需要展示英文标识
+			edbList, e := data_manage.GetChartEdbMappingListByChartInfoIds(chartInfoIds)
+			if e != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取图表,指标信息失败,Err:" + e.Error()
+				return
+			}
+			for _, v := range edbList {
+				chartEdbMap[v.ChartInfoId] = append(chartEdbMap[v.ChartInfoId], v)
+			}
+		}
+
+		for _, v := range searchList {
+			tmp := new(data_manage.ChartInfoMore)
+			tmp.ChartInfo = v.ChartInfo
+			// 图表数据权限
+			tmp.HaveOperaAuth = true
+			//判断是否需要展示英文标识
+			if edbTmpList, ok := chartEdbMap[v.ChartInfoId]; ok {
+				tmp.IsEnChart = data.CheckIsEnChart(v.ChartNameEn, edbTmpList, v.Source, v.ChartType)
+			}
+			tmp.SearchText = v.SearchText
+			if tmp.SearchText == "" {
+				tmp.SearchText = v.ChartName
+			}
+			finalList = append(finalList, tmp)
+		}
+	}
+	//新增搜索词记录
+	{
+		searchKeyword := new(data_manage.SearchKeyword)
+		searchKeyword.KeyWord = keyword
+		searchKeyword.CreateTime = time.Now()
+		go data_manage.AddSearchKeyword(searchKeyword)
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, int(total))
+	resp := data_manage.ChartInfoListByEsResp{
+		Paging: page,
+		List:   finalList,
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 132 - 0
controllers/data_manage/chart_common.go

@@ -9,6 +9,7 @@ import (
 	"eta/eta_api/controllers/data_manage/line_feature"
 	"eta/eta_api/controllers/data_manage/range_analysis"
 	"eta/eta_api/models"
+	aiPredictModel "eta/eta_api/models/ai_predict_model"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
@@ -290,6 +291,29 @@ func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
 		br.Success = true
 		br.Msg = "获取成功"
 		br.Data = resp
+	case utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY, utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY:
+		resp, isOk, msg, errMsg := GetAiPredictChartInfoDetailFromUniqueCode(chartInfo, isCache)
+		if !isOk {
+			if strings.Contains(errMsg, utils.ErrNoRow()) {
+				endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
+				resp.EdbInfoList = endInfoList
+				resp.ChartInfo = chartInfo
+				resp.Status = false
+
+				br.Data = resp
+				br.Ret = 200
+				br.Success = true
+				br.Msg = "获取成功"
+				return
+			}
+			br.Msg = msg
+			br.ErrMsg = errMsg
+			return
+		}
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
 	default:
 		br.Msg = "错误的图表"
 		br.ErrMsg = "错误的图表"
@@ -408,6 +432,114 @@ func (this *ChartInfoController) GeneralChartToken() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = token
+	return
+}
 
+// GetAiPredictChartInfoDetailFromUniqueCode 根据编码获取AI预测模型图表详情
+func GetAiPredictChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCache bool) (resp *data_manage.ChartInfoDetailFromUniqueCodeResp, isOk bool, msg, errMsg string) {
+	var err error
+	msg = "获取成功"
+	defer func() {
+		if err != nil {
+			tips := fmt.Sprintf("UniqueCode获取图表详情失败, %v", err)
+			msg = "获取失败"
+			errMsg = fmt.Sprintf(tips)
+			utils.FileLog.Info(tips)
+		}
+	}()
+	if chartInfo == nil {
+		err = fmt.Errorf("图表信息不存在")
+		return
+	}
+	if chartInfo.Source != utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY && chartInfo.Source != utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY {
+		err = fmt.Errorf("图表来源有误, Source: %d", chartInfo.Source)
+		return
+	}
+	resp = new(data_manage.ChartInfoDetailFromUniqueCodeResp)
+
+	// 获取图表标的
+	edbMappings, e := data_manage.GetChartEdbMappingsByChartInfoId(chartInfo.ChartInfoId)
+	if e != nil {
+		err = fmt.Errorf("获取图表指标关联失败, %v", e)
+		return
+	}
+	if len(edbMappings) == 0 {
+		err = fmt.Errorf("图表指标关联不存在, %v", e)
+		return
+	}
+	indexId := edbMappings[0].EdbInfoId
+	if indexId <= 0 {
+		err = fmt.Errorf("图表标的有误")
+		return
+	}
+	indexOb := new(aiPredictModel.AiPredictModelIndex)
+	indexItem, e := indexOb.GetItemById(indexId)
+	if e != nil {
+		err = fmt.Errorf("获取图表标的失败, %v", e)
+		return
+	}
+	if indexItem != nil && indexItem.AiPredictModelIndexId <= 0 {
+		err = fmt.Errorf("图表标的不存在, IndexId: %d", indexId)
+		return
+	}
+
+	// 获取标的数据
+	indexData := make([]*aiPredictModel.AiPredictModelData, 0)
+	dataSource := aiPredictModel.ModelDataSourceDaily
+	if chartInfo.Source == utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY {
+		dataSource = aiPredictModel.ModelDataSourceMonthly
+	}
+	dataOb := new(aiPredictModel.AiPredictModelData)
+	dataCond := fmt.Sprintf(` AND %s = ?`, dataOb.Cols().IndexCode)
+	dataPars := make([]interface{}, 0)
+	dataPars = append(dataPars, indexItem.IndexCode)
+	list, e := dataOb.GetItemsByCondition(dataCond, dataPars, []string{}, fmt.Sprintf("%s DESC", dataOb.Cols().DataTime))
+	if e != nil {
+		err = fmt.Errorf("获取标的数据失败, %v", e)
+		return
+	}
+	for _, v := range list {
+		if v.Source == dataSource {
+			indexData = append(indexData, v)
+			continue
+		}
+	}
+
+	//判断是否存在缓存,如果存在缓存,那么直接从缓存中获取
+	key := data.GetChartInfoDataKey(chartInfo.ChartInfoId)
+	if utils.Re == nil && isCache {
+		if utils.Re == nil && utils.Rc.IsExist(key) {
+			if chartData, e := utils.Rc.RedisBytes(key); e == nil {
+				e = json.Unmarshal(chartData, &resp)
+				if e != nil || resp == nil {
+					return
+				}
+				isOk = true
+				return
+			}
+		}
+	}
+
+	// 图表详情
+	chartDetail, e := services.GetAiPredictChartDetailByData(indexItem, indexData, dataSource)
+	if e != nil {
+		err = fmt.Errorf("获取图表详情失败, %v", e)
+		return
+	}
+	resp.ChartInfo = chartDetail.ChartInfo
+	resp.EdbInfoList = chartDetail.EdbInfoList
+	resp.XEdbIdValue = chartDetail.XEdbIdValue
+	resp.YDataList = chartDetail.YDataList
+	resp.XDataList = chartDetail.XDataList
+	resp.BarChartInfo = chartDetail.BarChartInfo
+	resp.CorrelationChartInfo = chartDetail.CorrelationChartInfo
+	resp.DataResp = chartDetail.DataResp
+	resp.Status = true
+
+	if utils.Re == nil {
+		jsonData, _ := json.Marshal(resp)
+		_ = utils.Rc.Put(key, jsonData, 10*time.Minute)
+	}
+	isOk = true
 	return
 }

+ 1 - 1
controllers/data_manage/edb_classify.go

@@ -291,7 +291,7 @@ func (this *EdbClassifyController) EditEdbClassify() {
 		return
 	}
 
-	err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ParentId, req.ClassifyName, this.Lang, this.SysUser)
+	err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ParentId, req.ClassifyName, this.Lang, this.SysUser, false)
 	if errMsg != `` {
 		br.Msg = errMsg
 		br.ErrMsg = errMsg

+ 35 - 4
controllers/data_manage/edb_info.go

@@ -2249,7 +2249,15 @@ func (this *EdbInfoController) EdbInfoList() {
 	edbInfoItem.FrequencyEn = data.GetFrequencyEn(edbInfoItem.Frequency)
 	// 获取是否供应商停更
 	edbInfoItem.IsSupplierStop = data.GetIsSupplierStop(edbInfoItem.Source, edbInfoItem.EdbCode)
-
+	relation, err := data.GetEdbRelationListById(edbInfoItem.EdbInfoId, edbInfoItem.Source)
+	if err != nil && !utils.IsErrNoRow(err) {
+		br.Msg = "获取指标引用信息失败"
+		br.ErrMsg = "获取指标引用信息失败,Err:" + err.Error()
+		return
+	}
+	if relation != nil && relation.RelationNum > 0 {
+		edbInfoItem.IsRelation = true
+	}
 	//查询目录
 	classifyList, err, errMsg := data.GetFullClassifyByClassifyId(edbInfoItem.ClassifyId)
 	if err != nil {
@@ -2997,7 +3005,7 @@ func (this *EdbInfoController) EdbInfoRefresh() {
 		br.ErrMsg = "参数错误"
 		return
 	}
-	_, err := data_manage.GetEdbInfoById(edbInfoId)
+	edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 	if err != nil {
 		if utils.IsErrNoRow(err) {
 			br.Msg = "数据已被删除,请刷新页面"
@@ -3008,6 +3016,11 @@ func (this *EdbInfoController) EdbInfoRefresh() {
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
 	}
+	if edbInfo.NoUpdate == 1 {
+		br.Msg = "该指标已停用"
+		br.ErrMsg = "该指标已停用,edbCode:" + edbInfo.EdbCode
+		return
+	}
 	err, isAsync := data.EdbInfoRefreshAllFromBaseV2(edbInfoId, false, false)
 	if err != nil {
 		br.Msg = "刷新失败"
@@ -3899,7 +3912,16 @@ func (this *ChartInfoController) EdbInfoData() {
 	fullEdb.EdbInfo = edbInfo
 	// 是否供应商停更
 	fullEdb.IsSupplierStop = data.GetIsSupplierStop(edbInfo.Source, edbInfo.EdbCode)
-
+	//是否被引用
+	relation, err := data.GetEdbRelationListById(edbInfo.EdbInfoId, edbInfo.Source)
+	if err != nil && !utils.IsErrNoRow(err) {
+		br.Msg = err.Error()
+		br.ErrMsg = "获取指标关联关系失败,err:" + err.Error()
+		return
+	}
+	if relation != nil && relation.RelationNum > 0 {
+		fullEdb.IsRelation = true
+	}
 	fullEdb.ClassifyList = classifyList
 
 	var currClassifyItem *data_manage.EdbClassifyIdItems
@@ -5660,9 +5682,18 @@ func (this *EdbInfoController) EdbChartList() {
 						v.IsSupplierStop = 1
 					}
 				}
+				var relation *data_manage.BaseRelationEdbInfo
+				relation, err = data.GetEdbRelationListById(v.EdbInfoId, v.Source)
+				if err != nil && !utils.IsErrNoRow(err) {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取数据引用信息失败,Err:" + e.Error()
+					return
+				}
+				if relation != nil && relation.RelationNum > 0 {
+					v.IsRelation = true
+				}
 			}
 		}
-
 		page = paging.GetPaging(currentIndex, pageSize, int(dataCount))
 	}
 

+ 28 - 10
controllers/data_manage/edb_info_refresh.go

@@ -679,7 +679,7 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 	}
 	edbType := 1 //基础指标
 	switch req.Source {
-	case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND: // wind
+	case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_THS, utils.DATA_SOURCE_PB_FINANCE, utils.DATA_SOURCE_PB: // wind
 	case -1:
 		req.Source = 0
 		edbType = 2
@@ -690,6 +690,10 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 	// todo 批量设置刷新状态修改
 	edbIdList := make([]int, 0)
 	edbCodeList := make([]string, 0)
+	isStop := 0
+	if req.ModifyStatus == `暂停` {
+		isStop = 1
+	}
 	// 指标id列表
 	if req.IsSelectAll {
 		// 如果是列表全选
@@ -712,12 +716,32 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 			if ok {
 				continue
 			}
-
+			if v.RelationNum > 0 && v.IsSupplierStop == 0 && isStop == 1 {
+				br.Msg = "保存失败,停用指标已被引用,指标ID:" + v.EdbCode + "指标名称:" + v.EdbName
+				br.ErrMsg = "保存失败,停用指标已被引用,指标ID:" + v.EdbCode + "指标名称:" + v.EdbName
+				return
+			}
 			// 加入到待配置的指标列表id
 			edbIdList = append(edbIdList, v.EdbInfoId)
 		}
 	} else {
 		edbIdList = req.EdbSelectIdList
+		_, edbRelationList, err := data.GetEdbRelationListByIds(edbIdList, req.Source)
+		if err != nil && !utils.IsErrNoRow(err) {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range edbRelationList {
+			if v.RelationNum > 0 && v.IsSupplierStop == 0 && isStop == 1 {
+				br.Msg = "保存失败,停用指标已被引用,指标ID:" + v.EdbCode + "指标名称:" + v.EdbName
+				br.ErrMsg = "保存失败,停用指标已被引用,指标ID:" + v.EdbCode + "指标名称:" + v.EdbName
+				return
+			}
+			// 加入到待配置的指标列表id
+			// 加入到待配置的指标列表id
+			edbIdList = append(edbIdList, v.EdbInfoId)
+		}
 	}
 
 	if len(edbIdList) <= 0 {
@@ -729,10 +753,10 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 	edbList, e := data_manage.GetEdbInfoByIdList(edbIdList)
 	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取数据失败,Err:" + e.Error()
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
-
+	//var edbList []*data_manage.EdbInfo
 	// 如果是钢联化工,那么需要过滤供应商暂停的指标
 	if req.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
 		// 获取未被供应商暂停的指标
@@ -760,7 +784,6 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-
 		if len(edbList) <= 0 {
 			br.Ret = 200
 			br.Success = true
@@ -779,11 +802,6 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 		}
 	}
 
-	isStop := 0
-	if req.ModifyStatus == `暂停` {
-		isStop = 1
-	}
-
 	// 查询计算指标ID
 	// 查询相关的计算指标
 	calculateEdbIdList := make([]int, 0)

+ 6 - 0
controllers/data_manage/excel/excel_classify.go

@@ -9,6 +9,7 @@ import (
 	response2 "eta/eta_api/models/data_manage/excel/response"
 	"eta/eta_api/services/data/data_manage_permission"
 	excel2 "eta/eta_api/services/data/excel"
+	excelService "eta/eta_api/services/excel"
 	"eta/eta_api/utils"
 	"fmt"
 	"sort"
@@ -792,6 +793,11 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 			return
 		}
 
+		// 写入ES
+		go func() {
+			excelService.EsAddOrEditExcel(excelInfo.ExcelInfoId)
+		}()
+
 		// 返回下一个表格的信息
 		{
 			var nextItem *excel.ExcelInfo

+ 70 - 33
controllers/data_manage/excel/excel_info.go

@@ -3501,32 +3501,15 @@ func (c *ExcelInfoController) SearchByEs() {
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
 	// 平衡表的查询条件
-	var condBalance string
-	var parsBalance []interface{}
-	if source == utils.BALANCE_TABLE {
-		condBalance += ` AND source = ? AND parent_id = 0 AND balance_type = 0` // 只显示动态表的一级表(不显示子表和静态表)
-		parsBalance = append(parsBalance, source)
-	}
+	//var condBalance string
+	//var parsBalance []interface{}
+	//if source == utils.BALANCE_TABLE {
+	//	condBalance += ` AND source = ? AND parent_id = 0 AND balance_type = 0` // 只显示动态表的一级表(不显示子表和静态表)
+	//	parsBalance = append(parsBalance, source)
+	//}
 
 	// 可见性过滤
 	var queryIds, exceptIds []int
-	{
-		unauthorized, e := excelPermissionModel.GetExcelInfoDataNoPermissionByUserId(sysUser.AdminId, source)
-		if e != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = fmt.Sprintf("获取无权限表格失败, %v", e)
-			return
-		}
-		if len(unauthorized) > 0 {
-			for _, v := range unauthorized {
-				id, _ := strconv.Atoi(v.DataId)
-				if id == 0 {
-					continue
-				}
-				exceptIds = append(exceptIds, id)
-			}
-		}
-	}
 
 	// 自定义分析表
 	var queryAdminId int
@@ -3580,17 +3563,71 @@ func (c *ExcelInfoController) SearchByEs() {
 	}
 	hasCheck := make(map[int]bool)
 	if isShowMe {
-		// 平衡表查询有权限的表格IDs
-		if source == utils.BALANCE_TABLE {
-			excelIds, e := services.GetBalanceExcelIdsByAdminId(sysUser.AdminId, condBalance, parsBalance, permissionEdbIdList, permissionClassifyIdList)
-			if e != nil {
-				br.Msg = "获取失败"
-				br.ErrMsg = fmt.Sprintf("获取平衡表有权限的表格IDs失败, %v", e)
+		if source == utils.BALANCE_TABLE { //平衡表的,显示同时需要显示协作人相关的图表
+			//找到当前协作人相关的表格ID
+			obj := new(excel3.ExcelWorker)
+			existList, err := obj.GetBySysUserId(sysUser.AdminId)
+			if err != nil {
+				br.Msg = "获取表格协作人失败!"
+				br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
 				return
 			}
-			if len(excelIds) == 0 {
-				list := make([]*excel3.SearchExcelInfo, 0)
-				resp := response.SearchExcelListResp{
+			var excelIds []int
+			var newCondition string
+			var newPars []interface{}
+			if len(existList) > 0 {
+				for _, v := range existList {
+					excelIds = append(excelIds, v.ExcelInfoId)
+				}
+				newCondition += fmt.Sprintf(` AND source = ? AND (excel_info_id IN (%s) or sys_user_id = ?)`, utils.GetOrmInReplace(len(excelIds)))
+				newPars = append(newPars, source, excelIds, sysUser.AdminId)
+			} else {
+				newCondition += ` AND sys_user_id = ? `
+				newPars = append(newPars, sysUser.AdminId)
+			}
+
+			//获取表格信息
+			tmpList, e := excel3.GetNoContentExcelListByConditionNoPage(newCondition, newPars)
+			if e != nil && !utils.IsErrNoRow(e) {
+				br.Success = true
+				br.Msg = "获取表格信息失败"
+				br.ErrMsg = "获取表格信息失败,Err:" + e.Error()
+				return
+			}
+			classifyIdListTmp := make([]int, 0)
+			for _, v := range tmpList {
+				classifyIdListTmp = append(classifyIdListTmp, v.ExcelClassifyId)
+			}
+			classifyMap := make(map[int]*excel3.ExcelClassify)
+
+			// 分类信息
+			if len(classifyIdListTmp) > 0 {
+				classifyListTmp, e := excel3.GetClassifyByIdList(classifyIdListTmp)
+				if e != nil {
+					br.Msg = "获取表格分类信息失败"
+					br.ErrMsg = "获取表格分类列表数据失败,Err:" + e.Error()
+					return
+				}
+				for _, v := range classifyListTmp {
+					classifyMap[v.ExcelClassifyId] = v
+				}
+			}
+			excelIds = make([]int, 0)
+			for _, v := range tmpList {
+				// 数据权限
+				if classifyInfo, ok := classifyMap[v.ExcelClassifyId]; ok {
+					v.HaveOperaAuth = data_manage_permission.CheckExcelPermissionByPermissionIdList(v.IsJoinPermission, classifyInfo.IsJoinPermission, v.ExcelInfoId, v.ExcelClassifyId, permissionEdbIdList, permissionClassifyIdList)
+					if v.HaveOperaAuth {
+						excelIds = append(excelIds, v.ExcelInfoId)
+					}
+					hasCheck[v.ExcelInfoId] = v.HaveOperaAuth
+				}
+			}
+			if len(excelIds) > 0 {
+				queryIds = excelIds
+			} else {
+				list := make([]*excel3.MyExcelInfoList, 0)
+				resp := response.ExcelListResp{
 					Paging: page,
 					List:   list,
 				}
@@ -3600,7 +3637,7 @@ func (c *ExcelInfoController) SearchByEs() {
 				br.Data = resp
 				return
 			}
-			queryIds = excelIds
+
 		} else {
 			queryAdminId = sysUser.AdminId
 		}

+ 1 - 1
controllers/data_manage/predict_edb_classify.go

@@ -259,7 +259,7 @@ func (this *PredictEdbClassifyController) Edit() {
 		return
 	}
 
-	err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ParentId, req.ClassifyName, this.Lang, this.SysUser)
+	err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ParentId, req.ClassifyName, this.Lang, this.SysUser, true)
 	if errMsg != `` {
 		br.Msg = errMsg
 		br.ErrMsg = errMsg

+ 4 - 1
controllers/sys_admin.go

@@ -1298,9 +1298,12 @@ func (this *SysAdminController) ResetPass() {
 	_ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
 	abnormalKey := fmt.Sprint(utils.CACHE_ABNORMAL_LOGIN, adminInfo.AdminName)
 	errPassKey := fmt.Sprint(utils.CACHE_LOGIN_ERR_PASS, adminInfo.AdminName)
+	mobileAbnormalKey := fmt.Sprint(utils.MOBILE_CACHE_ABNORMAL_LOGIN, adminInfo.AdminName)
+	mobileErrPassKey := fmt.Sprint(utils.MOBILE_CACHE_LOGIN_ERR_PASS, adminInfo.AdminName)
 	_ = utils.Rc.Delete(abnormalKey)
 	_ = utils.Rc.Delete(errPassKey)
-
+	_ = utils.Rc.Delete(mobileAbnormalKey)
+	_ = utils.Rc.Delete(mobileErrPassKey)
 	br.Ret = 200
 	br.Success = true
 	br.IsAddLog = true

+ 3 - 0
controllers/sys_user.go

@@ -407,6 +407,9 @@ func (this *SysUserController) SystemConfig() {
 	}, system.BusinessConf{
 		ConfKey: "LogoutUrl",
 		ConfVal: conf["LogoutUrl"],
+	}, system.BusinessConf{
+		ConfKey: "UserLogoutUrl",
+		ConfVal: conf["UserLogoutUrl"],
 	})
 
 	br.Data = list

+ 2 - 0
controllers/user_login.go

@@ -881,6 +881,8 @@ func (this *UserLoginController) ForgetResetPass() {
 	abnormalKey := fmt.Sprint(utils.CACHE_ABNORMAL_LOGIN, req.UserName)
 	_ = utils.Rc.Delete(abnormalKey)
 	_ = utils.Rc.Delete(successKey)
+	mobileAbnormalKey := fmt.Sprint(utils.MOBILE_CACHE_ABNORMAL_LOGIN, req.UserName)
+	_ = utils.Rc.Delete(mobileAbnormalKey)
 
 	// 同步ETA用户缓存
 	if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {

+ 71 - 9
models/ai_predict_model/ai_predict_model_index.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -229,7 +230,7 @@ type AiPredictModelIndexPageListResp struct {
 }
 
 // RemoveIndexAndData 删除标的及数据
-func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int) (err error) {
+func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int, chartIds []int) (err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	tx := o.Begin()
 	defer func() {
@@ -252,6 +253,21 @@ func (m *AiPredictModelIndex) RemoveIndexAndData(indexId int) (err error) {
 		err = fmt.Errorf("remove index data err: %v", e)
 		return
 	}
+
+	// 删除图表
+	if len(chartIds) == 0 {
+		return
+	}
+	sql = ` DELETE FROM chart_info WHERE chart_info_id IN ?`
+	if e = tx.Exec(sql, chartIds).Error; e != nil {
+		err = fmt.Errorf("remove charts err: %v", e)
+		return
+	}
+	sql = ` DELETE FROM chart_edb_mapping WHERE chart_info_id IN ?`
+	if e = tx.Exec(sql, chartIds).Error; e != nil {
+		err = fmt.Errorf("remove chart mappings err: %v", e)
+		return
+	}
 	return
 }
 
@@ -277,12 +293,18 @@ func GetFirstAiPredictModelIndexByClassifyId(classifyId int) (item *AiPredictMod
 }
 
 type AiPredictModelImportData struct {
-	Index *AiPredictModelIndex
-	Data  []*AiPredictModelData
+	Index  *AiPredictModelIndex
+	Data   []*AiPredictModelData
+	Charts []*AiPredictModelImportCharts
+}
+
+type AiPredictModelImportCharts struct {
+	ChartInfo   *data_manage.ChartInfo
+	EdbMappings []*data_manage.ChartEdbMapping
 }
 
 // ImportIndexAndData 导入数据
-func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []*AiPredictModelImportData, updateCols []string) (err error) {
+func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []*AiPredictModelImportData, updateCols []string) (chartIds []int, err error) {
 	if len(createIndexes) == 0 && len(updateIndexes) == 0 {
 		return
 	}
@@ -349,23 +371,43 @@ func (m *AiPredictModelIndex) ImportIndexAndData(createIndexes, updateIndexes []
 
 	if len(createIndexes) > 0 {
 		for _, v := range createIndexes {
-			e := tx.Create(v.Index).Error
-			if e != nil {
+			if e := tx.Create(v.Index).Error; e != nil {
 				err = fmt.Errorf("insert index err: %v", e)
 				return
 			}
 
 			indexId := v.Index.AiPredictModelIndexId
 			for _, d := range v.Data {
-				d.AiPredictModelIndexId = int(indexId)
+				d.AiPredictModelIndexId = indexId
 				d.IndexCode = v.Index.IndexCode
 				d.DataTimestamp = d.DataTime.UnixNano() / 1e6
 			}
-			e = tx.CreateInBatches(v.Data, utils.MultiAddNum).Error
-			if e != nil {
+			if e := tx.CreateInBatches(v.Data, utils.MultiAddNum).Error; e != nil {
 				err = fmt.Errorf("insert index data err: %v", e)
 				return
 			}
+
+			// 图表
+			if len(v.Charts) == 0 {
+				continue
+			}
+			for _, ct := range v.Charts {
+				if e := tx.Create(ct.ChartInfo).Error; e != nil {
+					err = fmt.Errorf("insert chart err: %v", e)
+					return
+				}
+				for _, cm := range ct.EdbMappings {
+					cm.ChartInfoId = ct.ChartInfo.ChartInfoId
+					cm.EdbInfoId = indexId
+					time.Sleep(time.Microsecond)
+					cm.UniqueCode = utils.MD5(fmt.Sprint(utils.CHART_PREFIX, "_", indexId, "_", strconv.FormatInt(time.Now().UnixNano(), 10)))
+				}
+				if e := tx.CreateInBatches(ct.EdbMappings, utils.MultiAddNum).Error; e != nil {
+					err = fmt.Errorf("insert chart mapping err: %v", e)
+					return
+				}
+				chartIds = append(chartIds, ct.ChartInfo.ChartInfoId)
+			}
 		}
 	}
 	return
@@ -402,3 +444,23 @@ type AiPredictModelIndexExtraConfig struct {
 		PredictLegendName string `description:"预测图例的名称(通常为Predicted)"`
 	}
 }
+
+func (m *AiPredictModelIndex) GetSortMax() (sort int, err error) {
+	o := global.DbMap[utils.DbNameIndex]
+	sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM ai_predict_model_index`
+	err = o.Raw(sql).Scan(&sort).Error
+	if err != nil {
+		return
+	}
+	// 查询分类的最大排序
+	sql = `SELECT COALESCE(MAX(sort), 0) AS sort FROM ai_predict_model_classify`
+	var classifySort int
+	err = o.Raw(sql).Scan(&classifySort).Error
+	if err != nil {
+		return
+	}
+	if classifySort > sort {
+		sort = classifySort
+	}
+	return
+}

+ 6 - 0
models/data_manage/chart_edb_mapping.go

@@ -388,3 +388,9 @@ func GetRelationEdbInfoListMappingByCondition(condition string, pars []interface
 	err = o.Raw(sql, pars...).Find(&item).Error
 	return
 }
+
+func GetChartEdbMappingsByChartInfoId(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
+	sql := ` SELECT * FROM chart_edb_mapping AS a WHERE chart_info_id = ? ORDER BY chart_edb_mapping_id ASC`
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, chartInfoId).Find(&list).Error
+	return
+}

+ 39 - 0
models/data_manage/chart_info.go

@@ -2976,3 +2976,42 @@ func GetNextChartByClassifyIdAndSource(classifyId, source int) (item *ChartInfo,
 	err = global.DbMap[utils.DbNameIndex].Raw(sql, classifyId, source).First(&item).Error
 	return
 }
+
+// GetAiPredictChartInfoByIndexId 获取AI预测模型图表
+func GetAiPredictChartInfoByIndexId(source, indexId int) (item *ChartInfo, err error) {
+	sql := `SELECT * FROM chart_info WHERE chart_info_id = (
+		  SELECT chart_info_id FROM chart_edb_mapping WHERE source = ? AND edb_info_id = ?
+		) LIMIT 1`
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, source, indexId).First(&item).Error
+	return
+}
+
+func (m *ChartInfo) AddChartInfoAndEdbMappings(item *ChartInfo, edbMappings []*ChartEdbMapping) (err error) {
+	if item == nil {
+		return
+	}
+	tx := global.DbMap[utils.DbNameIndex].Begin()
+	defer func() {
+		if err != nil {
+			_ = tx.Rollback()
+			return
+		}
+		_ = tx.Commit()
+	}()
+
+	if e := tx.Create(item).Error; e != nil {
+		err = fmt.Errorf("insert chart err: %v", e)
+		return
+	}
+	if len(edbMappings) == 0 {
+		return
+	}
+	for _, v := range edbMappings {
+		v.ChartInfoId = item.ChartInfoId
+	}
+	if e := tx.CreateInBatches(edbMappings, utils.MultiAddNum).Error; e != nil {
+		err = fmt.Errorf("insert chart mapping err: %v", e)
+		return
+	}
+	return
+}

+ 6 - 4
models/data_manage/edb_info.go

@@ -104,6 +104,7 @@ type EdbInfoFullClassify struct {
 	ClassifyList   []*EdbClassifyIdItems
 	HaveOperaAuth  bool `description:"是否有数据权限,默认:false"`
 	IsSupplierStop int  `description:"是否供应商停更:1:停更,0:未停更"`
+	IsRelation     bool `description:"是否被引用,默认:0"`
 }
 
 func AddEdbInfo(item *EdbInfo) (lastId int64, err error) {
@@ -527,6 +528,7 @@ type EdbInfoList struct {
 	MinValue         float64                 `description:"最小值"`
 	MaxValue         float64                 `description:"最大值"`
 	SearchText       string                  `description:"搜索结果(含高亮)"`
+	IsRelation       bool                    `description:"是否被引用"`
 }
 
 // AfterFind
@@ -761,14 +763,14 @@ type EdbInfoMaxAndMinInfo struct {
 }
 
 func (edbInfoMaxAndMinInfo *EdbInfoMaxAndMinInfo) AfterFind(tx *gorm.DB) (err error) {
-			edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
-			edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
+	edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
+	edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
 	return
 }
 
 func (edbInfoMaxAndMinInfo *EdbInfoMaxAndMinInfo) ConvertTimeStr() {
-			edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
-			edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
+	edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
+	edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
 }
 
 // GetEdbInfoMaxAndMinInfo

+ 7 - 0
models/data_manage/excel/excel_info.go

@@ -816,3 +816,10 @@ type ExcelInfoFreeze struct {
 	FreezeStartCol int  `description:"冻结开始列"`
 	FreezeEndCol   int  `description:"冻结结束列"`
 }
+
+// GetItemById 主键获取表格
+func (m *ExcelInfo) GetItemById(excelInfoId int) (item *ExcelInfo, err error) {
+	sql := ` SELECT * FROM excel_info WHERE excel_info_id = ? LIMIT 1`
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, excelInfoId).First(&item).Error
+	return
+}

+ 1 - 1
models/sandbox/sandbox_classify.go

@@ -129,7 +129,7 @@ func GetSandboxInfoCountByClassifyId(classifyId int) (count int, err error) {
 	var sql string
 	var pars []interface{}
 	if utils.DbDriverName == utils.DbDriverByDm {
-		sql = `WITH RECURSIVE classify_tree AS (
+		sql = `WITH RECURSIVE classify_tree(sandbox_classify_id, parent_id, level) AS (
     -- 基础查询:获取起始节点
     SELECT sandbox_classify_id, parent_id, 1 as level
     FROM sandbox_classify

+ 1 - 1
models/target.go

@@ -306,7 +306,7 @@ func GetEdbinfoItemList(condition string, pars []interface{}, startSize, pageSiz
 
 // EdbParamsInfo 指标数据结构体
 type EdbParamsInfo struct {
-	Unit      string `gorm:"column(UNIT);" description:"单位" gorm:"column:UNIT"`
+	Unit      string `description:"单位" gorm:"column:UNIT"`
 	Frequency string `gorm:"column:frequency;" description:"单位"`
 }
 

+ 9 - 0
routers/commentsRouter.go

@@ -358,6 +358,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"],
+        beego.ControllerComments{
+            Method: "SearchByEs",
+            Router: `/chart/search_by_es`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage/ai_predict_model:AiPredictModelIndexController"],
         beego.ControllerComments{
             Method: "DashboardDetail",

+ 5 - 5
services/ai_predict_model_classify.go

@@ -156,7 +156,7 @@ func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, n
 	updateCol := make([]string, 0)
 
 	// 移动对象为分类, 判断分类是否存在
-	if edbClassifyInfo != nil {
+	if edbClassifyInfo != nil && edbClassifyInfo.AiPredictModelClassifyId > 0 {
 		oldParentId := edbClassifyInfo.ParentId
 		oldLevel := edbClassifyInfo.Level
 		var classifyIds []int
@@ -271,7 +271,7 @@ func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, n
 			}
 
 			//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-			if firstClassify != nil && firstClassify.Sort == 0 {
+			if firstClassify != nil && firstClassify.AiPredictModelClassifyId > 0 && firstClassify.Sort == 0 {
 				updateSortStr := ` sort + 1 `
 				_ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, firstClassify.AiPredictModelClassifyId-1, 0, updateSortStr)
 				//该分类下的所有指标也需要+1
@@ -286,7 +286,7 @@ func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, n
 				}
 
 				//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-				if firstEdb != nil && firstEdb.Sort == 0 {
+				if firstEdb != nil && firstEdb.AiPredictModelIndexId > 0 && firstEdb.Sort == 0 {
 					updateSortStr := ` sort + 1 `
 					_ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, firstEdb.AiPredictModelIndexId-1, updateSortStr)
 					_ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, 0, updateSortStr)
@@ -403,7 +403,7 @@ func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, n
 			}
 
 			//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-			if firstClassify != nil && firstClassify.Sort == 0 {
+			if firstClassify != nil && firstClassify.AiPredictModelClassifyId> 0 && firstClassify.Sort == 0 {
 				updateSortStr := ` sort + 1 `
 				_ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, firstClassify.AiPredictModelClassifyId-1, 0, updateSortStr)
 				//该分类下的所有指标也需要+1
@@ -418,7 +418,7 @@ func moveAiPredictModelClassify(parentClassify, edbClassifyInfo, prevClassify, n
 				}
 
 				//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-				if firstEdb != nil && firstEdb.Sort == 0 {
+				if firstEdb != nil && firstEdb.AiPredictModelIndexId > 0 && firstEdb.Sort == 0 {
 					updateSortStr := ` sort + 1 `
 					_ = aiPredictModel.UpdateAiPredictModelIndexSortByClassifyId(parentClassifyId, 0, firstEdb.AiPredictModelIndexId-1, updateSortStr)
 					_ = aiPredictModel.UpdateAiPredictModelClassifySortByParentId(parentClassifyId, 0, 0, updateSortStr)

+ 179 - 4
services/ai_predict_model_index.go

@@ -8,10 +8,11 @@ import (
 	"eta/eta_api/utils"
 	"fmt"
 	"sort"
+	"strconv"
 	"time"
 )
 
-func ImportAiPredictModelIndexAndData(imports []*aiPredictModel.AiPredictModelImportData) (err error) {
+func ImportAiPredictModelIndexAndData(imports []*aiPredictModel.AiPredictModelImportData, adminId int, adminRealName string) (err error) {
 	if len(imports) == 0 {
 		return
 	}
@@ -33,6 +34,12 @@ func ImportAiPredictModelIndexAndData(imports []*aiPredictModel.AiPredictModelIm
 	updateCols := []string{indexOb.Cols().ClassifyId, indexOb.Cols().ModelFramework, indexOb.Cols().PredictDate, indexOb.Cols().PredictValue, indexOb.Cols().DirectionAccuracy, indexOb.Cols().AbsoluteDeviation, indexOb.Cols().ExtraConfig, indexOb.Cols().SysUserId, indexOb.Cols().SysUserRealName, indexOb.Cols().ModifyTime}
 	updateIndexes := make([]*aiPredictModel.AiPredictModelImportData, 0)
 	createIndexes := make([]*aiPredictModel.AiPredictModelImportData, 0)
+
+	maxSort, err := indexOb.GetSortMax()
+	if err != nil {
+		err = fmt.Errorf("获取标的最大排序失败, %v", err)
+		return
+	}
 	for _, v := range imports {
 		exist := indexNameItem[v.Index.IndexName]
 		// 编辑
@@ -52,28 +59,42 @@ func ImportAiPredictModelIndexAndData(imports []*aiPredictModel.AiPredictModelIm
 				b, _ := json.Marshal(oldConfig)
 				v.Index.ExtraConfig = string(b)
 			}
-
+			
 			v.Index.AiPredictModelIndexId = exist.AiPredictModelIndexId
 			v.Index.IndexCode = exist.IndexCode
 			updateIndexes = append(updateIndexes, v)
 			continue
 		}
 
-		// 新增
+		// 新增标的/图表
 		indexCode, e := utils.GenerateEdbCode(1, "IPM")
 		if e != nil {
 			err = fmt.Errorf("生成标的编码失败, %v", e)
 			return
 		}
 		v.Index.IndexCode = indexCode
+		v.Charts = GetAiPredictCharts(v.Index.IndexName, adminId, adminRealName)
+		maxSort = maxSort + 1
+		v.Index.Sort = maxSort
 		createIndexes = append(createIndexes, v)
 	}
 
 	// 新增/更新指标
-	if e := indexOb.ImportIndexAndData(createIndexes, updateIndexes, updateCols); e != nil {
+	chartIds, e := indexOb.ImportIndexAndData(createIndexes, updateIndexes, updateCols)
+	if e != nil {
 		err = fmt.Errorf("导入指标失败, %v", e)
 		return
 	}
+
+	// 更新图表ES
+	if len(chartIds) == 0 {
+		return
+	}
+	go func() {
+		for _, v := range chartIds {
+			data.EsAddOrEditChartInfo(v)
+		}
+	}()
 	return
 }
 
@@ -114,8 +135,29 @@ func GetAiPredictChartDetailByData(indexItem *aiPredictModel.AiPredictModelIndex
 		confLeftMax = indexItem.LeftMax
 	}
 
+	// 获取指标对应的图表
+	chartSourceMapping := map[int]int{
+		aiPredictModel.ModelDataSourceMonthly: utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY,
+		aiPredictModel.ModelDataSourceDaily:   utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY,
+	}
+	chartInfo, e := data_manage.GetAiPredictChartInfoByIndexId(chartSourceMapping[source], indexItem.AiPredictModelIndexId)
+	if e != nil && !utils.IsErrNoRow(e) {
+		err = fmt.Errorf("获取标的图表失败, %v", e)
+		return
+	}
+
 	// 获取曲线图主题样式
 	chartView := new(data_manage.ChartInfoView)
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 {
+		chartView.ChartInfoId = chartInfo.ChartInfoId
+		chartView.ChartName = chartInfo.ChartName
+		chartView.ChartNameEn = chartInfo.ChartNameEn
+		chartView.Source = chartInfo.Source
+		chartView.ChartImage = chartInfo.ChartImage
+	} else {
+		chartView.ChartName = indexItem.IndexName
+		chartView.ChartNameEn = indexItem.IndexName
+	}
 	chartView.ChartType = utils.CHART_SOURCE_DEFAULT
 	chartTheme, e := data.GetChartThemeConfig(0, chartView.ChartType, utils.CHART_TYPE_CURVE)
 	if e != nil {
@@ -264,3 +306,136 @@ func GetAiPredictChartDetailByData(indexItem *aiPredictModel.AiPredictModelIndex
 	resp.EdbInfoList = edbList
 	return
 }
+
+// GetAiPredictCharts 获取AI预测模型图表
+func GetAiPredictCharts(indexName string, adminId int, adminRealName string) (charts []*aiPredictModel.AiPredictModelImportCharts) {
+	charts = make([]*aiPredictModel.AiPredictModelImportCharts, 0)
+
+	// 日度/月度图表
+	frequencyArr := []int{aiPredictModel.ModelDataSourceMonthly, aiPredictModel.ModelDataSourceDaily}
+	sourceMapping := map[int]int{
+		aiPredictModel.ModelDataSourceMonthly: utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY,
+		aiPredictModel.ModelDataSourceDaily:   utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY,
+	}
+	suffixNameMapping := map[int]string{
+		aiPredictModel.ModelDataSourceMonthly: "预测模型/回测",
+		aiPredictModel.ModelDataSourceDaily:   "预测模型",
+	}
+
+	for _, v := range frequencyArr {
+		chartSource := sourceMapping[v]
+		newChart := new(aiPredictModel.AiPredictModelImportCharts)
+
+		// 新增图表
+		chartName := fmt.Sprintf("%s%s", indexName, suffixNameMapping[v])
+		chartInfo := new(data_manage.ChartInfo)
+		chartInfo.ChartName = chartName
+		chartInfo.ChartNameEn = chartName
+		chartInfo.ChartType = utils.CHART_TYPE_CURVE
+		chartInfo.Calendar = "公历"
+		chartInfo.SysUserId = adminId
+		chartInfo.SysUserRealName = adminRealName
+		chartInfo.CreateTime = time.Now()
+		chartInfo.ModifyTime = time.Now()
+		chartInfo.Source = chartSource
+		time.Sleep(time.Microsecond)
+		chartInfo.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + strconv.FormatInt(time.Now().UnixNano(), 10))
+		newChart.ChartInfo = chartInfo
+
+		// chart_edb_mapping中edb_info_id为标的ID
+		edbMapping := new(data_manage.ChartEdbMapping)
+		//edbMapping.EdbInfoId = indexId
+		//edbMapping.UniqueCode = utils.MD5(fmt.Sprint(utils.CHART_PREFIX, "_", indexId, "_", strconv.FormatInt(time.Now().UnixNano(), 10)))
+		edbMapping.Source = chartSource
+		edbMapping.CreateTime = time.Now().Local()
+		edbMapping.ModifyTime = time.Now().Local()
+		newChart.EdbMappings = append(newChart.EdbMappings, edbMapping)
+
+		charts = append(charts, newChart)
+	}
+	return
+}
+
+// FixAiPredictCharts 修复AI预测模型图表
+func FixAiPredictCharts() {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+		}
+		fmt.Println("修复完成")
+	}()
+	fmt.Println("开始修复")
+
+	indexOb := new(aiPredictModel.AiPredictModelIndex)
+	indexes, e := indexOb.GetItemsByCondition("", make([]interface{}, 0), []string{}, "")
+	if e != nil {
+		err = fmt.Errorf("获取所有标的失败, %v", e)
+		return
+	}
+	// 日度/月度图表
+	frequencyArr := []int{aiPredictModel.ModelDataSourceMonthly, aiPredictModel.ModelDataSourceDaily}
+	sourceMapping := map[int]int{
+		aiPredictModel.ModelDataSourceMonthly: utils.CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY,
+		aiPredictModel.ModelDataSourceDaily:   utils.CHART_SOURCE_AI_PREDICT_MODEL_DAILY,
+	}
+	suffixNameMapping := map[int]string{
+		aiPredictModel.ModelDataSourceMonthly: "预测模型/回测",
+		aiPredictModel.ModelDataSourceDaily:   "预测模型",
+	}
+	chartOb := new(data_manage.ChartInfo)
+	for _, v := range indexes {
+		for _, fre := range frequencyArr {
+			chartSource := sourceMapping[fre]
+			item, e := data_manage.GetAiPredictChartInfoByIndexId(chartSource, v.AiPredictModelIndexId)
+			if e != nil && !utils.IsErrNoRow(e) {
+				err = fmt.Errorf("获取AI预测模型图表失败, %v", e)
+				return
+			}
+			// 由于标的名称是固定的所以chart_info没有什么可更新的, 已加入过就忽略
+			if item != nil && item.ChartInfoId > 0 {
+				fmt.Printf("标的%d-%d图表已存在, continue\n", v.AiPredictModelIndexId, chartSource)
+				continue
+			}
+
+			// 新增图表
+			chartName := fmt.Sprintf("%s%s", v.IndexName, suffixNameMapping[fre])
+			chartInfo := new(data_manage.ChartInfo)
+			chartInfo.ChartName = chartName
+			chartInfo.ChartNameEn = chartName
+			chartInfo.ChartType = utils.CHART_TYPE_CURVE
+			chartInfo.Calendar = "公历"
+			chartInfo.SysUserId = v.SysUserId
+			chartInfo.SysUserRealName = v.SysUserRealName
+			chartInfo.CreateTime = time.Now()
+			chartInfo.ModifyTime = time.Now()
+			chartInfo.Source = chartSource
+			time.Sleep(time.Microsecond)
+			chartInfo.UniqueCode = utils.MD5(utils.CHART_PREFIX + "_" + strconv.FormatInt(time.Now().UnixNano(), 10))
+
+			// chart_edb_mapping中edb_info_id为标的ID
+			mappings := make([]*data_manage.ChartEdbMapping, 0)
+			edbMapping := new(data_manage.ChartEdbMapping)
+			edbMapping.EdbInfoId = v.AiPredictModelIndexId
+			edbMapping.UniqueCode = utils.MD5(fmt.Sprint(utils.CHART_PREFIX, "_", v.AiPredictModelIndexId, "_", strconv.FormatInt(time.Now().UnixNano(), 10)))
+			edbMapping.Source = chartSource
+			edbMapping.CreateTime = time.Now().Local()
+			edbMapping.ModifyTime = time.Now().Local()
+			mappings = append(mappings, edbMapping)
+
+			// 新增图表
+			if e = chartOb.AddChartInfoAndEdbMappings(chartInfo, mappings); e != nil {
+				err = fmt.Errorf("新增图表及mapping失败, %v", e)
+				return
+			}
+
+			// 写入ES
+			if chartInfo.ChartInfoId <= 0 {
+				err = fmt.Errorf("图表ID有误")
+				return
+			}
+			go data.EsAddOrEditChartInfo(chartInfo.ChartInfoId)
+		}
+	}
+	return
+}

+ 4 - 2
services/data/edb_classify.go

@@ -399,13 +399,15 @@ func AddEdbClassify(classifyName string, parentId, level int, classifyType uint8
 }
 
 // EditEdbClassify 编辑指标分类
-func EditEdbClassify(classifyId, parentId int, classifyName, lang string, sysUser *system.Admin) (err error, errMsg string) {
+func EditEdbClassify(classifyId, parentId int, classifyName, lang string, sysUser *system.Admin, isPreditClassify bool) (err error, errMsg string) {
 	item, err := data_manage.GetEdbClassifyById(classifyId)
 	if err != nil {
 		errMsg = `保存失败`
 		return
 	}
-
+	if isPreditClassify {
+		parentId = item.ParentId // 预测指标的分类编辑时不支持修改父级分类
+	}
 	// 权限校验
 	{
 		// 已授权分类id

+ 45 - 0
services/data/edb_info_relation.go

@@ -474,6 +474,51 @@ func GetEdbRelationList(source, edbType int, classifyId, sysUserId, frequency, k
 	return
 }
 
+// GetEdbRelationList 获取指标引用列表
+func GetEdbRelationListByIds(edbIds []int, source int) (total int, list []*data_manage.BaseRelationEdbInfo, err error) {
+	var pars []interface{}
+	var condition string
+	if len(edbIds) == 0 {
+		return
+	}
+	condition += ` AND e.edb_info_id IN (` + utils.GetOrmInReplace(len(edbIds)) + `)`
+	pars = append(pars, edbIds)
+	list = make([]*data_manage.BaseRelationEdbInfo, 0)
+	// 关联表语句
+	var addFieldStr, joinTableStr string
+	// 供应商停用
+	if source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
+		joinTableStr = ` LEFT JOIN base_from_mysteel_chemical_index z ON e.edb_code = z.index_code `
+		addFieldStr = ` ,z.is_supplier_stop `
+	}
+	total, list, err = data_manage.GetEdbInfoRelationList(condition, pars, addFieldStr, joinTableStr, "", 0, len(edbIds))
+	return
+}
+
+// GetEdbRelationList 获取指标引用列表
+func GetEdbRelationListById(edbId int, source int) (item *data_manage.BaseRelationEdbInfo, err error) {
+	var pars []interface{}
+	var condition string
+	condition += ` AND e.edb_info_id = ?`
+	pars = append(pars, edbId)
+	list := make([]*data_manage.BaseRelationEdbInfo, 0)
+	// 关联表语句
+	var addFieldStr, joinTableStr string
+	// 供应商停用
+	if source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
+		joinTableStr = ` LEFT JOIN base_from_mysteel_chemical_index z ON e.edb_code = z.index_code `
+		addFieldStr = ` ,z.is_supplier_stop `
+	}
+	_, list, err = data_manage.GetEdbInfoRelationList(condition, pars, addFieldStr, joinTableStr, "", 0, 1)
+	if err != nil {
+		return
+	}
+	if len(list) > 0 {
+		item = list[0]
+	}
+	return
+}
+
 // 查找当前计算指标的所有溯源指标
 func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo, needPredict bool) (edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
 	if len(edbInfoList) == 0 {

+ 40 - 2
services/elastic/elastic.go

@@ -2138,7 +2138,7 @@ func SearchDataSourceIndex(indexName, keyword string, source, subSource int, cla
 }
 
 // CreateEsIndex 创建ES索引
-func CreateEsIndex(indexName, jsonMapping string) (err error) {
+func CreateEsIndex(indexName, jsonMapping string) (exists bool, err error) {
 	defer func() {
 		if err != nil {
 			tips := fmt.Sprintf("CreateEsIndex err: %v", err)
@@ -2148,11 +2148,12 @@ func CreateEsIndex(indexName, jsonMapping string) (err error) {
 	client := utils.EsClient
 
 	// 校验是否存在
-	exists, e := client.IndexExists(indexName).Do(context.Background())
+	exist, e := client.IndexExists(indexName).Do(context.Background())
 	if e != nil {
 		err = fmt.Errorf("check exists err: %v", e)
 		return
 	}
+	exists = exist
 	if exists {
 		fmt.Printf("索引已存在: %s, 跳过\n", indexName)
 		return
@@ -2167,3 +2168,40 @@ func CreateEsIndex(indexName, jsonMapping string) (err error) {
 	fmt.Printf("create index success: %s\n", createIndex.Index)
 	return
 }
+
+// ClearEsIndex 清空指定索引的所有数据
+func ClearEsIndex(indexName string) (err error) {
+	defer func() {
+		if err != nil {
+			tips := fmt.Sprintf("ClearEsIndex err: %v", err)
+			utils.FileLog.Info(tips)
+		}
+	}()
+
+	client := utils.EsClient
+
+	// 校验索引是否存在
+	exists, e := client.IndexExists(indexName).Do(context.Background())
+	if e != nil {
+		err = fmt.Errorf("check index exists err: %v", e)
+		return
+	}
+	if !exists {
+		err = fmt.Errorf("index does not exist: %s", indexName)
+		return
+	}
+
+	query := elastic.NewMatchAllQuery()
+	res, e := client.DeleteByQuery().
+		Index(indexName).
+		Query(query).
+		ProceedOnVersionConflict(). // 忽略版本冲突
+		Do(context.Background())
+	if e != nil {
+		err = fmt.Errorf("delete by query err: %v", e)
+		return
+	}
+
+	fmt.Printf("Cleared index: %s, Deleted documents count: %d\n", indexName, res.Deleted)
+	return
+}

+ 2 - 1
services/excel/excel_elastic.go

@@ -17,7 +17,8 @@ func EsAddOrEditExcel(excelId int) {
 			utils.FileLog.Info(tips)
 		}
 	}()
-	item, e := excel2.GetExcelInfoById(excelId)
+	excelOb := new(excel2.ExcelInfo)
+	item, e := excelOb.GetItemById(excelId)
 	if e != nil {
 		err = fmt.Errorf("获取表格失败, %v", e)
 		return

+ 21 - 0
services/material/material.go

@@ -3,6 +3,7 @@ package materialService
 import (
 	"encoding/json"
 	"eta/eta_api/models"
+	aiPredictModel "eta/eta_api/models/ai_predict_model"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/material"
@@ -163,6 +164,26 @@ func AddToMaterial(req material.SaveAsMaterialReq, opUserId int, opUserName stri
 		}
 
 		oldRsourceUrl = docObj.ResultImg
+	case "ai_predict_model_framework":
+		// AI预测模型框架
+		frameworkOb := new(aiPredictModel.AiPredictModelFramework)
+		framework, e := frameworkOb.GetItemById(req.ObjectId)
+		if e != nil {
+			if utils.IsErrNoRow(e) {
+				errMsg = "AI预测模型框架不存在"
+				err = fmt.Errorf("AI预测模型框架不存在")
+				return
+			}
+			errMsg = "获取AI预测模型框架失败"
+			err = e
+			return
+		}
+		if framework.FrameworkImg == "" {
+			errMsg = "AI预测模型框架封面为空"
+			err = fmt.Errorf("AI预测模型框架封面为空")
+			return
+		}
+		oldRsourceUrl = framework.FrameworkImg
 	default:
 		errMsg = "不支持的类型"
 		err = fmt.Errorf("不支持的类型")

+ 3 - 3
services/residual_analysis_service/residual_analysis_service.go

@@ -992,9 +992,9 @@ func ResidualAnalysisDetail(edbInfoId int) (residual_analysis_model.ResidualAnal
 	pars = []interface{}{}
 
 	condition += ` and edb_info_id in(` + utils.GetOrmInReplace(len(edbInfoIdList)) + `)`
-	for _, id := range edbInfoIdList {
-		pars = append(pars, id)
-	}
+	//for _, id := range edbInfoIdList {
+	pars = append(pars, edbInfoIdList)
+	//}
 
 	edbInfoList, err := data_manage.GetEdbInfoListByCond(condition, pars)
 	if err != nil {

+ 506 - 484
services/temp_fix.go

@@ -1,9 +1,7 @@
 package services
 
 import (
-	aiPredictModel "eta/eta_api/models/ai_predict_model"
 	"eta/eta_api/models/data_manage/excel"
-	dataSourceModel "eta/eta_api/models/data_source"
 	"eta/eta_api/services/elastic"
 	excel2 "eta/eta_api/services/excel"
 	"eta/eta_api/utils"
@@ -29,505 +27,529 @@ func FixNewEs() {
 	}
 	fmt.Println("开始创建表格索引:", utils.EsExcelIndexName)
 	indexMapping := `{"mappings":{"properties":{"ExcelInfoId":{"type":"long"},"Source":{"type":"long"},"ExcelType":{"type":"long"},"ExcelName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"UniqueCode":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ExcelClassifyId":{"type":"long"},"SysUserId":{"type":"long"},"SysUserRealName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Content":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ExcelImage":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"FileUrl":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Sort":{"type":"long"},"IsDelete":{"type":"long"},"ModifyTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"CreateTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IsJoinPermission":{"type":"long"},"ParentId":{"type":"long"},"BalanceType":{"type":"long"},"UpdateUserId":{"type":"long"},"UpdateUserRealName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"RelExcelInfoId":{"type":"long"},"VersionName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"SourcesFrom":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}`
-	if e := elastic.CreateEsIndex(utils.EsExcelIndexName, indexMapping); e != nil {
+	tableExists, e := elastic.CreateEsIndex(utils.EsExcelIndexName, indexMapping)
+	if e != nil {
 		err = fmt.Errorf("创建excel索引失败, %v", e)
 		return
 	}
 	fmt.Println("表格索引创建成功")
 
+	// 清空表格数据
+	fmt.Println("开始清空表格数据")
+	if tableExists {
+		if e := elastic.ClearEsIndex(utils.EsExcelIndexName); e != nil {
+			err = fmt.Errorf("清空excel索引数据失败, %v", e)
+			return
+		}
+	}
+	fmt.Println("结束清空表格数据")
+
 	fmt.Println("开始修复表格数据")
 	excels, e := excel.GetExcelInfoAll()
 	if e != nil {
 		err = fmt.Errorf("获取所有excel表格失败, %v", e)
 		return
 	}
+	var fixTotal int
 	for _, v := range excels {
 		fmt.Printf("ExcelId: %d 修复中\n", v.ExcelInfoId)
 		excel2.EsAddOrEditExcel(v.ExcelInfoId)
+		fixTotal += 1
 	}
-	fmt.Println("表格数据修复成功")
+	fmt.Println("表格数据修复成功, Total: ", fixTotal)
 
 	// 数据源
-	fmt.Println("数据源索引名:", utils.EsDataSourceIndexName)
-	if utils.EsDataSourceIndexName == "" {
-		err = fmt.Errorf("数据源索引名为空")
-		return
-	}
-	fmt.Println("开始创建数据源索引:", utils.EsDataSourceIndexName)
-	indexMappingB := `{"mappings":{"properties":{"ClassifyId":{"type":"long"},"CreateTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"EndDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Frequency":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IndexCode":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IndexName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IsDeleted":{"type":"long"},"LatestValue":{"type":"text"},"ModifyTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"PrimaryId":{"type":"long"},"Source":{"type":"long"},"SourceName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"SubSource":{"type":"long"},"StartDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Unit":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}`
-	//indexMappingB := `{"settings":{"analysis":{"analyzer":{"ik_analyzer":{"type":"custom","tokenizer":"ik_max_word"},"ngram_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_filter"]}},"filter":{"ngram_filter":{"type":"ngram","min_gram":1,"max_gram":2,"token_chars":["letter","digit"]}}}},"mappings":{"properties":{"ClassifyId":{"type":"long"},"CreateTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"EndDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Frequency":{"type":"text","analyzer":"ik_smart"},"IndexCode":{"type":"text","fields":{"ngram":{"type":"text","analyzer":"ngram_analyzer","search_analyzer":"standard"},"keyword":{"type":"keyword","ignore_above":256}}},"IndexName":{"type":"text","fields":{"ik":{"type":"text","analyzer":"ik_analyzer","search_analyzer":"ik_analyzer"},"ngram":{"type":"text","analyzer":"ngram_analyzer","search_analyzer":"standard"},"keyword":{"type":"keyword","ignore_above":256}}},"IsDeleted":{"type":"long"},"LatestValue":{"type":"double"},"ModifyTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"PrimaryId":{"type":"long"},"Source":{"type":"long"},"SourceName":{"type":"text","analyzer":"ik_smart"},"SubSource":{"type":"long"},"StartDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Unit":{"type":"text","analyzer":"ik_smart"}}}}`
-	if e := elastic.CreateEsIndex(utils.EsDataSourceIndexName, indexMappingB); e != nil {
-		err = fmt.Errorf("创建数据源索引失败, %v", e)
-		return
-	}
-	fmt.Println("数据源索引创建成功")
-
-	fmt.Println("开始修复数据源")
-	var cond string
-	var pars []interface{}
-	// 睿咨得
-	rzdOb := new(dataSourceModel.BaseFromRzdIndex)
-	{
-		list, e := rzdOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取睿咨得失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:睿咨得-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("睿咨得-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 泛糖科技
-	hisugarOb := new(dataSourceModel.BaseFromHisugarIndex)
-	{
-		list, e := hisugarOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取泛糖科技失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:泛糖科技-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("泛糖科技-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 粮油商务网
-	lyOb := new(dataSourceModel.BaseFromLyIndex)
-	{
-		list, e := lyOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取粮油商务网失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:粮油商务网-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("粮油商务网-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 卓创红期
-	sciHqOb := new(dataSourceModel.BaseFromSciHqIndex)
-	{
-		list, e := sciHqOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取卓创红期失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:卓创红期-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("卓创红期-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 同花顺高频
-	thsHfOb := new(dataSourceModel.BaseFromThsHfIndex)
-	{
-		list, e := thsHfOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取同花顺高频失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:同花顺高频-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("同花顺高频-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 隆众资讯
-	oilchemOb := new(dataSourceModel.BaseFromOilchemIndex)
-	{
-		list, e := oilchemOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取隆众资讯失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:隆众资讯-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("隆众资讯-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// CCF化纤信息
-	ccfOb := new(dataSourceModel.BaseFromCcfIndex)
-	{
-		list, e := ccfOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取CCF化纤信息失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:CCF化纤信息-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("CCF化纤信息-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 上海钢联
-	mysteelOb := new(dataSourceModel.BaseFromMysteelChemicalIndex)
-	{
-		list, e := mysteelOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取上海钢联失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:上海钢联-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("上海钢联-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// SMM、有色原始数据库
-	smmOb := new(dataSourceModel.BaseFromSmmIndex)
-	{
-		list, e := smmOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取有色原始数据库失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:有色原始数据库-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("有色原始数据库-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 百川盈孚
-	baiinfoOb := new(dataSourceModel.BaseFromBaiinfoIndex)
-	{
-		list, e := baiinfoOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取百川盈孚失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:百川盈孚-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("百川盈孚-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 红桃3
-	sciOb := new(dataSourceModel.BaseFromSciIndex)
-	{
-		list, e := sciOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取红桃3失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:红桃3-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("红桃3-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 中国煤炭市场网
-	coalmineOb := new(dataSourceModel.BaseFromCoalmineMapping)
-	{
-		list, e := coalmineOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取中国煤炭市场网失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:中国煤炭市场网-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("中国煤炭市场网-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// EIA STEO报告
-	eiaOb := new(dataSourceModel.BaseFromEiaSteoIndex)
-	{
-		list, e := eiaOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取EIA STEO报告失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:EIA STEO报告-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("EIA STEO报告-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// ICPI消费价格指数
-	icpiOb := new(dataSourceModel.BaseFromIcpiIndex)
-	{
-		list, e := icpiOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取ICPI消费价格指数失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:ICPI消费价格指数-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("ICPI消费价格指数-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 涌益咨询
-	yongyiOb := new(dataSourceModel.BaseFromYongyiIndex)
-	{
-		list, e := yongyiOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取涌益咨询失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:涌益咨询-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("涌益咨询-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 汾渭数据
-	fenweiOb := new(dataSourceModel.BaseFromFenweiIndex)
-	{
-		list, e := fenweiOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取汾渭数据失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:汾渭数据-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("汾渭数据-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 卓创数据
-	sci99Ob := new(dataSourceModel.BaseFromSci99Index)
-	{
-		list, e := sci99Ob.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取卓创数据失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:卓创数据-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("卓创数据-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 钢联原始指标库
-	glOb := new(dataSourceModel.BaseFromGlIndex)
-	{
-		list, e := glOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取钢联原始指标库失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:钢联原始指标库-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("钢联原始指标库-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 手工指标录入
-	manualOb := new(dataSourceModel.BaseFromManualEdb)
-	{
-		list, e := manualOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取手工指标失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:手工指标-%s\n", indexItem.IndexCode)
-			docId := fmt.Sprintf("%d-%s", indexItem.Source, indexItem.IndexCode)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("手工指标-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// Bloomberg
-	bloombergOb := new(dataSourceModel.BaseFromBloombergIndex)
-	{
-		list, e := bloombergOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取Bloomberg失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:Bloomberg-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("Bloomberg-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 煤炭江湖
-	mtjhOb := new(dataSourceModel.BaseFromMtjhMapping)
-	{
-		list, e := mtjhOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取煤炭江湖失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:煤炭江湖-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("煤炭江湖-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// AI预测模型
-	aiPredictOb := new(aiPredictModel.AiPredictModelIndex)
-	{
-		list, e := aiPredictOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取AI预测模型失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := new(dataSourceModel.SearchDataSource)
-			indexItem.PrimaryId = v.AiPredictModelIndexId
-			indexItem.IndexName = v.IndexName
-			indexItem.IndexCode = v.IndexCode
-			indexItem.ClassifyId = v.ClassifyId
-			indexItem.Source = utils.DATA_SOURCE_AI_PREDICT_MODEL
-			indexItem.SourceName = "AI预测模型"
-			indexItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, v.CreateTime)
-			indexItem.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime)
-			fmt.Printf("写入中:AI预测模型-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("AI预测模型-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 美国农业部
-	usdaOb := new(dataSourceModel.BaseFromUsdaFasIndex)
-	{
-		list, e := usdaOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取美国农业部失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:美国农业部-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("美国农业部-写入es失败, %v", e)
-				return
-			}
-		}
-	}
-
-	// 自有数据
-	businessOb := new(dataSourceModel.BaseFromBusinessIndex)
-	{
-		list, e := businessOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if e != nil {
-			err = fmt.Errorf("获取自有数据失败, %v", e)
-			return
-		}
-		for _, v := range list {
-			indexItem := v.Format2SearchDataSource(v)
-			fmt.Printf("写入中:自有数据-%d\n", indexItem.PrimaryId)
-			docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
-			if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
-				err = fmt.Errorf("自有数据-写入es失败, %v", e)
-				return
-			}
-		}
-	}
+	//fmt.Println("数据源索引名:", utils.EsDataSourceIndexName)
+	//if utils.EsDataSourceIndexName == "" {
+	//	err = fmt.Errorf("数据源索引名为空")
+	//	return
+	//}
+	//fmt.Println("开始创建数据源索引:", utils.EsDataSourceIndexName)
+	//indexMappingB := `{"mappings":{"properties":{"ClassifyId":{"type":"long"},"CreateTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"EndDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Frequency":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IndexCode":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IndexName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"IsDeleted":{"type":"long"},"LatestValue":{"type":"text"},"ModifyTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"PrimaryId":{"type":"long"},"Source":{"type":"long"},"SourceName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"SubSource":{"type":"long"},"StartDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Unit":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}}`
+	////indexMappingB := `{"settings":{"analysis":{"analyzer":{"ik_analyzer":{"type":"custom","tokenizer":"ik_max_word"},"ngram_analyzer":{"type":"custom","tokenizer":"standard","filter":["lowercase","ngram_filter"]}},"filter":{"ngram_filter":{"type":"ngram","min_gram":1,"max_gram":2,"token_chars":["letter","digit"]}}}},"mappings":{"properties":{"ClassifyId":{"type":"long"},"CreateTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"EndDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Frequency":{"type":"text","analyzer":"ik_smart"},"IndexCode":{"type":"text","fields":{"ngram":{"type":"text","analyzer":"ngram_analyzer","search_analyzer":"standard"},"keyword":{"type":"keyword","ignore_above":256}}},"IndexName":{"type":"text","fields":{"ik":{"type":"text","analyzer":"ik_analyzer","search_analyzer":"ik_analyzer"},"ngram":{"type":"text","analyzer":"ngram_analyzer","search_analyzer":"standard"},"keyword":{"type":"keyword","ignore_above":256}}},"IsDeleted":{"type":"long"},"LatestValue":{"type":"double"},"ModifyTime":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"PrimaryId":{"type":"long"},"Source":{"type":"long"},"SourceName":{"type":"text","analyzer":"ik_smart"},"SubSource":{"type":"long"},"StartDate":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"Unit":{"type":"text","analyzer":"ik_smart"}}}}`
+	//_, e = elastic.CreateEsIndex(utils.EsDataSourceIndexName, indexMappingB)
+	//if e != nil {
+	//	err = fmt.Errorf("创建数据源索引失败, %v", e)
+	//	return
+	//}
+	//fmt.Println("数据源索引创建成功")
+	//
+	//// 清空数据源
+	////fmt.Println("开始清空数据源")
+	////if sourceExists {
+	////	if e := elastic.ClearEsIndex(utils.EsDataSourceIndexName); e != nil {
+	////		err = fmt.Errorf("清空数据源索引数据失败, %v", e)
+	////		return
+	////	}
+	////}
+	////fmt.Println("结束清空数据源")
+	//
+	//fmt.Println("开始修复数据源")
+	//var cond string
+	//var pars []interface{}
+	//// 睿咨得
+	//rzdOb := new(dataSourceModel.BaseFromRzdIndex)
+	//{
+	//	list, e := rzdOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取睿咨得失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:睿咨得-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("睿咨得-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 泛糖科技
+	//hisugarOb := new(dataSourceModel.BaseFromHisugarIndex)
+	//{
+	//	list, e := hisugarOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取泛糖科技失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:泛糖科技-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("泛糖科技-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 粮油商务网
+	//lyOb := new(dataSourceModel.BaseFromLyIndex)
+	//{
+	//	list, e := lyOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取粮油商务网失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:粮油商务网-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("粮油商务网-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 卓创红期
+	//sciHqOb := new(dataSourceModel.BaseFromSciHqIndex)
+	//{
+	//	list, e := sciHqOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取卓创红期失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:卓创红期-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("卓创红期-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 同花顺高频
+	//thsHfOb := new(dataSourceModel.BaseFromThsHfIndex)
+	//{
+	//	list, e := thsHfOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取同花顺高频失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:同花顺高频-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("同花顺高频-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 隆众资讯
+	//oilchemOb := new(dataSourceModel.BaseFromOilchemIndex)
+	//{
+	//	list, e := oilchemOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取隆众资讯失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:隆众资讯-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("隆众资讯-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// CCF化纤信息
+	//ccfOb := new(dataSourceModel.BaseFromCcfIndex)
+	//{
+	//	list, e := ccfOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取CCF化纤信息失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:CCF化纤信息-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("CCF化纤信息-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 上海钢联
+	//mysteelOb := new(dataSourceModel.BaseFromMysteelChemicalIndex)
+	//{
+	//	list, e := mysteelOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取上海钢联失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:上海钢联-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("上海钢联-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// SMM、有色原始数据库
+	//smmOb := new(dataSourceModel.BaseFromSmmIndex)
+	//{
+	//	list, e := smmOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取有色原始数据库失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:有色原始数据库-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("有色原始数据库-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 百川盈孚
+	//baiinfoOb := new(dataSourceModel.BaseFromBaiinfoIndex)
+	//{
+	//	list, e := baiinfoOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取百川盈孚失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:百川盈孚-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("百川盈孚-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 红桃3
+	//sciOb := new(dataSourceModel.BaseFromSciIndex)
+	//{
+	//	list, e := sciOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取红桃3失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:红桃3-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("红桃3-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 中国煤炭市场网
+	//coalmineOb := new(dataSourceModel.BaseFromCoalmineMapping)
+	//{
+	//	list, e := coalmineOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取中国煤炭市场网失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:中国煤炭市场网-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("中国煤炭市场网-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// EIA STEO报告
+	//eiaOb := new(dataSourceModel.BaseFromEiaSteoIndex)
+	//{
+	//	list, e := eiaOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取EIA STEO报告失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:EIA STEO报告-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("EIA STEO报告-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// ICPI消费价格指数
+	//icpiOb := new(dataSourceModel.BaseFromIcpiIndex)
+	//{
+	//	list, e := icpiOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取ICPI消费价格指数失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:ICPI消费价格指数-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("ICPI消费价格指数-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 涌益咨询
+	//yongyiOb := new(dataSourceModel.BaseFromYongyiIndex)
+	//{
+	//	list, e := yongyiOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取涌益咨询失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:涌益咨询-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("涌益咨询-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 汾渭数据
+	//fenweiOb := new(dataSourceModel.BaseFromFenweiIndex)
+	//{
+	//	list, e := fenweiOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取汾渭数据失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:汾渭数据-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("汾渭数据-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 卓创数据
+	//sci99Ob := new(dataSourceModel.BaseFromSci99Index)
+	//{
+	//	list, e := sci99Ob.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取卓创数据失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:卓创数据-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("卓创数据-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 钢联原始指标库
+	//glOb := new(dataSourceModel.BaseFromGlIndex)
+	//{
+	//	list, e := glOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取钢联原始指标库失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:钢联原始指标库-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("钢联原始指标库-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 手工指标录入
+	//manualOb := new(dataSourceModel.BaseFromManualEdb)
+	//{
+	//	list, e := manualOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取手工指标失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:手工指标-%s\n", indexItem.IndexCode)
+	//		docId := fmt.Sprintf("%d-%s", indexItem.Source, indexItem.IndexCode)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("手工指标-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// Bloomberg
+	//bloombergOb := new(dataSourceModel.BaseFromBloombergIndex)
+	//{
+	//	list, e := bloombergOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取Bloomberg失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:Bloomberg-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("Bloomberg-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 煤炭江湖
+	//mtjhOb := new(dataSourceModel.BaseFromMtjhMapping)
+	//{
+	//	list, e := mtjhOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取煤炭江湖失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:煤炭江湖-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("煤炭江湖-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// AI预测模型
+	//aiPredictOb := new(aiPredictModel.AiPredictModelIndex)
+	//{
+	//	list, e := aiPredictOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取AI预测模型失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := new(dataSourceModel.SearchDataSource)
+	//		indexItem.PrimaryId = v.AiPredictModelIndexId
+	//		indexItem.IndexName = v.IndexName
+	//		indexItem.IndexCode = v.IndexCode
+	//		indexItem.ClassifyId = v.ClassifyId
+	//		indexItem.Source = utils.DATA_SOURCE_AI_PREDICT_MODEL
+	//		indexItem.SourceName = "AI预测模型"
+	//		indexItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, v.CreateTime)
+	//		indexItem.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime)
+	//		fmt.Printf("写入中:AI预测模型-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("AI预测模型-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 美国农业部
+	//usdaOb := new(dataSourceModel.BaseFromUsdaFasIndex)
+	//{
+	//	list, e := usdaOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取美国农业部失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:美国农业部-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("美国农业部-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
+	//
+	//// 自有数据
+	//businessOb := new(dataSourceModel.BaseFromBusinessIndex)
+	//{
+	//	list, e := businessOb.GetItemsByCondition(cond, pars, []string{}, "")
+	//	if e != nil {
+	//		err = fmt.Errorf("获取自有数据失败, %v", e)
+	//		return
+	//	}
+	//	for _, v := range list {
+	//		indexItem := v.Format2SearchDataSource(v)
+	//		fmt.Printf("写入中:自有数据-%d\n", indexItem.PrimaryId)
+	//		docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
+	//		if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
+	//			err = fmt.Errorf("自有数据-写入es失败, %v", e)
+	//			return
+	//		}
+	//	}
+	//}
 
 	fmt.Println("修复完成")
 }

+ 5 - 0
utils/constants.go

@@ -237,6 +237,9 @@ const (
 	CACHE_ACCESS_TOKEN_LOGIN_NO_TRUST = "pc_eta_admin:login:no_trust:"        //管理后台登录(不可信登录态)
 	CACHE_ABNORMAL_LOGIN              = "pc_eta_admin:login:abnormal:"        //管理后台登录-异常登录
 	CACHE_LOGIN_ERR_PASS              = "pc_eta_admin:login:errPass:"         //管理后台登录-输入错误密码次数
+	MOBILE_CACHE_ABNORMAL_LOGIN       = "mobile_eta_admin:login:abnormal:"        //管理后台登录-异常登录
+	MOBILE_CACHE_LOGIN_ERR_PASS             = "mobile_eta_admin:login:errPass:"         //管理后台登录-输入错误密码次数
+
 	CACHE_FIND_PASS_VERIFY            = "pc_eta_admin:findPass:verify:"       //找回密码校验成功标记
 	CACHE_KEY_MYSTEEL_REFRESH         = "mysteel_chemical:refresh"            //钢联化工刷新
 	CACHE_KEY_DAYNEW_REFRESH          = "admin:day_new:refresh"               //每日资讯拉取企业微信聊天记录
@@ -320,6 +323,8 @@ const (
 	CHART_SOURCE_BALANCE_EXCEL                   = 11 // 平衡表图表
 	CHART_SOURCE_RANGE_ANALYSIS                  = 12 // 	区间分析图表
 	CHART_SOURCE_TRADE_ANALYSIS_PROCESS          = 13 // 持仓分析-建仓过程图表
+	CHART_SOURCE_AI_PREDICT_MODEL_DAILY          = 14 // AI预测模型图表-日度预测
+	CHART_SOURCE_AI_PREDICT_MODEL_MONTHLY        = 15 // AI预测模型图表-月度预测
 )
 
 // 批量配置图表的位置来源