@@ -426,18 +426,10 @@ private boolean isOverdue(long time, long currentTime, Expression expr) { |
426 | 426 | private boolean caculate(double currentValue, double lastValue, NotifyStrategy.Expression expr, |
427 | 427 | Map<String, Object> judgeResult) { |
428 | 428 |
|
429 | | - boolean result = false; |
430 | | - |
431 | 429 | double diff = currentValue - lastValue; |
432 | | - |
433 | | - String limitString = ""; |
434 | | - |
435 | | - String upperLimitString = expr.getUpperLimit(); |
436 | | - String lowerLimitString = expr.getLowerLimit(); |
437 | | - // 增幅or降幅 |
438 | | - String upperORlower = ""; |
439 | 430 | double upperLimit = 0; |
440 | | - double lowerLimit = 0; |
| 431 | + String upperLimitString = expr.getUpperLimit(); |
| 432 | + |
441 | 433 | // get upperLimit |
442 | 434 | if (upperLimitString.contains("#")) { |
443 | 435 | upperLimit = Double.parseDouble(upperLimitString.substring(upperLimitString.indexOf('#') + 1)); |
@@ -450,6 +442,18 @@ else if (!upperLimitString.contains("*")) { |
450 | 442 | upperLimit = Double.parseDouble(upperLimitString); |
451 | 443 | } |
452 | 444 |
|
| 445 | + if (!upperLimitString.contains("*") && diff > upperLimit) { |
| 446 | + judgeResult.put("actualValue", String.format("%.2f", diff) + (upperLimitString.contains("%") ? "%" : "")); |
| 447 | + judgeResult.put("expectedValue", upperLimitString); |
| 448 | + judgeResult.put("upperORlower", "upper"); |
| 449 | + |
| 450 | + return true; |
| 451 | + } |
| 452 | + |
| 453 | + diff = currentValue - lastValue; |
| 454 | + double lowerLimit = 0; |
| 455 | + String lowerLimitString = expr.getLowerLimit(); |
| 456 | + |
453 | 457 | // get lowerLimit |
454 | 458 | if (lowerLimitString.contains("#")) { |
455 | 459 | lowerLimit = 0 - Double.parseDouble(lowerLimitString.substring(lowerLimitString.indexOf('#') + 1)); |
@@ -462,22 +466,15 @@ else if (!lowerLimitString.contains("*")) { |
462 | 466 | lowerLimit = Double.parseDouble(lowerLimitString); |
463 | 467 | } |
464 | 468 |
|
465 | | - if (!upperLimitString.contains("*") && diff > upperLimit) { |
466 | | - result = true; |
467 | | - upperORlower = "upper"; |
468 | | - limitString = upperLimitString; |
469 | | - } |
470 | | - else if (!lowerLimitString.contains("*") && diff < 0 - lowerLimit) { |
471 | | - result = true; |
472 | | - upperORlower = "lower"; |
473 | | - limitString = lowerLimitString; |
474 | | - } |
| 469 | + if (!lowerLimitString.contains("*") && diff < 0 - lowerLimit) { |
| 470 | + judgeResult.put("actualValue", String.format("%.2f", diff) + (lowerLimitString.contains("%") ? "%" : "")); |
| 471 | + judgeResult.put("expectedValue", lowerLimitString); |
| 472 | + judgeResult.put("upperORlower", "lower"); |
475 | 473 |
|
476 | | - judgeResult.put("actualValue", String.format("%.2f", diff) + (limitString.contains("%") ? "%" : "")); |
477 | | - judgeResult.put("expectedValue", limitString); |
478 | | - judgeResult.put("upperORlower", upperORlower); |
479 | | - return result; |
| 474 | + return true; |
| 475 | + } |
480 | 476 |
|
| 477 | + return false; |
481 | 478 | } |
482 | 479 |
|
483 | 480 | @SuppressWarnings({"rawtypes" }) |
|