Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
4e8da25d
Commit
4e8da25d
authored
Jun 30, 2022
by
翁国栋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8小时后台--
ByteArrayOutputStream没关闭
parent
a297762d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
+13
-7
No files found.
src/main/java/cn/timer/api/controller/insure/InsureContorll.java
View file @
4e8da25d
...
...
@@ -1706,6 +1706,7 @@ public class InsureContorll {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Object
>
replaceUserPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"policyId"
)
Integer
policyId
){
InsurePolicy
insurePolicy
=
InsurePolicy
.
builder
().
id
(
policyId
).
build
().
selectById
();
ByteArrayOutputStream
bos
=
null
;
try
{
XSSFWorkbook
xw
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFSheet
sheetAt
=
xw
.
getSheetAt
(
0
);
...
...
@@ -1825,11 +1826,11 @@ public class InsureContorll {
}
}
/*上传替换文件到保司服务器*/
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
bos
=
new
ByteArrayOutputStream
();
/*保司返回地址*/
String
url
=
""
;
xw
.
write
(
b
yteArrayOutputStream
);
byte
[]
bytes
=
b
yteArrayOutputStream
.
toByteArray
();
xw
.
write
(
b
os
);
byte
[]
bytes
=
b
os
.
toByteArray
();
String
fileBase64
=
Base64
.
byteArrayToBase64
(
bytes
);
/*body参数 begin*/
Map
bodyMap
=
Maps
.
newHashMap
();
...
...
@@ -1842,16 +1843,21 @@ public class InsureContorll {
Object
o
=
dataMap
.
get
(
"data"
);
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
o
));
url
=
map
.
get
(
"file_url"
).
toString
();
if
(
StringUtils
.
isNullOrEmpty
(
url
)||
url
==
"error"
){
return
ResultUtil
.
error
(
"上传文件路径异常"
);
}
}
InsureLog
.
builder
().
requestParam
(
JSONObject
.
toJSONString
(
setParams
(
JSONObject
.
toJSONString
(
bodyMap
),
appidq
,
secretq
))).
type
(
6
)
.
requestData
(
JSONObject
.
toJSONString
(
bodyMap
)).
createTime
(
new
Date
()).
requestType
(
1
).
returnBody
(
data
).
requestPath
(
uploadUrl2
)
.
returnCode
(
dataMap
.
get
(
"errcode"
).
toString
()).
returnMsg
(
dataMap
.
get
(
"errmsg"
).
toString
()).
fileUrl
(
url
).
build
().
insert
();
/*替换逻辑*/
}
catch
(
Exception
e
){
throw
new
CustomException
(
"导入异常"
);
}
finally
{
try
{
bos
.
close
();
}
catch
(
IOException
e
)
{
throw
new
CustomException
(
"ByteArrayOutputStream流关闭异常"
);
}
}
return
ResultUtil
.
success
();
}
...
...
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