Browse Source

修改四则混合运算中,传入bigdecimal的值如果是Double转换来的,会导致精度丢失

zhoupeng 2 năm trước cách đây
mục cha
commit
263850112d

+ 1 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/DataModelController.java

@@ -128,7 +128,7 @@ public class DataModelController {
         if (Blank.isEmpty(parameter, mathString, dataValue)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
-        return Result.ok(MathUtil.quadricOperation(parameter, mathString, new BigDecimal(dataValue)));
+        return Result.ok(MathUtil.quadricOperation(parameter, mathString, new BigDecimal(dataValue.toString())));
     }
 
 }

+ 1 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataModelServiceImpl.java

@@ -90,6 +90,6 @@ public class DataModelServiceImpl implements DataModelService {
         if (Blank.isEmpty(dataModel)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "没有相应的数据模型");
         }
-        return Result.ok(MathUtil.quadricOperation(dataModel.getMathParameter(), dataModel.getOperationRule(), new BigDecimal(dataValue)));
+        return Result.ok(MathUtil.quadricOperation(dataModel.getMathParameter(), dataModel.getOperationRule(), new BigDecimal(dataValue.toString())));
     }
 }