Browse Source

增加车辆历史轨迹核验接口

15810770710@163.com 3 years ago
parent
commit
92662e7934

+ 44 - 8
pom.xml

@@ -114,15 +114,51 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>
-                            <groupId>org.projectlombok</groupId>
-                            <artifactId>lombok</artifactId>
-                        </exclude>
-                    </excludes>
-                </configuration>
             </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+            </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</directory>
+                                    <filtering>true</filtering>
+                                    <includes>
+                                        <include>**</include>
+                                    </includes>
+                                </resource>
+
+                            </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+
         </plugins>
     </build>
 

+ 2 - 1
src/main/java/info/aspirecn/iov/sjjh/entity/VehicleHistoryPositionResponse.java

@@ -21,7 +21,8 @@ public class VehicleHistoryPositionResponse {
         private String longitudeDegree;
         private String latitudeDegree;
         private String speed;
-        private String directionOfVehicle;
+//        private String directionOfVehicle;
+        private String positionDescribe;
     }
 
 }

+ 12 - 14
src/main/java/info/aspirecn/iov/sjjh/service/impl/VehicleServiceImpl.java

@@ -20,6 +20,7 @@ import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -90,7 +91,6 @@ public class VehicleServiceImpl implements VehicleService {
             requestObject.setPartyFunctionCode(supplierConfig.getPartyFunctionCode());
             response = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
                     supplierConfig.getAppKey(), supplierConfig.getAppSecret(), outTime);
-            System.out.println(JSON.toJSONString(response));
         } catch (IOException e) {
             log.info("supplier-vehicle.vehicleHistoryPositionQuery-IOException:{}", e);
             ErrorUtils.captureException(e);
@@ -108,14 +108,16 @@ public class VehicleServiceImpl implements VehicleService {
     private String setVehicleHistoryPositionQueryResponse(ChannelTypeHandleResponseObject ret, Response response,
                                                           VehicleHistoryPositionRequestParam requestParam) {
         String upstreamCode = "";
+        log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseStatus:{}", response.getStatusCode());
+        log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseBody:{}", response.getBody());
         if (response.getStatusCode() == Constants.STATUS_CODE_200) {
             VehicleHistoryPositionResponse positionResponse = JSON.toJavaObject(JSON.parseObject(response.getBody()),
                     VehicleHistoryPositionResponse.class);
             upstreamCode = positionResponse.getResultCode();
             if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
                 if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
-                    boolean result = vehicleHistoryPositionQueryByBaidu(positionResponse.getData(), requestParam);
-                    if (result) {
+                    String result = vehicleHistoryPositionQueryByBaidu(positionResponse.getData(), requestParam);
+                    if (StringUtils.isBlank(result)) {
                         JSONObject vehicleLocationInfo = new JSONObject();
                         vehicleLocationInfo.put("vehicleLocationInfo", positionResponse.getData());
                         ret.setResultCode(Constant.MATCH_CODE);
@@ -123,7 +125,7 @@ public class VehicleServiceImpl implements VehicleService {
                         ret.setResultDesc(Constant.QUERY_SUCCESS);
                     } else {
                         ret.setResultCode(Constant.UN_MATCH_CODE);
-                        ret.setResultBody("核验不一致");
+                        ret.setResultBody(result);
                         ret.setResultDesc(Constant.QUERY_SUCCESS);
                     }
                 } else {
@@ -150,7 +152,7 @@ public class VehicleServiceImpl implements VehicleService {
         return upstreamCode;
     }
 
-    private boolean vehicleHistoryPositionQueryByBaidu(List<VehicleHistoryPositionResponse.Data> positionList,
+    private String vehicleHistoryPositionQueryByBaidu(List<VehicleHistoryPositionResponse.Data> positionList,
                                                     VehicleHistoryPositionRequestParam requestParam) {
         /**
          * 1、云雁调取A-到B+之间所有的车辆轨迹(每30秒有一个经纬度数据)。
@@ -195,9 +197,7 @@ public class VehicleServiceImpl implements VehicleService {
                 if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListA.get(i))
                         && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListA.get(i+1))) {
                     verificationPositionListA.add(position);
-                    if (getGeocodingCheck(3000,
-                            (position.getLatitudeDegree() + "," + position.getLongitudeDegree()),
-                            requestParam.getLoadingCountrySubdivisionCode())) {
+                    if (requestParam.getLoadingCountrySubdivisionCode().equals(position.getPositionDescribe())) {
                         checkResultA = true;
                     }
                     break;
@@ -208,7 +208,7 @@ public class VehicleServiceImpl implements VehicleService {
             }
         }
         if (!checkResultA) {
-            return false;
+            return "loadingCountrySubdivisionCode与数据源不一致";
         }
 
         boolean checkResultB = false;
@@ -219,9 +219,7 @@ public class VehicleServiceImpl implements VehicleService {
                 if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListB.get(i))
                         && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListB.get(i+1))) {
                     verificationPositionListB.add(position);
-                    if (getGeocodingCheck(3000,
-                            (position.getLatitudeDegree() + "," + position.getLongitudeDegree()),
-                            requestParam.getReceiptCountrySubdivisionCode())) {
+                    if (requestParam.getReceiptCountrySubdivisionCode().equals(position.getPositionDescribe())) {
                         checkResultB = true;
                     }
                     break;
@@ -233,9 +231,9 @@ public class VehicleServiceImpl implements VehicleService {
         }
 
         if (checkResultA && checkResultB) {
-            return true;
+            return "";
         } else {
-            return false;
+            return  "receiptCountrySubdivisionCode与数据源不一致";
         }
     }
 

+ 0 - 4
src/main/java/info/aspirecn/iov/sjjh/util/DateUtil.java

@@ -20,13 +20,11 @@ public class DateUtil {
         if (date == null) {
             return "";
         }
-        System.out.println("front:" + format.format(date)); //显示输入的日期
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);
         cal.add(Calendar.HOUR, hours);// 24小时制
         date = cal.getTime();
         String result = format.format(date);
-        System.out.println("after:" + result);  //显示更新后的日期
         return result;
     }
 
@@ -41,13 +39,11 @@ public class DateUtil {
         if (date == null) {
             return "";
         }
-        System.out.println("front:" + format.format(date)); //显示输入的日期
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);
         cal.add(Calendar.MINUTE, minutes);// 24小时制
         date = cal.getTime();
         String result = format.format(date);
-        System.out.println("after:" + result);  //显示更新后的日期
         return result;
     }
 }

+ 0 - 5
src/main/java/info/aspirecn/iov/sjjh/util/PostUtil.java

@@ -45,8 +45,6 @@ public class PostUtil {
      */
     public static Response postString(String URL, String BODY,
                                       String APP_KEY, String APP_SECRET, Integer outTime) throws Exception {
-    	System.out.println("Request:");
-    	System.out.println("Url: " + URL);
     	String PATH = URL.substring(HOST.length(), URL.length());
         Map<String, String> headers = new HashMap<String, String>();
         //(必填)根据期望的Response内容类型设置
@@ -70,9 +68,6 @@ public class PostUtil {
 
         //调用服务端
         Response response = Client.execute(request);
-        System.out.println("Body: " + BODY);
-        System.out.println("");
-        System.out.println("Response: ");
         return response;
     }
 

+ 0 - 80
src/main/resources/config/application-test.yml

@@ -1,80 +0,0 @@
-server:
-  tomcat:
-    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}r",
-                "parentId":"%{x-b3-parentspanid}i","ApplicationName":"${spring.application.name}","MG-IsCharge":%{isCharge}r,
-                "MG-ChannelId":%{channelId}i,"MG-CustomBody":"%{x-requestQuery}r","MG-ResultBody":"%{resultBody}o",
-                "MG-ResponseCode":%{respnoseCode}r,"MG-Upstream-ResponseCode":"%{upResponseCode}r","MG-SellingPrice":%{price}i,"req_type":"%{req_type}r","MG-ProductId":%{productId}i,"MG-UserId":%{userid}i}'
-      prefix: access_${HOSTNAME}_${spring.application.name}_${server.port}
-      directory: ${logging.path}
-  servlet:
-    context-path: /
-
-spring:
-  sleuth:
-    sampler:
-      probability: 1
-    web:
-      additional-skip-pattern: /api/v2/spans
-  zipkin:
-    base-url: http://127.0.0.1:${server.port}
-
-  mvc:
-    favicon:
-      enabled: false
-
-#management
-management:
-  endpoints:
-    enabled-by-default: true
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: always
-    shutdown:
-      enabled: true
-
-#logging
-logging:
-  path: /Users/jkxy/root-logs/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
-
-#error logging
-#sleuth logging
-rdc:
-  logging:
-    error-file: ${logging.path}/error_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}.log
-    sleuth-file: ${logging.path}/sleuth_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}.log
-
-#eureka
-eureka:
-  instance:
-    prefer-ip-address: true
-    instance-id: ${spring.cloud.client.ipaddress}:${server.port}
-    metadata-map:
-      management:
-        port: ${management.server.port}
-    health-check-url: http://${spring.cloud.client.ipaddress}:${management.server.port}${eureka.instance.health-check-url-path}
-    health-check-url-path: /actuator/health
-  client:
-    serviceUrl:
-      defaultZone: http://localhost:8888/eureka
-
-#custom
-supplier:
-  appKey: 3AA555152F3299F6A37C66C074DEF14D
-  appSecret: A84A975F4C324E20659CB340735DA894
-  historyPositionUrl: https://gateway.logink.cn/gps/getHistoryPosition
-  partyFunctionCode: logink
-swagger:
-  show: true

+ 0 - 84
src/main/resources/config/application.yml

@@ -1,84 +0,0 @@
-server:
-  tomcat:
-    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}r",
-                "parentId":"%{x-b3-parentspanid}i","ApplicationName":"${spring.application.name}","MG-IsCharge":%{isCharge}r,
-                "MG-ChannelId":%{channelId}i,"MG-CustomBody":"%{x-requestQuery}r","MG-ResultBody":"%{resultBody}o",
-                "MG-ResponseCode":%{respnoseCode}r,"MG-Upstream-ResponseCode":"%{upResponseCode}r","MG-SellingPrice":%{price}i,"req_type":"%{req_type}r","MG-ProductId":%{productId}i,"MG-UserId":%{userid}i}'
-      prefix: access_${HOSTNAME}_${spring.application.name}_${server.port}
-      directory: ${logging.path}
-  servlet:
-    context-path: /
-
-spring:
-  sleuth:
-    sampler:
-      probability: 1
-    web:
-      additional-skip-pattern: /api/v2/spans
-  zipkin:
-    base-url: http://127.0.0.1:${server.port}
-
-  mvc:
-    favicon:
-      enabled: false
-
-#management
-management:
-  endpoints:
-    enabled-by-default: true
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: always
-    shutdown:
-      enabled: true
-
-#logging
-logging:
-  path: /Users/jkxy/root-logs/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
-
-#error logging
-#sleuth logging
-rdc:
-  logging:
-    error-file: ${logging.path}/error_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}.log
-    sleuth-file: ${logging.path}/sleuth_${spring.cloud.client.hostname}_${spring.application.name}_${server.port}.log
-
-#eureka
-eureka:
-  instance:
-    prefer-ip-address: true
-    instance-id: ${spring.cloud.client.ipaddress}:${server.port}
-    metadata-map:
-      management:
-        port: ${management.server.port}
-    health-check-url: http://${spring.cloud.client.ipaddress}:${management.server.port}${eureka.instance.health-check-url-path}
-    health-check-url-path: /actuator/health
-  client:
-    serviceUrl:
-      defaultZone: http://localhost:8888/eureka
-
-#custom
-supplier:
-  appKey: 3AA555152F3299F6A37C66C074DEF14D
-  appSecret: A84A975F4C324E20659CB340735DA894
-  historyPositionUrl: https://gateway.logink.cn/gps/getHistoryPosition
-  partyFunctionCode: logink
-  addHours: 4
-  reduceHours: -4
-  baiduUrl: http://api.map.baidu.com/reverse_geocoding/v3/
-  baiduAk: 2cgadO5KodmKx0KBPKO0Ym3BgT0xFDPG
-swagger:
-  show: true

+ 11 - 11
src/main/resources/config/bootstrap.yml

@@ -1,18 +1,18 @@
 spring:
   application:
-    name: '@project.artifactId@'
+    name: 'iov-sjjh-servicenode-supplier-vehicle'
   banner:
     location: classpath:config/banner.txt
-#  profiles:
-#    active: test
-#  cloud:
-#    config:
-#      discovery:
-#        enabled: false
-#      uri: http://10.8.18.157:32533
-#      label: trunk
-#      name: ${spring.application.name}
-#      profile: ${spring.profiles.active}
+  profiles:
+    active: jkonline
+  cloud:
+    config:
+      discovery:
+        enabled: false
+      uri: http://iov-sjjh-config-node.iov-sjjh:8080
+      label: trunk
+      name: ${spring.application.name}
+      profile: ${spring.profiles.active}
 
 server:
   port: 25103

+ 1 - 1
src/main/resources/config/logback-spring.xml

@@ -6,7 +6,7 @@
     <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="/Users/jkxy/root-logs/apps/var/jakarta/logs"/>
+    <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="test-servicenode-supplier-2"/>
     <springProperty scope="context" name="sleuth_file" source="rdc.logging.sleuth-file" defaultValue="${LOG_PATH}/sleuth/sleuth.log"/>
     <springProperty scope="context" name="error_file" source="rdc.logging.error-file" defaultValue="${LOG_PATH}/error/error.log"/>

+ 8 - 0
src/main/resources/docker/Dockerfile

@@ -0,0 +1,8 @@
+FROM hub.i139.cn/rdc-commons/official-openjdk:8u191-jre-alpine3.9
+VOLUME /tmp
+COPY target/lib/ ./lib/
+ADD *.jar app.jar
+RUN sh -c 'touch /app.jar'
+ENV JAVA_OPTS="-Xmx256M -Xms256M -Xss256k -Duser.timezone=Asia/Shanghai"
+ENV APP_OPTS=""
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar $APP_OPTS" ]