正在显示
19 个修改的文件
包含
1253 行增加
和
0 行删除
.gitignore
0 → 100644
1 | +HELP.md | ||
2 | +target/ | ||
3 | +!.mvn/wrapper/maven-wrapper.jar | ||
4 | +!**/src/main/** | ||
5 | +!**/src/test/** | ||
6 | + | ||
7 | +### STS ### | ||
8 | +.apt_generated | ||
9 | +.classpath | ||
10 | +.factorypath | ||
11 | +.project | ||
12 | +.settings | ||
13 | +.springBeans | ||
14 | +.sts4-cache | ||
15 | + | ||
16 | +### IntelliJ IDEA ### | ||
17 | +.idea | ||
18 | +*.iws | ||
19 | +*.iml | ||
20 | +*.ipr | ||
21 | + | ||
22 | +### NetBeans ### | ||
23 | +/nbproject/private/ | ||
24 | +/nbbuild/ | ||
25 | +/dist/ | ||
26 | +/nbdist/ | ||
27 | +/.nb-gradle/ | ||
28 | +build/ | ||
29 | + | ||
30 | +### VS Code ### | ||
31 | +.vscode/ |
ReadMe.md
0 → 100644
1 | +# 项目描述-海关新舱单、运输工具报文生成服务 | ||
2 | +* 生成XML格式的新舱单报文 和 运输工具报文 | ||
3 | +* 前端采用vue element开发框架集成 ,前端git:[git@118.31.66.166:zp260/vue_cli.git](git@118.31.66.166:zp260/vue_cli.git) | ||
4 | +* 后端采用spring boot 2 | ||
5 | +## 配置 | ||
6 | +* 配置文件为项目根目录下的config文件夹内,方便部署后的配置修改 | ||
7 | + * logback-dev.xml 为logback的配置文件 | ||
8 | + * application.yml 为spring boot的配置文件 | ||
9 | +##集成 | ||
10 | +* 集成Spring Cloud | ||
11 | +* 集成lombok,简化部分代码录入,比如实体类,方便实体及表结构修改,敏捷开发必用,使用方法见[lombok集成使用说明](https://jingyan.baidu.com/article/0a52e3f4e53ca1bf63ed725c.html) | ||
12 | +) | ||
13 | +* 集成了swagger2,开发环境开启此POM配置,生产环境记得去掉。包冲突问题看POM配置文件注释。[接口访问测试地址](http://localhost:7003/swagger-ui.html) | ||
14 | + |
config/application.yml
0 → 100644
1 | +#上传文件的路径,要带斜杠 | ||
2 | +web: | ||
3 | + upload-path: upload/ | ||
4 | +server: | ||
5 | + port: 7003 | ||
6 | + servlet: | ||
7 | + context-path: ${SERVER_CONTEXTPATH:} | ||
8 | +spring: | ||
9 | + profiles: | ||
10 | + active: dev | ||
11 | + mvc: | ||
12 | + #静态资源,设置上传文件的访问, | ||
13 | + static-path-pattern: /** | ||
14 | + | ||
15 | + resources: | ||
16 | + static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path} | ||
17 | + | ||
18 | + application: | ||
19 | + name: WLPT-MessageBuilder | ||
20 | + | ||
21 | + jackson: | ||
22 | + serialization: | ||
23 | + FAIL_ON_EMPTY_BEANS: false | ||
24 | + #springboot2.0之后会把Date类型字段自动给转成UTC字符串 如:1990-11-26T16:00:00.000+0000,如果想转成时间戳在application.properties配置文件增加以下配置 | ||
25 | + date-format: yyyy-MM-dd HH:mm:ss | ||
26 | + #时区必须要设置 | ||
27 | + time-zone: GMT+8 | ||
28 | + #ALWAYS的意思是即时属性为null,仍然也会输出这个key | ||
29 | + default-property-inclusion: always | ||
30 | + | ||
31 | + cloud: | ||
32 | + #eureka主机名,会在控制页面中显示 | ||
33 | + #DEV环境关闭注册。 | ||
34 | + features: | ||
35 | + enabled: true | ||
36 | + discovery: | ||
37 | + enabled: true | ||
38 | + service-registry: | ||
39 | + auto-registration: | ||
40 | + enabled: true | ||
41 | + datasource: | ||
42 | + type: com.alibaba.druid.pool.DruidDataSource | ||
43 | + #oracle | ||
44 | + #driver-class-name=oracle.jdbc.OracleDriver | ||
45 | + #url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW | ||
46 | + #username=CGOETL | ||
47 | + #password=1q2w3e4r | ||
48 | + #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 | ||
49 | + url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8 | ||
50 | + username: root | ||
51 | + password: | ||
52 | + driver-class-name: com.mysql.jdbc.Driver | ||
53 | + max-idle: 10 | ||
54 | + max-wait: 10000 | ||
55 | + min-idle: 5 | ||
56 | + initial-size: 5 | ||
57 | + #配置初始化大小/最小/最大 | ||
58 | + druid: | ||
59 | + initial-size: 1 | ||
60 | + min-idle: 1 | ||
61 | + max-active: 20 | ||
62 | + #获取连接等待超时时间 | ||
63 | + max-wait: 60000 | ||
64 | + #一个连接在池中最小生存的时间 | ||
65 | + min-evictable-idle-time-millis: 300000 | ||
66 | + #间隔多久进行一次检测,检测需要关闭的空闲连接 | ||
67 | + time-between-eviction-runs-millis: 60000 | ||
68 | + #mysql | ||
69 | + validation-query: SELECT 1 FROM DUAL | ||
70 | + #oracle | ||
71 | + #druid.validation-query:SELECT 'x' FROM DUAL | ||
72 | + test-while-idle: true | ||
73 | + test-on-borrow: false | ||
74 | + test-on-return: false | ||
75 | + default-auto-commit: true | ||
76 | + freemarker: | ||
77 | + template-loader-path: classpath:/templates | ||
78 | + #关闭缓存,及时刷新,上线生产环境需要修改为true | ||
79 | + cache: false | ||
80 | + charset: utf-8 | ||
81 | + check-template-location: true | ||
82 | + content-type: text/xml | ||
83 | + suffix: .ftlx | ||
84 | + | ||
85 | + | ||
86 | +eureka: | ||
87 | + instance: | ||
88 | + #eureka服务器页面中status的请求路径 | ||
89 | + status-page-url: http://${eureka.instance.hostname}:${server.port}/index | ||
90 | + prefer-ip-address: true | ||
91 | + instance-id: ${spring.cloud.client.ip-address}:${server.port} | ||
92 | + hostname: ${spring.cloud.client.ip-address} | ||
93 | + client: | ||
94 | + #eureka注册中心服务器地址 | ||
95 | + service-url: | ||
96 | + defaultZone: http://10.50.3.82:19527/eureka/ | ||
97 | + registry-fetch-interval-seconds: 30 | ||
98 | + lease-renewal-interval-in-seconds: 15 | ||
99 | + lease-expiration-duration-in-seconds: 45 | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | +mybatis: | ||
104 | + mapper-locations: classpath:mapping/*.xml | ||
105 | + type-aliases-package: com.tianbo.warehouse.model | ||
106 | +pagehelper: | ||
107 | + #auto-dialect: true | ||
108 | + #auto-runtime-dialect: true | ||
109 | + helper-dialect: mysql | ||
110 | + reasonable: true | ||
111 | + support-methods-arguments: true | ||
112 | + params: count=countSql | ||
113 | + | ||
114 | +#debug配置,debug或者为true的时候,logback才会记录和写入日志文件 | ||
115 | +trace: false | ||
116 | +debug: true | ||
117 | + | ||
118 | +logging: | ||
119 | + file: | ||
120 | + path: ./logs/ | ||
121 | + name: system.log | ||
122 | + config: config/logback-dev.xml | ||
123 | + #转移到logback配置文件中 | ||
124 | + #level: | ||
125 | + #org.apache.tomcat: info | ||
126 | + #com.tianbo.warehouse.dao: DEBUG | ||
127 | + #org.springframework.security: trace | ||
128 | + #日志配置,输出到文本, | ||
129 | +#Java Web Token 时效时间,单位秒 | ||
130 | +jwt: | ||
131 | + max-alive: 300 | ||
132 | +custom: | ||
133 | + send-path: ./send/ | ||
134 | +tcs: | ||
135 | + mq-number: DXPENT0000460002 |
config/logback-dev.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!--参考文档链接:https://blog.csdn.net/qq_34912478/article/details/80877132--> | ||
3 | +<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 --> | ||
4 | +<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true --> | ||
5 | +<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 --> | ||
6 | +<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 --> | ||
7 | +<configuration scan="true" scanPeriod="10 seconds"> | ||
8 | + | ||
9 | + <!--<include resource="org/springframework/boot/logging/logback/base.xml" />--> | ||
10 | + | ||
11 | + <contextName>logback</contextName> | ||
12 | + <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 --> | ||
13 | + <property name="log.path" value="./logs" /> | ||
14 | + | ||
15 | + <!-- 彩色日志 --> | ||
16 | + <!-- 彩色日志依赖的渲染类 --> | ||
17 | + <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" /> | ||
18 | + <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" /> | ||
19 | + <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" /> | ||
20 | + <!-- 彩色日志格式 --> | ||
21 | + <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> | ||
22 | + | ||
23 | + | ||
24 | + <!--输出到控制台--> | ||
25 | + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
26 | + <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> | ||
27 | + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
28 | + <level>INFO</level> | ||
29 | + </filter> | ||
30 | + <encoder> | ||
31 | + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern> | ||
32 | + <!-- 设置字符集 --> | ||
33 | + <charset>UTF-8</charset> | ||
34 | + </encoder> | ||
35 | + </appender> | ||
36 | + | ||
37 | + | ||
38 | + <!--输出到文件--> | ||
39 | + | ||
40 | + <!-- 时间滚动输出 level为 DEBUG 日志 --> | ||
41 | + <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
42 | + <!-- 正在记录的日志文件的路径及文件名 --> | ||
43 | + <file>${log.path}/log_debug.log</file> | ||
44 | + <!--日志文件输出格式--> | ||
45 | + <encoder> | ||
46 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> | ||
47 | + <charset>UTF-8</charset> <!-- 设置字符集 --> | ||
48 | + </encoder> | ||
49 | + <!-- 日志记录器的滚动策略,按日期,按大小记录 --> | ||
50 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
51 | + <!-- 日志归档 --> | ||
52 | + <fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
53 | + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
54 | + <maxFileSize>100MB</maxFileSize> | ||
55 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
56 | + <!--日志文件保留天数--> | ||
57 | + <maxHistory>15</maxHistory> | ||
58 | + </rollingPolicy> | ||
59 | + <!-- 此日志文件只记录debug级别的 --> | ||
60 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
61 | + <level>debug</level> | ||
62 | + <onMatch>ACCEPT</onMatch> | ||
63 | + <onMismatch>DENY</onMismatch> | ||
64 | + </filter> | ||
65 | + </appender> | ||
66 | + | ||
67 | + <!-- 时间滚动输出 level为 INFO 日志 --> | ||
68 | + <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
69 | + <!-- 正在记录的日志文件的路径及文件名 --> | ||
70 | + <file>${log.path}/log_info.log</file> | ||
71 | + <!--日志文件输出格式--> | ||
72 | + <encoder> | ||
73 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> | ||
74 | + <charset>UTF-8</charset> | ||
75 | + </encoder> | ||
76 | + <!-- 日志记录器的滚动策略,按日期,按大小记录 --> | ||
77 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
78 | + <!-- 每天日志归档路径以及格式 --> | ||
79 | + <fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
80 | + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
81 | + <maxFileSize>100MB</maxFileSize> | ||
82 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
83 | + <!--日志文件保留天数--> | ||
84 | + <maxHistory>15</maxHistory> | ||
85 | + </rollingPolicy> | ||
86 | + <!-- 此日志文件只记录info级别的 --> | ||
87 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
88 | + <level>info</level> | ||
89 | + <onMatch>ACCEPT</onMatch> | ||
90 | + <onMismatch>DENY</onMismatch> | ||
91 | + </filter> | ||
92 | + </appender> | ||
93 | + | ||
94 | + <!-- 时间滚动输出 level为 WARN 日志 --> | ||
95 | + <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
96 | + <!-- 正在记录的日志文件的路径及文件名 --> | ||
97 | + <file>${log.path}/log_warn.log</file> | ||
98 | + <!--日志文件输出格式--> | ||
99 | + <encoder> | ||
100 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> | ||
101 | + <charset>UTF-8</charset> <!-- 此处设置字符集 --> | ||
102 | + </encoder> | ||
103 | + <!-- 日志记录器的滚动策略,按日期,按大小记录 --> | ||
104 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
105 | + <fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
106 | + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
107 | + <maxFileSize>100MB</maxFileSize> | ||
108 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
109 | + <!--日志文件保留天数--> | ||
110 | + <maxHistory>15</maxHistory> | ||
111 | + </rollingPolicy> | ||
112 | + <!-- 此日志文件只记录warn级别的 --> | ||
113 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
114 | + <level>warn</level> | ||
115 | + <onMatch>ACCEPT</onMatch> | ||
116 | + <onMismatch>DENY</onMismatch> | ||
117 | + </filter> | ||
118 | + </appender> | ||
119 | + | ||
120 | + | ||
121 | + <!-- 时间滚动输出 level为 ERROR 日志 --> | ||
122 | + <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
123 | + <!-- 正在记录的日志文件的路径及文件名 --> | ||
124 | + <file>${log.path}/log_error.log</file> | ||
125 | + <!--日志文件输出格式--> | ||
126 | + <encoder> | ||
127 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> | ||
128 | + <charset>UTF-8</charset> <!-- 此处设置字符集 --> | ||
129 | + </encoder> | ||
130 | + <!-- 日志记录器的滚动策略,按日期,按大小记录 --> | ||
131 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
132 | + <fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
133 | + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
134 | + <maxFileSize>100MB</maxFileSize> | ||
135 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
136 | + <!--日志文件保留天数--> | ||
137 | + <maxHistory>15</maxHistory> | ||
138 | + </rollingPolicy> | ||
139 | + <!-- 此日志文件只记录ERROR级别的 --> | ||
140 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
141 | + <level>ERROR</level> | ||
142 | + <onMatch>ACCEPT</onMatch> | ||
143 | + <onMismatch>DENY</onMismatch> | ||
144 | + </filter> | ||
145 | + </appender> | ||
146 | + | ||
147 | + <!-- | ||
148 | + <logger>用来设置某一个包或者具体的某一个类的日志打印级别、 | ||
149 | + 以及指定<appender>。<logger>仅有一个name属性, | ||
150 | + 一个可选的level和一个可选的addtivity属性。 | ||
151 | + name:用来指定受此logger约束的某一个包或者具体的某一个类。 | ||
152 | + level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF, | ||
153 | + 还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。 | ||
154 | + 如果未设置此属性,那么当前logger将会继承上级的级别。 | ||
155 | + addtivity:是否向上级logger传递打印信息。默认是true。 | ||
156 | + --> | ||
157 | + <!--<logger name="org.springframework.web" level="info"/>--> | ||
158 | + <!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>--> | ||
159 | + <!-- | ||
160 | + 使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作: | ||
161 | + 第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息 | ||
162 | + 第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别: | ||
163 | + --> | ||
164 | + | ||
165 | + | ||
166 | + <!-- | ||
167 | + root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性 | ||
168 | + level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF, | ||
169 | + 不能设置为INHERITED或者同义词NULL。默认是DEBUG | ||
170 | + 可以包含零个或多个元素,标识这个appender将会添加到这个logger。 | ||
171 | + --> | ||
172 | + | ||
173 | + <!--开发环境:打印控制台--> | ||
174 | + <springProfile name="dev"> | ||
175 | + <logger name="org.springframework.security" level="trace"/> | ||
176 | + <logger name="org.apache.tomcat" level="info" /> | ||
177 | + <logger name="com.tianbo.warehouse.dao" level="DEBUG" /> | ||
178 | + <root level="INFO"> | ||
179 | + <appender-ref ref="CONSOLE" /> | ||
180 | + <!--<appender-ref ref="DEBUG_FILE" />--> | ||
181 | + <!--<appender-ref ref="INFO_FILE" />--> | ||
182 | + <!--<appender-ref ref="WARN_FILE" />--> | ||
183 | + <appender-ref ref="ERROR_FILE" /> | ||
184 | + </root> | ||
185 | + </springProfile> | ||
186 | + | ||
187 | + <!--生产环境:输出到文件--> | ||
188 | + <springProfile name="pro"> | ||
189 | + <root level="info"> | ||
190 | + <appender-ref ref="CONSOLE" /> | ||
191 | + <appender-ref ref="DEBUG_FILE" /> | ||
192 | + <appender-ref ref="INFO_FILE" /> | ||
193 | + <appender-ref ref="ERROR_FILE" /> | ||
194 | + <appender-ref ref="WARN_FILE" /> | ||
195 | + </root> | ||
196 | + </springProfile> | ||
197 | + | ||
198 | +</configuration> |
pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + <parent> | ||
6 | + <groupId>org.springframework.boot</groupId> | ||
7 | + <artifactId>spring-boot-starter-parent</artifactId> | ||
8 | + <version>2.2.0.M6</version> | ||
9 | + <relativePath/> <!-- lookup parent from repository --> | ||
10 | + </parent> | ||
11 | + <groupId>com.sunyo.wlpt.message</groupId> | ||
12 | + <artifactId>builder</artifactId> | ||
13 | + <version>0.0.1-SNAPSHOT</version> | ||
14 | + <name>builder</name> | ||
15 | + <description>海关报文生成</description> | ||
16 | + | ||
17 | + <properties> | ||
18 | + <java.version>1.8</java.version> | ||
19 | + <spring-cloud.version>Hoxton.M2</spring-cloud.version> | ||
20 | + <swagger2_version>2.9.2</swagger2_version> | ||
21 | + </properties> | ||
22 | + | ||
23 | + <dependencies> | ||
24 | + <dependency> | ||
25 | + <groupId>org.springframework.boot</groupId> | ||
26 | + <artifactId>spring-boot-starter-freemarker</artifactId> | ||
27 | + </dependency> | ||
28 | + <dependency> | ||
29 | + <groupId>org.springframework.boot</groupId> | ||
30 | + <artifactId>spring-boot-starter-web</artifactId> | ||
31 | + </dependency> | ||
32 | + <dependency> | ||
33 | + <groupId>org.springframework.cloud</groupId> | ||
34 | + <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> | ||
35 | + </dependency> | ||
36 | + <dependency> | ||
37 | + <groupId>org.springframework.cloud</groupId> | ||
38 | + <artifactId>spring-cloud-starter-openfeign</artifactId> | ||
39 | + </dependency> | ||
40 | + | ||
41 | + <dependency> | ||
42 | + <groupId>org.projectlombok</groupId> | ||
43 | + <artifactId>lombok</artifactId> | ||
44 | + <optional>true</optional> | ||
45 | + </dependency> | ||
46 | + <!--集成swagger2,下面两个spring的配置解决springboot包 与swagger2的包冲突问题,生产部署的时候记得要去掉此swagger2的配置,开发环境开启--> | ||
47 | + <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> | ||
48 | + <dependency> | ||
49 | + <groupId>org.springframework.plugin</groupId> | ||
50 | + <artifactId>spring-plugin-core</artifactId> | ||
51 | + <version>1.2.0.RELEASE</version><!--$NO-MVN-MAN-VER$--> | ||
52 | + </dependency> | ||
53 | + <dependency> | ||
54 | + <groupId>org.springframework.plugin</groupId> | ||
55 | + <artifactId>spring-plugin-metadata</artifactId> | ||
56 | + <version>1.2.0.RELEASE</version><!--$NO-MVN-MAN-VER$--> | ||
57 | + </dependency> | ||
58 | + <dependency> | ||
59 | + <groupId>org.springframework.boot</groupId> | ||
60 | + <artifactId>spring-boot-starter-test</artifactId> | ||
61 | + <scope>test</scope> | ||
62 | + <exclusions> | ||
63 | + <exclusion> | ||
64 | + <groupId>org.junit.vintage</groupId> | ||
65 | + <artifactId>junit-vintage-engine</artifactId> | ||
66 | + </exclusion> | ||
67 | + </exclusions> | ||
68 | + </dependency> | ||
69 | + <dependency> | ||
70 | + <groupId>io.springfox</groupId> | ||
71 | + <artifactId>springfox-swagger-ui</artifactId> | ||
72 | + <version>${swagger2_version}</version> | ||
73 | + <exclusions> | ||
74 | + <exclusion> | ||
75 | + <groupId>org.springframework.plugin</groupId> | ||
76 | + <artifactId>spring-plugin-core</artifactId> | ||
77 | + </exclusion> | ||
78 | + <exclusion> | ||
79 | + <groupId>org.springframework.plugin</groupId> | ||
80 | + <artifactId>spring-plugin-metadata</artifactId> | ||
81 | + </exclusion> | ||
82 | + </exclusions> | ||
83 | + </dependency> | ||
84 | + <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> | ||
85 | + <dependency> | ||
86 | + <groupId>io.springfox</groupId> | ||
87 | + <artifactId>springfox-swagger2</artifactId> | ||
88 | + <version>${swagger2_version}</version> | ||
89 | + <!--2.9.2集成的是M1的这两个包,跟现在用的Greenwich.BUILD-SNAPSHOT的版本的SPRING boot2的版本包有冲突。去掉--> | ||
90 | + <exclusions> | ||
91 | + <exclusion> | ||
92 | + <groupId>org.springframework.plugin</groupId> | ||
93 | + <artifactId>spring-plugin-core</artifactId> | ||
94 | + </exclusion> | ||
95 | + <exclusion> | ||
96 | + <groupId>org.springframework.plugin</groupId> | ||
97 | + <artifactId>spring-plugin-metadata</artifactId> | ||
98 | + </exclusion> | ||
99 | + </exclusions> | ||
100 | + </dependency> | ||
101 | + <dependency> | ||
102 | + <groupId>com.tianbo</groupId> | ||
103 | + <artifactId>util</artifactId> | ||
104 | + <version>1.0-SNAPSHOT</version> | ||
105 | + </dependency> | ||
106 | + <dependency> | ||
107 | + <groupId>com.sunyo.wlpt</groupId> | ||
108 | + <artifactId>base</artifactId> | ||
109 | + <version>1.0-SNAPSHOT</version> | ||
110 | + </dependency> | ||
111 | + </dependencies> | ||
112 | + | ||
113 | + <dependencyManagement> | ||
114 | + <dependencies> | ||
115 | + <dependency> | ||
116 | + <groupId>org.springframework.cloud</groupId> | ||
117 | + <artifactId>spring-cloud-dependencies</artifactId> | ||
118 | + <version>${spring-cloud.version}</version> | ||
119 | + <type>pom</type> | ||
120 | + <scope>import</scope> | ||
121 | + </dependency> | ||
122 | + </dependencies> | ||
123 | + </dependencyManagement> | ||
124 | + | ||
125 | + <build> | ||
126 | + <plugins> | ||
127 | + <plugin> | ||
128 | + <groupId>org.springframework.boot</groupId> | ||
129 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
130 | + </plugin> | ||
131 | + <plugin> | ||
132 | + <groupId>org.springframework.boot</groupId> | ||
133 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
134 | + <configuration> | ||
135 | + <includeSystemScope>true</includeSystemScope> | ||
136 | + </configuration> | ||
137 | + </plugin> | ||
138 | + <!-- mybatis generator 自动生成代码插件 --> | ||
139 | + <plugin> | ||
140 | + <groupId>org.mybatis.generator</groupId> | ||
141 | + <artifactId>mybatis-generator-maven-plugin</artifactId> | ||
142 | + <version>1.3.2</version> | ||
143 | + <configuration> | ||
144 | + <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile> | ||
145 | + <overwrite>true</overwrite> | ||
146 | + <verbose>true</verbose> | ||
147 | + </configuration> | ||
148 | + </plugin> | ||
149 | + </plugins> | ||
150 | + </build> | ||
151 | + | ||
152 | + <repositories> | ||
153 | + <repository> | ||
154 | + <id>spring-milestones</id> | ||
155 | + <name>Spring Milestones</name> | ||
156 | + <url>https://repo.spring.io/milestone</url> | ||
157 | + </repository> | ||
158 | + </repositories> | ||
159 | + <pluginRepositories> | ||
160 | + <pluginRepository> | ||
161 | + <id>spring-milestones</id> | ||
162 | + <name>Spring Milestones</name> | ||
163 | + <url>https://repo.spring.io/milestone</url> | ||
164 | + </pluginRepository> | ||
165 | + </pluginRepositories> | ||
166 | + | ||
167 | +</project> |
1 | +package com.sunyo.wlpt.message.builder; | ||
2 | + | ||
3 | +import org.springframework.boot.SpringApplication; | ||
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
5 | +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
6 | + | ||
7 | +@SpringBootApplication | ||
8 | +@EnableDiscoveryClient | ||
9 | +public class BuilderApplication { | ||
10 | + | ||
11 | + public static void main(String[] args) { | ||
12 | + SpringApplication.run(BuilderApplication.class, args); | ||
13 | + } | ||
14 | + | ||
15 | +} |
1 | +package com.sunyo.wlpt.message.builder; | ||
2 | + | ||
3 | +import org.springframework.context.annotation.Bean; | ||
4 | +import org.springframework.context.annotation.Configuration; | ||
5 | +import springfox.documentation.builders.ApiInfoBuilder; | ||
6 | +import springfox.documentation.builders.PathSelectors; | ||
7 | +import springfox.documentation.builders.RequestHandlerSelectors; | ||
8 | +import springfox.documentation.service.ApiInfo; | ||
9 | +import springfox.documentation.service.Contact; | ||
10 | +import springfox.documentation.spi.DocumentationType; | ||
11 | +import springfox.documentation.spring.web.plugins.Docket; | ||
12 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
13 | + | ||
14 | +@Configuration | ||
15 | +@EnableSwagger2 | ||
16 | +public class Swagger2 { | ||
17 | + //swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 | ||
18 | + @Bean | ||
19 | + public Docket createRestApi() { | ||
20 | + return new Docket(DocumentationType.SWAGGER_2) | ||
21 | + .apiInfo(apiInfo()) | ||
22 | + .select() | ||
23 | + //为当前包路径 | ||
24 | + .apis(RequestHandlerSelectors.basePackage("com.sunyo.wlpt.message.builder.controller")) | ||
25 | + .paths(PathSelectors.any()) | ||
26 | + .build(); | ||
27 | + } | ||
28 | + //构建 api文档的详细信息函数,注意这里的注解引用的是哪个 | ||
29 | + private ApiInfo apiInfo() { | ||
30 | + return new ApiInfoBuilder() | ||
31 | + //页面标题 | ||
32 | + .title("海关报文生成服务") | ||
33 | + //创建人 | ||
34 | + .contact(new Contact("mrz", "http://www.baidu.com", "17966059@qq.com")) | ||
35 | + //版本号 | ||
36 | + .version("1.0") | ||
37 | + //描述 | ||
38 | + .description("API 描述") | ||
39 | + .build(); | ||
40 | + } | ||
41 | + | ||
42 | + | ||
43 | +} |
1 | +package com.sunyo.wlpt.message.builder.controller; | ||
2 | + | ||
3 | +import org.springframework.web.bind.annotation.GetMapping; | ||
4 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
5 | +import org.springframework.web.bind.annotation.RestController; | ||
6 | + | ||
7 | + | ||
8 | +@RestController | ||
9 | +@RequestMapping(value = "/") | ||
10 | +public class IndexController { | ||
11 | + | ||
12 | + @GetMapping("index") | ||
13 | + public String index(){ | ||
14 | + return "11"; | ||
15 | +// return "数据仓库接收,落地报文给新舱单"; | ||
16 | + } | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | +} |
1 | +package com.sunyo.wlpt.message.builder.controller; | ||
2 | + | ||
3 | +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; | ||
4 | +import freemarker.template.Configuration; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.web.bind.annotation.RequestBody; | ||
7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
8 | +import org.springframework.web.bind.annotation.RestController; | ||
9 | + | ||
10 | +import java.util.Map; | ||
11 | + | ||
12 | +@RestController | ||
13 | +@RequestMapping("/mt1201") | ||
14 | +public class MT1201Controller extends CustomXmlMaker { | ||
15 | + | ||
16 | + private static String businessType = "MT1201"; | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private Configuration freemakerTemplate; | ||
20 | + | ||
21 | + @RequestMapping("/send") | ||
22 | + public Boolean mt1201New(@RequestBody Map awb_manifest) throws Exception{ | ||
23 | + | ||
24 | + } | ||
25 | +} |
1 | +package com.sunyo.wlpt.message.builder.controller; | ||
2 | + | ||
3 | +import com.sunyo.wlpt.message.builder.model.CUSTOM_RESPONSE; | ||
4 | +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; | ||
5 | +import freemarker.template.Configuration; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.web.bind.annotation.RequestBody; | ||
8 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
9 | +import org.springframework.web.bind.annotation.RestController; | ||
10 | + | ||
11 | +import java.util.Date; | ||
12 | +import java.util.Map; | ||
13 | + | ||
14 | +@RestController | ||
15 | +@RequestMapping("/mt2201") | ||
16 | +public class MT2201Controller extends CustomXmlMaker { | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private Configuration freemakerTemplate; | ||
20 | + | ||
21 | + private static String businessType = "MT2201"; | ||
22 | + | ||
23 | + /** | ||
24 | + * MAP包含运单实体与舱单实体 | ||
25 | + * @param awb_manifest {awb:AWB_AWBINFO,man:} | ||
26 | + * @return | ||
27 | + * @throws Exception | ||
28 | + */ | ||
29 | + @RequestMapping("/send") | ||
30 | + public Boolean mt1201New(@RequestBody Map awb_manifest) throws Exception{ | ||
31 | + try { | ||
32 | + CUSTOM_RESPONSE response = new CUSTOM_RESPONSE(); | ||
33 | + response.setAwbano("17212345678"); | ||
34 | + response.setCusfunctioncode("2"); | ||
35 | + | ||
36 | + response.setCusreciverid("4604"); | ||
37 | + response.setCusversion("1.2"); | ||
38 | + response.setBusdate(new Date()); | ||
39 | + response.setBustype(businessType); | ||
40 | + | ||
41 | + String msgId = makeMsgID(businessType,"460470678920X","17212345678"); | ||
42 | + response.setCusmsgid(msgId); | ||
43 | + response.setCussenderid(makeSenderID("4604","460470678920X")); | ||
44 | + | ||
45 | + String filename = response.getCusmsgid()+".xml"; | ||
46 | + makeXmlToFile("/manifest/MT2201.ftlx",filename,awb_manifest); | ||
47 | + }catch (Exception e){ | ||
48 | + e.printStackTrace(); | ||
49 | + return false; | ||
50 | + } | ||
51 | + return true; | ||
52 | + } | ||
53 | +} |
1 | +package com.sunyo.wlpt.message.builder.model; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | + | ||
5 | +public class CUSTOM_RESPONSE { | ||
6 | + private String id; | ||
7 | + | ||
8 | + private Date flightdate; | ||
9 | + | ||
10 | + private String flightno; | ||
11 | + | ||
12 | + private String carrier; | ||
13 | + | ||
14 | + private String awbano; | ||
15 | + | ||
16 | + private String awbhno; | ||
17 | + | ||
18 | + private String bustype; | ||
19 | + | ||
20 | + private Date busdate; | ||
21 | + | ||
22 | + private Long busweight; | ||
23 | + | ||
24 | + private Integer buspiece; | ||
25 | + | ||
26 | + private String opertype; | ||
27 | + | ||
28 | + private String cusmsgid; | ||
29 | + | ||
30 | + private String cussenderid; | ||
31 | + | ||
32 | + private String cusreciverid; | ||
33 | + | ||
34 | + private String cusversion; | ||
35 | + | ||
36 | + private String cusfunctioncode; | ||
37 | + | ||
38 | + private Date cusresrcvtime; | ||
39 | + | ||
40 | + private Date cusressendtime; | ||
41 | + | ||
42 | + private String cusrescode; | ||
43 | + | ||
44 | + private String cusresstatus; | ||
45 | + | ||
46 | + private String operusername; | ||
47 | + | ||
48 | + private String opersystemname; | ||
49 | + | ||
50 | + private String cusrestext; | ||
51 | + | ||
52 | + public String getId() { | ||
53 | + return id; | ||
54 | + } | ||
55 | + | ||
56 | + public void setId(String id) { | ||
57 | + this.id = id == null ? null : id.trim(); | ||
58 | + } | ||
59 | + | ||
60 | + public Date getFlightdate() { | ||
61 | + return flightdate; | ||
62 | + } | ||
63 | + | ||
64 | + public void setFlightdate(Date flightdate) { | ||
65 | + this.flightdate = flightdate; | ||
66 | + } | ||
67 | + | ||
68 | + public String getFlightno() { | ||
69 | + return flightno; | ||
70 | + } | ||
71 | + | ||
72 | + public void setFlightno(String flightno) { | ||
73 | + this.flightno = flightno == null ? null : flightno.trim(); | ||
74 | + } | ||
75 | + | ||
76 | + public String getCarrier() { | ||
77 | + return carrier; | ||
78 | + } | ||
79 | + | ||
80 | + public void setCarrier(String carrier) { | ||
81 | + this.carrier = carrier == null ? null : carrier.trim(); | ||
82 | + } | ||
83 | + | ||
84 | + public String getAwbano() { | ||
85 | + return awbano; | ||
86 | + } | ||
87 | + | ||
88 | + public void setAwbano(String awbano) { | ||
89 | + this.awbano = awbano == null ? null : awbano.trim(); | ||
90 | + } | ||
91 | + | ||
92 | + public String getAwbhno() { | ||
93 | + return awbhno; | ||
94 | + } | ||
95 | + | ||
96 | + public void setAwbhno(String awbhno) { | ||
97 | + this.awbhno = awbhno == null ? null : awbhno.trim(); | ||
98 | + } | ||
99 | + | ||
100 | + public String getBustype() { | ||
101 | + return bustype; | ||
102 | + } | ||
103 | + | ||
104 | + public void setBustype(String bustype) { | ||
105 | + this.bustype = bustype == null ? null : bustype.trim(); | ||
106 | + } | ||
107 | + | ||
108 | + public Date getBusdate() { | ||
109 | + return busdate; | ||
110 | + } | ||
111 | + | ||
112 | + public void setBusdate(Date busdate) { | ||
113 | + this.busdate = busdate; | ||
114 | + } | ||
115 | + | ||
116 | + public Long getBusweight() { | ||
117 | + return busweight; | ||
118 | + } | ||
119 | + | ||
120 | + public void setBusweight(Long busweight) { | ||
121 | + this.busweight = busweight; | ||
122 | + } | ||
123 | + | ||
124 | + public Integer getBuspiece() { | ||
125 | + return buspiece; | ||
126 | + } | ||
127 | + | ||
128 | + public void setBuspiece(Integer buspiece) { | ||
129 | + this.buspiece = buspiece; | ||
130 | + } | ||
131 | + | ||
132 | + public String getOpertype() { | ||
133 | + return opertype; | ||
134 | + } | ||
135 | + | ||
136 | + public void setOpertype(String opertype) { | ||
137 | + this.opertype = opertype == null ? null : opertype.trim(); | ||
138 | + } | ||
139 | + | ||
140 | + public String getCusmsgid() { | ||
141 | + return cusmsgid; | ||
142 | + } | ||
143 | + | ||
144 | + public void setCusmsgid(String cusmsgid) { | ||
145 | + this.cusmsgid = cusmsgid == null ? null : cusmsgid.trim(); | ||
146 | + } | ||
147 | + | ||
148 | + public String getCussenderid() { | ||
149 | + return cussenderid; | ||
150 | + } | ||
151 | + | ||
152 | + public void setCussenderid(String cussenderid) { | ||
153 | + this.cussenderid = cussenderid == null ? null : cussenderid.trim(); | ||
154 | + } | ||
155 | + | ||
156 | + public String getCusreciverid() { | ||
157 | + return cusreciverid; | ||
158 | + } | ||
159 | + | ||
160 | + public void setCusreciverid(String cusreciverid) { | ||
161 | + this.cusreciverid = cusreciverid == null ? null : cusreciverid.trim(); | ||
162 | + } | ||
163 | + | ||
164 | + public String getCusversion() { | ||
165 | + return cusversion; | ||
166 | + } | ||
167 | + | ||
168 | + public void setCusversion(String cusversion) { | ||
169 | + this.cusversion = cusversion == null ? null : cusversion.trim(); | ||
170 | + } | ||
171 | + | ||
172 | + public String getCusfunctioncode() { | ||
173 | + return cusfunctioncode; | ||
174 | + } | ||
175 | + | ||
176 | + public void setCusfunctioncode(String cusfunctioncode) { | ||
177 | + this.cusfunctioncode = cusfunctioncode == null ? null : cusfunctioncode.trim(); | ||
178 | + } | ||
179 | + | ||
180 | + public Date getCusresrcvtime() { | ||
181 | + return cusresrcvtime; | ||
182 | + } | ||
183 | + | ||
184 | + public void setCusresrcvtime(Date cusresrcvtime) { | ||
185 | + this.cusresrcvtime = cusresrcvtime; | ||
186 | + } | ||
187 | + | ||
188 | + public Date getCusressendtime() { | ||
189 | + return cusressendtime; | ||
190 | + } | ||
191 | + | ||
192 | + public void setCusressendtime(Date cusressendtime) { | ||
193 | + this.cusressendtime = cusressendtime; | ||
194 | + } | ||
195 | + | ||
196 | + public String getCusrescode() { | ||
197 | + return cusrescode; | ||
198 | + } | ||
199 | + | ||
200 | + public void setCusrescode(String cusrescode) { | ||
201 | + this.cusrescode = cusrescode == null ? null : cusrescode.trim(); | ||
202 | + } | ||
203 | + | ||
204 | + public String getCusresstatus() { | ||
205 | + return cusresstatus; | ||
206 | + } | ||
207 | + | ||
208 | + public void setCusresstatus(String cusresstatus) { | ||
209 | + this.cusresstatus = cusresstatus == null ? null : cusresstatus.trim(); | ||
210 | + } | ||
211 | + | ||
212 | + public String getOperusername() { | ||
213 | + return operusername; | ||
214 | + } | ||
215 | + | ||
216 | + public void setOperusername(String operusername) { | ||
217 | + this.operusername = operusername == null ? null : operusername.trim(); | ||
218 | + } | ||
219 | + | ||
220 | + public String getOpersystemname() { | ||
221 | + return opersystemname; | ||
222 | + } | ||
223 | + | ||
224 | + public void setOpersystemname(String opersystemname) { | ||
225 | + this.opersystemname = opersystemname == null ? null : opersystemname.trim(); | ||
226 | + } | ||
227 | + | ||
228 | + public String getCusrestext() { | ||
229 | + return cusrestext; | ||
230 | + } | ||
231 | + | ||
232 | + public void setCusrestext(String cusrestext) { | ||
233 | + this.cusrestext = cusrestext == null ? null : cusrestext.trim(); | ||
234 | + } | ||
235 | +} |
此 diff 太大无法显示。
1 | +package com.sunyo.wlpt.message.builder.service.imp; | ||
2 | + | ||
3 | +import com.sunyo.wlpt.base.model.AWB_AWBINFO; | ||
4 | +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_MT1201; | ||
5 | +import com.sunyo.wlpt.base.model.NMMS_CUSTOM_RESPONSE; | ||
6 | +import com.sunyo.wlpt.message.builder.model.CUSTOM_RESPONSE; | ||
7 | +import com.sunyo.wlpt.message.builder.service.MakeXml1201Service; | ||
8 | +import com.sunyo.wlpt.message.builder.util.CustomXmlMaker; | ||
9 | +import freemarker.template.Configuration; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.web.bind.annotation.RequestBody; | ||
12 | + | ||
13 | +import java.util.Date; | ||
14 | +import java.util.HashMap; | ||
15 | +import java.util.Map; | ||
16 | + | ||
17 | +public class MakeXml1201ServiceImp extends CustomXmlMaker implements MakeXml1201Service { | ||
18 | + | ||
19 | + private static String businessType = "MT1201"; | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private Configuration freemakerTemplate; | ||
23 | + | ||
24 | + | ||
25 | + /** | ||
26 | + * MAP包含运单实体与舱单实体 | ||
27 | + * @param awb_manifest {awb:AWB_AWBINFO,man:NMMS_CUSTOM_MT1201} | ||
28 | + * @return | ||
29 | + * @throws Exception | ||
30 | + */ | ||
31 | + @Override | ||
32 | + public boolean makeXml1201_new(@RequestBody Map awb_manifest) throws Exception{ | ||
33 | + try { | ||
34 | + NMMS_CUSTOM_MT1201 mt1201 = new NMMS_CUSTOM_MT1201(); | ||
35 | + AWB_AWBINFO awb = new AWB_AWBINFO(); | ||
36 | + NMMS_CUSTOM_RESPONSE customResponse = new NMMS_CUSTOM_RESPONSE(); | ||
37 | + Map<String,Object> xmlmap = new HashMap<>(); | ||
38 | + xmlmap.put("awb",awb); | ||
39 | + xmlmap.put("man",mt1201); | ||
40 | + xmlmap.put("res",customResponse); | ||
41 | + | ||
42 | + mt1201.setAwba("17212345678"); | ||
43 | + mt1201.setCarrier("CV"); | ||
44 | + mt1201.setCustomcode("4604"); | ||
45 | + mt1201.setFlightno("9733"); | ||
46 | + mt1201.setFlightdate(new Date()); | ||
47 | + mt1201.setDestinationstation("CGO"); | ||
48 | + | ||
49 | + String msgId = makeMsgID(businessType,"460470678920X","17212345678"); | ||
50 | + makeXmlToFile("/manifest/MT2201.ftlx",filename,awb_manifest); | ||
51 | + }catch (Exception e){ | ||
52 | + e.printStackTrace(); | ||
53 | + return false; | ||
54 | + } | ||
55 | + return true; | ||
56 | + } | ||
57 | +} |
1 | +package com.sunyo.wlpt.message.builder.util; | ||
2 | + | ||
3 | +import com.tianbo.util.Date.DateUtil; | ||
4 | +import freemarker.template.Configuration; | ||
5 | +import freemarker.template.Template; | ||
6 | +import freemarker.template.TemplateException; | ||
7 | +import org.apache.commons.io.FileUtils; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.beans.factory.annotation.Value; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | +import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; | ||
12 | + | ||
13 | +import java.io.File; | ||
14 | +import java.io.IOException; | ||
15 | +import java.util.Map; | ||
16 | + | ||
17 | +@Component | ||
18 | +public class CustomXmlMaker { | ||
19 | + @Autowired | ||
20 | + private Configuration freemakerTemplate; | ||
21 | + | ||
22 | + @Value("${custom.send-path}") | ||
23 | + private static String sendPath; | ||
24 | + | ||
25 | + @Value("${tcs.mq-number}") | ||
26 | + private static String TCSMQNumber; | ||
27 | + | ||
28 | + /** | ||
29 | + * 所有填制项中不得出现“<”、“&”符号,如有实际需要,请填写对应的转义符“<”、“&”。 | ||
30 | + 十、报文中不允许出现空节点,如<Consignee></Consignee>或<Consignee/>。 | ||
31 | + * @param tplName 模板名称 | ||
32 | + * @param fileName 生成的报文名称 | ||
33 | + * @param manifestMap 数据实体 | ||
34 | + * @return 0失败,1成功 | ||
35 | + * @throws IOException | ||
36 | + */ | ||
37 | + public int makeXmlToFile(String tplName,String fileName,Map manifestMap) throws IOException{ | ||
38 | + try { | ||
39 | + Template template = freemakerTemplate.getTemplate(tplName); | ||
40 | + String content = FreeMarkerTemplateUtils.processTemplateIntoString(template,manifestMap); | ||
41 | + String filename = sendPath+fileName; | ||
42 | + File sendfile = new File(filename); | ||
43 | + FileUtils.writeStringToFile(sendfile,content,"UTF-8"); | ||
44 | + }catch (IOException e){ | ||
45 | + e.printStackTrace(); | ||
46 | + return 0; | ||
47 | + }catch (TemplateException ee){ | ||
48 | + ee.printStackTrace(); | ||
49 | + return 0; | ||
50 | + } | ||
51 | + return 1; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * 生成MessageId | ||
56 | + * MessageID:报文编号,由企业自定义, | ||
57 | + * 要求与其它企业同类型报文不得重复, | ||
58 | + * 最大长度为64位,由字母、数字、特定符号组成,并不得出现除“-”、“_”“/”等以外的特殊符号, | ||
59 | + * 且符号不得作为报文编号的开头与结尾; | ||
60 | + * @param mtType 舱单业务申报类型 如:MT1201 | ||
61 | + * @param ORGSN 使用企业在海关备案的代码,备案规则为:4位关区代码+9位企业组织机构代码+50位自定义扩展字符。:460470678920X | ||
62 | + * @param waylbillNo 运单号 | ||
63 | + * @return CN_MT1201_1P0_460470678920X_17218902832_yyyyMMddHHmmssSSS | ||
64 | + */ | ||
65 | + public String makeMsgID(String mtType,String ORGSN,String waylbillNo){ | ||
66 | + StringBuilder sb = new StringBuilder(); | ||
67 | + sb.append("CN_") | ||
68 | + .append(mtType) | ||
69 | + .append("_1P0_") | ||
70 | + .append(ORGSN).append("_") | ||
71 | + .append(waylbillNo) | ||
72 | + .append("_").append(DateUtil.getCurrentTime17()); | ||
73 | + return sb.toString(); | ||
74 | + } | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + /** | ||
80 | + * 生成新舱单报文报头的SenderID。 | ||
81 | + * 发送方代码,使用企业在海关备案的代码,备案规则为:4位关区代码+9位企业组织机构代码+50位自定义扩展字符, | ||
82 | + * 由字母和数字组成,并不得出现除“-”、“_”“/”、“@”、“.”、“*”等以外的特殊字符,且符号不得作为结尾。 | ||
83 | + * 我们这里的备案规则设置为:关区代码+9位企业组织机构代码+_TCS通道号。 | ||
84 | + * @param customCode 关区代码 | ||
85 | + * @param ORGSN 海关企业备案编码 | ||
86 | + * @param TCSSN TCS分配的通道编号 | ||
87 | + * @return 460470678920X_DXPENT0000460002 | ||
88 | + */ | ||
89 | + public String makeSenderID(String customCode,String ORGSN,String TCSSN){ | ||
90 | + StringBuilder sb = new StringBuilder(); | ||
91 | + sb.append(customCode) | ||
92 | + .append(ORGSN) | ||
93 | + .append("_") | ||
94 | + .append(TCSSN); | ||
95 | + return sb.toString(); | ||
96 | + } | ||
97 | + public String makeSenderID(String customCode,String ORGSN){ | ||
98 | + return makeSenderID(customCode,ORGSN,TCSMQNumber); | ||
99 | + } | ||
100 | +} |
src/main/resources/banner.txt
0 → 100644
1 | +${AnsiColor.YELLOW} | ||
2 | + ##################*CETC-TIANBO*######################### | ||
3 | + | ||
4 | + .::::. | ||
5 | + .::::::::. | ||
6 | + ::::::::::: | ||
7 | + ..:::::::::::' | ||
8 | + '::::::::::::' | ||
9 | + .:::::::::: | ||
10 | + '::::::::::::::.. | ||
11 | + ..::::::::::::. | ||
12 | + ``:::::::::::::::: | ||
13 | + ::::``:::::::::' .:::. | ||
14 | + ::::' ':::::' .::::::::. | ||
15 | + .::::' :::: .:::::::'::::. | ||
16 | + .:::' ::::: .:::::::::' ':::::. | ||
17 | + .::' :::::.:::::::::' ':::::. | ||
18 | + .::' ::::::::::::::' ``::::. | ||
19 | + ...::: ::::::::::::' ``::. | ||
20 | + ```` ':. ':::::::::' ::::.. | ||
21 | + '.:::::' ':'````.. | ||
22 | + ######################################################### | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | ||
27 | +================================================== | ||
28 | +Application Info:${application.title} | ||
29 | +ver:${application.version} | ||
30 | +Powered by:Spring Boot ${spring-boot.version} |
1 | +<Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT1201:1"> | ||
2 | + <Head> | ||
3 | + <MessageID>CN_MT1201_1P0_460470678920X_20190918220458427</MessageID> | ||
4 | + <FunctionCode>9</FunctionCode> | ||
5 | + <MessageType>MT1201</MessageType> | ||
6 | + <SenderID>460470678920X_DXPENT0000460002</SenderID> | ||
7 | + <ReceiverID>4604</ReceiverID> | ||
8 | + <SendTime>20190918220458427</SendTime> | ||
9 | + <Version>1.0</Version> | ||
10 | + </Head> | ||
11 | + <Declaration> | ||
12 | + <RepresentativePerson> | ||
13 | + <Name>9141010070678920XJ</Name> | ||
14 | + </RepresentativePerson> | ||
15 | + <ExitCustomsOffice> | ||
16 | + <ID>KUL</ID> | ||
17 | + </ExitCustomsOffice> | ||
18 | + <Carrier> | ||
19 | + <ID>CV</ID> | ||
20 | + </Carrier> | ||
21 | + <BorderTransportMeans> | ||
22 | + <JourneyID>CV7303/20190919</JourneyID> | ||
23 | + <TypeCode>4</TypeCode> | ||
24 | + <FirstArrivalLocationID>CGO</FirstArrivalLocationID> | ||
25 | + <ArrivalDateTime>20190919010458086</ArrivalDateTime> | ||
26 | + <DepartureDateTime>20190918230458086</DepartureDateTime> | ||
27 | + </BorderTransportMeans> | ||
28 | + <Consignment> | ||
29 | + <TransportContractDocument> | ||
30 | + <ID>17236633273</ID> | ||
31 | + <ConditionCode>10</ConditionCode> | ||
32 | + </TransportContractDocument> | ||
33 | + <LoadingLocation> | ||
34 | + <ID>KUL</ID> | ||
35 | + </LoadingLocation> | ||
36 | + <UnloadingLocation> | ||
37 | + <ID>CGO/4604</ID> | ||
38 | + <ArrivalDate>20190919</ArrivalDate> | ||
39 | + </UnloadingLocation> | ||
40 | + <TransitDestination> | ||
41 | + <ID>CGN</ID> | ||
42 | + </TransitDestination> | ||
43 | + <CustomsStatusCode>002</CustomsStatusCode> | ||
44 | + <TransportSplitIndicator>0</TransportSplitIndicator> | ||
45 | + <FreightPayment> | ||
46 | + <MethodCode>PP</MethodCode> | ||
47 | + </FreightPayment> | ||
48 | + <ConsignmentPackaging> | ||
49 | + <QuantityQuantity>3</QuantityQuantity> | ||
50 | + </ConsignmentPackaging> | ||
51 | + <TotalGrossMassMeasure>24.0</TotalGrossMassMeasure> | ||
52 | + <Consignee> | ||
53 | + <ID>8888+NONE</ID> | ||
54 | + <Name>SCHENKER DEUTSCHLAND AG</Name> | ||
55 | + <Address> | ||
56 | + <Line>NEUER WEYERSTRASSERWEG 120 122</Line> | ||
57 | + <CountryCode>CN</CountryCode> | ||
58 | + </Address> | ||
59 | + <Communication> | ||
60 | + <ID>00000000</ID> | ||
61 | + <TypeID>TE</TypeID> | ||
62 | + </Communication> | ||
63 | + <Contact> | ||
64 | + <Name>NONE</Name> | ||
65 | + <Communication> | ||
66 | + <ID>00000000</ID> | ||
67 | + <TypeID>TE</TypeID> | ||
68 | + </Communication> | ||
69 | + </Contact> | ||
70 | + </Consignee> | ||
71 | + <Consignor> | ||
72 | + <ID>9999+NONE</ID> | ||
73 | + <Name>SCHENKER LOGISTICS MALAYSIA SDN BHD</Name> | ||
74 | + <Address> | ||
75 | + <Line>B 10 MAS FREIGHT FOWARDERS COMPLEX</Line> | ||
76 | + <CountryCode>MY</CountryCode> | ||
77 | + </Address> | ||
78 | + <Communication> | ||
79 | + <ID>60387757888</ID> | ||
80 | + <TypeID>TE</TypeID> | ||
81 | + </Communication> | ||
82 | + </Consignor> | ||
83 | + <ConsignmentItem> | ||
84 | + <SequenceNumeric>1</SequenceNumeric> | ||
85 | + <ConsignmentItemPackaging> | ||
86 | + <QuantityQuantity>3</QuantityQuantity> | ||
87 | + </ConsignmentItemPackaging> | ||
88 | + <Commodity> | ||
89 | + <CargoDescription>CONSOL</CargoDescription> | ||
90 | + </Commodity> | ||
91 | + <GoodsMeasure> | ||
92 | + <GrossMassMeasure>24</GrossMassMeasure> | ||
93 | + </GoodsMeasure> | ||
94 | + </ConsignmentItem> | ||
95 | + </Consignment> | ||
96 | + </Declaration> | ||
97 | +</Manifest> |
1 | +<Manifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:Declaration:datamodel:standard:CN:MT1201:1"> | ||
2 | + <Head> | ||
3 | + <MessageID>${cusmsgid}</MessageID> | ||
4 | + <FunctionCode>${cusfunctioncode}</FunctionCode> | ||
5 | + <MessageType>${bustype}</MessageType> | ||
6 | + <SenderID>${cussenderid}</SenderID> | ||
7 | + <ReceiverID>${cusreciverid}</ReceiverID> | ||
8 | + <SendTime>${busdate?string('ddMMyyyyHHmmssSSS')}</SendTime> | ||
9 | + <Version>${cusversion}</Version> | ||
10 | + </Head> | ||
11 | +</Manifest> |
-
请 注册 或 登录 后发表评论