Browse Source

first commit

15810770710@163.com 4 years ago
parent
commit
3442ad0ff6

+ 145 - 0
pom.xml

@@ -0,0 +1,145 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.2.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>info.aspirecn.cloud.yysj</groupId>
+    <artifactId>cloud-yysj-eid-info</artifactId>
+    <version>1.0.0</version>
+    <name>cloud-yysj-eid-info</name>
+    <description>cloud yysj platform driver product information</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+         <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+      <dependency>
+	    <groupId>org.projectlombok</groupId>
+	    <artifactId>lombok</artifactId>
+	    <optional>true</optional>
+	</dependency>
+	<!--swagger-->
+	<dependency>
+	    <groupId>io.springfox</groupId>
+	    <artifactId>springfox-swagger2</artifactId>
+	    <version>2.9.2</version>
+	</dependency>
+	<dependency>
+	    <groupId>io.springfox</groupId>
+	    <artifactId>springfox-swagger-ui</artifactId>
+	    <version>2.9.2</version>
+	</dependency>
+	<dependency>
+	    <groupId>com.github.xiaoymin</groupId>
+	    <artifactId>knife4j-spring-boot-starter</artifactId>
+	    <version>2.0.1</version>
+	</dependency>
+      <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+         <dependency>
+           <groupId>org.elasticsearch.client</groupId>
+           <artifactId>elasticsearch-rest-high-level-client</artifactId>
+           <version>6.5.4</version>
+       </dependency>
+       <dependency>
+           <groupId>org.elasticsearch</groupId>
+           <artifactId>elasticsearch</artifactId>
+           <version>6.5.4</version>
+       </dependency>
+       <!-- fastjson -->
+		<dependency>
+		    <groupId>com.alibaba</groupId>
+		    <artifactId>fastjson</artifactId>
+		    <version>1.2.66</version>
+		</dependency>
+		
+		<dependency>
+		  <groupId>org.springframework.cloud</groupId>
+		  <artifactId>spring-cloud-starter-kubernetes-config</artifactId>
+		</dependency>
+		<!--actuator-->
+		<dependency>
+		    <groupId>org.springframework.boot</groupId>
+		    <artifactId>spring-boot-starter-actuator</artifactId>
+		</dependency>
+		      
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring-cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+	 <build>
+	    <plugins>
+	        <!--设置应用 Main 参数启动依赖查找的地址指向外部 lib 文件夹-->
+	        <plugin>
+	            <groupId>org.apache.maven.plugins</groupId>
+	            <artifactId>maven-jar-plugin</artifactId>
+	            <configuration>
+	                <archive>
+	                    <manifest>
+	                        <addClasspath>true</addClasspath>
+	                        <classpathPrefix>lib/</classpathPrefix>
+	                    </manifest>
+	                </archive>
+	            </configuration>
+	        </plugin>
+	        <!--设置 SpringBoot 打包插件不包含任何 Jar 依赖包-->
+	        <plugin>
+	            <groupId>org.springframework.boot</groupId>
+	            <artifactId>spring-boot-maven-plugin</artifactId>
+	            <configuration>
+	                <includes>
+	                    <include>
+	                        <groupId>nothing</groupId>
+	                        <artifactId>nothing</artifactId>
+	                    </include>
+	                </includes>
+	            </configuration>
+	        </plugin>
+	        <!--设置将 lib 拷贝到应用 Jar 外面-->
+	        <plugin>
+	            <groupId>org.apache.maven.plugins</groupId>
+	            <artifactId>maven-dependency-plugin</artifactId>
+	            <executions>
+	                <execution>
+	                    <id>copy-dependencies</id>
+	                    <phase>prepare-package</phase>
+	                    <goals>
+	                        <goal>copy-dependencies</goal>
+	                    </goals>
+	                    <configuration>
+	                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
+	                    </configuration>
+	                </execution>
+	            </executions>
+	        </plugin>
+	    </plugins>
+	</build>
+</project>

+ 17 - 0
src/main/java/info/aspirecn/cloud/yysj/Application.java

@@ -0,0 +1,17 @@
+package info.aspirecn.cloud.yysj;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@EnableSwagger2
+@SpringBootApplication
+public class Application {
+
+    public static void main(String[] args) {
+    	
+        SpringApplication.run(Application.class, args);
+    }
+
+}

+ 72 - 0
src/main/java/info/aspirecn/cloud/yysj/config/ElasticSearchConfig.java

@@ -0,0 +1,72 @@
+package info.aspirecn.cloud.yysj.config;
+
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import java.util.ArrayList;
+import java.util.List;
+
+@Configuration
+public class ElasticSearchConfig {
+	  /** 协议 */
+    @Value("${elasticsearch.schema}")
+    private String schema;
+
+    /** 集群地址,如果有多个用“,”隔开 */
+    @Value("${elasticsearch.address}")
+    private String address;
+
+    /** 连接超时时间 */
+    @Value("${elasticsearch.connectTimeout:5000}")
+    private int connectTimeout;
+
+    /** Socket 连接超时时间 */
+    @Value("${elasticsearch.socketTimeout:10000}")
+    private int socketTimeout;
+
+    /** 获取连接的超时时间 */
+    @Value("${elasticsearch.connectionRequestTimeout:5000}")
+    private int connectionRequestTimeout;
+
+    /** 最大连接数 */
+    @Value("${elasticsearch.maxConnectNum:100}")
+    private int maxConnectNum;
+
+    /** 最大路由连接数 */
+    @Value("${elasticsearch.maxConnectPerRoute:100}")
+    private int maxConnectPerRoute;
+
+    @Bean
+    public RestHighLevelClient restHighLevelClient() {
+        // 拆分地址
+        List<HttpHost> hostLists = new ArrayList<>();
+        String[] hostList = address.split(",");
+        for (String addr : hostList) {
+            String host = addr.split(":")[0];
+            String port = addr.split(":")[1];
+            hostLists.add(new HttpHost(host, Integer.parseInt(port), schema));
+        }
+        // 转换成 HttpHost 数组
+        HttpHost[] httpHost = hostLists.toArray(new HttpHost[]{});
+        // 构建连接对象
+        RestClientBuilder builder = RestClient.builder(httpHost);
+        // 异步连接延时配置
+        builder.setRequestConfigCallback(requestConfigBuilder -> {
+            requestConfigBuilder.setConnectTimeout(connectTimeout);
+            requestConfigBuilder.setSocketTimeout(socketTimeout);
+            requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeout);
+            return requestConfigBuilder;
+        });
+        // 异步连接数配置
+        builder.setHttpClientConfigCallback(httpClientBuilder -> {
+            httpClientBuilder.setMaxConnTotal(maxConnectNum);
+            httpClientBuilder.setMaxConnPerRoute(maxConnectPerRoute);
+            return httpClientBuilder;
+        });
+        return new RestHighLevelClient(builder);
+    }
+}

+ 19 - 0
src/main/java/info/aspirecn/cloud/yysj/config/JsonConfig.java

@@ -0,0 +1,19 @@
+package info.aspirecn.cloud.yysj.config;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+@Configuration
+public class JsonConfig {
+	
+	@Bean
+    public ObjectMapper objectMapper() {
+        ObjectMapper objectMapper = new ObjectMapper();
+        // 不转换值null的字段
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+        return objectMapper;
+    }
+
+}

+ 48 - 0
src/main/java/info/aspirecn/cloud/yysj/config/SwaggerConfig.java

@@ -0,0 +1,48 @@
+package info.aspirecn.cloud.yysj.config;
+
+import com.google.common.base.Predicates;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+/**
+ * Swagger 配置
+ *
+ * @author dingliqiang
+ */
+@Configuration
+public class SwaggerConfig {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                // 项目组名
+                .apiInfo(apiInfo())
+                // 选择那些路径和api会生成document
+                .select()
+                // 对所有api进行监控
+                .apis(RequestHandlerSelectors.any())
+                // 对所有路径进行监控
+                .paths(PathSelectors.any())
+                //错误路径不监控
+                .paths(Predicates.not(PathSelectors.regex("/error.*")))
+                //actuator路径跳过
+                .paths(Predicates.not(PathSelectors.regex("/actuator.*")))
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                // 文档标题
+                .title("swagger-example-service")
+                // 文档描述
+                .description("This is a swagger project.")
+                // 文档版本
+                .version("1.0.0")
+                .build();
+    }
+}

+ 84 - 0
src/main/java/info/aspirecn/cloud/yysj/controller/EidController.java

@@ -0,0 +1,84 @@
+package info.aspirecn.cloud.yysj.controller;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RestController;
+
+import info.aspirecn.cloud.yysj.entity.ResponseInfo;
+import info.aspirecn.cloud.yysj.entity.request.IdentityInfoRequest;
+import info.aspirecn.cloud.yysj.entity.request.LivingInfoRequest;
+import info.aspirecn.cloud.yysj.service.EidService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 身份查询列表、活体查询列表
+ *
+ * @author baizehui
+ */
+@Api(tags = "身份查询列表、活体查询列表接口")
+@ApiResponses({
+        @ApiResponse(code = 200, message = "成功处理请求"),
+        @ApiResponse(code = 400, message = "参数错误"),
+        @ApiResponse(code = 401, message = "没有权限访问该服务"),
+        @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
+        @ApiResponse(code = 404, message = "未发现该微服务"),
+        @ApiResponse(code = 500, message = "服务器内部错误")
+})
+@RestController
+@Slf4j
+public class EidController {
+	
+	@Autowired
+    private EidService eidService;
+
+    @ApiOperation(value = "身份查询校验信息列表接口", notes = "身份查询校验信息列表接口。")
+    @PostMapping("/getIdentityList")
+    private ResponseInfo getIdentityList(@RequestHeader(required = false) String userId,@RequestBody IdentityInfoRequest  identityInfoRequest, HttpServletResponse response){
+        try {
+        	if (userId== null&&"".equals(userId)) {
+        		return new ResponseInfo().setMessage("userId不能为空");
+        	}
+        	Map<String, Object> map =eidService.getIdentityList(userId,identityInfoRequest);
+        	 Integer total = (Integer)map.get("total");
+            response.addHeader("pageNum", Integer.toString(identityInfoRequest.getPageNum()));
+            response.addHeader("pageSize", Integer.toString(identityInfoRequest.getPageSize()));
+            response.addHeader("pageTotal",   Integer.toString(total%identityInfoRequest.getPageSize() > 0 ? total/identityInfoRequest.getPageSize()+1 : total/identityInfoRequest.getPageSize()));
+            response.addHeader("total",Integer.toString(total));
+            return new ResponseInfo().setData(map.get("dataList"));
+        } catch (Exception e) {
+            log.error("身份查询校验信息列表接口,e:{}", e);
+        }
+		return null;
+    }
+    
+    @ApiOperation(value = "活体查询校验信息列表接口", notes = "活体查询校验信息列表接口。")
+    @PostMapping("/getLivingList")
+    private ResponseInfo getLivingList(@RequestHeader(required = false) String userId,@RequestBody LivingInfoRequest  livingInfoRequest, HttpServletResponse response){
+        try {
+        	if (userId== null&&"".equals(userId)) {
+        		return new ResponseInfo().setMessage("userId不能为空");
+        	}
+        	Map<String, Object> map =eidService.getLivingList(userId,livingInfoRequest);
+        	 Integer total = (Integer)map.get("total");
+            response.addHeader("pageNum", Integer.toString(livingInfoRequest.getPageNum()));
+            response.addHeader("pageSize", Integer.toString(livingInfoRequest.getPageSize()));
+            response.addHeader("pageTotal",   Integer.toString(total%livingInfoRequest.getPageSize() > 0 ? total/livingInfoRequest.getPageSize()+1 : total/livingInfoRequest.getPageSize()));
+            response.addHeader("total",Integer.toString(total));
+            return new ResponseInfo().setData(map.get("dataList"));
+        } catch (Exception e) {
+            log.error("活体查询校验信息列表接口,e:{}", e);
+        }
+		return null;
+    }
+   
+}

+ 18 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ResponseInfo.java

@@ -0,0 +1,18 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author dingliqiang
+ */
+@Data
+@Accessors(chain = true)
+public class ResponseInfo {
+
+    /** 错误信息*/
+    private String message = "";
+    /** 返回结果*/
+    private Object data = "";
+
+}

+ 33 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/request/IdentityInfoRequest.java

@@ -0,0 +1,33 @@
+package info.aspirecn.cloud.yysj.entity.request;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * 身份请求信息
+ *
+ * @author baizehui
+ */
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@AllArgsConstructor
+public class IdentityInfoRequest {
+
+	@ApiModelProperty(value = "请求id")
+	private String reqID;
+	@ApiModelProperty(value = "核验结果")
+	private String verificationResult;
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+    @ApiModelProperty(value = "页数")
+    private int pageNum;
+    @ApiModelProperty(value = "页面显示数量")
+    private int pageSize;
+
+}

+ 33 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/request/LivingInfoRequest.java

@@ -0,0 +1,33 @@
+package info.aspirecn.cloud.yysj.entity.request;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * 身份请求信息
+ *
+ * @author baizehui
+ */
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@AllArgsConstructor
+public class LivingInfoRequest {
+
+	@ApiModelProperty(value = "请求id")
+	private String reqID;
+	@ApiModelProperty(value = "核验结果")
+	private String verificationResult;
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+    @ApiModelProperty(value = "页数")
+    private int pageNum;
+    @ApiModelProperty(value = "页面显示数量")
+    private int pageSize;
+
+}

+ 38 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/response/IdentityInfoResponse.java

@@ -0,0 +1,38 @@
+package info.aspirecn.cloud.yysj.entity.response;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * 身份响应信息
+ *
+ * @author baizehui
+ */
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@AllArgsConstructor
+public class IdentityInfoResponse {
+	@ApiModelProperty(value = "用户id")
+	private String userId;
+	@ApiModelProperty(value = "请求id")
+	private String reqId;
+	@ApiModelProperty(value = "姓名")
+	private String name;
+	@ApiModelProperty(value = "身份证号")
+	private String idNumber;
+	@ApiModelProperty(value = "eid身份标识")
+	private String appeIdCode;
+	@ApiModelProperty(value = "eid验证凭证")
+	private String eidVoucher;
+	@ApiModelProperty(value = "相似度")
+	private String similarity;
+    @ApiModelProperty(value = "核验结果")
+    private String verificationResult;
+    @ApiModelProperty(value = "请求时间")
+    private String requestTime;
+
+}

+ 30 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/response/LivingInfoResponse.java

@@ -0,0 +1,30 @@
+package info.aspirecn.cloud.yysj.entity.response;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * 活体响应信息
+ *
+ * @author baizehui
+ */
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@AllArgsConstructor
+public class LivingInfoResponse {
+	@ApiModelProperty(value = "用户id")
+	private String userId;
+	@ApiModelProperty(value = "请求id")
+	private String reqId;
+	@ApiModelProperty(value = "相似度")
+	private String similarity;
+    @ApiModelProperty(value = "核验结果")
+    private String verificationResult;
+    @ApiModelProperty(value = "请求时间")
+    private String requestTime;
+
+}

+ 16 - 0
src/main/java/info/aspirecn/cloud/yysj/service/EidService.java

@@ -0,0 +1,16 @@
+package info.aspirecn.cloud.yysj.service;
+
+import java.util.Map;
+
+import info.aspirecn.cloud.yysj.entity.request.IdentityInfoRequest;
+import info.aspirecn.cloud.yysj.entity.request.LivingInfoRequest;
+
+public interface EidService {
+
+	Map<String, Object> getIdentityList(String userId, IdentityInfoRequest identityInfoRequest);
+
+	Map<String, Object> getLivingList(String userId, LivingInfoRequest livingInfoRequest);
+
+
+	
+}

+ 220 - 0
src/main/java/info/aspirecn/cloud/yysj/service/impl/EidServiceImpl.java

@@ -0,0 +1,220 @@
+package info.aspirecn.cloud.yysj.service.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHits;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.elasticsearch.search.sort.SortOrder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import info.aspirecn.cloud.yysj.entity.request.IdentityInfoRequest;
+import info.aspirecn.cloud.yysj.entity.request.LivingInfoRequest;
+import info.aspirecn.cloud.yysj.entity.response.IdentityInfoResponse;
+import info.aspirecn.cloud.yysj.entity.response.LivingInfoResponse;
+import info.aspirecn.cloud.yysj.service.EidService;
+import info.aspirecn.cloud.yysj.utils.DateUtil;
+import info.aspirecn.cloud.yysj.utils.ElasticSearchUitls;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
+@Service
+public class  EidServiceImpl implements EidService {
+	
+	 /** 主订单索引 */
+    @Value("${elasticsearch.firstIndex}")
+    private String firstIndex;
+
+    /** 身份产品编号 */
+    @Value("${product.IdentityProductId}")
+    private String identityProductId;
+
+    /** 活体产品编号 */
+    @Value("${product.LivingProductId}")
+    private String livingProductId;
+	
+	@Autowired
+	private ElasticSearchUitls elasticSearchUitls;
+ 
+	@Override
+	public Map<String, Object> getIdentityList(String userId,IdentityInfoRequest identityInfoRequest) {
+		
+		 //数据不能大于1000
+        if((identityInfoRequest.getPageNum() * identityInfoRequest.getPageSize()) > 1000){
+            return null;
+        }
+        // 创建 Bool 查询构建器
+        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+        // 构建查询条件
+        boolQueryBuilder.must(QueryBuilders.termsQuery("URI.keyword","/info_check/identity.do"));
+        boolQueryBuilder.must(QueryBuilders.termsQuery("MG-UserId.keyword", userId));
+        if (identityInfoRequest.getReqID()!=null&&!"".equals(identityInfoRequest.getReqID())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.ReqID.keyword", "*"+identityInfoRequest.getReqID()+"*"));
+		}
+        if (identityInfoRequest.getVerificationResult()!=null&&!"".equals(identityInfoRequest.getVerificationResult())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("MG-Consistent.keyword","*"+ identityInfoRequest.getVerificationResult()+"*"));
+		}
+       
+        if (identityInfoRequest.getStartTime()!=null&&!"".equals(identityInfoRequest.getStartTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").gte(DateUtil.mysqlTime2ESTime(identityInfoRequest.getStartTime())));
+		}
+        if (identityInfoRequest.getEndTime()!=null&&!"".equals(identityInfoRequest.getEndTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").lte(DateUtil.mysqlTime2ESTime(identityInfoRequest.getEndTime())));
+		}
+        // 构建查询源构建器
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+        searchSourceBuilder.query(boolQueryBuilder);
+        searchSourceBuilder.sort("DateTime", SortOrder.DESC);
+        searchSourceBuilder.size(1000);
+        //设置源字段过虑,第一个参数结果集包括哪些字段,第二个参数表示结果集不包括哪些字段
+        searchSourceBuilder.fetchSource(new String[]{"RequestInfo.ReqID","Check-Reuslt", "DateTime","MG-Consistent"}, null);
+		
+        // 创建查询请求对象,将查询对象配置到其中
+        SearchRequest searchRequest = new SearchRequest(firstIndex);
+        searchRequest.source(searchSourceBuilder);
+
+        // 返回集合
+        List<IdentityInfoResponse> identityInfoResponseList = new ArrayList<IdentityInfoResponse>();
+        //获取数据
+        SearchHits hits = elasticSearchUitls.getResultHits(searchRequest);
+        Map<String, Object> map=new HashMap<String, Object>();
+        if (hits == null) {
+        	map.put("dataList", identityInfoResponseList);
+        	map.put("total", 0);
+            return map;
+        }
+        //遍历数据, 加上核验结果条件, 计算总数, 分页
+        int total = 0;
+        for (SearchHit hit : hits) {
+              JSONObject jsonObject = JSONObject.parseObject(hit.getSourceAsString());
+              String verificationResult ="";
+              JSONArray reusltJson = jsonObject.getJSONArray("Check-Reuslt");
+              if (reusltJson.size()>0) {
+            	  for (int i = 0; i < reusltJson.size(); i++) {
+                	  JSONObject checkResObj = reusltJson.getJSONObject(i);
+                	  if (identityProductId.equals(checkResObj.getString("productId"))) {
+                		  verificationResult=checkResObj.getString("result");
+                	  }
+                  }
+              }
+    
+              total++;
+              if(total > ((identityInfoRequest.getPageNum()-1) * identityInfoRequest.getPageSize()) && identityInfoResponseList.size() < identityInfoRequest.getPageSize()){
+	              JSONObject riJsonObject = jsonObject.getJSONObject("RequestInfo");
+	              JSONObject jsonObjectResult =JSONObject.parseObject(verificationResult);
+	              String result = jsonObject.getString("MG-Consistent");
+	              if (riJsonObject!=null&& !reusltJson.isEmpty()) {
+	            	  IdentityInfoResponse identityInfoResponse=new IdentityInfoResponse();
+	            	  identityInfoResponse.setUserId(userId);
+	            	  identityInfoResponse.setReqId(riJsonObject.getString("ReqID"));
+	            	  identityInfoResponse.setName(jsonObjectResult.getString("Name"));
+		              identityInfoResponse.setIdNumber(jsonObjectResult.getString("IdNumber"));
+		              identityInfoResponse.setAppeIdCode(jsonObjectResult.getString("AppeIdCode"));
+		              identityInfoResponse.setEidVoucher(jsonObjectResult.getString("EidVoucher"));
+		              identityInfoResponse.setVerificationResult(result);
+		              identityInfoResponse.setSimilarity(jsonObjectResult.getString("Similarity"));
+		              identityInfoResponse.setRequestTime(DateUtil.esTime2MySQLTime(jsonObject.getString("DateTime")));
+		              identityInfoResponseList.add(identityInfoResponse);
+	              }
+              }
+         }
+        map.put("dataList", identityInfoResponseList);
+    	map.put("total", total);
+        return map;
+	}
+	
+	@Override
+	public Map<String, Object> getLivingList(String userId, LivingInfoRequest livingInfoRequest) {
+		
+		 //数据不能大于1000
+        if((livingInfoRequest.getPageNum() * livingInfoRequest.getPageSize()) > 1000){
+            return null;
+        }
+        // 创建 Bool 查询构建器
+        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+        // 构建查询条件
+        boolQueryBuilder.must(QueryBuilders.termsQuery("URI.keyword","/info_check/living.do"));
+        boolQueryBuilder.must(QueryBuilders.termsQuery("MG-UserId.keyword", userId));
+        if (livingInfoRequest.getReqID()!=null&&!"".equals(livingInfoRequest.getReqID())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.ReqID.keyword", "*"+livingInfoRequest.getReqID()+"*"));
+		}
+        if (livingInfoRequest.getVerificationResult()!=null&&!"".equals(livingInfoRequest.getVerificationResult())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("MG-Consistent.keyword","*"+ livingInfoRequest.getVerificationResult()+"*"));
+		}
+       
+        if (livingInfoRequest.getStartTime()!=null&&!"".equals(livingInfoRequest.getStartTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").gte(DateUtil.mysqlTime2ESTime(livingInfoRequest.getStartTime())));
+		}
+        if (livingInfoRequest.getEndTime()!=null&&!"".equals(livingInfoRequest.getEndTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").lte(DateUtil.mysqlTime2ESTime(livingInfoRequest.getEndTime())));
+		}
+        // 构建查询源构建器
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+        searchSourceBuilder.query(boolQueryBuilder);
+        searchSourceBuilder.sort("DateTime", SortOrder.DESC);
+        searchSourceBuilder.size(1000);
+        //设置源字段过虑,第一个参数结果集包括哪些字段,第二个参数表示结果集不包括哪些字段
+        searchSourceBuilder.fetchSource(new String[]{"RequestInfo.AppeIdCode", "RequestInfo.ReqID", "RequestInfo.EidVoucher",
+        		"Check-Reuslt", "DateTime","MG-Consistent"}, null);
+		
+        // 创建查询请求对象,将查询对象配置到其中
+        SearchRequest searchRequest = new SearchRequest(firstIndex);
+        searchRequest.source(searchSourceBuilder);
+
+        // 返回集合
+        List<LivingInfoResponse> livingInfoResponseList = new ArrayList<LivingInfoResponse>();
+        //获取数据
+        SearchHits hits = elasticSearchUitls.getResultHits(searchRequest);
+        Map<String, Object> map=new HashMap<String, Object>();
+        if (hits == null) {
+        	map.put("dataList", livingInfoResponseList);
+        	map.put("total", 0);
+            return map;
+        }
+        //遍历数据, 加上核验结果条件, 计算总数, 分页
+        int total = 0;
+        for (SearchHit hit : hits) {
+              JSONObject jsonObject = JSONObject.parseObject(hit.getSourceAsString());
+              String verificationResult ="";
+              JSONArray reusltJson = jsonObject.getJSONArray("Check-Reuslt");
+              if (reusltJson.size()>0) {
+            	  for (int i = 0; i < reusltJson.size(); i++) {
+                	  JSONObject checkResObj = reusltJson.getJSONObject(i);
+                	  if (livingProductId.equals(checkResObj.getString("productId"))) {
+                		  verificationResult=checkResObj.getString("result");
+                	  }
+                  }
+              }
+          
+              total++;
+              if(total > ((livingInfoRequest.getPageNum()-1) * livingInfoRequest.getPageSize()) && livingInfoResponseList.size() < livingInfoRequest.getPageSize()){
+	              JSONObject riJsonObject = jsonObject.getJSONObject("RequestInfo");
+	              JSONObject jsonObjectResult =JSONObject.parseObject(verificationResult);
+	              String result = jsonObject.getString("MG-Consistent");
+	              if (riJsonObject!=null && !reusltJson.isEmpty()) {
+	            	  LivingInfoResponse livingInfoResponse=new LivingInfoResponse();
+	            	  livingInfoResponse.setUserId(userId);
+	            	  livingInfoResponse.setReqId(riJsonObject.getString("ReqID"));
+	            	  livingInfoResponse.setVerificationResult(result);
+	            	  livingInfoResponse.setSimilarity(jsonObjectResult.getString("Similarity"));
+	            	  livingInfoResponse.setRequestTime(DateUtil.esTime2MySQLTime(jsonObject.getString("DateTime")));
+		              livingInfoResponseList.add(livingInfoResponse);
+	              }
+              }
+         }
+        map.put("dataList", livingInfoResponseList);
+    	map.put("total", total);
+        return map;
+	}
+
+}

+ 77 - 0
src/main/java/info/aspirecn/cloud/yysj/utils/DateUtil.java

@@ -0,0 +1,77 @@
+package info.aspirecn.cloud.yysj.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+//日期工具类
+public class DateUtil {
+
+	/**ES时间格式化对象*/
+	public static SimpleDateFormat sdfES = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXX");
+
+	/**MySQL时间格式化对象*/
+	public static SimpleDateFormat sdfMySQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+	private DateUtil(){}
+
+	/**获取当前时间,格式化为MySQL时间*/
+	public static String getStrTimeMySQL() {
+		return sdfMySQL.format(new Date());
+	}
+
+	/**指定天数前时间,格式化为MySQL时间*/
+	public static String getBeforTimeMySQL(int d){
+		Date date = new Date();
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(date);
+		calendar.add(calendar.DATE, -d);
+		date = calendar.getTime();
+		return sdfMySQL.format(date);
+	}
+
+	/**获取当前时间,格式化为ES时间*/
+	public static String getStrTimeES() {
+		return sdfES.format(new Date());
+	}
+
+	/**指定天数前时间,格式化为ES时间*/
+	public static String getBeforTimeES(int d){
+		Date date = new Date();
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(date);
+		calendar.add(calendar.DATE, -d);
+		date = calendar.getTime();
+		return sdfES.format(date);
+	}
+
+	/**将ES时间格式化为MySQL时间*/
+	public static String esTime2MySQLTime(String esTime){
+		String reTime = "2000-01-01 00:00:00";
+		try {
+			Date time = sdfES.parse(esTime);
+			reTime = sdfMySQL.format(time);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		return reTime;
+	}
+
+	/**将MySQL时间格式化为ES时间*/
+	public static String mysqlTime2ESTime(String mysqlTime){
+		String reTime = "2000-01-01T00:00:00.000+0800";
+		try {
+			Date time = sdfMySQL.parse(mysqlTime);
+			reTime = sdfES.format(time);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		return reTime;
+	}
+	
+	public static void main(String[] args) {
+		System.out.println(mysqlTime2ESTime("2000-01-01 00:00:00"));
+	}
+}

+ 59 - 0
src/main/java/info/aspirecn/cloud/yysj/utils/ElasticSearchAddParamUtil.java

@@ -0,0 +1,59 @@
+package info.aspirecn.cloud.yysj.utils;
+
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+/**
+ * Email:lixinxu@aspirecn.com
+ * Descrption:
+ */
+public class ElasticSearchAddParamUtil {
+
+
+    public static void addParam(BoolQueryBuilder boolQueryBuilder, Object obj, Map<String, Integer> outFields){
+        Field[] fields = obj.getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++){
+            Field field = fields[i];
+            field.setAccessible(true);
+
+            if(outFields.get(field.getName()) != null){
+                continue;
+            }
+
+            try {
+                Object value = field.get(obj);
+                if(value != null && value != ""){
+                    boolQueryBuilder.must(QueryBuilders.termsQuery(field.getName(),value));
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static void addParamKeyword(SearchSourceBuilder searchSourceBuilder, Object obj, Map<String, Integer> outFields){
+        Field[] fields = obj.getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++){
+            Field field = fields[i];
+            field.setAccessible(true);
+
+            if(outFields.get(field.getName()) != null){
+                continue;
+            }
+
+            try {
+                Object value = field.get(obj);
+                if(value != null && value != ""){
+                    searchSourceBuilder.query(QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(field.getName()+".keyword",value)));
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+}

+ 79 - 0
src/main/java/info/aspirecn/cloud/yysj/utils/ElasticSearchUitls.java

@@ -0,0 +1,79 @@
+package info.aspirecn.cloud.yysj.utils;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.rest.RestStatus;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHits;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Slf4j
+@Component
+public class ElasticSearchUitls {
+
+    @Autowired
+    private RestHighLevelClient restHighLevelClient;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    /**
+             * 获取查询结果
+     *
+     * @param searchRequest 查询请求对象
+     * @return 结果数据集合
+     */
+    public <T> List<T> getResult(SearchRequest searchRequest, Class<T> type) {
+        // 设置返回集合
+        List<T> list = new ArrayList<>();
+        // 使用 RestHighLevelClient 客户端进行请求
+        try {
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            // 根据状态和数据条数验证是否返回了数据
+            if (RestStatus.OK.equals(searchResponse.status()) && searchResponse.getHits().totalHits > 0) {
+                SearchHits hits = searchResponse.getHits();
+                for (SearchHit hit : hits) {
+                    // 将 JSON 转换成对象
+                    T t = objectMapper.readValue(hit.getSourceAsString(), type);
+                    // 加入到对象集合
+                    list.add(t);
+                }
+            }
+        } catch (IOException e) {
+            log.error("", e);
+        }
+        return list;
+    }
+    
+    
+	/**
+	 * 获取查询结果
+	 *
+	 * @param searchRequest 查询请求对象
+	 * @return 
+	 * @return 结果数据集合
+	 */
+	public  SearchHits getResultHits(SearchRequest searchRequest) {
+		// 使用 RestHighLevelClient 客户端进行请求
+		try {
+			SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+			// 根据状态和数据条数验证是否返回了数据
+			if (RestStatus.OK.equals(searchResponse.status()) && searchResponse.getHits().totalHits > 0) {
+				SearchHits hits = searchResponse.getHits();
+				return hits;
+			}
+		} catch (IOException e) {
+			log.error("", e);
+		}
+		return null;
+	}
+
+}

+ 41 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,41 @@
+#ConfigMap 配置参数
+server:
+  port: 8080
+spring:
+  application:
+    name: cloud-yysj-eid-info
+  cloud:
+    kubernetes:
+      reload:
+        enabled: true
+        mode: polling
+        period: 10000
+        strategy: refresh
+        monitoring-secrets: true
+      config:
+        enabled: true
+        enableApi: true
+        sources:
+          - namespace: cloud-yysj
+            name: ${spring.application.name}
+product:
+  IdentityProductId: 12
+  LivingProductId: 13
+#监控配置参数
+management:
+  server:
+    port: 8081
+  endpoint:
+    restart:
+      enabled: true
+    health:
+      show-details: always
+  endpoints:
+    enabled-by-default: true
+    web:
+      exposure:
+        include: "*"
+info:
+  name: eid
+  version: '1.0.0'
+