Эх сурвалжийг харах

fix: 增加int64类型的adjust支持

gaoyagang 1 жил өмнө
parent
commit
cce8e77047

+ 4 - 1
envitem/func.go

@@ -221,7 +221,10 @@ func (e *EnvItem) getCurrentData() (*ItemValueResp, error) {
 		}
 
 		if adjustValue && cache != nil && len(res.Data) > 0 {
-			if rv, err := strconv.ParseFloat(res.Data[0].Val, 64); err == nil {
+			if rv, err := strconv.ParseInt(res.Data[0].Val, 10, 64); err == nil {
+				adjust, _ := e.GetAdjustInt64Val()
+				res.Data[0].Val = fmt.Sprintf("%d", rv+adjust)
+			} else if rv, err := strconv.ParseFloat(res.Data[0].Val, 64); err == nil {
 				adjust, _ := e.GetAdjustFloat64Val()
 				res.Data[0].Val = fmt.Sprintf("%f", rv+adjust)
 			}

+ 2 - 2
envitem/func_test.go

@@ -124,10 +124,10 @@ func TestEnvItem_GetValueForAdjust(t *testing.T) {
 	SetOptions(Options{GtServerIp: "47.96.12.136:8788", Cache: cache, AdjustValue: false})
 	e := EnvItem{
 		ProjectId: 92,
-		Item:      "C.M.LT_QSC@out",
+		Item:      "C.M.UF1_DB@word_control",
 	}
 
-	v := e.GetItemFloat64Val()
+	v := e.GetItemInt64Val()
 
 	t.Log(v)
 }