Просмотр исходного кода

调整和整合架构,日志和序列文件迁移

java110 лет назад: 5
Родитель
Сommit
1468caa107
69 измененных файлов с 99 добавлено и 3093 удалено
  1. 8 0
      java110-core/src/main/java/com/java110/core/event/center/DataFlowEventPublishing.java
  2. 21 0
      java110-core/src/main/java/com/java110/core/event/center/event/InvokeFinishBusinessSystemEvent.java
  3. 2 1
      java110-interface/src/main/resources/config/center_event.properties
  4. 0 2
      pom.xml
  5. 0 101
      service-log/README.md
  6. 0 14
      service-log/bin/start_log.sh
  7. 0 62
      service-log/doc/create_table.db
  8. 0 14
      service-log/doc/start_logService.sh
  9. 0 11
      service-log/docker/Dockerfile
  10. 0 11
      service-log/docker/onStart.sh
  11. BIN
      service-log/orderDispatch.png
  12. 0 72
      service-log/pom.xml
  13. 0 43
      service-log/src/main/java/com/java110/log/LogServiceApplicationStart.java
  14. 0 30
      service-log/src/main/java/com/java110/log/dao/LogServiceDao.java
  15. 0 61
      service-log/src/main/java/com/java110/log/dao/impl/LogServiceDaoImpl.java
  16. 0 16
      service-log/src/main/java/com/java110/log/kafka/LogServiceBean.java
  17. 0 56
      service-log/src/main/java/com/java110/log/kafka/LogServiceKafka.java
  18. 0 16
      service-log/src/main/java/com/java110/log/package-info.java
  19. 0 37
      service-log/src/main/java/com/java110/log/smo/ILogServiceSMO.java
  20. 0 147
      service-log/src/main/java/com/java110/log/smo/impl/LogServiceSMOImpl.java
  21. 0 96
      service-log/src/main/resources/application-dev.yml
  22. 0 96
      service-log/src/main/resources/application-prod.yml
  23. 0 96
      service-log/src/main/resources/application-test.yml
  24. 0 3
      service-log/src/main/resources/application.yml
  25. 0 15
      service-log/src/main/resources/banner.txt
  26. 0 3
      service-log/src/main/resources/java110.properties
  27. 0 39
      service-log/src/test/java/com/java110/log/AppTest.java
  28. 0 114
      service-log/src/test/java/com/java110/log/common/PreBoCustAttr.java
  29. 0 80
      service-log/src/test/java/com/java110/log/executor/ExecutorTest.java
  30. 0 23
      service-log/src/test/java/com/java110/log/executor/PrintInt.java
  31. 0 38
      service-log/src/test/java/com/java110/log/jsonpath/CustIdTest.java
  32. 0 22
      service-log/src/test/java/com/java110/log/type/AppCustEvent.java
  33. 0 24
      service-log/src/test/java/com/java110/log/type/AppEvent.java
  34. 0 19
      service-log/src/test/java/com/java110/log/type/AppListener.java
  35. 0 40
      service-log/src/test/java/com/java110/log/type/CommonTest.java
  36. 0 21
      service-log/src/test/java/com/java110/log/type/CustDispatchListener.java
  37. 0 19
      service-log/src/test/java/com/java110/log/type/Ordered.java
  38. 0 45
      service-log/src/test/java/com/java110/log/type/TypeTest.java
  39. 52 0
      service-order/src/main/java/com/java110/order/listener/TransactionOrderInfoToKafkaListener.java
  40. 16 36
      service-order/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java
  41. 0 28
      service-sequence/Readme.md
  42. 0 14
      service-sequence/bin/start_code.sh
  43. 0 6
      service-sequence/doc/IdRequest_protocol.json
  44. 0 7
      service-sequence/doc/IdResponse_protocol.json
  45. 0 14
      service-sequence/doc/start_codeService.sh
  46. 0 11
      service-sequence/docker/Dockerfile
  47. 0 11
      service-sequence/docker/onStart.sh
  48. 0 70
      service-sequence/pom.xml
  49. 0 90
      service-sequence/src/main/java/com/java110/code/CodeServiceApplicationStart.java
  50. 0 159
      service-sequence/src/main/java/com/java110/code/api/CodeApi.java
  51. 0 66
      service-sequence/src/main/java/com/java110/code/dao/ICommonServiceDao.java
  52. 0 22
      service-sequence/src/main/java/com/java110/code/dao/IPrimaryKeyServiceDao.java
  53. 0 14
      service-sequence/src/main/java/com/java110/code/dao/ISnowflakeldWorker.java
  54. 0 160
      service-sequence/src/main/java/com/java110/code/dao/impl/CommonServiceDaoImpl.java
  55. 0 40
      service-sequence/src/main/java/com/java110/code/dao/impl/PrimaryKeyServiceDaoImpl.java
  56. 0 182
      service-sequence/src/main/java/com/java110/code/dao/impl/SnowflakeIdWorkerImpl.java
  57. 0 16
      service-sequence/src/main/java/com/java110/code/package-info.java
  58. 0 62
      service-sequence/src/main/java/com/java110/code/smo/ICommonServiceSmo.java
  59. 0 27
      service-sequence/src/main/java/com/java110/code/smo/IPrimaryKeyServiceSMO.java
  60. 0 62
      service-sequence/src/main/java/com/java110/code/smo/impl/CommonServiceSmoImpl.java
  61. 0 80
      service-sequence/src/main/java/com/java110/code/smo/impl/PrimaryKeyServiceSMOImpl.java
  62. 0 97
      service-sequence/src/main/resources/application-dev.yml
  63. 0 97
      service-sequence/src/main/resources/application-prod.yml
  64. 0 97
      service-sequence/src/main/resources/application-test.yml
  65. 0 3
      service-sequence/src/main/resources/application.yml
  66. 0 23
      service-sequence/src/main/resources/banner.txt
  67. 0 75
      service-sequence/src/main/resources/dataSource.yml
  68. 0 3
      service-sequence/src/main/resources/java110.properties
  69. 0 34
      service-sequence/src/test/java/com/java110/AppTest.java

+ 8 - 0
java110-core/src/main/java/com/java110/core/event/center/DataFlowEventPublishing.java

@@ -253,6 +253,14 @@ public class DataFlowEventPublishing extends LoggerEngine {
         multicastEvent(new InvokeBusinessSystemEvent("",dataFlow));
     }
 
+    /**
+     * 调用完成业务系统事件
+     * @param dataFlow 数据流
+     */
+    public static void invokeFinishBusinessSystem(IOrderDataFlowContext dataFlow){
+        multicastEvent(new InvokeFinishBusinessSystemEvent("",dataFlow));
+    }
+
 
     /**
      * 调用业务系统成功后事件

+ 21 - 0
java110-core/src/main/java/com/java110/core/event/center/event/InvokeFinishBusinessSystemEvent.java

@@ -0,0 +1,21 @@
+package com.java110.core.event.center.event;
+
+import com.java110.core.context.IOrderDataFlowContext;
+
+/**
+ * 调用业务系统事件
+ * Created by wuxw on 2018/7/2.
+ */
+public class InvokeFinishBusinessSystemEvent extends DataFlowEvent {
+
+    /**
+     * Constructs a prototypical Event.
+     *
+     * @param source   The object on which the Event initially occurred.
+     * @param dataFlow
+     * @throws IllegalArgumentException if source is null.
+     */
+    public InvokeFinishBusinessSystemEvent(Object source, IOrderDataFlowContext dataFlow) {
+        super(source, dataFlow);
+    }
+}

+ 2 - 1
java110-interface/src/main/resources/config/center_event.properties

@@ -1,2 +1,3 @@
 java110.event.properties.centerServiceListener=\
-  dealUserIdListener
+  dealUserIdListener,\
+  transactionOrderInfoToKafkaListener

+ 0 - 2
pom.xml

@@ -16,10 +16,8 @@
         <module>java110-service</module>
         <module>java110-db</module>
         <module>service-user</module>
-        <module>service-log</module>
         <module>service-fee</module>
         <module>service-eureka</module>
-        <module>service-sequence</module>
         <module>service-store</module>
         <module>service-order</module>
         <module>service-api</module>

+ 0 - 101
service-log/README.md

@@ -1,101 +0,0 @@
-OrderService模块
-
-1.0 订单管理
-
-1.1.1 订单查询
-
-1.1.2 订单提交
-
-请求报文格式为:
-{
-    "orderList": {
-        "orderListAttrs": [
-            {
-                "attrCd": "40010026",
-                "name": "购物车流水号",
-                "value": "31201704110009114961"
-            }
-        ],
-        "busiOrder": [
-            {
-                "data": {
-                    "boCust": [
-                        {
-                            "custId": "-1",
-                            "name": "S",
-                            "email": "-52",
-                            "cellphone": "17797173942",
-                            "realName": "wuxw",
-                            "sex": "1",
-                            "password": "123456",
-                            "lanId": "863010",
-                            "custAdress": "青海省西宁市城中区格兰小镇",
-                            "custType": "1",
-                            "openId": "",
-                            "state": "ADD"
-                        },
-                        {
-                            "custId": "123",
-                            "name": "S",
-                            "email": "-52",
-                            "cellphone": "17797173942",
-                            "realName": "wuxw",
-                            "sex": "1",
-                            "password": "123456",
-                            "lanId": "863010",
-                            "custAdress": "青海省西宁市城中区格兰小镇",
-                            "custType": "1",
-                            "openId": "",
-                            "state": "DEL"
-                        }
-                    ],
-                    "boCustAttr": [
-                        {
-                            "custId": "123",
-                            "prodId": "-1",
-                            "attrCd": "123344",
-                            "value": "1",
-                            "state": "ADD"
-                        },
-                        {
-                            "custId": "123",
-                            "prodId": "-1",
-                            "attrCd": "123345",
-                            "value": "1",
-                            "state": "DEL"
-                        }
-                    ]
-                },
-                "busiOrder": {
-                    "name": "新建客户",
-                    "actionTypeCd": "C1",
-                    "actionClassCd": "1",
-                    "status_cd": "S",
-                    "start_dt": "2017-04-11",
-                    "end_dt": "2017-04-12",
-                    "remark": ""
-                },
-                "busiOrderAttrs": [
-                    {
-                        "attrCd": "40010026",
-                        "name": "购物车流水号",
-                        "value": "31201704110009114961"
-                    }
-                ]
-            }
-        ],
-        "orderListInfo": {
-            "transactionId": "1000000200201704113137002690",
-            "channelId": "700212896",
-            "remarks": "",
-            "olId": "-1",
-            "custId": "701008023904",
-            "statusCd": "S",
-            "reqTime": "20170411163709",
-            "extSystemId": "310013698777",
-            "olTypeCd": "15"
-        }
-    }
-}
-
-1.1.3 订单取消

+ 0 - 14
service-log/bin/start_log.sh

@@ -1,14 +0,0 @@
-#!/bin/bash
-#### debug model prod
-#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/LogService.jar $1 > log.log 2>&1 &
-
-#### normal prod model
-#nohup java -jar -Dspring.profiles.active=prod $1 target/LogService.jar > log.log $1 2>&1 &
-
-#### normal test model
-#nohup java -jar -Dspring.profiles.active=test $1 target/LogService.jar > log.log $1 2>&1 &
-
-#### normal dev model
-nohup java -jar -Dspring.profiles.active=$1 $2 target/LogService.jar > log.log $1 2>&1 &
-
-tail -100f log.log

+ 0 - 62
service-log/doc/create_table.db

@@ -1,64 +0,0 @@
-
-create table l_transaction_log(
-    log_id varchar(30) not null keY unique COMMENT 'id',
-    transaction_id VARCHAR(30) NOT NULL COMMENT '外部交易流水',
-    contract_id varchar(64) not null comment '上下文ID',
-    ip varchar(20) not null comment '日志产生主机IP',
-    port varchar(10) not null comment '日志产生端口',
-    src_ip varchar(20) comment '调用方IP',
-    src_port varchar(10) comment '调用方端口',
-    app_id varchar(30) not null comment '调用方应用ID',
-    user_id varchar(30) comment '用户ID',
-    service_code varchar(50) comment '服务编码',
-    service_name varchar(50) comment '服务名称',
-    timestamp TIMESTAMP NOT NULL comment '日志交互时间,时间戳',
-    status_cd varchar(2) not null comment '交互状态 S 成功 F 失败',
-    month INT NOT NULL default month(CURRENT_DATE) comment '月份',
-    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    PRIMARY KEY (log_id)
-)
-partition BY RANGE (month) (
-    partition transaction_log_1 VALUES LESS THAN (2),
-    partition transaction_log_2 VALUES LESS THAN (3),
-    partition transaction_log_3 VALUES LESS THAN (4),
-    partition transaction_log_4 VALUES LESS THAN (5),
-    partition transaction_log_5 VALUES LESS THAN (6),
-    partition transaction_log_6 VALUES LESS THAN (7),
-    partition transaction_log_7 VALUES LESS THAN (8),
-    partition transaction_log_8 VALUES LESS THAN (9),
-    partition transaction_log_9 VALUES LESS THAN (10),
-    partition transaction_log_10 VALUES LESS THAN (11),
-    partition transaction_log_11 VALUES LESS THAN (12),
-    partition transaction_log_12 VALUES LESS THAN (13)
-);
-
-
-
-
-create table l_transaction_log_message(
-    log_id varchar(30) not null unique FOREIGN KEY REFERENCES l_transaction_log(log_id) COMMENT 'id',
-    request_header LONGTEXT COMMENT '请求头信息',
-    response_header LONGTEXT COMMENT '返回头信息',
-    request_message LONGTEXT comment '请求报文',
-    response_message LONGTEXT comment '返回报文',
-    remark varchar(200) comment '备注',
-    month INT NOT NULL default month(CURRENT_DATE) comment '月份',
-    create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
-)
-partition BY RANGE (month) (
-    partition transaction_log_message_1 VALUES LESS THAN (2),
-    partition transaction_log_message_2 VALUES LESS THAN (3),
-    partition transaction_log_message_3 VALUES LESS THAN (4),
-    partition transaction_log_message_4 VALUES LESS THAN (5),
-    partition transaction_log_message_5 VALUES LESS THAN (6),
-    partition transaction_log_message_6 VALUES LESS THAN (7),
-    partition transaction_log_message_7 VALUES LESS THAN (8),
-    partition transaction_log_message_8 VALUES LESS THAN (9),
-    partition transaction_log_message_9 VALUES LESS THAN (10),
-    partition transaction_log_message_10 VALUES LESS THAN (11),
-    partition transaction_log_message_11 VALUES LESS THAN (12),
-    partition transaction_log_message_12 VALUES LESS THAN (13)
-);
-

+ 0 - 14
service-log/doc/start_logService.sh

@@ -1,14 +0,0 @@
-#!/bin/bash
-#### debug model prod
-#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev LogService.jar $1 > log.log 2>&1 &
-
-#### normal prod model
-#nohup java -jar -Dspring.profiles.active=prod $1 LogService.jar > log.log $1 2>&1 &
-
-#### normal test model
-#nohup java -jar -Dspring.profiles.active=test $1 LogService.jar > log.log $1 2>&1 &
-
-#### normal dev model
-nohup java -jar -Dspring.profiles.active=dev $1 LogService.jar > log.log $1 2>&1 &
-
-tail -100f log.log

+ 0 - 11
service-log/docker/Dockerfile

@@ -1,11 +0,0 @@
-FROM registry.cn-beijing.aliyuncs.com/sxd/ubuntu-java8:1.0
-MAINTAINER wuxw <928255095@qq.com>
-
-ADD target/service-log.jar /root/target/
-
-ADD bin/start_log.sh /root/
-
-
-RUN chmod u+x /root/start_log.sh
-
-CMD ["/root/start_log.sh","dev"]

+ 0 - 11
service-log/docker/onStart.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-cp -r ../bin .
-
-cp  -r ../target .
-
-docker build -t java110/log .
-
-docker run -ti --name log_test -p8004:8004 -idt java110/log:latest
-
-docker logs -f log_test

BIN
service-log/orderDispatch.png


+ 0 - 72
service-log/pom.xml

@@ -1,72 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>MicroCommunity</artifactId>
-        <groupId>com.java110</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>service-log</artifactId>
-    <packaging>jar</packaging>
-
-    <name>service-log</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    </properties>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>com.java110</groupId>
-            <artifactId>java110-service</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>com.java110</groupId>
-            <artifactId>java110-interface</artifactId>
-            <scope>provided</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <finalName>service-log</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <version>2.10</version>
-                <executions>
-                    <execution>
-                        <id>unpack</id>
-                        <phase>generate-resources</phase>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <configuration>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>com.java110</groupId>
-                                    <artifactId>java110-interface</artifactId>
-                                    <version>${microcommunity.version}</version>
-                                    <type>jar</type>
-                                    <overWrite>true</overWrite>
-                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <mainClass>com.java110.log.LogServiceApplicationStart</mainClass>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 43
service-log/src/main/java/com/java110/log/LogServiceApplicationStart.java

@@ -1,43 +0,0 @@
-package com.java110.log;
-
-/**
- * Hello world!
- */
-
-import com.java110.service.init.ServiceStartInit;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.context.ApplicationContext;
-
-/**
- * 日志服务初始化启动类 初始化启动类
- *
- * @version v0.1
- * @auther com.java110.wuxw
- * @mail 928255095@qq.com
- * @date 2016年8月6日
- * @tag
- */
-@SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.log",
-        "com.java110.core", "com.java110.config.properties.code"})
-@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"com.java110.intf"})
-public class LogServiceApplicationStart {
-    private static Logger logger = LoggerFactory.getLogger(LogServiceApplicationStart.class);
-
-
-    public static void main(String[] args) throws Exception {
-        try {
-            ApplicationContext context = SpringApplication.run(LogServiceApplicationStart.class, args);
-
-            ServiceStartInit.initSystemConfig(context);
-        } catch (Throwable e) {
-            logger.error("系统启动失败", e);
-        }
-
-    }
-}

+ 0 - 30
service-log/src/main/java/com/java110/log/dao/LogServiceDao.java

@@ -1,30 +0,0 @@
-package com.java110.log.dao;
-
-import com.java110.utils.exception.DAOException;
-
-import java.util.Map;
-
-/**
- * 购物车,订单项信息管理
- *
- * 增加,查询
- * 没有查询,理论上购物车信息,不允许删除和修改
- *
- * Created by wuxw on 2016/12/27.
- */
-public interface LogServiceDao {
-
-    /**
-     * 保存日志
-     * 相关表 l_transaction_log
-     * @param logMessageParams 日志参数信息
-     */
-    public void saveTransactionLog(Map logMessageParams) throws DAOException;
-
-    /**
-     * 保存日志(交互报文)
-     * 相关表 l_transaction_log_message
-     * @param logMessageParams 日志参数信息
-     */
-    public void saveTransactionLogMessage(Map logMessageParams) throws DAOException;
-}

+ 0 - 61
service-log/src/main/java/com/java110/log/dao/impl/LogServiceDaoImpl.java

@@ -1,61 +0,0 @@
-package com.java110.log.dao.impl;
-
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.exception.DAOException;
-import com.java110.core.base.dao.BaseServiceDao;
-import com.java110.log.dao.LogServiceDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import java.util.Map;
-
-/**
- * 日志服务 与数据库交互
- * Created by wuxw on 2017/4/5.
- */
-
-@Service("logServiceDaoImpl")
-//@Transactional
-public class LogServiceDaoImpl extends BaseServiceDao implements LogServiceDao {
-
-    private final static Logger logger = LoggerFactory.getLogger(LogServiceDaoImpl.class);
-
-    /**
-     * 保存日志
-     * @param logMessageParams 日志参数信息
-     */
-    @Override
-    public void saveTransactionLog(Map logMessageParams) throws DAOException {
-        logger.debug("save log params :{}",logMessageParams);
-        try{
-            int row = sqlSessionTemplate.insert("logServiceDaoImpl.saveTransactionLog",logMessageParams);
-            if(row < 1){
-                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"save log error, nothing to save");
-            }
-        }catch (Exception e){
-            logger.error("save log error:",e);
-            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"save log error"+e);
-        }
-
-    }
-
-    /**
-     * 保存日志(交互报文)
-     * @param logMessageParams 日志参数信息
-     */
-    @Override
-    public void saveTransactionLogMessage(Map logMessageParams) throws DAOException{
-        logger.debug("save log message params :{}",logMessageParams);
-        try{
-            int row = sqlSessionTemplate.insert("logServiceDaoImpl.saveTransactionLogMessage",logMessageParams);
-            if(row < 1){
-                throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"save log error, nothing to save");
-            }
-        }catch (Exception e){
-            logger.error("save log error:",e);
-            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"save log error"+e);
-        }
-
-    }
-}

+ 0 - 16
service-log/src/main/java/com/java110/log/kafka/LogServiceBean.java

@@ -1,16 +0,0 @@
-package com.java110.log.kafka;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Created by wuxw on 2018/4/15.
- */
-@Configuration
-public class LogServiceBean {
-    @Bean
-    public LogServiceKafka listener() {
-        return new LogServiceKafka();
-    }
-
-}

+ 0 - 56
service-log/src/main/java/com/java110/log/kafka/LogServiceKafka.java

@@ -1,56 +0,0 @@
-package com.java110.log.kafka;
-
-import com.java110.core.base.controller.BaseController;
-import com.java110.log.smo.ILogServiceSMO;
-import org.apache.kafka.clients.consumer.ConsumerRecord;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.kafka.annotation.KafkaListener;
-
-/**
- * kafka侦听
- * 接受到的信息报文格式为:
- * {
- *     "transactionId":"交易流水号",
- *     "dataFlowId":"上下文对象",
- *     "ip":"ip",
- *     "port":"端口",
- *     "srcIp":"调用方IP",
- *     "srcPort":"调用方端口",
- *     "appId":"应用ID",
- *     "userId":"用户ID",
- *     "serviceCode":"服务编码",
- *     "serviceName":"服务名称",
- *     "timestamp":"时间储",
- *     "logStatus":"记录状态",
- *     "requestMessage":"请求信息",
- *     "responseMessage":"返回信息"
- * }
- * Created by wuxw on 2018/4/15.
- */
-public class LogServiceKafka extends BaseController {
-
-    private final static Logger logger = LoggerFactory.getLogger(LogServiceKafka.class);
-
-
-    @Autowired
-    private ILogServiceSMO logServiceSMOImpl;
-
-    @KafkaListener(topics = {"LOG"})
-    public void listen(ConsumerRecord<?, ?> record) {
-        logger.info("LogServiceKafka receive message: {}", record.value().toString());
-        String logMessage = record.value().toString();
-        logServiceSMOImpl.saveLogMessage(logMessage);
-    }
-
-
-
-    public ILogServiceSMO getLogServiceSMOImpl() {
-        return logServiceSMOImpl;
-    }
-
-    public void setLogServiceSMOImpl(ILogServiceSMO logServiceSMOImpl) {
-        this.logServiceSMOImpl = logServiceSMOImpl;
-    }
-}

+ 0 - 16
service-log/src/main/java/com/java110/log/package-info.java

@@ -1,16 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.log;

+ 0 - 37
service-log/src/main/java/com/java110/log/smo/ILogServiceSMO.java

@@ -1,37 +0,0 @@
-package com.java110.log.smo;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.entity.order.OrderList;
-
-/**
- * 订单服务业务处理接口
- *
- * 订单受理
- * Created by wuxw on 2017/4/11.
- */
-public interface ILogServiceSMO {
-
-    /**
-     * 保存日志信息
-     * {
-     *     "transactionId":"交易流水号",
-     *     "dataFlowId":"上下文对象",
-     *     "ip":"ip",
-     *     "port":"端口",
-     *     "srcIp":"调用方IP",
-     *     "srcPort":"调用方端口",
-     *     "appId":"应用ID",
-     *     "userId":"用户ID",
-     *     "serviceCode":"服务编码",
-     *     "serviceName":"服务名称",
-     *     "timestamp":"时间储",
-     *     "logStatus":"记录状态",
-     *     "requestMessage":"请求信息",
-     *     "responseMessage":"返回信息"
-     * }
-     * @param logMessage 需要保存的日志信息
-     *                   从kafka 中读取日志消息保存
-     */
-    public void saveLogMessage(String logMessage);
-
-}

+ 0 - 147
service-log/src/main/java/com/java110/log/smo/impl/LogServiceSMOImpl.java

@@ -1,147 +0,0 @@
-package com.java110.log.smo.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.DateUtil;
-import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.core.factory.GenerateCodeFactory;
-import com.java110.intf.code.ICodeApi;
-import com.java110.log.dao.LogServiceDao;
-import com.java110.log.smo.ILogServiceSMO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 日志 消息处理类
- * Created by wuxw on 2017/4/11.
- */
-@Service("logServiceSMOImpl")
-@Transactional
-public class LogServiceSMOImpl extends BaseServiceSMO implements ILogServiceSMO {
-
-    private static Logger logger = LoggerFactory.getLogger(LogServiceSMOImpl.class);
-
-    @Autowired
-    private ICodeApi codeApi;
-
-    @Autowired
-    private LogServiceDao logServiceDaoImpl;
-
-    /**
-     * 保存日志信息
-     *
-     * @param logMessage 需要保存的日志信息
-     */
-    @Override
-    public void saveLogMessage(String logMessage) {
-        logger.debug("received log message : {}", logMessage);
-
-        try {
-            doSaveLogMessage(logMessage);
-        } catch (Exception e) {
-            logger.error("save log message error :", e);
-        }
-    }
-
-
-    /**
-     * @param logMessage 需要保存的日志信息
-     * @throws Exception 异常信息
-     */
-    private void doSaveLogMessage(String logMessage) throws Exception {
-
-        JSONObject logMessageObj = JSONObject.parseObject(logMessage);
-        //校验
-        validateLogMessage(logMessageObj);
-
-        // 调用服务生成log_id
-        String logId = GenerateCodeFactory.getInnerTransactionId();
-        //String log_id = codeApi.generateCode("1000001");
-
-        // 封装日志保存参数
-        Map logMessageParams = new HashMap();
-        logMessageParams.put("logId", logId);
-        builderLogMessageParams(logMessageParams, logMessageObj);
-
-        //保存日志
-        logServiceDaoImpl.saveTransactionLog(logMessageParams);
-        //保存日志(交互报文)
-        logServiceDaoImpl.saveTransactionLogMessage(logMessageParams);
-
-    }
-
-    /**
-     * 封装日志保存参数
-     *
-     * @param logMessageParams 日志保存参数
-     * @param logMessageObj 日志消息对象
-     * @throws Exception 异常信息
-     */
-    private void builderLogMessageParams(Map logMessageParams, JSONObject logMessageObj) throws Exception {
-
-        logMessageParams.putAll(logMessageObj);
-        //#{requestHeader},#{responseHeader},#{requestMessage},#{responseMessage},#{remark}
-        String requestMessage = logMessageObj.getString("requestMessage");
-        String responseMessage = logMessageObj.getString("responseMessage");
-
-        JSONObject requestMessageObj = JSONObject.parseObject(requestMessage);
-        JSONObject responseMessageObj = JSONObject.parseObject(responseMessage);
-
-        logMessageParams.put("requestHeader", requestMessageObj.getString("headers"));
-        logMessageParams.put("requestMessage", requestMessageObj.getString("body"));
-        logMessageParams.put("responseHeader", responseMessageObj.getString("headers"));
-        logMessageParams.put("responseMessage", responseMessageObj.getString("body"));
-
-        logMessageParams.put("timestamp", DateUtil.getDefaultDateFromString(logMessageObj.getString("timestamp")));
-
-        logMessageParams.put("month", DateUtil.getCurrentMonth());
-    }
-
-    /**
-     * 校验 日志报文 必填节点是否存在
-     *
-     * @param logMessageObj JSON 化的日志信息
-     */
-    private void validateLogMessage(JSONObject logMessageObj) {
-
-        Assert.hasKeyAndValue(logMessageObj, "transactionId", "can not find transactionId node or transactionId is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "dataFlowId", "can not find dataFlowId node or dataFlowId is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "ip", "can not find ip node or ip is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "port", "can not find port node or port is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "appId", "can not find appId node or appId is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "timestamp", "can not find timestamp node or timestamp is null");
-
-        Assert.hasKeyAndValue(logMessageObj, "logStatus", "can not find logStatus node or logStatus is null");
-
-        Assert.hasKey(logMessageObj, "requestMessage", "can not find requestMessage node ");
-
-        Assert.hasKey(logMessageObj, "responseMessage", "can not find responseMessage node ");
-    }
-
-    public ICodeApi getCodeApi() {
-        return codeApi;
-    }
-
-    public void setCodeApi(ICodeApi codeApi) {
-        this.codeApi = codeApi;
-    }
-
-    public LogServiceDao getLogServiceDaoImpl() {
-        return logServiceDaoImpl;
-    }
-
-    public void setLogServiceDaoImpl(LogServiceDao logServiceDaoImpl) {
-        this.logServiceDaoImpl = logServiceDaoImpl;
-    }
-}

+ 0 - 96
service-log/src/main/resources/application-dev.yml

@@ -1,96 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: dev.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password:
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://dev.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8004
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: log-service
-  redis:
-    database: 0
-    host: 192.168.31.199
-    port: 6379
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: dev.zk.java110.com:2181
-    servers: dev.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: logService
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: dev.zk.java110.com:2181
-    servers: dev.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 96
service-log/src/main/resources/application-prod.yml

@@ -1,96 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: prod.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password:
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://prod.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8004
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: log-service
-  redis:
-    database: 0
-    host: 192.168.31.199
-    port: 6379
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://prod.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: prod.zk.java110.com:2181
-    servers: prod.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: logService
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: prod.zk.java110.com:2181
-    servers: prod.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 96
service-log/src/main/resources/application-test.yml

@@ -1,96 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: test.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password:
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://test.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8004
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: log-service
-  redis:
-    database: 0
-    host: 192.168.31.199
-    port: 6379
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://test.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: test.zk.java110.com:2181
-    servers: test.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: logService
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: test.zk.java110.com:2181
-    servers: test.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 3
service-log/src/main/resources/application.yml

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

+ 0 - 15
service-log/src/main/resources/banner.txt

@@ -1,15 +0,0 @@
-${AnsiColor.BRIGHT_RED}
-     __                       ____  ____ _______
-    |__|_____  ___  _______  /_   |/_   |\   _  \
-    |  |\__  \ \  \/ /\__  \  |   | |   |/  /_\  \
-    |  | / __ \_\   /  / __ \_|   | |   |\  \_/   \
-/\__|  |(____  / \_/  (____  /|___| |___| \_____  /
-\______|     \/            \/                   \/
-_________                   __                   _________                      .__
-\_   ___ \   ____    ____ _/  |_   ____ _______ /   _____/  ____ _______ ___  __|__|  ____   ____
-/    \  \/ _/ __ \  /    \\   __\_/ __ \\_  __ \\_____  \ _/ __ \\_  __ \\  \/ /|  |_/ ___\_/ __ \
-\     \____\  ___/ |   |  \|  |  \  ___/ |  | \//        \\  ___/ |  | \/ \   / |  |\  \___\  ___/
- \______  / \___  >|___|  /|__|   \___  >|__|  /_______  / \___  >|__|     \_/  |__| \___  >\___  >
-        \/      \/      \/            \/               \/      \/                        \/     \/
-
- java110 CenterService starting, more information scan https://github.com/java110/MicroCommunity

+ 0 - 3
service-log/src/main/resources/java110.properties

@@ -1,3 +0,0 @@
-java110.mappingPath=classpath:mapper/*/*.xml
-
-

+ 0 - 39
service-log/src/test/java/com/java110/log/AppTest.java

@@ -1,39 +0,0 @@
-package com.java110.log;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest 
-    extends TestCase
-{
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public AppTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( AppTest.class );
-    }
-
-    /**
-     * Rigourous Test :-)
-     */
-    public void testApp()
-    {
-
-        //System.out.println(ICodeApi.class.getName());
-    }
-}

+ 0 - 114
service-log/src/test/java/com/java110/log/common/PreBoCustAttr.java

@@ -1,114 +0,0 @@
-package com.java110.log.common;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.entity.user.BoCustAttr;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Created by wuxw on 2017/4/29.
- */
-public class PreBoCustAttr extends TestCase
-{
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public PreBoCustAttr( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( PreBoCustAttr.class );
-    }
-
-
-    public void testGetPreBoCustAttr(){
-        List<BoCustAttr> boCustAttrs = new ArrayList<BoCustAttr>();
-        BoCustAttr boCustAttr = null;
-        for(int boCustAttrIndex = 0; boCustAttrIndex < 3; boCustAttrIndex++){
-            boCustAttr = new BoCustAttr();
-
-            boCustAttr.setCustId("1234456");
-            boCustAttr.setBoId("1");
-            boCustAttr.setAttrCd("BoCustAttr"+boCustAttrIndex);
-            boCustAttr.setCreate_dt(new Date());
-            boCustAttr.setState("ADD");
-            boCustAttr.setValue(boCustAttrIndex+"");
-            boCustAttrs.add(boCustAttr);
-        }
-
-        for(int boCustAttrIndex = 0; boCustAttrIndex < 5; boCustAttrIndex++){
-            boCustAttr = new BoCustAttr();
-
-            boCustAttr.setCustId("1234456");
-            boCustAttr.setBoId("2");
-            boCustAttr.setAttrCd("BoCustAttr"+boCustAttrIndex);
-            boCustAttr.setCreate_dt(new Date());
-            boCustAttr.setState("ADD");
-            boCustAttr.setValue(boCustAttrIndex+"");
-            boCustAttrs.add(boCustAttr);
-        }
-
-        for(int boCustAttrIndex = 0; boCustAttrIndex < 3; boCustAttrIndex++){
-            boCustAttr = new BoCustAttr();
-
-            boCustAttr.setCustId("1234456");
-            boCustAttr.setBoId("3");
-            boCustAttr.setAttrCd("BoCustAttr"+boCustAttrIndex);
-            boCustAttr.setCreate_dt(new Date());
-            boCustAttr.setState("ADD");
-            boCustAttr.setValue(boCustAttrIndex+"");
-            boCustAttrs.add(boCustAttr);
-        }
-
-        for (BoCustAttr boCustAttrTml : boCustAttrs){
-            System.out.println(JSONObject.toJSON(boCustAttrTml));
-        }
-
-        System.out.println("-----------------------------处理前------------------------------------");
-
-        boCustAttrs = getPreBoCustAttrs(boCustAttrs);
-
-        for (BoCustAttr boCustAttrTml : boCustAttrs){
-            System.out.println(JSONObject.toJSON(boCustAttrTml));
-        }
-
-        System.out.println("-----------------------------处理后------------------------------------");
-
-    }
-
-    /**
-     * 获取上上一次的操作
-     * @param boCustAttrs
-     * @return
-     */
-    private List<BoCustAttr> getPreBoCustAttrs(List<BoCustAttr> boCustAttrs){
-
-        String firstBoId = boCustAttrs.get(0).getBoId();
-        String preBoId = "";
-        List<BoCustAttr> preBoCustAttrs = new ArrayList<BoCustAttr>();
-        for(BoCustAttr boCustAttr : boCustAttrs){
-            if(!firstBoId.equals(boCustAttr.getBoId())){
-                if(!preBoId.equals(boCustAttr.getBoId()) && !"".equals(preBoId)){
-                    break;
-                }
-                preBoId = boCustAttr.getBoId();
-                preBoCustAttrs.add(boCustAttr);
-            }
-        }
-        return preBoCustAttrs;
-    }
-
-}

+ 0 - 80
service-log/src/test/java/com/java110/log/executor/ExecutorTest.java

@@ -1,80 +0,0 @@
-package com.java110.log.executor;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-/**
- * Created by wuxw on 2017/4/25.
- */
-public class ExecutorTest  extends TestCase
-{
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public ExecutorTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( ExecutorTest.class );
-    }
-
-    public void testThrowException(){
-        ExecutorService executorService = Executors.newFixedThreadPool(100);
-
-        int i = 0;
-        List<Future<Integer>> futureList = new ArrayList<Future<Integer>>();
-        while(i < 5) {
-            Future<Integer> sum = executorService.submit(new PrintInt());
-            i++;
-            futureList.add(sum);
-        }
-
-        for(Future<Integer> sum : futureList) {
-            try{
-
-                    System.out.println(sum.get());
-
-            }catch (Exception e){
-                System.out.println("异常了");
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public void testThrowException1(){
-        ExecutorService executorService = Executors.newFixedThreadPool(100);
-
-        int i = 0;
-        while(i < 5) {
-            Future<Integer> sum = executorService.submit(new PrintInt());
-            i++;
-
-            try{
-
-                System.out.println(sum.get());
-
-            }catch (Exception e){
-                System.out.println("异常了");
-                e.printStackTrace();
-            }
-
-        }
-
-    }
-
-}

+ 0 - 23
service-log/src/test/java/com/java110/log/executor/PrintInt.java

@@ -1,23 +0,0 @@
-package com.java110.log.executor;
-
-import java.util.concurrent.Callable;
-
-/**
- * Created by wuxw on 2017/4/25.
- */
-public class PrintInt implements Callable<Integer> {
-    @Override
-    public Integer call() throws Exception {
-
-        System.out.println("1234567");
-
-        //Thread.sleep(10000);
-        throwException();
-
-        return 1111;
-    }
-
-    private void throwException(){
-        throw new IllegalArgumentException("异常了,报出来。。。");
-    }
-}

Разница между файлами не показана из-за своего большого размера
+ 0 - 38
service-log/src/test/java/com/java110/log/jsonpath/CustIdTest.java


+ 0 - 22
service-log/src/test/java/com/java110/log/type/AppCustEvent.java

@@ -1,22 +0,0 @@
-package com.java110.log.type;
-
-import com.java110.core.context.AppContext;
-
-
-/**
- * 客户事件
- * Created by wuxw on 2017/4/14.
- */
-public class AppCustEvent extends AppEvent {
-
-    /**
-     * Constructs a prototypical Event.
-     *
-     * @param source The object on which the Event initially occurred.
-     * @throws IllegalArgumentException if source is null.
-     */
-    public AppCustEvent(Object source, AppContext context) {
-        super(source,context);
-    }
-
-}

+ 0 - 24
service-log/src/test/java/com/java110/log/type/AppEvent.java

@@ -1,24 +0,0 @@
-package com.java110.log.type;
-
-import com.java110.core.context.AppContext;
-
-import java.util.EventObject;
-
-/**
- * java110 事件
- * Created by wuxw on 2017/4/14.
- */
-public class AppEvent extends EventObject {
-    /**
-     * Constructs a prototypical Event.
-     *
-     * @param source The object on which the Event initially occurred.
-     * @throws IllegalArgumentException if source is null.
-     */
-    public AppEvent(AppContext source) {
-        super(source);
-    }
-    public AppEvent(Object obj,AppContext source) {
-        super(source);
-    }
-}

+ 0 - 19
service-log/src/test/java/com/java110/log/type/AppListener.java

@@ -1,19 +0,0 @@
-package com.java110.log.type;
-
-
-
-import java.util.EventListener;
-
-/**
- * 通用事件处理,
- * Created by wuxw on 2017/4/14.
- */
-public interface AppListener<E extends AppEvent> extends EventListener {
-
-    /**
-     * Handle an application event.
-     * @param event the event to respond to
-     */
-    void onJava110Event(E event);
-
-}

+ 0 - 40
service-log/src/test/java/com/java110/log/type/CommonTest.java

@@ -1,40 +0,0 @@
-package com.java110.log.type;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Created by wuxw on 2017/4/22.
- */
-public class CommonTest
-        extends TestCase
-{
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public CommonTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( CommonTest.class );
-    }
-
-
-    public void testSubString(){
-        String actionTypeCds = "'C1','A1','M1',";
-        actionTypeCds = actionTypeCds.endsWith(",")?actionTypeCds.substring(0,actionTypeCds.length()-1):actionTypeCds;
-
-        System.out.println(actionTypeCds);
-    }
-
-
-}

+ 0 - 21
service-log/src/test/java/com/java110/log/type/CustDispatchListener.java

@@ -1,21 +0,0 @@
-package com.java110.log.type;
-
-
-
-/**
- * Created by wuxw on 2017/4/14.
- */
-public class CustDispatchListener implements AppListener<AppCustEvent> ,Ordered{
-
-    private final static int order = Ordered.dafultValue+1;
-    @Override
-    public void onJava110Event(AppCustEvent event) {
-
-        //这里写 客户信息处理逻辑
-    }
-
-    @Override
-    public int getOrder() {
-        return order;
-    }
-}

+ 0 - 19
service-log/src/test/java/com/java110/log/type/Ordered.java

@@ -1,19 +0,0 @@
-package com.java110.log.type;
-
-/**
- * 顺序
- * Created by wuxw on 2017/4/14.
- */
-public interface Ordered {
-
-    /**
-     * 默认值
-     */
-    public final static int dafultValue = 0;
-
-    /**
-     * 获取顺序,为了同一个事件需要多个侦听处理时,需要有前后顺序
-     * @return
-     */
-    public int getOrder();
-}

+ 0 - 45
service-log/src/test/java/com/java110/log/type/TypeTest.java

@@ -1,45 +0,0 @@
-package com.java110.log.type;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-/**
- * Created by wuxw on 2017/4/14.
- */
-public class TypeTest
-
-    extends TestCase
-    {
-        /**
-         * Create the test case
-         *
-         * @param testName name of the test case
-         */
-    public TypeTest( String testName )
-        {
-            super( testName );
-        }
-
-        /**
-         * @return the suite of tests being tested
-         */
-    public static Test suite()
-    {
-        return new TestSuite( TypeTest.class );
-    }
-
-        /**
-         *
-         * @since 1.7
-         * @throws Exception
-         */
-    public void testType() throws Exception{
-       Object obj = Class.forName("com.java110.log.type.CustDispatchListener").newInstance();
-        Type[] types = obj.getClass().getGenericInterfaces();
-       System.out.println(((ParameterizedType)types[0]).getActualTypeArguments()[0].getTypeName());
-    }
-}

+ 52 - 0
service-order/src/main/java/com/java110/order/listener/TransactionOrderInfoToKafkaListener.java

@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.order.listener;
+
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.IOrderDataFlowContext;
+import com.java110.core.event.app.order.Ordered;
+import com.java110.core.event.center.event.InvokeFinishBusinessSystemEvent;
+import com.java110.core.event.center.listener.DataFlowListener;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.ListenerExecuteException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 用户ID处理 侦听
+ * Created by wuxw on 2018/7/2.
+ */
+
+@Java110Listener(name = "transactionOrderInfoToKafkaListener")
+public class TransactionOrderInfoToKafkaListener implements DataFlowListener<InvokeFinishBusinessSystemEvent>, Ordered {
+
+    private final static Logger logger = LoggerFactory.getLogger(TransactionOrderInfoToKafkaListener.class);
+
+    @Override
+    public void soService(InvokeFinishBusinessSystemEvent event) {
+        IOrderDataFlowContext dataFlow = event.getDataFlow();
+        if (dataFlow == null || dataFlow.getBusinessList() == null || dataFlow.getBusinessList().size() == 0) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR, "用户ID处理侦听执行异常,没有可处理的business");
+        }
+
+        //判断是否存在 "serviceCode": "save.user.info", 业务,如果存在则处理
+    }
+
+    @Override
+    public int getOrder() {
+        return 1;
+    }
+}

+ 16 - 36
service-order/src/main/java/com/java110/order/smo/impl/OrderServiceSMOImpl.java

@@ -2,48 +2,30 @@ package com.java110.order.smo.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.java110.utils.cache.MappingCache;
-import com.java110.utils.constant.CommonConstant;
-import com.java110.utils.constant.KafkaConstant;
-import com.java110.utils.constant.MappingConstant;
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.constant.StatusConstant;
-import com.java110.utils.exception.BusinessException;
-import com.java110.utils.exception.BusinessStatusException;
-import com.java110.utils.exception.DAOException;
-import com.java110.utils.exception.DecryptException;
-import com.java110.utils.exception.InitConfigDataException;
-import com.java110.utils.exception.NoAuthorityException;
-import com.java110.utils.exception.NoSupportException;
-import com.java110.utils.exception.OrdersException;
-import com.java110.utils.exception.RuleException;
-import com.java110.utils.exception.SMOException;
-import com.java110.utils.factory.ApplicationContextFactory;
-import com.java110.utils.kafka.KafkaFactory;
-import com.java110.utils.log.LoggerEngine;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.ServiceBusinessUtil;
-import com.java110.utils.util.StringUtil;
-import com.java110.utils.util.WebServiceAxisClient;
 import com.java110.core.client.RestTemplate;
-import com.java110.core.context.DataFlow;
-import com.java110.core.context.IOrderDataFlowContext;
-import com.java110.core.context.IOrderNotifyDataFlowContext;
-import com.java110.core.context.IOrderResponse;
-import com.java110.core.context.OrderDataFlow;
-import com.java110.core.context.OrderNotifyDataFlow;
+import com.java110.core.context.*;
+import com.java110.core.event.center.DataFlowEventPublishing;
 import com.java110.core.factory.AuthenticationFactory;
 import com.java110.core.factory.OrderDataFlowContextFactory;
+import com.java110.core.log.LogAgent;
 import com.java110.entity.center.AppService;
 import com.java110.entity.center.DataFlowLinksCost;
 import com.java110.entity.order.Business;
 import com.java110.entity.order.ServiceBusiness;
-import com.java110.core.event.center.DataFlowEventPublishing;
-import com.java110.core.log.LogAgent;
 import com.java110.order.dao.ICenterServiceDAO;
 import com.java110.order.smo.IOrderServiceSMO;
 import com.java110.service.init.ServiceInfoListener;
 import com.java110.service.smo.IQueryServiceSMO;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.*;
+import com.java110.utils.exception.*;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.kafka.KafkaFactory;
+import com.java110.utils.log.LoggerEngine;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ServiceBusinessUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.utils.util.WebServiceAxisClient;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,8 +53,6 @@ public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements
     private static Logger logger = LoggerFactory.getLogger(OrderServiceSMOImpl.class);
 
 
-
-
     @Autowired
     private IQueryServiceSMO queryServiceSMOImpl;
 
@@ -107,6 +87,9 @@ public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements
             DataFlowEventPublishing.invokeBusinessSystem(dataFlow);
             invokeBusinessSystem(dataFlow);
 
+            // 业务调用完成
+            DataFlowEventPublishing.invokeFinishBusinessSystem(dataFlow);
+
             //能够执行到这一步 认为是都成功了
             refreshOrderDataFlowResJson(dataFlow);
 
@@ -322,7 +305,6 @@ public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements
     }
 
 
-
     /**
      * 加入撤单记录
      *
@@ -647,7 +629,6 @@ public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements
     }
 
 
-
     /**
      * 处理异步业务
      *
@@ -744,7 +725,6 @@ public class OrderServiceSMOImpl extends AbstractOrderServiceSMOImpl implements
     }
 
 
-
     public ICenterServiceDAO getCenterServiceDaoImpl() {
         return centerServiceDaoImpl;
     }

+ 0 - 28
service-sequence/Readme.md

@@ -1,28 +0,0 @@
-## 编码生成服务(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、协议 访问[这里](https://github.com/java110/MicroCommunity/wiki/%E7%B3%BB%E7%BB%9FID%E7%94%9F%E6%88%90%E5%8D%8F%E8%AE%AE)
-
-

+ 0 - 14
service-sequence/bin/start_code.sh

@@ -1,14 +0,0 @@
-#!/bin/bash
-#### debug model prod
-#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev target/CodeService.jar $1 > code.log 2>&1 &
-
-#### normal prod model
-#nohup java -jar -Dspring.profiles.active=prod $1 target/CodeService.jar > code.log $1 2>&1 &
-
-#### normal test model
-#nohup java -jar -Dspring.profiles.active=test $1 target/CodeService.jar > code.log $1 2>&1 &
-
-#### normal dev model
-nohup java -jar -Dspring.profiles.active=$1 $2 target/CodeService.jar > code.log $1 2>&1 &
-
-tail -100f code.log

+ 0 - 6
service-sequence/doc/IdRequest_protocol.json

@@ -1,6 +0,0 @@
-{
-    "transactionId": "100000000020180409224736000001",
-    "requestTime": "20180409224736",
-    "prefix": "71",
-    "name": "订单ID生成"
-}

+ 0 - 7
service-sequence/doc/IdResponse_protocol.json

@@ -1,7 +0,0 @@
-{
-    "transactionId": "100000000020180409224736000001",
-    "responseTime": "20180409224736",
-    "id": "71009183837738",
-    "code":"0000",
-    "message": "订单ID生成"
-}

+ 0 - 14
service-sequence/doc/start_codeService.sh

@@ -1,14 +0,0 @@
-#!/bin/bash
-#### debug model prod
-#nohup java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar -Dspring.profiles.active=dev CodeService.jar $1 > code.log 2>&1 &
-
-#### normal prod model
-#nohup java -jar -Dspring.profiles.active=prod $1 CodeService.jar > code.log $1 2>&1 &
-
-#### normal test model
-#nohup java -jar -Dspring.profiles.active=test $1 CodeService.jar > code.log $1 2>&1 &
-
-#### normal dev model
-nohup java -jar -Dspring.profiles.active=dev $1 CodeService.jar > code.log $1 2>&1 &
-
-tail -100f code.log

+ 0 - 11
service-sequence/docker/Dockerfile

@@ -1,11 +0,0 @@
-FROM registry.cn-beijing.aliyuncs.com/sxd/ubuntu-java8:1.0
-MAINTAINER wuxw <928255095@qq.com>
-
-ADD target/service-sequence.jar /root/target/
-
-ADD bin/start_code.sh /root/
-
-
-RUN chmod u+x /root/start_code.sh
-
-CMD ["/root/start_code.sh","dev"]

+ 0 - 11
service-sequence/docker/onStart.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-cp -r ../bin .
-
-cp  -r ../target .
-
-docker build -t java110/code .
-
-docker run -ti --name code_test -p8003:8003 -idt java110/code:latest
-
-docker logs -f code_test

+ 0 - 70
service-sequence/pom.xml

@@ -1,70 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>MicroCommunity</artifactId>
-        <groupId>com.java110</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>service-sequence</artifactId>
-    <packaging>jar</packaging>
-
-    <name>service-sequence</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>com.java110</groupId>
-            <artifactId>java110-service</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <finalName>service-sequence</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <version>2.10</version>
-                <executions>
-                    <execution>
-                        <id>unpack</id>
-                        <phase>generate-resources</phase>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <configuration>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>com.java110</groupId>
-                                    <artifactId>java110-interface</artifactId>
-                                    <version>${microcommunity.version}</version>
-                                    <type>jar</type>
-                                    <overWrite>true</overWrite>
-                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <mainClass>com.java110.code.CodeServiceApplicationStart</mainClass>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 0 - 90
service-sequence/src/main/java/com/java110/code/CodeServiceApplicationStart.java

@@ -1,90 +0,0 @@
-package com.java110.code;
-
-/**
- * Hello world!
- */
-
-import com.java110.core.client.RestTemplate;
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.exception.StartException;
-import com.java110.utils.factory.ApplicationContextFactory;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.StringUtil;
-import com.java110.config.properties.code.ZookeeperProperties;
-import com.java110.service.init.ServiceInfoListener;
-import com.java110.service.init.ServiceStartInit;
-import org.apache.zookeeper.*;
-import org.apache.zookeeper.data.Stat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
-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.loadbalancer.LoadBalanced;
-import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.http.converter.StringHttpMessageConverter;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.charset.Charset;
-import java.util.List;
-
-/**
- * spring boot 初始化启动类
- *
- * @version v0.1
- * @auther com.java110.wuxw
- * @mail 928255095@qq.com
- * @date 2016年8月6日
- * @tag
- */
-@SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.code", "com.java110.core",
-        "com.java110.config.properties.code", "com.java110.db"})
-//@SpringBootApplication(scanBasePackages = {"com.java110.service","com.java110.code","com.java110.config.properties.code"})
-@EnableDiscoveryClient
-@EnableFeignClients(basePackages = {"com.java110.intf"})
-public class CodeServiceApplicationStart {
-    protected final static Logger logger = LoggerFactory.getLogger(CodeServiceApplicationStart.class);
-
-
-    /**
-     * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力.
-     *
-     * @return restTemplate
-     */
-    @Bean
-    @LoadBalanced
-    public RestTemplate restTemplate() {
-        StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
-        RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class);
-        return restTemplate;
-    }
-
-    /**
-     * 实例化RestTemplate
-     *
-     * @return restTemplate
-     */
-    @Bean
-    public RestTemplate outRestTemplate() {
-        StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
-        RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class);
-        return restTemplate;
-    }
-
-    public static void main(String[] args) throws Exception {
-
-        ApplicationContext context = SpringApplication.run(CodeServiceApplicationStart.class, args);
-
-        ServiceStartInit.initSystemConfig(context);
-
-
-
-    }
-
-
-
-}

+ 0 - 159
service-sequence/src/main/java/com/java110/code/api/CodeApi.java

@@ -1,159 +0,0 @@
-package com.java110.code.api;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.code.smo.IPrimaryKeyServiceSMO;
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.exception.ResponseErrorException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.DateUtil;
-import com.java110.core.base.controller.BaseController;
-import com.java110.core.context.CodeDataFlow;
-import com.java110.core.factory.DataFlowFactory;
-import com.java110.core.factory.DataTransactionFactory;
-import com.java110.intf.code.ICodeApi;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * ID 生成
- * Created by wuxw on 2018/6/3.
- */
-@RestController
-public class CodeApi extends BaseController implements ICodeApi {
-
-    protected static Logger logger = LoggerFactory.getLogger(CodeApi.class);
-
-
-    @Autowired
-    IPrimaryKeyServiceSMO primaryKeyServiceSMOImpl;
-
-    /**
-     * 生成编码服务器 不支持Get方法请求
-     * @param request http 请求对象
-     * @return 不支持Get方法请求
-     */
-    @Deprecated
-    @RequestMapping(path = "/codeApi/generate", method = RequestMethod.GET)
-    public String generateGet(HttpServletRequest request) {
-        return DataTransactionFactory.createCodeResponseJson(ResponseConstant.NO_TRANSACTION_ID, "-1",
-                ResponseConstant.RESULT_CODE_ERROR, "不支持Get方法请求").toJSONString();
-    }
-
-    /**
-     * 生成编码服务器 不支持Get方法请求
-     * @param orderInfo 请求信息
-     * @param request http 请求对象
-     * @return 不支持Get方法请求
-     */
-    @RequestMapping(path = "/codeApi/generate", method = RequestMethod.POST)
-    public String generatePost(@RequestBody String orderInfo, HttpServletRequest request) {
-        Map<String, String> headers = new HashMap<String, String>();
-        try {
-            getRequestInfo(request, headers);
-            //预校验
-            preValidateOrderInfo(orderInfo, headers);
-            CodeDataFlow dataFlow = DataFlowFactory.newInstance(CodeDataFlow.class).builder(orderInfo, null);
-            primaryKeyServiceSMOImpl.generateCode(dataFlow);
-            return dataFlow.getResJson().toJSONString();
-        } catch (Exception e) {
-            logger.error("请求订单异常", e);
-            return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + e).toJSONString();
-        }
-    }
-
-    /**
-     * 获取请求信息
-     *
-     * @param request 请求信息封装
-     * @param headers 请求头信息
-     * @throws Exception 处理数据失败会返回Exception异常
-     */
-    private void getRequestInfo(HttpServletRequest request, Map headers) throws Exception {
-        try {
-            super.initHeadParam(request, headers);
-            super.initUrlParam(request, headers);
-        } catch (Exception e) {
-            logger.error("加载头信息失败", e);
-            throw e;
-        }
-    }
-
-    /**
-     * 这里预校验,请求报文中不能有 dataFlowId
-     *
-     * @param orderInfo 请求信息封装
-     * @param headers  请求头信息
-     */
-    private void preValidateOrderInfo(String orderInfo, Map<String, String> headers) {
-
-        Assert.jsonObjectHaveKey(orderInfo, "prefix", "没有包含prefix");
-
-        Assert.jsonObjectHaveKey(orderInfo, "transactionId", "没有包含transactionId");
-
-    }
-
-
-    public IPrimaryKeyServiceSMO getPrimaryKeyServiceSMOImpl() {
-        return primaryKeyServiceSMOImpl;
-    }
-
-    public void setPrimaryKeyServiceSMOImpl(IPrimaryKeyServiceSMO primaryKeyServiceSMOImpl) {
-        this.primaryKeyServiceSMOImpl = primaryKeyServiceSMOImpl;
-    }
-
-    /**
-     * 生成 编码
-     *
-     * @param prefix 前缀
-     * @return
-     */
-    @Override
-    @RequestMapping(value = "/codeApi/generateCode", method = RequestMethod.POST)
-    public String generateCode(@RequestParam("prefix") String prefix) {
-
-        try {
-            JSONObject requestInfo = new JSONObject();
-
-            //封装符合构建CodeDataFlow对象的JSON对象参数
-            builderRequestInfo(prefix, requestInfo);
-
-            CodeDataFlow dataFlow = DataFlowFactory.newInstance(CodeDataFlow.class).builder(requestInfo.toJSONString(), null);
-
-            //生成编码
-            primaryKeyServiceSMOImpl.generateCode(dataFlow);
-
-            if (!ResponseConstant.RESULT_CODE_SUCCESS.equals(dataFlow.getResJson().getString("code"))) {
-                throw new ResponseErrorException(ResponseConstant.RESULT_CODE_ERROR, "生成编码失败 "
-                        + dataFlow.getResJson().getString("message"));
-            }
-
-            return dataFlow.getResJson().getString("id");
-        } catch (Exception e) {
-            logger.error("请求订单异常", e);
-            return ResponseConstant.RESULT_CODE_ERROR;
-        }
-    }
-
-    /**
-     * 封装符合构建CodeDataFlow对象的JSON对象参数
-     *
-     * @param prefix      前缀
-     * @param requestInfo 构建的请求JSON对象
-     */
-    private void builderRequestInfo(String prefix, JSONObject requestInfo) {
-        requestInfo.put("transactionId", UUID.randomUUID().toString().replace("-", ""));
-        requestInfo.put("prefix", prefix);
-        requestInfo.put("requestTime", DateUtil.getNowDefault());
-    }
-}

+ 0 - 66
service-sequence/src/main/java/com/java110/code/dao/ICommonServiceDao.java

@@ -1,66 +0,0 @@
-package com.java110.code.dao;
-
-
-import com.java110.entity.mapping.CodeMapping;
-
-import java.util.List;
-
-/**
- * 公用处理,与数据库交互
- * 如:映射关系加载
- * Created by wuxw on 2017/3/2.
- * version:1.0
- */
-public interface ICommonServiceDao {
-
-
-    /**
-     * 查询所有有效的映射数据
-     *
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingAll()  throws Exception;
-
-    /**
-     * 根据域查询对应的映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据HCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping)  throws Exception;
-
-
-    /**
-     * 根据PCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据domain 和 hcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据domain 和 pcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping) throws Exception;
-
-
-}

+ 0 - 22
service-sequence/src/main/java/com/java110/code/dao/IPrimaryKeyServiceDao.java

@@ -1,22 +0,0 @@
-package com.java110.code.dao;
-
-import java.util.Map;
-
-/**
- * 主键查询操作数据类
- * <p>
- * Created by wuxw on 2016/12/27.
- */
-public interface IPrimaryKeyServiceDao {
-
-    /**
-     * 根据主键name查询主键生成ID
-     * map 中必须包含name字段
-     *
-     * @param primaryKey 主键name信息
-     * @return 返回map中为 targetId 字段
-     */
-    public Map queryPrimaryKey(Map primaryKey) throws RuntimeException;
-
-
-}

+ 0 - 14
service-sequence/src/main/java/com/java110/code/dao/ISnowflakeldWorker.java

@@ -1,14 +0,0 @@
-package com.java110.code.dao;
-
-/**
- * Created by wuxw on 2018/6/3.
- */
-public interface ISnowflakeldWorker {
-
-    /**
-     * 根据前缀生成ID
-     * @param prefix
-     * @return
-     */
-    public String getIdByPrefix(String prefix,long workId);
-}

+ 0 - 160
service-sequence/src/main/java/com/java110/code/dao/impl/CommonServiceDaoImpl.java

@@ -1,160 +0,0 @@
-package com.java110.code.dao.impl;
-
-import com.java110.code.dao.ICommonServiceDao;
-import com.java110.utils.util.SerializeUtil;
-import com.java110.core.base.dao.BaseServiceDao;
-import com.java110.entity.mapping.CodeMapping;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import redis.clients.jedis.Jedis;
-
-import java.util.List;
-
-/**
- * 公用处理,与数据库交互 实现类
- * 如:映射关系加载
- * Created by wuxw on 2017/3/2.
- * version:1.0
- */
-@Service("commonServiceDaoImpl")
-@Transactional
-public class CommonServiceDaoImpl extends BaseServiceDao implements ICommonServiceDao {
-
-    protected final static Logger logger = LoggerFactory.getLogger(CommonServiceDaoImpl.class);
-
-
-    /**
-     * 查询所有有效的映射数据
-     *
-     * @return
-     */
-    @Override
-    @Cacheable(key= "CodeMappingAll")
-    public List<CodeMapping> getCodeMappingAll() throws Exception{
-       Jedis jedis = this.getJedis();
-
-       List<CodeMapping> codeMappings = null;
-       if(jedis.exists("CodeMappingAll".getBytes())){
-           codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingAll".getBytes()),CodeMapping.class);
-       }else{
-           codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingAll");
-
-           jedis.set("CodeMappingAll".getBytes(),SerializeUtil.serializeList(codeMappings));
-       }
-        return codeMappings;
-    }
-
-    /**
-     * 根据域查询对应的映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-
-    @Override
-    @Cacheable(key= "CodeMappingByDomain")
-    public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception{
-
-        Jedis jedis = this.getJedis();
-        List<CodeMapping> codeMappings = null;
-        if(jedis.exists("CodeMappingByDomain".getBytes())){
-            codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomain".getBytes()),CodeMapping.class);
-        }else{
-            codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingByDomain", codeMapping);
-
-            jedis.set("CodeMappingByDomain".getBytes(),SerializeUtil.serializeList(codeMappings));
-        }
-        return codeMappings;
-    }
-
-    /**
-     * 根据HCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    @Override
-    @Cacheable(key= "CodeMappingByHCode")
-    public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping) throws Exception{
-
-        Jedis jedis = this.getJedis();
-        List<CodeMapping> codeMappings = null;
-        if(jedis.exists("CodeMappingByHCode".getBytes())){
-            codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByHCode".getBytes()),CodeMapping.class);
-        }else{
-            codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingByHCode", codeMapping);
-
-            jedis.set("CodeMappingByHCode".getBytes(),SerializeUtil.serializeList(codeMappings));
-        }
-        return codeMappings;
-    }
-
-    /**
-     * 根据PCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    @Override
-    @Cacheable(key= "CodeMappingByPCode")
-    public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception{
-
-        Jedis jedis = this.getJedis();
-        List<CodeMapping> codeMappings = null;
-        if(jedis.exists("CodeMappingByPCode".getBytes())){
-            codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByPCode".getBytes()),CodeMapping.class);
-        }else{
-            codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingByPCode", codeMapping);
-
-            jedis.set("CodeMappingByPCode".getBytes(),SerializeUtil.serializeList(codeMappings));
-        }
-        return codeMappings;
-    }
-
-    /**
-     * 根据domain 和 hcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    @Override
-    @Cacheable(key= "CodeMappingByDomainAndHCode")
-    public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception{
-
-        Jedis jedis = this.getJedis();
-        List<CodeMapping> codeMappings = null;
-        if(jedis.exists("CodeMappingByDomainAndHCode".getBytes())){
-            codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndHCode".getBytes()),CodeMapping.class);
-        }else{
-            codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingByDomainAndHCode", codeMapping);
-
-            jedis.set("CodeMappingByDomainAndHCode".getBytes(),SerializeUtil.serializeList(codeMappings));
-        }
-        return codeMappings;
-    }
-
-    /**
-     * 根据domain 和 pcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    @Override
-    @Cacheable(key= "CodeMappingByDomainAndPCode")
-    public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping)  throws Exception{
-
-        Jedis jedis = this.getJedis();
-        List<CodeMapping> codeMappings = null;
-        if(jedis.exists("CodeMappingByDomainAndPCode".getBytes())){
-            codeMappings = SerializeUtil.unserializeList(jedis.get("CodeMappingByDomainAndPCode".getBytes()),CodeMapping.class);
-        }else{
-            codeMappings = sqlSessionTemplate.selectList("commonServiceDaoImpl.getCodeMappingByDomainAndPCode", codeMapping);
-
-            jedis.set("CodeMappingByDomainAndPCode".getBytes(),SerializeUtil.serializeList(codeMappings));
-        }
-        return codeMappings;
-    }
-}

+ 0 - 40
service-sequence/src/main/java/com/java110/code/dao/impl/PrimaryKeyServiceDaoImpl.java

@@ -1,40 +0,0 @@
-package com.java110.code.dao.impl;
-
-import com.java110.code.dao.IPrimaryKeyServiceDao;
-import com.java110.utils.log.LoggerEngine;
-import com.java110.core.base.dao.BaseServiceDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Map;
-
-/**
- * 用户服务 与数据库交互
- * Created by wuxw on 2017/4/5.
- */
-
-/**
- * 用户信息实现工程
- * Created by wuxw on 2016/12/27.
- */
-@Service("primaryKeyServiceDaoImpl")
-@Transactional
-public class PrimaryKeyServiceDaoImpl extends BaseServiceDao implements IPrimaryKeyServiceDao {
-
-    protected final static Logger logger = LoggerFactory.getLogger(PrimaryKeyServiceDaoImpl.class);
-
-    /**
-     * 根据主键name查询主键生成ID
-     *
-     * @param primaryKey 主键name信息
-     * @return
-     */
-    @Override
-    public Map queryPrimaryKey(Map primaryKey) {
-
-        LoggerEngine.debug("----【PrimaryKeyServiceDaoImpl.queryPrimaryKey】入参 : " + primaryKey);
-        return sqlSessionTemplate.selectOne("primaryKeyServiceDaoImpl.queryPrimaryKey", primaryKey);
-    }
-}

+ 0 - 182
service-sequence/src/main/java/com/java110/code/dao/impl/SnowflakeIdWorkerImpl.java

@@ -1,182 +0,0 @@
-package com.java110.code.dao.impl;
-
-
-/**
- * Twitter_Snowflake<br>
- * SnowFlake的结构如下(每部分用-分开):<br>
- * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
- * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
- * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
- * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
- * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
- * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
- * 加起来刚好64位,为一个Long型。<br>
- * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
- */
-
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.utils.exception.DAOException;
-import com.java110.utils.log.LoggerEngine;
-import com.java110.code.dao.ISnowflakeldWorker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-/**
- * Created by wuxw on 2018/5/28.
- */
-@Service
-public class SnowflakeIdWorkerImpl extends LoggerEngine implements ISnowflakeldWorker {
-
-    protected final static Logger logger = LoggerFactory.getLogger(SnowflakeIdWorkerImpl.class);
-
-
-    // ==============================Fields===========================================
-    /** 开始时间截 (2015-01-01) */
-    private final long twepoch = 1420041600000L;
-
-    /** 机器id所占的位数 */
-    //private final long workerIdBits = 5L;
-    private final long workerIdBits = 10L;
-
-    /** 数据标识id所占的位数 */
-   // private final long datacenterIdBits = 5L;
-
-    /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
-    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
-
-    /** 支持的最大数据标识id,结果是31 */
-   // private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
-
-    /** 序列在id中占的位数 */
-    private final long sequenceBits = 12L;
-
-    /** 机器ID向左移12位 */
-    private final long workerIdShift = sequenceBits;
-
-    /** 数据标识id向左移17位(12+5) */
-    private final long datacenterIdShift = sequenceBits + workerIdBits;
-
-    /** 时间截向左移22位(5+5+12) */
-    private final long timestampLeftShift = sequenceBits + workerIdBits ;//+ datacenterIdBits;
-
-    /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
-    private final long sequenceMask = -1L ^ (-1L << sequenceBits);
-
-    /** 工作机器ID(0~31) */
-    private long workerId;
-
-    /** 数据中心ID(0~31) */
-    private long datacenterId;
-
-    /** 毫秒内序列(0~4095) */
-    private long sequence = 0L;
-
-    /** 上次生成ID的时间截 */
-    private long lastTimestamp = -1L;
-
-    //==============================Constructors=====================================
-    /**
-     * 构造函数
-
-     */
-    public SnowflakeIdWorkerImpl() {
-
-    }
-
-    // ==============================Methods==========================================
-    /**
-     * 获得下一个ID (该方法是线程安全的)
-     * @param workerId 工作ID (0~1024)
-     * @return SnowflakeId
-     */
-    public synchronized long nextId(long workerId) {
-
-        if (workerId > maxWorkerId || workerId < 0) {
-            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
-        }
-       /* if (datacenterId > maxDatacenterId || datacenterId < 0) {
-            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
-        }*/
-        this.workerId = workerId;
-      /*  this.datacenterId = datacenterId;*/
-
-        long timestamp = timeGen();
-
-        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
-        if (timestamp < lastTimestamp) {
-            throw new RuntimeException(
-                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
-        }
-
-        //如果是同一时间生成的,则进行毫秒内序列
-        if (lastTimestamp == timestamp) {
-            sequence = (sequence + 1) & sequenceMask;
-            //毫秒内序列溢出
-            if (sequence == 0) {
-                //阻塞到下一个毫秒,获得新的时间戳
-                timestamp = tilNextMillis(lastTimestamp);
-            }
-        }
-        //时间戳改变,毫秒内序列重置
-        else {
-            sequence = 0L;
-        }
-
-        //上次生成ID的时间截
-        lastTimestamp = timestamp;
-
-        //移位并通过或运算拼到一起组成64位的ID
-        return ((timestamp - twepoch) << timestampLeftShift) //
-                //| (datacenterId << datacenterIdShift) //
-                | (workerId << workerIdShift) //
-                | sequence;
-    }
-
-    /**
-     * 阻塞到下一个毫秒,直到获得新的时间戳
-     * @param lastTimestamp 上次生成ID的时间截
-     * @return 当前时间戳
-     */
-    protected long tilNextMillis(long lastTimestamp) {
-        long timestamp = timeGen();
-        while (timestamp <= lastTimestamp) {
-            timestamp = timeGen();
-        }
-        return timestamp;
-    }
-
-    /**
-     * 返回以毫秒为单位的当前时间
-     * @return 当前时间(毫秒)
-     */
-    protected long timeGen() {
-        return System.currentTimeMillis();
-    }
-
-    //==============================Test=============================================
-    /** 测试 */
-    public static void main(String[] args) {
-        SnowflakeIdWorkerImpl idWorker = new SnowflakeIdWorkerImpl();
-        for (int i = 0; i < 1000; i++) {
-            long id = idWorker.nextId(0);
-            System.out.println(Long.toBinaryString(id));
-            System.out.println(id);
-        }
-    }
-
-    @Override
-    public String getIdByPrefix(String prefix,long workId) throws DAOException{
-        String id = prefix;
-        try{
-            id += nextId(workId);
-        }catch (Exception e){
-            logger.error("生成主键ID异常"+prefix,e);
-            throw new DAOException(ResponseConstant.RESULT_CODE_INNER_ERROR,"生成主键ID异常"+prefix+e);
-        }finally {
-            return id;
-        }
-    }
-
-
-}

+ 0 - 16
service-sequence/src/main/java/com/java110/code/package-info.java

@@ -1,16 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.code;

+ 0 - 62
service-sequence/src/main/java/com/java110/code/smo/ICommonServiceSmo.java

@@ -1,62 +0,0 @@
-package com.java110.code.smo;
-
-import com.java110.entity.mapping.CodeMapping;
-
-import java.util.List;
-
-/**
- * Created by wuxw on 2017/7/25.
- */
-public interface ICommonServiceSmo {
-
-    /**
-     * 查询所有有效的映射数据
-     *
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingAll()  throws Exception;
-
-    /**
-     * 根据域查询对应的映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据HCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping)  throws Exception;
-
-
-    /**
-     * 根据PCode查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据domain 和 hcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception;
-
-    /**
-     * 根据domain 和 pcode 查询映射关系
-     *
-     * @param codeMapping
-     * @return
-     */
-    public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping)  throws Exception;
-
-
-
-}

+ 0 - 27
service-sequence/src/main/java/com/java110/code/smo/IPrimaryKeyServiceSMO.java

@@ -1,27 +0,0 @@
-package com.java110.code.smo;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.utils.exception.SMOException;
-import com.java110.core.context.CodeDataFlow;
-
-/**
- * 用户信息管理,服务
- * Created by wuxw on 2017/4/5.
- */
-public interface IPrimaryKeyServiceSMO {
-
-    /**
-     * 根据sequence 表中name 查询ID
-     *
-     * @param primaryKeyInfo name信息封装
-     * @return
-     */
-    public JSONObject queryPrimaryKey(JSONObject primaryKeyInfo) throws Exception;
-
-    /**
-     * 生成编码
-     * @param dataFlow
-     * @throws SMOException
-     */
-    public void generateCode(CodeDataFlow dataFlow) throws SMOException;
-}

+ 0 - 62
service-sequence/src/main/java/com/java110/code/smo/impl/CommonServiceSmoImpl.java

@@ -1,62 +0,0 @@
-package com.java110.code.smo.impl;
-
-import com.java110.code.dao.ICommonServiceDao;
-import com.java110.code.smo.ICommonServiceSmo;
-import com.java110.entity.mapping.CodeMapping;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * Created by wuxw on 2017/7/25.
- */
-@Service("commonServiceSmoImpl")
-public class CommonServiceSmoImpl implements ICommonServiceSmo {
-
-    protected final static Logger logger = LoggerFactory.getLogger(CommonServiceSmoImpl.class);
-
-    @Autowired
-    ICommonServiceDao commonServiceDaoImpl;
-
-    @Override
-    public List<CodeMapping> getCodeMappingAll()  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingAll();
-    }
-
-    @Override
-    public List<CodeMapping> getCodeMappingByDomain(CodeMapping codeMapping)  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingByDomain(codeMapping);
-    }
-
-    @Override
-    public List<CodeMapping> getCodeMappingByHCode(CodeMapping codeMapping)  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingByHCode(codeMapping);
-    }
-
-    @Override
-    public List<CodeMapping> getCodeMappingByPCode(CodeMapping codeMapping)  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingByPCode(codeMapping);
-    }
-
-    @Override
-    public List<CodeMapping> getCodeMappingByDomainAndHCode(CodeMapping codeMapping)  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingByDomainAndHCode(codeMapping);
-    }
-
-    @Override
-    public List<CodeMapping> getCodeMappingByDomainAndPCode(CodeMapping codeMapping)  throws Exception{
-        return commonServiceDaoImpl.getCodeMappingByDomainAndPCode(codeMapping);
-    }
-
-
-    public ICommonServiceDao getCommonServiceDaoImpl() {
-        return commonServiceDaoImpl;
-    }
-
-    public void setCommonServiceDaoImpl(ICommonServiceDao commonServiceDaoImpl) {
-        this.commonServiceDaoImpl = commonServiceDaoImpl;
-    }
-}

+ 0 - 80
service-sequence/src/main/java/com/java110/code/smo/impl/PrimaryKeyServiceSMOImpl.java

@@ -1,80 +0,0 @@
-package com.java110.code.smo.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.code.dao.IPrimaryKeyServiceDao;
-import com.java110.code.dao.ISnowflakeldWorker;
-import com.java110.code.smo.IPrimaryKeyServiceSMO;
-import com.java110.utils.constant.ResponseConstant;
-import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.core.context.CodeDataFlow;
-import com.java110.core.factory.DataTransactionFactory;
-import com.java110.service.init.ServiceInfoListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Map;
-
-/**
- * 用户服务信息管理业务信息实现
- * Created by wuxw on 2017/4/5.
- */
-@Service("primaryKeyServiceSMOImpl")
-public class PrimaryKeyServiceSMOImpl extends BaseServiceSMO implements IPrimaryKeyServiceSMO {
-    protected final static Logger logger = LoggerFactory.getLogger(PrimaryKeyServiceSMOImpl.class);
-
-
-    @Autowired
-    IPrimaryKeyServiceDao iPrimaryKeyServiceDao;
-
-    @Autowired
-    ISnowflakeldWorker snowflakeIdWorkerImpl;
-
-    @Autowired
-    private ServiceInfoListener serviceInfoListener;
-
-    /**
-     * 根据sequence 表中name 查询ID
-     *
-     * @param primaryKeyInfo name信息封装
-     * @return
-     */
-    public JSONObject queryPrimaryKey(JSONObject primaryKeyInfo) throws Exception {
-        Map paramIn = JSONObject.toJavaObject(primaryKeyInfo, Map.class);
-        Map primaryKey = iPrimaryKeyServiceDao.queryPrimaryKey(paramIn);
-        JSONObject returnPrimaryKey = new JSONObject();
-        if (primaryKey != null && primaryKey.containsKey("targetId")) {
-            returnPrimaryKey.put("targetId", primaryKey.get("targetId"));
-        } else {
-            //如果没定义相应name的键序列,直接返回-1 表示 自己系统需要自己生成
-            returnPrimaryKey.put("targetId", "-1");
-        }
-        return returnPrimaryKey;
-    }
-
-    public void generateCode(CodeDataFlow dataFlow){
-        String code = snowflakeIdWorkerImpl.getIdByPrefix(dataFlow.getPrefix(),serviceInfoListener.getWorkId());
-
-        JSONObject resJson = DataTransactionFactory.createCodeResponseJson(dataFlow.getTransactionId(),code, ResponseConstant.RESULT_CODE_SUCCESS,"成功");
-
-        dataFlow.setResJson(resJson);
-    }
-
-    public ServiceInfoListener getServiceInfoListener() {
-        return serviceInfoListener;
-    }
-
-    public void setServiceInfoListener(ServiceInfoListener serviceInfoListener) {
-        this.serviceInfoListener = serviceInfoListener;
-    }
-
-
-    public ISnowflakeldWorker getSnowflakeIdWorkerImpl() {
-        return snowflakeIdWorkerImpl;
-    }
-
-    public void setSnowflakeIdWorkerImpl(ISnowflakeldWorker snowflakeIdWorkerImpl) {
-        this.snowflakeIdWorkerImpl = snowflakeIdWorkerImpl;
-    }
-}

+ 0 - 97
service-sequence/src/main/resources/application-dev.yml

@@ -1,97 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: dev.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password: hc
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://dev.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8003
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: code-service
-  redis:
-    database: 0
-    host: dev.redis.java110.com
-    port: 6379
-    password: hc
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: dev.zk.java110.com:2181
-    servers: dev.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: codeServiceStatus
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: dev.zk.java110.com:2181
-    servers: dev.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 97
service-sequence/src/main/resources/application-prod.yml

@@ -1,97 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: prod.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password: hc
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://prod.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8003
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: code-service
-  redis:
-    database: 0
-    host: prod.redis.java110.com
-    port: 6379
-    password: hc
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://prod.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: prod.zk.java110.com:2181
-    servers: prod.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: codeServiceStatus
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: prod.zk.java110.com:2181
-    servers: prod.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 97
service-sequence/src/main/resources/application-test.yml

@@ -1,97 +0,0 @@
-jedis:
-  pool:
-    config:
-      maxTotal: 100
-      maxIdle: 20
-      maxWaitMillis: 20000
-    host: test.redis.java110.com
-    port: 6379
-    timeout: 3000
-    password: hc
-
-eureka:
-  instance:
-    leaseRenewalIntervalInSeconds: 10
-    leaseExpirationDurationInSeconds: 30
-    preferIpAddress: true
-    instanceId: ${spring.cloud.client.ip-address}:${server.port}
-  client:
-    serviceUrl:
-      defaultZone: http://test.java110.com:8761/eureka/
-      #defaultZone: http://localhost:8761/eureka/
-server:
-  port: 8003
-  tomcat:
-    uri-encoding: UTF-8
-
-spring:
-  http:
-    encoding:
-      charset: UTF-8
-      enabled: true
-      force: true
-  application:
-    name: code-service
-  redis:
-    database: 0
-    host: test.redis.java110.com
-    port: 6379
-    password: hc
-    pool:
-      max-active: 300
-      max-wait: 10000
-      max-idle: 100
-      min-idle: 0
-      timeout: 0
-  datasource:
-    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-    type: com.alibaba.druid.pool.DruidDataSource
-    url: jdbc:mysql://test.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    maxPoolPreparedStatementPerConnectionSize: 20
-    password: TT@12345678
-    testOnBorrow: false
-    testWhileIdle: true
-    minEvictableIdleTimeMillis: 300000
-    timeBetweenEvictionRunsMillis: 60000
-    testOnReturn: false
-    driverClassName: com.mysql.cj.jdbc.Driver
-    maxActive: 20
-    username: TT
-
-#============== kafka ===================
-kafka:
-  consumer:
-    zookeeper:
-      connect: test.zk.java110.com:2181
-    servers: test.kafka.java110.com:9092
-    enable:
-      auto:
-        commit: true
-    session:
-      timeout: 6000
-    auto:
-      commit:
-        interval: 100
-      offset:
-        reset: latest
-    topic: test
-    group:
-      id: codeServiceStatus
-    concurrency: 10
-
-  producer:
-    zookeeper:
-      connect: test.zk.java110.com:2181
-    servers: test.kafka.java110.com:9092
-    retries: 0
-    batch:
-      size: 4096
-    linger: 1
-    buffer:
-      memory: 40960

+ 0 - 3
service-sequence/src/main/resources/application.yml

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

+ 0 - 23
service-sequence/src/main/resources/banner.txt

@@ -1,23 +0,0 @@
-${AnsiColor.BRIGHT_RED}
-////////////////////////////////////////////////////////////////////
-//                          _ooOoo_                               //
-//                         o8888888o                              //
-//                         88" . "88                              //
-//                         (| ^_^ |)                              //
-//                         O\  =  /O                              //
-//                      ____/`---'\____                           //
-//                    .'  \\|     |//  `.                         //
-//                   /  \\|||  :  |||//  \                        //
-//                  /  _||||| -:- |||||-  \                       //
-//                  |   | \\\  -  /// |   |                       //
-//                  | \_|  ''\---/''  |   |                       //
-//                  \  .-\__  `-`  ___/-. /                       //
-//                ___`. .'  /--.--\  `. . ___                     //
-//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
-//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
-//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
-//      ========`-.____`-.___\_____/___.-`____.-'========         //
-//                           `=---='                              //
-//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
-//            佛祖保佑       永不宕机     永无BUG                  //
-////////////////////////////////////////////////////////////////////

+ 0 - 75
service-sequence/src/main/resources/dataSource.yml

@@ -1,75 +0,0 @@
-dataSources:
-  ds0: !!com.alibaba.druid.pool.DruidDataSource
-    driverClassName: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://dev.db.java110.com:3306/hc_community?useUnicode=true&characterEncoding=utf-8
-    username: hc_community
-    password: hc_community@12345678
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-#  ds0_slave0: !!com.alibaba.druid.pool.DruidDataSource
-#    driverClassName: com.mysql.jdbc.Driver
-#    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-#    username: TT
-#    password: TT@12345678
-#    connectionTimeoutMilliseconds: 30000
-#    idleTimeoutMilliseconds: 60000
-#    maxPoolSize: 50
-#    minPoolSize: 1
-#    maintenanceIntervalMilliseconds: 30000
-  ds1: !!com.alibaba.druid.pool.DruidDataSource
-    driverClassName: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-    username: TT
-    password: TT@12345678
-    minIdle: 5
-    validationQuery: SELECT 1 FROM DUAL
-    initialSize: 5
-    maxWait: 60000
-    filters: stat,wall,log4j
-    poolPreparedStatements: true
-#  ds1_slave0: !!com.alibaba.druid.pool.DruidDataSource
-#    driverClassName: com.mysql.jdbc.Driver
-#    url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
-#    username: TT
-#    password: TT@12345678
-#    connectionTimeoutMilliseconds: 30000
-#    idleTimeoutMilliseconds: 60000
-#    maxPoolSize: 50
-#    minPoolSize: 1
-#    maintenanceIntervalMilliseconds: 30000
-
-shardingRule:
-  tables:
-    business_xxx:
-      actualDataNodes: ds${0..1}.business_community
-      databaseStrategy:
-        inline:
-          shardingColumn: community_id
-          algorithmExpression: ds${Long.parseLong(community_id) % 2}
-
-  bindingTables:
-    - business_xxx
-
-  defaultDataSourceName: ds1
-  defaultDatabaseStrategy:
-    none:
-  defaultTableStrategy:
-    none:
-
-#  masterSlaveRules:
-#    ms_ds0:
-#     masterDataSourceName: ds0
-#     slaveDataSourceNames:
-#       - ds0_slave0
-#     loadBalanceAlgorithmType: ROUND_ROBIN
-#   ms_ds1:
-#     masterDataSourceName: ds1
-#     slaveDataSourceNames:
-#       - ds1_slave0
-#     loadBalanceAlgorithmType: ROUND_ROBIN
-props:
-  sql.show: true

+ 0 - 3
service-sequence/src/main/resources/java110.properties

@@ -1,3 +0,0 @@
-java110.mappingPath=classpath:mapper/*/*.xml
-
-

+ 0 - 34
service-sequence/src/test/java/com/java110/AppTest.java

@@ -1,34 +0,0 @@
-package com.java110;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
-        extends TestCase {
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public AppTest(String testName) {
-        super(testName);
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite() {
-        return new TestSuite(AppTest.class);
-    }
-
-    /**
-     * Rigourous Test :-)
-     */
-    public void testApp() {
-        assertTrue(true);
-    }
-}