Commit 925182bfbaa3df7b66e50661c694fd84ff9893ce
1 parent
eb7abcf1ba
Exists in
master
and in
6 other branches
体重管理
Showing 1 changed file with 15 additions and 18 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
925182b
| ... | ... | @@ -1315,40 +1315,38 @@ |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
| 1317 | 1317 | * 孕妇期所需卡里计算 |
| 1318 | - * @param bWeight 孕前体重 | |
| 1319 | - * @param cWeight 当前体重 | |
| 1318 | + * @param currentWeight 孕前体重 | |
| 1319 | + * @param beforeWeight 当前体重 | |
| 1320 | 1320 | * @return |
| 1321 | 1321 | */ |
| 1322 | - private Map<String,String> getComputeKul(double bWeight,double cWeight,int week,double bmi) | |
| 1322 | + private Map<String,String> getComputeKul(double beforeWeight,double currentWeight,int week,double bmi) | |
| 1323 | 1323 | { |
| 1324 | 1324 | Map<String,String> map = new HashMap<>(); |
| 1325 | 1325 | |
| 1326 | 1326 | double kulStart = 0; |
| 1327 | 1327 | double kulEnd = 0; |
| 1328 | 1328 | |
| 1329 | - BigDecimal currentWeight = new BigDecimal(cWeight); | |
| 1330 | - BigDecimal beforeWeight = new BigDecimal(bWeight); | |
| 1331 | 1329 | String status = ""; |
| 1332 | 1330 | |
| 1333 | - double add = currentWeight.subtract(beforeWeight).doubleValue(); | |
| 1334 | - add = Math.round(add * 100) * 0.01; | |
| 1331 | + double add = Double.valueOf(String.format("%.2f",currentWeight - beforeWeight)); | |
| 1332 | + | |
| 1335 | 1333 | //孕早期 |
| 1336 | 1334 | if (week <= 12) |
| 1337 | 1335 | { |
| 1338 | 1336 | if (add < 1 && (1 - add >= 0.5)) |
| 1339 | 1337 | { |
| 1340 | 1338 | status = "低于"; |
| 1341 | - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue()+500; | |
| 1339 | + kulStart = currentWeight * 25+500; | |
| 1342 | 1340 | } |
| 1343 | 1341 | else if (add > 1.5 && (add - 1.5 >= 0.5)) |
| 1344 | 1342 | { |
| 1345 | 1343 | status = "高于"; |
| 1346 | - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue()-500; | |
| 1344 | + kulStart = currentWeight * 25-500; | |
| 1347 | 1345 | } |
| 1348 | 1346 | else |
| 1349 | 1347 | { |
| 1350 | 1348 | status = "处于"; |
| 1351 | - kulStart = currentWeight.multiply(new BigDecimal(25)).doubleValue(); | |
| 1349 | + kulStart = currentWeight * 25; | |
| 1352 | 1350 | } |
| 1353 | 1351 | kulEnd = kulStart; |
| 1354 | 1352 | } |
| 1355 | 1353 | |
| 1356 | 1354 | |
| ... | ... | @@ -1376,14 +1374,13 @@ |
| 1376 | 1374 | avge = 0.22; |
| 1377 | 1375 | } |
| 1378 | 1376 | |
| 1379 | - BigDecimal bigavage = new BigDecimal(avge); | |
| 1380 | - BigDecimal rangeweek = new BigDecimal(week - 12); | |
| 1377 | + int rangeweek = week - 12; | |
| 1381 | 1378 | |
| 1382 | - double addWeightStart = 1 + rangeweek.multiply(bigavage).doubleValue(); | |
| 1383 | - double addWeightEnd = 1.5 + rangeweek.multiply(bigavage).doubleValue(); | |
| 1379 | + double addWeightStart = 1 + rangeweek*avge; | |
| 1380 | + double addWeightEnd = 1.5 + rangeweek*avge; | |
| 1384 | 1381 | |
| 1385 | - double kstart = (beforeWeight.add(new BigDecimal(addWeightStart)).doubleValue()) * 25 + basekul; | |
| 1386 | - double kend = (beforeWeight.add(new BigDecimal(addWeightEnd)).doubleValue()) * 25 + basekul; | |
| 1382 | + double kstart = (beforeWeight + addWeightStart) * 25 + basekul; | |
| 1383 | + double kend = (beforeWeight + addWeightEnd) * 25 + basekul; | |
| 1387 | 1384 | |
| 1388 | 1385 | status = "处于"; |
| 1389 | 1386 | if (addWeightEnd < add && (add - addWeightEnd) >= 0.5) |
| ... | ... | @@ -1411,8 +1408,8 @@ |
| 1411 | 1408 | |
| 1412 | 1409 | public static void main(String[] args) { |
| 1413 | 1410 | PatientWeightServiceImpl patientWeightService = new PatientWeightServiceImpl(); |
| 1414 | - String bmi = patientWeightService.getBmi("77.52", "161"); | |
| 1415 | - Map<String,String> map = patientWeightService.getComputeKul(77.52 , 85.58, 39, Double.parseDouble(bmi)); | |
| 1411 | + String bmi = patientWeightService.getBmi("65", "168"); | |
| 1412 | + Map<String,String> map = patientWeightService.getComputeKul(65 , 78.76, 40, Double.parseDouble(bmi)); | |
| 1416 | 1413 | System.out.println(map); |
| 1417 | 1414 | |
| 1418 | 1415 | // double kulStart = 750; |