Browse Source

Merge branch 'feature/edb_update_check' of eta_server/eta_index_lib into master

xyxie 1 year ago
parent
commit
d8da3398e8
3 changed files with 97 additions and 0 deletions
  1. 75 0
      controllers/edb_info.go
  2. 13 0
      models/edb_info.go
  3. 9 0
      routers/commentsRouter.go

+ 75 - 0
controllers/edb_info.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/utils"
 	"eta/eta_index_lib/utils"
 	"strconv"
 	"strconv"
+	"strings"
 	"time"
 	"time"
 )
 )
 
 
@@ -253,3 +254,77 @@ func (this *EdbInfoController) CopyFromHz() {
 	br.Msg = "新增成功"
 	br.Msg = "新增成功"
 	br.Data = edbInfo
 	br.Data = edbInfo
 }
 }
+
+// RefreshCheck @Title 指标数据更新检查
+// @Description 指标数据更新检查
+// @Param	request	body models.EdbInfoRefreshCheckReq true "type json string"
+// @Success 200 {object} models.EdbInfo
+// @router /refresh_check [post]
+func (this *EdbInfoController) RefreshCheck() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var req models.EdbInfoRefreshCheckReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Source == 0 {
+		br.Msg = "请输入指标来源"
+		return
+	}
+	if req.LatestDate == "" {
+		br.Msg = "请输入查询日期"
+		return
+	}
+
+	_, err = time.Parse(utils.FormatDate, req.LatestDate)
+	if err != nil {
+		br.Msg = "查询日期格式错误"
+		return
+	}
+
+	condition := ` and source=? and no_update=0 `
+	pars := make([]interface{}, 0)
+	pars = append(pars, req.Source)
+
+	if req.FrequencyBatch != "" {
+		frequency := strings.Split(req.FrequencyBatch, ",")
+		condition += ` and frequency in (` + utils.GetOrmInReplace(len(frequency)) + `)`
+		for _, v := range frequency {
+			pars = append(pars, v)
+		}
+	}
+	updateCondition := condition + ` and latest_date = ?`
+	pars = append(pars, req.LatestDate)
+
+	unUpdateCondition := condition + ` and latest_date != ?`
+
+	updateNum, err := models.GetEdbInfoCountByCondition(updateCondition, pars)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	unUpdateNum, err := models.GetEdbInfoCountByCondition(unUpdateCondition, pars)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	resp := models.EdbInfoRefreshCheckResp{
+		UpdateNum:   updateNum,
+		UnUpdateNum: unUpdateNum,
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 13 - 0
models/edb_info.go

@@ -1095,3 +1095,16 @@ func EdbInfoAdd(req *AddEdbInfoParams, serverUrl string, sysUserId int, sysUserR
 	edbInfo.EdbInfoId = int(edbInfoId)
 	edbInfo.EdbInfoId = int(edbInfoId)
 	return
 	return
 }
 }
+
+// EdbInfoRefreshCheckReq 指标数据更新情况查询
+type EdbInfoRefreshCheckReq struct {
+	Source         int    `description:"来源id"`
+	LatestDate     string `description:"数据最新日期"`
+	FrequencyBatch string `description:"更新频度"`
+}
+
+// EdbInfoRefreshCheckResp 指标数据更新情况查询
+type EdbInfoRefreshCheckResp struct {
+	UpdateNum   int `description:"已更新指标数"`
+	UnUpdateNum int `description:"未更新指标数"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -250,6 +250,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EdbInfoController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EdbInfoController"],
+        beego.ControllerComments{
+            Method: "RefreshCheck",
+            Router: `/refresh_check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EiaSteoController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EiaSteoController"],
     beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EiaSteoController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EiaSteoController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "Add",
             Method: "Add",