15810770710@163.com il y a 4 ans
Parent
commit
002f6c83b1
21 fichiers modifiés avec 1214 ajouts et 0 suppressions
  1. 82 0
      deploy/cloud-yysj-driver-info.yaml
  2. 20 0
      deploy/config-map.yaml
  3. 145 0
      pom.xml
  4. 17 0
      src/main/java/info/aspirecn/cloud/yysj/Application.java
  5. 72 0
      src/main/java/info/aspirecn/cloud/yysj/config/ElasticSearchConfig.java
  6. 19 0
      src/main/java/info/aspirecn/cloud/yysj/config/JsonConfig.java
  7. 48 0
      src/main/java/info/aspirecn/cloud/yysj/config/SwaggerConfig.java
  8. 88 0
      src/main/java/info/aspirecn/cloud/yysj/controller/DriverController.java
  9. 72 0
      src/main/java/info/aspirecn/cloud/yysj/entity/Driver.java
  10. 22 0
      src/main/java/info/aspirecn/cloud/yysj/entity/DriverCheck.java
  11. 18 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ResponseInfo.java
  12. 19 0
      src/main/java/info/aspirecn/cloud/yysj/entity/request/DriverDetailsRequest.java
  13. 41 0
      src/main/java/info/aspirecn/cloud/yysj/entity/request/DriverInfoRequest.java
  14. 44 0
      src/main/java/info/aspirecn/cloud/yysj/entity/response/DriverInfoDetailsResponse.java
  15. 38 0
      src/main/java/info/aspirecn/cloud/yysj/entity/response/DriverInfoResponse.java
  16. 15 0
      src/main/java/info/aspirecn/cloud/yysj/service/DriverService.java
  17. 200 0
      src/main/java/info/aspirecn/cloud/yysj/service/impl/DriverServiceImpl.java
  18. 77 0
      src/main/java/info/aspirecn/cloud/yysj/utils/DateUtil.java
  19. 59 0
      src/main/java/info/aspirecn/cloud/yysj/utils/ElasticSearchAddParamUtil.java
  20. 79 0
      src/main/java/info/aspirecn/cloud/yysj/utils/ElasticSearchUitls.java
  21. 39 0
      src/main/resources/bootstrap.yml

+ 82 - 0
deploy/cloud-yysj-driver-info.yaml

@@ -0,0 +1,82 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: cloud-yysj-driver-info
+  labels:
+    app: cloud-yysj-driver-info
+    svcEndpoints: actuator
+spec:
+  type: NodePort
+  ports:
+    - name: server
+      port: 8080
+      targetPort: 8080
+    - name: management
+      port: 8081
+      targetPort: 8081
+  selector:
+    app: cloud-yysj-driver-info
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: cloud-yysj-driver-info
+  labels:
+    app: cloud-yysj-driver-info
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: cloud-yysj-driver-info
+  template:
+    metadata:
+      name: cloud-yysj-driver-info
+      labels:
+        app: cloud-yysj-driver-info
+    spec:
+      restartPolicy: Always
+      containers:
+      - name: service-provider
+        image: hub.i139.cn/cloud-yysj/cloud-yysj-driver-info:1.0.0
+        imagePullPolicy: IfNotPresent
+        ports:
+        - name: server
+          containerPort: 8080
+        - name: management
+          containerPort: 8081
+        env:
+        - name: KUBERNETES_NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        - name: POD_NAME
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        - name: JAVA_OPTS
+          value: ""
+        - name: APP_OPTS
+          value: ""
+        resources:
+          limits:
+            memory: 1000Mi
+            cpu: 2000m
+          requests:
+            memory: 256Mi
+            cpu: 1000m
+        readinessProbe:
+          initialDelaySeconds: 20
+          periodSeconds: 5
+          timeoutSeconds: 10
+          failureThreshold: 5
+          httpGet:
+            path: /actuator/health
+            port: 8081
+        livenessProbe:
+          initialDelaySeconds: 60
+          periodSeconds: 5
+          timeoutSeconds: 5
+          failureThreshold: 3
+          httpGet:
+            path: /actuator/health
+            port: 8081

+ 20 - 0
deploy/config-map.yaml

@@ -0,0 +1,20 @@
+kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: cloud-yysj-driver-info
+data:
+  application.yaml: |-
+    elasticsearch:
+      schema: http
+      address: 10.8.17.119:32482
+      connectTimeout: 10000
+      socketTimeout: 10000
+      connectionRequestTimeout: 10000
+      maxConnectNum: 100
+      maxConnectPerRoute: 100
+      firstIndex: "access-yysj-gateway-first-log-cloud-yysj*"
+    product:
+      driverLicenseNumberProductId: 2
+      qualificationCertificateProductId: 3
+
+   

+ 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-driver-info</artifactId>
+    <version>1.0.1</version>
+    <name>cloud-yysj-driver-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.62</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();
+    }
+}

+ 88 - 0
src/main/java/info/aspirecn/cloud/yysj/controller/DriverController.java

@@ -0,0 +1,88 @@
+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.DriverDetailsRequest;
+import info.aspirecn.cloud.yysj.entity.request.DriverInfoRequest;
+import info.aspirecn.cloud.yysj.entity.response.DriverInfoDetailsResponse;
+import info.aspirecn.cloud.yysj.service.DriverService;
+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 DriverController {
+	
+	@Autowired
+    private DriverService driverService;
+
+    @ApiOperation(value = "查询司机校验信息列表接口", notes = "获取司机校验信息列表接口。")
+    @PostMapping("/getDriverList")
+    private ResponseInfo getDriverList(@RequestHeader(required = false) String userId,@RequestBody DriverInfoRequest  driverInfoRequest, HttpServletResponse response){
+        try {
+        	if (userId== null&&"".equals(userId)) {
+        		return new ResponseInfo().setMessage("userId不能为空");
+        	}
+        	Map<String, Object> map =driverService.getDriverList(userId,driverInfoRequest);
+        	 Integer total = (Integer)map.get("total");
+            response.addHeader("pageNum", Integer.toString(driverInfoRequest.getPageNum()));
+            response.addHeader("pageSize", Integer.toString(driverInfoRequest.getPageSize()));
+            response.addHeader("pageTotal",   Integer.toString(total%driverInfoRequest.getPageSize() > 0 ? total/driverInfoRequest.getPageSize()+1 : total/driverInfoRequest.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("/getDriverDetails")
+    private ResponseInfo getDriverDetails(@RequestHeader(required = false) String userId,
+    		@RequestBody DriverDetailsRequest driverDetailsRequest){
+        
+        try {
+        	if (userId== null&&"".equals(userId)) {
+        		return new ResponseInfo().setMessage("userId不能为空");
+        	}
+        	if (driverDetailsRequest.getDriverName()== null&&"".equals(driverDetailsRequest.getDriverName())) {
+        		return new ResponseInfo().setMessage("driverName不能为空");
+        	}
+        	if (driverDetailsRequest.getDrivingLicense()== null&&"".equals(driverDetailsRequest.getDrivingLicense())) {
+        		return new ResponseInfo().setMessage("drivingLicense不能为空");
+        	}
+         	DriverInfoDetailsResponse driverInfoDetails=driverService.getDriverDetails(userId,driverDetailsRequest.getDriverName(),driverDetailsRequest.getDrivingLicense());
+            return new ResponseInfo().setData(driverInfoDetails);
+        } catch (Exception e) {
+            log.error("查询司机详情信息列表接口,e:{}", e);
+        }
+		return null;
+    }
+}

+ 72 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/Driver.java

@@ -0,0 +1,72 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class Driver {
+	
+	@JsonProperty("traceId")
+	private String traceId;
+	@JsonProperty("DateTime")
+	private String dateTime;
+	@JsonProperty("RequestInfo")
+	private RequestInfo requestInfo;
+	
+	@Data
+	public static class RequestInfo {
+			@ApiModelProperty(value = "用户id")
+			@JsonProperty("MG_UserId")
+			private String userId;
+			@ApiModelProperty(value = "司机姓名")
+			@JsonProperty("DriverName")
+			private String driverName;
+			@ApiModelProperty(value = "身份证号")
+			@JsonProperty("DrivingLicense")
+			private String drivingLicense;
+			@ApiModelProperty(value = "驾驶证号")
+			@JsonProperty("DriverLicenseNumber")
+			private String driverLicenseNumber;
+			@ApiModelProperty(value = "从业资格证号")
+			@JsonProperty("QualificationCertificate")
+			private String qualificationCertificate;
+			@ApiModelProperty(value = "准驾车型")
+			@JsonProperty("VehicleClass")
+			private String vehicleClass;
+			@ApiModelProperty(value = "驾驶证发证机关")
+			@JsonProperty("IssuingOrganizations")
+			private String issuingOrganizations;
+			@ApiModelProperty(value = "驾驶证有效期自")
+			@JsonProperty("ValidPeriodFrom")
+			private String validPeriodFrom;
+			@ApiModelProperty(value = "驾驶证有效期至")
+			@JsonProperty("ValidPeriodTo")
+			private String validPeriodTo;
+			@ApiModelProperty(value = "手机号")
+			@JsonProperty("Telephone")
+			private String telephone;
+			@ApiModelProperty(value = "备注")
+			@JsonProperty("Remark")
+			private String remark;
+		//    @ApiModelProperty(value = "身份证核验结果")
+		//	@JsonProperty("idCardResult")
+		//    private String idCardResult;
+		//    @ApiModelProperty(value = "从业资格证核验结果")
+		//	@JsonProperty("qualificationCardResult")
+		//    private String qualificationCardResult;
+		//    @ApiModelProperty(value = "驾驶证核验结果")
+		//    @JsonProperty("driveCardResult")
+		//    private String driveCardResult;
+		//    @ApiModelProperty(value = "请求时间")
+		//    @JsonProperty("requestTime")
+		//    private String requestTime;
+	}
+
+}

+ 22 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/DriverCheck.java

@@ -0,0 +1,22 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class DriverCheck {
+	
+	    @ApiModelProperty(value = "产品id")
+		@JsonProperty("MG-ProductId")
+	    private int productId;
+	    @ApiModelProperty(value = "核验结果")
+		@JsonProperty("MG-Result")
+	    private int result;
+}

+ 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 = "";
+
+}

+ 19 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/request/DriverDetailsRequest.java

@@ -0,0 +1,19 @@
+package info.aspirecn.cloud.yysj.entity.request;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class DriverDetailsRequest {
+	
+	@ApiModelProperty(value = "司机姓名")
+	private String driverName;
+	@ApiModelProperty(value = "身份证号")
+	private String drivingLicense;
+
+}

+ 41 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/request/DriverInfoRequest.java

@@ -0,0 +1,41 @@
+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 DriverInfoRequest {
+
+	@ApiModelProperty(value = "司机姓名")
+	private String driverName;
+	@ApiModelProperty(value = "身份证号")
+	private String drivingLicense;
+	@ApiModelProperty(value = "驾驶证号")
+	private String driverLicenseNumber;
+	@ApiModelProperty(value = "从业资格证号")
+	private String qualificationCertificate;
+    @ApiModelProperty(value = "从业资格证核验结果")
+    private String qualificationCardResult;
+    @ApiModelProperty(value = "驾驶证核验结果")
+    private String driveCardResult;
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+    @ApiModelProperty(value = "页数")
+    private int pageNum;
+    @ApiModelProperty(value = "页面显示数量")
+    private int pageSize;
+    
+}

+ 44 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/response/DriverInfoDetailsResponse.java

@@ -0,0 +1,44 @@
+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 DriverInfoDetailsResponse {
+
+   
+	@ApiModelProperty(value = "用户id")
+	private String userId;
+	@ApiModelProperty(value = "司机姓名")
+	private String driverName;
+	@ApiModelProperty(value = "身份证号")
+	private String drivingLicense;
+	@ApiModelProperty(value = "驾驶证号")
+	private String driverLicenseNumber;
+	@ApiModelProperty(value = "准驾车型")
+	private String vehicleClass;
+	@ApiModelProperty(value = "驾驶证发证机关")
+	private String issuingOrganizations;
+	@ApiModelProperty(value = "从业资格证号")
+	private String qualificationCertificate;
+	@ApiModelProperty(value = "驾驶证有效期自")
+	private String validPeriodFrom;
+	@ApiModelProperty(value = "驾驶证有效期至")
+	private String validPeriodTo;
+	@ApiModelProperty(value = "手机号")
+	private String telephone;
+	@ApiModelProperty(value = "备注")
+	private String remark;
+ 
+}

+ 38 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/response/DriverInfoResponse.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 DriverInfoResponse {
+	@ApiModelProperty(value = "用户id")
+	private String userId;
+	@ApiModelProperty(value = "司机姓名")
+	private String driverName;
+	@ApiModelProperty(value = "身份证号")
+	private String drivingLicense;
+	@ApiModelProperty(value = "驾驶证号")
+	private String driverLicenseNumber;
+	@ApiModelProperty(value = "从业资格证号")
+	private String qualificationCertificate;
+    @ApiModelProperty(value = "身份证核验结果")
+    private String idCardResult;
+    @ApiModelProperty(value = "从业资格证核验结果")
+    private String qualificationCardResult;
+    @ApiModelProperty(value = "驾驶证核验结果")
+    private String driveCardResult;
+    @ApiModelProperty(value = "请求时间")
+    private String requestTime;
+
+}

+ 15 - 0
src/main/java/info/aspirecn/cloud/yysj/service/DriverService.java

@@ -0,0 +1,15 @@
+package info.aspirecn.cloud.yysj.service;
+
+import java.util.Map;
+
+import info.aspirecn.cloud.yysj.entity.request.DriverInfoRequest;
+import info.aspirecn.cloud.yysj.entity.response.DriverInfoDetailsResponse;
+
+public interface DriverService {
+
+	Map<String, Object> getDriverList(String userId, DriverInfoRequest driverInfoRequest);
+
+	DriverInfoDetailsResponse getDriverDetails(String userId, String driverName, String drivingLicense);
+
+	
+}

+ 200 - 0
src/main/java/info/aspirecn/cloud/yysj/service/impl/DriverServiceImpl.java

@@ -0,0 +1,200 @@
+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.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import info.aspirecn.cloud.yysj.entity.Driver;
+import info.aspirecn.cloud.yysj.entity.request.DriverInfoRequest;
+import info.aspirecn.cloud.yysj.entity.response.DriverInfoDetailsResponse;
+import info.aspirecn.cloud.yysj.entity.response.DriverInfoResponse;
+import info.aspirecn.cloud.yysj.service.DriverService;
+import info.aspirecn.cloud.yysj.utils.DateUtil;
+import info.aspirecn.cloud.yysj.utils.ElasticSearchUitls;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
+@Service
+public class  DriverServiceImpl implements DriverService {
+	
+	 /** 主订单索引 */
+    @Value("${elasticsearch.firstIndex}")
+    private String firstIndex;
+
+    /** 驾驶证核验产品编号 */
+    @Value("${product.driverLicenseNumberProductId}")
+    private String driverLicenseNumberProductId;
+
+    /** 从业资格证核验产品编号 */
+    @Value("${product.qualificationCertificateProductId}")
+    private String qualificationCertificateProductId;
+	
+	@Autowired
+	private ElasticSearchUitls elasticSearchUitls;
+ 
+	@Override
+	public Map<String, Object> getDriverList(String userId,DriverInfoRequest driverInfoRequest) {
+		log.info("司机列表查询请求参数:{}",JSON.toJSON(driverInfoRequest));
+		
+		 //数据不能大于1000
+        if((driverInfoRequest.getPageNum() * driverInfoRequest.getPageSize()) > 1000){
+            return null;
+        }
+        // 创建 Bool 查询构建器
+        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+        // 构建查询条件
+        boolQueryBuilder.must(QueryBuilders.termsQuery("URI.keyword","/info_check/driverInfo.do"));
+        boolQueryBuilder.must(QueryBuilders.termsQuery("MG-UserId.keyword", userId));
+        if (driverInfoRequest.getDriverName()!=null&&!"".equals(driverInfoRequest.getDriverName())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.DriverName.keyword", "*"+driverInfoRequest.getDriverName()+"*"));
+		}
+        if (driverInfoRequest.getDrivingLicense()!=null&&!"".equals(driverInfoRequest.getDrivingLicense())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.DrivingLicense.keyword", "*"+driverInfoRequest.getDrivingLicense()+"*"));
+		}
+        if (driverInfoRequest.getDriverLicenseNumber()!=null&&!"".equals(driverInfoRequest.getDriverLicenseNumber())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.DriverLicenseNumber.keyword","*"+driverInfoRequest.getDriverLicenseNumber()+"*"));
+        }
+        if (driverInfoRequest.getQualificationCertificate()!=null&&!"".equals(driverInfoRequest.getQualificationCertificate())) {
+        	boolQueryBuilder.must(QueryBuilders.wildcardQuery("RequestInfo.QualificationCertificate.keyword", "*"+driverInfoRequest.getQualificationCertificate()+"*"));
+        }
+        if (driverInfoRequest.getDriveCardResult()!=null&&!"".equals(driverInfoRequest.getDriveCardResult())) {
+        	boolQueryBuilder.must(QueryBuilders.termsQuery("Check-Reuslt.result.keyword",driverInfoRequest.getDriveCardResult()));
+        	boolQueryBuilder.must(QueryBuilders.termsQuery("Check-Reuslt.productId.keyword",driverLicenseNumberProductId));
+        }
+        if (driverInfoRequest.getQualificationCardResult()!=null&&!"".equals(driverInfoRequest.getQualificationCardResult())) {
+        	boolQueryBuilder.must(QueryBuilders.termsQuery("Check-Reuslt.result.keyword",driverInfoRequest.getQualificationCardResult()));
+        	boolQueryBuilder.must(QueryBuilders.termsQuery("Check-Reuslt.productId.keyword",qualificationCertificateProductId));
+        }
+        if (driverInfoRequest.getStartTime()!=null&&!"".equals(driverInfoRequest.getStartTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").gte(driverInfoRequest.getStartTime()+"T00:00:00.000+0800"));
+		}
+        if (driverInfoRequest.getEndTime()!=null&&!"".equals(driverInfoRequest.getEndTime())) {
+        	  boolQueryBuilder.must(QueryBuilders.rangeQuery("DateTime").lte(driverInfoRequest.getEndTime()+"T23:59:59.000+0800"));
+		}
+        // 构建查询源构建器
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+        searchSourceBuilder.query(boolQueryBuilder);
+        searchSourceBuilder.sort("DateTime", SortOrder.DESC);
+        searchSourceBuilder.size(1000);
+        //设置源字段过虑,第一个参数结果集包括哪些字段,第二个参数表示结果集不包括哪些字段
+        searchSourceBuilder.fetchSource(new String[]{"RequestInfo.DriverName", "RequestInfo.DrivingLicense", "RequestInfo.DriverLicenseNumber",
+        		"Check-Reuslt", "DateTime","RequestInfo.QualificationCertificate"}, null);
+		
+        // 创建查询请求对象,将查询对象配置到其中
+        SearchRequest searchRequest = new SearchRequest(firstIndex);
+        searchRequest.source(searchSourceBuilder);
+
+        // 返回集合
+        List<DriverInfoResponse> driverInfoResponsesList = new ArrayList<DriverInfoResponse>();
+        //获取数据
+        SearchHits hits = elasticSearchUitls.getResultHits(searchRequest);
+        Map<String, Object> map=new HashMap<String, Object>();
+        if (hits == null) {
+        	map.put("dataList", driverInfoResponsesList);
+        	map.put("total", 0);
+            return map;
+        }
+        //遍历数据, 加上核验结果条件, 计算总数, 分页
+        int total = 0;
+        for (SearchHit hit : hits) {
+              JSONObject jsonObject = JSONObject.parseObject(hit.getSourceAsString());
+              String drivingLicenseCheckRes = "";
+              String driverLicenseNumberCheckRes= "";
+              String qualificationCertificateCheckRes ="";
+              JSONArray reusltJson = jsonObject.getJSONArray("Check-Reuslt");
+              if (reusltJson.size()>0) {
+            	  for (int i = 0; i < reusltJson.size(); i++) {
+                	  JSONObject checkResObj = reusltJson.getJSONObject(i);
+                	  if (driverLicenseNumberProductId.equals(checkResObj.getString("productId"))) {
+                		  driverLicenseNumberCheckRes=checkResObj.getString("result");
+                	  }
+                	  if (qualificationCertificateProductId.equals(checkResObj.getString("productId"))) {
+                		  qualificationCertificateCheckRes=checkResObj.getString("result");
+                	  }
+                  }
+              }
+             
+              if(driverInfoRequest.getDriveCardResult() != null
+                  && !"".equals(driverInfoRequest.getDriveCardResult())
+                  && !driverInfoRequest.getDriveCardResult().equals(driverLicenseNumberCheckRes)){
+                   continue;
+               }
+              if(driverInfoRequest.getQualificationCardResult() != null
+                  && !"".equals(driverInfoRequest.getQualificationCardResult())
+                  && !driverInfoRequest.getQualificationCardResult().equals(qualificationCertificateCheckRes)){
+                   continue;
+               }
+              total++;
+              if(total > ((driverInfoRequest.getPageNum()-1) * driverInfoRequest.getPageSize()) && driverInfoResponsesList.size() < driverInfoRequest.getPageSize()){
+	              JSONObject riJsonObject = jsonObject.getJSONObject("RequestInfo");
+	              if (riJsonObject!=null) {
+	            	  DriverInfoResponse driverInfoResponse=new DriverInfoResponse();
+		              driverInfoResponse.setUserId(userId);
+		              driverInfoResponse.setDriverName(riJsonObject.getString("DriverName"));
+		              driverInfoResponse.setDrivingLicense(riJsonObject.getString("DrivingLicense"));
+		              driverInfoResponse.setDriverLicenseNumber(riJsonObject.getString("DriverLicenseNumber"));
+		              driverInfoResponse.setQualificationCertificate(riJsonObject.getString("QualificationCertificate"));
+		              driverInfoResponse.setIdCardResult(drivingLicenseCheckRes);
+		              driverInfoResponse.setDriveCardResult(driverLicenseNumberCheckRes);
+		              driverInfoResponse.setQualificationCardResult(qualificationCertificateCheckRes);
+		              driverInfoResponse.setRequestTime(DateUtil.esTime2MySQLTime(jsonObject.getString("DateTime")));
+		              driverInfoResponsesList.add(driverInfoResponse);
+	              }
+              }
+         }
+        log.info("司机列表返回结果:{}",JSON.toJSON(driverInfoResponsesList));
+        map.put("dataList", driverInfoResponsesList);
+    	map.put("total", total);
+        return map;
+	}
+	
+	@Override
+	public  DriverInfoDetailsResponse getDriverDetails(String userId, String driverName, String drivingLicense) {
+		  SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+		  // 构建查询条件
+		  searchSourceBuilder.fetchSource(new String[]{"RequestInfo.DriverName", "RequestInfo.DrivingLicense", "RequestInfo.DriverLicenseNumber",
+				  "RequestInfo.VehicleClass","RequestInfo.IssuingOrganizations","RequestInfo.ValidPeriodFrom","RequestInfo.ValidPeriodTo",
+				  "RequestInfo.QualificationCertificate","RequestInfo.Telephone","RequestInfo.Remark",}, null);
+       
+		  searchSourceBuilder.query(QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery("DateTime").gte("now/M"))
+    	   		.must(QueryBuilders.termQuery("URI.keyword", "/info_check/driverInfo.do"))
+    	   		.must(QueryBuilders.termQuery("RequestInfo.DriverName.keyword", driverName))
+    	   		.must(QueryBuilders.termQuery("RequestInfo.DrivingLicense.keyword", drivingLicense))
+                .must(QueryBuilders.termQuery("MG-UserId.keyword", userId)));
+        
+	    // 创建查询请求对象,将查询对象配置到其中
+        SearchRequest searchRequest = new SearchRequest(firstIndex);
+        searchRequest.source(searchSourceBuilder);
+        // 将相应 JSON 结果转换成对象
+        List<Driver> driverList = elasticSearchUitls.getResult(searchRequest, Driver.class);
+        DriverInfoDetailsResponse dResponse=new DriverInfoDetailsResponse();
+        for (Driver driver : driverList) {
+			dResponse.setDriverName(driver.getRequestInfo().getDriverName());
+			dResponse.setDrivingLicense(driver.getRequestInfo().getDrivingLicense());
+			dResponse.setDriverLicenseNumber(driver.getRequestInfo().getDriverLicenseNumber());
+			dResponse.setVehicleClass(driver.getRequestInfo().getVehicleClass());
+			dResponse.setIssuingOrganizations(driver.getRequestInfo().getIssuingOrganizations());
+			dResponse.setValidPeriodFrom(driver.getRequestInfo().getValidPeriodFrom());
+			dResponse.setValidPeriodTo(driver.getRequestInfo().getValidPeriodTo());
+			dResponse.setQualificationCertificate(driver.getRequestInfo().getQualificationCertificate());
+			dResponse.setTelephone(driver.getRequestInfo().getTelephone());
+		}
+        log.info("----getDriverDetails{}----"+dResponse);
+        return dResponse;
+	}
+}

+ 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;
+	}
+
+}

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

@@ -0,0 +1,39 @@
+#ConfigMap 配置参数
+server:
+  port: 8080
+spring:
+  application:
+    name: cloud-yysj-driver-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}
+
+#监控配置参数
+management:
+  server:
+    port: 8081
+  endpoint:
+    restart:
+      enabled: true
+    health:
+      show-details: always
+  endpoints:
+    enabled-by-default: true
+    web:
+      exposure:
+        include: "*"
+info:
+  name: 司机列表
+  version: '1.0.0'
+