From 925182bfbaa3df7b66e50661c694fd84ff9893ce Mon Sep 17 00:00:00 2001 From: liquanyu Date: Fri, 8 Jun 2018 18:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E9=87=8D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/impl/PatientWeightServiceImpl.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 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 77373d5..8f5c3ad 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 @@ -1315,40 +1315,38 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient /** * 孕妇期所需卡里计算 - * @param bWeight 孕前体重 - * @param cWeight 当前体重 + * @param currentWeight 孕前体重 + * @param beforeWeight 当前体重 * @return */ - private Map getComputeKul(double bWeight,double cWeight,int week,double bmi) + private Map getComputeKul(double beforeWeight,double currentWeight,int week,double bmi) { Map map = new HashMap<>(); double kulStart = 0; double kulEnd = 0; - BigDecimal currentWeight = new BigDecimal(cWeight); - BigDecimal beforeWeight = new BigDecimal(bWeight); String status = ""; - double add = currentWeight.subtract(beforeWeight).doubleValue(); - add = Math.round(add * 100) * 0.01; + double add = Double.valueOf(String.format("%.2f",currentWeight - beforeWeight)); + //孕早期 if (week <= 12) { if (add < 1 && (1 - add >= 0.5)) { status = "低于"; - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue()+500; + kulStart = currentWeight * 25+500; } else if (add > 1.5 && (add - 1.5 >= 0.5)) { status = "高于"; - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue()-500; + kulStart = currentWeight * 25-500; } else { status = "处于"; - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue(); + kulStart = currentWeight * 25; } kulEnd = kulStart; } @@ -1376,14 +1374,13 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient avge = 0.22; } - BigDecimal bigavage = new BigDecimal(avge); - BigDecimal rangeweek = new BigDecimal(week - 12); + int rangeweek = week - 12; - double addWeightStart = 1 + rangeweek.multiply(bigavage).doubleValue(); - double addWeightEnd = 1.5 + rangeweek.multiply(bigavage).doubleValue(); + double addWeightStart = 1 + rangeweek*avge; + double addWeightEnd = 1.5 + rangeweek*avge; - double kstart = (beforeWeight.add(new BigDecimal(addWeightStart)).doubleValue()) * 25 + basekul; - double kend = (beforeWeight.add(new BigDecimal(addWeightEnd)).doubleValue()) * 25 + basekul; + double kstart = (beforeWeight + addWeightStart) * 25 + basekul; + double kend = (beforeWeight + addWeightEnd) * 25 + basekul; status = "处于"; if (addWeightEnd < add && (add - addWeightEnd) >= 0.5) @@ -1411,8 +1408,8 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public static void main(String[] args) { PatientWeightServiceImpl patientWeightService = new PatientWeightServiceImpl(); - String bmi = patientWeightService.getBmi("77.52", "161"); - Map map = patientWeightService.getComputeKul(77.52 , 85.58, 39, Double.parseDouble(bmi)); + String bmi = patientWeightService.getBmi("65", "168"); + Map map = patientWeightService.getComputeKul(65 , 78.76, 40, Double.parseDouble(bmi)); System.out.println(map); // double kulStart = 750; -- 1.8.3.1