瀏覽代碼

first commit

15810770710@163.com 4 年之前
父節點
當前提交
4ea7f4f4ee
共有 21 個文件被更改,包括 1600 次插入0 次删除
  1. 213 0
      pom.xml
  2. 80 0
      src/main/java/info/aspirecn/iov/yysj/product/check/ProductCheck.java
  3. 80 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/ChannelRibbonHandle.java
  4. 34 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/CommonUtil.java
  5. 25 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/Property.java
  6. 29 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/RestTemplateConfigurate.java
  7. 11 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/ResultCodeException.java
  8. 33 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/TraceIdInterceptor.java
  9. 76 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/TransferParam.java
  10. 479 0
      src/main/java/info/aspirecn/iov/yysj/product/check/common/ZuulHelper.java
  11. 38 0
      src/main/java/info/aspirecn/iov/yysj/product/check/entity/RequestBody.java
  12. 13 0
      src/main/java/info/aspirecn/iov/yysj/product/check/entity/ResponseObject.java
  13. 16 0
      src/main/java/info/aspirecn/iov/yysj/product/check/entity/SjjhTransferReq.java
  14. 8 0
      src/main/java/info/aspirecn/iov/yysj/product/check/entity/YysjRequestBody.java
  15. 109 0
      src/main/java/info/aspirecn/iov/yysj/product/check/pre/OtherBillFilter.java
  16. 143 0
      src/main/java/info/aspirecn/iov/yysj/product/check/pre/WayBillFilter.java
  17. 68 0
      src/main/java/info/aspirecn/iov/yysj/product/check/redis/RedisConfig.java
  18. 3 0
      src/main/resources/config/banner.txt
  19. 46 0
      src/main/resources/config/bootstrap.yml
  20. 64 0
      src/main/resources/config/cloud-yysj-product-check.yaml
  21. 32 0
      src/main/resources/config/logback-spring.xml

+ 213 - 0
pom.xml

@@ -0,0 +1,213 @@
+<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">
+	<modelVersion>4.0.0</modelVersion>
+
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.2.2.RELEASE</version>
+	</parent>
+
+	<groupId>info.aspirecn.iov.yysj</groupId>
+	<artifactId>cloud-yysj-product-check</artifactId>
+	<version>1.1.2</version>
+	<packaging>jar</packaging>
+
+	<name>cloud-yysj-product-check</name>
+	<url>http://maven.apache.org</url>
+
+	<properties>
+  		 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
+	<dependencies>
+		<dependency>
+    				<groupId>org.springframework.boot</groupId>
+  			 <artifactId>spring-boot-starter-actuator</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-sleuth</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+		</dependency>
+		<dependency>
+		    <groupId>org.springframework.boot</groupId>
+		    <artifactId>spring-boot-starter-data-redis</artifactId>
+		</dependency>
+		<dependency>
+    		<groupId>commons-codec</groupId>
+    		<artifactId>commons-codec</artifactId>
+    		<version>1.11</version>
+		</dependency>
+
+		<dependency>
+		  <groupId>org.springframework.boot</groupId>
+		    <artifactId>spring-boot-starter-tomcat</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-zuul</artifactId>
+			<version>1.4.5.RELEASE</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-devtools</artifactId>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-kubernetes-config</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>info.aspirecn.cloud.yysj</groupId>
+			<artifactId>cloud-yysj-commons-lang</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<!--<dependency>
+			<groupId>net.rakugakibox.spring.boot</groupId>
+			<artifactId>logback-access-spring-boot-starter</artifactId>
+			<version>2.7.1</version>
+		</dependency>-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-configuration-processor</artifactId>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>net.logstash.logback</groupId>
+			<artifactId>logstash-logback-encoder</artifactId>
+			<version>5.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-lang3</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.modelmapper</groupId>
+			<artifactId>modelmapper</artifactId>
+			<version>2.3.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.google.code.gson</groupId>
+			<artifactId>gson</artifactId>
+		</dependency>
+
+	</dependencies>
+	<dependencyManagement>
+		<dependencies>
+			<dependency>
+				<groupId>org.springframework.cloud</groupId>
+				<artifactId>spring-cloud-dependencies</artifactId>
+				<version>Hoxton.RELEASE</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
+
+
+	<build>
+		<plugins>
+			<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>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<includes>
+						<include>
+							<groupId>info.aspirecn.cloud.yysj</groupId>
+							<artifactId>cloud-yysj-commons-lang</artifactId>
+						</include>
+					</includes>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-resources-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>default-resources</id>
+						<phase>validate</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>target/classes</outputDirectory>
+							<useDefaultDelimiters>false</useDefaultDelimiters>
+							<delimiters>
+								<delimiter>@</delimiter>
+							</delimiters>
+							<resources>
+								<resource>
+									<directory>src/main/resources/config</directory>
+									<targetPath>config</targetPath>
+									<filtering>true</filtering>
+									<includes>
+										<include>**</include>
+									</includes>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<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>
+							<excludeGroupIds>
+								info.aspirecn.cloud.yysj
+							</excludeGroupIds>
+						</configuration>
+					</execution>
+					<execution>
+						<id>copy</id>
+						<phase>install</phase>
+						<goals>
+							<goal>copy-dependencies</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>
+								${project.build.directory}/lib
+							</outputDirectory>
+							<excludeGroupIds>
+								info.aspirecn.cloud.yysj
+							</excludeGroupIds>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

+ 80 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/ProductCheck.java

@@ -0,0 +1,80 @@
+package info.aspirecn.iov.yysj.product.check;
+import java.io.IOException;
+
+import info.aspirecn.iov.yysj.product.check.common.Property;
+import info.aspirecn.iov.yysj.product.check.pre.OtherBillFilter;
+import info.aspirecn.iov.yysj.product.check.pre.WayBillFilter;
+import org.apache.commons.lang.math.NumberUtils;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.core.env.Environment;
+import org.springframework.util.StopWatch;
+import org.springframework.web.bind.annotation.RestController;
+import lombok.extern.slf4j.Slf4j;
+@ComponentScan(basePackages={"info.aspirecn.iov.yysj.product"})
+@SpringBootApplication
+@EnableZuulProxy
+@RestController
+@Slf4j
+@EnableCaching
+public class ProductCheck {
+
+
+	public static void main(String[] args) {
+
+		StopWatch watch = new StopWatch();
+		watch.start();
+		ApplicationContext context = SpringApplication.run(ProductCheck.class, args);
+		Environment environment = context.getBean(Environment.class);
+		String applicationName = environment.getProperty("spring.application.name");
+		String infoName = environment.getProperty("info.name");
+		String infoVersion = environment.getProperty("info.version");
+		int serverPort = NumberUtils.toInt(environment.getProperty("server.port"));
+		int managementServerPort = NumberUtils.toInt(environment.getProperty("management.server.port"));
+		Property property = context.getBean(Property.class);
+		watch.stop();
+
+		log.info("{} Ver.{} ({}) 启动完毕,serverPort={}, managementServerPort={}, times={}s", infoName, infoVersion,
+				applicationName, serverPort, managementServerPort, watch.getTotalTimeSeconds());
+	}
+
+	/**
+	 * 动态更新路由策略 经测试,可以加策略,但是删除需要重启
+	 * 
+	 * @return
+	 */
+	@RefreshScope
+	@ConfigurationProperties("zuul")
+	public ZuulProperties zuulProperties() {
+		return new ZuulProperties();
+	}
+	/**
+	 * 链路日志打印
+	 *
+	 * @throws IOException
+	 */
+/*	@PostMapping("/api/v2/spans")
+	public void index(HttpServletRequest request) throws IOException {
+		String context = IOUtils.toString(request.getInputStream(), Charsets.UTF_8);
+		logger_sleuth.debug(context);
+	}*/
+
+	@Bean
+	public WayBillFilter addUserBalanceFilter() {
+		return new WayBillFilter();
+	}
+
+	@Bean
+	public OtherBillFilter addOtherBillFilter() {
+		return new OtherBillFilter();
+	}
+
+}

+ 80 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/ChannelRibbonHandle.java

@@ -0,0 +1,80 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Resource;
+
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import info.aspirecn.iov.yysj.product.check.entity.ResponseObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.netflix.zuul.context.RequestContext;
+import lombok.extern.slf4j.Slf4j;
+
+@Component
+@Slf4j
+public class ChannelRibbonHandle {
+	@Resource(name = "getRestTemplate")
+	RestTemplate restTemplate;
+	@Autowired
+	ObjectMapper objectMapper;
+	@Autowired
+	Property property;
+
+	public ResponseObject channelRibbonHandle(String  token,String body) {
+		ResponseObject responseObject = null;
+		try{
+				RequestContext.getCurrentContext().set("connectTimeout", property.getConnetTimeOut());
+				RequestContext.getCurrentContext().set("readTimeout", property.getReadTimeOut()+1000);
+			HttpHeaders headers = new HttpHeaders();
+
+			restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
+			MediaType type = MediaType.parseMediaType("application/json;charset=UTF-8");
+			headers.setContentType(type);
+			headers.add(Constants.HEADER_ACCEPT_KEY, MediaType.APPLICATION_JSON.toString()+";charset=UTF-8");
+			headers.add(Constants.HEADER_TOKEN_KEY, token);
+			HttpEntity <String>httpEntity =null;
+			ResponseEntity<ResponseObject> entity = null;
+				httpEntity = new HttpEntity<String>(body,
+						headers);
+				entity = restTemplate.postForEntity(property.getGateWayUrl(), httpEntity,
+						ResponseObject.class,new HashMap());
+
+			if (entity != null && entity.getStatusCode() == HttpStatus.OK) {// 调用通道成功
+
+				responseObject = entity.getBody();
+				HttpHeaders httpHeaders = entity.getHeaders();
+				List<String> prices = httpHeaders.get(Constants.price);
+
+				if(prices!=null && prices.size()>=1){
+					responseObject.setPrice(Integer.parseInt(prices.get(0)));
+					RequestContext.getCurrentContext().getRequest().setAttribute(Constants.price,Integer.parseInt(prices.get(0)));
+				}
+				List<String> isCharges = httpHeaders.get("isCharge");
+
+			/*	if(prices!=null && prices.size()>=1){
+					responseObject.setPrice(Integer.parseInt(prices.get(0)));
+				}*/
+				if(isCharges!=null && isCharges.size()>=1){
+					RequestContext.getCurrentContext().getRequest().setAttribute("isCharge",isCharges.get(0));
+				}
+
+			}
+			log.info("responseObject:{}",responseObject);
+		} catch (Exception ex) {
+			log.error("ex:{}",ex);
+		}
+		return responseObject;
+	}
+}

+ 34 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/CommonUtil.java

@@ -0,0 +1,34 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.List;
+
+@Slf4j
+public class CommonUtil {
+    private static List<String> allowUrls=null;
+    //获取请求内容
+    public static String getBody(HttpServletRequest request){
+        String bodyStr =null;
+        try {
+            StringBuffer body = new StringBuffer();
+            BufferedReader bufferedReader = new BufferedReader(
+                    new InputStreamReader(request.getInputStream(), "utf-8")); // 读取参数流
+            String nextLine = bufferedReader.readLine();
+            while (nextLine != null) {
+                body.append(nextLine);
+                nextLine = bufferedReader.readLine();
+            }
+            bodyStr = body.toString();
+            if (bodyStr == null || bodyStr.length() <= 0) {
+                log.error("请求参数为空,bodyStr:{}",bodyStr);
+            }
+        }catch (Exception ex){
+            log.error("获取参数异常,ex:{}",ex);
+        }
+        return  bodyStr;
+    }
+}

+ 25 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/Property.java

@@ -0,0 +1,25 @@
+package info.aspirecn.iov.yysj.product.check.common;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Component
+@Data
+@ConfigurationProperties(prefix = "common")
+public class Property {
+    private int  connetTimeOut;
+    private int readTimeOut;
+    private String appKey;
+    private String appSecret;
+    private String tokenSecret;
+    private String gateWayUrl;
+    private Map<String,String> Products;
+    private Map<String,String> productMap;
+    private List<String> sjjhSystemErrors;
+}
+
+

+ 29 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/RestTemplateConfigurate.java

@@ -0,0 +1,29 @@
+package info.aspirecn.iov.yysj.product.check.common;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.web.client.RestTemplate;
+import java.util.List;
+
+@Configuration
+@Slf4j
+public class RestTemplateConfigurate {
+	@Autowired
+	TraceIdInterceptor traceIdInterceptor;
+	@Bean(name = "getRestTemplate")
+	//@LoadBalanced
+	public RestTemplate getRestTemplate() {
+		// 把自定义的ClientHttpRequestInterceptor添加到RestTemplate,可添加多个
+		 RestTemplate restTemplate =  new RestTemplate();
+		List<ClientHttpRequestInterceptor> interceptors =  restTemplate.getInterceptors();
+		for(ClientHttpRequestInterceptor interceptor : interceptors){
+			log.info("interceptor:{}",interceptor);
+		}
+		interceptors.add(traceIdInterceptor);
+		restTemplate.setInterceptors(interceptors);
+		return restTemplate;
+	}
+}

+ 11 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/ResultCodeException.java

@@ -0,0 +1,11 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class ResultCodeException extends Exception{
+	private String code;
+	private String message;
+}

+ 33 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/TraceIdInterceptor.java

@@ -0,0 +1,33 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.util.List;
+@Component
+@Slf4j
+public class TraceIdInterceptor implements ClientHttpRequestInterceptor {
+
+
+    @Override
+    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
+            throws IOException {
+        HttpHeaders headers = request.getHeaders();
+        //取出来设置的traceId的信息
+        List<String> list = headers.get(Constants.HEADER_TRACEID_KEY);
+        headers.add(Constants.HEADER_PARENT_TRACEID_KEY, list.get(0));
+        //清除链路设置的traceId数据
+        list.clear();
+        //添加新的traceId数据
+        list.add(headers.get("x-b3-spanid").get(0));
+        // 保证请求继续被执行
+        return execution.execute(request, body);
+    }
+}

+ 76 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/TransferParam.java

@@ -0,0 +1,76 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.*;
+
+@Component
+@Slf4j
+public class TransferParam {
+    @Autowired
+    private Property property;
+    public Map<String,String> getCustomBody( Map<String, Object> paramMap,String productId,List<String> emptyList) throws IOException {
+        Map customBody =null;
+        Map<String,String> productMap = property.getProductMap();
+        if (productMap.get("qyyyxkyz_jyxkzh").equals(productId)) {//企业经营许可验证  经营许可证号
+
+            customBody=qyyyxkyz_jyxkzh(paramMap,emptyList);
+        }else if (productMap.get("qyyyxkyz_tyshdm").equals(productId)) {//企业经营许可验证   统一社会代码
+
+            customBody=qyyyxkyz_tyshdm(paramMap,emptyList);
+        }else if (productMap.get("clxszyz").equals(productId)) {//车辆行驶证
+
+            customBody=clxszyz(paramMap);
+        }else if (productMap.get("ryjszyz").equals(productId)) {//人员驾驶证
+
+            customBody=ryjszyz(paramMap);
+        }else{
+            customBody = paramMap;
+        }
+        return customBody;
+    }
+    public Map<String,String> clxszyz(Map<String,Object> requestMap) throws IOException {
+
+
+        Map<String, String> vehicleInfoMap = new HashMap<String, String>();
+        vehicleInfoMap.put(Constants.clxszyz_carNumber, (String)requestMap.get(Constants.clxszyz_carNumber));
+        vehicleInfoMap.put(Constants.clxszyz_carType, (String) requestMap.get(Constants.clxszyz_carType));
+        vehicleInfoMap.put(Constants.clxszyz_name, (String) requestMap.get(Constants.clxszyz_name));
+        return vehicleInfoMap;
+    }
+    public Map<String,String> ryjszyz(Map<String,Object> requestMap) throws IOException {
+        Map<String, String> vehicleInfoMap = new HashMap<String, String>();
+        vehicleInfoMap.put(Constants.ryjszyz_name, (String)requestMap.get(Constants.ryjszyz_name));
+        vehicleInfoMap.put(Constants.ryjszyz_driveNo, (String) requestMap.get(Constants.ryjszyz_driveNo));
+        return vehicleInfoMap;
+    }
+    public Map<String,String> qyyyxkyz_jyxkzh(Map<String,Object> requestMap,List<String> emptyList) throws IOException {
+        String carrier=(String)requestMap.get(Constants.bill_carrier);
+        String permitNumber=(String)requestMap.get(Constants.bill_permitNumber);
+/*        String permitValidPeriodFrom=requestMap.get(Constants.bill_permitValidPeriodFrom);
+        String permitValidPeriodTo=requestMap.get(Constants.bill_permitValidPeriodTo);*/
+        String provinceCode =(String)requestMap.get("provinceCode");
+
+            Map<String, String> vehicleInfoMap = new HashMap<String, String>();
+            vehicleInfoMap.put(Constants.qyyyxkz_carrier, carrier);
+            vehicleInfoMap.put(Constants.qyyyxkz_permitNumber, permitNumber);
+            vehicleInfoMap.put(Constants.qyyyxkz_provinceCode, provinceCode);
+  /*      vehicleInfoMap.put(Constants.clyyyz_periodStartDate, permitValidPeriodFrom);
+        vehicleInfoMap.put(Constants.clyyyz_periodEndDate, permitValidPeriodTo);*/
+            return vehicleInfoMap;
+    }
+    public Map<String,String> qyyyxkyz_tyshdm(Map<String,Object> requestMap,List<String> emptyList) throws IOException {
+        String carrier=(String)requestMap.get(Constants.bill_carrier);
+      //  String unifiedSocialCreditIdentifier=requestMap.get(Constants.bill_unifiedSocialCreditIdentifier);
+            Map<String, String> vehicleInfoMap = new HashMap<String, String>();
+            vehicleInfoMap.put(Constants.qyyyxkz_name, carrier);
+           // vehicleInfoMap.put(Constants.qyyyxkz_creditCode, unifiedSocialCreditIdentifier);
+            return vehicleInfoMap;
+        }
+
+
+
+}

+ 479 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/common/ZuulHelper.java

@@ -0,0 +1,479 @@
+package info.aspirecn.iov.yysj.product.check.common;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import info.aspirecn.cloud.yysj.commons.lang.BillItemResult;
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import info.aspirecn.cloud.yysj.commons.lang.OtherCommonResult;
+import info.aspirecn.iov.yysj.product.check.entity.*;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.netflix.zuul.context.RequestContext;
+import lombok.extern.slf4j.Slf4j;
+@Component
+@Slf4j
+public class ZuulHelper {
+	@Autowired
+	private ObjectMapper mapper;
+	@Autowired
+	Gson gson;
+	@Autowired
+	StringRedisTemplate stringTemplate;
+	@Autowired
+	private Property property;
+	@Autowired
+	private ChannelRibbonHandle channelRibbonHandle;
+	@Value("#{'${common.errorCode}'.split(',')}")
+	List<String> errorCode;
+	@Autowired
+	private ZuulHelper helper;
+	public Boolean hasProcessFlag(RequestContext requestContext) {
+        
+        Boolean ret = (Boolean)requestContext.get("process");
+        if( ret != null )
+        {
+            return ret;
+        }
+        else
+        {
+            return Boolean.FALSE;
+        }
+    }
+	
+	public void responseHandle(BillItemResult responseObject, RequestContext requestContext) throws JsonProcessingException{
+		String json = mapper.writeValueAsString(responseObject);
+		 requestContext.set("process", Boolean.TRUE);
+		 requestContext.setResponseBody(json);
+		 requestContext.getResponse().setCharacterEncoding("utf-8");
+		 requestContext.getResponse().setContentType("application/json");
+		 requestContext.setSendZuulResponse(false);
+		 requestContext.setResponseStatusCode(HttpServletResponse.SC_OK);// 返回码
+	}
+	public void responseHandleCommon(Object object, RequestContext requestContext) throws JsonProcessingException{
+		String json = mapper.writeValueAsString(object);
+		requestContext.set("process", Boolean.TRUE);
+		requestContext.setResponseBody(json);
+		requestContext.getResponse().setCharacterEncoding("utf-8");
+		requestContext.getResponse().setContentType("application/json");
+		requestContext.setSendZuulResponse(false);
+		requestContext.setResponseStatusCode(HttpServletResponse.SC_OK);// 返回码
+	}
+	//获取请求参数
+	public  String getCustomBody(HttpServletRequest request) throws UnsupportedEncodingException, IOException{
+		StringBuilder body = new StringBuilder();
+	 	BufferedReader bufferedReader = new BufferedReader(
+				new InputStreamReader(request.getInputStream(), "utf-8")); // 读取参数流
+		String nextLine = bufferedReader.readLine();
+		while (nextLine != null) {
+		    body.append(nextLine);
+			nextLine = bufferedReader.readLine();
+		}
+		String bodyStr = body.toString();
+
+		return bodyStr;
+	}
+	//根据响应参数,判断结果
+	public void handleResult(String productId,ResponseObject responseObject,Map<String,Object> requestParams,BillItemResult billItemResult){
+		Set<String> inconsistentList = new HashSet<String>();//不一致项列表
+		Set<String> emptyList = new HashSet<String>();
+		String result =Constants.consistent_code;
+		BillItemResult.ErrorResponse errorResponse =new BillItemResult.ErrorResponse();
+		try {
+			String resultBody = "";
+			if (responseObject.getResultBody() instanceof String) {
+				resultBody = (String) responseObject.getResultBody();
+			} else {
+				resultBody = mapper.writeValueAsString(responseObject.getResultBody());
+			}
+			if(errorCode.contains(responseObject.getResultCode())){
+				errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
+				billItemResult.setResult(Constants.inconsistent_code);
+				billItemResult.setExceptionInformation(errorResponse);
+				return ;
+			}
+			Map<String, String> productMap = property.getProductMap();
+			if (productMap.get("clxszyz").equals(productId)) {//行驶证
+
+				if ("128".equals(responseObject.getResultCode())||"1000".equals(responseObject.getResultCode())) {
+
+					Map<String, String> responseParams = mapper.readValue(resultBody, Map.class);
+					//使用性质、车辆识别代号、发证机关、注册日期、发证日期
+					if ("不一致".equals(responseParams.get("isOwner"))) {
+
+						result = Constants.inconsistent_code;
+						inconsistentList.add(Constants.car_owner);
+					}
+					String resp_vin=responseParams.get(Constants.clxszyz_vin);
+					if (StringUtils.isEmpty(resp_vin)) {
+						result = Constants.inconsistent_code;
+						emptyList.add(Constants.car_vin);
+
+					} else if (!requestParams.get(Constants.car_vin).equals(resp_vin)) {
+						result = Constants.inconsistent_code;
+						inconsistentList.add(Constants.car_vin);
+					}
+					String resp_register_date=responseParams.get(Constants.clxszyz_register_date);
+					if (StringUtils.isEmpty(resp_register_date)) {
+						result = Constants.inconsistent_code;
+						emptyList.add(Constants.car_registerDate);
+					} else {
+						SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+						SimpleDateFormat ymdSdf = new SimpleDateFormat("yyyyMMdd");
+						String resigerDate = ymdSdf.format(sdf.parse(resp_register_date));
+						if (!resigerDate.equals(requestParams.get(Constants.car_registerDate))) {
+							result = Constants.inconsistent_code;
+							inconsistentList.add(Constants.car_registerDate);
+						}
+					}
+
+				} else if("129".equals(responseObject.getResultCode()) ||"1099".equals(responseObject.getResultCode())){
+					result = Constants.inconsistent_code;
+					emptyList.add(Constants.car_vehicleNumber);
+					emptyList.add(Constants.car_vehicleType);
+					emptyList.add(Constants.car_owner);
+				}else {
+					result = Constants.inconsistent_code;
+					inconsistentList.add(Constants.car_vehicleNumber);
+					inconsistentList.add(Constants.car_vehicleType);
+					inconsistentList.add(Constants.car_owner);
+
+				}
+				if (emptyList.size() != 0) {
+
+					errorResponse.setCode(Constants.ErrorCode.NULL.getErrorCode());
+					errorResponse.setResultList(emptyList);
+				} else if (inconsistentList.size() != 0) {
+					errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
+					errorResponse.setResultList(inconsistentList);
+					//errorInfo = "数据源" + StringUtils.join(emptyList.toArray(), ",") + "为不一致";
+				}
+			} else if (productMap.get("ryjszyz").equals(productId)) {
+
+
+				if ("124".equals(responseObject.getResultCode())||"1000".equals(responseObject.getResultCode())) {
+					Map<String, String> responseParams = mapper.readValue(resultBody, Map.class);
+					//准驾车型、有效期自、有效期至
+					String zjcx = responseParams.get("ZJCX");
+					if (StringUtils.isEmpty(zjcx)) {
+						emptyList.add(Constants.driver_vehicleClass);
+						result = Constants.inconsistent_code;
+					} else if (!requestParams.get(Constants.driver_vehicleClass).equals(zjcx)) {
+						result = Constants.inconsistent_code;
+						inconsistentList.add(Constants.driver_vehicleClass);
+					}
+					String qsyxqStr=responseParams.get("QSYXQ");
+					String jsyxqStr=responseParams.get("JSYXQ");
+					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+					SimpleDateFormat ymdSdf = new SimpleDateFormat("yyyyMMdd");
+					if (qsyxqStr == null || qsyxqStr.length() < 10) {
+						emptyList.add(Constants.driver_validPeriodFrom);
+						result = Constants.inconsistent_code;
+					} else {
+						String qsyxq = qsyxqStr.substring(0, 10);
+						if (!requestParams.get(Constants.driver_validPeriodFrom).equals(ymdSdf.format(sdf.parse(qsyxq)))) {
+							result = Constants.inconsistent_code;
+							inconsistentList.add(Constants.driver_validPeriodFrom);
+
+						}
+					}
+					if (jsyxqStr == null || jsyxqStr.length() < 10) {
+						emptyList.add(Constants.driver_validPeriodTo);
+						result = Constants.inconsistent_code;
+					} else {
+						String jsyxq = jsyxqStr.substring(0, 10);
+						if (!requestParams.get(Constants.driver_validPeriodTo).equals(ymdSdf.format(sdf.parse(jsyxq)))) {
+							result = Constants.inconsistent_code;
+							inconsistentList.add(Constants.driver_validPeriodTo);
+						}
+					}
+
+				} else if("125".equals(responseObject.getResultCode())||"1099".equals(responseObject.getResultCode())){
+					result = Constants.inconsistent_code;
+					emptyList.add(Constants.driver_driverNamer);
+					emptyList.add(Constants.driver_driverLicenseNumber);
+				}else {
+				result = Constants.inconsistent_code;
+				inconsistentList.add(Constants.driver_driverNamer);
+				inconsistentList.add(Constants.driver_driverLicenseNumber);
+
+			}
+
+				if (emptyList.size() != 0) {
+
+					errorResponse.setCode(Constants.ErrorCode.NULL.getErrorCode());
+					errorResponse.setResultList(emptyList);
+				} else if (inconsistentList.size() != 0) {
+					errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
+					errorResponse.setResultList(inconsistentList);
+					//errorInfo = "数据源" + StringUtils.join(emptyList.toArray(), ",") + "为不一致";
+				}
+			} else if(productMap.get("czyz").equals(productId)){
+				if (!"1".equals(responseObject.getResultCode())) {
+					result = Constants.inconsistent_code;
+					if ("2".equals(responseObject.getResultCode())) {
+						errorResponse.setCode(Constants.ErrorCode.WEIGTHOVER.getErrorCode());
+					}else{
+						errorResponse = mapper.readValue(resultBody, BillItemResult.ErrorResponse.class);
+					}
+				}
+			} else if(productMap.get("sfzyz").equals(productId)){
+				if (!"114".equals(responseObject.getResultCode()) && !"1174".equals(responseObject.getResultCode())) {
+					result = Constants.inconsistent_code;
+					inconsistentList.add(Constants.persontyr_name);
+					inconsistentList.add(Constants.persontyr_idCode);
+					errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
+					errorResponse.setResultList(inconsistentList);
+				}
+			}else {
+				if (!"1".equals(responseObject.getResultCode())) {
+					/*if("3".equals(responseObject.getResultCode())){
+						errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
+						billItemResult.setResult(Constants.inconsistent_code);
+						billItemResult.setExceptionInformation(errorResponse);
+						return ;
+					}*/
+					result = Constants.inconsistent_code;
+					 errorResponse = mapper.readValue(resultBody, BillItemResult.ErrorResponse.class);
+
+					/*Object resultObj = map.get("resultList");
+					List list = null;
+					if (resultObj instanceof LinkedList) {
+						list = (List) resultObj;
+						transferParam(productMap, productId, list);
+					}
+					if ("1".equals(map.get("code"))) {
+
+						errorInfo = "数据源" + StringUtils.join(list.toArray(), ",") + "为空";
+
+					} else {
+
+						errorInfo = "数据源" + StringUtils.join(list.toArray(), ",") + "为空";
+
+					}*/
+				}
+			}
+
+		}catch(Exception ex){
+			log.error("解析参数异常,Exception:{}",ex);
+			result = Constants.inconsistent_code;
+			errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
+		}
+		billItemResult.setResult(result);
+		billItemResult.setExceptionInformation(errorResponse);
+	}
+	public void transferParam(Map<String,String> productMap,String productId,List<String> list){
+		List<String> removeList = new ArrayList<String>();
+		if (productMap.get("rycyzgyz").equals(productId)) {//人员从业资格验证
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.rycyzgyz_nameOfPerson.equals(param)){
+					list.add(Constants.driver_driverNamer);
+				}
+				if(Constants.rycyzgyz_qualificationCertificateNumber.equals(param)){
+					list.add(Constants.driver_qualificationCertificate);
+				}
+				if(Constants.rycyzgyz_provinceCode.equals(param)){
+					list.add(Constants.driver_provinceCode);
+				}
+				if(Constants.rycyzgyz_periodStartDate.equals(param)){
+					list.add(Constants.driver_qualificationCertificateFrom);
+				}
+				if(Constants.rycyzgyz_periodEndDate.equals(param)){
+					list.add(Constants.driver_qualificationCertificateTo);
+				}
+			}
+
+		}if (productMap.get("clyyyz").equals(productId)) {//车辆营运验证
+
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.clyyyz_vehicleNumber.equals(param)){
+					list.add(Constants.car_vehicleNumber);
+				}
+				if(Constants.clyyyz_licensePlateTypeCode.equals(param)){
+					list.add(Constants.car_vehiclePlateColorCode);
+				}
+				if(Constants.clyyyz_roadTransportCertificateNumber.equals(param)){
+					list.add(Constants.car_roadTransport);
+				}
+				if(Constants.clyyyz_periodStartDate.equals(param)){
+					list.add(Constants.car_roadTransportCertificateValidPeriodFrom);
+				}
+				if(Constants.clyyyz_periodEndDate.equals(param)){
+					list.add(Constants.car_roadTransportCertificateValidPeriodTo);
+				}
+			}
+		}if (productMap.get("qyyyxkyz_jyxkzh").equals(productId)) {//企业经营许可验证  经营许可证号
+
+
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.qyyyxkz_carrier.equals(param)){
+					list.add(Constants.bill_carrier);
+				}
+				if(Constants.qyyyxkz_permitNumber.equals(param)){
+					list.add(Constants.bill_permitNumber);
+				}
+				if(Constants.qyyyxkz_provinceCode.equals(param)){
+					list.add(Constants.bill_carrier);
+					list.add(Constants.bill_unifiedSocialCreditIdentifier);
+				}
+			}
+		}if (productMap.get("qyyyxkyz_tyshdm").equals(productId)) {//企业经营许可验证   统一社会代码
+
+
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.qyyyxkz_name.equals(param)){
+					list.add(Constants.bill_carrier);
+				}
+				if(Constants.qyyyxkz_creditCode.equals(param)){
+					list.add(Constants.bill_unifiedSocialCreditIdentifier);
+				}
+
+			}
+		}if (productMap.get("clrwyz").equals(productId)) {//车辆入网验证
+
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.clrw_vehicleNumber.equals(param)){
+					list.add(Constants.car_vehicleNumber);
+				}
+				if(Constants.clrw_licensePlateTypeCode.equals(param)){
+					list.add(Constants.car_vehiclePlateColorCode);
+				}
+			}
+		}if (productMap.get("tyrsfyz_person").equals(productId)) {//托运人身份验证(个人)
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.persontyr_name.equals(param)){
+					list.add(Constants.bill_consignor);
+				}
+				if(Constants.persontyr_idCode.equals(param)){
+					list.add(Constants.bill_ConsignorID);
+				}
+
+			}
+		}if (productMap.get("tyrsfyz_enterprise").equals(productId)) {//托运人身份验证(企业)
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.enterpricetyr_name.equals(param)){
+					list.add(Constants.bill_consignor);
+				}
+				if(Constants.enterpricetyr_creditCode.equals(param)){
+					list.add(Constants.bill_ConsignorID);
+				}
+			}
+		}if (productMap.get("zhdwyz").equals(productId)) {//托运人身份验证(企业)
+			for(String param : list){
+				removeList.add(param);
+				if(Constants.enterpricetyr_name.equals(param)){
+					list.add(Constants.bill_consignor);
+				}
+				if(Constants.enterpricetyr_creditCode.equals(param)){
+					list.add(Constants.bill_ConsignorID);
+				}
+			}
+		}
+	}
+	public ResponseObject getResult(SjjhTransferReq sjjhTransferReq,BillItemResult billItemResult) throws IOException {
+		BillItemResult.ErrorResponse errorResponse = new BillItemResult.ErrorResponse();
+
+		billItemResult.setResult(Constants.consistent_code);
+		RequestBody requestBody = new RequestBody();
+		requestBody.setAccessId(sjjhTransferReq.getAccessId());
+		requestBody.setProductId(sjjhTransferReq.getSjjhProductId());
+		requestBody.setCustomBody(sjjhTransferReq.getCustomBody());
+		String requestBodyStr = mapper.writeValueAsString(requestBody);
+		log.info("requestBodyStr:{}", requestBodyStr);
+		requestBodyStr = new String(requestBodyStr.getBytes(), "utf-8");
+		ResponseObject responseObject = channelRibbonHandle.channelRibbonHandle(sjjhTransferReq.getToken(), requestBodyStr);
+		if (responseObject == null) {//系统错误
+			billItemResult.setResult(Constants.inconsistent_code);
+			errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
+			billItemResult.setExceptionInformation(errorResponse);
+		} else {
+			 helper.handleResult(sjjhTransferReq.getSjjhProductId(), responseObject, sjjhTransferReq.getOriginCustomBody(),billItemResult);
+
+		}
+
+		return responseObject;
+	}
+	public OtherCommonResult getOtherResult(SjjhTransferReq sjjhTransferReq) throws IOException {
+		OtherCommonResult otherCommonResult = new OtherCommonResult();
+		otherCommonResult.setResultCode(Constants.inconsistent_code);
+		RequestBody requestBody = new RequestBody();
+		requestBody.setAccessId(sjjhTransferReq.getAccessId());
+		requestBody.setProductId(sjjhTransferReq.getSjjhProductId());
+		requestBody.setCustomBody(sjjhTransferReq.getCustomBody());
+		String requestBodyStr = mapper.writeValueAsString(requestBody);
+		log.info("requestBodyStr:{}", requestBodyStr);
+		requestBodyStr = new String(requestBodyStr.getBytes(), "utf-8");
+		ResponseObject responseObject = channelRibbonHandle.channelRibbonHandle(sjjhTransferReq.getToken(), requestBodyStr);
+		if(responseObject!=null ){
+			if("1".equals(responseObject.getResultCode())) {
+
+				String resultBody = "";
+				if (responseObject.getResultBody() instanceof String) {
+					resultBody = (String) responseObject.getResultBody();
+				} else {
+					resultBody = mapper.writeValueAsString(responseObject.getResultBody());
+				}
+				Map<String,String> resultMap = mapper.readValue(resultBody,Map.class);
+				String url = RequestContext.getCurrentContext().getRequest().getHeader(Constants.Url);
+				if(Constants.OtherRquestUrl.LIVINGURL.getValue().equals(url)){
+					String similarity = resultMap.get("similarity");
+					double similarityDouble =  Double.parseDouble(similarity);
+					if(similarityDouble>=85){
+						otherCommonResult.setResultCode(Constants.consistent_code);
+					}else{
+						otherCommonResult.setResultCode(Constants.inconsistent_code);
+					}
+					resultMap.clear();
+					resultMap.put("similarity",similarity);
+				}else if(Constants.OtherRquestUrl.IDLENTITYVERIFICATION.getValue().equals(url)){
+					String similarity = resultMap.get("similarity");
+					String appeidcode = resultMap.get("appeidcode");
+					String eIDvoucher = resultMap.get("eidvoucher");
+					String h1 = resultMap.get("h1");
+					/*String name = resultMap.get("name");
+					String idNumber = resultMap.get("idNumber");*/
+					double similarityDouble =  Double.parseDouble(similarity);
+					if(similarityDouble>=85){
+						otherCommonResult.setResultCode(Constants.consistent_code);
+					}else{
+						otherCommonResult.setResultCode(Constants.inconsistent_code);
+					}
+					resultMap.clear();
+					resultMap.put("similarity",similarity);
+					resultMap.put("appeIdCode",appeidcode);
+					resultMap.put("eidVoucher",eIDvoucher);
+					resultMap.put("H1",h1);
+					//resultMap.put("idNumber",idNumber);
+				}
+				otherCommonResult.setResultBody(resultMap);
+			}else if(errorCode.contains(responseObject.getResultCode())){
+				otherCommonResult.setResultCode(Constants.xysj_error);
+			}else if("8".equals(responseObject.getResultCode())){
+				otherCommonResult.setResultCode(Constants.param_error);
+			}
+		}else{
+			otherCommonResult.setResultCode(Constants.xysj_error);
+		}
+		return otherCommonResult;
+	}
+}

+ 38 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/entity/RequestBody.java

@@ -0,0 +1,38 @@
+package info.aspirecn.iov.yysj.product.check.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class RequestBody implements Serializable {
+
+	private static final long serialVersionUID = 3458902254495234357L;
+	private String productId;
+	private String accessId;
+	private Object customBody;
+
+	public String getProductId() {
+		return productId;
+	}
+
+	public void setProductId(String productId) {
+		this.productId = productId;
+	}
+
+	public String getAccessId() {
+		return accessId;
+	}
+
+	public void setAccessId(String accessId) {
+		this.accessId = accessId;
+	}
+
+	public Object getCustomBody() {
+		return customBody;
+	}
+
+	public void setCustomBody(Object customBody) {
+		this.customBody = customBody;
+	}
+}

+ 13 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/entity/ResponseObject.java

@@ -0,0 +1,13 @@
+package info.aspirecn.iov.yysj.product.check.entity;
+
+import lombok.Data;
+
+@Data
+public class ResponseObject {
+	private String accessId;
+	private String resultCode;
+	private Object resultBody;
+	private String transationId;
+	private String reuslt;
+	private int price;
+}

+ 16 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/entity/SjjhTransferReq.java

@@ -0,0 +1,16 @@
+package info.aspirecn.iov.yysj.product.check.entity;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class SjjhTransferReq {
+    private String sjjhTraceId;
+    private String accessId;
+    private String sjjhProductId;
+    private String token;
+    private String result;
+    private Object customBody;
+    private Map<String,Object> originCustomBody;
+}

+ 8 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/entity/YysjRequestBody.java

@@ -0,0 +1,8 @@
+package info.aspirecn.iov.yysj.product.check.entity;
+
+import lombok.Data;
+
+@Data
+public class YysjRequestBody {
+    private String requestBody;
+}

+ 109 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/pre/OtherBillFilter.java

@@ -0,0 +1,109 @@
+package info.aspirecn.iov.yysj.product.check.pre;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+import info.aspirecn.cloud.yysj.commons.lang.BillItemResult;
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import info.aspirecn.cloud.yysj.commons.lang.OtherCommonResult;
+import info.aspirecn.cloud.yysj.commons.lang.ProductCheckRequest;
+import info.aspirecn.iov.yysj.product.check.common.Property;
+import info.aspirecn.iov.yysj.product.check.common.TransferParam;
+import info.aspirecn.iov.yysj.product.check.common.ZuulHelper;
+import info.aspirecn.iov.yysj.product.check.entity.ResponseObject;
+import info.aspirecn.iov.yysj.product.check.entity.SjjhTransferReq;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 运单信息核验服务,
+ */
+@Slf4j
+public class OtherBillFilter extends ZuulFilter {
+	@Autowired
+	private ObjectMapper mapper;
+	@Autowired
+	private ZuulHelper helper;
+	@Autowired
+	private TransferParam transferParam;
+	@Override
+	public boolean shouldFilter() {
+		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
+/*		request.setAttribute("result", "0");
+		request.setAttribute(Constants.price,"0");
+		request.setAttribute("isCharge","0");*/
+		String url = request.getRequestURI();
+
+		return Constants.ProductCheckUrl.OTHERBILLURL.getValue().equals(url);
+	}
+
+	@Override
+	public Object run() {
+		String accessId = UUID.randomUUID().toString().replace("-","");
+		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
+		OtherCommonResult responseObject = new OtherCommonResult();
+		try {
+			//从请求头中获取token
+			String token = request.getHeader(Constants.HEADER_TOKEN_KEY);
+			int price =0;
+
+			String body = helper.getCustomBody(request);
+			ProductCheckRequest productCheckRequest = mapper.readValue(body, ProductCheckRequest.class);
+			List<String> sjjhProductIds = productCheckRequest.getSjjhProductId();
+			List<String> emptyList = new ArrayList<String>();
+
+			if(sjjhProductIds.size() ==1){
+				SjjhTransferReq sjjhTransferReq = new SjjhTransferReq();
+				sjjhTransferReq.setAccessId(accessId);
+				sjjhTransferReq.setSjjhProductId(sjjhProductIds.get(0));
+				Map<String,Object> customMap =productCheckRequest.getCustomBody();
+				//转换成数据交互的请求参数信息
+				Object customObject = transferParam.getCustomBody(customMap,productCheckRequest.getSjjhProductId().get(0),emptyList);
+				sjjhTransferReq.setCustomBody(customObject);
+				//设置云验平台资格校验项校验内容,用于返回结果一致性比较
+				sjjhTransferReq.setOriginCustomBody(customMap);
+				sjjhTransferReq.setToken(token);
+
+				 responseObject = helper.getOtherResult(sjjhTransferReq);
+				if(responseObject!=null){
+					price = responseObject.getPrice();
+				}
+
+			}
+
+			if(Constants.inconsistent_code.equals(responseObject.getResultCode())||Constants.consistent_code.equals(responseObject.getResultCode())){
+				request.setAttribute("result", responseObject.getResultCode());
+			}else{
+				request.setAttribute("result", Constants.error);
+			}
+			RequestContext.getCurrentContext().getRequest().setAttribute(Constants.price,price);
+		} catch (Exception ex) {
+			log.error("Exception:{}",ex);
+			responseObject.setResultCode(Constants.error);
+		}
+		try {
+			helper.responseHandleCommon(responseObject, RequestContext.getCurrentContext());
+		} catch (JsonProcessingException e) {
+			log.error("JsonProcessingException:{}",e);
+		}
+		return null;
+	}
+
+	@Override
+	public String filterType() {
+		return FilterConstants.PRE_TYPE;
+	}
+
+	@Override
+	public int filterOrder() {
+		return FilterConstants.SERVLET_30_WRAPPER_FILTER_ORDER + 4;
+	}
+}

+ 143 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/pre/WayBillFilter.java

@@ -0,0 +1,143 @@
+package info.aspirecn.iov.yysj.product.check.pre;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+import info.aspirecn.cloud.yysj.commons.lang.BillItemResult;
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
+import info.aspirecn.cloud.yysj.commons.lang.ProductCheckRequest;
+import info.aspirecn.iov.yysj.product.check.common.*;
+import info.aspirecn.iov.yysj.product.check.entity.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tomcat.util.bcel.Const;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+/**
+ * 运单信息核验服务,
+ */
+@Slf4j
+public class WayBillFilter extends ZuulFilter {
+	@Autowired
+	private ObjectMapper mapper;
+	@Autowired
+	private ZuulHelper helper;
+	@Autowired
+	private TransferParam transferParam;
+	@Autowired
+	private Property property;
+	@Override
+	public boolean shouldFilter() {
+		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
+		request.setAttribute("result", "0");
+		request.setAttribute(Constants.price,"0");
+		request.setAttribute("isCharge","0");
+
+		String url = request.getRequestURI();
+
+		return Constants.ProductCheckUrl.BILLWAYURL.getValue().equals(url);
+	}
+
+	@Override
+	public Object run() {
+		BillItemResult billItemResult = new BillItemResult();
+		String accessId = UUID.randomUUID().toString().replace("-","");
+		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
+
+
+		try {
+			//从请求头中获取token
+			String token = request.getHeader(Constants.HEADER_TOKEN_KEY);
+			int price =0;
+			String yysjTraceId = request.getHeader(Constants.HEADER_TRACEID_KEY);
+
+			String body = helper.getCustomBody(request);
+			ProductCheckRequest productCheckRequest = mapper.readValue(body, ProductCheckRequest.class);
+			List<String> sjjhProductIds = productCheckRequest.getSjjhProductId();
+			int sjjhTraceIdIndex = 0;
+			String result = "1";
+			List<String> emptyList = new ArrayList<String>();
+
+			if(sjjhProductIds.size() ==1){
+				SjjhTransferReq sjjhTransferReq = new SjjhTransferReq();
+				sjjhTransferReq.setAccessId(accessId);
+				sjjhTransferReq.setSjjhProductId(sjjhProductIds.get(0));
+				Map<String,Object> customMap =productCheckRequest.getCustomBody();
+				/*String yysjCustomStr = mapper.writeValueAsString(productCheckRequest.getCustomBody());
+				Map<String,String> customMap = mapper.readValue(yysjCustomStr,Map.class);*/
+				//转换成数据交互的请求参数信息
+				Object customObject = transferParam.getCustomBody(customMap,productCheckRequest.getSjjhProductId().get(0),emptyList);
+				sjjhTransferReq.setCustomBody(customObject);
+				//设置云验平台资格校验项校验内容,用于返回结果一致性比较
+				sjjhTransferReq.setOriginCustomBody(customMap);
+				sjjhTransferReq.setToken(token);
+				ResponseObject responseObject = helper.getResult(sjjhTransferReq,billItemResult);
+
+				price = responseObject.getPrice();
+			}else{
+
+
+				SjjhTransferReq sjjhTransferReq = new SjjhTransferReq();
+				sjjhTransferReq.setAccessId(accessId);
+				String sjjhProductId = property.getProductMap().get("qyyyxkyz_tyshdm");
+				sjjhTransferReq.setSjjhProductId(sjjhProductId);
+				sjjhTransferReq.setToken(token);
+				Map<String,Object> customMap = productCheckRequest.getCustomBody();
+				/*String yysjCustomStr = mapper.writeValueAsString(productCheckRequest.getCustomBody());
+				Map<String,String> customMap = mapper.readValue(yysjCustomStr,Map.class);*/
+				Map<String,String> customObject = transferParam.getCustomBody(customMap,sjjhProductId,emptyList);
+				sjjhTransferReq.setCustomBody(customObject);
+				sjjhTransferReq.setOriginCustomBody(customMap);
+				ResponseObject responseObject = helper.getResult(sjjhTransferReq,billItemResult);
+				 result =billItemResult.getResult();
+				price = responseObject.getPrice();
+				if(Constants.consistent_code.equals(result)){
+
+					sjjhTraceIdIndex++;
+					sjjhTransferReq.setAccessId(accessId);
+					sjjhProductId = property.getProducts().get("qyyyxkyz_jyxkzh");
+					sjjhTransferReq.setSjjhProductId(sjjhProductId);
+					sjjhTransferReq.setToken(token);
+					sjjhTransferReq.setSjjhTraceId(yysjTraceId + sjjhTraceIdIndex);
+					customMap.put("provinceCode",(String)responseObject.getResultBody());
+					customObject = transferParam.getCustomBody(customMap,sjjhProductId,emptyList);
+					sjjhTransferReq.setCustomBody(customObject);
+					sjjhTransferReq.setOriginCustomBody(customMap);
+					responseObject = helper.getResult(sjjhTransferReq,billItemResult);
+					result =responseObject.getReuslt();
+					price = price+responseObject.getPrice();
+				}
+			}
+			RequestContext.getCurrentContext().getRequest().setAttribute(Constants.price,price);
+			request.setAttribute("result", billItemResult.getResult());
+		} catch (Exception ex) {
+			log.error("Exception:{}",ex);
+			billItemResult.setResult("0");
+			BillItemResult.ErrorResponse errorResponse = new BillItemResult.ErrorResponse();
+			errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
+			billItemResult.setExceptionInformation(errorResponse);
+		}
+		try {
+			helper.responseHandle(billItemResult, RequestContext.getCurrentContext());
+		} catch (JsonProcessingException e) {
+			log.error("JsonProcessingException:{}",e);
+		}
+		log.info("money r:{}",RequestContext.getCurrentContext().getRequest().getAttribute(Constants.price));
+		return null;
+	}
+
+	@Override
+	public String filterType() {
+		return FilterConstants.PRE_TYPE;
+	}
+
+	@Override
+	public int filterOrder() {
+		return FilterConstants.SERVLET_30_WRAPPER_FILTER_ORDER + 3;
+	}
+}

+ 68 - 0
src/main/java/info/aspirecn/iov/yysj/product/check/redis/RedisConfig.java

@@ -0,0 +1,68 @@
+package info.aspirecn.iov.yysj.product.check.redis;
+
+import java.nio.charset.Charset;
+import java.util.Optional;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.script.DefaultRedisScript;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+import org.springframework.scripting.support.ResourceScriptSource;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import lombok.extern.slf4j.Slf4j;
+@Configuration
+@Slf4j
+public class RedisConfig {
+	@Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
+        RedisTemplate<String, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(connectionFactory);
+        //使用FastJsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
+        FastJsonRedisSerializer<Object> serializer = new FastJsonRedisSerializer<Object>(Object.class);
+        template.setValueSerializer(serializer);
+        template.setKeySerializer(serializer);
+        template.afterPropertiesSet();
+        return template;
+    }
+	@Bean
+    public DefaultRedisScript<Integer> getRedisScript() {
+			DefaultRedisScript<Integer> getRedisScript = new DefaultRedisScript<Integer>();
+	        getRedisScript.setResultType(Integer.class);
+	        getRedisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("config/test.lua")));
+	        return getRedisScript;
+    }
+	public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
+	    public final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+	    private Class<T> clazz;
+	 
+	    public FastJsonRedisSerializer(Class<T> clazz){
+	        super();
+	        this.clazz = clazz;
+	    }
+	 
+	    @Override
+	    public byte[] serialize(T t) throws SerializationException {
+	    	
+	        return Optional.ofNullable(t).map(r ->  {
+	        	log.debug("T:{}",t);
+	        	return JSON.toJSONString(r, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
+	        }).orElseGet(() -> new byte[0]);
+	    }
+	 
+	    @Override
+	    public T deserialize(byte[] bytes) throws SerializationException {
+	        return Optional.ofNullable(bytes)
+	                .map(t ->{ 
+	                	T result = JSON.parseObject(new String(t, DEFAULT_CHARSET), clazz);
+	                	log.debug("result:{}",result);
+	                	return result;
+	                })
+	                .orElseGet(() -> null);
+	    }
+	 
+	}
+}

+ 3 - 0
src/main/resources/config/banner.txt

@@ -0,0 +1,3 @@
+*******************************************************************************
+	 @project.artifactId@  (version:@project.version@)
+*******************************************************************************

+ 46 - 0
src/main/resources/config/bootstrap.yml

@@ -0,0 +1,46 @@
+spring:
+  application:
+    name:  cloud-yysj-product-check
+  banner:
+    location: classpath:config/banner.txt
+  sleuth:
+    sampler:
+      probability: 0.1
+      web:
+        additional-skip-pattern: /api/v2/spans
+  zipkin:
+    base-url: http://127.0.0.1:${server.port}
+  output:
+    ansi:
+      enabled: DETECT
+  http:
+    encoding:
+      force: true
+      enabled: true
+      charset: UTF-8
+  main:
+    allow-bean-definition-overriding: true
+  cloud:
+    kubernetes:
+      config:
+        sources:
+          - name: ${spring.application.name}
+            namespace: cloud-yysj
+server:
+  port: 8080
+management:
+  server:
+    port: 8081
+  endpoint:
+    restart:
+      enabled: true
+    health:
+      show-details: always
+  endpoints:
+    enabled-by-default: true
+    web:
+      exposure:
+        include: "*"
+info:
+  name: 云验平台二级网关
+  version: '@project.version@'

+ 64 - 0
src/main/resources/config/cloud-yysj-product-check.yaml

@@ -0,0 +1,64 @@
+common:
+  connetTimeOut: 3000
+  readTimeOut: 4000
+  gateWayUrl: http://iov-sjjh-gateway.iov-sjjh:8080/gateway-ct/route/route.do
+  productMap: {clxszyz: 30000074,ryjszyz: 30000075,rycyzgyz: 30000078,clyyyz: 30000079,qyyyxkyz_jyxkzh: 30000080,qyyyxkyz_tyshdm: 30000082,clrwyz: 30000081,tyrsfyz_person: 30000077,tyrsfyz_enterprise: 30000082,zhdwyz: 30000085,xhdwyz: 30000085,czyz: 30000086,sfzyz: 30000077}
+  products: {clxszyz: 30000074,ryjszyz: 30000075,qyyyxkyz_jyxkzh: 30000080,qyyyxkyz_tyshdm: 30000082}
+  errorCode: 501,502,503,504,505,506,507,510,530,531,532,535,534,536,511,-1003,533,537,538,3
+spring:
+  redis:
+      database: 0
+      host: iov-yysj-redis.cloud-yysj
+      port: 6379
+      jedis:
+        pool:
+          max-active: 8
+          max-wait: -1
+          max-idle: 8
+          min-idle: 0
+server:
+  servlet:
+    session:
+      cookie:
+        path: /
+  tomcat:
+    charset: UTF-8
+    uri-encoding: UTF-8
+    accesslog:
+      buffered: false
+      enabled: true
+      pattern: '{"DateTime":"%{yyyy-MM-dd''T''HH:mm:ss.SSSZZ}t","ClientIP":"%a","Method":"%m","URI":"%U","RequestProtocol":"%H","ResponseCode":%s
+              ,"ResponseTime":%D,"UserAgent":"%{user-agent}i","X-Forwarded-For":"%{x-forwarded-for}r","X-User-IP":"%{X-User-IP}i","traceId":"%{x-b3-traceid}i","id":"%{x-b3-spanid}i",
+              "parentId":"%{x-b3-parentspanid}i","ApplicationName":"cloud-yysj-product-check","MG-ProductId":%{yysjProductId}i,"MG-Result":%{result}r,"MG-TotalTraceId":"%{parent-traceid}i","MG-UserId":"%{userId}i","Kafka_Topics":"yysj-gateway-second","ES_Index":"yysj-gateway-second-log","AC_LogType":"AccessLog","MG-Money":%{money}r,"MG-IsCharge":%{isCharge}r
+              }'
+      prefix: yysjaccess_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}
+      directory: ${logging.path}
+logging:
+        path: /apps/var/jakarta/logs
+        level:
+          root: INFO
+          red:
+              microcloud: DEBUG
+        config: classpath:config/logback-spring.xml
+        file: ${logging.path}/catalina_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}.out
+zuul:
+  ignoredServices: '*'
+  ignored-patterns: /**/inner/**
+  addHostHeader: true
+  routes:
+    routegateway:
+      path: /detail/**
+      serviceId:  cloud-yysj-product-check
+      sensitiveHeaders: user-agent,cookie
+  base64:
+    endecode: utf-8
+
+
+cloud-yysj-servicenode-paramtransfer:
+  ribbon:
+    ConnetTimeout: 250
+    ReadTimeout: 3000
+iov-sjjh-gateway:
+  ribbon:
+    ConnetTimeout: 250
+    ReadTimeout: 3000

+ 32 - 0
src/main/resources/config/logback-spring.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+	<include resource="org/springframework/boot/logging/logback/defaults.xml" />
+	<include
+			resource="org/springframework/boot/logging/logback/console-appender.xml" />
+
+	<property name="LOG_FILE"
+			  value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}" />
+	<springProperty scope="context" name="LOG_PATH" source="logging.path" defaultValue="/apps/var/jakarta/logs" />
+	<springProperty scope="context" name="application_name" source="spring.application.name" defaultValue="iov-sjjh-servicenode-channel" />
+
+	<appender name="TIME_FILE"
+			  class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<encoder>
+			<pattern>${FILE_LOG_PATTERN}</pattern>
+		</encoder>
+		<file>${LOG_FILE}</file>
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i</fileNamePattern>
+			<maxHistory>10</maxHistory>
+			<timeBasedFileNamingAndTriggeringPolicy
+					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+				<maxFileSize>100MB</maxFileSize>
+			</timeBasedFileNamingAndTriggeringPolicy>
+		</rollingPolicy>
+	</appender>
+
+	<root level="INFO">
+		<appender-ref ref="CONSOLE" />
+		<appender-ref ref="TIME_FILE" />
+	</root>
+</configuration>