diff --git a/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java b/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java index 2133b2b..9346da9 100644 --- a/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java +++ b/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON; import com.emr.annotation.OptionalLog; import com.emr.dao.*; import com.emr.dao.approve.Emr_Apply_ApproveMapper; +import com.emr.dao.emrPdfWaterSet.EmrPdfWaterSetMapper; import com.emr.dao.tScanAssort.T_Scan_AssortMapper; import com.emr.entity.*; import com.emr.entity.emrLog.Emr_Log; +import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet; import com.emr.entity.recordType.Emr_Type; import com.emr.entity.recordType.Emr_Type_Related; import com.emr.service.CommomService; @@ -17,11 +19,13 @@ import com.emr.service.recordType.EmrTypeRelatedService; import com.emr.service.recordType.EmrTypeService; import com.emr.service.tScanAssort.T_Scan_AssortService; import com.emr.util.ExceptionPrintUtil; +import com.emr.util.img2PdfUtil; import com.emr.vo.EmrPrintOrDownLoadInfo.EmrPrintOrDownLoadInfoVo; import com.emr.vo.FontVo.ScanAssortVo; import com.emr.vo.commomSearch.*; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.util.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -77,6 +81,8 @@ public class CommomSearchController { private CommomService commomService; @Autowired private LogService logService; + @Autowired + private EmrPdfWaterSetMapper pdfWaterSetMapper; //祈福医院 @RequiresPermissions("/commom/commomListqf") @@ -643,9 +649,32 @@ public class CommomSearchController { */ @RequestMapping(value = "showRecordContentBlood") @ResponseBody - public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response) { + public ResultUtil showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response,HttpServletRequest request) { + try { + commomService.showRecordContentBlood(patientId, scanPages, sources, flag, response,request); + return ResultUtil.ok(); + } catch (Exception e) { + ExceptionPrintUtil.printException(e); + e.printStackTrace(); + return ResultUtil.error("showRecordContentBlood查询文件出错了"); + } + } + + @RequestMapping(value = "getRecordContentBlood") + @ResponseBody + public void getRecordContentBlood(String patientId,HttpServletRequest request,HttpServletResponse response) { try { - commomService.showRecordContentBlood(patientId, scanPages, sources, flag, response); + Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + String mapKey = user.getUserName() + "_" + patientId; + List scanPages = (List)request.getSession().getAttribute(mapKey); + if(!CollectionUtils.isEmpty(scanPages)) { + String pdfName = "档案管理PDF"; + //根据图片路径转换pdf + EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1); + img2PdfUtil.imageToPdf(response, scanPages, pdfName, emrPdfWaterSet); + //移除缓存 + request.removeAttribute(mapKey); + } } catch (Exception e) { ExceptionPrintUtil.printException(e); e.printStackTrace(); diff --git a/src/main/java/com/emr/service/CommomService.java b/src/main/java/com/emr/service/CommomService.java index 27c09ee..e2237c9 100644 --- a/src/main/java/com/emr/service/CommomService.java +++ b/src/main/java/com/emr/service/CommomService.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.emr.dao.CommomMapper; import com.emr.dao.emrPdfWaterSet.EmrPdfWaterSetMapper; import com.emr.entity.EmrComomSet; +import com.emr.entity.Power_User; import com.emr.entity.ResultUtil; import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet; import com.emr.entity.tScanAssort.T_Scan_Assort; @@ -162,8 +163,7 @@ public class CommomService { //脐血库显示pdf - public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response) throws Exception { - String pdfName = "档案管理PDF"; + public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response,HttpServletRequest request) throws Exception { if (StringUtils.isNotBlank(patientId)) { patientId = patientId.replace("\'", ""); //查询 @@ -200,9 +200,9 @@ public class CommomService { } } if (!filePaths.isEmpty()) { - //根据图片路径转换pdf - EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1); - img2PdfUtil.imageToPdf(response, filePaths, pdfName, emrPdfWaterSet); + Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + String mapKey = user.getUserName() + "_" + patientId; + request.getSession().setAttribute(mapKey,filePaths); } } } 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 9e3f583..f477045 100644 --- a/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp +++ b/src/main/webapp/WEB-INF/views/recordManage/commomSearch/showRecordIframeBlood.jsp @@ -255,7 +255,7 @@ + src="${path}/static/js/recordManage/commomSearch/showRecordIframeBlood.js?t=2021-08-24"> diff --git a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js index acc36dc..a68fdd1 100644 --- a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js +++ b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js @@ -119,6 +119,36 @@ function onloadPdfMethod() { //加载pdf按钮功能 function onloadPdf(scanPages, sources) { + $("#iframeLoad").val(""); + $("#printPicLoaded").val(""); + var patientId = $("#patientId").val(); + //根目录字段识别名称 + var flag = parent.$("#flag").val(); + $.ajax({ + type: 'post', + url: path + "/commom/showRecordContentBlood", + data: { + patientId: patientId, + scanPages: scanPages, + flag: flag, + sources: sources + }, + datType: 'json', + success: function (data) { + if (data.code == 0) { + var str = path + "/commom/getRecordContentBlood?patientId=" + patientId; + $("#iframe1").attr("src", path + "/static/pdfjs/web/viewer1.html?file=" + encodeURIComponent(str)); + var rootPaths = parent.$("#rootPaths").val(); + //加载的图片 + var print = $("#print").val(); + if (scanPages != '' && print == 1) { + selectPrintPic(patientId, rootPaths, scanPages, sources); + } + } + } + }) +} +/*function onloadPdf(scanPages, sources) { $("#iframeLoad").val(""); $("#printPicLoaded").val(""); var patientId = $("#patientId").val(); @@ -132,7 +162,7 @@ function onloadPdf(scanPages, sources) { if (scanPages != '' && print == 1) { selectPrintPic(patientId, rootPaths, scanPages, sources); } -} +}*/ var iframe = document.getElementById("iframe1");