|
|
|
@ -13,8 +13,6 @@ import com.itextpdf.text.Image;
|
|
|
|
import com.itextpdf.text.PageSize;
|
|
|
|
import com.itextpdf.text.PageSize;
|
|
|
|
import com.itextpdf.text.pdf.*;
|
|
|
|
import com.itextpdf.text.pdf.*;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.tools.zip.ZipEntry;
|
|
|
|
|
|
|
|
import org.apache.tools.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -26,6 +24,8 @@ import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @ClassName BatchExportServiceImpl
|
|
|
|
* @ClassName BatchExportServiceImpl
|
|
|
|
@ -211,18 +211,13 @@ public class BatchExportServiceImpl implements BatchExportService {
|
|
|
|
return "没有任务";
|
|
|
|
return "没有任务";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response.reset();
|
|
|
|
response.reset();
|
|
|
|
//response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
|
|
|
response.setContentType("application/zip");
|
|
|
|
response.setContentType("application/zip");
|
|
|
|
ZipOutputStream zos = null;
|
|
|
|
|
|
|
|
BufferedOutputStream bos = null;
|
|
|
|
String zipName = "任务清单pdf压缩包";
|
|
|
|
ByteArrayOutputStream out = null;
|
|
|
|
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
BufferedInputStream bis = null;
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
|
|
|
|
try {
|
|
|
|
|
|
|
|
String zipName = "任务清单pdf压缩包";
|
|
|
|
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){
|
|
|
|
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
|
|
|
|
|
|
|
|
zos = new ZipOutputStream(response.getOutputStream());
|
|
|
|
|
|
|
|
bos = new BufferedOutputStream(zos);
|
|
|
|
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
for (ExportTaskDetailsVo list : taskList) {
|
|
|
|
for (ExportTaskDetailsVo list : taskList) {
|
|
|
|
//根据住院号出院日期查询需要导出病历路径
|
|
|
|
//根据住院号出院日期查询需要导出病历路径
|
|
|
|
@ -232,62 +227,40 @@ public class BatchExportServiceImpl implements BatchExportService {
|
|
|
|
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历找不到。");
|
|
|
|
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历找不到。");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//组织导出文件名
|
|
|
|
|
|
|
|
//fileName = exportFlieName(list);
|
|
|
|
|
|
|
|
out = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
Boolean aBoolean = imageToPdf1(filePathList, out, emrPdfWaterSet);
|
|
|
|
|
|
|
|
//Boolean aBoolean = imageToPdf(filePathList, fileName,exportPdfPath);
|
|
|
|
|
|
|
|
//为true时修改任务状态1完成2失败
|
|
|
|
|
|
|
|
if (aBoolean) {
|
|
|
|
|
|
|
|
exportTaskDetailsMapper.upStatc(1, list.getId());
|
|
|
|
|
|
|
|
String inpNo = list.getInpNo();
|
|
|
|
|
|
|
|
String dischargeDateTime = list.getDischargeDateTime();
|
|
|
|
|
|
|
|
//格式化日期
|
|
|
|
|
|
|
|
String disDateStr = dischargeDateTime.substring(0, 4) + dischargeDateTime.substring(5, 7) + dischargeDateTime.substring(8, 10);
|
|
|
|
|
|
|
|
String pdfNameStr = inpNo + "_" + disDateStr;
|
|
|
|
|
|
|
|
//每个文件名
|
|
|
|
|
|
|
|
String filePdfName = flieName + "_" + pdfNameStr;
|
|
|
|
|
|
|
|
zos.putNextEntry(new ZipEntry(filePdfName + ".pdf"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] file1 = out.toByteArray(); //这个zip文件的字节
|
|
|
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
|
|
|
bis = new BufferedInputStream(new ByteArrayInputStream(file1));
|
|
|
|
Boolean aBoolean = imageToPdf1(filePathList, out, emrPdfWaterSet);
|
|
|
|
//输出
|
|
|
|
//为true时修改任务状态1完成2失败
|
|
|
|
int len = 0;
|
|
|
|
if (aBoolean) {
|
|
|
|
byte[] buf = new byte[1024 * 1024];
|
|
|
|
exportTaskDetailsMapper.upStatc(1, list.getId());
|
|
|
|
while ((len = bis.read(buf, 0, buf.length)) != -1) {
|
|
|
|
String inpNo = list.getInpNo();
|
|
|
|
bos.write(buf, 0, len);
|
|
|
|
String dischargeDateTime = list.getDischargeDateTime();
|
|
|
|
|
|
|
|
//格式化日期
|
|
|
|
|
|
|
|
String disDateStr = dischargeDateTime.substring(0, 4) + dischargeDateTime.substring(5, 7) + dischargeDateTime.substring(8, 10);
|
|
|
|
|
|
|
|
String pdfNameStr = inpNo + "_" + disDateStr;
|
|
|
|
|
|
|
|
//每个文件名
|
|
|
|
|
|
|
|
String filePdfName = flieName + "_" + pdfNameStr;
|
|
|
|
|
|
|
|
zos.putNextEntry(new ZipEntry(filePdfName + ".pdf"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//byte[] file1 = out.toByteArray(); //这个zip文件的字节
|
|
|
|
|
|
|
|
//bis = new BufferedInputStream(new ByteArrayInputStream(file1));
|
|
|
|
|
|
|
|
try (BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(out.toByteArray()))) {
|
|
|
|
|
|
|
|
//输出
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
byte[] buf = new byte[1024 * 1024];
|
|
|
|
|
|
|
|
while ((len = bis.read(buf, 0, buf.length)) != -1) {
|
|
|
|
|
|
|
|
zos.write(buf, 0, len);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
exportTaskDetailsMapper.upStatc(2, list.getId());
|
|
|
|
|
|
|
|
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历保存失败。");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bis.close(); // 及时关闭流,避免资源泄露
|
|
|
|
|
|
|
|
out.reset(); // 重置ByteArrayOutputStream以便下次使用
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
exportTaskDetailsMapper.upStatc(2, list.getId());
|
|
|
|
|
|
|
|
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历保存失败。");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null != bis) {
|
|
|
|
|
|
|
|
bis.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null != bos) {
|
|
|
|
|
|
|
|
bos.flush();
|
|
|
|
|
|
|
|
bos.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null != out) {
|
|
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null != zos) {
|
|
|
|
|
|
|
|
zos.flush();
|
|
|
|
|
|
|
|
zos.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "下载完成";
|
|
|
|
return "下载完成";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|