Kaynağa Gözat

生成ID统一走codeService

wuxw7 7 yıl önce
ebeveyn
işleme
3d01961008
20 değiştirilmiş dosya ile 580 ekleme ve 68 silme
  1. 28 0
      CodeService/Readme.md
  2. 1 1
      CodeService/pom.xml
  3. 8 0
      CodeService/src/main/java/com/java110/CodeServiceApplicationStart.java
  4. 6 6
      CodeService/src/main/java/com/java110/code/dao/impl/CommonServiceDaoImpl.java
  5. 1 1
      CodeService/src/main/java/com/java110/code/rest/CommonServiceRest.java
  6. 1 1
      CodeService/src/main/java/com/java110/code/rest/PrimaryKeyServiceRest.java
  7. 1 1
      CodeService/src/main/resources/application.yml
  8. 3 3
      RuleService/src/main/java/com/java110/rule/dao/impl/RuleDaoImpl.java
  9. 2 1
      java110-common/src/main/java/com/java110/common/cache/BaseCache.java
  10. 4 0
      java110-common/src/main/java/com/java110/common/constant/MappingConstant.java
  11. 189 0
      java110-common/src/main/java/com/java110/common/exception/GenerateCodeException.java
  12. 189 0
      java110-common/src/main/java/com/java110/common/exception/ResponseErrorException.java
  13. 81 12
      java110-common/src/main/java/com/java110/common/util/SequenceUtil.java
  14. 14 12
      java110-config/db/CenterService/create_table.db
  15. 2 2
      java110-config/db/ConsoleService/create_table.db
  16. 22 22
      java110-config/db/UserService/create_table.db
  17. 8 1
      java110-config/src/main/resources/config/code/zookeeper.properties
  18. 2 1
      java110-core/src/main/java/com/java110/core/base/AppBase.java
  19. 4 4
      java110-core/src/main/java/com/java110/core/base/dao/BaseServiceDao.java
  20. 14 0
      java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java

+ 28 - 0
CodeService/Readme.md

@@ -0,0 +1,28 @@
+## 编码生成服务(ID生成)
+
+### 1、说明
+
+微小区平台的 主键生成全部交CodeService(编码生成服务) 同一生成,依赖redis,kafka,zookeeper,java8开源工具
+
+### 2、开发工具
+
+java1.8 + idea/eclipse + mysql
+
+### 3、服务安装说明
+
+a、安装mysql,kafka,redis,git ,maven (详细安装请Google或百度)
+
+b、git clone https://github.com/java110/MicroCommunity.git 下载代码
+
+c、在相应服务下(如:CenterService 服务) src/main/application.yml 中修改mysql地址、用户名和密码、kafka地址、redis地址
+
+d、进入MicroCommunity 目录 执行 mvn clean install 打包
+
+e、启动
+
+(1) 启动 eureka 命令为 java -jar eureka.jar
+(2) 启动 CodeService 命令为 java -jar CodeService.jar
+
+f、协议 访问[这里](MicroCommunity/wiki/系统ID生成协议)
+
+

+ 1 - 1
CodeService/pom.xml

@@ -10,7 +10,7 @@
     <artifactId>CodeService</artifactId>
     <artifactId>CodeService</artifactId>
     <packaging>jar</packaging>
     <packaging>jar</packaging>
 
 
-    <name>CommonService</name>
+    <name>CodeService</name>
     <url>http://maven.apache.org</url>
     <url>http://maven.apache.org</url>
 
 
     <properties>
     <properties>

+ 8 - 0
CodeService/src/main/java/com/java110/CodeServiceApplicationStart.java

@@ -17,11 +17,17 @@ import org.apache.zookeeper.*;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.data.Stat;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
 
 
 import java.net.InetAddress;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.net.UnknownHostException;
+import java.nio.charset.Charset;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -35,9 +41,11 @@ import java.util.List;
  */
  */
 @SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.core","com.java110.cache",
 @SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.core","com.java110.cache",
 "com.java110.config.properties.code"})
 "com.java110.config.properties.code"})
+//@SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.config.properties.code"})
 @EnableDiscoveryClient
 @EnableDiscoveryClient
 public class CodeServiceApplicationStart {
 public class CodeServiceApplicationStart {
 
 
+
     public static void main(String[] args) throws Exception {
     public static void main(String[] args) throws Exception {
 
 
         ApplicationContext context =  SpringApplication.run(CodeServiceApplicationStart.class, args);
         ApplicationContext context =  SpringApplication.run(CodeServiceApplicationStart.class, args);

+ 6 - 6
CodeService/src/main/java/com/java110/code/dao/impl/CommonServiceDaoImpl.java

@@ -29,7 +29,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Override
     @Override
     @Cacheable(key= "CodeMappingAll")
     @Cacheable(key= "CodeMappingAll")
     public List<CodeMapping> getCodeMappingAll() throws Exception{
     public List<CodeMapping> getCodeMappingAll() throws Exception{
-       Jedis jedis = jedisPool.getResource();
+       Jedis jedis = this.getJedis();
 
 
        List<CodeMapping> codeMappings = null;
        List<CodeMapping> codeMappings = null;
        if(jedis.exists("CodeMappingAll".getBytes())){
        if(jedis.exists("CodeMappingAll".getBytes())){
@@ -53,7 +53,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Cacheable(key= "CodeMappingByDomain")
     @Cacheable(key= "CodeMappingByDomain")
     public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception{
     public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception{
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = this.getJedis();
         List<CodeMapping> codeMappings = null;
         List<CodeMapping> codeMappings = null;
         if(jedis.exists("CodeMappingByDomain".getBytes())){
         if(jedis.exists("CodeMappingByDomain".getBytes())){
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomain".getBytes()),CodeMapping.class);
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomain".getBytes()),CodeMapping.class);
@@ -75,7 +75,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Cacheable(key= "CodeMappingByHCode")
     @Cacheable(key= "CodeMappingByHCode")
     public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping) throws Exception{
     public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping) throws Exception{
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = this.getJedis();
         List<CodeMapping> codeMappings = null;
         List<CodeMapping> codeMappings = null;
         if(jedis.exists("CodeMappingByHCode".getBytes())){
         if(jedis.exists("CodeMappingByHCode".getBytes())){
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByHCode".getBytes()),CodeMapping.class);
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByHCode".getBytes()),CodeMapping.class);
@@ -97,7 +97,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Cacheable(key= "CodeMappingByPCode")
     @Cacheable(key= "CodeMappingByPCode")
     public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception{
     public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception{
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = this.getJedis();
         List<CodeMapping> codeMappings = null;
         List<CodeMapping> codeMappings = null;
         if(jedis.exists("CodeMappingByPCode".getBytes())){
         if(jedis.exists("CodeMappingByPCode".getBytes())){
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByPCode".getBytes()),CodeMapping.class);
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByPCode".getBytes()),CodeMapping.class);
@@ -119,7 +119,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Cacheable(key= "CodeMappingByDomainAndHCode")
     @Cacheable(key= "CodeMappingByDomainAndHCode")
     public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception{
     public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception{
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = this.getJedis();
         List<CodeMapping> codeMappings = null;
         List<CodeMapping> codeMappings = null;
         if(jedis.exists("CodeMappingByDomainAndHCode".getBytes())){
         if(jedis.exists("CodeMappingByDomainAndHCode".getBytes())){
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndHCode".getBytes()),CodeMapping.class);
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndHCode".getBytes()),CodeMapping.class);
@@ -141,7 +141,7 @@ public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServi
     @Cacheable(key= "CodeMappingByDomainAndPCode")
     @Cacheable(key= "CodeMappingByDomainAndPCode")
     public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping)  throws Exception{
     public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping)  throws Exception{
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = this.getJedis();
         List<CodeMapping> codeMappings = null;
         List<CodeMapping> codeMappings = null;
         if(jedis.exists("CodeMappingByDomainAndPCode".getBytes())){
         if(jedis.exists("CodeMappingByDomainAndPCode".getBytes())){
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndPCode".getBytes()),CodeMapping.class);
             codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndPCode".getBytes()),CodeMapping.class);

+ 1 - 1
CodeService/src/main/java/com/java110/code/rest/CommonServiceRest.java

@@ -14,7 +14,7 @@ import java.util.List;
 /**
 /**
  * Created by wuxw on 2017/7/25.
  * Created by wuxw on 2017/7/25.
  */
  */
-@RestController
+//@RestController
 public class CommonServiceRest extends BaseController implements ICommonService{
 public class CommonServiceRest extends BaseController implements ICommonService{
 
 
     @Autowired
     @Autowired

+ 1 - 1
CodeService/src/main/java/com/java110/code/rest/PrimaryKeyServiceRest.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
  * 主键信息查询
  * 主键信息查询
  * Created by wuxw on 2017/4/5.
  * Created by wuxw on 2017/4/5.
  */
  */
-@RestController
+//@RestController
 public class PrimaryKeyServiceRest extends BaseController implements IPrimaryKeyService {
 public class PrimaryKeyServiceRest extends BaseController implements IPrimaryKeyService {
 
 
     @Autowired
     @Autowired

+ 1 - 1
CodeService/src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
 spring:
   profiles:
   profiles:
-    active: test
+    active: dev

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

@@ -67,7 +67,7 @@ public class RuleDaoImpl extends BaseServiceDao implements IRuleDao {
     @Cacheable(key=RuleDomain.REDIS_KEY_RULE_ENTRANCE)
     @Cacheable(key=RuleDomain.REDIS_KEY_RULE_ENTRANCE)
     public Map<String, RuleEntrance> getRuleEntranceMap() throws Exception {
     public Map<String, RuleEntrance> getRuleEntranceMap() throws Exception {
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = getJedis();
 
 
         Map map = new HashMap();
         Map map = new HashMap();
 
 
@@ -102,7 +102,7 @@ public class RuleDaoImpl extends BaseServiceDao implements IRuleDao {
     public List getRuleGroupRelaList() throws Exception {
     public List getRuleGroupRelaList() throws Exception {
         List saopRuleGroupRelaList = new ArrayList();
         List saopRuleGroupRelaList = new ArrayList();
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = getJedis();
 
 
         if(jedis.exists(RuleDomain.REDIS_KEY_RULE_ENTRANCE.getBytes())){
         if(jedis.exists(RuleDomain.REDIS_KEY_RULE_ENTRANCE.getBytes())){
             saopRuleGroupRelaList =  SerializeUtil.unserializeList(jedis.get(RuleDomain.REDIS_KEY_RULE_GROUP.getBytes()),Map.class);
             saopRuleGroupRelaList =  SerializeUtil.unserializeList(jedis.get(RuleDomain.REDIS_KEY_RULE_GROUP.getBytes()),Map.class);
@@ -168,7 +168,7 @@ public class RuleDaoImpl extends BaseServiceDao implements IRuleDao {
     @Cacheable(key=RuleDomain.REDIS_KEY_RULE)
     @Cacheable(key=RuleDomain.REDIS_KEY_RULE)
     public Map<String, Rule> getRuleMap() throws Exception {
     public Map<String, Rule> getRuleMap() throws Exception {
 
 
-        Jedis jedis = jedisPool.getResource();
+        Jedis jedis = getJedis();
 
 
         List<Rule> ruleList = null;
         List<Rule> ruleList = null;
 
 

+ 2 - 1
java110-common/src/main/java/com/java110/common/cache/BaseCache.java

@@ -2,6 +2,7 @@ package com.java110.common.cache;
 
 
 
 
 import com.java110.common.factory.ApplicationContextFactory;
 import com.java110.common.factory.ApplicationContextFactory;
+import com.java110.common.log.LoggerEngine;
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.JedisPool;
 import redis.clients.jedis.JedisPool;
 
 
@@ -11,7 +12,7 @@ import java.util.Set;
  * 缓存基类
  * 缓存基类
  * Created by wuxw on 2018/4/14.
  * Created by wuxw on 2018/4/14.
  */
  */
-public class BaseCache {
+public class BaseCache extends LoggerEngine{
 
 
     protected static Jedis getJedis(){
     protected static Jedis getJedis(){
         JedisPool jedisPool = (JedisPool) ApplicationContextFactory.getBean("jedisPool");
         JedisPool jedisPool = (JedisPool) ApplicationContextFactory.getBean("jedisPool");

+ 4 - 0
java110-common/src/main/java/com/java110/common/constant/MappingConstant.java

@@ -48,6 +48,10 @@ public class MappingConstant {
     //默认掩码
     //默认掩码
     public final static String KEY_DEFAULT_SECURITY_CODE = "DEFAULT_SECURITY_CODE";
     public final static String KEY_DEFAULT_SECURITY_CODE = "DEFAULT_SECURITY_CODE";
 
 
+    // 生成 编码路径
+    public final static String KEY_CODE_PATH = "CODE_PATH";
+
+
 
 
     /**
     /**
      * 中心服务地址
      * 中心服务地址

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/GenerateCodeException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 生成编码异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class GenerateCodeException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public GenerateCodeException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public GenerateCodeException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public GenerateCodeException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public GenerateCodeException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public GenerateCodeException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public GenerateCodeException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public GenerateCodeException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public GenerateCodeException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 189 - 0
java110-common/src/main/java/com/java110/common/exception/ResponseErrorException.java

@@ -0,0 +1,189 @@
+package com.java110.common.exception;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 目标系统 错误异常
+ * Created by wuxw on 2018/4/14.
+ */
+public class ResponseErrorException extends RuntimeException {
+
+
+    private Result result;
+    private Throwable cause = this;
+
+    public ResponseErrorException(){}
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param cause  异常堆栈
+     */
+    public ResponseErrorException(Result result, Throwable cause) {
+        super(result.getMsg(), cause);
+        this.result = result;
+    }
+
+    /**
+     * 构造方法
+     * @param code 返回码
+     * @param msg  错误消息
+     */
+    public ResponseErrorException(int code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    public ResponseErrorException(String code, String msg) {
+        super(msg);
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     */
+    public ResponseErrorException(Result result, String detail) {
+        super(result.getMsg() + "," + detail);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param result 返回值
+     * @param detail 具体的返回消息
+     * @param cause  异常堆栈
+     */
+    public ResponseErrorException(Result result, String detail, Throwable cause) {
+        super(result.getMsg() + "," + detail, cause);
+        this.result = new Result(result.getCode(), result.getMsg() + "," + detail);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param msg	返回消息
+     * @param cause 异常堆栈
+     */
+    public ResponseErrorException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     * 构造方法
+     * @param code	返回码
+     * @param cause	异常堆栈
+     */
+    public ResponseErrorException(int code, Throwable cause) {
+        super(cause);
+        String msg = "";
+
+        if(cause != null) {
+            if(cause.getCause() != null) {
+                msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
+            }
+            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+        }
+        this.result = new Result(code, msg);
+    }
+
+    /**
+     *
+     * TODO 简单描述该方法的实现功能(可选).
+     * @see Throwable#getCause()
+     */
+    public synchronized Throwable getCause() {
+        return (cause==this ? super.getCause() : cause);
+    }
+
+
+    /**
+     * 返回异常消息
+     * @return 异常消息
+     */
+    @Override
+    public String getMessage() {
+        return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+    }
+
+    /**
+     * 异常
+     * @return
+     */
+    public String toJsonString() {
+        JSONObject exceptionJson = JSONObject.parseObject("{\"exception\":{}");
+        JSONObject exceptionJsonObj = exceptionJson.getJSONObject("exception");
+
+        if (getResult() != null)
+            exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
+
+        exceptionJsonObj.put("exceptionTrace",getMessage());
+
+        return exceptionJsonObj.toString();
+    }
+    @Override
+    public void printStackTrace(PrintStream ps) {
+        ps.print("<exception>");
+        if (getResult() != null) {
+            ps.print(result.toString());
+        }
+        ps.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(ps);
+        } else {
+            ps.println(this);
+            ps.print("Caused by: ");
+            cause.printStackTrace(ps);
+        }
+        ps.append("</exceptionTrace>");
+        ps.println("</exception>");
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter pw) {
+        pw.print("<exception>");
+        if (getResult() != null) {
+            pw.print(result.toString());
+        }
+        pw.append("<exceptionTrace>");
+
+        Throwable cause = getCause();
+        if (cause == null) {
+            super.printStackTrace(pw);
+        } else {
+            pw.println(this);
+            pw.print("Caused by: ");
+            cause.printStackTrace(pw);
+        }
+        pw.append("</exceptionTrace>");
+        pw.println("</exception>");
+    }
+
+    /**
+     * 返回异常值
+     * @return	异常值对象
+     */
+    public Result getResult() {
+        return result;
+    }
+
+    public void setResult(Result result) {
+        this.result = result;
+    }
+
+}

+ 81 - 12
java110-common/src/main/java/com/java110/common/util/SequenceUtil.java

@@ -1,8 +1,15 @@
 package com.java110.common.util;
 package com.java110.common.util;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.common.cache.MappingCache;
 import com.java110.common.cache.MappingCache;
 import com.java110.common.constant.MappingConstant;
 import com.java110.common.constant.MappingConstant;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.exception.GenerateCodeException;
+import com.java110.common.exception.ResponseErrorException;
+import com.java110.common.factory.ApplicationContextFactory;
+import org.springframework.web.client.RestTemplate;
 
 
+import java.rmi.NoSuchObjectException;
 import java.text.DateFormat;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
@@ -27,9 +34,9 @@ public class SequenceUtil {
      *
      *
      * 只有在不调用服务生成ID时有用
      * 只有在不调用服务生成ID时有用
      */
      */
-    private static Map prefixMap = null;
+    private static Map<String,String> prefixMap = null;
     static {
     static {
-        prefixMap = new HashMap();
+        prefixMap = new HashMap<String,String>();
         //10+yyyymmdd+八位序列
         //10+yyyymmdd+八位序列
         prefixMap.put("oId","10");
         prefixMap.put("oId","10");
         //(20+yyyymmdd+八位序列)
         //(20+yyyymmdd+八位序列)
@@ -86,45 +93,107 @@ public class SequenceUtil {
         return prefixMap.get("pageTransactionId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId();
         return prefixMap.get("pageTransactionId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId();
     }
     }
 
 
-    public static String getOId(){
+    public static String getOId() throws GenerateCodeException{
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("oId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
             return prefixMap.get("oId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
         }
         }
+        return getCode(prefixMap.get("oId"));
+    }
+
+
+    /**
+     * 查询Code
+     * @param prefix
+     * @return
+     * @throws GenerateCodeException
+     */
+    private static String getCode(String prefix) throws GenerateCodeException{
         //调用服务
         //调用服务
-        return null;
+        String code = "-1";
+        try {
+            String responseMessage = restTemplate().postForObject(MappingCache.getValue(MappingConstant.KEY_CODE_PATH),
+                    createCodeRequestJson(getTransactionId(),prefix,prefix).toJSONString(), String.class);
+
+            Assert.jsonObjectHaveKey(responseMessage, "code", "编码生成系统 返回报文错误" + responseMessage);
+
+            JSONObject resJson = JSONObject.parseObject(responseMessage);
+
+            if (!ResponseConstant.RESULT_CODE_SUCCESS.equals(resJson.getString("code"))) {
+                throw new ResponseErrorException(resJson.getString("code"), "生成oId编码失败 "
+                        + resJson.getString("message"));
+            }
+            code = resJson.getString("id");
+        }catch (Exception e){
+            throw new GenerateCodeException(ResponseConstant.RESULT_CODE_ERROR,e.getMessage());
+        }
+        finally {
+            return code;
+        }
+
     }
     }
 
 
-    public static String getBId(){
+    public static String getBId()  throws GenerateCodeException{
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("bId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
             return prefixMap.get("bId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
         }
         }
         //调用服务
         //调用服务
-        return null;
+        return getCode(prefixMap.get("bId"));
     }
     }
 
 
-    public static String getAttrId(){
+    public static String getAttrId()  throws GenerateCodeException{
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("attrId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
             return prefixMap.get("attrId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
         }
         }
         //调用服务
         //调用服务
-        return null;
+        return getCode(prefixMap.get("attrId"));
     }
     }
 
 
-    public static String getDataFlowId(){
+    public static String getDataFlowId()  throws GenerateCodeException{
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("dataFlowId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
             return prefixMap.get("dataFlowId") + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_H) + nextId("%08d");
         }
         }
 
 
-        return null;
+        return getCode(prefixMap.get("dataFlowId"));
 
 
     }
     }
 
 
-    public static String getUserId(){
+    public static String getUserId()  throws GenerateCodeException{
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
         if(!MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_NEED_INVOKE_GENERATE_ID))){
             return prefixMap.get("userId") + nextId("%08d");
             return prefixMap.get("userId") + nextId("%08d");
         }
         }
         //调用服务
         //调用服务
-        return null;
+        return getCode(prefixMap.get("userId"));
     }
     }
 
 
+
+    /**
+     * 获取restTemplate
+     * @return
+     * @throws NoSuchObjectException
+     */
+    private static RestTemplate restTemplate() throws NoSuchObjectException{
+
+       Object bean = ApplicationContextFactory.getBean("restTemplate");
+
+       if(bean == null){
+           throw new NoSuchObjectException("没有找到restTemplate对象,请核实");
+       }
+
+       return (RestTemplate) bean;
+    }
+
+
+    /**
+     * ID生成请求报文
+     * @param transactionId
+     * @return
+     */
+    private static JSONObject createCodeRequestJson(String transactionId, String prefix, String name){
+        JSONObject paramOut = JSONObject.parseObject("{}");
+        paramOut.put("transactionId",transactionId);
+        paramOut.put("prefix",prefix);
+        paramOut.put("name",name);
+        paramOut.put("requestTime",DateUtil.getNowDefault());
+        return paramOut;
+    }
 }
 }

+ 14 - 12
java110-config/db/CenterService/create_table.db

@@ -3,10 +3,10 @@ create database TT;
 -- c_orders
 -- c_orders
 
 
 CREATE TABLE c_orders(
 CREATE TABLE c_orders(
-    o_id VARCHAR(18) NOT NULL UNIQUE COMMENT '订单ID',
-    app_id VARCHAR(10) NOT NULL COMMENT '应用ID',
+    o_id VARCHAR(30) NOT NULL UNIQUE COMMENT '订单ID',
+    app_id VARCHAR(30) NOT NULL COMMENT '应用ID',
     ext_transaction_id VARCHAR(30) NOT NULL COMMENT '外部交易流水',
     ext_transaction_id VARCHAR(30) NOT NULL COMMENT '外部交易流水',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     request_time VARCHAR(16) NOT NULL COMMENT '外部系统请求时间',
     request_time VARCHAR(16) NOT NULL COMMENT '外部系统请求时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     order_type_cd VARCHAR(4) NOT NULL COMMENT '订单类型,参考c_order_type表',
     order_type_cd VARCHAR(4) NOT NULL COMMENT '订单类型,参考c_order_type表',
@@ -18,8 +18,8 @@ CREATE TABLE c_orders(
 -- c_orders_attrs
 -- c_orders_attrs
 
 
 CREATE TABLE c_orders_attrs(
 CREATE TABLE c_orders_attrs(
-    o_id VARCHAR(18) NOT NULL COMMENT '订单ID',
-    attr_id VARCHAR(18) NOT NULL COMMENT '属性id',
+    o_id VARCHAR(30) NOT NULL COMMENT '订单ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     `value` VARCHAR(50) NOT NULL COMMENT '属性值'
     `value` VARCHAR(50) NOT NULL COMMENT '属性值'
 );
 );
@@ -29,8 +29,8 @@ CREATE TABLE c_orders_attrs(
 -- c_business
 -- c_business
 
 
 CREATE TABLE c_business(
 CREATE TABLE c_business(
-    b_id VARCHAR(18) NOT NULL UNIQUE COMMENT '业务Id',
-    o_id VARCHAR(18) NOT NULL COMMENT '订单ID',
+    b_id VARCHAR(30) NOT NULL UNIQUE COMMENT '业务Id',
+    o_id VARCHAR(30) NOT NULL COMMENT '订单ID',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     business_type_cd VARCHAR(4) NOT NULL COMMENT '业务项类型,参考c_business_type表',
     business_type_cd VARCHAR(4) NOT NULL COMMENT '业务项类型,参考c_business_type表',
     finish_time DATE COMMENT '完成时间',
     finish_time DATE COMMENT '完成时间',
@@ -41,8 +41,8 @@ CREATE TABLE c_business(
 --c_orders_attrs
 --c_orders_attrs
 
 
 CREATE TABLE c_business_attrs(
 CREATE TABLE c_business_attrs(
-    b_id VARCHAR(18) NOT NULL COMMENT '订单ID',
-    attr_id VARCHAR(18) NOT NULL COMMENT '属性id',
+    b_id VARCHAR(30) NOT NULL COMMENT '订单ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     `value` VARCHAR(50) NOT NULL COMMENT '属性值'
     `value` VARCHAR(50) NOT NULL COMMENT '属性值'
 );
 );
@@ -111,7 +111,7 @@ insert into spec(domain,spec_cd,name,description) values('BUSINESS','200001','
 
 
 CREATE TABLE c_route(
 CREATE TABLE c_route(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    app_id VARCHAR(10) NOT NULL COMMENT '应用ID',
+    app_id VARCHAR(30) NOT NULL COMMENT '应用ID',
     service_id INT NOT NULL COMMENT '下游接口配置ID',
     service_id INT NOT NULL COMMENT '下游接口配置ID',
     order_type_cd VARCHAR(4) NOT NULL COMMENT '订单类型,参考c_order_type表',
     order_type_cd VARCHAR(4) NOT NULL COMMENT '订单类型,参考c_order_type表',
     invoke_limit_times INT COMMENT '接口调用一分钟调用次数',
     invoke_limit_times INT COMMENT '接口调用一分钟调用次数',
@@ -136,7 +136,7 @@ CREATE TABLE c_service(
     method VARCHAR(50) COMMENT '方法 空 为http post LOCAL_SERVICE 为调用本地服务 其他为webservice方式调用',
     method VARCHAR(50) COMMENT '方法 空 为http post LOCAL_SERVICE 为调用本地服务 其他为webservice方式调用',
     timeout INT NOT NULL DEFAULT 60 COMMENT '超时时间',
     timeout INT NOT NULL DEFAULT 60 COMMENT '超时时间',
     retry_count INT NOT NULL DEFAULT 3 COMMENT '重试次数',
     retry_count INT NOT NULL DEFAULT 3 COMMENT '重试次数',
-    provide_app_id VARCHAR(10) NOT NULL COMMENT '应用ID',
+    provide_app_id VARCHAR(30) NOT NULL COMMENT '应用ID',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
 );
 );
@@ -173,10 +173,12 @@ INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','中
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制中心APP_ID','CONSOLE_SERVICE_APP_ID','8000418002','控制中心APP_ID');
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制中心APP_ID','CONSOLE_SERVICE_APP_ID','8000418002','控制中心APP_ID');
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制服务加密开关','KEY_CONSOLE_SERVICE_SECURITY_ON_OFF','ON','控制服务加密开关');
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制服务加密开关','KEY_CONSOLE_SERVICE_SECURITY_ON_OFF','ON','控制服务加密开关');
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制服务鉴权秘钥','CONSOLE_SECURITY_CODE','WEBURFPKIFJUHNCJUEIKMKJUJHULSMNCHDY89KMC','控制服务鉴权秘钥');
 INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','控制服务鉴权秘钥','CONSOLE_SECURITY_CODE','WEBURFPKIFJUHNCJUEIKMKJUJHULSMNCHDY89KMC','控制服务鉴权秘钥');
+INSERT c_mapping(domain,`name`,`key`,`value`,remark) VALUES('DOMAIN.COMMON','编码生成服务地址','CODE_PATH','http://code-service/codeApi/generate','编码生成服务地址');
+
 -- c_app
 -- c_app
 CREATE TABLE c_app(
 CREATE TABLE c_app(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    app_id VARCHAR(10) NOT NULL UNIQUE COMMENT '应用ID',
+    app_id VARCHAR(30) NOT NULL UNIQUE COMMENT '应用ID',
     `name` VARCHAR(50) NOT NULL COMMENT '名称 对应系统名称',
     `name` VARCHAR(50) NOT NULL COMMENT '名称 对应系统名称',
     security_code VARCHAR(64) NOT NULL COMMENT '签名码 sign签名时用',
     security_code VARCHAR(64) NOT NULL COMMENT '签名码 sign签名时用',
     while_list_ip VARCHAR(200) COMMENT '白名单ip 多个之间用;隔开',
     while_list_ip VARCHAR(200) COMMENT '白名单ip 多个之间用;隔开',

+ 2 - 2
java110-config/db/ConsoleService/create_table.db

@@ -29,7 +29,7 @@ create table m_menu_ctg(
 create table m_menu_2_user(
 create table m_menu_2_user(
     m_user_id INT NOT NULL AUTO_INCREMENT KEY COMMENT '菜单用户ID',
     m_user_id INT NOT NULL AUTO_INCREMENT KEY COMMENT '菜单用户ID',
     m_id int not null comment '菜单id',
     m_id int not null comment '菜单id',
-    user_id varchar(12) not null comment '用户id',
+    user_id varchar(30) not null comment '用户id',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
     status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
 );
 );
@@ -278,7 +278,7 @@ CREATE TABLE c_cache(
 create table c_cache_2_user(
 create table c_cache_2_user(
      id INT NOT NULL AUTO_INCREMENT KEY COMMENT '缓存用户ID',
      id INT NOT NULL AUTO_INCREMENT KEY COMMENT '缓存用户ID',
      cache_code int not null comment '缓存编码',
      cache_code int not null comment '缓存编码',
-     user_id varchar(12) not null comment '用户id',
+     user_id varchar(30) not null comment '用户id',
      create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
      status_cd VARCHAR(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,0在用,1失效'
 );
 );

+ 22 - 22
java110-config/db/UserService/create_table.db

@@ -2,8 +2,8 @@
 
 
 create table business_user(
 create table business_user(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     name VARCHAR(50) NOT NULL COMMENT '名称',
     name VARCHAR(50) NOT NULL COMMENT '名称',
     email VARCHAR(30) COMMENT '邮箱地址',
     email VARCHAR(30) COMMENT '邮箱地址',
     address VARCHAR(200) COMMENT '现居住地址',
     address VARCHAR(200) COMMENT '现居住地址',
@@ -41,9 +41,9 @@ CREATE TABLE u_location(
 
 
 -- business_user_attr
 -- business_user_attr
 CREATE TABLE business_user_attr(
 CREATE TABLE business_user_attr(
-    b_id VARCHAR(18) NOT NULL COMMENT '订单ID',
-    attr_id VARCHAR(18) NOT NULL COMMENT '属性id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '订单ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     value VARCHAR(50) NOT NULL COMMENT '属性值',
     value VARCHAR(50) NOT NULL COMMENT '属性值',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
@@ -53,7 +53,7 @@ CREATE TABLE business_user_attr(
 -- u_user
 -- u_user
 create table u_user(
 create table u_user(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    user_id VARCHAR(12) NOT NULL UNIQUE COMMENT '用户ID',
+    user_id VARCHAR(30) NOT NULL UNIQUE COMMENT '用户ID',
     name VARCHAR(50) NOT NULL COMMENT '名称',
     name VARCHAR(50) NOT NULL COMMENT '名称',
     email VARCHAR(30) COMMENT '邮箱地址',
     email VARCHAR(30) COMMENT '邮箱地址',
     address VARCHAR(200) COMMENT '现居住地址',
     address VARCHAR(200) COMMENT '现居住地址',
@@ -63,7 +63,7 @@ create table u_user(
     sex varchar(1) comment '性别,0表示男孩 1表示女孩',
     sex varchar(1) comment '性别,0表示男孩 1表示女孩',
     tel varchar(11) comment '用户手机',
     tel varchar(11) comment '用户手机',
     level_cd varchar(2) not null default '0' comment '用户级别,关联user_level',
     level_cd varchar(2) not null default '0' comment '用户级别,关联user_level',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效'
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效'
 );
 );
@@ -73,19 +73,19 @@ create table u_user(
 
 
 CREATE TABLE u_user_attr(
 CREATE TABLE u_user_attr(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    attr_id VARCHAR(18) NOT NULL COMMENT '属性id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    attr_id VARCHAR(30) NOT NULL COMMENT '属性id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     spec_cd VARCHAR(12) NOT NULL COMMENT '规格id,参考spec表',
     value VARCHAR(50) NOT NULL COMMENT '属性值',
     value VARCHAR(50) NOT NULL COMMENT '属性值',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务ID',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0在用,1失效'
     status_cd VARCHAR(2) NOT NULL default '0' COMMENT '数据状态,详细参考c_status表,S 保存,0在用,1失效'
 );
 );
 -- 用户 物流地址
 -- 用户 物流地址
 create table business_user_address(
 create table business_user_address(
-    address_id VARCHAR(18) NOT NULL COMMENT '地址ID',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    address_id VARCHAR(30) NOT NULL COMMENT '地址ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     tel varchar(11) not null comment '电话',
     tel varchar(11) not null comment '电话',
     postal_code varchar(10) not null comment '邮政编码',
     postal_code varchar(10) not null comment '邮政编码',
     address varchar(200) not null comment '地址',
     address varchar(200) not null comment '地址',
@@ -97,9 +97,9 @@ create table business_user_address(
 -- u_user_address
 -- u_user_address
 create table u_user_address(
 create table u_user_address(
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
     id INT NOT NULL AUTO_INCREMENT KEY COMMENT 'id',
-    address_id VARCHAR(18) NOT NULL COMMENT '地址ID',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    address_id VARCHAR(30) NOT NULL COMMENT '地址ID',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     tel varchar(11) not null comment '电话',
     tel varchar(11) not null comment '电话',
     postal_code varchar(10) not null comment '邮政编码',
     postal_code varchar(10) not null comment '邮政编码',
     address varchar(200) not null comment '地址',
     address varchar(200) not null comment '地址',
@@ -109,9 +109,9 @@ create table u_user_address(
 );
 );
 -- 用户标签
 -- 用户标签
 create table business_user_tag(
 create table business_user_tag(
-    id VARCHAR(12) NOT NULL COMMENT 'Id',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    id VARCHAR(30) NOT NULL COMMENT 'Id',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     tag_cd VARCHAR(12) NOT NULL COMMENT '标签编码,参考tag表',
     tag_cd VARCHAR(12) NOT NULL COMMENT '标签编码,参考tag表',
     remark VARCHAR(200) COMMENT '备注',
     remark VARCHAR(200) COMMENT '备注',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
@@ -121,10 +121,10 @@ create table business_user_tag(
 
 
 -- 用户标签
 -- 用户标签
 create table u_user_tag(
 create table u_user_tag(
-    id VARCHAR(12) NOT NULL COMMENT 'Id',
-    user_id VARCHAR(12) NOT NULL COMMENT '用户ID',
+    id VARCHAR(30) NOT NULL COMMENT 'Id',
+    user_id VARCHAR(30) NOT NULL COMMENT '用户ID',
     tag_cd VARCHAR(12) NOT NULL COMMENT '标签编码,参考tag表',
     tag_cd VARCHAR(12) NOT NULL COMMENT '标签编码,参考tag表',
-    b_id VARCHAR(18) NOT NULL COMMENT '业务Id',
+    b_id VARCHAR(30) NOT NULL COMMENT '业务Id',
     tag_count int not null default 1 comment '打标数量',
     tag_count int not null default 1 comment '打标数量',
     remark VARCHAR(200) COMMENT '备注',
     remark VARCHAR(200) COMMENT '备注',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

+ 8 - 1
java110-config/src/main/resources/config/code/zookeeper.properties

@@ -1,4 +1,11 @@
-java110.code.zookeeper.url=135.192.86.200
+#java110.code.zookeeper.url=135.192.86.200
+#java110.code.zookeeper.port=2181
+#java110.code.zookeeper.timeOut=60000
+#java110.code.zookeeper.workDir=/java110_works
+
+
+java110.code.zookeeper.url=192.168.31.199
 java110.code.zookeeper.port=2181
 java110.code.zookeeper.port=2181
 java110.code.zookeeper.timeOut=60000
 java110.code.zookeeper.timeOut=60000
 java110.code.zookeeper.workDir=/java110_works
 java110.code.zookeeper.workDir=/java110_works
+

+ 2 - 1
java110-core/src/main/java/com/java110/core/base/AppBase.java

@@ -2,6 +2,7 @@ package com.java110.core.base;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.common.cache.BaseCache;
 import com.java110.common.log.LoggerEngine;
 import com.java110.common.log.LoggerEngine;
 
 
 import java.util.List;
 import java.util.List;
@@ -10,7 +11,7 @@ import java.util.Map;
 /**
 /**
  * Created by wuxw on 2017/4/10.
  * Created by wuxw on 2017/4/10.
  */
  */
-public class AppBase extends LoggerEngine {
+public class AppBase extends BaseCache {
 
 
 
 
     private final static String SERVICE_CASE_JSON_EXCEPTION = "101";//转json异常
     private final static String SERVICE_CASE_JSON_EXCEPTION = "101";//转json异常

+ 4 - 4
java110-core/src/main/java/com/java110/core/base/dao/BaseServiceDao.java

@@ -20,8 +20,8 @@ import java.util.logging.Logger;
  */
  */
 public class BaseServiceDao extends AppBase {
 public class BaseServiceDao extends AppBase {
 
 
-    @Autowired
-    protected JedisPool jedisPool;
+   /* @Autowired
+    protected JedisPool jedisPool;*/
 
 
 
 
     @Autowired
     @Autowired
@@ -100,11 +100,11 @@ public class BaseServiceDao extends AppBase {
         return reqMap;
         return reqMap;
     }
     }
 
 
-    public JedisPool getJedisPool() {
+  /*  public JedisPool getJedisPool() {
         return jedisPool;
         return jedisPool;
     }
     }
 
 
     public void setJedisPool(JedisPool jedisPool) {
     public void setJedisPool(JedisPool jedisPool) {
         this.jedisPool = jedisPool;
         this.jedisPool = jedisPool;
-    }
+    }*/
 }
 }

+ 14 - 0
java110-core/src/main/java/com/java110/core/factory/DataTransactionFactory.java

@@ -381,4 +381,18 @@ public class DataTransactionFactory {
         return paramOut;
         return paramOut;
     }
     }
 
 
+    /**
+     * ID生成请求报文
+     * @param transactionId
+     * @return
+     */
+    public static JSONObject createCodeRequestJson(String transactionId, String prefix,String name){
+        JSONObject paramOut = JSONObject.parseObject("{}");
+        paramOut.put("transactionId",transactionId);
+        paramOut.put("prefix",prefix);
+        paramOut.put("name",name);
+        paramOut.put("requestTime",DateUtil.getNowDefault());
+        return paramOut;
+    }
+
 }
 }