temp_fix.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. package services
  2. import (
  3. "eta/eta_api/models/data_manage/excel"
  4. "eta/eta_api/services/elastic"
  5. excel2 "eta/eta_api/services/excel"
  6. "eta/eta_api/utils"
  7. "fmt"
  8. )
  9. // FixNewEs 修复新的es数据
  10. func FixNewEs() {
  11. fmt.Println("开始修复")
  12. var err error
  13. defer func() {
  14. if err != nil {
  15. tips := fmt.Sprintf("修复es历史数据失败, %v", err)
  16. fmt.Println(tips)
  17. utils.FileLog.Info(tips)
  18. }
  19. }()
  20. // 表格
  21. if utils.EsExcelIndexName == "" {
  22. err = fmt.Errorf("表格索引名为空")
  23. return
  24. }
  25. fmt.Println("开始创建表格索引:", utils.EsExcelIndexName)
  26. 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}}}}}}`
  27. tableExists, e := elastic.CreateEsIndex(utils.EsExcelIndexName, indexMapping)
  28. if e != nil {
  29. err = fmt.Errorf("创建excel索引失败, %v", e)
  30. return
  31. }
  32. fmt.Println("表格索引创建成功")
  33. // 清空表格数据
  34. fmt.Println("开始清空表格数据")
  35. if tableExists {
  36. if e := elastic.ClearEsIndex(utils.EsExcelIndexName); e != nil {
  37. err = fmt.Errorf("清空excel索引数据失败, %v", e)
  38. return
  39. }
  40. }
  41. fmt.Println("结束清空表格数据")
  42. fmt.Println("开始修复表格数据")
  43. excels, e := excel.GetExcelInfoAll()
  44. if e != nil {
  45. err = fmt.Errorf("获取所有excel表格失败, %v", e)
  46. return
  47. }
  48. var fixTotal int
  49. for _, v := range excels {
  50. fmt.Printf("ExcelId: %d 修复中\n", v.ExcelInfoId)
  51. excel2.EsAddOrEditExcel(v.ExcelInfoId)
  52. fixTotal += 1
  53. }
  54. fmt.Println("表格数据修复成功, Total: ", fixTotal)
  55. // 数据源
  56. //fmt.Println("数据源索引名:", utils.EsDataSourceIndexName)
  57. //if utils.EsDataSourceIndexName == "" {
  58. // err = fmt.Errorf("数据源索引名为空")
  59. // return
  60. //}
  61. //fmt.Println("开始创建数据源索引:", utils.EsDataSourceIndexName)
  62. //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}}}}}}`
  63. ////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"}}}}`
  64. //_, e = elastic.CreateEsIndex(utils.EsDataSourceIndexName, indexMappingB)
  65. //if e != nil {
  66. // err = fmt.Errorf("创建数据源索引失败, %v", e)
  67. // return
  68. //}
  69. //fmt.Println("数据源索引创建成功")
  70. //
  71. //// 清空数据源
  72. ////fmt.Println("开始清空数据源")
  73. ////if sourceExists {
  74. //// if e := elastic.ClearEsIndex(utils.EsDataSourceIndexName); e != nil {
  75. //// err = fmt.Errorf("清空数据源索引数据失败, %v", e)
  76. //// return
  77. //// }
  78. ////}
  79. ////fmt.Println("结束清空数据源")
  80. //
  81. //fmt.Println("开始修复数据源")
  82. //var cond string
  83. //var pars []interface{}
  84. //// 睿咨得
  85. //rzdOb := new(dataSourceModel.BaseFromRzdIndex)
  86. //{
  87. // list, e := rzdOb.GetItemsByCondition(cond, pars, []string{}, "")
  88. // if e != nil {
  89. // err = fmt.Errorf("获取睿咨得失败, %v", e)
  90. // return
  91. // }
  92. // for _, v := range list {
  93. // indexItem := v.Format2SearchDataSource(v)
  94. // fmt.Printf("写入中:睿咨得-%d\n", indexItem.PrimaryId)
  95. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  96. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  97. // err = fmt.Errorf("睿咨得-写入es失败, %v", e)
  98. // return
  99. // }
  100. // }
  101. //}
  102. //
  103. //// 泛糖科技
  104. //hisugarOb := new(dataSourceModel.BaseFromHisugarIndex)
  105. //{
  106. // list, e := hisugarOb.GetItemsByCondition(cond, pars, []string{}, "")
  107. // if e != nil {
  108. // err = fmt.Errorf("获取泛糖科技失败, %v", e)
  109. // return
  110. // }
  111. // for _, v := range list {
  112. // indexItem := v.Format2SearchDataSource(v)
  113. // fmt.Printf("写入中:泛糖科技-%d\n", indexItem.PrimaryId)
  114. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  115. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  116. // err = fmt.Errorf("泛糖科技-写入es失败, %v", e)
  117. // return
  118. // }
  119. // }
  120. //}
  121. //
  122. //// 粮油商务网
  123. //lyOb := new(dataSourceModel.BaseFromLyIndex)
  124. //{
  125. // list, e := lyOb.GetItemsByCondition(cond, pars, []string{}, "")
  126. // if e != nil {
  127. // err = fmt.Errorf("获取粮油商务网失败, %v", e)
  128. // return
  129. // }
  130. // for _, v := range list {
  131. // indexItem := v.Format2SearchDataSource(v)
  132. // fmt.Printf("写入中:粮油商务网-%d\n", indexItem.PrimaryId)
  133. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  134. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  135. // err = fmt.Errorf("粮油商务网-写入es失败, %v", e)
  136. // return
  137. // }
  138. // }
  139. //}
  140. //
  141. //// 卓创红期
  142. //sciHqOb := new(dataSourceModel.BaseFromSciHqIndex)
  143. //{
  144. // list, e := sciHqOb.GetItemsByCondition(cond, pars, []string{}, "")
  145. // if e != nil {
  146. // err = fmt.Errorf("获取卓创红期失败, %v", e)
  147. // return
  148. // }
  149. // for _, v := range list {
  150. // indexItem := v.Format2SearchDataSource(v)
  151. // fmt.Printf("写入中:卓创红期-%d\n", indexItem.PrimaryId)
  152. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  153. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  154. // err = fmt.Errorf("卓创红期-写入es失败, %v", e)
  155. // return
  156. // }
  157. // }
  158. //}
  159. //
  160. //// 同花顺高频
  161. //thsHfOb := new(dataSourceModel.BaseFromThsHfIndex)
  162. //{
  163. // list, e := thsHfOb.GetItemsByCondition(cond, pars, []string{}, "")
  164. // if e != nil {
  165. // err = fmt.Errorf("获取同花顺高频失败, %v", e)
  166. // return
  167. // }
  168. // for _, v := range list {
  169. // indexItem := v.Format2SearchDataSource(v)
  170. // fmt.Printf("写入中:同花顺高频-%d\n", indexItem.PrimaryId)
  171. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  172. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  173. // err = fmt.Errorf("同花顺高频-写入es失败, %v", e)
  174. // return
  175. // }
  176. // }
  177. //}
  178. //
  179. //// 隆众资讯
  180. //oilchemOb := new(dataSourceModel.BaseFromOilchemIndex)
  181. //{
  182. // list, e := oilchemOb.GetItemsByCondition(cond, pars, []string{}, "")
  183. // if e != nil {
  184. // err = fmt.Errorf("获取隆众资讯失败, %v", e)
  185. // return
  186. // }
  187. // for _, v := range list {
  188. // indexItem := v.Format2SearchDataSource(v)
  189. // fmt.Printf("写入中:隆众资讯-%d\n", indexItem.PrimaryId)
  190. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  191. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  192. // err = fmt.Errorf("隆众资讯-写入es失败, %v", e)
  193. // return
  194. // }
  195. // }
  196. //}
  197. //
  198. //// CCF化纤信息
  199. //ccfOb := new(dataSourceModel.BaseFromCcfIndex)
  200. //{
  201. // list, e := ccfOb.GetItemsByCondition(cond, pars, []string{}, "")
  202. // if e != nil {
  203. // err = fmt.Errorf("获取CCF化纤信息失败, %v", e)
  204. // return
  205. // }
  206. // for _, v := range list {
  207. // indexItem := v.Format2SearchDataSource(v)
  208. // fmt.Printf("写入中:CCF化纤信息-%d\n", indexItem.PrimaryId)
  209. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  210. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  211. // err = fmt.Errorf("CCF化纤信息-写入es失败, %v", e)
  212. // return
  213. // }
  214. // }
  215. //}
  216. //
  217. //// 上海钢联
  218. //mysteelOb := new(dataSourceModel.BaseFromMysteelChemicalIndex)
  219. //{
  220. // list, e := mysteelOb.GetItemsByCondition(cond, pars, []string{}, "")
  221. // if e != nil {
  222. // err = fmt.Errorf("获取上海钢联失败, %v", e)
  223. // return
  224. // }
  225. // for _, v := range list {
  226. // indexItem := v.Format2SearchDataSource(v)
  227. // fmt.Printf("写入中:上海钢联-%d\n", indexItem.PrimaryId)
  228. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  229. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  230. // err = fmt.Errorf("上海钢联-写入es失败, %v", e)
  231. // return
  232. // }
  233. // }
  234. //}
  235. //
  236. //// SMM、有色原始数据库
  237. //smmOb := new(dataSourceModel.BaseFromSmmIndex)
  238. //{
  239. // list, e := smmOb.GetItemsByCondition(cond, pars, []string{}, "")
  240. // if e != nil {
  241. // err = fmt.Errorf("获取有色原始数据库失败, %v", e)
  242. // return
  243. // }
  244. // for _, v := range list {
  245. // indexItem := v.Format2SearchDataSource(v)
  246. // fmt.Printf("写入中:有色原始数据库-%d\n", indexItem.PrimaryId)
  247. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  248. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  249. // err = fmt.Errorf("有色原始数据库-写入es失败, %v", e)
  250. // return
  251. // }
  252. // }
  253. //}
  254. //
  255. //// 百川盈孚
  256. //baiinfoOb := new(dataSourceModel.BaseFromBaiinfoIndex)
  257. //{
  258. // list, e := baiinfoOb.GetItemsByCondition(cond, pars, []string{}, "")
  259. // if e != nil {
  260. // err = fmt.Errorf("获取百川盈孚失败, %v", e)
  261. // return
  262. // }
  263. // for _, v := range list {
  264. // indexItem := v.Format2SearchDataSource(v)
  265. // fmt.Printf("写入中:百川盈孚-%d\n", indexItem.PrimaryId)
  266. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  267. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  268. // err = fmt.Errorf("百川盈孚-写入es失败, %v", e)
  269. // return
  270. // }
  271. // }
  272. //}
  273. //
  274. //// 红桃3
  275. //sciOb := new(dataSourceModel.BaseFromSciIndex)
  276. //{
  277. // list, e := sciOb.GetItemsByCondition(cond, pars, []string{}, "")
  278. // if e != nil {
  279. // err = fmt.Errorf("获取红桃3失败, %v", e)
  280. // return
  281. // }
  282. // for _, v := range list {
  283. // indexItem := v.Format2SearchDataSource(v)
  284. // fmt.Printf("写入中:红桃3-%d\n", indexItem.PrimaryId)
  285. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  286. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  287. // err = fmt.Errorf("红桃3-写入es失败, %v", e)
  288. // return
  289. // }
  290. // }
  291. //}
  292. //
  293. //// 中国煤炭市场网
  294. //coalmineOb := new(dataSourceModel.BaseFromCoalmineMapping)
  295. //{
  296. // list, e := coalmineOb.GetItemsByCondition(cond, pars, []string{}, "")
  297. // if e != nil {
  298. // err = fmt.Errorf("获取中国煤炭市场网失败, %v", e)
  299. // return
  300. // }
  301. // for _, v := range list {
  302. // indexItem := v.Format2SearchDataSource(v)
  303. // fmt.Printf("写入中:中国煤炭市场网-%d\n", indexItem.PrimaryId)
  304. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  305. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  306. // err = fmt.Errorf("中国煤炭市场网-写入es失败, %v", e)
  307. // return
  308. // }
  309. // }
  310. //}
  311. //
  312. //// EIA STEO报告
  313. //eiaOb := new(dataSourceModel.BaseFromEiaSteoIndex)
  314. //{
  315. // list, e := eiaOb.GetItemsByCondition(cond, pars, []string{}, "")
  316. // if e != nil {
  317. // err = fmt.Errorf("获取EIA STEO报告失败, %v", e)
  318. // return
  319. // }
  320. // for _, v := range list {
  321. // indexItem := v.Format2SearchDataSource(v)
  322. // fmt.Printf("写入中:EIA STEO报告-%d\n", indexItem.PrimaryId)
  323. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  324. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  325. // err = fmt.Errorf("EIA STEO报告-写入es失败, %v", e)
  326. // return
  327. // }
  328. // }
  329. //}
  330. //
  331. //// ICPI消费价格指数
  332. //icpiOb := new(dataSourceModel.BaseFromIcpiIndex)
  333. //{
  334. // list, e := icpiOb.GetItemsByCondition(cond, pars, []string{}, "")
  335. // if e != nil {
  336. // err = fmt.Errorf("获取ICPI消费价格指数失败, %v", e)
  337. // return
  338. // }
  339. // for _, v := range list {
  340. // indexItem := v.Format2SearchDataSource(v)
  341. // fmt.Printf("写入中:ICPI消费价格指数-%d\n", indexItem.PrimaryId)
  342. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  343. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  344. // err = fmt.Errorf("ICPI消费价格指数-写入es失败, %v", e)
  345. // return
  346. // }
  347. // }
  348. //}
  349. //
  350. //// 涌益咨询
  351. //yongyiOb := new(dataSourceModel.BaseFromYongyiIndex)
  352. //{
  353. // list, e := yongyiOb.GetItemsByCondition(cond, pars, []string{}, "")
  354. // if e != nil {
  355. // err = fmt.Errorf("获取涌益咨询失败, %v", e)
  356. // return
  357. // }
  358. // for _, v := range list {
  359. // indexItem := v.Format2SearchDataSource(v)
  360. // fmt.Printf("写入中:涌益咨询-%d\n", indexItem.PrimaryId)
  361. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  362. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  363. // err = fmt.Errorf("涌益咨询-写入es失败, %v", e)
  364. // return
  365. // }
  366. // }
  367. //}
  368. //
  369. //// 汾渭数据
  370. //fenweiOb := new(dataSourceModel.BaseFromFenweiIndex)
  371. //{
  372. // list, e := fenweiOb.GetItemsByCondition(cond, pars, []string{}, "")
  373. // if e != nil {
  374. // err = fmt.Errorf("获取汾渭数据失败, %v", e)
  375. // return
  376. // }
  377. // for _, v := range list {
  378. // indexItem := v.Format2SearchDataSource(v)
  379. // fmt.Printf("写入中:汾渭数据-%d\n", indexItem.PrimaryId)
  380. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  381. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  382. // err = fmt.Errorf("汾渭数据-写入es失败, %v", e)
  383. // return
  384. // }
  385. // }
  386. //}
  387. //
  388. //// 卓创数据
  389. //sci99Ob := new(dataSourceModel.BaseFromSci99Index)
  390. //{
  391. // list, e := sci99Ob.GetItemsByCondition(cond, pars, []string{}, "")
  392. // if e != nil {
  393. // err = fmt.Errorf("获取卓创数据失败, %v", e)
  394. // return
  395. // }
  396. // for _, v := range list {
  397. // indexItem := v.Format2SearchDataSource(v)
  398. // fmt.Printf("写入中:卓创数据-%d\n", indexItem.PrimaryId)
  399. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  400. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  401. // err = fmt.Errorf("卓创数据-写入es失败, %v", e)
  402. // return
  403. // }
  404. // }
  405. //}
  406. //
  407. //// 钢联原始指标库
  408. //glOb := new(dataSourceModel.BaseFromGlIndex)
  409. //{
  410. // list, e := glOb.GetItemsByCondition(cond, pars, []string{}, "")
  411. // if e != nil {
  412. // err = fmt.Errorf("获取钢联原始指标库失败, %v", e)
  413. // return
  414. // }
  415. // for _, v := range list {
  416. // indexItem := v.Format2SearchDataSource(v)
  417. // fmt.Printf("写入中:钢联原始指标库-%d\n", indexItem.PrimaryId)
  418. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  419. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  420. // err = fmt.Errorf("钢联原始指标库-写入es失败, %v", e)
  421. // return
  422. // }
  423. // }
  424. //}
  425. //
  426. //// 手工指标录入
  427. //manualOb := new(dataSourceModel.BaseFromManualEdb)
  428. //{
  429. // list, e := manualOb.GetItemsByCondition(cond, pars, []string{}, "")
  430. // if e != nil {
  431. // err = fmt.Errorf("获取手工指标失败, %v", e)
  432. // return
  433. // }
  434. // for _, v := range list {
  435. // indexItem := v.Format2SearchDataSource(v)
  436. // fmt.Printf("写入中:手工指标-%s\n", indexItem.IndexCode)
  437. // docId := fmt.Sprintf("%d-%s", indexItem.Source, indexItem.IndexCode)
  438. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  439. // err = fmt.Errorf("手工指标-写入es失败, %v", e)
  440. // return
  441. // }
  442. // }
  443. //}
  444. //
  445. //// Bloomberg
  446. //bloombergOb := new(dataSourceModel.BaseFromBloombergIndex)
  447. //{
  448. // list, e := bloombergOb.GetItemsByCondition(cond, pars, []string{}, "")
  449. // if e != nil {
  450. // err = fmt.Errorf("获取Bloomberg失败, %v", e)
  451. // return
  452. // }
  453. // for _, v := range list {
  454. // indexItem := v.Format2SearchDataSource(v)
  455. // fmt.Printf("写入中:Bloomberg-%d\n", indexItem.PrimaryId)
  456. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  457. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  458. // err = fmt.Errorf("Bloomberg-写入es失败, %v", e)
  459. // return
  460. // }
  461. // }
  462. //}
  463. //
  464. //// 煤炭江湖
  465. //mtjhOb := new(dataSourceModel.BaseFromMtjhMapping)
  466. //{
  467. // list, e := mtjhOb.GetItemsByCondition(cond, pars, []string{}, "")
  468. // if e != nil {
  469. // err = fmt.Errorf("获取煤炭江湖失败, %v", e)
  470. // return
  471. // }
  472. // for _, v := range list {
  473. // indexItem := v.Format2SearchDataSource(v)
  474. // fmt.Printf("写入中:煤炭江湖-%d\n", indexItem.PrimaryId)
  475. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  476. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  477. // err = fmt.Errorf("煤炭江湖-写入es失败, %v", e)
  478. // return
  479. // }
  480. // }
  481. //}
  482. //
  483. //// AI预测模型
  484. //aiPredictOb := new(aiPredictModel.AiPredictModelIndex)
  485. //{
  486. // list, e := aiPredictOb.GetItemsByCondition(cond, pars, []string{}, "")
  487. // if e != nil {
  488. // err = fmt.Errorf("获取AI预测模型失败, %v", e)
  489. // return
  490. // }
  491. // for _, v := range list {
  492. // indexItem := new(dataSourceModel.SearchDataSource)
  493. // indexItem.PrimaryId = v.AiPredictModelIndexId
  494. // indexItem.IndexName = v.IndexName
  495. // indexItem.IndexCode = v.IndexCode
  496. // indexItem.ClassifyId = v.ClassifyId
  497. // indexItem.Source = utils.DATA_SOURCE_AI_PREDICT_MODEL
  498. // indexItem.SourceName = "AI预测模型"
  499. // indexItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, v.CreateTime)
  500. // indexItem.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime)
  501. // fmt.Printf("写入中:AI预测模型-%d\n", indexItem.PrimaryId)
  502. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  503. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  504. // err = fmt.Errorf("AI预测模型-写入es失败, %v", e)
  505. // return
  506. // }
  507. // }
  508. //}
  509. //
  510. //// 美国农业部
  511. //usdaOb := new(dataSourceModel.BaseFromUsdaFasIndex)
  512. //{
  513. // list, e := usdaOb.GetItemsByCondition(cond, pars, []string{}, "")
  514. // if e != nil {
  515. // err = fmt.Errorf("获取美国农业部失败, %v", e)
  516. // return
  517. // }
  518. // for _, v := range list {
  519. // indexItem := v.Format2SearchDataSource(v)
  520. // fmt.Printf("写入中:美国农业部-%d\n", indexItem.PrimaryId)
  521. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  522. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  523. // err = fmt.Errorf("美国农业部-写入es失败, %v", e)
  524. // return
  525. // }
  526. // }
  527. //}
  528. //
  529. //// 自有数据
  530. //businessOb := new(dataSourceModel.BaseFromBusinessIndex)
  531. //{
  532. // list, e := businessOb.GetItemsByCondition(cond, pars, []string{}, "")
  533. // if e != nil {
  534. // err = fmt.Errorf("获取自有数据失败, %v", e)
  535. // return
  536. // }
  537. // for _, v := range list {
  538. // indexItem := v.Format2SearchDataSource(v)
  539. // fmt.Printf("写入中:自有数据-%d\n", indexItem.PrimaryId)
  540. // docId := fmt.Sprintf("%d-%d", indexItem.Source, indexItem.PrimaryId)
  541. // if e := elastic.EsAddOrEditDataSourceIndex(utils.EsDataSourceIndexName, docId, indexItem); e != nil {
  542. // err = fmt.Errorf("自有数据-写入es失败, %v", e)
  543. // return
  544. // }
  545. // }
  546. //}
  547. fmt.Println("修复完成")
  548. }