浏览代码

Merge branch 'chart/13.8' into debug

Roc 2 年之前
父节点
当前提交
4070a4123e
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 9 0
      controllers/base_from_calculate.go
  2. 13 0
      models/base_from_manual.go

+ 9 - 0
controllers/base_from_calculate.go

@@ -1584,6 +1584,15 @@ func (this *CalculateController) Refresh() {
 			errMsg = "RefreshAllCalculateKszs Err:" + err.Error()
 			break
 		}
+	case utils.DATA_SOURCE_STOCK_PLANT: //存量装置
+		//startDate = edbInfo.StartDate
+		endDate = time.Now().Format(utils.FormatDate)
+		req.StartDate = `` // 开始日期也给过滤吧,万一研究员补充了之前的数据呢,还是过滤掉吧
+		err = models.RefreshEdbDataFromStockPlant(req.EdbInfoId, req.EdbCode, req.StartDate)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			errMsg = "RefreshEdbDataFromStockPlant Err:" + err.Error()
+			break
+		}
 	case utils.DATA_SOURCE_CALCULATE_CORRELATION:
 		err, errMsg = models.RefreshAllCalculateCorrelation(edbInfo)
 	default:

+ 13 - 0
models/base_from_manual.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/shopspring/decimal"
 	"hongze/hongze_edb_lib/utils"
 	"strconv"
 	"strings"
@@ -54,6 +55,13 @@ func AddEdbDataFromManual(edbCode string) (err error) {
 			item := manualDataList[i]
 			eDate := item.Dt
 			sValue := item.Close
+			tmpDecimal, err := decimal.NewFromString(sValue)
+			if err != nil {
+				return err
+			}
+			sValue = tmpDecimal.Round(4).String()
+
+
 			dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
 			if err != nil {
 				return err
@@ -147,6 +155,11 @@ func RefreshEdbDataFromManual(edbInfoId int, edbCode, startDate string) (err err
 		item := v
 		eDate := item.Dt
 		sValue := item.Close
+		tmpDecimal, err := decimal.NewFromString(sValue)
+		if err != nil {
+			return err
+		}
+		sValue = tmpDecimal.Round(4).String()
 
 		dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
 		if err != nil {