Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-api
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Data-王博
finance-api
Commits
2db08466
Commit
2db08466
authored
Feb 19, 2017
by
Data-王博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
湖北消金 - 保存请求和发送的的原始文件
parent
333db2c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
2 deletions
+50
-2
HuBeiServiceImpl.java
...n/quantgroup/financial/service/impl/HuBeiServiceImpl.java
+46
-1
financial_api.properties
src/main/resources/config/local/financial_api.properties
+1
-0
financial_api.properties
src/main/resources/config/release/financial_api.properties
+1
-0
financial_api.properties
src/main/resources/config/test/financial_api.properties
+1
-0
HuBeiServiceTest.java
...ava/cn/quantgroup/financial/service/HuBeiServiceTest.java
+1
-1
No files found.
src/main/java/cn/quantgroup/financial/service/impl/HuBeiServiceImpl.java
View file @
2db08466
...
...
@@ -35,6 +35,9 @@ import javax.xml.parsers.ParserConfigurationException;
import
javax.xml.transform.TransformerException
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -50,6 +53,9 @@ public class HuBeiServiceImpl implements IHuBeiService {
@Value
(
"${spring.mail.username}"
)
private
String
sender
;
@Value
(
"${hubei.history.filepath}"
)
private
String
hubeiHistoryFilePath
;
@Autowired
private
IHuBeiDispatcher
huBeiHandlerDispatcher
;
...
...
@@ -151,9 +157,12 @@ public class HuBeiServiceImpl implements IHuBeiService {
}
logger
.
info
(
"apiUrl={}, requestBody={}"
,
hubeiApiUrl
,
requestBody
);
requestMap
.
put
(
HubeiCFCField
.
xmlString
,
requestBody
);
String
filePre
=
docName
==
null
?
dataType
.
get
()+
"_"
:
dataType
.
get
()+
"_"
+
docName
;
saveHistoryFile
(
requestBody
,
filePre
+
"_request"
);
HttpResult
httpResult
=
NetUtil
.
postRequestUrl
(
hubeiApiUrl
,
requestMap
,
headerMap
,
SysConstant
.
retryOneNums
);
if
(
httpResult
.
getStatus
()==
NetUtil
.
RequestStatus
.
SUCCESS_STATUS
){
String
responseBody
=
httpResult
.
getResult
();
saveHistoryFile
(
responseBody
,
filePre
+
"_response"
);
if
(
logger
.
isDebugEnabled
()){
logger
.
info
(
"responseBody={}"
,
responseBody
);
}
...
...
@@ -170,6 +179,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
DataSource
dataSource
=
null
;
switch
(
dataType
){
case
SEND_DEBIT:
case
SEND_ADVANCE_REPAYMENT_CHECK:
//发送送盘文件 邮件
dataSource
=
iMailService
.
getDataSource
(
new
String
(
Base64
.
decodeBase64
(
response
.
getFileConent
())),
response
.
getFileName
());
sendMailAttachment
(
dataType
,
new
ArrayList
<
DataSource
>(
Arrays
.
asList
(
dataSource
)));
...
...
@@ -178,7 +188,6 @@ public class HuBeiServiceImpl implements IHuBeiService {
case
RETURN_ADVANCE_REPAYMENT:
case
RETURN_BATCH_DEBIT:
case
RETURN_BATCH_COMPENSATION:
case
SEND_ADVANCE_REPAYMENT_CHECK:
//发送回盘 邮件
dataSource
=
iMailService
.
getDataSource
(
new
String
(
Base64
.
decodeBase64
(
huBeiCFCRequest
.
getFileConent
())),
huBeiCFCRequest
.
getFileName
());
sendMailAttachment
(
dataType
,
new
ArrayList
<
DataSource
>(
Arrays
.
asList
(
dataSource
)));
...
...
@@ -309,6 +318,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
public
void
saveResponseData
(
HuBeiCFCResponse
response
,
HubeiCFCDataType
type
)
throws
ServerErrorException
{
logger
.
info
(
"saveResponseData method is called"
);
String
line
=
null
;
saveHistoryFile
(
response
.
getFileConent
(),
response
.
getFileName
());
try
(
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
new
ByteArrayInputStream
(
Base64
.
decodeBase64
(
response
.
getFileConent
())))))
{
HuBeiDocName
docName
=
new
HuBeiDocName
();
docName
.
setDocName
(
response
.
getFileName
());
...
...
@@ -797,5 +807,40 @@ public class HuBeiServiceImpl implements IHuBeiService {
return
huBeiDocName
;
}
/**
* 保存发送和接收的内容方便历史查询
* @param fileContent
* @param fileName
*/
public
void
saveHistoryFile
(
String
fileContent
,
String
fileName
){
if
(
StringUtils
.
isEmpty
(
fileContent
)||
StringUtils
.
isEmpty
(
fileName
)){
logger
.
info
(
"saveHistoryFile fileContent or fileName is empty"
);
return
;
}
try
{
fileName
=
fileName
+
"_"
+
System
.
currentTimeMillis
();
createDir
();
File
file
=
new
File
(
hubeiHistoryFilePath
+
DateUtil
.
sampleDateFormatFormat
(
new
Date
())+
File
.
separatorChar
+
fileName
);
file
.
createNewFile
();
try
(
BufferedOutputStream
outputStream
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
))){
outputStream
.
write
(
fileContent
.
getBytes
(
EncodingConfig
.
defaultCharset
));
outputStream
.
flush
();
}
logger
.
info
(
"File save successfully!"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
info
(
"save fileContent fail,fileName={}, content="
,
fileName
);
logger
.
info
(
"{}"
,
fileContent
);
}
}
public
void
createDir
(){
String
dateFormat
=
DateUtil
.
sampleDateFormatFormat
(
new
Date
());
File
fileDir
=
new
File
(
hubeiHistoryFilePath
+
dateFormat
+
File
.
separatorChar
);
if
(!
fileDir
.
exists
()||!
fileDir
.
isDirectory
()){
fileDir
.
mkdir
();
}
}
}
src/main/resources/config/local/financial_api.properties
View file @
2db08466
hubei.mail.touser
=
bo.wang@quantgroup.cn
hubei.history.filepath
=
E:/hubeitest/
log_dir
=
quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启
scheduled_trigger
=
scheduled_trigger
\ No newline at end of file
src/main/resources/config/release/financial_api.properties
View file @
2db08466
hubei.mail.touser
=
bo.wang@quantgroup.cn
hubei.history.filepath
=
/vpants/hubeifiles/
log_dir
=
quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启
scheduled_trigger
=
scheduled_trigger
\ No newline at end of file
src/main/resources/config/test/financial_api.properties
View file @
2db08466
hubei.mail.touser
=
bo.wang@quantgroup.cn
hubei.history.filepath
=
/home/results/
log_dir
=
quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启
scheduled_trigger
=
scheduled_trigger
\ No newline at end of file
src/test/java/cn/quantgroup/financial/service/HuBeiServiceTest.java
View file @
2db08466
...
...
@@ -88,7 +88,7 @@ public class HuBeiServiceTest {
public
void
testGetSendDisc
(){
//20170119_9009_T01.txt
try
{
huBeiService
.
handleDiscData
(
HubeiCFCDataType
.
SEND_DEBIT
,
null
,
null
,
new
Integer
(
1
).
byteValue
(),
"2017022
2
"
);
huBeiService
.
handleDiscData
(
HubeiCFCDataType
.
SEND_DEBIT
,
null
,
null
,
new
Integer
(
1
).
byteValue
(),
"2017022
4
"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
...
...
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