Przeglądaj źródła

加入硬件设配层服务,对接硬件设备,目前对接锐目人脸识别

wuxw 6 lat temu
rodzic
commit
0b3366a4eb
20 zmienionych plików z 988 dodań i 0 usunięć
  1. 10 0
      HardwareAdapationService/docker/Dockerfile
  2. 14 0
      HardwareAdapationService/docker/bin/start_hardwareAdapation.sh
  3. 25 0
      HardwareAdapationService/docker/docker-compose.yml
  4. 11 0
      HardwareAdapationService/docker/onStart.sh
  5. 76 0
      HardwareAdapationService/pom.xml
  6. 63 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/HardwareAdapationServiceApplicationStart.java
  7. 104 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/api/HardwareAdapationApi.java
  8. 16 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/kafka/HardwareAdapationServiceBean.java
  9. 92 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/kafka/HardwareAdapationServiceKafka.java
  10. 17 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/IHardwareAdapationServiceSMO.java
  11. 112 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/impl/HardwareAdapationServiceSMOImpl.java
  12. 98 0
      HardwareAdapationService/src/main/resources/application-dev.yml
  13. 96 0
      HardwareAdapationService/src/main/resources/application-prod.yml
  14. 61 0
      HardwareAdapationService/src/main/resources/application-share.yml
  15. 96 0
      HardwareAdapationService/src/main/resources/application-test.yml
  16. 3 0
      HardwareAdapationService/src/main/resources/application.yml
  17. 15 0
      HardwareAdapationService/src/main/resources/banner.txt
  18. 75 0
      HardwareAdapationService/src/main/resources/dataSource.yml
  19. 3 0
      HardwareAdapationService/src/main/resources/java110.properties
  20. 1 0
      pom.xml

+ 10 - 0
HardwareAdapationService/docker/Dockerfile

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

+ 14 - 0
HardwareAdapationService/docker/bin/start_hardwareAdapation.sh

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

+ 25 - 0
HardwareAdapationService/docker/docker-compose.yml

@@ -0,0 +1,25 @@
+version: '2'
+services:
+   hardwareadapationserivce:
+       container_name: hardwareadapationserivce-1
+       build:
+          context: .
+          dockerfile: Dockerfile
+       restart: always
+       ports:
+       - "8010:8010"
+       volumes:
+       - ../target/HardwareAdapationService.jar:/root/target/HardwareAdapationService.jar
+       networks:
+       - java110-net
+#       mem_limit: 1024m
+#       extra_hosts:
+#       - "dev.java110.com:192.168.1.18"
+#       - "dev.db.java110.com:192.168.1.18"
+#       - "dev.zk.java110.com:192.168.1.18"
+#       - "dev.kafka.java110.com:192.168.1.18"
+#       - "dev.redis.java110.com:192.168.1.18"
+#       - "api.java110.com:92.168.1.18"
+networks:
+  java110-net:
+    external: true

+ 11 - 0
HardwareAdapationService/docker/onStart.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cp -r ../bin .
+
+cp  -r ../target .
+
+docker build -t java110/hardwareAdapation .
+
+docker run -ti --name hardwareAdapation_test -p8010:8010 -idt java110/hardwareAdapation:latest
+
+docker logs -f hardwareAdapation_test

+ 76 - 0
HardwareAdapationService/pom.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>HardwareAdapationService</artifactId>
+  <packaging>jar</packaging>
+
+  <name>HardwareAdapationService</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>com.java110</groupId>
+      <artifactId>java110-service</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.java110</groupId>
+      <artifactId>java110-event</artifactId>
+    </dependency>
+
+  </dependencies>
+
+
+  <build>
+    <finalName>HardwareAdapationService</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-config</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.hardwareAdapation.HardwareAdapationServiceApplicationStart</mainClass>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

+ 63 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/HardwareAdapationServiceApplicationStart.java

@@ -0,0 +1,63 @@
+package com.java110.fee;
+
+import com.java110.core.annotation.Java110ListenerDiscovery;
+import com.java110.event.service.BusinessServiceDataFlowEventPublishing;
+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.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 org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.Charset;
+
+
+/**
+ * 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.hardwareAdapation",
+        "com.java110.core", "com.java110.cache", "com.java110.config.properties.code","com.java110.db"})
+@EnableDiscoveryClient
+@Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
+        basePackages = {"com.java110.hardwareAdapation.listener"})
+@EnableFeignClients(basePackages = {"com.java110.core.smo.user"})
+public class HardwareAdapationServiceApplicationStart {
+
+    private static Logger logger = LoggerFactory.getLogger(HardwareAdapationServiceApplicationStart.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();
+        return restTemplate;
+    }
+
+    public static void main(String[] args) throws Exception {
+        try{
+            ApplicationContext context = SpringApplication.run(HardwareAdapationServiceApplicationStart.class, args);
+            ServiceStartInit.initSystemConfig(context);
+        }catch (Throwable e){
+            logger.error("系统启动失败",e);
+        }
+    }
+}

+ 104 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/api/HardwareAdapationApi.java

@@ -0,0 +1,104 @@
+package com.java110.hardwareAdapation.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.InitDataFlowContextException;
+import com.java110.core.base.controller.BaseController;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.core.factory.DataTransactionFactory;
+import com.java110.hardwareAdapation.smo.IHardwareAdapationServiceSMO;
+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.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 用户服务类
+ * Created by wuxw on 2018/5/14.
+ */
+@RestController
+public class HardwareAdapationApi extends BaseController {
+    private final static Logger logger = LoggerFactory.getLogger(HardwareAdapationApi.class);
+
+    @Autowired
+    IHardwareAdapationServiceSMO hardwareAdapationServiceSMOImpl;
+
+    @RequestMapping(path = "/hardwareAdapationApi/service",method= RequestMethod.GET)
+    public String serviceGet(HttpServletRequest request) {
+        return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,"不支持Get方法请求").toJSONString();
+    }
+
+    /**
+     * 用户服务统一处理接口
+     * @param orderInfo
+     * @param request
+     * @return
+     */
+    @RequestMapping(path = "/hardwareAdapationApi/service",method= RequestMethod.POST)
+    public String servicePost(@RequestBody String orderInfo, HttpServletRequest request) {
+        BusinessServiceDataFlow businessServiceDataFlow = null;
+        JSONObject responseJson = null;
+        try {
+            Map<String, String> headers = new HashMap<String, String>();
+            getRequestInfo(request, headers);
+            //预校验
+            preValiateOrderInfo(orderInfo);
+            businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers);
+            responseJson = hardwareAdapationServiceSMOImpl.service(businessServiceDataFlow);
+        }catch (InitDataFlowContextException e){
+            logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败"+orderInfo,e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
+        }catch (InitConfigDataException e){
+            logger.error("请求报文错误,加载配置信息失败"+orderInfo,e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
+        }catch (Exception e){
+            logger.error("请求订单异常",e);
+            responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow,ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e,
+                    null);
+        }finally {
+            return responseJson.toJSONString();
+        }
+    }
+
+    /**
+     * 这里预校验,请求报文中不能有 dataFlowId
+     * @param orderInfo
+     */
+    private void preValiateOrderInfo(String orderInfo) {
+       /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){
+            throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点");
+        }*/
+    }
+
+    /**
+     * 获取请求信息
+     * @param request
+     * @param headers
+     * @throws RuntimeException
+     */
+    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 new InitConfigDataException(ResponseConstant.RESULT_PARAM_ERROR,"加载头信息失败");
+        }
+    }
+
+    public IHardwareAdapationServiceSMO getHardwareAdapationServiceSMOImpl() {
+        return hardwareAdapationServiceSMOImpl;
+    }
+
+    public void setHardwareAdapationServiceSMOImpl(IHardwareAdapationServiceSMO hardwareAdapationServiceSMOImpl) {
+        this.hardwareAdapationServiceSMOImpl = hardwareAdapationServiceSMOImpl;
+    }
+}

+ 16 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/kafka/HardwareAdapationServiceBean.java

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

+ 92 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/kafka/HardwareAdapationServiceKafka.java

@@ -0,0 +1,92 @@
+package com.java110.hardwareAdapation.kafka;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.KafkaConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.exception.InitConfigDataException;
+import com.java110.utils.exception.InitDataFlowContextException;
+import com.java110.utils.kafka.KafkaFactory;
+import com.java110.core.base.controller.BaseController;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.core.factory.DataTransactionFactory;
+import com.java110.hardwareAdapation.smo.IHardwareAdapationServiceSMO;
+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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * kafka侦听
+ * Created by wuxw on 2018/4/15.
+ */
+public class HardwareAdapationServiceKafka extends BaseController {
+
+    private final static Logger logger = LoggerFactory.getLogger(HardwareAdapationServiceKafka.class);
+
+
+    @Autowired
+    private IHardwareAdapationServiceSMO hardwareAdapationServiceSMOImpl;
+
+    @KafkaListener(topics = {"hardwareAdapationServiceTopic"})
+    public void listen(ConsumerRecord<?, ?> record) {
+        logger.info("kafka的key: " + record.key());
+        logger.info("kafka的value: " + record.value().toString());
+        String orderInfo = record.value().toString();
+        BusinessServiceDataFlow businessServiceDataFlow = null;
+        JSONObject responseJson = null;
+        try {
+            Map<String, String> headers = new HashMap<String, String>();
+            //预校验
+            preValiateOrderInfo(orderInfo);
+            businessServiceDataFlow = this.writeDataToDataFlowContext(orderInfo, headers);
+            responseJson = hardwareAdapationServiceSMOImpl.service(businessServiceDataFlow);
+        }catch (InitDataFlowContextException e){
+            logger.error("请求报文错误,初始化 BusinessServiceDataFlow失败"+orderInfo,e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
+        }catch (InitConfigDataException e){
+            logger.error("请求报文错误,加载配置信息失败"+orderInfo,e);
+            responseJson = DataTransactionFactory.createNoBusinessTypeBusinessResponseJson(orderInfo,ResponseConstant.RESULT_PARAM_ERROR,e.getMessage(),null);
+        }catch (Exception e){
+            logger.error("请求订单异常",e);
+            responseJson = DataTransactionFactory.createBusinessResponseJson(businessServiceDataFlow,ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e,
+                    null);
+        }finally {
+            logger.debug("当前请求报文:" + orderInfo +", 当前返回报文:" +responseJson.toJSONString());
+            //只有business 和 instance 过程才做通知消息
+            if(!StatusConstant.REQUEST_BUSINESS_TYPE_BUSINESS.equals(responseJson.getString("businessType"))
+                    && !StatusConstant.REQUEST_BUSINESS_TYPE_INSTANCE.equals(responseJson.getString("businessType"))){
+                return ;
+            }
+            try {
+                KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_NOTIFY_CENTER_SERVICE_NAME, "", responseJson.toJSONString());
+            }catch (Exception e){
+                logger.error("用户服务通知centerService失败"+responseJson,e);
+                //这里保存异常信息
+            }
+        }
+    }
+
+
+    /**
+     * 这里预校验,请求报文中不能有 dataFlowId
+     * @param orderInfo
+     */
+    private void preValiateOrderInfo(String orderInfo) {
+       /* if(JSONObject.parseObject(orderInfo).getJSONObject("orders").containsKey("dataFlowId")){
+            throw new BusinessException(ResponseConstant.RESULT_CODE_ERROR,"报文中不能存在dataFlowId节点");
+        }*/
+    }
+
+    public IHardwareAdapationServiceSMO getHardwareAdapationServiceSMOImpl() {
+        return hardwareAdapationServiceSMOImpl;
+    }
+
+    public void setHardwareAdapationServiceSMOImpl(IHardwareAdapationServiceSMO hardwareAdapationServiceSMOImpl) {
+        this.hardwareAdapationServiceSMOImpl = hardwareAdapationServiceSMOImpl;
+    }
+}

+ 17 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/IHardwareAdapationServiceSMO.java

@@ -0,0 +1,17 @@
+package com.java110.hardwareAdapation.smo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.exception.SMOException;
+import com.java110.core.context.BusinessServiceDataFlow;
+
+/**
+ *
+ * 用户信息管理,服务
+ * Created by wuxw on 2017/4/5.
+ */
+public interface IHardwareAdapationServiceSMO {
+
+
+    public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException;
+
+}

+ 112 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/smo/impl/HardwareAdapationServiceSMOImpl.java

@@ -0,0 +1,112 @@
+package com.java110.hardwareAdapation.smo.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.KafkaConstant;
+import com.java110.utils.constant.MappingConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.SMOException;
+import com.java110.utils.kafka.KafkaFactory;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.hardwareAdapation.smo.IHardwareAdapationServiceSMO;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.context.BusinessServiceDataFlow;
+import com.java110.core.factory.DataFlowFactory;
+import com.java110.entity.center.DataFlowLinksCost;
+import com.java110.entity.center.DataFlowLog;
+import com.java110.event.service.BusinessServiceDataFlowEventPublishing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 用户服务信息管理业务信息实现
+ * Created by wuxw on 2017/4/5.
+ */
+@Service("hardwareAdapationServiceSMOImpl")
+@Transactional
+public class HardwareAdapationServiceSMOImpl extends BaseServiceSMO implements IHardwareAdapationServiceSMO {
+
+    private static Logger logger = LoggerFactory.getLogger(HardwareAdapationServiceSMOImpl.class);
+
+    @Override
+    public JSONObject service(BusinessServiceDataFlow businessServiceDataFlow) throws SMOException {
+        try {
+            Assert.hasLength(businessServiceDataFlow.getbId(), "bId 不能为空");
+
+            BusinessServiceDataFlowEventPublishing.multicastEvent(businessServiceDataFlow);
+            Assert.notEmpty(businessServiceDataFlow.getResJson(), "用户服务[" + businessServiceDataFlow.getCurrentBusiness().getServiceCode() + "]没有返回内容");
+        } catch (Exception e) {
+            logger.error("用户信息处理异常", e);
+            throw new SMOException(ResponseConstant.RESULT_PARAM_ERROR, "用户信息处理异常" + e.getMessage());
+        } finally {
+            if (businessServiceDataFlow == null) {
+                return null;
+            }
+
+            //这里记录日志
+            Date endDate = DateUtil.getCurrentDate();
+
+            businessServiceDataFlow.setEndDate(endDate);
+            //添加耗时
+            DataFlowFactory.addCostTime(businessServiceDataFlow, "service", "业务处理总耗时",
+                    businessServiceDataFlow.getStartDate(), businessServiceDataFlow.getEndDate());
+            //保存耗时
+            saveCostTimeLogMessage(businessServiceDataFlow);
+            //保存日志
+            saveLogMessage(businessServiceDataFlow);
+        }
+        return businessServiceDataFlow.getResJson();
+    }
+
+    /**
+     * 保存日志信息
+     *
+     * @param businessServiceDataFlow
+     */
+    private void saveLogMessage(BusinessServiceDataFlow businessServiceDataFlow) {
+
+        try {
+            if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_LOG_ON_OFF))) {
+                for (DataFlowLog dataFlowLog : businessServiceDataFlow.getLogDatas()) {
+                    KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_LOG_NAME, "", JSONObject.toJSONString(dataFlowLog));
+                }
+            }
+        } catch (Exception e) {
+            logger.error("报错日志出错了,", e);
+        }
+    }
+
+    /**
+     * 保存耗时信息
+     *
+     * @param businessServiceDataFlow
+     */
+    private void saveCostTimeLogMessage(BusinessServiceDataFlow businessServiceDataFlow) {
+        try {
+            if (MappingConstant.VALUE_ON.equals(MappingCache.getValue(MappingConstant.KEY_COST_TIME_ON_OFF))) {
+                List<DataFlowLinksCost> dataFlowLinksCosts = businessServiceDataFlow.getLinksCostDates();
+                JSONObject costDate = new JSONObject();
+                JSONArray costDates = new JSONArray();
+                JSONObject newObj = null;
+                for (DataFlowLinksCost dataFlowLinksCost : dataFlowLinksCosts) {
+                    newObj = JSONObject.parseObject(JSONObject.toJSONString(dataFlowLinksCost));
+                    newObj.put("dataFlowId", businessServiceDataFlow.getDataFlowId());
+                    newObj.put("transactionId", businessServiceDataFlow.getTransactionId());
+                    costDates.add(newObj);
+                }
+                costDate.put("costDates", costDates);
+
+                KafkaFactory.sendKafkaMessage(KafkaConstant.TOPIC_COST_TIME_LOG_NAME, "", costDate.toJSONString());
+            }
+        } catch (Exception e) {
+            logger.error("报错日志出错了,", e);
+        }
+    }
+}

+ 98 - 0
HardwareAdapationService/src/main/resources/application-dev.yml

@@ -0,0 +1,98 @@
+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: 8011
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  profiles:
+    active: share
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: hardwareAdapation-service
+  redis:
+    database: 0
+    host: dev.redis.java110.com
+    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.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: hardwareAdapationBusinessStatus
+    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

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

@@ -0,0 +1,96 @@
+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: 8011
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: hardwareAdapation-service
+  redis:
+    database: 0
+    host: prod.redis.java110.com
+    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.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: hardwareAdapationBusinessStatus
+    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

+ 61 - 0
HardwareAdapationService/src/main/resources/application-share.yml

@@ -0,0 +1,61 @@
+spring:
+  shardingsphere:
+    datasource:
+#      names: ds_master_0,ds_master_1,ds_master_0_slave_0,ds_master_0_slave_1,ds_master_1_slave_0,ds_master_1_slave_1
+      names: ds_master_0,ds_master_1
+#      ds_master_0_slave_0:
+#        jdbc-url: jdbc:mysql://localhost:3306/demo_ds_master_0_slave_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+#        password:
+#        type: com.zaxxer.hikari.HikariDataSource
+#        driver-class-name: com.mysql.jdbc.Driver
+#        username: root
+      ds_master_0:
+        driver-class-name: com.mysql.jdbc.Driver
+        type: com.alibaba.druid.pool.DruidDataSource
+        jdbc-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
+      ds_master_1:
+        driver-class-name: com.mysql.jdbc.Driver
+        type: com.alibaba.druid.pool.DruidDataSource
+        jdbc-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
+    sharding:
+      tables:
+        business_community:
+          actual-data-nodes: ds_master_$->{0..1}.business_community
+          database-strategy:
+            inline:
+              sharding-column: community_id
+              algorithm-expression: ds_master_$->{Long.parseLong(community_id) % 2}
+        community:
+          actual-data-nodes: ds_master_$->{0..1}.community
+          database-strategy:
+            inline:
+              sharding-column: community_id
+              algorithm-expression: ds_master_$->{Long.parseLong(community_id) % 2}
+      default-database-strategy:
+        none:
+      default-table-strategy:
+        none:
+      default-datasource-name: ds_master_0
+#      master-slave-rules:
+#        ds_1:
+#          slave-data-source-names: ds_master_1_slave_0, ds_master_1_slave_1
+#          master-data-source-name: ds_master_1
+#        ds_0:
+#          slave-data-source-names: ds_master_0_slave_0, ds_master_0_slave_1
+#          master-data-source-name: ds_master_0

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

@@ -0,0 +1,96 @@
+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: 8011
+  tomcat:
+    uri-encoding: UTF-8
+
+spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
+  application:
+    name: hardwareAdapation-service
+  redis:
+    database: 0
+    host: test.redis.java110.com
+    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.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: hardwareAdapationBusinessStatus
+    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

+ 3 - 0
HardwareAdapationService/src/main/resources/application.yml

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

+ 15 - 0
HardwareAdapationService/src/main/resources/banner.txt

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

+ 75 - 0
HardwareAdapationService/src/main/resources/dataSource.yml

@@ -0,0 +1,75 @@
+dataSources:
+  ds0: !!com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.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.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

+ 3 - 0
HardwareAdapationService/src/main/resources/java110.properties

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

+ 1 - 0
pom.xml

@@ -37,6 +37,7 @@
         <module>CommonService</module>
         <module>ReportService</module>
         <module>ReportComponent</module>
+        <module>HardwareAdapationService</module>
     </modules>
 
     <parent>