|
|
@ -203,7 +203,44 @@ public class EamObjectServiceImpl implements EamObjectService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void downLoadObjectFile(Integer id,String orderRef3, HttpServletResponse response) throws UnsupportedEncodingException { |
|
|
|
|
|
|
|
|
public void downLoadObjectFile(Integer id, HttpServletResponse response) throws UnsupportedEncodingException { |
|
|
|
|
|
//处理路径和名称 |
|
|
|
|
|
List<SysOssEntity> getFileData = eamObjectMapper.getFileData(id); |
|
|
|
|
|
if (getFileData.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("该文件不存在,请刷新列表"); |
|
|
|
|
|
} |
|
|
|
|
|
File file = new File(getFileData.get(0).getUrl()); |
|
|
|
|
|
//读取缓存1kb |
|
|
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
|
|
FileInputStream fis = null; |
|
|
|
|
|
BufferedInputStream bis = null; |
|
|
|
|
|
FileOutputStream fos = null; |
|
|
|
|
|
BufferedOutputStream bos = null; |
|
|
|
|
|
response.setContentType("application/force-download;charset=utf-8"); |
|
|
|
|
|
response.setHeader("Content-disposition", "attachment; filename=" + new String(getFileData.get(0).getFileName().getBytes("gbk"), "iso8859-1")); |
|
|
|
|
|
try { |
|
|
|
|
|
//读取文件 |
|
|
|
|
|
fis = new FileInputStream(file); |
|
|
|
|
|
//加缓存 |
|
|
|
|
|
bis = new BufferedInputStream(fis); |
|
|
|
|
|
//开始读取 |
|
|
|
|
|
int i = bis.read(buffer); |
|
|
|
|
|
//设置输出流 |
|
|
|
|
|
ServletOutputStream os = response.getOutputStream(); |
|
|
|
|
|
//开始循环读取 |
|
|
|
|
|
while (i != -1) { |
|
|
|
|
|
os.write(buffer, 0, i); |
|
|
|
|
|
i = bis.read(buffer); |
|
|
|
|
|
} |
|
|
|
|
|
fis.close(); |
|
|
|
|
|
fos.close(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void downLoadObjectFile2(Integer id,String orderRef3, HttpServletResponse response) throws UnsupportedEncodingException { |
|
|
//处理路径和名称 |
|
|
//处理路径和名称 |
|
|
if (orderRef3 == null){ |
|
|
if (orderRef3 == null){ |
|
|
orderRef3 = "9.9"; |
|
|
orderRef3 = "9.9"; |
|
|
|