From eea3a023a88354fb1842347f733e716f0cd76f1e Mon Sep 17 00:00:00 2001 From: "jian.wang" <824612544@qq.com> Date: Tue, 14 May 2024 09:18:18 +0800 Subject: [PATCH] =?UTF-8?q?bug=EF=BC=9A=E4=BF=AE=E6=94=B9pdf=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E7=A9=BA=E7=99=BD=E5=92=8C=E5=9B=BE=E5=83=8F=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=95=8C=E9=9D=A2=E4=B8=8A=E6=96=B0=E5=A2=9E=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=9B=BE=E5=83=8F=E4=B8=8A=E4=BC=A0=E6=8A=A5=E9=94=99?= =?UTF-8?q?=20bug=EF=BC=9A=E6=9F=A5=E8=AF=A2=E5=88=97=E8=A1=A8=E6=8A=8A?= =?UTF-8?q?=E7=9B=98=E5=8F=B7=E6=94=BE=E7=97=85=E6=A1=88=E5=8F=B7=E5=89=8D?= =?UTF-8?q?=20bug=EF=BC=9A=E4=B8=8B=E8=BD=BD=E5=90=AF=E7=94=A8=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=B0=B4=E5=8D=B0=E8=AE=BE=E7=BD=AE=E4=B8=BA=E5=90=A6?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E6=98=AF=E4=B8=8B=E8=BD=BD=E7=9A=84pdf?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E6=9C=89=E6=B0=B4=E5=8D=B0=EF=BC=8C=E8=AF=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=A0=E6=95=88=20bug:=E5=A7=93=E5=90=8D?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2:=E4=B8=8D=E8=83=BD=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=A8=A1=E7=B3=8A=E6=9F=A5=E8=AF=A2=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=87=AA=E9=80=89=EF=BC=8C=E5=89=8D=E4=B8=AD=E5=90=8E=E5=9D=87?= =?UTF-8?q?=E5=8F=AF=E6=A8=A1=E7=B3=8A=E6=9F=A5=E8=AF=A2=20bug:=E7=97=85?= =?UTF-8?q?=E6=A1=88=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?:=E7=97=85=E6=A1=88=E5=8F=B7=20=E5=A7=93=E5=90=8D=20=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=20=E5=87=BA=E9=99=A2=E6=97=A5=E6=9C=9F=20=E4=B8=BB?= =?UTF-8?q?=E8=A6=81=E8=AF=8A=E6=96=AD=E5=90=8D=E7=A7=B0=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8F=AF=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A0=B9=E6=8D=AE=E6=9D=83=E9=99=90=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20bug:=E7=97=85=E4=BE=8B=E5=9B=BE=E5=83=8F?= =?UTF-8?q?=E8=B6=85=E8=BF=87300=E5=A4=9A=E9=A1=B5=E5=B0=B1=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=8B=E8=BD=BD=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TemplateSearchController.java | 145 ++++++++++++------ src/main/java/com/emr/util/imgToPdfUtil.java | 23 +-- .../commomSearch/commomListqf.jsp | 4 +- .../commomSearch/showRecordIframeBlood.jsp | 2 +- .../commomSearch/showRecordIframeBlood.js | 44 +++--- .../templateSearch/searchCommomMethodqf.js | 18 ++- src/main/webapp/static/pdfjs/Print.js | 1 + src/main/webapp/static/pdfjs/web/viewer2.html | 21 +-- 8 files changed, 162 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java index d08a75d..1dc36ac 100644 --- a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java +++ b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java @@ -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 scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, null, flag); - List 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); + Set list = new LinkedHashSet<>(); + Set patientIdSet = new LinkedHashSet<>(); + //批量添加下载记录 + printOrDownLoadInfoService.SimpleInsert(scanPathVos, null, Short.valueOf("2")); + for (ScanPathVo scanPathVo : scanPathVos) { + patientIdSet.add(scanPathVo.getPatientId()); } - // 压缩完成后,关闭压缩流 - 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(); + for (String patinetId : patientIdSet) { + ScanPathForPatientListVo vo = new ScanPathForPatientListVo(); + List 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); + } + } + } + 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 scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, null, flag); +// List 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); } diff --git a/src/main/java/com/emr/util/imgToPdfUtil.java b/src/main/java/com/emr/util/imgToPdfUtil.java index d50e770..ac00004 100644 --- a/src/main/java/com/emr/util/imgToPdfUtil.java +++ b/src/main/java/com/emr/util/imgToPdfUtil.java @@ -7,6 +7,7 @@ import com.itextpdf.text.*; import com.itextpdf.text.pdf.*; import com.twelvemonkeys.imageio.metadata.tiff.IFD; import org.apache.commons.lang3.StringUtils; +import org.springframework.util.ObjectUtils; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; @@ -85,16 +86,18 @@ public class imgToPdfUtil { // 添加图片到PDF for (int i = 0; i < scanPathVos.size(); i++) { String assortName = scanPathVos.get(i).getAssortName(); - if (StringUtils.isNotBlank(lastOutline) && lastOutline.equals(assortName)) { - outFlag = false; - } - if (StringUtils.isBlank(lastOutline)) { - lastOutline = assortName; - outFlag=true; - } - if (!lastOutline.equals(assortName)){ - lastOutline = assortName; - outFlag=true; + if(!ObjectUtils.isEmpty(assortName)){ + if (StringUtils.isNotBlank(lastOutline) && lastOutline.equals(assortName)) { + outFlag = false; + } + if (StringUtils.isBlank(lastOutline)) { + lastOutline = assortName; + outFlag=true; + } + if (!lastOutline.equals(assortName)){ + lastOutline = assortName; + outFlag=true; + } } String imagePath = scanPathVos.get(i).getFileRealPath(); Image image = Image.getInstance(imagePath); diff --git a/src/main/webapp/WEB-INF/views/recordManage/commomSearch/commomListqf.jsp b/src/main/webapp/WEB-INF/views/recordManage/commomSearch/commomListqf.jsp index e7bff39..1096a82 100644 --- a/src/main/webapp/WEB-INF/views/recordManage/commomSearch/commomListqf.jsp +++ b/src/main/webapp/WEB-INF/views/recordManage/commomSearch/commomListqf.jsp @@ -215,13 +215,13 @@ + value="盘号,病案号,ID号,住院次数,姓名,性别,年龄_岁,年龄_月,入院日期,出院日期,出院科室,联系地址,主诊ICD码,主诊名称,主诊转归,住院天数,主治医生,其他诊断,病理诊断,损伤中毒,是否有手术,病案备注"> + value="ph,inpatientNo,admissId,admissTimes,name,sex,age,ageMonth,admissDate,disDate,disDept,homeAddr,mainDiagCode,mainDiagName,mainDisThing,admissDays,attending,otherDiagName,pathologyName,poisoningName,isOper,memo"> diff --git a/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp b/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp index 69f7421..49e9c12 100644 --- a/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp +++ b/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp @@ -265,6 +265,6 @@ src="${path}/static/js/recordManage/commomSearch/showRecordIframeBloodCommom.js"> + src="${path}/static/pdfjs/web/viewer2.js"> diff --git a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js index 542498f..0d84cf8 100644 --- a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js +++ b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js @@ -48,6 +48,10 @@ var menu = { $("#assortIds").val(scanPages); sources = sources.substring(0, sources.length - 1); $("#sources").val(sources); + }else{ + if(data[1] != undefined ){ + scanPages = data[1].assortName; + } } $.fn.zTree.init($("#ztree"), menu.setting, data); zTree = $.fn.zTree.getZTreeObj("ztree"); @@ -209,26 +213,26 @@ function selectPrintPic(patientId, rootPaths, scanPages, sources) { } }) //查询进度定时器 - var interval1 = setInterval(function () { - $.ajax({ - type: 'get', - url: path + "/commom/getPrintPicLoading", - data: {patientId: $("#patientId").val()}, - dataType: 'json', - success: function (data) { - if (data.code == 0) { - var value = data.data; - $("#loading").val(value + "%"); - if (value == 100) { - //杀死进度定时器 - clearInterval(interval1); - } - } else { - toastr.error(data.msg); - } - } - }) - }, 100000); + // var interval1 = setInterval(function () { + // $.ajax({ + // type: 'get', + // url: path + "/commom/getPrintPicLoading", + // data: {patientId: $("#patientId").val()}, + // dataType: 'json', + // success: function (data) { + // if (data.code == 0) { + // var value = data.data; + // $("#loading").val(value + "%"); + // if (value == 100) { + // //杀死进度定时器 + // clearInterval(interval1); + // } + // } else { + // toastr.error(data.msg); + // } + // } + // }) + // }, 100); } function selectPrintPic2(patientId, scanPages, sources) { diff --git a/src/main/webapp/static/js/recordManage/templateSearch/searchCommomMethodqf.js b/src/main/webapp/static/js/recordManage/templateSearch/searchCommomMethodqf.js index d36b4e2..162fedd 100644 --- a/src/main/webapp/static/js/recordManage/templateSearch/searchCommomMethodqf.js +++ b/src/main/webapp/static/js/recordManage/templateSearch/searchCommomMethodqf.js @@ -338,7 +338,14 @@ function exportExcel() { checks = checks.substring(0, checks.length - 1); var whereSql = ' WHERE ' + commomtable + '.patient_id IN (' + checks + ')'; var url = path + "/template/exportExcel"; - post(url, {"selectSql": $("#englishFields").val(),"fromTableSql":$("#fromTableSql").val(),"whereSql":whereSql,"tableThNames": tableThNames,orderBys:$("#orderBys").val(), "fieldCns": fieldCns}); + post(url, { + "selectSql": $("#englishFields").val(), + "fromTableSql": $("#fromTableSql").val(), + "whereSql": whereSql, + "tableThNames": tableThNames, + orderBys: $("#orderBys").val(), + "fieldCns": fieldCns + }); } else { Common.confirm({ title: "提示", @@ -346,7 +353,14 @@ function exportExcel() { operate: function (reselt) { if (reselt) { var url = path + "/template/exportExcel"; - post(url, {"selectSql": $("#englishFields").val(),"fromTableSql":$("#fromTableSql").val(),"whereSql":$("#whereSql").val(),"orderBys":$("#orderBys").val(),"tableThNames": tableThNames, "fieldCns": fieldCns}); + post(url, { + "selectSql": $("#englishFields").val(), + "fromTableSql": $("#fromTableSql").val(), + "whereSql": $("#whereSql").val(), + "orderBys": $("#orderBys").val(), + "tableThNames": tableThNames, + "fieldCns": fieldCns + }); } } }) diff --git a/src/main/webapp/static/pdfjs/Print.js b/src/main/webapp/static/pdfjs/Print.js index 31f8a14..6f7161b 100644 --- a/src/main/webapp/static/pdfjs/Print.js +++ b/src/main/webapp/static/pdfjs/Print.js @@ -25,6 +25,7 @@ Print.prototype = { init: function () { var content = this.getStyle() + this.getHtml(); + console.log("------------------------------32131232132132131------------------------------", this.getHtml()) this.writeIframe(content); }, extend: function (obj, obj2) { diff --git a/src/main/webapp/static/pdfjs/web/viewer2.html b/src/main/webapp/static/pdfjs/web/viewer2.html index 849434e..a43b346 100644 --- a/src/main/webapp/static/pdfjs/web/viewer2.html +++ b/src/main/webapp/static/pdfjs/web/viewer2.html @@ -538,16 +538,17 @@ http://sourceforge.net/adobe/cmap/wiki/License/ $("#printLoading").show(); } }) - var getLoadingInterval = setInterval(function () { - //获取打印预览图片加载进度 - var loading = parent.$("#loading").val(); - $(".progress-bar").css("width",loading); - $("#printLoading p").text(loading); - //加载完退出定时 - if(loading == '100%'){ - clearInterval(getLoadingInterval); - } - },100); + // var getLoadingInterval = setInterval(function () { + // //获取打印预览图片加载进度 + // var loading = parent.$("#loading").val(); + // console.log("获取打印预览图片加载进度",loading) + // $(".progress-bar").css("width",loading); + // $("#printLoading p").text(loading); + // //加载完退出定时 + // if(loading == '100%'){ + // clearInterval(getLoadingInterval); + // } + // },100);