Kaynağa Gözat

规则校验服务完工

wuxw7 8 yıl önce
ebeveyn
işleme
f34e19b7a0
23 değiştirilmiş dosya ile 2723 ekleme ve 273 silme
  1. 558 256
      .idea/workspace.xml
  2. 143 7
      RuleService/RuleService.iml
  3. 3 4
      RuleService/pom.xml
  4. 583 0
      RuleService/src/main/java/com/java110/rule/common/RuleCommon.java
  5. 22 0
      RuleService/src/main/java/com/java110/rule/dao/IRuleDao.java
  6. 49 0
      RuleService/src/main/java/com/java110/rule/dao/impl/RuleDaoImpl.java
  7. 99 0
      RuleService/src/main/java/com/java110/rule/rest/RuleServiceRest.java
  8. 11 0
      RuleService/src/main/java/com/java110/rule/service/RuleService.java
  9. 16 0
      RuleService/src/main/java/com/java110/rule/smo/IRuleServiceSMO.java
  10. 255 0
      RuleService/src/main/java/com/java110/rule/smo/impl/RuleServiceSMOImpl.java
  11. 159 0
      RuleService/src/main/java/com/java110/rule/thread/RuleCommonThread.java
  12. 33 0
      bean/src/main/java/com/java110/entity/rule/ContractRootRule.java
  13. 101 0
      bean/src/main/java/com/java110/entity/rule/Rule.java
  14. 165 0
      bean/src/main/java/com/java110/entity/rule/RuleCondCfg.java
  15. 49 0
      bean/src/main/java/com/java110/entity/rule/RuleEntrance.java
  16. 52 0
      bean/src/main/java/com/java110/entity/rule/TcpContRule.java
  17. 60 0
      common/src/main/java/com/java110/common/constant/RuleDomain.java
  18. 1 0
      common/src/main/java/com/java110/common/util/ConstantUtil.java
  19. 124 0
      common/src/main/java/com/java110/common/util/RuleUtil.java
  20. 41 0
      common/src/main/java/com/java110/common/util/SpringBeanInvoker.java
  21. 172 0
      common/src/main/java/com/java110/common/util/StringJsonDeal.java
  22. 5 6
      config/db/rule.db
  23. 22 0
      config/src/main/resources/mapper/rule/RuleDaoImplMapper.xml

Dosya farkı çok büyük olduğundan ihmal edildi
+ 558 - 256
.idea/workspace.xml


+ 143 - 7
RuleService/RuleService.iml

@@ -10,14 +10,155 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="service" />
+    <orderEntry type="module" module-name="common" />
+    <orderEntry type="module" module-name="bean" />
+    <orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.28" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.axis:axis:1.4" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.axis:axis-jaxrpc:1.4" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.axis:axis-saaj:1.4" level="project" />
+    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.4" level="project" />
+    <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
+    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
+    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
+    <orderEntry type="library" name="Maven: ch.qos.logback:logback-access:1.1.3" level="project" />
+    <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.3" level="project" />
+    <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.3" level="project" />
+    <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
+    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
+    <orderEntry type="module" module-name="core" />
+    <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.1" level="project" />
+    <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.1" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.4.0.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.4" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.4" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.alibaba:druid:1.0.18" level="project" />
+    <orderEntry type="module-library">
+      <library name="Maven: com.alibaba:jconsole:1.8.0">
+        <CLASSES>
+          <root url="jar://F:/software/Java/jdk1.8.0_121/lib/jconsole.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="Maven: com.alibaba:tools:1.8.0">
+        <CLASSES>
+          <root url="jar://F:/software/Java/jdk1.8.0_121/lib/tools.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-starter:1.1.0" level="project" />
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:1.0.0" level="project" />
+    <orderEntry type="library" name="Maven: tk.mybatis:mapper:3.3.9" level="project" />
+    <orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-eureka:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:4.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:1.1.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.1.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.47" level="project" />
+    <orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.47" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-core:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-netflix-eureka-client:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.eureka:eureka-client:1.4.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.jettison:jettison:1.3.7" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: stax:stax-api:1.0.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-eventbus:0.3.0" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.7.4" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-core:0.10.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.servo:servo-internal:0.10.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-core:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey:jersey-client:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.jersey.contribs:jersey-apache-client4:1.19.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpcore:4.4.5" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.google.inject:guice:4.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.inject:javax.inject:1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: aopalliance:aopalliance:1.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator-api:1.12.10" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.eureka:eureka-core:1.4.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-core:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.8.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-ec2:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-autoscaling:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-sts:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.amazonaws:aws-java-sdk-route53:1.11.18" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator:1.12.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.governator:governator-core:1.12.10" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.4.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-archaius:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
+    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-ribbon:1.1.5.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.ribbon:ribbon-transport:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-contexts:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty-servo:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.hystrix:hystrix-core:1.5.3" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.hdrhistogram:HdrHistogram:2.1.7" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.reactivex:rxnetty:0.4.9" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec-http:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-handler:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-common:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-buffer:4.0.27.Final" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport:4.0.27.Final" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-core:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-httpclient:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-commons-util:0.1.1" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-loadbalancer:2.2.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: com.netflix.netflix-commons:netflix-statistics:0.1.1" level="project" />
+    <orderEntry type="library" name="Maven: io.reactivex:rxjava:1.1.5" level="project" />
+    <orderEntry type="library" name="Maven: com.netflix.ribbon:ribbon-eureka:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.2" level="project" />
+    <orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
+    <orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
+    <orderEntry type="module" module-name="feign" />
+    <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.39" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.activemq:activemq-pool:5.7.0" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec:1.0.1" level="project" />
+    <orderEntry type="library" name="Maven: commons-pool:commons-pool:1.6" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.activemq:activemq-core:5.7.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.activemq:kahadb:5.7.0" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.activemq.protobuf:activemq-protobuf:1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.fusesource.mqtt-client:mqtt-client:1.3" level="project" />
+    <orderEntry type="library" name="Maven: org.fusesource.hawtdispatch:hawtdispatch-transport:1.11" level="project" />
+    <orderEntry type="library" name="Maven: org.fusesource.hawtdispatch:hawtdispatch:1.11" level="project" />
+    <orderEntry type="library" name="Maven: org.fusesource.hawtbuf:hawtbuf:1.9" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:1.0.1" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: commons-net:commons-net:3.1" level="project" />
+    <orderEntry type="library" name="Maven: org.jasypt:jasypt:1.9.0" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-jms:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-messaging:4.3.2.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.2.RELEASE" level="project" />
+    <orderEntry type="module" module-name="config" scope="PROVIDED" />
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.4.0.RELEASE" level="project" />
-    <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.3" level="project" />
-    <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.3" level="project" />
     <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.7" level="project" />
     <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.7" level="project" />
     <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.7" level="project" />
@@ -34,9 +175,6 @@
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.1" level="project" />
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.1" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.2.RELEASE" level="project" />
-    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.2.RELEASE" level="project" />
-    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.2.RELEASE" level="project" />
-    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.2.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.2.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.2.RELEASE" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.0.RELEASE" level="project" />
@@ -45,8 +183,6 @@
     <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
-    <orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.3" level="project" />
-    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />

+ 3 - 4
RuleService/pom.xml

@@ -25,10 +25,9 @@
         </dependency>
 
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>3.8.1</version>
-            <scope>test</scope>
+            <groupId>com.java110</groupId>
+            <artifactId>config</artifactId>
+            <scope>provided</scope>
         </dependency>
     </dependencies>
 </project>

+ 583 - 0
RuleService/src/main/java/com/java110/rule/common/RuleCommon.java

@@ -0,0 +1,583 @@
+package com.java110.rule.common;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
+import com.java110.common.constant.RuleDomain;
+import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.RuleUtil;
+import com.java110.common.util.SpringBeanInvoker;
+import com.java110.entity.rule.ContractRootRule;
+import com.java110.entity.rule.Rule;
+import com.java110.entity.rule.RuleCondCfg;
+import com.java110.rule.dao.IRuleDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+@Service("ruleCommon")
+public class RuleCommon extends LoggerEngine{
+
+
+    private String ruleCode;
+    private String ruleMsg;
+    private String ruleCondRtn;//配置规则条件返回值 0成功 1失败
+
+    @Autowired
+    IRuleDao ruleDaoImpl;
+
+
+    Map<String,String> ruleNodeMap;
+
+    Map<String,String> dataStackMap = null;
+
+    Map<String,List<Map<String,String>>> ruleDbMap;
+
+
+
+    public RuleCommon(Map<String, String> dataStackMap) {
+        this.dataStackMap = dataStackMap;
+    }
+
+    public String ruleCommonCondMed(String ruleId, ContractRootRule contractRootRule, JSONObject reqJson)  throws Exception {
+        long allStartTime = System.currentTimeMillis();
+        java.sql.Timestamp startTime = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+
+        String condReturnXml = "";
+        Map<String,Rule> ruleMap = RuleUtil.getRuleMap();
+        Rule rule = ruleMap.get(ruleId);
+
+        Map<String,String> map = new HashMap<String,String>();
+
+        List<TreeMap<String,String>> paramList = new ArrayList<TreeMap<String,String>>();
+
+        map = ruleCommonCondMed(ruleId,paramList,reqJson);
+
+        condReturnXml = ruleCommonCondMed(map,paramList,rule,contractRootRule.getTcpCont().getTransactionId());
+        //记录耗时明细
+        recordCostTime(reqJson,
+                System.currentTimeMillis()-allStartTime,
+                "校验规则条件判断耗时[ruleId:"+ruleId+"]",
+                2,
+                startTime,
+                new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+        return condReturnXml;
+    }
+
+    public String ruleCommonCondMed(Map<String,String> map,List<TreeMap<String,String>> paramList,Rule rule,String transactionID)  throws Exception {
+        String retCode = map.get("retCode");
+        String retMsg = map.get("retMsg");
+        if(!StringUtils.isEmpty(retCode)){
+            if(retCode.equals(RuleDomain.RULE_COND_RETURN_0000)){//校验通过
+                return retCode;
+            }else{//校验失败
+                return RuleUtil.ruleReturnJson(transactionID,retCode,retMsg,rule.getRule_type());
+            }
+        }else{
+            //如果调用存过的参数为空,直接返回成功
+            if(paramList.size() == 0 || !rule.getRule_type().contains(RuleDomain.RULE_TYPE_STORED_PROCEDURE)){
+                return RuleDomain.RULE_COND_RETURN_0000;
+            }else{
+                return ruleAction(transactionID,rule,paramList);
+            }
+        }
+    }
+
+
+    public Map<String,String> ruleCommonCondMed (String ruleId, List<TreeMap<String,String>> list,JSONObject reqJson)  throws Exception {
+        if(list == null){
+            list = new ArrayList<TreeMap<String, String>>();
+        }
+
+        Map<String,String> returnMap = new HashMap<String,String>();
+        dataStackMap = new HashMap<String,String>();
+        Map<String,Rule> ruleMap = RuleUtil.getRuleMap();
+        List<RuleCondCfg> ruleCondCfgList = ruleMap.get(ruleId).getRuleCondCfgs();
+        ruleNodeMap = new HashMap<String,String>();
+        ruleDbMap = new HashMap<String, List<Map<String,String>>>();
+        returnMap.clear();
+        TreeMap<String,String> returnTreeMap = new TreeMap<String,String>();
+        String ruleCommonCondStr = "";
+        int i = 0;
+        for(RuleCondCfg ruleCondCfg : ruleCondCfgList){
+            i++;
+            String ruleNode = ruleCondCfg.getRule_node();
+            String ruleNodeTmp = RuleDomain.RULE_SIGN_5+ruleCondCfg.getNode_existed()+RuleDomain.RULE_SIGN_5;
+            String ruleNodeValue = "";
+            String ruleNodeValueTmp = ruleNodeMap.get(ruleNodeTmp)==null?"":ruleNodeMap.get(ruleNodeTmp);
+            if(!StringUtils.isEmpty(ruleNode)){
+                String dataFromFlag = ruleCondCfg.getData_from_flag();
+                if(dataFromFlag.contains(RuleDomain.RULE_SIGN_4)){
+                    for(String dataFromFlag1 : dataFromFlag.split(RuleDomain.RULE_SIGN_4)){
+                        ruleNodeValue = getRuleNodeValue(dataFromFlag1,ruleCondCfg,ruleNodeValueTmp,reqJson.toJSONString());
+                        if(!StringUtils.isEmpty(ruleNodeValue)){
+                            break;
+                        }
+                    }
+                }else{
+                    ruleNodeValue = getRuleNodeValue(dataFromFlag,ruleCondCfg,ruleNodeValueTmp,reqJson.toJSONString());
+                }
+
+            }
+            ruleNodeMap.put(RuleDomain.RULE_SIGN_5+ruleNode+RuleDomain.RULE_SIGN_5, ruleNodeValue);
+            //如果堆栈节点配置不为空并且取值方式不是5,则把结果值压入堆栈
+            if(!StringUtils.isEmpty(ruleCondCfg.getData_stack_flag_prefix()) && !ruleCondCfg.getData_from_flag().equals("5")){
+                dataStackMap.put(ruleCondCfg.getData_stack_flag_prefix(),ruleNodeValue);
+            }
+            if(!StringUtils.isEmpty(ruleCondCfg.getIs_log()) && ruleCondCfg.getIs_log().equals(RuleDomain.RULE_IS_Y)){
+                ruleCommonCondStr += RuleDomain.RULE_SIGN_1+ruleNodeValue;
+            }
+            if(!StringUtils.isEmpty(ruleCondCfg.getError_code())){
+                if(((StringUtils.isEmpty(StringUtils.replace(ruleNodeValue, "''", ""))
+                        && (StringUtils.isEmpty(ruleCondCfg.getIs_reverse())
+                        || ruleCondCfg.getIs_reverse().equals(RuleDomain.RULE_IS_N)))
+                        || (!StringUtils.isEmpty(StringUtils.replace(ruleNodeValue, "''", ""))
+                        && !StringUtils.isEmpty(ruleCondCfg.getIs_reverse())
+                        && ruleCondCfg.getIs_reverse().equals(RuleDomain.RULE_IS_Y)))){
+                    returnMap.put("retCode", ruleCondCfg.getError_code());
+                    returnMap.put("retMsg", getErrorMsg(ruleCondCfg.getError_msg()));
+                    break;
+                }
+            }
+            if(!StringUtils.isEmpty(ruleCondCfg.getProc_param_flag())){
+                returnTreeMap.put(String.valueOf(i), ruleNodeValue);
+            }
+        }
+        //记录规则日志
+
+        String transactionID = reqJson.getJSONObject("TcpCont").getString("TransactionID");
+        saveRuleCommonCondLog(transactionID,ruleId,ruleCommonCondStr,returnMap);
+        if(!returnTreeMap.isEmpty()){
+            list.add(returnTreeMap);
+        }
+
+        return returnMap;
+    }
+
+
+    /**
+     * 获取值
+     * @param dataFromFlag
+     * @param ruleCondCfg
+     * @param ruleNodeValueTmp
+     * @param reqJson
+     * @return
+     * @throws Exception
+     */
+    public String getRuleNodeValue(String dataFromFlag,RuleCondCfg ruleCondCfg,String ruleNodeValueTmp,String reqJson) throws Exception{
+
+        if(dataFromFlag.equals("2")){//dbSql取值
+            //return getRuleNodeValueFromDbSQL(ruleCondCfg.getRuleNode(),getDbSQL(ruleCondCfg.getDbSql()));
+            String dbSql =getDbSQL(ruleCondCfg.getDb_sql());
+            try
+            {
+                return getRuleNodeValueFromDbSQL(ruleCondCfg.getRule_node(),dbSql);
+            }catch(Exception e)
+            {
+                logger.error("-------------[RuleServiceSMOImpl.getRuleNodeValue]-------------rule_id is "+ruleCondCfg.getRule_id()+" ,error sql is ="+dbSql);
+                throw e;
+            }
+        }else if(dataFromFlag.equals("3")){//常量
+            return ruleCondCfg.getDefault_value();
+        }else if(dataFromFlag.equals("4")){//取已有节点的值
+            return ruleNodeValueTmp;
+        }else if(dataFromFlag.equals("5")){//从堆栈中获取
+            return getRuleNodeValueFromDataStack(ruleCondCfg.getData_stack_flag_prefix());
+        }else if(dataFromFlag.equals("6")){//从XML中获取
+            return getRuleNodeValueFromJson(ruleCondCfg.getJpath(),reqJson);
+        }else{
+            return "";
+        }
+    }
+
+
+    public String getDbSQL(String dbSql)  throws Exception {
+        String exeDbSql = "";
+        String[] sqlArray = dbSql.split(RuleDomain.RULE_SIGN_5);
+        if (null != sqlArray && sqlArray.length > 1) {
+            String sqlStr = null;
+            int sqlLength = sqlArray.length;
+            if (0 == sqlLength % 2) {
+                if (!dbSql.endsWith(RuleDomain.RULE_SIGN_5)) {
+                    return "SQL语句配置错误,参数两边的#没有成对出现:SQL=" + dbSql;
+                }
+            }
+            for (int j = 0; j < sqlLength; j++) {
+                sqlStr = sqlArray[j];
+                if (0 != j % 2) {
+                    sqlStr = ruleNodeMap.get(RuleDomain.RULE_SIGN_5+sqlStr+RuleDomain.RULE_SIGN_5)==null?"":ruleNodeMap.get(RuleDomain.RULE_SIGN_5+sqlStr+RuleDomain.RULE_SIGN_5);
+                    if(!sqlStr.contains(RuleDomain.RULE_SIGN_3)){
+                        sqlStr = "'" + sqlStr + "'";
+                    }
+                } else {
+                    sqlStr = getDbSQL(sqlStr);
+                }
+                exeDbSql += sqlStr;
+            }
+            return exeDbSql;
+        }
+        return dbSql;
+    }
+
+
+    /**
+     * 根据sql获取值
+     * @param ruleNode
+     * @param dbSql
+     * @return
+     * @throws Exception
+     */
+    public String getRuleNodeValueFromDbSQL(String ruleNode,String dbSql)  throws Exception {
+        String columnStr = "";
+        String retVal = "";
+        String dbSqlStr = dbSql;
+        if(dbSql.startsWith(RuleDomain.RULE_SIGN_6)){
+            String dbSqlTmp = dbSql.split(RuleDomain.RULE_SIGN_6)[1];
+            if(dbSqlTmp.contains(RuleDomain.RULE_SIGN_8)){
+                String ruleNodeTmp = dbSqlTmp.split("\\"+RuleDomain.RULE_SIGN_8)[0];
+                String columnStrTmp = dbSqlTmp.split("\\"+RuleDomain.RULE_SIGN_8)[1];
+                List<Map<String,String>> dbList = ruleDbMap.get(ruleNodeTmp);
+                if(dbList != null && dbList.size() > 0){
+                    for(Map<String,String> dbMap : dbList){
+                        retVal += RuleDomain.RULE_SIGN_4 + RuleDomain.RULE_SIGN_3 + String.valueOf(dbMap.get(columnStrTmp.toUpperCase())) + RuleDomain.RULE_SIGN_3;
+                    }
+                    if(retVal.length() > 0){
+                        retVal = retVal.substring(1);
+                    }
+                }
+            }
+        }else{
+            if(dbSql.contains(RuleDomain.RULE_SIGN_7)){
+                if(dbSql.split(RuleDomain.RULE_SIGN_7).length > 1){
+                    columnStr = dbSql.split(RuleDomain.RULE_SIGN_7)[1].toUpperCase();
+                }
+                dbSqlStr = dbSql.split(RuleDomain.RULE_SIGN_7)[0];
+            }
+            List<Map<String,String>> dbList = ruleDaoImpl.executeSql(dbSqlStr);
+            if(dbList != null && dbList.size() > 0){
+                for(Map<String,String> dbMap : dbList){
+                    if(StringUtils.isEmpty(columnStr)){
+                        Object[] retAttr = dbMap.values().toArray();
+                        if(retAttr.length > 0){
+                            if(retAttr[0]!=null){
+                                retVal += RuleDomain.RULE_SIGN_4 + RuleDomain.RULE_SIGN_3 + retAttr[0].toString() + RuleDomain.RULE_SIGN_3;
+
+                            }
+                        }
+                    }else{
+                        retVal += RuleDomain.RULE_SIGN_4 + RuleDomain.RULE_SIGN_3 + String.valueOf(dbMap.get(columnStr)) + RuleDomain.RULE_SIGN_3;
+                    }
+                }
+                if(retVal.length() > 0){
+                    retVal = retVal.substring(1);
+                }
+                ruleDbMap.put(ruleNode, dbList);
+            }
+        }
+        return retVal;
+    }
+
+
+    //从堆栈中获取值
+    public String getRuleNodeValueFromDataStack(String dataStackFlagPrefix)  throws Exception {
+        String retVal = "";
+        if(!StringUtils.isEmpty(dataStackFlagPrefix) && !StringUtils.isEmpty(dataStackMap)){
+            retVal = dataStackMap.get(dataStackFlagPrefix);
+            if(retVal == null){
+                retVal = "";
+            }
+        }else{
+            return "";
+        }
+        return retVal;
+    }
+
+    //从json中获取值
+    public String getRuleNodeValueFromJson(String jPath,String reqJson)  throws Exception {
+        String retVal = "";
+        if (!StringUtils.isEmpty(jPath)) {
+            if(jPath.contains(RuleDomain.RULE_SIGN_5)){
+                String[] sooNodeXpathArray = jPath.split(RuleDomain.RULE_SIGN_5);
+                if (null != sooNodeXpathArray) {
+                    String sql3 = null;
+                    int sooNodeXpathArrayLength = sooNodeXpathArray.length;
+                    if (0 == sooNodeXpathArrayLength % 2) {
+                        if (!jPath.endsWith(RuleDomain.RULE_SIGN_5)) {
+                            return "规则配置错误,配置sooNodeXpath的#没有成对出现";
+                        }
+                    }
+                    String sooNodeParam = null;
+                    String sooNodevalue = null;
+                    for (int j = 0; j < sooNodeXpathArrayLength; j++) {
+                        sooNodeParam = RuleDomain.PART_STRING_ORIGINAL_VALUE;
+                        sooNodeParam = sooNodeXpathArray[j];
+                        if (0 != j % 2) {
+                            sooNodevalue = ruleNodeMap.get(RuleDomain.RULE_SIGN_5+sooNodeParam+RuleDomain.RULE_SIGN_5)==null?"":ruleNodeMap.get(RuleDomain.RULE_SIGN_5+sooNodeParam+RuleDomain.RULE_SIGN_5);
+                            sooNodevalue = sooNodevalue.contains("'")?sooNodevalue:"'"+sooNodevalue+"'";
+                            jPath = StringUtils.replace(jPath, RuleDomain.RULE_SIGN_5+sooNodeParam+RuleDomain.RULE_SIGN_5, sooNodevalue);
+                        }
+                    }
+                }
+            }
+            retVal = this.getNodeValueFromJson(jPath, reqJson);
+        }
+        return retVal;
+    }
+
+
+    /**
+     * 通过jpath 获取值
+     * @param jPath
+     * @param reqJson
+     * @return
+     */
+    private String getNodeValueFromJson(String jPath,String reqJson){
+        String nodeValue = "";
+        JSONObject reqJsonObject = null;
+        if (!StringUtils.isEmpty(reqJson)) {
+            try {
+                reqJsonObject = JSONObject.parseObject(reqJson);
+            } catch (Exception e) {
+                return "给出的报文格式存在错误,无法转换为JSON对象,具体原因为:" + e;
+            }
+            //报文中SOO对象的根节点
+            if (null != reqJsonObject) {
+                if (null != jPath && !"".equals(jPath)) {
+                    String[] array1 = jPath.split(RuleDomain.RULE_SIGN_9);
+                    int length1 = array1.length;
+                    if (0 < length1) {
+                        String sooNodeJpathTmp = null;
+                        for (int i = 0; i < length1; i++) {
+                            sooNodeJpathTmp = array1[i];
+                            if (null != sooNodeJpathTmp && !"".equals(sooNodeJpathTmp)) {
+                                if(!sooNodeJpathTmp.startsWith("$.")){
+                                    sooNodeJpathTmp = "$."+sooNodeJpathTmp;
+                                }
+                                Object valueObj = JSONPath.eval(reqJsonObject,sooNodeJpathTmp);
+                                if (null != valueObj && valueObj instanceof String) {
+                                    nodeValue = nodeValue + ",'" +valueObj + "'";
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return nodeValue.length()>0?nodeValue.substring(1):"";
+    }
+
+
+
+    /**
+     * 业务规则校验,调用存储过程
+     * @param
+     * @return
+     */
+    public String ruleAction(String transactionId, Rule rule,List<TreeMap<String,String>> paramList) throws Exception{
+        long allStartTime = System.currentTimeMillis();
+        java.sql.Timestamp startTime = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+
+        String procParam = "";
+        String ruleCode = RuleDomain.RULE_COND_RETURN_0000;
+        String ruleDesc = "";
+        for(TreeMap<String,String> paramMap : paramList){
+            procParam = "";
+            for(String paramStr : paramMap.values()){
+                if(StringUtils.isEmpty(paramStr)){
+                    paramStr = "''";
+                }
+                procParam +=  paramStr + RuleDomain.RULE_SIGN_1;
+            }
+            procParam = procParam.substring(0,procParam.length() - 2);
+            String actionRtn = ruleDaoImpl.executeProc(transactionId,procParam, rule.getRule_url());
+            if(!actionRtn.equals(ruleCode)){//校验不通过
+                ruleCode = RuleDomain.RULE_COND_RETURN_0002;
+                ruleDesc = actionRtn;
+                break;
+            }else{
+                ruleCode = actionRtn;
+            }
+        }
+
+        //记录耗时明细
+        recordCostTime(null,
+                System.currentTimeMillis()-allStartTime,
+                "LTE4G全量校验规则逻辑校验耗时[ruleId:"+rule.getRule_id()+"]",
+                2,
+                startTime,
+                new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+
+        if(ruleCode.equals(RuleDomain.RULE_COND_RETURN_0000)){//校验通过
+            return ruleCode;
+        }else{//校验失败
+            return RuleUtil.ruleReturnJson(transactionId,rule.getRule_code(),ruleDesc,"");
+        }
+
+    }
+
+    /**
+     * 业务规则条件
+     * @param contractRootRule
+     * @return
+     */
+    public String ruleCond(String ruleId,ContractRootRule contractRootRule) throws Exception{
+
+        long allStartTime = System.currentTimeMillis();
+        java.sql.Timestamp startTime = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+
+        String condReturnXml = "";
+        Map<String,Rule> ruleMap = RuleUtil.getRuleMap();
+        Rule rule = ruleMap.get(ruleId);
+        if(!StringUtils.isEmpty(rule.getRule_url())){
+
+            List<TreeMap<String,String>> paramList = new ArrayList<TreeMap<String,String>>();
+            Class[] parameterTypes = {ContractRootRule.class,List.class};
+            Object[] args = {contractRootRule,paramList};
+
+            Object ruleService = SpringBeanInvoker.getBean("ruleService");
+            Method method = ruleService.getClass().getMethod(rule.getRule_url(), parameterTypes);
+            String condRtn =  (String)method.invoke(ruleService, args);
+            //记录耗时明细
+            recordCostTime(null,
+                    System.currentTimeMillis()-allStartTime,
+                    "LTE4G全量校验规则条件判断耗时[ruleId:"+ruleId+"]",
+                    2,
+                    startTime,
+                    new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+
+            if(!StringUtils.isEmpty(condRtn)){
+                if(condRtn.equals(RuleDomain.RULE_COND_RETURN_0000)){//校验通过
+                    condReturnXml = condRtn;
+                }else if(condRtn.equals(RuleDomain.RULE_COND_RETURN_0001)){//继续转存过校验
+                    //如果调用存过的参数为空,直接返回成功
+                    if(paramList.size() == 0 || !rule.getRule_type().contains(RuleDomain.RULE_TYPE_STORED_PROCEDURE)){
+                        return RuleDomain.RULE_COND_RETURN_0000;
+                    }
+                    condReturnXml = ruleAction(contractRootRule.getTcpCont().getTransactionId(),rule,paramList);
+                }else{//校验失败
+                    condReturnXml = RuleUtil.ruleReturnJson(contractRootRule.getTcpCont().getTransactionId(),rule.getRule_code(),condRtn,rule.getRule_level());
+                }
+            }
+        }
+
+        return condReturnXml;
+
+    }
+
+
+    public String getErrorMsg(String errorMsg)  throws Exception {
+        String exeErrorMsg = "";
+        String[] errorMsgArray = errorMsg.split(RuleDomain.RULE_SIGN_5);
+        if (null != errorMsgArray && errorMsgArray.length > 1) {
+            String errorMsg1 = null;
+            int errorMsgLength = errorMsgArray.length;
+            if (0 == errorMsgLength % 2) {
+                if (!errorMsg.endsWith(RuleDomain.RULE_SIGN_5)) {
+                    return "规则提示语配置错误,配置的#没有成对出现:errorMsg=" + errorMsg;
+                }
+            }
+            for (int j = 0; j < errorMsgLength; j++) {
+                errorMsg1 = errorMsgArray[j];
+                if (0 != j % 2) {
+                    errorMsg1 = ruleNodeMap.get(RuleDomain.RULE_SIGN_5+errorMsg1+RuleDomain.RULE_SIGN_5)==null?"":ruleNodeMap.get(RuleDomain.RULE_SIGN_5+errorMsg1+RuleDomain.RULE_SIGN_5);
+                } else {
+                    errorMsg1 = getErrorMsg(errorMsg1);
+                }
+                exeErrorMsg += errorMsg1;
+            }
+            return exeErrorMsg;
+        }
+        return errorMsg;
+    }
+
+    public void saveRuleCommonCondLog(String transactionID,String ruleID,String ruleNodeValue,Map<String,String> returnMap)  throws Exception {
+       /* String retCode = returnMap.get("retCode");
+        String retMsg = returnMap.get("retMsg");
+        String retVal;
+        if(StringUtils.isBlank(retCode) || retCode.equals(RuleDomain.RULE_COND_RETURN_0000)){
+            retVal = RuleDomain.RULE_COND_RETURN_0000;
+        }else{
+            retVal = retMsg;
+        }
+        ruleNodeValue = StringUtils.isBlank(ruleNodeValue)?"":ruleNodeValue.substring(2);
+        Map<String,String> ruleCondMap = new HashMap<String,String>();
+        ruleCondMap.put("transactionID", transactionID);
+        ruleCondMap.put("ruleID", ruleID);
+        ruleCondMap.put("ruleNodeValue", ruleNodeValue);
+        ruleCondMap.put("retVal", retVal);
+        this.getRuleManageBmo().saveRuleCommonCondLog(ruleCondMap);*/
+    }
+
+
+    /**
+     * 记录耗时明细
+     * @param
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public void recordCostTime(JSONObject reqJson,long costTime, String costDesc,int classFlag ,java.sql.Timestamp startTime,java.sql.Timestamp endTime){
+       /* try {
+            //判断是否开启了日志记录监控
+            if(PCrmDomain.WRITE_LOG_SWITCH_DCV.ON.value.equals(CodeMapUtil.getDynamicConstantValue(PCrmDomain.WRITE_COST_TIME_SWITCH_DCN))){
+                //这里统计最终的耗时,然后记录到监控表中
+                Map detailMap = new HashMap();
+                detailMap.put("TRANSACTION_ID", transactionId);
+                detailMap.put("COST_TIME", costTime);
+                detailMap.put("REMARK", costDesc);
+                detailMap.put("DO_WHAT", costDesc);
+                detailMap.put("CLASS_FLAG", classFlag);
+                detailMap.put("START_TIME", startTime);
+                detailMap.put("FINISH_TIME", endTime);
+
+                this.getCustManagerSearchBMO().insertCostTimeDetail(detailMap);
+            }
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }*/
+    }
+
+    public void init(){
+        this.setRuleCode("");
+        this.setRuleMsg("");
+        this.setRuleCondRtn("");
+    }
+
+
+    public String getRuleCode() {
+        return ruleCode;
+    }
+
+    public void setRuleCode(String ruleCode) {
+        this.ruleCode = ruleCode;
+    }
+
+    public String getRuleMsg() {
+        return ruleMsg;
+    }
+
+    public void setRuleMsg(String ruleMsg) {
+        this.ruleMsg = ruleMsg;
+    }
+
+    public String getRuleCondRtn() {
+        return ruleCondRtn;
+    }
+
+    public void setRuleCondRtn(String ruleCondRtn) {
+        this.ruleCondRtn = ruleCondRtn;
+    }
+
+    public IRuleDao getRuleDaoImpl() {
+        return ruleDaoImpl;
+    }
+
+    public void setRuleDaoImpl(IRuleDao ruleDaoImpl) {
+        this.ruleDaoImpl = ruleDaoImpl;
+    }
+}

+ 22 - 0
RuleService/src/main/java/com/java110/rule/dao/IRuleDao.java

@@ -0,0 +1,22 @@
+package com.java110.rule.dao;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+public interface IRuleDao {
+
+
+    /**
+     * 执行 sql
+     * @param sql
+     * @return
+     * @throws Exception
+     */
+    public List<Map<String,String>> executeSql(String sql) throws Exception;
+
+
+    public String executeProc(String transactionId,String paramIn,String procName) throws Exception;
+}

+ 49 - 0
RuleService/src/main/java/com/java110/rule/dao/impl/RuleDaoImpl.java

@@ -0,0 +1,49 @@
+package com.java110.rule.dao.impl;
+
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.rule.dao.IRuleDao;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+
+@Service("ruleDaoImpl")
+@Transactional
+public class RuleDaoImpl extends BaseServiceDao implements IRuleDao {
+    @Override
+    public List<Map<String, String>> executeSql(String sql) throws Exception {
+        return sqlSessionTemplate.selectList("ruleDaoImpl.executeSql",sql);
+    }
+
+    /**
+     *
+     * @param transactionId
+     * @param paramIn
+     * @param procName
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String executeProc(String transactionId, String paramIn, String procName) throws Exception {
+
+        Map<String,String> paramInMap = new HashMap<String,String>();
+        paramInMap.put("transactionId",transactionId);
+
+        paramInMap.put("procName",procName);
+
+        paramInMap.put("paramIn",paramIn);
+
+        long updateFlag = sqlSessionTemplate.update("ruleDaoImpl.executeProc",paramInMap);
+
+        if (updateFlag > 0){
+            return paramInMap.get("paramOut");
+        }
+        return null;
+    }
+}

+ 99 - 0
RuleService/src/main/java/com/java110/rule/rest/RuleServiceRest.java

@@ -0,0 +1,99 @@
+package com.java110.rule.rest;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.RuleDomain;
+import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.CodeMapUtil;
+import com.java110.common.util.RuleUtil;
+import com.java110.core.base.controller.BaseController;
+import com.java110.entity.rule.ContractRootRule;
+import com.java110.entity.rule.TcpContRule;
+import com.java110.rule.smo.IRuleServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+/**
+ * 规则服务
+ * Created by wuxw on 2017/7/22.
+ */
+@RestController
+public class RuleServiceRest extends BaseController {
+
+
+    @Autowired
+    IRuleServiceSMO ruleServiceSMOImpl;
+
+    /**
+     * 规则校验方法
+     * 请求报文协议:
+     *
+     * {
+     "ContractRoot": {
+     "TcpCont": { -- 请求头部
+     "RuleType":"RULE0001", -- 用来区分走那个规则组
+     "ServiceCode": "SVC0001", -- 用来判断走那些规则
+     "TransactionID": "1001000101201603081234567890", -- 交易流水
+     "ReqTime": "20130817200202123",--请求时间
+     },
+     "SvcCont": { -- 请求体 这里面的结构可以随便定
+     "AccNbr": "",
+     "ProductNbr":"",
+     "RegionCode":"863000"
+     }
+     }
+     }
+     *
+     * @param validateInfo
+     * @return
+     */
+    @RequestMapping("/ruleService/validate")
+    @ResponseBody
+    public String validate(@RequestParam("validateInfo") String validateInfo){
+        String resultInfo = "";
+        logger.debug("----------[RuleServiceRest.validate]-----------请求报文:" + validateInfo);
+        try{
+            resultInfo = ruleServiceSMOImpl.validate(validateInfo);
+        }catch (Exception e){
+            LoggerEngine.error("----------[RuleServiceRest.validate]-----------出现异常,请求报文为["+validateInfo+"]" ,e);
+            try {
+                //XStream转换出错,默认返回成功,后台记录错误日志
+                JSONObject jsonObject = JSONObject.parseObject(validateInfo);
+                String transactionID = jsonObject.containsKey("TcpCont") ?
+                        (jsonObject.getJSONObject("TcpCont").containsKey("TransactionID")?jsonObject.getJSONObject("TcpCont").getString("TransactionID"):"-1")
+                        :"-1";
+                String error =  e.toString();
+                //记录错误日志
+                //recordRuleLog(transactionID,error,"LTE4G全量校验报文转换环节异常");
+                //动态常量DEP_PRVNC_RULE_ERROR_RET,不配置或配置不是1,则程序异常默认返回成功,其他返回具体异常信息
+                String depPrvncSaopRuleErrorRet = CodeMapUtil.getDynamicConstantValue("DEP_PRVNC_RULE_ERROR_RET");
+                if(StringUtils.isEmpty(depPrvncSaopRuleErrorRet) || !depPrvncSaopRuleErrorRet.equals("1")){
+                    resultInfo = RuleUtil.ruleReturnJson(transactionID,RuleDomain.RULE_COND_RETURN_0000,"成功","");
+                }else{
+                    resultInfo = RuleUtil.ruleReturnJson(transactionID,RuleDomain.RULE_COND_RETURN_1999,e.getMessage(),"");
+                }
+            } catch (Exception e1) {
+                LoggerEngine.error("----------[RuleServiceRest.validate]-----------出现异常,请求报文为["+validateInfo+"]" ,e);
+                resultInfo = RuleUtil.ruleReturnJson("-1",RuleDomain.RULE_COND_RETURN_1999,e.getMessage(),"");
+            }
+        }finally {
+            //这里需要记录日志报文
+            logger.debug("----------[RuleServiceRest.validate]-----------返回报文:" + resultInfo);
+            return resultInfo;
+        }
+    }
+
+
+    public IRuleServiceSMO getRuleServiceSMOImpl() {
+        return ruleServiceSMOImpl;
+    }
+
+    public void setRuleServiceSMOImpl(IRuleServiceSMO ruleServiceSMOImpl) {
+        this.ruleServiceSMOImpl = ruleServiceSMOImpl;
+    }
+}

+ 11 - 0
RuleService/src/main/java/com/java110/rule/service/RuleService.java

@@ -0,0 +1,11 @@
+package com.java110.rule.service;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+
+@Component("ruleService")
+public class RuleService {
+}

+ 16 - 0
RuleService/src/main/java/com/java110/rule/smo/IRuleServiceSMO.java

@@ -0,0 +1,16 @@
+package com.java110.rule.smo;
+
+/**
+ * 规则服务接口类
+ * Created by wuxw on 2017/7/23.
+ */
+public interface IRuleServiceSMO {
+
+    /**
+     * 校验方法
+     * @param validateInfo
+     * @return
+     * @throws Exception
+     */
+    public String validate(String validateInfo) throws Exception;
+}

+ 255 - 0
RuleService/src/main/java/com/java110/rule/smo/impl/RuleServiceSMOImpl.java

@@ -0,0 +1,255 @@
+package com.java110.rule.smo.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
+import com.java110.common.constant.RuleDomain;
+import com.java110.common.util.CodeMapUtil;
+import com.java110.common.util.RuleUtil;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.entity.rule.ContractRootRule;
+import com.java110.entity.rule.Rule;
+import com.java110.entity.rule.RuleEntrance;
+import com.java110.entity.rule.TcpContRule;
+import com.java110.rule.common.RuleCommon;
+import com.java110.rule.smo.IRuleServiceSMO;
+import com.java110.rule.thread.RuleCommonThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 规则服务实现类
+ * Created by wuxw on 2017/7/23.
+ */
+@Service("ruleServiceSMOImpl")
+public class RuleServiceSMOImpl extends BaseServiceSMO implements IRuleServiceSMO {
+
+
+    public static DateFormat df = new SimpleDateFormat("yyyyMMddHHmmSSS");
+
+
+
+    @Autowired
+    RuleCommon ruleCommon;
+
+
+
+
+    /**
+     * 校验方法
+     *
+     * 请求协议:
+     * {
+     "ContractRoot": {
+     "TcpCont": { -- 请求头部
+     "RuleType":"RULE0001", -- 用来区分走那个规则组
+     "ServiceCode": "SVC0001", -- 用来判断走那些规则
+     "TransactionID": "1001000101201603081234567890", -- 交易流水
+     "ReqTime": "20130817200202123",--请求时间
+     },
+     "SvcCont": { -- 请求体 这里面的结构可以随便定
+     "AccNbr": "",
+     "ProductNbr":"",
+     "RegionCode":"863000"
+     }
+     }
+     }
+     * @param validateInfo
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String validate(String validateInfo) throws Exception {
+
+        JSONObject validateInfoJson = JSONObject.parseObject(validateInfo);
+        ContractRootRule contractRootRule = new ContractRootRule();
+
+        try {
+            TcpContRule reqTcpCont = JSONObject.parseObject(validateInfoJson.getJSONObject("TcpCont").toJSONString(), TcpContRule.class);
+            JSONObject reqSvcCont = validateInfoJson.getJSONObject("SvcCont");
+            contractRootRule.setTcpCont(reqTcpCont);
+            contractRootRule.setSvcCont(reqSvcCont);
+        }catch (Exception e){
+            //说明报文不是按协议来的,我们也需要支撑,所以这里补充数据,以免后续流程异常,流程继续往下走
+            TcpContRule reqTcpCont = new TcpContRule();
+            reqTcpCont.setTransactionId("-1");
+            reqTcpCont.setServiceCode(RuleDomain.RULE_SERVICE_CODE_DEFAULT);
+            reqTcpCont.setRuleType(RuleDomain.RULE_TYPE_DEFAULT);
+            reqTcpCont.setReqTime(df.format(new Date()));
+            contractRootRule.setTcpCont(reqTcpCont);
+            contractRootRule.setSvcCont(validateInfoJson);
+        }
+
+        return  ruleCommon(contractRootRule,validateInfoJson);
+    }
+
+
+
+
+    /**
+     * 业务规则校验实体转换
+     * @param reqJson
+     * @return
+     */
+    public String ruleCommon(ContractRootRule contractRootRule,JSONObject reqJson) throws Exception{
+            java.sql.Timestamp startTime = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+            long allStartTime = System.currentTimeMillis();
+
+            //调用规则校验
+            String ruleResult =  ruleEntrance(contractRootRule,reqJson);
+
+            //记录耗时明细
+            ruleCommon.recordCostTime(reqJson,
+                    System.currentTimeMillis()-allStartTime,
+                    "LTE4G全量规则校验总耗时",
+                    1,
+                    startTime,
+                    new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+
+            return ruleResult;
+        }
+
+
+    /**
+     * 业务规则入口
+     * @param contractRootRule
+     * @return
+     */
+    public String ruleEntrance(ContractRootRule contractRootRule,JSONObject reqJson) throws Exception{
+        long ruleEntranceStartTime = System.currentTimeMillis();
+        java.sql.Timestamp ruleEntranceStart = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+        String transactionId = contractRootRule.getTcpCont().getTransactionId();
+
+        String roamFlag = RuleDomain.RULE_COND_RETURN_0000;
+            String depPrvncSaopRuleType = CodeMapUtil.getDynamicConstantValue("DEP_PRVNC_RULE_TYPE");
+            //获取表 Rule_Entrance 数据
+            Map<String,RuleEntrance> ruleEntranceMap = RuleUtil.getRuleEntranceMap();
+            int ruleCount = 0;
+            this.ruleCommon.init();
+
+            //当前分组下的规则编码集合
+            List ruleIdsInCurGroupList = RuleUtil.getRuleIdsInGroupByJson(reqJson.toJSONString());
+
+            //耗时明细信息集合
+            List costTimeMapList = new ArrayList();
+
+            List<String> ruleList = new ArrayList<String>();
+            //记录耗时明细-耗时明细信息
+            Map ruleEntranceDetailMap = new HashMap();
+            ruleEntranceDetailMap.put("TRANSACTION_ID", contractRootRule.getTcpCont().getTransactionId());
+            ruleEntranceDetailMap.put("COST_TIME", System.currentTimeMillis()-ruleEntranceStartTime);
+            ruleEntranceDetailMap.put("REMARK", "LTE4G全量校验规则对象转换耗时");
+            ruleEntranceDetailMap.put("DO_WHAT", "LTE4G全量校验规则对象转换耗时");
+            ruleEntranceDetailMap.put("CLASS_FLAG", 2);
+            ruleEntranceDetailMap.put("START_TIME", ruleEntranceStart);
+            ruleEntranceDetailMap.put("FINISH_TIME", new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+            costTimeMapList.add(ruleEntranceDetailMap);
+            for (RuleEntrance ruleEntrance : ruleEntranceMap.values()) {
+                //add begin by dongchao 对业务规则校验增加分组逻辑 2015/6/6
+                if(!ruleIdsInCurGroupList.contains(ruleEntrance.getRule_id()))
+                {
+                    continue;
+                }
+                long allStartTime = System.currentTimeMillis();
+                java.sql.Timestamp startTime = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
+
+                String ruleCondition = ruleEntrance.getRule_condition();
+
+                //BO_ACTION_TYPE入口检查
+                if(!StringUtils.isEmpty(ruleCondition)){
+                    if(!ruleCondition(ruleEntrance,reqJson)){
+                        continue;
+                    }
+                }
+
+                //记录耗时明细-耗时明细信息
+                Map detailMap = new HashMap();
+                detailMap.put("TRANSACTION_ID", contractRootRule.getTcpCont().getTransactionId());
+                detailMap.put("COST_TIME", System.currentTimeMillis()-allStartTime);
+                detailMap.put("REMARK", "LTE4G全量校验规则入口判断耗时[ruleId:"+ruleEntrance.getRule_id()+"]");
+                detailMap.put("DO_WHAT", "LTE4G全量校验规则入口判断耗时[ruleId:"+ruleEntrance.getRule_id()+"]");
+                detailMap.put("CLASS_FLAG", 2);
+                detailMap.put("START_TIME", startTime);
+                detailMap.put("FINISH_TIME", new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
+                costTimeMapList.add(detailMap);
+
+                //调用规则条件
+                if(StringUtils.isEmpty(depPrvncSaopRuleType) || !depPrvncSaopRuleType.equals("1")){//不配置或配置不是1 为多线程并发调用模式
+                    ruleCount ++;
+                    ruleList.add(ruleEntrance.getRule_id());
+                }else{//配置1为单线程串行调用模式
+                    Rule rule = RuleUtil.getRuleMap().get(ruleEntrance.getRule_id());
+                    String url = rule.getRule_url();
+                    String entranceRetrunXml = "";
+                    if(!StringUtils.isEmpty(url)){
+                        if(rule.getRule_type().contains(RuleDomain.RULE_TYPE_COND_CFG)){
+                            entranceRetrunXml = ruleCommon.ruleCommonCondMed(ruleEntrance.getRule_id(),contractRootRule,reqJson);
+                        }else{
+                            entranceRetrunXml = ruleCommon.ruleCond(ruleEntrance.getRule_id(),contractRootRule);
+                        }
+
+                    }
+
+                    if(!StringUtils.isEmpty(entranceRetrunXml) && !entranceRetrunXml.equals(RuleDomain.RULE_COND_RETURN_0000)){
+                         //校验失败
+                         //校验失败返回
+                         return entranceRetrunXml;
+                    }
+                }
+            }
+
+            if((StringUtils.isEmpty(depPrvncSaopRuleType) || !depPrvncSaopRuleType.equals("1")) && ruleCount > 0){//不配置或配置不是1 为多线程并发调用模式
+                RuleCommonThread ruleCommonThread = new RuleCommonThread(ruleCommon,"",contractRootRule,reqJson,ruleCount,ruleList);
+                roamFlag = ruleCommonThread.getRuleRst();
+                //关闭线程池
+                ruleCommonThread.shutdownThreadPool();
+            }
+
+            //校验成功返回
+            if(!roamFlag.equals(RuleDomain.RULE_COND_RETURN_0000)){
+                //国漫免预存返回报文-特殊
+                return RuleUtil.ruleReturnJson(transactionId,RuleDomain.RULE_COND_RETURN_1999,roamFlag,"");
+            }else{
+                String serviceCode = contractRootRule.getTcpCont().getServiceCode();
+                return RuleUtil.ruleReturnJson(transactionId,RuleDomain.RULE_COND_RETURN_0000,"成功","");
+
+            }
+
+    }
+
+    /**
+     * 业务规则入口检查[Rule_condition]
+     * @param ruleEntrance,reqJson
+     * @return
+     */
+    public boolean ruleCondition(RuleEntrance ruleEntrance,JSONObject reqJson){
+        try {
+
+            String ruleCondition = ruleEntrance.getRule_condition();
+
+            JSONPath.eval(reqJson,ruleCondition);
+            //ruleCondition 入口检查
+            if(!StringUtils.isEmpty(JSONPath.eval(reqJson,ruleCondition))){
+                return true;
+            }
+
+        }catch (Exception e) {
+            logger.error("----------[RuleServiceSMOImpl.ruleCondition]-----------条件判断异常:规则条件为 "
+                    +JSONObject.toJSONString(ruleEntrance)+",请求报文为 "+reqJson);
+        }
+        return false;
+    }
+
+
+    public RuleCommon getRuleCommon() {
+        return ruleCommon;
+    }
+
+    public void setRuleCommon(RuleCommon ruleCommon) {
+        this.ruleCommon = ruleCommon;
+    }
+}

+ 159 - 0
RuleService/src/main/java/com/java110/rule/thread/RuleCommonThread.java

@@ -0,0 +1,159 @@
+package com.java110.rule.thread;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.RuleDomain;
+import com.java110.common.log.LoggerEngine;
+import com.java110.common.util.CodeMapUtil;
+import com.java110.common.util.RuleUtil;
+import com.java110.entity.rule.ContractRootRule;
+import com.java110.entity.rule.Rule;
+import com.java110.rule.common.RuleCommon;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.*;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+public class RuleCommonThread extends LoggerEngine{
+
+
+    private RuleCommon ruleCommon;
+
+    private String ruleId;
+    private JSONObject reqJson;
+    private ContractRootRule contractRootRule;
+    private int threadNum;
+    private ExecutorService rulethreadPool;
+
+    private CompletionService<String> ruleCompletionService;
+
+    public RuleCommonThread(RuleCommon ruleCommon, String ruleId,
+                            ContractRootRule contractRootRule,JSONObject reqJson,int threadNum,List<String> ruleList){
+//		super();
+        this.ruleCommon = ruleCommon;
+        this.ruleId = ruleId;
+        this.contractRootRule = contractRootRule;
+        this.reqJson = reqJson;
+        this.threadNum = threadNum;
+//		this.start();
+        this.ruleCurThread(ruleList);
+    }
+
+    //启动校验线程
+    public void ruleCurThread(List<String> ruleList){
+        rulethreadPool = Executors.newFixedThreadPool(threadNum);
+        ruleCompletionService = new ExecutorCompletionService<String>(rulethreadPool);
+        //往线程池里面加入线程对象
+        for(final String ruleIdStr : ruleList){
+            ruleCompletionService.submit(new Callable<String>(){
+                public String call() throws Exception{
+                    try {
+                        Map<String,Rule> ruleMap = RuleUtil.getRuleMap();
+                        Rule rule = ruleMap.get(ruleIdStr);
+                        String url = rule.getRule_url();
+                        String condRtn = "";
+                        if(!StringUtils.isEmpty(url)){
+                            if(rule.getRule_type().contains(RuleDomain.RULE_TYPE_COND_CFG)){
+                                condRtn = ruleCommon.ruleCommonCondMed(ruleIdStr,contractRootRule,reqJson);
+                            }else{
+                                condRtn = ruleCommon.ruleCond(ruleIdStr,contractRootRule);
+                            }
+                        }
+                        if(!StringUtils.isEmpty(condRtn)){
+                            return condRtn;
+                        }else{
+                            //默认返回成功
+                            return RuleDomain.RULE_COND_RETURN_0000;
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        //动态常量DEP_PRVNC_RULE_ERROR_RET,不配置或配置不是1,则程序异常默认返回成功,其他返回具体异常信息
+                        String depPrvncSaopRuleErrorRet = CodeMapUtil.getDynamicConstantValue("DEP_PRVNC_RULE_ERROR_RET");
+                        if(StringUtils.isEmpty(depPrvncSaopRuleErrorRet) || !depPrvncSaopRuleErrorRet.equals("1")){
+                            return RuleDomain.RULE_COND_RETURN_0000;
+                        }else{
+                            return "LTE4G全量校验规则条件判断环节异常[ruleId:"+ruleIdStr+"]:"+e.getMessage();
+                        }
+                    }
+                }
+            });
+        }
+    }
+
+    //获取执行结果
+    public String getRuleRst(){
+        String retStr = RuleDomain.RULE_COND_RETURN_0000;
+        for(int i=0; i<this.threadNum; i++){
+            //检索并移除表示下一个已完成任务的 Future,如果目前不存在这样的任务,则等待。
+            try {
+                String ruleRst = ruleCompletionService.take().get();
+                if(RuleDomain.RULE_COND_RETURN_0000.equals(ruleRst)){//校验成功
+
+                }else if(RuleDomain.RULE_COND_RETURN_0003.equals(ruleRst)
+                        || RuleDomain.RULE_COND_RETURN_0004.equals(ruleRst)){//国漫预存款校验
+                    retStr = ruleRst;
+                }else{//校验失败
+                    return ruleRst;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                //动态常量DEP_PRVNC_RULE_ERROR_RET,不配置或配置不是1,则程序异常默认返回成功,其他返回具体异常信息
+                String depPrvncSaopRuleErrorRet = CodeMapUtil.getDynamicConstantValue("DEP_PRVNC_RULE_ERROR_RET");
+                if(StringUtils.isEmpty(depPrvncSaopRuleErrorRet) || !depPrvncSaopRuleErrorRet.equals("1")){
+
+                }else{
+                    return "LTE4G全量校验规则条件判断环节异常:"+e.getMessage();
+                }
+            }
+        }
+        return retStr;
+    }
+
+    //关闭线程池
+    public void shutdownThreadPool(){
+        rulethreadPool.shutdown();
+    }
+
+    public void run() {
+        Rule rule = null;
+        try{
+            Map<String,Rule> ruleMap = RuleUtil.getRuleMap();
+            rule = ruleMap.get(ruleId);
+            String url = rule.getRule_url();
+            String condRtn = "";
+            if(!StringUtils.isEmpty(url)){
+                if(rule.getRule_type().contains(RuleDomain.RULE_TYPE_COND_CFG)){
+                    condRtn = this.ruleCommon.ruleCommonCondMed(ruleId,contractRootRule,this.reqJson);
+                }else{
+                    condRtn = this.ruleCommon.ruleCond(ruleId,contractRootRule);
+                }
+            }
+
+            if(!StringUtils.isEmpty(condRtn)){
+                if(condRtn.equals(RuleDomain.RULE_COND_RETURN_0000)){//成功
+                    this.ruleCommon.setRuleCondRtn(this.ruleCommon.getRuleCondRtn()+"0,");
+                }else{//失败
+                    this.ruleCommon.setRuleCode(RuleDomain.RULE_COND_RETURN_1999);
+                    this.ruleCommon.setRuleMsg(condRtn);
+                    this.ruleCommon.setRuleCondRtn(this.ruleCommon.getRuleCondRtn()+"1,");
+
+                }
+            }else{
+                this.ruleCommon.setRuleCondRtn(this.ruleCommon.getRuleCondRtn()+"0,");//默认成功
+            }
+        } catch (Exception e) {
+            logger.error("校验异常",e);
+            this.ruleCommon.setRuleCondRtn(this.ruleCommon.getRuleCondRtn()+"0,");//默认成功
+            /*try {
+                //记录错误日志
+                this.ruleCommon.recordRuleLog(rule,e.getMessage(),"LTE4G全量校验规则条件判断环节异常[ruleId:"+ruleId+"]");
+
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }*/
+        }
+    }
+}

+ 33 - 0
bean/src/main/java/com/java110/entity/rule/ContractRootRule.java

@@ -0,0 +1,33 @@
+package com.java110.entity.rule;
+
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ * 请求报文封装
+ * Created by wuxw on 2017/7/23.
+ */
+public class ContractRootRule {
+
+
+    private TcpContRule tcpCont;
+
+
+    private JSONObject svcCont;
+
+
+    public TcpContRule getTcpCont() {
+        return tcpCont;
+    }
+
+    public void setTcpCont(TcpContRule tcpCont) {
+        this.tcpCont = tcpCont;
+    }
+
+    public JSONObject getSvcCont() {
+        return svcCont;
+    }
+
+    public void setSvcCont(JSONObject svcCont) {
+        this.svcCont = svcCont;
+    }
+}

+ 101 - 0
bean/src/main/java/com/java110/entity/rule/Rule.java

@@ -0,0 +1,101 @@
+package com.java110.entity.rule;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 业务规则主体
+ * Created by wuxw on 2017/7/23.
+ */
+public class Rule {
+
+    private String rule_id;
+
+    private String rule_code;
+
+    private String rule_level;
+
+    private String rule_name;
+
+    private String rule_desc;
+
+    private String rule_type;
+
+    private String rule_url;
+
+    private Date create_dt;
+
+    private List<RuleCondCfg> ruleCondCfgs;
+
+    public String getRule_id() {
+        return rule_id;
+    }
+
+    public void setRule_id(String rule_id) {
+        this.rule_id = rule_id;
+    }
+
+    public String getRule_code() {
+        return rule_code;
+    }
+
+    public void setRule_code(String rule_code) {
+        this.rule_code = rule_code;
+    }
+
+    public String getRule_level() {
+        return rule_level;
+    }
+
+    public void setRule_level(String rule_level) {
+        this.rule_level = rule_level;
+    }
+
+    public String getRule_name() {
+        return rule_name;
+    }
+
+    public void setRule_name(String rule_name) {
+        this.rule_name = rule_name;
+    }
+
+    public String getRule_desc() {
+        return rule_desc;
+    }
+
+    public void setRule_desc(String rule_desc) {
+        this.rule_desc = rule_desc;
+    }
+
+    public String getRule_type() {
+        return rule_type;
+    }
+
+    public void setRule_type(String rule_type) {
+        this.rule_type = rule_type;
+    }
+
+    public String getRule_url() {
+        return rule_url;
+    }
+
+    public void setRule_url(String rule_url) {
+        this.rule_url = rule_url;
+    }
+
+    public Date getCreate_dt() {
+        return create_dt;
+    }
+
+    public void setCreate_dt(Date create_dt) {
+        this.create_dt = create_dt;
+    }
+
+    public List<RuleCondCfg> getRuleCondCfgs() {
+        return ruleCondCfgs;
+    }
+
+    public void setRuleCondCfgs(List<RuleCondCfg> ruleCondCfgs) {
+        this.ruleCondCfgs = ruleCondCfgs;
+    }
+}

+ 165 - 0
bean/src/main/java/com/java110/entity/rule/RuleCondCfg.java

@@ -0,0 +1,165 @@
+package com.java110.entity.rule;
+
+import java.util.Date;
+
+/**
+ *
+ * Created by wuxw on 2017/7/23.
+ */
+public class RuleCondCfg {
+
+    private String rule_id;
+    private String rule_node;
+    private String data_from_flag;
+    private String db_sql;
+    private String default_value;
+    private String node_existed;
+    private String proc_param_flag;
+    private String is_reverse;
+    private String is_log;
+    private String error_code;
+    private String error_msg;
+    private String remark;
+    private String seq;
+    private String data_stack_flag_prefix;
+    private String jpath;
+    private String status_cd;
+    private Date create_dt;
+
+
+    public String getRule_id() {
+        return rule_id;
+    }
+
+    public void setRule_id(String rule_id) {
+        this.rule_id = rule_id;
+    }
+
+    public String getRule_node() {
+        return rule_node;
+    }
+
+    public void setRule_node(String rule_node) {
+        this.rule_node = rule_node;
+    }
+
+    public String getData_from_flag() {
+        return data_from_flag;
+    }
+
+    public void setData_from_flag(String data_from_flag) {
+        this.data_from_flag = data_from_flag;
+    }
+
+    public String getDb_sql() {
+        return db_sql;
+    }
+
+    public void setDb_sql(String db_sql) {
+        this.db_sql = db_sql;
+    }
+
+    public String getDefault_value() {
+        return default_value;
+    }
+
+    public void setDefault_value(String default_value) {
+        this.default_value = default_value;
+    }
+
+    public String getNode_existed() {
+        return node_existed;
+    }
+
+    public void setNode_existed(String node_existed) {
+        this.node_existed = node_existed;
+    }
+
+    public String getProc_param_flag() {
+        return proc_param_flag;
+    }
+
+    public void setProc_param_flag(String proc_param_flag) {
+        this.proc_param_flag = proc_param_flag;
+    }
+
+    public String getIs_reverse() {
+        return is_reverse;
+    }
+
+    public void setIs_reverse(String is_reverse) {
+        this.is_reverse = is_reverse;
+    }
+
+    public String getIs_log() {
+        return is_log;
+    }
+
+    public void setIs_log(String is_log) {
+        this.is_log = is_log;
+    }
+
+    public String getError_code() {
+        return error_code;
+    }
+
+    public void setError_code(String error_code) {
+        this.error_code = error_code;
+    }
+
+    public String getError_msg() {
+        return error_msg;
+    }
+
+    public void setError_msg(String error_msg) {
+        this.error_msg = error_msg;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getSeq() {
+        return seq;
+    }
+
+    public void setSeq(String seq) {
+        this.seq = seq;
+    }
+
+    public String getData_stack_flag_prefix() {
+        return data_stack_flag_prefix;
+    }
+
+    public void setData_stack_flag_prefix(String data_stack_flag_prefix) {
+        this.data_stack_flag_prefix = data_stack_flag_prefix;
+    }
+
+    public String getJpath() {
+        return jpath;
+    }
+
+    public void setJpath(String jpath) {
+        this.jpath = jpath;
+    }
+
+    public String getStatus_cd() {
+        return status_cd;
+    }
+
+    public void setStatus_cd(String status_cd) {
+        this.status_cd = status_cd;
+    }
+
+    public Date getCreate_dt() {
+        return create_dt;
+    }
+
+    public void setCreate_dt(Date create_dt) {
+        this.create_dt = create_dt;
+    }
+}

+ 49 - 0
bean/src/main/java/com/java110/entity/rule/RuleEntrance.java

@@ -0,0 +1,49 @@
+package com.java110.entity.rule;
+
+import java.util.Date;
+
+/**
+ * 对应表rule_entrance
+ * Created by wuxw on 2017/7/23.
+ */
+public class RuleEntrance {
+
+    private String rule_id;
+
+    private String rule_condition;
+
+    private String status_cd;
+    private Date create_dt;
+
+    public String getRule_id() {
+        return rule_id;
+    }
+
+    public void setRule_id(String rule_id) {
+        this.rule_id = rule_id;
+    }
+
+    public String getRule_condition() {
+        return rule_condition;
+    }
+
+    public void setRule_condition(String rule_condition) {
+        this.rule_condition = rule_condition;
+    }
+
+    public String getStatus_cd() {
+        return status_cd;
+    }
+
+    public void setStatus_cd(String status_cd) {
+        this.status_cd = status_cd;
+    }
+
+    public Date getCreate_dt() {
+        return create_dt;
+    }
+
+    public void setCreate_dt(Date create_dt) {
+        this.create_dt = create_dt;
+    }
+}

+ 52 - 0
bean/src/main/java/com/java110/entity/rule/TcpContRule.java

@@ -0,0 +1,52 @@
+package com.java110.entity.rule;
+
+/**
+ * 头部信息封装
+ * "RuleType":"RULE0001", -- 用来区分走那个规则组
+ "ServiceCode": "SVC0001", -- 用来判断走那些规则
+ "TransactionID": "1001000101201603081234567890", -- 交易流水
+ "ReqTime": "20130817200202123",--请求时间
+ * Created by wuxw on 2017/7/23.
+ */
+public class TcpContRule {
+
+    private String ruleType;
+
+    private String serviceCode;
+
+    private String transactionId;
+
+    private String reqTime;
+
+    public String getRuleType() {
+        return ruleType;
+    }
+
+    public void setRuleType(String ruleType) {
+        this.ruleType = ruleType;
+    }
+
+    public String getServiceCode() {
+        return serviceCode;
+    }
+
+    public void setServiceCode(String serviceCode) {
+        this.serviceCode = serviceCode;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+
+    public String getReqTime() {
+        return reqTime;
+    }
+
+    public void setReqTime(String reqTime) {
+        this.reqTime = reqTime;
+    }
+}

+ 60 - 0
common/src/main/java/com/java110/common/constant/RuleDomain.java

@@ -0,0 +1,60 @@
+package com.java110.common.constant;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+public class RuleDomain {
+
+
+    //RULE_COND_RETURN
+    public static final String RULE_COND_RETURN_0000 = "0000";//成功
+    public static final String RULE_COND_RETURN_0001 = "0001";//继续调存过校验
+    public static final String RULE_COND_RETURN_0002 = "0002";//存过校验失败
+    public static final String RULE_COND_RETURN_0003 = "0003";//国漫预存款校验-免预存
+    public static final String RULE_COND_RETURN_0004 = "0004";//国漫预存款校验-不免预存
+    public static final String RULE_COND_RETURN_0005 = "0005";//JAVA校验失败
+    public static final String RULE_COND_RETURN_0006 = "0006";//特定员工不需要校验
+    public static final String RULE_COND_RETURN_1999 = "1999";//程序异常
+
+
+    /**
+     * 规则编码默认值
+     */
+    public static final String RULE_SERVICE_CODE_DEFAULT = "SVC0000";
+    /**
+     * 规则类型
+     */
+    public static final String RULE_TYPE_DEFAULT = "RULE0000";
+
+
+    /*******************************************规则实现方式***************************************/
+
+    public static final String RULE_TYPE_JAVA_METHOD = "1";//1 反射调用java 方法实现,
+
+    public static final String RULE_TYPE_COND_CFG = "2";//2 通过 rule_cond_cfg 配置逻辑实现
+
+    public static final String RULE_TYPE_STORED_PROCEDURE = "3" ;//3 调用存储过程实现,存储过程入参可以在rule_cond_cfg 表中配置
+
+
+
+
+    //分隔符
+    public final static String RULE_SIGN_1 = "@@";
+    public final static String RULE_SIGN_2 = "$-";
+    public final static String RULE_SIGN_3 = "'";
+    public final static String RULE_SIGN_4 = ",";
+    public final static String RULE_SIGN_5 = "#";
+    public final static String RULE_SIGN_6 = ">";
+    public final static String RULE_SIGN_7 = "@";
+    public final static String RULE_SIGN_8 = ".";
+    public final static String RULE_SIGN_9 = ";";
+
+    public final static String RULE_IS_Y = "Y";
+    public final static String RULE_IS_N = "N";
+
+
+
+    public static final String PART_STRING_ORIGINAL_VALUE = "ORIGINAL_VALUE"; //表示字符串:ORIGINAL_VALUE,含义是在处理字符串时表示没有被任何改变的“原始值”标识
+
+
+}

+ 1 - 0
common/src/main/java/com/java110/common/util/ConstantUtil.java

@@ -132,4 +132,5 @@ public class ConstantUtil {
 
 
 
+
 }

+ 124 - 0
common/src/main/java/com/java110/common/util/RuleUtil.java

@@ -0,0 +1,124 @@
+package com.java110.common.util;
+
+import com.java110.common.log.LoggerEngine;
+import com.java110.entity.rule.Rule;
+import com.java110.entity.rule.RuleEntrance;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by wuxw on 2017/7/23.
+ */
+public class RuleUtil extends LoggerEngine{
+
+   public static Map<String,RuleEntrance> getRuleEntranceMap(){
+
+       return null;
+   }
+
+    /**
+     * 获取规则组
+     * @return
+     */
+    public static List getRuleGroupRelaList() {
+        return null;
+    }
+
+
+    public static Map<String, Rule> getRuleMap() {
+        return null;
+    }
+
+
+    /**
+     * 根据传入的json从缓存中获取规则分组下的规则编码集合
+     * @param reqJson
+     * @return   如果获取不到则会返回new ArrayList(),不会为null
+     */
+    public static List getRuleIdsInGroupByJson(String reqJson)
+    {
+        //获取缓存中规则分组集合
+        List saopRuleGroupInfoList = RuleUtil.getRuleGroupRelaList();
+
+        //当前分组下的规则编码集合
+        List ruleIdsInCurGroupList = new ArrayList();
+
+        try
+        {
+            int saopRuleGroupInfoListSize = saopRuleGroupInfoList.size();
+            if(saopRuleGroupInfoListSize > 0)
+            {
+                for(int i = 0; i < saopRuleGroupInfoListSize; i++)
+                {
+                    Map ruleGroupMap = (Map)saopRuleGroupInfoList.get(i);
+
+                    //获取集团报文中的关键信息片断,用于报文分析时定位当前转换场景
+                    String keyIdentifyLogicInfo = "";
+                    if(null != ruleGroupMap.get("KEY_IDENTIFY_LOGIC_STR"))
+                    {
+                        keyIdentifyLogicInfo = String.valueOf(ruleGroupMap.get("KEY_IDENTIFY_LOGIC_STR"));
+                    }
+
+                    if(!StringUtil.isEmpty(keyIdentifyLogicInfo))
+                    {
+                        //对逻辑字符串进行分析和运算
+                        boolean logicMatchRtn = StringJsonDeal.logicCalculus(reqJson,keyIdentifyLogicInfo);
+
+                        if(logicMatchRtn)
+                        {
+                            if(null != ruleGroupMap.get("ruleIdList"))
+                            {
+                                ruleIdsInCurGroupList = (List)ruleGroupMap.get("ruleIdList");
+                            }
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        if(null != ruleGroupMap.get("ruleIdList"))
+                        {
+                            ruleIdsInCurGroupList = (List)ruleGroupMap.get("ruleIdList");
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+        catch(Exception e)
+        {
+            e.printStackTrace();
+            if(logger.isErrorEnabled())
+            {
+                logger.error("CodeMapUtil.getRuleIdsInGroupByXml执行出错,错误信息:" + e.toString());
+            }
+        }
+        return ruleIdsInCurGroupList;
+    }
+
+    /**
+     * 拼装业务规则校验返回报文
+     * @param
+     * @return
+     */
+    public static String ruleReturnJson(String transactionId,String ruleCode,String ruleDesc,String ruleType){
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
+        StringBuffer returnJson = new StringBuffer("{")
+                .append("\"ContractRoot\":{")
+                .append("\"TcpCont\":{")
+                .append("\"TransactionID\":\"").append(transactionId).append("\",")
+                .append("\"RspTime\":\"").append(df.format(new Date())).append("\",")
+                .append("\"RspType\":\"").append(ruleType).append("\",")
+                .append("\"RspCode\":").append(ruleCode).append("\",")
+                .append("\"RspDesc\":").append(ruleDesc).append("\"")
+                .append("}")
+                .append("}");
+        return returnJson.toString();
+    }
+
+
+
+}

+ 41 - 0
common/src/main/java/com/java110/common/util/SpringBeanInvoker.java

@@ -0,0 +1,41 @@
+package com.java110.common.util;
+
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpringBeanInvoker implements ApplicationContextAware {
+
+    private static ApplicationContext applicationContext;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        if(SpringBeanInvoker.applicationContext == null) {
+            SpringBeanInvoker.applicationContext = applicationContext;
+        }
+    }
+
+    //获取applicationContext
+    public static ApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+    //通过name获取 Bean.
+    public static Object getBean(String name){
+        return getApplicationContext().getBean(name);
+    }
+
+    //通过class获取Bean.
+    public static <T> T getBean(Class<T> clazz){
+        return getApplicationContext().getBean(clazz);
+    }
+
+    //通过name,以及Clazz返回指定的Bean
+    public static <T> T getBean(String name,Class<T> clazz){
+        return getApplicationContext().getBean(name, clazz);
+    }
+
+}

+ 172 - 0
common/src/main/java/com/java110/common/util/StringJsonDeal.java

@@ -0,0 +1,172 @@
+package com.java110.common.util;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.RuleDomain;
+import com.java110.common.log.LoggerEngine;
+
+import java.text.SimpleDateFormat;
+
+/**
+ * JSON 格式字符串解析
+ * Created by wuxw on 2017/7/23.
+ */
+public class StringJsonDeal extends LoggerEngine{
+
+
+    private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMddHHmmss");
+
+    private JSONObject jsonObject = null;
+
+    public StringJsonDeal(String jsonString){
+        try {
+            jsonObject = JSONObject.parseObject(jsonString);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+
+
+    public StringJsonDeal(JSONObject jsonObject) {
+        this.jsonObject = jsonObject;
+    }
+
+
+
+
+    /**
+     * 对逻辑字符串进行分析和运算
+     *
+     * @param jsonString
+     * @param keyIdentifyLogicInfo
+     * @return
+     * @throws
+     */
+    public static boolean logicCalculus(String jsonString, String keyIdentifyLogicInfo) throws Exception {
+        final String PART_STRING_DBL_AMPERSAND = "&&"; //表示字符串:&&
+        final String PART_STRING_DBL_VERTICAL_BAR = "||"; //表示字符串:||
+        final String PART_STRING_L_BIG_BRACKET = "{"; //表示字符串:{
+        final String PART_STRING_R_BIG_BRACKET = "}"; //表示字符串:}
+        final String PRVT_TRUE_STR = "1";
+        final String PRVT_FALSE_STR = "0";
+        final String PRVT_OR_BLANK_STR = " || ";
+        String keyIdentifyLogicStr = keyIdentifyLogicInfo; //动态变化的关键判断逻辑信息
+        while (keyIdentifyLogicStr.contains(PART_STRING_L_BIG_BRACKET)
+                && keyIdentifyLogicStr.contains(PART_STRING_R_BIG_BRACKET)
+                || keyIdentifyLogicStr.contains(PART_STRING_DBL_AMPERSAND)
+                || keyIdentifyLogicStr.contains(PART_STRING_DBL_VERTICAL_BAR)
+                || !PRVT_TRUE_STR.equals(keyIdentifyLogicStr) && !PRVT_FALSE_STR.equals(keyIdentifyLogicStr)) {
+            int leftBigBracketPosition = 0; //最内左大括号的位置
+            int rightBigBracketPosition = 0; //最内右大括号的位置
+            String curProcessStr = keyIdentifyLogicStr; //当前要处理的字符串片断
+            if (keyIdentifyLogicStr.contains(PART_STRING_L_BIG_BRACKET)
+                    && keyIdentifyLogicStr.contains(PART_STRING_R_BIG_BRACKET)) {
+                leftBigBracketPosition = keyIdentifyLogicStr.lastIndexOf(PART_STRING_L_BIG_BRACKET);
+                rightBigBracketPosition = keyIdentifyLogicStr
+                        .indexOf(PART_STRING_R_BIG_BRACKET, leftBigBracketPosition);
+                curProcessStr = keyIdentifyLogicStr.substring(leftBigBracketPosition + 1, rightBigBracketPosition);
+            }
+            String rsltLogicStr = "";
+            if (curProcessStr.contains(PART_STRING_DBL_VERTICAL_BAR)) {
+                String[] orLogicStrs = curProcessStr.split("\\|\\|"); //“或”逻辑信息
+                int orLogicStrNum = orLogicStrs.length;
+                String curOrLogicStr = "";
+                String curAndLogicStr = "";
+                String orLogicStr = "";
+                String andLogicStr = "";
+                boolean hasTrue = false;
+                for (int i = 0; i < orLogicStrNum; i++) {
+                    curOrLogicStr = orLogicStrs[i];
+                    if (null != curOrLogicStr) {
+                        curOrLogicStr = curOrLogicStr.trim();
+                    }
+                    if (null == curOrLogicStr || "".equals(curOrLogicStr)) {
+                        throw new Exception("字段配置错误,两个||之间不能没有信息");
+                    }
+                    orLogicStr = PRVT_FALSE_STR;
+                    if (curOrLogicStr.contains(PART_STRING_DBL_AMPERSAND)) {
+                        String[] andLogicStrs = curOrLogicStr.split(PART_STRING_DBL_AMPERSAND); //“与”逻辑信息
+                        int andLogicStrNum = andLogicStrs.length;
+                        andLogicStr = PRVT_TRUE_STR;
+                        for (int j = 0; j < andLogicStrNum; j++) {
+                            curAndLogicStr = andLogicStrs[j];
+                            if (null != curAndLogicStr) {
+                                curAndLogicStr = curAndLogicStr.trim();
+                            }
+                            if (null == curAndLogicStr || "".equals(curAndLogicStr)) {
+                                throw new Exception("字段配置错误,两个&&之间不能没有信息");
+                            }
+                            if (!jsonString.contains(curAndLogicStr) || PRVT_FALSE_STR.equals(curAndLogicStr)) {
+                                andLogicStr = PRVT_FALSE_STR;
+                                break;
+                            }
+                        }
+                        if ("".equals(rsltLogicStr)) {
+                            rsltLogicStr = andLogicStr;
+                        } else {
+                            rsltLogicStr += PRVT_OR_BLANK_STR + andLogicStr;
+                        }
+                    } else {
+                        if (jsonString.contains(curOrLogicStr) || PRVT_TRUE_STR.equals(curOrLogicStr)) {
+                            if (!hasTrue) {
+                                orLogicStr = PRVT_TRUE_STR;
+                                if ("".equals(rsltLogicStr)) {
+                                    rsltLogicStr = orLogicStr;
+                                } else {
+                                    rsltLogicStr += PRVT_OR_BLANK_STR + orLogicStr;
+                                }
+                                hasTrue = true;
+                            }
+                        }
+                    }
+                }
+                if (!hasTrue) {
+                    if ("".equals(rsltLogicStr)) {
+                        rsltLogicStr = orLogicStr;
+                    } else {
+                        rsltLogicStr += PRVT_OR_BLANK_STR + orLogicStr;
+                    }
+                }
+            } else if (curProcessStr.contains(PART_STRING_DBL_AMPERSAND)) {
+                String[] andLogicStrs = curProcessStr.split(PART_STRING_DBL_AMPERSAND); //“与”逻辑信息
+                int andLogicStrNum = andLogicStrs.length;
+                String curAndLogicStr = "";
+                String andLogicStr = PRVT_TRUE_STR;
+                for (int j = 0; j < andLogicStrNum; j++) {
+                    curAndLogicStr = andLogicStrs[j];
+                    if (null != curAndLogicStr) {
+                        curAndLogicStr = curAndLogicStr.trim();
+                    }
+                    if (null == curAndLogicStr || "".equals(curAndLogicStr)) {
+                        throw new Exception("字段配置错误,两个&&之间不能没有信息");
+                    }
+                    if (!jsonString.contains(curAndLogicStr) || PRVT_FALSE_STR.equals(curAndLogicStr)) {
+                        andLogicStr = PRVT_FALSE_STR;
+                        break;
+                    }
+                }
+                rsltLogicStr = andLogicStr;
+            } else {
+                String andLogicStr = PRVT_TRUE_STR;
+                if (!jsonString.contains(curProcessStr) || PRVT_FALSE_STR.equals(curProcessStr)) {
+                    andLogicStr = PRVT_FALSE_STR;
+                }
+                rsltLogicStr = andLogicStr;
+            }
+            logger.debug("替换前判断逻辑字符串(keyIdentifyLogicStr) :{}", keyIdentifyLogicStr);
+            logger.debug("当前用于替换的逻辑字符串(rsltLogicStr) :{}", rsltLogicStr);
+            if (0 != rightBigBracketPosition) {
+                keyIdentifyLogicStr = keyIdentifyLogicStr.substring(0, leftBigBracketPosition) + rsltLogicStr
+                        + keyIdentifyLogicStr.substring(rightBigBracketPosition + 1);
+            } else {
+                keyIdentifyLogicStr = rsltLogicStr;
+            }
+            logger.debug("替换后判断逻辑字符串(keyIdentifyLogicStr) :{}", keyIdentifyLogicStr);
+        }
+        if (PRVT_TRUE_STR.equals(keyIdentifyLogicStr)) {
+            return true;
+        }
+        return false;
+    }
+}

+ 5 - 6
config/db/rule.db

@@ -28,6 +28,9 @@ create table rule
   rule_code varchar(20) not null comment '规则编码',
   rule_name varchar(100) not null comment '规则名称',
   rule_desc varchar(2000) not null comment '规则描述',
+  rule_level        varchar(2) not null comment '规则级别,1 限制性 2 提示性',
+  rule_type         varchar(2) not null comment '规则实现方式,1 反射调用java 方法实现,2 通过 rule_cond_cfg 配置逻辑实现 3 调用存储过程实现,存储过程入参可以在rule_cond_cfg 表中配置'
+  rule_url          varchar(200) not null comment '对应于 rule_type 方式 1 时,写类路径加方法 如com.java110.rule.ARule#AMethod, 方式2 时,写成Common 方式 3 时写 过程名称'
   status_cd  varchar(2)  not null default '0' comment '状态,0-有效,1-无效',
   create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
 );
@@ -35,12 +38,8 @@ create table rule
 -- 规则入口表
 create table rule_entrance
 (
-
   rule_id           varchar(20) not null comment '规则ID',
-  rule_level        varchar(2) not null comment '规则级别,1 限制性 2 提示性',
-  rule_condition    varchar(200) not null comment '校验条件 jpath 语句,如果有值则走这个规则,没有值则不走这个规则,如果所有业务都走,写*号',
-  rule_type         varchar(2) not null comment '规则实现方式,1 反射调用java 方法实现,2 通过 rule_cond_cfg 配置逻辑实现 3 调用存储过程实现,存储过程入参可以在rule_cond_cfg 表中配置'
-  rule_url          varchar(200) not null comment '对应于 rule_type 方式 1 时,写类路径加方法 如com.java110.rule.ARule#AMethod, 方式2 时,写成Common 方式 3 时写 过程名称'
+  rule_condition    varchar(200) not null comment '校验条件 jpath 语句,如果有值则走这个规则,没有值则不走这个规则,如果所有业务都走,不写',
   status_cd  varchar(2)  not null default '0' comment '状态,0-有效,1-无效',
   create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
 );
@@ -54,7 +53,7 @@ create table rule_cond_cfg
   rule_node              varchar(30) not null comment '规则节点',
   data_from_flag         varchar(30) not null comment '规则节点取值方式 1从JSON中获取(jpath) 2从DB_SQL中取值、3从DEFULT_VALUE中取值、4从NODE_EXISTED中取值、5从堆栈中获取',
   db_sql                 varchar(3000) comment 'SQL语句',
-  defult_value           varchar(30) comment '默认值',
+  default_value           varchar(30) comment '默认值',
   node_existed           varchar(1000) comment '复用已存在规则节点',
   proc_param_flag        varchar(2) comment '标示此规则节点是否是存储过程入参',
   is_reverse             varchar(2) comment '规则校验是否取反',

+ 22 - 0
config/src/main/resources/mapper/rule/RuleDaoImplMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="ruleDaoImpl">
+
+    <parameterMap type="map" id="executeProMap">
+        <parameter property="transactionId" jdbcType="VARCHAR" mode="IN"/>
+        <parameter property="paramIn" jdbcType="VARCHAR" mode="IN"/>
+        <parameter property="paramOut" jdbcType="VARCHAR" mode="OUT"/>
+    </parameterMap>
+
+    <!-- 执行sql-->
+    <select id="executeSql"  resultType="java.util.HashMap" >
+        $sql$
+    </select>
+
+    <!-- 执行 存储过程 -->
+    <update id="executeProc" parameterMap="executeProMap" statementType="CALLABLE">
+        {call $procName$(?, ?, ?)}
+    </update>
+ </mapper>