Browse Source

修改计算精度

hongze 3 years ago
parent
commit
fdb114d768
1 changed files with 6 additions and 3 deletions
  1. 6 3
      models/data_manage/edb_info_calculate_nszydpjjs.go

+ 6 - 3
models/data_manage/edb_info_calculate_nszydpjjs.go

@@ -110,11 +110,14 @@ func RefreshCalculateNszydpjjs(edbInfoId, source, formulaInt int, fromEdbInfo *E
 				}
 			}
 			valArrLen := len(valArr)
-			var totalVal float64
+			totalVal := decimal.NewFromFloat(0.00)
 			for _, v := range valArr {
-				totalVal = totalVal + v
+				//totalVal = totalVal + v
+				newDecimal := decimal.NewFromFloat(v)
+				totalVal = totalVal.Add(newDecimal)
 			}
-			af := decimal.NewFromFloat(totalVal)
+			//af := decimal.NewFromFloat(totalVal)
+			af := totalVal
 			bf := decimal.NewFromFloat(float64(valArrLen))
 			val, _ := af.Div(bf).Float64()
 			currentDate, err := time.Parse(utils.FormatDate, av)