Browse Source

年龄规则处理

zhoutg 4 years ago
parent
commit
bcc9de7303
1 changed files with 17 additions and 7 deletions
  1. 17 7
      src/main/java/com/diagbot/rule/AgeRule.java

+ 17 - 7
src/main/java/com/diagbot/rule/AgeRule.java

@@ -6,6 +6,8 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 
+import java.math.BigDecimal;
+
 /**
  * @description: 年龄规则
  * @author: zhoutg
@@ -25,15 +27,23 @@ public class AgeRule {
         Boolean flag = false;
         if (ageNeoDTO != null && wordCrfDTO.getAge() != null) {
             Integer age = wordCrfDTO.getAge();
-            Integer minAge = ageNeoDTO.getMin().intValue();
-            if (minAge != null) {
-                if (age < minAge) {
+            BigDecimal min = ageNeoDTO.getMin();
+            BigDecimal max = ageNeoDTO.getMax();
+
+            if (min != null && max != null) {
+                int minAge = min.intValue();
+                int maxAge = max.intValue();
+                if (minAge <= age && age <= maxAge) {
                     flag = true;
                 }
-            }
-            Integer maxAge = ageNeoDTO.getMax().intValue();
-            if (maxAge != null) {
-                if (age > minAge) {
+            } else if (min != null && max == null) {
+                int minAge = min.intValue();
+                if (minAge <= age) {
+                    flag = true;
+                }
+            } else if (min == null && max != null) {
+                int maxAge = max.intValue();
+                if (age <= maxAge) {
                     flag = true;
                 }
             }