Commit 4e8da25d by 翁国栋

8小时后台--

ByteArrayOutputStream没关闭
parent a297762d
......@@ -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(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
xw.write(bos);
byte[] bytes = bos.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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment