|
|
|
@ -1130,7 +1130,7 @@ public class TemplateSearchController {
|
|
|
|
@OptionalLog(module = "下载图片转换pdf压缩包", methods = "病案查询页面")
|
|
|
|
@OptionalLog(module = "下载图片转换pdf压缩包", methods = "病案查询页面")
|
|
|
|
@RequestMapping(value = "downloadBloodZip", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
|
|
|
|
@RequestMapping(value = "downloadBloodZip", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public void downloadBloodZip(HttpServletResponse response, String patientIds, String flag) {
|
|
|
|
public void downloadBloodZip(HttpServletResponse response, String patientIds, String flag, String dataSource) {
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNoneBlank(patientIds)) {
|
|
|
|
if (StringUtils.isNoneBlank(patientIds)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -1150,9 +1150,12 @@ public class TemplateSearchController {
|
|
|
|
if (scanPathVo.getPatientId().equals(patinetId)) {
|
|
|
|
if (scanPathVo.getPatientId().equals(patinetId)) {
|
|
|
|
vo.setName(scanPathVo.getName());
|
|
|
|
vo.setName(scanPathVo.getName());
|
|
|
|
vo.setInpatientNo(scanPathVo.getInpatientNo());
|
|
|
|
vo.setInpatientNo(scanPathVo.getInpatientNo());
|
|
|
|
|
|
|
|
vo.setSubjectNo(scanPathVo.getSubjectNo());
|
|
|
|
String disDate = scanPathVo.getDisDate();
|
|
|
|
String disDate = scanPathVo.getDisDate();
|
|
|
|
|
|
|
|
if(!ObjectUtils.isEmpty(disDate)){
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
vo.setDisDate(sdf.parse(disDate));
|
|
|
|
vo.setDisDate(sdf.parse(disDate));
|
|
|
|
|
|
|
|
}
|
|
|
|
String fileRealPath = scanPathVo.getFileRealPath();
|
|
|
|
String fileRealPath = scanPathVo.getFileRealPath();
|
|
|
|
if (StringUtils.isNoneBlank(fileRealPath) && new File(fileRealPath).exists()) {
|
|
|
|
if (StringUtils.isNoneBlank(fileRealPath) && new File(fileRealPath).exists()) {
|
|
|
|
filePaths.add(fileRealPath);
|
|
|
|
filePaths.add(fileRealPath);
|
|
|
|
@ -1165,7 +1168,7 @@ public class TemplateSearchController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String zipName = "档案pdf压缩包";
|
|
|
|
String zipName = "档案pdf压缩包";
|
|
|
|
downloadPdfZip(response, zipName, list);
|
|
|
|
downloadPdfZip(response, zipName, list, dataSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
@ -1335,66 +1338,50 @@ public class TemplateSearchController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装下载pdf压缩包方法
|
|
|
|
//封装下载pdf压缩包方法
|
|
|
|
private void downloadPdfZip(HttpServletResponse response, String zipName, Set<ScanPathForPatientListVo> list) {
|
|
|
|
private void downloadPdfZip(HttpServletResponse response, String zipName, Set<ScanPathForPatientListVo> list, String dataSource) throws UnsupportedEncodingException {
|
|
|
|
response.reset();
|
|
|
|
response.reset();
|
|
|
|
response.setContentType("application/zip;charset=UTF-8");
|
|
|
|
response.setContentType("application/zip;charset=UTF-8");
|
|
|
|
ZipOutputStream zos = null;
|
|
|
|
|
|
|
|
BufferedOutputStream bos = null;
|
|
|
|
|
|
|
|
ByteArrayOutputStream out = null;
|
|
|
|
|
|
|
|
BufferedInputStream bis = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
|
|
|
|
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");
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
|
|
|
|
zos = new ZipOutputStream(response.getOutputStream());
|
|
|
|
String filePdfName = "";
|
|
|
|
bos = new BufferedOutputStream(zos);
|
|
|
|
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
for (ScanPathForPatientListVo vo : list) {
|
|
|
|
for (ScanPathForPatientListVo vo : list) {
|
|
|
|
String disDate = "";
|
|
|
|
String disDate = "无";
|
|
|
|
if (null != vo.getDisDate()) {
|
|
|
|
if (!ObjectUtils.isEmpty(vo.getDisDate())) {
|
|
|
|
disDate = fmt.format(vo.getDisDate());
|
|
|
|
disDate = fmt.format(vo.getDisDate());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<String> scanPathList = vo.getScanPathList();
|
|
|
|
List<String> scanPathList = vo.getScanPathList();
|
|
|
|
|
|
|
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
|
|
|
//每个文件名
|
|
|
|
//每个文件名
|
|
|
|
String fileName = vo.getInpatientNo().trim() + "-" + vo.getName().trim() + "-" + disDate.trim() + "_" + fmt.format(new Date());
|
|
|
|
String inpatientNo = ObjectUtils.isEmpty(vo.getInpatientNo()) ? "无" : vo.getInpatientNo().trim();
|
|
|
|
|
|
|
|
String name = ObjectUtils.isEmpty(vo.getName()) ? "无" : vo.getName().trim();
|
|
|
|
|
|
|
|
if("3".equals(dataSource)){
|
|
|
|
|
|
|
|
//药学楼
|
|
|
|
|
|
|
|
filePdfName = vo.getSubjectNo().trim() + "-" + name + "_" + fmt.format(new Date());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
filePdfName = inpatientNo + "-" + name + "-" + disDate.trim() + "_" + fmt.format(new Date());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String fileName = hospitaInfo + "_" + filePdfName;
|
|
|
|
zos.putNextEntry(new ZipEntry(fileName + ".pdf"));
|
|
|
|
zos.putNextEntry(new ZipEntry(fileName + ".pdf"));
|
|
|
|
//合成pdf
|
|
|
|
//合成pdf
|
|
|
|
out = new ByteArrayOutputStream();
|
|
|
|
|
|
|
|
img2PdfUtil.imageToPdfToBuffOut(out, scanPathList, emrPdfWaterSet);
|
|
|
|
img2PdfUtil.imageToPdfToBuffOut(out, scanPathList, emrPdfWaterSet);
|
|
|
|
byte[] file = out.toByteArray(); //这个zip文件的字节
|
|
|
|
try (BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(out.toByteArray()))) {
|
|
|
|
bis = new BufferedInputStream(new ByteArrayInputStream(file));
|
|
|
|
|
|
|
|
//输出
|
|
|
|
//输出
|
|
|
|
int len = 0;
|
|
|
|
int len = 0;
|
|
|
|
byte[] buf = new byte[1024 * 1024];
|
|
|
|
byte[] buf = new byte[1024 * 1024];
|
|
|
|
while ((len = bis.read(buf, 0, buf.length)) != -1) {
|
|
|
|
while ((len = bis.read(buf, 0, buf.length)) != -1) {
|
|
|
|
bos.write(buf, 0, len);
|
|
|
|
zos.write(buf, 0, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bis.close(); // 及时关闭流,避免资源泄露
|
|
|
|
|
|
|
|
out.reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (null != bos) {
|
|
|
|
|
|
|
|
bos.flush();
|
|
|
|
|
|
|
|
bos.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (null != bis) {
|
|
|
|
|
|
|
|
bis.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
if (null != zos) {
|
|
|
|
|
|
|
|
zos.flush();
|
|
|
|
|
|
|
|
zos.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -1560,8 +1547,8 @@ public class TemplateSearchController {
|
|
|
|
JSONObject jsonObject= (JSONObject) JSONObject.toJSON(scanPathVo);
|
|
|
|
JSONObject jsonObject= (JSONObject) JSONObject.toJSON(scanPathVo);
|
|
|
|
List<String> patientInfoList = Arrays.asList(patientInfo.split(","));
|
|
|
|
List<String> patientInfoList = Arrays.asList(patientInfo.split(","));
|
|
|
|
for (String list:patientInfoList){
|
|
|
|
for (String list:patientInfoList){
|
|
|
|
String contents = jsonObject.getString(list).trim();
|
|
|
|
String contents = ObjectUtils.isEmpty(jsonObject.getString(list)) ? "无" : jsonObject.getString(list).trim();
|
|
|
|
if (list.equals("disDate")){
|
|
|
|
if ("disDate".equals(list) && !ObjectUtils.isEmpty(jsonObject.getString(list))){
|
|
|
|
String dateString = jsonObject.getString(list);
|
|
|
|
String dateString = jsonObject.getString(list);
|
|
|
|
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|