|
|
|
|
@ -1110,66 +1110,108 @@ public class TemplateSearchController {
|
|
|
|
|
@RequestMapping(value = "downloadBloodZip", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public void downloadBloodZip(HttpServletResponse response, String patientIds, String flag) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNoneBlank(patientIds)) {
|
|
|
|
|
try {
|
|
|
|
|
List<ScanPathVo> scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, null, flag);
|
|
|
|
|
List<String> filePaths = new ArrayList<>();
|
|
|
|
|
// if (null != scanPathVos && !scanPathVos.isEmpty()) {
|
|
|
|
|
// for (int i = 0; i < scanPathVos.size(); i++) {
|
|
|
|
|
// String fileRealPath = scanPathVos.get(i).getFileRealPath();
|
|
|
|
|
// if(StringUtils.isNoneBlank(fileRealPath)){
|
|
|
|
|
// filePaths.add(fileRealPath);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// String zipName = "数字病案图片压缩包";
|
|
|
|
|
// downloadZip1(response,zipName,filePaths);
|
|
|
|
|
// }
|
|
|
|
|
if (null != scanPathVos && !scanPathVos.isEmpty()) {
|
|
|
|
|
// 创建临时路径,存放压缩文件
|
|
|
|
|
File file = new File("D:/tmp");
|
|
|
|
|
//查询保存文件目录是否存在
|
|
|
|
|
createFile(file);
|
|
|
|
|
// 压缩输出流,包装流,将临时文件输出流包装成压缩流,将所有文件输出到这里,打成zip包
|
|
|
|
|
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(file));
|
|
|
|
|
// 循环调用压缩文件方法,将一个一个需要下载的文件打入压缩文件包
|
|
|
|
|
for (int i = 0; i < scanPathVos.size(); i++) {
|
|
|
|
|
String fileRealPath = scanPathVos.get(i).getFileRealPath();
|
|
|
|
|
if(StringUtils.isNoneBlank(fileRealPath)){
|
|
|
|
|
Set<ScanPathForPatientListVo> list = new LinkedHashSet<>();
|
|
|
|
|
Set<String> patientIdSet = new LinkedHashSet<>();
|
|
|
|
|
//批量添加下载记录
|
|
|
|
|
printOrDownLoadInfoService.SimpleInsert(scanPathVos, null, Short.valueOf("2"));
|
|
|
|
|
for (ScanPathVo scanPathVo : scanPathVos) {
|
|
|
|
|
patientIdSet.add(scanPathVo.getPatientId());
|
|
|
|
|
}
|
|
|
|
|
for (String patinetId : patientIdSet) {
|
|
|
|
|
ScanPathForPatientListVo vo = new ScanPathForPatientListVo();
|
|
|
|
|
List<String> filePaths = new ArrayList<>();
|
|
|
|
|
for (ScanPathVo scanPathVo : scanPathVos) {
|
|
|
|
|
if (scanPathVo.getPatientId().equals(patinetId)) {
|
|
|
|
|
vo.setName(scanPathVo.getName());
|
|
|
|
|
vo.setInpatientNo(scanPathVo.getInpatientNo());
|
|
|
|
|
String disDate = scanPathVo.getDisDate();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
vo.setDisDate(sdf.parse(disDate));
|
|
|
|
|
String fileRealPath = scanPathVo.getFileRealPath();
|
|
|
|
|
if (StringUtils.isNoneBlank(fileRealPath) && new File(fileRealPath).exists()) {
|
|
|
|
|
filePaths.add(fileRealPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (String path : filePaths) {
|
|
|
|
|
// 该方法在下面定义
|
|
|
|
|
fileToZip(path, zipOut);
|
|
|
|
|
}
|
|
|
|
|
// 压缩完成后,关闭压缩流
|
|
|
|
|
zipOut.close();
|
|
|
|
|
|
|
|
|
|
//拼接下载默认名称并转为ISO-8859-1格式
|
|
|
|
|
String fileName = new String(("我的压缩文件.zip").getBytes(),"ISO-8859-1");
|
|
|
|
|
response.setHeader("Content-Disposition", "attchment;filename="+fileName);
|
|
|
|
|
|
|
|
|
|
//该流不可以手动关闭,手动关闭下载会出问题,下载完成后会自动关闭
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
FileInputStream inputStream = new FileInputStream("D:/tmp");
|
|
|
|
|
// 如果是SpringBoot框架,在这个路径
|
|
|
|
|
// org.apache.tomcat.util.http.fileupload.IOUtils产品
|
|
|
|
|
// 否则需要自主引入apache的 commons-io依赖
|
|
|
|
|
// copy方法为文件复制,在这里直接实现了下载效果
|
|
|
|
|
IOUtils.copy(inputStream, outputStream);
|
|
|
|
|
|
|
|
|
|
// 关闭输入流
|
|
|
|
|
inputStream.close();
|
|
|
|
|
|
|
|
|
|
//下载完成之后,删掉这个zip包
|
|
|
|
|
File fileTempZip = new File("D:/tmp");
|
|
|
|
|
fileTempZip.delete();
|
|
|
|
|
if (!filePaths.isEmpty()) {
|
|
|
|
|
vo.setScanPathList(filePaths);
|
|
|
|
|
list.add(vo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String zipName = "档案pdf压缩包";
|
|
|
|
|
downloadPdfZip(response, zipName, list);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//以前的方法
|
|
|
|
|
// if (StringUtils.isNoneBlank(patientIds)) {
|
|
|
|
|
// try {
|
|
|
|
|
// List<ScanPathVo> scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, null, flag);
|
|
|
|
|
// List<String> filePaths = new ArrayList<>();
|
|
|
|
|
//// if (null != scanPathVos && !scanPathVos.isEmpty()) {
|
|
|
|
|
//// for (int i = 0; i < scanPathVos.size(); i++) {
|
|
|
|
|
//// String fileRealPath = scanPathVos.get(i).getFileRealPath();
|
|
|
|
|
//// if(StringUtils.isNoneBlank(fileRealPath)){
|
|
|
|
|
//// filePaths.add(fileRealPath);
|
|
|
|
|
//// }
|
|
|
|
|
//// }
|
|
|
|
|
//// String zipName = "数字病案图片压缩包";
|
|
|
|
|
//// downloadZip1(response,zipName,filePaths);
|
|
|
|
|
//// }
|
|
|
|
|
// if (null != scanPathVos && !scanPathVos.isEmpty()) {
|
|
|
|
|
// // 创建临时路径,存放压缩文件
|
|
|
|
|
// File file = new File("D:/tmp");
|
|
|
|
|
// //查询保存文件目录是否存在
|
|
|
|
|
// createFile(file);
|
|
|
|
|
// // 压缩输出流,包装流,将临时文件输出流包装成压缩流,将所有文件输出到这里,打成zip包
|
|
|
|
|
// ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(file));
|
|
|
|
|
// // 循环调用压缩文件方法,将一个一个需要下载的文件打入压缩文件包
|
|
|
|
|
// for (int i = 0; i < scanPathVos.size(); i++) {
|
|
|
|
|
// String fileRealPath = scanPathVos.get(i).getFileRealPath();
|
|
|
|
|
// if(StringUtils.isNoneBlank(fileRealPath)){
|
|
|
|
|
// filePaths.add(fileRealPath);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// for (String path : filePaths) {
|
|
|
|
|
// // 该方法在下面定义
|
|
|
|
|
// fileToZip(path, zipOut);
|
|
|
|
|
// }
|
|
|
|
|
// // 压缩完成后,关闭压缩流
|
|
|
|
|
// zipOut.close();
|
|
|
|
|
//
|
|
|
|
|
// //拼接下载默认名称并转为ISO-8859-1格式
|
|
|
|
|
// String fileName = new String(("我的压缩文件.zip").getBytes(),"ISO-8859-1");
|
|
|
|
|
// response.setHeader("Content-Disposition", "attchment;filename="+fileName);
|
|
|
|
|
//
|
|
|
|
|
// //该流不可以手动关闭,手动关闭下载会出问题,下载完成后会自动关闭
|
|
|
|
|
// ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
// FileInputStream inputStream = new FileInputStream("D:/tmp");
|
|
|
|
|
// // 如果是SpringBoot框架,在这个路径
|
|
|
|
|
// // org.apache.tomcat.util.http.fileupload.IOUtils产品
|
|
|
|
|
// // 否则需要自主引入apache的 commons-io依赖
|
|
|
|
|
// // copy方法为文件复制,在这里直接实现了下载效果
|
|
|
|
|
// IOUtils.copy(inputStream, outputStream);
|
|
|
|
|
//
|
|
|
|
|
// // 关闭输入流
|
|
|
|
|
// inputStream.close();
|
|
|
|
|
//
|
|
|
|
|
// //下载完成之后,删掉这个zip包
|
|
|
|
|
// File fileTempZip = new File("D:/tmp");
|
|
|
|
|
// fileTempZip.delete();
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// ExceptionPrintUtil.printException(e);
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void createFile(File file) {
|
|
|
|
|
@ -1277,7 +1319,7 @@ public class TemplateSearchController {
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
ZipOutputStream zos = null;
|
|
|
|
|
BufferedOutputStream bos = null;
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
ByteArrayOutputStream out = null;
|
|
|
|
|
BufferedInputStream bis = null;
|
|
|
|
|
try {
|
|
|
|
|
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
|
@ -1296,12 +1338,13 @@ public class TemplateSearchController {
|
|
|
|
|
String fileName = vo.getInpatientNo().trim() + "-" + vo.getName().trim() + "-" + disDate.trim() + "_" + fmt.format(new Date());
|
|
|
|
|
zos.putNextEntry(new ZipEntry(fileName + ".pdf"));
|
|
|
|
|
//合成pdf
|
|
|
|
|
out = new ByteArrayOutputStream();
|
|
|
|
|
img2PdfUtil.imageToPdfToBuffOut(out, scanPathList, emrPdfWaterSet);
|
|
|
|
|
byte[] file = out.toByteArray(); //这个zip文件的字节
|
|
|
|
|
bis = new BufferedInputStream(new ByteArrayInputStream(file));
|
|
|
|
|
//输出
|
|
|
|
|
int len = 0;
|
|
|
|
|
byte[] buf = new byte[10 * 1024];
|
|
|
|
|
byte[] buf = new byte[1024 * 1024];
|
|
|
|
|
while ((len = bis.read(buf, 0, buf.length)) != -1) {
|
|
|
|
|
bos.write(buf, 0, len);
|
|
|
|
|
}
|
|
|
|
|
|