浏览代码

Merge remote-tracking branch 'origin/eta/1.5.1' into debug

# Conflicts:
#	models/db.go
Roc 1 年之前
父节点
当前提交
bfb7b307a7

+ 48 - 0
controllers/data_manage/edb_info_refresh.go

@@ -424,8 +424,56 @@ func (c *EdbInfoController) RefreshEdbList() {
 		List:   list,
 	}
 
+	// todo 数据源中的最新值
+	// todo 刷新时间
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// GetEdbRefreshDefaultConfig
+// @Title 获取待配置的指标列表接口
+// @Description 获取待配置的指标列表接口
+// @Param   Source   query   int  true       "来源:1:同花顺,2:wind,3:彭博"
+// @Param   SubSource   query   int  true       "来源:0:经济数据库,1:日期序列"
+// @Param   Frequency   query   string  false       "频度"
+// @Success 200 {object} data_manage.RefreshBaseEdbInfoResp
+// @router /edb_info/refresh/default_config [get]
+func (c *EdbInfoController) GetEdbRefreshDefaultConfig() {
+	br := new(models.BaseResponse).Init()
+
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	source, _ := c.GetInt("Source")
+	subSource, _ := c.GetInt("SubSource")
+	frequency := c.GetString("Frequency")
+
+	if source <= 0 {
+		br.Msg = "来源不能为空"
+		br.IsSendEmail = false
+		return
+	}
+
+	if frequency == `` {
+		br.Msg = "频度不能为空"
+		br.IsSendEmail = false
+		return
+	}
+
+	list, err := data_manage.GetListBySourceAndFrequency(source, subSource, frequency)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = list
+}

+ 1 - 1
models/data_manage/edb_info.go

@@ -1750,7 +1750,7 @@ func GetEdbBaseInfo(condition string, pars []interface{}, startSize, pageSize in
 	}
 
 	// 列表数据
-	sql := ` SELECT edb_info_id as edb_info_id, classify_id as classify_id,edb_code as index_code,edb_name as index_name,end_date,sys_user_id,sys_user_real_name,frequency,no_update as is_stop,terminal_code FROM edb_info WHERE 1=1  `
+	sql := ` SELECT edb_info_id as edb_info_id, classify_id as classify_id,edb_code as index_code,edb_name as index_name,end_date,end_value,sys_user_id,sys_user_real_name,frequency,no_update as is_stop,terminal_code FROM edb_info WHERE 1=1  `
 	if condition != "" {
 		sql += condition
 	}

+ 75 - 0
models/data_manage/edb_refresh_default_config.go

@@ -0,0 +1,75 @@
+package data_manage
+
+import (
+	"errors"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// EdbRefreshDefaultConfig
+// @Description: 指标的默认刷新时间配置表
+type EdbRefreshDefaultConfig struct {
+	Id                  int       `orm:"column(id);pk"`
+	Source              int       `description:"来源"`
+	SubSource           int       `description:"来源名称"`
+	Frequency           string    `description:"频度"`
+	RefreshFrequency    string    `description:"刷新频率"`
+	RefreshFrequencyNum int       `description:"具体刷新的日期"`
+	RefreshTime         string    `description:"刷新时间"`
+	RefreshDataNum      int       `description:"刷新单元格数"`
+	ModifyTime          time.Time `description:"最晚一次的更新时间"`
+	CreateTime          time.Time `description:"添加时间"`
+}
+
+// Add
+// @Description: 添加
+// @author: Roc
+// @receiver m
+// @datetime 2023-12-14 16:11:10
+// @param cols []string
+// @return err error
+func (m *EdbRefreshDefaultConfig) Add() (err error) {
+	if m.Id > 0 {
+		err = errors.New("该配置已存在")
+		return
+	}
+	o := orm.NewOrmUsingDB("data")
+	lastId, err := o.Insert(m)
+	if err != nil {
+		return
+	}
+	m.Id = int(lastId)
+
+	return
+}
+
+// Update
+// @Description: 更新
+// @author: Roc
+// @receiver m
+// @datetime 2023-12-14 16:11:10
+// @param cols []string
+// @return err error
+func (m *EdbRefreshDefaultConfig) Update(cols []string) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Update(m, cols...)
+	return
+}
+
+// GetListBySourceAndFrequency
+// @Description: 根据来源和频度获取列表
+// @author: Roc
+// @datetime 2024-01-04 17:39:47
+// @param source int
+// @param subSource int
+// @param frequency string
+// @return list []*EdbRefreshDefaultConfig
+// @return err error
+func GetListBySourceAndFrequency(source, subSource int, frequency string) (list []*EdbRefreshDefaultConfig, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := `SELECT * FROM edb_refresh_default_config
+         WHERE source = ? AND sub_source = ? AND frequency = ? ORDER BY id ASC `
+	_, err = o.Raw(sql, source, subSource, frequency).QueryRows(&list)
+
+	return
+}

+ 1 - 1
models/data_manage/edb_refresh_source.go

@@ -6,7 +6,7 @@ import (
 )
 
 // EdbRefreshSource
-// @Description: 获取刷新的数据源
+// @Description: 刷新的数据源
 type EdbRefreshSource struct {
 	Id            int       `orm:"column(id);pk"`
 	Source        int       `orm:"column(source)" description:"来源"`

+ 11 - 0
models/db.go

@@ -182,6 +182,9 @@ func init() {
 	// 报告审批
 	initReportApprove()
 
+	// 初始化指标刷新
+	initEdbRefresh()
+
 	// 初始化部分数据表变量(直接init会有顺序问题=_=!)
 	data_manage.InitEdbSourceVar()
 }
@@ -535,3 +538,11 @@ func initChartTheme() {
 		new(chart_theme.ChartThemeDefaultData), //默认数据
 	)
 }
+
+// initEdbRefresh 初始化指标刷新
+func initEdbRefresh() {
+	orm.RegisterModel(
+		new(data_manage.EdbRefreshSource),        // 刷新的数据源表
+		new(data_manage.EdbRefreshDefaultConfig), // 指标的默认刷新时间配置表
+	)
+}

+ 9 - 0
routers/commentsRouter.go

@@ -2959,6 +2959,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"],
+        beego.ControllerComments{
+            Method: "GetEdbRefreshDefaultConfig",
+            Router: `/edb_info/refresh/default_config`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"],
         beego.ControllerComments{
             Method: "RefreshEdbList",