From 2b0aaf0f6d0b9bcbb435b16c61d7e1877f7295ba Mon Sep 17 00:00:00 2001 From: liquanyu Date: Tue, 15 May 2018 17:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=A5=E5=85=BB=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E5=BF=AB=E9=80=9F=E6=B5=8B=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/web/service/impl/PatientWeightServiceImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index 66b3cee..6dc2ea0 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -36,6 +36,7 @@ import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; @Service @@ -279,12 +280,10 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Override public String getBmi(String weight, String height) { if(StringUtils.isNotBlank(weight) && StringUtils.isNotEmpty(height)) { - Double w = Double.parseDouble(weight); - Double h = Double.parseDouble(height) / 100l; - Double bmi = w / (h * h); - BigDecimal bg = new BigDecimal(bmi); - bmi = bg.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); - return bmi.toString(); + java.text.DecimalFormat df = new java.text.DecimalFormat("#.#"); + df.setRoundingMode(RoundingMode.FLOOR); + double tzzs = Double.parseDouble(weight) / Math.pow(Double.parseDouble(height) / 100, 2); + return df.format(tzzs); } return ""; } -- 1.8.3.1