123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- 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"
- "fmt"
- )
- // FixNewEs 修复新的es数据
- func FixNewEs() {
- fmt.Println("开始修复")
- var err error
- defer func() {
- if err != nil {
- tips := fmt.Sprintf("修复es历史数据失败, %v", err)
- fmt.Println(tips)
- utils.FileLog.Info(tips)
- }
- }()
- // 表格
- if utils.EsExcelIndexName == "" {
- err = fmt.Errorf("表格索引名为空")
- return
- }
- 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 {
- 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
- }
- for _, v := range excels {
- fmt.Printf("ExcelId: %d 修复中\n", v.ExcelInfoId)
- excel2.EsAddOrEditExcel(v.ExcelInfoId)
- }
- fmt.Println("表格数据修复成功")
- // 数据源
- 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("修复完成")
- }
|