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 ""; }