Commit d10278e9 by 毛树良

长春华为智非项目对接优化

1 parent 664b8502
......@@ -54,7 +54,7 @@
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>*.properties</exclude>
<exclude>application.properties</exclude>
</excludes>
</configuration>
</plugin>
......
package com.viontech.tvp;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.xml.JSONXMLSerializer;
import lombok.extern.slf4j.Slf4j;
......@@ -8,6 +9,7 @@ import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
......@@ -45,23 +47,35 @@ public class ForwardService {
try {
JSONObject cast = cast(fxData);
String data = JSONXMLSerializer.toXml(cast, "Data");
data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + data;
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(tvpUrl);
Object[] res = client.invoke("InPeccancyInfo", data);
Object[] res = client.invoke("inPeccancyInfo", data);
log.info("发送消息结果:[{}]", res[0]);
} catch (Exception e) {
e.printStackTrace();
log.error("Task.run.Exception", e);
}
}
public JSONObject cast(JSONObject fxData) {
JSONObject result = new JSONObject();
result.set("DataType", "Violation");
JSONObject res = new JSONObject();
res.set("DataType", "Violation");
res.set("SFQJ", "00");
res.set("CJYH", "VION");
res.set("SJLY", "09");
String eventDt = fxData.getStr("event_dt").substring(0, 19);
if (eventDt.contains("T")) {
eventDt = eventDt.replaceAll("T", " ");
Date parse = DateUtil.parse(eventDt, "yyyy-MM-dd HH:mm:ss");
Date date = DateUtil.offsetHour(parse, 8);
eventDt = DateUtil.formatDateTime(date);
} else {
Date parse = DateUtil.parse(eventDt, "yyyy-MM-dd HH:mm:ss");
Date date = DateUtil.offsetHour(parse, 8);
eventDt = DateUtil.formatDateTime(date);
}
JSONObject eventData = fxData.getJSONObject("event_data");
JSONObject plate = eventData.getJSONObject("vehicle").getJSONObject("plate");
JSONObject illegal = eventData.getJSONObject("illegal");
......@@ -79,7 +93,7 @@ public class ForwardService {
// 违法行为
res.set("WFXW", IllegalCodeUtil.cast(illegalCode));
// 违法地点
res.set("WFDD", eventData.getJSONObject("location").getStr("name"));
res.set("WFDD", eventData.getJSONObject("location").getStr("code"));
if (overSpeed) {
// 车辆速度
res.set("CLSD", eventData.getFloat("speed"));
......@@ -94,11 +108,14 @@ public class ForwardService {
// todo 方向编号
// res.set("FXBH", "");
// 设备编号
res.set("SBBH", fxData.getStr("vchan_refid"));
// res.set("SBBH", fxData.getStr("vchan_refid"));
res.set("SBBH", eventData.getJSONObject("device").getStr("code"));
log.info("Data:{}", res.toString());
// 违法图片
String base64 = Optional.of(fxData).map(x -> x.getJSONArray("pics")).map(x -> x.getJSONObject(0)).map(x -> x.getStr("pic_base64")).orElse(null);
res.set("ZJWJ1", base64);
return res;
result.set("DataBody", res);
return result;
}
private String castPlateType(String plateType) {
......
server.port=60005
vion.tvp.url=http://IP:8080/EHL_TVPDB_WEBSERVICE/services/TvpService?wsdl
\ No newline at end of file
vion.tvp.url=http://192.168.2.36:8080/EHL_TVPDB_WEBSERVICE/services/TvpService?wsdl
\ No newline at end of file
00=00
01=01
02=02
03=03
04=04
05=05
06=06
02=10191
03=10391
04=10391
05=11171
06=13731
07=07
08=08
09=09
10=10
08=16251
09=16251
10=16251
11=11
12=12
12=10181
13=13
14=14
15=15
......@@ -18,28 +18,28 @@
17=17
18=18
19=19
20=20
20=13571
21=21
22=22
22=10191
23=23
24=24
25=25
25=11171
26=26
27=27
28=28
29=29
30=30
30=10391
31=31
32=32
33=33
36=36
36=11201
37=37
38=38
38=13621
40=40
41=41
42=42
43=43
44=44
42=16251
43=16251
44=16251
45=45
46=46
47=47
......@@ -62,8 +62,8 @@
64=64
65=65
66=66
67=67
68=68
67=11161
68=11171
69=69
70=70
71=71
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
<!-- 设置字符集 -->
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.viontech" level="debug">
<appender-ref ref="DEBUG_FILE"/>
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</configuration>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!