Browse Source

fix:新增/编辑预测指标的时候,支持用户写入最大最小值

Roc 1 year ago
parent
commit
31b1900890
3 changed files with 11 additions and 7 deletions
  1. 2 2
      controllers/base_from_predict.go
  2. 7 5
      logic/predict_edb.go
  3. 2 0
      models/predict_edb_conf.go

+ 2 - 2
controllers/base_from_predict.go

@@ -58,7 +58,7 @@ func addPredict(br *models.BaseResponse, req models.AddPredictEdbInfoReq) {
 	}
 
 	// 添加指标
-	edbInfo, err, errMsg := logic.AddPredictEdbInfo(req.SourceEdbInfoId, req.ClassifyId, req.EdbName, req.RuleList, req.AdminId, req.AdminName)
+	edbInfo, err, errMsg := logic.AddPredictEdbInfo(req.SourceEdbInfoId, req.ClassifyId, req.EdbName, req.RuleList, req.MinValue, req.MaxValue, req.AdminId, req.AdminName)
 	if err != nil {
 		br.Msg = "保存失败"
 		if errMsg != `` {
@@ -96,7 +96,7 @@ func editPredict(br *models.BaseResponse, req models.AddPredictEdbInfoReq) {
 	}
 
 	// 编辑指标
-	edbInfo, err, errMsg := logic.EditPredictEdbInfo(req.EdbInfoId, req.ClassifyId, req.EdbName, req.RuleList)
+	edbInfo, err, errMsg := logic.EditPredictEdbInfo(req.EdbInfoId, req.ClassifyId, req.EdbName, req.RuleList, req.MinValue, req.MaxValue)
 	if err != nil {
 		br.Msg = "保存失败"
 		if errMsg != `` {

+ 7 - 5
logic/predict_edb.go

@@ -11,7 +11,7 @@ import (
 )
 
 // AddPredictEdbInfo 新增预测指标
-func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName string, ruleList []models.RuleConfig, sysUserId int, sysUserName string) (edbInfo *models.EdbInfo, err error, errMsg string) {
+func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName string, ruleList []models.RuleConfig, minValue, maxValue float64, sysUserId int, sysUserName string) (edbInfo *models.EdbInfo, err error, errMsg string) {
 	var sourceEdbInfo *models.EdbInfo
 	// 来源指标信息校验
 	{
@@ -104,8 +104,8 @@ func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName string, ruleList
 		UniqueCode:       utils.MD5(utils.DATA_PREFIX + "_" + timestamp),
 		CreateTime:       time.Now(),
 		ModifyTime:       time.Now(),
-		MinValue:         sourceEdbInfo.MinValue,
-		MaxValue:         sourceEdbInfo.MaxValue,
+		MinValue:         minValue,
+		MaxValue:         maxValue,
 		CalculateFormula: sourceEdbInfo.CalculateFormula,
 		EdbType:          1,
 		//Sort:             sourceEdbInfo.,
@@ -382,7 +382,7 @@ func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName string, ruleList
 }
 
 // EditPredictEdbInfo 编辑预测指标
-func EditPredictEdbInfo(edbInfoId, classifyId int, edbName string, ruleList []models.RuleConfig) (edbInfo *models.EdbInfo, err error, errMsg string) {
+func EditPredictEdbInfo(edbInfoId, classifyId int, edbName string, ruleList []models.RuleConfig, minValue, maxValue float64) (edbInfo *models.EdbInfo, err error, errMsg string) {
 	// 指标信息校验
 	{
 		edbInfo, err = models.GetEdbInfoById(edbInfoId)
@@ -451,8 +451,10 @@ func EditPredictEdbInfo(edbInfoId, classifyId int, edbName string, ruleList []mo
 	edbInfo.EdbName = edbName
 	edbInfo.EdbNameSource = edbName
 	edbInfo.ClassifyId = classifyId
+	edbInfo.MinValue = minValue
+	edbInfo.MaxValue = maxValue
 	edbInfo.ModifyTime = time.Now()
-	updateEdbInfoCol := []string{"EdbName", "EdbNameSource", "ClassifyId", "EndDate", "ModifyTime"}
+	updateEdbInfoCol := []string{"EdbName", "EdbNameSource", "ClassifyId", "EndDate", "MinValue", "MaxValue", "ModifyTime"}
 
 	var sourceEdbInfo *models.EdbInfo
 	// 来源指标信息校验

+ 2 - 0
models/predict_edb_conf.go

@@ -16,6 +16,8 @@ type AddPredictEdbInfoReq struct {
 	SourceEdbInfoId int          `description:"来源指标id"`
 	EdbName         string       `description:"指标名称"`
 	RuleList        []RuleConfig `description:"配置规则列表"`
+	MaxValue        float64      `description:"最大值"`
+	MinValue        float64      `description:"最小值"`
 }
 
 // RuleConfig 预测规则配置