Commit 4e8da25d by 翁国栋

8小时后台--

ByteArrayOutputStream没关闭
parent a297762d
...@@ -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(byteArrayOutputStream); xw.write(bos);
byte[] bytes = byteArrayOutputStream.toByteArray(); byte[] bytes = bos.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();
} }
......
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