浏览代码

Merge branch 'feature/eta1.2.2_edb_source' into debug

# Conflicts:
#	routers/router.go
xyxie 1 年之前
父节点
当前提交
164922814c
共有 5 个文件被更改,包括 62 次插入18 次删除
  1. 30 0
      controllers/edb_info_stat.go
  2. 9 0
      routers/commentsRouter.go
  3. 5 0
      routers/router.go
  4. 4 17
      services/base_from_mysteel_chemical.go
  5. 14 1
      services/edb_info_stat.go

+ 30 - 0
controllers/edb_info_stat.go

@@ -0,0 +1,30 @@
+package controllers
+
+import (
+	"eta/eta_index_lib/models"
+	"eta/eta_index_lib/services"
+)
+
+type EdbInfoStatController struct {
+	BaseAuthController
+}
+
+// SetEdbSourceStat
+// @Title 指标终端更新情况定时汇总
+// @Description 指标终端情况定时汇总
+// @Success 200 {object}
+// @router /source_update [post]
+func (this *EdbInfoStatController) SetEdbSourceStat() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	// 钢联终端统计汇总
+	_ = services.SetMysteelChemicalEdbInfoUpdateStat()
+	_ = services.SetEdbSourceStat()
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 9 - 0
routers/commentsRouter.go

@@ -295,6 +295,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EdbInfoStatController"] = append(beego.GlobalControllerRouter["eta/eta_index_lib/controllers:EdbInfoStatController"],
+        beego.ControllerComments{
+            Method: "SetEdbSourceStat",
+            Router: `/source_update`,
+            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.ControllerComments{
             Method: "Add",

+ 5 - 0
routers/router.go

@@ -212,6 +212,11 @@ func init() {
 				&controllers.JiaYueController{},
 			),
 		),
+		beego.NSNamespace("/edb_stat",
+			beego.NSInclude(
+				&controllers.EdbInfoStatController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 4 - 17
services/base_from_mysteel_chemical.go

@@ -20,24 +20,11 @@ func HandleMysteelIndex(req *models.HandleMysteelIndexResp) (err error) {
 			return
 		}
 	}
-	go func() {
-		var lErr error
-		defer func() {
-			if lErr != nil {
-				tips := fmt.Sprintf("钢联数据刷新-ETA指标刷新统计异常 Err: %s", lErr.Error())
-				alarm_msg.SendAlarmMsg(tips, 3)
-			}
-		}()
 
-		lErr = SetMysteelChemicalEdbInfoUpdateStat()
-		if lErr != nil {
-			return
-		}
-		lErr = SetEdbSourceStat()
-
-		if lErr != nil {
-			return
-		}
+	go func() {
+		// 钢联终端统计汇总
+		_ = SetMysteelChemicalEdbInfoUpdateStat()
+		_ = SetEdbSourceStat()
 	}()
 	return
 }

+ 14 - 1
services/edb_info_stat.go

@@ -3,6 +3,7 @@ package services
 import (
 	"eta/eta_index_lib/models"
 	"eta/eta_index_lib/models/data_stat"
+	"eta/eta_index_lib/services/alarm_msg"
 	"eta/eta_index_lib/utils"
 	"fmt"
 	"time"
@@ -56,8 +57,14 @@ func AddEdbInfoUpdateLog(edbInfoId int, updateResult int, updateFailedReason str
 
 // SetMysteelChemicalEdbInfoUpdateStat 定时统计钢联化工的数据源明细表
 func SetMysteelChemicalEdbInfoUpdateStat() (err error) {
+	defer func() {
+		if err != nil {
+			tips := fmt.Sprintf("钢联数据刷新-ETA指标刷新统计异常 Err: %s", err.Error())
+			alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
 	//查询钢联的所有指标信息
-	condition := " and source = ? and edb_info_id=101838"
+	condition := " and source = ? "
 	var pars []interface{}
 	pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL)
 	edbList, err := models.GetEdbInfoByCondition(condition, pars, 0)
@@ -206,6 +213,12 @@ func checkMySteelEdbInfoNeedRefresh(frequency string) (needRefresh int, err erro
 
 // SetEdbSourceStat 定时统计数据源汇总表
 func SetEdbSourceStat() (err error) {
+	defer func() {
+		if err != nil {
+			tips := fmt.Sprintf("钢联数据刷新-ETA指标刷新统计异常 Err: %s", err.Error())
+			alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
 	//查询钢联的所有指标信息
 	nowTime := time.Now()
 	today := time.Now().Format(utils.FormatDate)