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 = "初始化成功" }