123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- package controllers
- import (
- "eta/eta_data_init/models"
- "eta/eta_data_init/services"
- "fmt"
- beego "github.com/beego/beego/v2/server/web"
- )
- // DataInitController
- // Operations about Users
- type DataInitController struct {
- beego.Controller
- }
- // Base
- // @Title 初始化基础指标数据-不包含钢联化工的基础指标初始化
- // @Description 初始化基础指标数据-不包含钢联化工的基础指标初始化
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /base [get]
- func (this *DataInitController) Base() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitBaseIndexData(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // MySteelChemicalToSource
- // @Title 初始化联化工指标(添加到数据源)
- // @Description 初始化联化工指标(添加到数据源)
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /mysteel_chemical [get]
- func (this *DataInitController) MySteelChemicalToSource() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitMysteelChemicalIndex(filePath, false)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // MySteelChemicalBase
- // @Title 初始化钢联化工数据-由数据源批量初始化到指标库
- // @Description 初始化钢联化工数据-由数据源批量初始化到指标库
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /mysteel_chemical/base [get]
- func (this *DataInitController) MySteelChemicalBase() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitBaseIndexDataFromMysteel(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // SmmToDataSource
- // @Title 初始化有色指标到数据源
- // @Description 初始化有色指标到数据源
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /smm/to_data_source [get]
- func (this *DataInitController) SmmToDataSource() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitSmmIndexToDataSource(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // SmmToIndexLib
- // @Title 初始化有色指标-由数据源批量初始化到指标库
- // @Description 初始化有色指标-由数据源批量初始化到指标库
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /smm/add/to_index_lib [get]
- func (this *DataInitController) SmmToIndexLib() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitBaseIndexDataFromDataSourceSmm(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // BaseJiaYue
- // @Title 初始化嘉悦指标
- // @Description 初始化嘉悦指标
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /base_jiayue [get]
- func (this *DataInitController) BaseJiaYue() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitJiaYueIndexData(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // AddToEdbInfo
- // @Title 初始化指标到指标库-(如果需要添加数据源的指标(钢联、有色),那么需要先执行到添加到数据源,再添加到指标库)
- // @Description 初始化指标到指标库-(如果需要添加数据源的指标(钢联、有色),那么需要先执行到添加到数据源,再添加到指标库)
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /base/edb_info/add [get]
- func (this *DataInitController) AddToEdbInfo() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitDataToEdbInfo(filePath)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // InitPCSGBloomberg
- // @Title 批量导入中石油新加坡Bloomberg指标
- // @Description 批量导入中石油新加坡Bloomberg指标
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /pcsg/bloomberg [get]
- func (this *DataInitController) InitPCSGBloomberg() {
- br := new(models.BaseResponse).Init()
- defer func() {
- if br.ErrMsg == "" {
- br.IsSendEmail = false
- }
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- taskKey := this.GetString("TaskKey")
- if taskKey == "" {
- br.Msg = "TaskKey不可为空"
- return
- }
- fmt.Println("TaskKey: ", taskKey)
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitPCSGBloombergData(filePath, taskKey)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
- // MySteelChemicalApiBase
- // @Title 钢联API-初始化至数据源
- // @Description 钢联API-初始化至数据源
- // @Param FileName query string true "文件名称"
- // @Success Ret=200
- // @router /mysteel_chemical/api_base [get]
- func (this *DataInitController) MySteelChemicalApiBase() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- fileName := this.GetString("FileName")
- if fileName == "" {
- br.Msg = "文件名称不能为空"
- return
- }
- filePath := "/docs/" + fileName
- fmt.Println("filePath:" + filePath)
- services.InitMysteelChemicalIndex(filePath, true)
- br.Ret = 200
- br.Msg = "初始化成功"
- }
|