Browse Source

fix: BI看板引用混合表格数量有误

hsun 4 days ago
parent
commit
254be9d646

+ 2 - 1
.gitignore

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

+ 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
 		}

+ 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
+}

+ 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

+ 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("修复完成")
 }