Browse Source

Merge branch 'feature/eta1.5.2_mysteel_stat' into debug

xyxie 1 year ago
parent
commit
c583e21f9c

+ 8 - 1
controllers/data_manage/edb_info.go

@@ -2183,6 +2183,11 @@ func (this *EdbInfoController) EdbInfoAdd() {
 
 	//新增操作日志
 	{
+		// 添加钢联指标更新日志
+		if edbInfo.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
+			go data_stat.AddEdbInfoUpdateLog(edbInfo.EdbInfoId, 1, "", sysUser, 2)
+		}
+
 		edbLog := new(data_manage.EdbInfoLog)
 		edbLog.EdbInfoId = edbInfo.EdbInfoId
 		edbLog.SourceName = edbInfo.SourceName
@@ -2362,7 +2367,9 @@ func (this *EdbInfoController) EdbInfoEdit() {
 
 	// 添加钢联指标更新日志
 	if edbInfo.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
-		go data_stat.AddEdbInfoUpdateLog(req.EdbInfoId, 1, "", sysUser)
+		if edbInfo.EdbName != req.EdbName || edbInfo.Frequency != edbInfo.Frequency || edbInfo.Unit != req.Unit {
+			go data_stat.AddEdbInfoUpdateLog(req.EdbInfoId, 1, "", sysUser, 1)
+		}
 	}
 
 	br.Ret = 200

+ 30 - 5
controllers/data_stat/edb_source_stat.go

@@ -317,6 +317,7 @@ func (this *EdbSourceStatController) EdbUpdateLog() {
 	sortParamReq := this.GetString("SortParam", "")
 	sortType := this.GetString("SortType", "desc")
 	createTime := this.GetString("CreateTime", "")
+	updateType, _ := this.GetInt("UpdateType", -1)
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -345,7 +346,10 @@ func (this *EdbSourceStatController) EdbUpdateLog() {
 		condition += " AND create_time >= ? AND create_time < ?"
 		pars = append(pars, createTime, endT.Format(utils.FormatDate))
 	}
-
+	if updateType >= 0 {
+		condition += " AND update_type =? "
+		pars = append(pars, updateType)
+	}
 	sortStr := ``
 	sortParam := ``
 	if sortParamReq != `` {
@@ -557,7 +561,7 @@ func (this *EdbSourceStatController) EdbUpdateStat() {
 			err = nil
 		}
 	}
-	list := make([]*data_stat.EdbInfoUpdateStatItem, 0)
+	list := make([]*data_stat.EdbInfoUpdateStatItemMore, 0)
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	if total == 0 {
 		resp := data_stat.GetEdbUpdateStatResp{
@@ -577,8 +581,28 @@ func (this *EdbSourceStatController) EdbUpdateStat() {
 		return
 	}
 
+	// 获取初始数据源名称
+	var edbCodeList []string
+	for _, v := range tmpList {
+		edbCodeList = append(edbCodeList, v.EdbCode)
+	}
+	initSourceMap := make(map[string]string)
+	if len(edbCodeList) > 0 {
+		baseCond := " and index_code in (" + utils.GetOrmInReplace(len(edbCodeList)) + ")"
+		var basePars []interface{}
+		basePars = append(basePars, edbCodeList)
+		indexList, tErr := data_manage.GetMysteelChemicalIndexList(baseCond, basePars, 0, 1000)
+		if tErr != nil {
+			br.Msg = "获取初始指标信息失败"
+			br.ErrMsg = "获取初始指标信息失败,Err:" + tErr.Error()
+			return
+		}
+		for _, v := range indexList {
+			initSourceMap[v.IndexCode] = v.Source
+		}
+	}
 	for _, v := range tmpList {
-		tmp := new(data_stat.EdbInfoUpdateStatItem)
+		tmp := new(data_stat.EdbInfoUpdateStatItemMore)
 		tmp.Id = v.Id
 		tmp.EdbInfoId = v.EdbInfoId
 		tmp.SourceName = v.SourceName
@@ -608,6 +632,7 @@ func (this *EdbSourceStatController) EdbUpdateStat() {
 		tmp.IsAdd = v.IsAdd
 		tmp.NeedRefresh = v.NeedRefresh
 		tmp.HasRefresh = v.HasRefresh
+		tmp.InitSourceName, _ = initSourceMap[v.EdbCode]
 		list = append(list, tmp)
 	}
 
@@ -916,7 +941,7 @@ func (this *EdbSourceStatController) EdbUpdateFailedDetailList() {
 			err = nil
 		}
 	}
-	list := make([]*data_stat.EdbInfoUpdateStatItem, 0)
+	list := make([]*data_stat.EdbInfoUpdateStatItemMore, 0)
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	if total == 0 {
 		resp := data_stat.GetEdbUpdateStatResp{
@@ -937,7 +962,7 @@ func (this *EdbSourceStatController) EdbUpdateFailedDetailList() {
 	}
 
 	for _, v := range tmpList {
-		tmp := new(data_stat.EdbInfoUpdateStatItem)
+		tmp := new(data_stat.EdbInfoUpdateStatItemMore)
 		tmp.Id = v.Id
 		tmp.EdbInfoId = v.EdbInfoId
 		tmp.SourceName = v.SourceName

+ 2 - 0
models/data_stat/edb_info_update_log.go

@@ -37,6 +37,7 @@ type EdbInfoUpdateLog struct {
 	DataUpdateFailedReason string    `description:"数据未正常更新原因"`
 	DataUpdateTime         string    `description:"数据更新时间"`
 	IsSourceRefresh        int       `description:"是否为终端刷新到数据源的刷新操作:0否,1是"`
+	UpdateType             int       `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
 }
 
 type EdbInfoUpdateLogItem struct {
@@ -62,6 +63,7 @@ type EdbInfoUpdateLogItem struct {
 	TerminalCode          string  `description:"终端编码,用于配置在机器上"`
 	DataUpdateTime        string  `description:"最近一次数据发生变化的时间"`
 	ErDataUpdateDate      string  `description:"本次更新,数据发生变化的最早日期"`
+	UpdateType            int     `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
 }
 
 func AddEdbUpdateLog(item *EdbInfoUpdateLog) (lastId int64, err error) {

+ 6 - 1
models/data_stat/edb_info_update_stat.go

@@ -70,8 +70,13 @@ type EdbInfoUpdateStatItem struct {
 	HasRefresh             int8    `description:"今日是否已刷新,1是,0否"`
 }
 
+type EdbInfoUpdateStatItemMore struct {
+	EdbInfoUpdateStatItem
+	InitSourceName string `description:"初始数据源"`
+}
+
 type GetEdbUpdateStatResp struct {
-	List   []*EdbInfoUpdateStatItem
+	List   []*EdbInfoUpdateStatItemMore
 	Paging *paging.PagingItem
 }
 

+ 2 - 1
services/data_stat/edb_info_stat.go

@@ -9,7 +9,7 @@ import (
 )
 
 // AddEdbInfoUpdateLog 添加指标编辑/刷新日志
-func AddEdbInfoUpdateLog(edbInfoId int, updateResult int, updateFailedReason string, sysUser *system.Admin) (err error) {
+func AddEdbInfoUpdateLog(edbInfoId int, updateResult int, updateFailedReason string, sysUser *system.Admin, updateType int) (err error) {
 	var edbInfo *data_manage.EdbInfo
 	if edbInfoId > 0 {
 		// 获取指标详情
@@ -45,6 +45,7 @@ func AddEdbInfoUpdateLog(edbInfoId int, updateResult int, updateFailedReason str
 		log.UpdateFailedReason = updateFailedReason
 		log.DataUpdateTime = edbInfo.DataUpdateTime
 		log.ErDataUpdateDate = edbInfo.ErDataUpdateDate
+		log.UpdateType = updateType
 		_, err = data_stat.AddEdbUpdateLog(log)
 		if err != nil {
 			err = fmt.Errorf("新增指标更新日志失败,Err: %s", err)