Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
99665a71
Commit
99665a71
authored
May 26, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.word转换为pdf由docx4j调整为aspose-words;2.word转换为pdf由同步改为异步;
parent
ba0a696f
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
313 additions
and
213 deletions
+313
-213
pom.xml
pom.xml
+3
-20
CommonConstants.java
...sv/freight/customer/common/constants/CommonConstants.java
+48
-0
LogbackFilter.java
...com/esv/freight/customer/common/filter/LogbackFilter.java
+2
-1
RestLogFilter.java
...com/esv/freight/customer/common/filter/RestLogFilter.java
+61
-60
FeignUtils.java
...java/com/esv/freight/customer/common/util/FeignUtils.java
+9
-5
ReqUtils.java
...n/java/com/esv/freight/customer/common/util/ReqUtils.java
+7
-6
AsyncConfig.java
...ain/java/com/esv/freight/customer/config/AsyncConfig.java
+18
-0
ContractOnlineRecordEntity.java
...er/module/contract/entity/ContractOnlineRecordEntity.java
+12
-4
ContractOnlineRecordServiceImpl.java
...ontract/service/impl/ContractOnlineRecordServiceImpl.java
+84
-44
logback-spring.xml
src/main/resources/logback-spring.xml
+5
-1
ContractOnlineRecordDao.xml
...ain/resources/mapper/contract/ContractOnlineRecordDao.xml
+4
-2
BaseTestController.java
...est/java/com/esv/freight/customer/BaseTestController.java
+6
-0
AsposeWordsTest.java
...com/esv/freight/customer/common/util/AsposeWordsTest.java
+52
-0
WordTest.java
...t/java/com/esv/freight/customer/common/util/WordTest.java
+0
-68
ContractOnlineRecordControllerTest.java
...ntract/controller/ContractOnlineRecordControllerTest.java
+2
-2
No files found.
pom.xml
View file @
99665a71
...
@@ -121,27 +121,10 @@
...
@@ -121,27 +121,10 @@
<artifactId>
poi-tl
</artifactId>
<artifactId>
poi-tl
</artifactId>
<version>
1.7.3
</version>
<version>
1.7.3
</version>
</dependency>
</dependency>
<!-- word转pdf -->
<dependency>
<dependency>
<groupId>
org.docx4j
</groupId>
<groupId>
com.aspose
</groupId>
<artifactId>
docx4j
</artifactId>
<artifactId>
aspose-words
</artifactId>
<version>
6.1.2
</version>
<version>
16.4.0
</version>
<exclusions>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.docx4j
</groupId>
<artifactId>
docx4j-export-fo
</artifactId>
<version>
8.1.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-compress
</artifactId>
<version>
1.20
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.esv.platform
</groupId>
<groupId>
com.esv.platform
</groupId>
...
...
src/main/java/com/esv/freight/customer/common/constants/CommonConstants.java
View file @
99665a71
...
@@ -11,6 +11,7 @@ package com.esv.freight.customer.common.constants;
...
@@ -11,6 +11,7 @@ package com.esv.freight.customer.common.constants;
*/
*/
public
class
CommonConstants
{
public
class
CommonConstants
{
/**
/**
* 访问端来源:1-浏览器端、2-Android端、3-iOS端、4-后台服务端
* 访问端来源:1-浏览器端、2-Android端、3-iOS端、4-后台服务端
**/
**/
...
@@ -20,4 +21,51 @@ public class CommonConstants {
...
@@ -20,4 +21,51 @@ public class CommonConstants {
public
static
final
String
REQ_SOURCE_TYPE_IOS
=
"3"
;
public
static
final
String
REQ_SOURCE_TYPE_IOS
=
"3"
;
public
static
final
String
REQ_SOURCE_TYPE_SERVICE
=
"4"
;
public
static
final
String
REQ_SOURCE_TYPE_SERVICE
=
"4"
;
/**
* Feign调用返回参数
**/
public
static
final
String
FEIGN_RESULT_CODE
=
"code"
;
public
static
final
String
FEIGN_RESULT_MESSAGE
=
"message"
;
public
static
final
String
FEIGN_RESULT_DATA
=
"data"
;
public
static
final
int
FEIGN_RESULT_SUCCESS
=
200
;
/**
* 字符串"null"
**/
public
static
final
String
NULL_STRING
=
"null"
;
/**
* 字符串"unknown"
**/
public
static
final
String
UNKNOWN_STRING
=
"unknown"
;
/**
* log日志输出的最大长度及截取输出的长度
**/
public
static
final
int
LOG_MAX_LENGTH
=
5000
;
public
static
final
int
LOG_CUT_LENGTH
=
1000
;
/**
* Spring Boot Admin监控url前缀
**/
public
static
final
String
SPRING_BOOT_ADMIN_PREFIX_URL
=
"/actuator"
;
/**
* 默认字符编码
**/
public
static
final
String
DEFAULT_CHARACTER_ENCODING
=
"utf-8"
;
/**
* Http请求方式
**/
public
static
final
String
HTTP_REQUEST_METHOD_GET
=
"GET"
;
public
static
final
String
HTTP_REQUEST_METHOD_POST
=
"POST"
;
/**
* Http请求头
**/
public
static
final
String
HTTP_HEADER_X_FORWARDED_FOR
=
"x-forwarded-for"
;
public
static
final
String
HTTP_HEADER_PROXY_CLIENT_IP
=
"Proxy-Client-IP"
;
public
static
final
String
HTTP_HEADER_WL_PROXY_CLIENT_IP
=
"WL-Proxy-Client-IP"
;
}
}
src/main/java/com/esv/freight/customer/common/filter/LogbackFilter.java
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
filter
;
package
com
.
esv
.
freight
.
customer
.
common
.
filter
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.MDC
;
import
org.slf4j.MDC
;
...
@@ -50,7 +51,7 @@ public class LogbackFilter implements Filter {
...
@@ -50,7 +51,7 @@ public class LogbackFilter implements Filter {
}
}
private
boolean
setMDC
(
String
traceId
)
{
private
boolean
setMDC
(
String
traceId
)
{
if
(
StringUtils
.
isEmpty
(
traceId
)
||
"null"
.
equalsIgnoreCase
(
traceId
))
{
if
(
StringUtils
.
isEmpty
(
traceId
)
||
CommonConstants
.
NULL_STRING
.
equalsIgnoreCase
(
traceId
))
{
traceId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
traceId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
}
MDC
.
put
(
"traceId"
,
traceId
);
MDC
.
put
(
"traceId"
,
traceId
);
...
...
src/main/java/com/esv/freight/customer/common/filter/RestLogFilter.java
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
filter
;
package
com
.
esv
.
freight
.
customer
.
common
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.common.wrapper.RestRequestWrapper
;
import
com.esv.freight.customer.common.wrapper.RestRequestWrapper
;
import
com.esv.freight.customer.common.wrapper.RestResponseWrapper
;
import
com.esv.freight.customer.common.wrapper.RestResponseWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.io.*
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -30,44 +28,37 @@ import java.util.Map;
...
@@ -30,44 +28,37 @@ import java.util.Map;
@Slf4j
@Slf4j
public
class
RestLogFilter
implements
Filter
{
public
class
RestLogFilter
implements
Filter
{
@Override
@Override
public
void
init
(
FilterConfig
filterConfig
)
{
public
void
init
(
FilterConfig
filterConfig
)
{
}
}
@Override
public
void
destroy
()
{
}
@Override
@Override
public
void
doFilter
(
ServletRequest
servletRequest
,
ServletResponse
servletResponse
,
FilterChain
filterChain
)
throws
IOException
,
ServletException
{
public
void
doFilter
(
ServletRequest
servletRequest
,
ServletResponse
servletResponse
,
FilterChain
filterChain
)
throws
IOException
,
ServletException
{
RestRequestWrapper
requestWrapper
=
new
RestRequestWrapper
((
HttpServletRequest
)
servletRequest
);
RestRequestWrapper
requestWrapper
=
new
RestRequestWrapper
((
HttpServletRequest
)
servletRequest
);
RestResponseWrapper
responseWrapper
=
new
RestResponseWrapper
((
HttpServletResponse
)
servletResponse
);
RestResponseWrapper
responseWrapper
=
new
RestResponseWrapper
((
HttpServletResponse
)
servletResponse
);
String
reqContentType
=
StringUtils
.
trimToEmpty
(
requestWrapper
.
getContentType
()).
toLowerCase
();
// 日志输出请求体
if
(!
reqContentType
.
contains
(
"multipart/form-data"
))
{
this
.
logReq
(
requestWrapper
);
// 日志输出请求
logReq
(
requestWrapper
);
}
logReqHeader
(
requestWrapper
);
filterChain
.
doFilter
(
requestWrapper
,
responseWrapper
);
String
resContentType
=
StringUtils
.
trimToEmpty
(
responseWrapper
.
getContentType
());
// 日志输出请求头
if
(
resContentType
.
contains
(
"text"
)
||
resContentType
.
contains
(
"xml"
)
this
.
logReqHeader
(
requestWrapper
);
||
resContentType
.
contains
(
"json"
))
{
// 日志输出返回
try
{
logRes
(
requestWrapper
,
responseWrapper
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
log
.
info
(
"Response ContentType: {}"
,
resContentType
);
}
}
@Override
filterChain
.
doFilter
(
requestWrapper
,
responseWrapper
);
public
void
destroy
()
{
// 日志输出返回体
this
.
logRes
(
requestWrapper
,
responseWrapper
);
}
}
/**
* 获取请求返回体
**/
private
String
getPostBodyStr
(
HttpServletRequest
request
)
{
private
String
getPostBodyStr
(
HttpServletRequest
request
)
{
String
bodyStr
=
null
;
String
bodyStr
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
@@ -75,7 +66,7 @@ public class RestLogFilter implements Filter {
...
@@ -75,7 +66,7 @@ public class RestLogFilter implements Filter {
BufferedReader
reader
=
null
;
BufferedReader
reader
=
null
;
try
{
try
{
inputStream
=
request
.
getInputStream
();
inputStream
=
request
.
getInputStream
();
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
Charset
.
forName
(
"UTF-8"
)));
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
Charset
.
forName
(
CommonConstants
.
DEFAULT_CHARACTER_ENCODING
)));
String
line
=
""
;
String
line
=
""
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
while
((
line
=
reader
.
readLine
())
!=
null
)
{
sb
.
append
(
line
);
sb
.
append
(
line
);
...
@@ -114,30 +105,43 @@ public class RestLogFilter implements Filter {
...
@@ -114,30 +105,43 @@ public class RestLogFilter implements Filter {
return
bodyStr
;
return
bodyStr
;
}
}
/**
* 日志输出请求体
**/
private
void
logReq
(
RestRequestWrapper
requestWrapper
)
{
private
void
logReq
(
RestRequestWrapper
requestWrapper
)
{
String
url
=
requestWrapper
.
getRequestURI
();
String
url
=
requestWrapper
.
getRequestURI
();
String
method
=
requestWrapper
.
getMethod
();
String
method
=
requestWrapper
.
getMethod
();
if
(
"GET"
.
equalsIgnoreCase
(
method
))
{
String
reqBody
=
""
;
// 获取get、post请求体
if
(
CommonConstants
.
HTTP_REQUEST_METHOD_GET
.
equalsIgnoreCase
(
method
))
{
Enumeration
em
=
requestWrapper
.
getParameterNames
();
Enumeration
em
=
requestWrapper
.
getParameterNames
();
String
reqParams
=
""
;
while
(
em
.
hasMoreElements
())
{
while
(
em
.
hasMoreElements
())
{
String
k
=
em
.
nextElement
().
toString
();
String
k
=
em
.
nextElement
().
toString
();
String
v
=
requestWrapper
.
getParameter
(
k
);
String
v
=
requestWrapper
.
getParameter
(
k
);
reqParams
+=
"&"
+
k
+
"="
+
v
;
reqBody
+=
"&"
+
k
+
"="
+
v
;
}
reqParams
=
reqParams
.
replaceFirst
(
"&"
,
""
);
if
(
url
.
startsWith
(
"/actuator"
))
{
log
.
debug
(
"[IP={}]收到{}请求,url:{},params:{}"
,
getHttpClientIp
(
requestWrapper
),
method
,
url
,
reqParams
);
}
else
{
log
.
info
(
"[IP={}]收到{}请求,url:{},params:{}"
,
getHttpClientIp
(
requestWrapper
),
method
,
url
,
reqParams
);
}
}
}
else
if
(
"POST"
.
equalsIgnoreCase
(
method
))
{
reqBody
=
reqBody
.
replaceFirst
(
"&"
,
""
);
log
.
info
(
"[IP={}]收到{}请求,url:{},body:{}"
,
getHttpClientIp
(
requestWrapper
),
method
,
url
,
getPostBodyStr
(
requestWrapper
));
}
else
if
(
CommonConstants
.
HTTP_REQUEST_METHOD_POST
.
equalsIgnoreCase
(
method
))
{
}
else
{
reqBody
=
this
.
getPostBodyStr
(
requestWrapper
);
}
// 请求体日志截取
if
(
CommonConstants
.
LOG_MAX_LENGTH
<
reqBody
.
length
())
{
reqBody
=
reqBody
.
substring
(
0
,
CommonConstants
.
LOG_CUT_LENGTH
)
+
"……"
;
}
// 日志输出请求体
if
(
url
.
startsWith
(
CommonConstants
.
SPRING_BOOT_ADMIN_PREFIX_URL
))
{
log
.
debug
(
"[IP={}]收到{}请求,url:{},params:{}"
,
ReqUtils
.
getHttpClientIp
(
requestWrapper
),
method
,
url
,
reqBody
);
}
else
{
log
.
info
(
"[IP={}]收到{}请求,url:{},body:{}"
,
ReqUtils
.
getHttpClientIp
(
requestWrapper
),
method
,
url
,
reqBody
);
}
}
}
}
/**
* 日志输出请求头
**/
private
void
logReqHeader
(
RestRequestWrapper
request
)
{
private
void
logReqHeader
(
RestRequestWrapper
request
)
{
JSONObject
headerJson
=
new
JSONObject
();
JSONObject
headerJson
=
new
JSONObject
();
Enumeration
headerNames
=
request
.
getHeaderNames
();
Enumeration
headerNames
=
request
.
getHeaderNames
();
...
@@ -148,28 +152,25 @@ public class RestLogFilter implements Filter {
...
@@ -148,28 +152,25 @@ public class RestLogFilter implements Filter {
log
.
info
(
"请求头:{}"
,
headerJson
.
toJSONString
());
log
.
info
(
"请求头:{}"
,
headerJson
.
toJSONString
());
}
}
private
void
logRes
(
RestRequestWrapper
requestWrapper
,
RestResponseWrapper
responseWrapper
)
throws
Exception
{
/**
* 日志输出返回体
**/
private
void
logRes
(
RestRequestWrapper
requestWrapper
,
RestResponseWrapper
responseWrapper
)
{
byte
[]
bytes
=
responseWrapper
.
getBody
();
byte
[]
bytes
=
responseWrapper
.
getBody
();
String
resStr
=
new
String
(
bytes
,
"utf-8"
);
String
resBody
=
null
;
String
url
=
requestWrapper
.
getRequestURI
();
try
{
if
(
url
.
startsWith
(
"/actuator"
))
{
resBody
=
new
String
(
bytes
,
CommonConstants
.
DEFAULT_CHARACTER_ENCODING
);
log
.
debug
(
"请求响应:{}"
,
resStr
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
else
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
info
(
"请求响应:{}"
,
resStr
);
}
}
private
String
getHttpClientIp
(
HttpServletRequest
req
){
String
ip
=
req
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
req
.
getHeader
(
"Proxy-Client-IP"
);
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
String
url
=
requestWrapper
.
getRequestURI
();
ip
=
req
.
getHeader
(
"WL-Proxy-Client-IP"
);
if
(
CommonConstants
.
LOG_MAX_LENGTH
<
resBody
.
length
())
{
resBody
=
resBody
.
substring
(
0
,
CommonConstants
.
LOG_CUT_LENGTH
)
+
"……"
;
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
url
.
startsWith
(
CommonConstants
.
SPRING_BOOT_ADMIN_PREFIX_URL
))
{
ip
=
req
.
getRemoteAddr
();
log
.
debug
(
"请求响应:{}"
,
resBody
);
}
else
{
log
.
info
(
"请求响应:{}"
,
resBody
);
}
}
return
ip
;
}
}
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/common/util/FeignUtils.java
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
...
@@ -25,11 +25,15 @@ public class FeignUtils {
...
@@ -25,11 +25,15 @@ public class FeignUtils {
* createTime 2020/04/17 18:12
* createTime 2020/04/17 18:12
**/
**/
public
static
JSONObject
getFeignResultData
(
JSONObject
resultJson
)
throws
EException
{
public
static
JSONObject
getFeignResultData
(
JSONObject
resultJson
)
throws
EException
{
log
.
info
(
resultJson
.
toJSONString
());
String
result
=
resultJson
.
toJSONString
();
if
(
ECode
.
SUCCESS
.
code
()
!=
resultJson
.
getIntValue
(
"code"
))
{
if
(
CommonConstants
.
LOG_MAX_LENGTH
<
result
.
length
())
{
throw
new
EException
(
resultJson
.
getIntValue
(
"code"
),
resultJson
.
getString
(
"message"
));
result
=
result
.
substring
(
0
,
CommonConstants
.
LOG_CUT_LENGTH
)
+
"……"
;
}
log
.
info
(
result
);
if
(
CommonConstants
.
FEIGN_RESULT_SUCCESS
==
resultJson
.
getIntValue
(
CommonConstants
.
FEIGN_RESULT_CODE
))
{
return
resultJson
.
getJSONObject
(
CommonConstants
.
FEIGN_RESULT_DATA
);
}
else
{
}
else
{
return
resultJson
.
getJSONObject
(
"data"
);
throw
new
EException
(
resultJson
.
getIntValue
(
CommonConstants
.
FEIGN_RESULT_CODE
),
resultJson
.
getString
(
CommonConstants
.
FEIGN_RESULT_MESSAGE
)
);
}
}
}
}
...
...
src/main/java/com/esv/freight/customer/common/util/ReqUtils.java
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.constants.CommonConstants
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.gateway.common.GatewayHeaders
;
import
com.esv.gateway.common.GatewayHeaders
;
...
@@ -74,14 +75,14 @@ public class ReqUtils {
...
@@ -74,14 +75,14 @@ public class ReqUtils {
* @return
* @return
*/
*/
public
static
String
getHttpClientIp
(
HttpServletRequest
req
){
public
static
String
getHttpClientIp
(
HttpServletRequest
req
){
String
ip
=
req
.
getHeader
(
"x-forwarded-for"
);
String
ip
=
req
.
getHeader
(
CommonConstants
.
HTTP_HEADER_X_FORWARDED_FOR
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CommonConstants
.
UNKNOWN_STRING
.
equalsIgnoreCase
(
ip
))
{
ip
=
req
.
getHeader
(
"Proxy-Client-IP"
);
ip
=
req
.
getHeader
(
CommonConstants
.
HTTP_HEADER_PROXY_CLIENT_IP
);
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CommonConstants
.
UNKNOWN_STRING
.
equalsIgnoreCase
(
ip
))
{
ip
=
req
.
getHeader
(
"WL-Proxy-Client-IP"
);
ip
=
req
.
getHeader
(
CommonConstants
.
HTTP_HEADER_WL_PROXY_CLIENT_IP
);
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CommonConstants
.
UNKNOWN_STRING
.
equalsIgnoreCase
(
ip
))
{
ip
=
req
.
getRemoteAddr
();
ip
=
req
.
getRemoteAddr
();
}
}
return
ip
;
return
ip
;
...
...
src/main/java/com/esv/freight/customer/config/AsyncConfig.java
0 → 100644
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
/**
* @description: 异步任务
* @project: freight-customer-service
* @name: com.esv.freight.customer.config.AsyncConfig
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/26 9:19
* @version:1.0
*/
@Configuration
@EnableAsync
public
class
AsyncConfig
{
}
src/main/java/com/esv/freight/customer/module/contract/entity/ContractOnlineRecordEntity.java
View file @
99665a71
...
@@ -41,13 +41,21 @@ public class ContractOnlineRecordEntity implements Serializable {
...
@@ -41,13 +41,21 @@ public class ContractOnlineRecordEntity implements Serializable {
*/
*/
private
Integer
contractType
;
private
Integer
contractType
;
/**
/**
* 合同文件ID
* 合同
源
文件ID
*/
*/
private
String
contract
FileId
;
private
String
source
FileId
;
/**
/**
* 合同文件URL
* 合同
源
文件URL
*/
*/
private
String
contractFileUrl
;
private
String
sourceFileUrl
;
/**
* 合同目标文件ID
*/
private
String
targetFileId
;
/**
* 合同目标文件URL
*/
private
String
targetFileUrl
;
/**
/**
* 合同编号
* 合同编号
*/
*/
...
...
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlineRecordServiceImpl.java
View file @
99665a71
This diff is collapsed.
Click to expand it.
src/main/resources/logback-spring.xml
View file @
99665a71
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
<!-- mybatis sql日志 日志的级别需要是DEBUG -->
<!-- mybatis sql日志 日志的级别需要是DEBUG -->
<!-- 日志打印的包的范围,及分类日志文件存储 -->
<!-- 日志打印的包的范围,及分类日志文件存储 -->
<logger
name=
"com.esv"
level=
"
DEBUG
"
additivity=
"false"
>
<logger
name=
"com.esv"
level=
"
INFO
"
additivity=
"false"
>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
</logger>
</logger>
...
@@ -52,6 +52,10 @@
...
@@ -52,6 +52,10 @@
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
</logger>
</logger>
<logger
name=
"com.deepoove.poi"
level=
"ERROR"
additivity=
"false"
>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
</logger>
<!--控制台和日志文件输出级别-->
<!--控制台和日志文件输出级别-->
<root
level=
"INFO"
additivity=
"false"
>
<root
level=
"INFO"
additivity=
"false"
>
...
...
src/main/resources/mapper/contract/ContractOnlineRecordDao.xml
View file @
99665a71
...
@@ -9,8 +9,10 @@
...
@@ -9,8 +9,10 @@
<result
property=
"tenantId"
column=
"tenant_id"
/>
<result
property=
"tenantId"
column=
"tenant_id"
/>
<result
property=
"departmentId"
column=
"department_id"
/>
<result
property=
"departmentId"
column=
"department_id"
/>
<result
property=
"contractType"
column=
"contract_type"
/>
<result
property=
"contractType"
column=
"contract_type"
/>
<result
property=
"contractFileId"
column=
"contract_file_id"
/>
<result
property=
"sourceFileId"
column=
"source_file_id"
/>
<result
property=
"contractFileUrl"
column=
"contract_file_url"
/>
<result
property=
"sourceFileUrl"
column=
"source_file_url"
/>
<result
property=
"targetFileId"
column=
"target_file_id"
/>
<result
property=
"targetFileUrl"
column=
"target_file_url"
/>
<result
property=
"contractNumber"
column=
"contract_number"
/>
<result
property=
"contractNumber"
column=
"contract_number"
/>
<result
property=
"businessNumber"
column=
"business_number"
/>
<result
property=
"businessNumber"
column=
"business_number"
/>
<result
property=
"customerId"
column=
"customer_id"
/>
<result
property=
"customerId"
column=
"customer_id"
/>
...
...
src/test/java/com/esv/freight/customer/BaseTestController.java
View file @
99665a71
...
@@ -29,14 +29,20 @@ public class BaseTestController {
...
@@ -29,14 +29,20 @@ public class BaseTestController {
MockMvc
mockMvc
;
MockMvc
mockMvc
;
private
static
Long
TEST_START_TIME
;
private
static
Long
TEST_END_TIME
;
@Before
@Before
public
void
before
()
{
public
void
before
()
{
log
.
info
(
"=================================== Test Start ==================================="
);
log
.
info
(
"=================================== Test Start ==================================="
);
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
TEST_START_TIME
=
System
.
currentTimeMillis
();
}
}
@After
@After
public
void
after
()
{
public
void
after
()
{
TEST_END_TIME
=
System
.
currentTimeMillis
();
log
.
info
(
"Test耗时:"
+
(
TEST_END_TIME
-
TEST_START_TIME
)
+
"毫秒"
);
log
.
info
(
"=================================== Test End ==================================="
);
log
.
info
(
"=================================== Test End ==================================="
);
}
}
...
...
src/test/java/com/esv/freight/customer/common/util/AsposeWordsTest.java
0 → 100644
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
com.aspose.words.Document
;
import
com.aspose.words.SaveFormat
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.junit.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.File
;
import
java.io.FileOutputStream
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.AsposeWordsTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/25 20:40
* @version:1.0
*/
@SpringBootTest
@Slf4j
public
class
AsposeWordsTest
{
@Test
public
void
word_2_pdf_time_test
()
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
word_2_pdf_test
(
i
);
}
}
public
static
void
word_2_pdf_test
(
int
i
)
{
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
pdfPath
=
"D:\\test\\线上合同-货主-test-aspose-"
+
(
i
+
1
)
+
".pdf"
;
long
old
=
System
.
currentTimeMillis
();
FileOutputStream
fileOutputStream
=
null
;
try
{
fileOutputStream
=
new
FileOutputStream
(
new
File
(
pdfPath
));
Document
doc
=
new
Document
(
sourcePath
);
doc
.
save
(
fileOutputStream
,
SaveFormat
.
PDF
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"docx文档转换为PDF失败"
);
}
finally
{
IOUtils
.
closeQuietly
(
fileOutputStream
);
}
long
now
=
System
.
currentTimeMillis
();
log
.
info
(
"共耗时:"
+
((
now
-
old
)
/
1000.0
)
+
"秒"
);
}
}
src/test/java/com/esv/freight/customer/common/util/WordTest.java
View file @
99665a71
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
com.baomidou.mybatisplus.core.toolkit.BeanUtils
;
import
com.deepoove.poi.XWPFTemplate
;
import
com.deepoove.poi.XWPFTemplate
;
import
com.deepoove.poi.data.PictureRenderData
;
import
com.deepoove.poi.data.PictureRenderData
;
import
com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo
;
import
com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.docx4j.Docx4J
;
import
org.docx4j.fonts.IdentityPlusMapper
;
import
org.docx4j.fonts.Mapper
;
import
org.docx4j.fonts.PhysicalFonts
;
import
org.docx4j.openpackaging.packages.WordprocessingMLPackage
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,7 +28,6 @@ public class WordTest {
...
@@ -36,7 +28,6 @@ public class WordTest {
public
void
simple_test
()
throws
Exception
{
public
void
simple_test
()
throws
Exception
{
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
targetPath
=
"D:\\test\\线上合同-货主-合成.docx"
;
String
targetPath
=
"D:\\test\\线上合同-货主-合成.docx"
;
String
pdfPath
=
"D:\\test\\线上合同-货主-PDF.pdf"
;
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"contactNumber"
,
System
.
currentTimeMillis
());
dataMap
.
put
(
"contactNumber"
,
System
.
currentTimeMillis
());
...
@@ -68,27 +59,12 @@ public class WordTest {
...
@@ -68,27 +59,12 @@ public class WordTest {
out
.
flush
();
out
.
flush
();
out
.
close
();
out
.
close
();
template
.
close
();
template
.
close
();
FileOutputStream
fileOutputStream
=
null
;
try
{
File
file
=
new
File
(
targetPath
);
fileOutputStream
=
new
FileOutputStream
(
new
File
(
pdfPath
));
WordprocessingMLPackage
mlPackage
=
WordprocessingMLPackage
.
load
(
file
);
setFontMapper
(
mlPackage
);
Docx4J
.
toPDF
(
mlPackage
,
new
FileOutputStream
(
new
File
(
pdfPath
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"docx文档转换为PDF失败"
);
}
finally
{
IOUtils
.
closeQuietly
(
fileOutputStream
);
}
}
}
@Test
@Test
public
void
pojo_test
()
throws
Exception
{
public
void
pojo_test
()
throws
Exception
{
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
targetPath
=
"D:\\test\\线上合同-货主-合成.docx"
;
String
targetPath
=
"D:\\test\\线上合同-货主-合成.docx"
;
String
pdfPath
=
"D:\\test\\线上合同-货主-PDF.pdf"
;
ContractOnlineGoodsOwnerPojo
pojo
=
new
ContractOnlineGoodsOwnerPojo
();
ContractOnlineGoodsOwnerPojo
pojo
=
new
ContractOnlineGoodsOwnerPojo
();
pojo
.
setContactNumber
(
String
.
valueOf
(
System
.
currentTimeMillis
()));
pojo
.
setContactNumber
(
String
.
valueOf
(
System
.
currentTimeMillis
()));
...
@@ -110,8 +86,6 @@ public class WordTest {
...
@@ -110,8 +86,6 @@ public class WordTest {
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setGoodsOwnerSignImg
(
new
PictureRenderData
(
150
,
60
,
"D:\\test\\何锋.jpg"
));
pojo
.
setGoodsOwnerSignImg
(
new
PictureRenderData
(
150
,
60
,
"D:\\test\\何锋.jpg"
));
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
// Map<String, Object> dataMap = BeanUtils.beanToMap(pojo);
// dataMap.put("platformFreightSealImg", "{{@platformFreightSealImg}}");
XWPFTemplate
template
=
XWPFTemplate
.
compile
(
sourcePath
);
XWPFTemplate
template
=
XWPFTemplate
.
compile
(
sourcePath
);
template
.
render
(
pojo
);
template
.
render
(
pojo
);
...
@@ -120,47 +94,5 @@ public class WordTest {
...
@@ -120,47 +94,5 @@ public class WordTest {
out
.
flush
();
out
.
flush
();
out
.
close
();
out
.
close
();
template
.
close
();
template
.
close
();
FileOutputStream
fileOutputStream
=
null
;
try
{
File
file
=
new
File
(
targetPath
);
fileOutputStream
=
new
FileOutputStream
(
new
File
(
pdfPath
));
WordprocessingMLPackage
mlPackage
=
WordprocessingMLPackage
.
load
(
file
);
setFontMapper
(
mlPackage
);
Docx4J
.
toPDF
(
mlPackage
,
new
FileOutputStream
(
new
File
(
pdfPath
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"docx文档转换为PDF失败"
);
}
finally
{
IOUtils
.
closeQuietly
(
fileOutputStream
);
}
}
@Test
public
void
pdf_test
()
throws
Exception
{
String
sourcePath
=
"D:\\test\\线上合同-货主.docx"
;
String
pdfPath
=
"D:\\test\\线上合同-货主-test.pdf"
;
FileOutputStream
fileOutputStream
=
null
;
try
{
File
file
=
new
File
(
sourcePath
);
fileOutputStream
=
new
FileOutputStream
(
new
File
(
pdfPath
));
WordprocessingMLPackage
mlPackage
=
WordprocessingMLPackage
.
load
(
file
);
setFontMapper
(
mlPackage
);
Docx4J
.
toPDF
(
mlPackage
,
new
FileOutputStream
(
new
File
(
pdfPath
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"docx文档转换为PDF失败"
);
}
finally
{
IOUtils
.
closeQuietly
(
fileOutputStream
);
}
}
private
static
void
setFontMapper
(
WordprocessingMLPackage
mlPackage
)
throws
Exception
{
Mapper
fontMapper
=
new
IdentityPlusMapper
();
fontMapper
.
put
(
"等线"
,
PhysicalFonts
.
get
(
"Arial"
));
fontMapper
.
put
(
"宋体"
,
PhysicalFonts
.
get
(
"SimSun"
));
mlPackage
.
setFontMapper
(
fontMapper
);
}
}
}
}
src/test/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordControllerTest.java
View file @
99665a71
...
@@ -139,7 +139,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
...
@@ -139,7 +139,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据
// 构造数据
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
form
.
setContractNumber
(
"HZHT2020052
2000006
"
);
form
.
setContractNumber
(
"HZHT2020052
6000002
"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
...
@@ -191,7 +191,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
...
@@ -191,7 +191,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据
// 构造数据
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
form
.
setContractNumber
(
"HZHT2020052
5
000002"
);
form
.
setContractNumber
(
"HZHT2020052
6
000002"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment