Browse Source

Merge branch 'bzq1/fix_conflict_lib_record' of eta_server/eta_index_lib into debug

鲍自强 11 months ago
parent
commit
bef6a14d17
4 changed files with 29 additions and 16 deletions
  1. 2 1
      .gitignore
  2. 20 12
      controllers/base_from_predict_calculate.go
  3. 2 0
      models/base_from_calculate.go
  4. 5 3
      models/edb_info.go

+ 2 - 1
.gitignore

@@ -12,4 +12,5 @@ eta_index_lib
 /static/imgs/python/*
 /etalogs
 *.gz
-*.exe
+*.exe
+/.vscode/

+ 20 - 12
controllers/base_from_predict_calculate.go

@@ -899,18 +899,26 @@ func (this *PredictCalculateController) CalculateBatchSave() {
 		return
 	}
 
-	// 记录操作变更记录
-	newEdbInfo := new(models.EdbInfoEditRecord)
-	newEdbInfo.EdbName = req.EdbName
-	newEdbInfo.Frequency = req.Frequency
-	newEdbInfo.Unit = req.Unit
-	newEdbInfo.OperateUserId = req.AdminId
-	newEdbInfo.OperateUserRealName = req.AdminName
-	err = services.AddEditEdbInfoRcord(oldEdbInfo, newEdbInfo)
-	if err != nil {
-		br.Msg = "保存失败"
-		br.ErrMsg = "保存失败,Err:" + err.Error()
-		return
+	if req.EdbInfoId > 0 {
+		oldEdbInfo, err := models.GetEdbInfoById(req.EdbInfoId)
+		if err != nil {
+			br.Msg = "获取指标信息失败"
+			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
+			return
+		}
+		// 记录操作变更记录
+		newEdbInfo := new(models.EdbInfoEditRecord)
+		newEdbInfo.EdbName = req.EdbName
+		newEdbInfo.Frequency = req.Frequency
+		newEdbInfo.Unit = req.Unit
+		newEdbInfo.OperateUserId = req.AdminId
+		newEdbInfo.OperateUserRealName = req.AdminName
+		err = services.AddEditEdbInfoRcord(oldEdbInfo, newEdbInfo)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
 	}
 
 	resp := models.AddEdbInfoResp{

+ 2 - 0
models/base_from_calculate.go

@@ -685,6 +685,8 @@ type EdbInfoCalculateBatchEditReq struct {
 	Unit             string                         `description:"单位"`
 	UnitEn           string                         `description:"英文单位"`
 	ClassifyId       int                            `description:"分类id"`
+	AdminId          int                            `description:"操作人id"`
+	AdminName        string                         `description:"操作人姓名"`
 	Formula          string                         `description:"N值"`
 	EdbInfoId        int                            `description:"编辑指标id"`
 	FromEdbInfoId    int                            `description:"计算来源指标id"`

+ 5 - 3
models/edb_info.go

@@ -6,11 +6,13 @@ import (
 	"eta/eta_index_lib/models/mgo"
 	"eta/eta_index_lib/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
-	"github.com/shopspring/decimal"
-	"go.mongodb.org/mongo-driver/bson"
 	"strconv"
 	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
+
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/shopspring/decimal"
 )
 
 type EdbInfo struct {