data_init.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package controllers
  2. import (
  3. "eta/eta_data_init/models"
  4. "eta/eta_data_init/services"
  5. "fmt"
  6. beego "github.com/beego/beego/v2/server/web"
  7. )
  8. // DataInitController
  9. // Operations about Users
  10. type DataInitController struct {
  11. beego.Controller
  12. }
  13. // Base
  14. // @Title 初始化基础指标数据-不包含钢联化工的基础指标初始化
  15. // @Description 初始化基础指标数据-不包含钢联化工的基础指标初始化
  16. // @Param FileName query string true "文件名称"
  17. // @Success Ret=200
  18. // @router /base [get]
  19. func (this *DataInitController) Base() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  22. this.Data["json"] = br
  23. this.ServeJSON()
  24. }()
  25. fileName := this.GetString("FileName")
  26. if fileName == "" {
  27. br.Msg = "文件名称不能为空"
  28. return
  29. }
  30. filePath := "/docs/" + fileName
  31. fmt.Println("filePath:" + filePath)
  32. services.InitBaseIndexData(filePath)
  33. br.Ret = 200
  34. br.Msg = "初始化成功"
  35. }
  36. // MySteelChemicalToSource
  37. // @Title 初始化联化工指标(添加到数据源)
  38. // @Description 初始化联化工指标(添加到数据源)
  39. // @Param FileName query string true "文件名称"
  40. // @Success Ret=200
  41. // @router /mysteel_chemical [get]
  42. func (this *DataInitController) MySteelChemicalToSource() {
  43. br := new(models.BaseResponse).Init()
  44. defer func() {
  45. this.Data["json"] = br
  46. this.ServeJSON()
  47. }()
  48. fileName := this.GetString("FileName")
  49. if fileName == "" {
  50. br.Msg = "文件名称不能为空"
  51. return
  52. }
  53. filePath := "/docs/" + fileName
  54. fmt.Println("filePath:" + filePath)
  55. services.InitMysteelChemicalIndex(filePath, false)
  56. br.Ret = 200
  57. br.Msg = "初始化成功"
  58. }
  59. // MySteelChemicalBase
  60. // @Title 初始化钢联化工数据-由数据源批量初始化到指标库
  61. // @Description 初始化钢联化工数据-由数据源批量初始化到指标库
  62. // @Param FileName query string true "文件名称"
  63. // @Success Ret=200
  64. // @router /mysteel_chemical/base [get]
  65. func (this *DataInitController) MySteelChemicalBase() {
  66. br := new(models.BaseResponse).Init()
  67. defer func() {
  68. this.Data["json"] = br
  69. this.ServeJSON()
  70. }()
  71. fileName := this.GetString("FileName")
  72. if fileName == "" {
  73. br.Msg = "文件名称不能为空"
  74. return
  75. }
  76. filePath := "/docs/" + fileName
  77. fmt.Println("filePath:" + filePath)
  78. services.InitBaseIndexDataFromMysteel(filePath)
  79. br.Ret = 200
  80. br.Msg = "初始化成功"
  81. }
  82. // SmmToDataSource
  83. // @Title 初始化有色指标到数据源
  84. // @Description 初始化有色指标到数据源
  85. // @Param FileName query string true "文件名称"
  86. // @Success Ret=200
  87. // @router /smm/to_data_source [get]
  88. func (this *DataInitController) SmmToDataSource() {
  89. br := new(models.BaseResponse).Init()
  90. defer func() {
  91. this.Data["json"] = br
  92. this.ServeJSON()
  93. }()
  94. fileName := this.GetString("FileName")
  95. if fileName == "" {
  96. br.Msg = "文件名称不能为空"
  97. return
  98. }
  99. filePath := "/docs/" + fileName
  100. fmt.Println("filePath:" + filePath)
  101. services.InitSmmIndexToDataSource(filePath)
  102. br.Ret = 200
  103. br.Msg = "初始化成功"
  104. }
  105. // SmmToIndexLib
  106. // @Title 初始化有色指标-由数据源批量初始化到指标库
  107. // @Description 初始化有色指标-由数据源批量初始化到指标库
  108. // @Param FileName query string true "文件名称"
  109. // @Success Ret=200
  110. // @router /smm/add/to_index_lib [get]
  111. func (this *DataInitController) SmmToIndexLib() {
  112. br := new(models.BaseResponse).Init()
  113. defer func() {
  114. this.Data["json"] = br
  115. this.ServeJSON()
  116. }()
  117. fileName := this.GetString("FileName")
  118. if fileName == "" {
  119. br.Msg = "文件名称不能为空"
  120. return
  121. }
  122. filePath := "/docs/" + fileName
  123. fmt.Println("filePath:" + filePath)
  124. services.InitBaseIndexDataFromDataSourceSmm(filePath)
  125. br.Ret = 200
  126. br.Msg = "初始化成功"
  127. }
  128. // BaseJiaYue
  129. // @Title 初始化嘉悦指标
  130. // @Description 初始化嘉悦指标
  131. // @Param FileName query string true "文件名称"
  132. // @Success Ret=200
  133. // @router /base_jiayue [get]
  134. func (this *DataInitController) BaseJiaYue() {
  135. br := new(models.BaseResponse).Init()
  136. defer func() {
  137. this.Data["json"] = br
  138. this.ServeJSON()
  139. }()
  140. fileName := this.GetString("FileName")
  141. if fileName == "" {
  142. br.Msg = "文件名称不能为空"
  143. return
  144. }
  145. filePath := "/docs/" + fileName
  146. fmt.Println("filePath:" + filePath)
  147. services.InitJiaYueIndexData(filePath)
  148. br.Ret = 200
  149. br.Msg = "初始化成功"
  150. }
  151. // AddToEdbInfo
  152. // @Title 初始化指标到指标库-(如果需要添加数据源的指标(钢联、有色),那么需要先执行到添加到数据源,再添加到指标库)
  153. // @Description 初始化指标到指标库-(如果需要添加数据源的指标(钢联、有色),那么需要先执行到添加到数据源,再添加到指标库)
  154. // @Param FileName query string true "文件名称"
  155. // @Success Ret=200
  156. // @router /base/edb_info/add [get]
  157. func (this *DataInitController) AddToEdbInfo() {
  158. br := new(models.BaseResponse).Init()
  159. defer func() {
  160. this.Data["json"] = br
  161. this.ServeJSON()
  162. }()
  163. fileName := this.GetString("FileName")
  164. if fileName == "" {
  165. br.Msg = "文件名称不能为空"
  166. return
  167. }
  168. filePath := "/docs/" + fileName
  169. fmt.Println("filePath:" + filePath)
  170. services.InitDataToEdbInfo(filePath)
  171. br.Ret = 200
  172. br.Msg = "初始化成功"
  173. }
  174. // InitPCSGBloomberg
  175. // @Title 批量导入中石油新加坡Bloomberg指标
  176. // @Description 批量导入中石油新加坡Bloomberg指标
  177. // @Param FileName query string true "文件名称"
  178. // @Success Ret=200
  179. // @router /pcsg/bloomberg [get]
  180. func (this *DataInitController) InitPCSGBloomberg() {
  181. br := new(models.BaseResponse).Init()
  182. defer func() {
  183. if br.ErrMsg == "" {
  184. br.IsSendEmail = false
  185. }
  186. this.Data["json"] = br
  187. this.ServeJSON()
  188. }()
  189. fileName := this.GetString("FileName")
  190. if fileName == "" {
  191. br.Msg = "文件名称不能为空"
  192. return
  193. }
  194. taskKey := this.GetString("TaskKey")
  195. if taskKey == "" {
  196. br.Msg = "TaskKey不可为空"
  197. return
  198. }
  199. fmt.Println("TaskKey: ", taskKey)
  200. filePath := "/docs/" + fileName
  201. fmt.Println("filePath:" + filePath)
  202. services.InitPCSGBloombergData(filePath, taskKey)
  203. br.Ret = 200
  204. br.Msg = "初始化成功"
  205. }
  206. // MySteelChemicalApiBase
  207. // @Title 钢联API-初始化至数据源
  208. // @Description 钢联API-初始化至数据源
  209. // @Param FileName query string true "文件名称"
  210. // @Success Ret=200
  211. // @router /mysteel_chemical/api_base [get]
  212. func (this *DataInitController) MySteelChemicalApiBase() {
  213. br := new(models.BaseResponse).Init()
  214. defer func() {
  215. this.Data["json"] = br
  216. this.ServeJSON()
  217. }()
  218. fileName := this.GetString("FileName")
  219. if fileName == "" {
  220. br.Msg = "文件名称不能为空"
  221. return
  222. }
  223. filePath := "/docs/" + fileName
  224. fmt.Println("filePath:" + filePath)
  225. services.InitMysteelChemicalIndex(filePath, true)
  226. br.Ret = 200
  227. br.Msg = "初始化成功"
  228. }