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
2 years ago
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 {
...
@@ -1706,6 +1706,7 @@ public class InsureContorll {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Object
>
replaceUserPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"policyId"
)
Integer
policyId
){
public
Result
<
Object
>
replaceUserPolicy
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"policyId"
)
Integer
policyId
){
InsurePolicy
insurePolicy
=
InsurePolicy
.
builder
().
id
(
policyId
).
build
().
selectById
();
InsurePolicy
insurePolicy
=
InsurePolicy
.
builder
().
id
(
policyId
).
build
().
selectById
();
ByteArrayOutputStream
bos
=
null
;
try
{
try
{
XSSFWorkbook
xw
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFWorkbook
xw
=
new
XSSFWorkbook
(
file
.
getInputStream
());
XSSFSheet
sheetAt
=
xw
.
getSheetAt
(
0
);
XSSFSheet
sheetAt
=
xw
.
getSheetAt
(
0
);
...
@@ -1825,11 +1826,11 @@ public class InsureContorll {
...
@@ -1825,11 +1826,11 @@ public class InsureContorll {
}
}
}
}
/*上传替换文件到保司服务器*/
/*上传替换文件到保司服务器*/
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
bos
=
new
ByteArrayOutputStream
();
/*保司返回地址*/
/*保司返回地址*/
String
url
=
""
;
String
url
=
""
;
xw
.
write
(
b
yteArrayOutputStream
);
xw
.
write
(
b
os
);
byte
[]
bytes
=
b
yteArrayOutputStream
.
toByteArray
();
byte
[]
bytes
=
b
os
.
toByteArray
();
String
fileBase64
=
Base64
.
byteArrayToBase64
(
bytes
);
String
fileBase64
=
Base64
.
byteArrayToBase64
(
bytes
);
/*body参数 begin*/
/*body参数 begin*/
Map
bodyMap
=
Maps
.
newHashMap
();
Map
bodyMap
=
Maps
.
newHashMap
();
...
@@ -1842,16 +1843,21 @@ public class InsureContorll {
...
@@ -1842,16 +1843,21 @@ public class InsureContorll {
Object
o
=
dataMap
.
get
(
"data"
);
Object
o
=
dataMap
.
get
(
"data"
);
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
o
));
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
o
));
url
=
map
.
get
(
"file_url"
).
toString
();
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
)
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
)
.
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
();
.
returnCode
(
dataMap
.
get
(
"errcode"
).
toString
()).
returnMsg
(
dataMap
.
get
(
"errmsg"
).
toString
()).
fileUrl
(
url
).
build
().
insert
();
/*替换逻辑*/
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
throw
new
CustomException
(
"导入异常"
);
throw
new
CustomException
(
"导入异常"
);
}
finally
{
try
{
bos
.
close
();
}
catch
(
IOException
e
)
{
throw
new
CustomException
(
"ByteArrayOutputStream流关闭异常"
);
}
}
}
return
ResultUtil
.
success
();
return
ResultUtil
.
success
();
}
}
...
...
This diff is collapsed.
Click to expand it.
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