From 942cd1ddd9bb3d576b7123c8cf4f65cb3e6615da Mon Sep 17 00:00:00 2001 From: wzqgit <568275241@qq.com> Date: Wed, 28 Apr 2021 20:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=87=BA=E9=99=A2=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=8C=BB=E7=94=9F=E6=8A=A4=E5=A3=AB=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=E9=83=A8=E5=88=86=E7=97=85=E5=8E=86=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E7=97=85=E6=A1=88=E5=AE=A4=E6=9F=A5=E7=9C=8B=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E5=88=97=E8=A1=A8=E4=B8=8D=E9=9C=80=E8=A6=81=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8C=89=E7=A7=91=E5=AE=A4=E6=9F=A5=E8=AF=A2=20=204/2?= =?UTF-8?q?8=20wzq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/emr/controller/FontController.java | 90 ++++----- .../controller/beHospitaledController.java | 8 +- src/main/java/com/emr/util/PDFUtils.java | 188 +++++++++++++++++- .../WEB-INF/views/faultDir/faultList.jsp | 11 +- .../views/lastVerifyDir/lastVerifyList.jsp | 44 ++-- 5 files changed, 265 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/emr/controller/FontController.java b/src/main/java/com/emr/controller/FontController.java index c565e148..a7b11ad2 100644 --- a/src/main/java/com/emr/controller/FontController.java +++ b/src/main/java/com/emr/controller/FontController.java @@ -48,41 +48,41 @@ public class FontController { @Autowired private Zd_AssortService assortService; - /***************************提供第三方按多个分段id和记账号查询病历pdf***********************************/ + /***************************ṩֶidͼ˺Ųѯpdf***********************************/ /** - * 提供第三方按多个分段id和记账号查询病历pdf + * ṩֶidͼ˺Ųѯpdf * */ @RequestMapping("showRecordByPatientId") public String showRecordByPatientId( HttpServletResponse response, String assortIds, String patientId, String visitId, Model model){ response.setCharacterEncoding("utf-8"); System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式 if(StringUtils.isBlank(assortIds)){ - return retrunErrorPage(model,"病案分类Id不能为空!"); + return retrunErrorPage(model,"IdΪ!"); } if(StringUtils.isBlank(patientId)){ - return retrunErrorPage(model,"记账号不能为空!"); + return retrunErrorPage(model,"˺ŲΪ!"); } if(StringUtils.isBlank(visitId)){ - return retrunErrorPage(model,"住院次数不能为空!"); + return retrunErrorPage(model,"סԺΪ!"); } List list = new ArrayList<>(); - //判断工号是否存在 + //жϹǷ try { /* String checkUserName = checkUserName(userName); if(StringUtils.isNotBlank(checkUserName)){ return retrunErrorPage(model,checkUserName); }*/ - //判断分类id是否存在,协商assortIds = "00000000"为查询全部 + //жϷidǷ,ЭassortIds = "00000000"Ϊѯȫ if(!allAddortIds.equals(assortIds)) { String checkAssortIds = checkAssortIds(assortIds); if (StringUtils.isNotBlank(checkAssortIds)) { return retrunErrorPage(model, checkAssortIds); } } - //判断记账号是否存在 + //жϼ˺Ƿ list = archiveMasterService.selectByObject(patientId,visitId); if(null == list || list.isEmpty()){ - return retrunErrorPage(model,"病历不存在!"); + return retrunErrorPage(model,"!"); } } catch (Exception e) { ExceptionPrintUtil.printException(e); @@ -95,7 +95,7 @@ public class FontController { } /** - * 返回错误页面 + * شҳ * */ private String retrunErrorPage(Model model, String errorMsg){ System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式 @@ -104,7 +104,7 @@ public class FontController { } /** - * 判断分类id是否存在 + * жϷidǷ * */ private String checkAssortIds(String assortIds){ System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式 @@ -120,7 +120,7 @@ public class FontController { if(null != assortList && !assortList.isEmpty()){ String[] split = assortIds.split(","); for (String s : split) { - //定义分类存在 + // boolean exist = false; if (StringUtils.isNotBlank(s)) { for (Zd_Assort assort1 : assortList) { @@ -131,17 +131,17 @@ public class FontController { } } if (!exist) { - return "病案分类Id有误!"; + return "Id!"; } } }else{ - return "病案分类Id有误!"; + return "Id!"; } return null; } /** - * 根据主键查询病案详情 + * ѯ * @param masterId * @return */ @@ -150,7 +150,7 @@ public class FontController { public String getPdfToPdf(String masterId){ try { Archive_Master archiveMaster = archiveMasterService.selectById(masterId); - //转换科室数据字典 + //תֵ if(StringUtils.isNotBlank(archiveMaster.getDeptName())){ Emr_Dictionary dictionary = new Emr_Dictionary(); dictionary.setCode(archiveMaster.getDeptName()); @@ -159,7 +159,7 @@ public class FontController { if(null != dictionaries && !dictionaries.isEmpty()){ archiveMaster.setDeptName(dictionaries.get(0).getName()); } - //判断出院日期 + //жϳԺ String dischargeDateTime = archiveMaster.getDischargeDateTime(); if(StringUtils.isNotBlank(dischargeDateTime)){ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); @@ -178,7 +178,7 @@ public class FontController { } /** - * 跳转到showRecordIframe页面 + * תshowRecordIframeҳ * */ /*@RequestMapping("showRecordIframe") public String showRecordIframe(){ @@ -186,7 +186,7 @@ public class FontController { }*/ /** - * 根据master表的记账号和分类id集合组织分类树 + * masterļ˺źͷid֯ * @return * @throws Exception */ @@ -198,19 +198,19 @@ public class FontController { List treeList = new ArrayList<>(); if(StringUtils.isNotBlank(patientId) && StringUtils.isNotBlank(assortIds)){ List list = new ArrayList<>(); - //assortIds等于协商的全查的分类id,全查 + //assortIdsЭ̵ȫķidȫ try { if(allAddortIds.equals(assortIds)){ list = archiveDetailService.selectTypeTreeByPatientIdAndAssortIds(patientId, null); }else{ - //否则按条件查 - //分类id分别以单引号隔开 + // + //idֱԵŸ StringBuilder assortIdStr = new StringBuilder(); String[] split = assortIds.split(","); for (String s : split) { assortIdStr.append("'").append(s).append("',"); } - //去掉最后一个逗号 + //ȥһ assortIdStr = new StringBuilder(assortIdStr.substring(0, assortIdStr.length() - 1)); list = archiveDetailService.selectTypeTreeByPatientIdAndAssortIds(patientId, assortIdStr.toString()); } @@ -220,18 +220,18 @@ public class FontController { } if(null != list && !list.isEmpty()){ Set assortList = new LinkedHashSet<>(); - //抽取首次病程记录 - String strTemp = "首次病程"; + //ȡ״β̼¼ + String strTemp = "״β"; String assortId = "11"; - //定义护理记录里的首次护理记录排前头 - String nurseTemp = "首次护理"; + //廤¼״λ¼ǰͷ + String nurseTemp = "״λ"; String nurseAssortId = "7"; Archive_Detail detailTemp = new Archive_Detail(); Archive_Detail nurseDetailVoTemp = new Archive_Detail(); - //分类去重 + //ȥ for(Archive_Detail detail : list){ assortList.add(detail.getSubassort()); - //获取title + //ȡtitle String title = detail.getTitle(); if(StringUtils.isNotBlank(title) && detail.getTitle().contains(strTemp)){ detailTemp = detail; @@ -240,41 +240,41 @@ public class FontController { nurseDetailVoTemp = detail; } } - //组织树 + //֯ int id = 1; - //定义第一层的id为第二层父id + //һidΪڶ㸸id int oneParentId = 0; - //定义第二层的id为第三层父id + //ڶidΪ㸸id int twoParentId = 0; AssortTypeTree tree = new AssortTypeTree(); - //第一层,根目录全部影像资料 + //һ,Ŀ¼ȫӰ tree.setId(id); tree.setParentId(0); - tree.setName("全部影像资料"); + tree.setName("ȫӰ"); tree.setChecked("true"); treeList.add(tree); oneParentId = id; id++; for(String assortName : assortList){ AssortTypeTree tree1 = new AssortTypeTree(); - //第二层,分类名称 + //ڶ, tree1.setId(id); tree1.setParentId(oneParentId); twoParentId = id; id++; - //定义该类的数量 + // int count = 0; - //定义是否添加了首次病程 + //Ƿ״β boolean flag = false; boolean nurseflag = false; for(Archive_Detail detail : list){ if(StringUtils.isNoneBlank(detail.getSubassort()) && assortName.equals(detail.getSubassort())){ String assortid = detail.getAssortid(); if(StringUtils.isNotBlank(assortid) && assortid.equals(assortId)){ - //是病程记录 + //Dz̼¼ if(!flag && StringUtils.isNotBlank(detailTemp.getTitle())){ AssortTypeTree tree2 = new AssortTypeTree(); - //第三层,资料名称 + //, count++; tree2.setId(id); tree2.setParentId(twoParentId); @@ -287,10 +287,10 @@ public class FontController { } } if(StringUtils.isNotBlank(assortid) && assortid.equals(nurseAssortId)){ - //是护理记录 + //ǻ¼ if(!nurseflag && StringUtils.isNotBlank(nurseDetailVoTemp.getTitle())){ AssortTypeTree tree2 = new AssortTypeTree(); - //第三层,资料名称 + //, count++; tree2.setId(id); tree2.setParentId(twoParentId); @@ -304,7 +304,7 @@ public class FontController { } if(!detail.equals(detailTemp) && !detail.equals(nurseDetailVoTemp)) { AssortTypeTree tree2 = new AssortTypeTree(); - //第三层,资料名称 + //, count++; tree2.setId(id); tree2.setParentId(twoParentId); @@ -326,7 +326,7 @@ public class FontController { } /** - * 根据病案号或类别或图片id获取图片列表,并生成PDF并返回pdf文件名 + * ݲŻͼƬidȡͼƬбPDFpdfļ * @param response * @param detailIds * @return @@ -342,13 +342,13 @@ public class FontController { detail.setTitle(detailIds); archiveDetailService.selectByIdStrFont(response,session,detail); }else{ - //存至session + //session session.setAttribute("showRecord",null); } return Msg.success(); } catch (Exception e) { ExceptionPrintUtil.printException(e); - return Msg.fail("查看出错了,请联系系统管理员"); + return Msg.fail("鿴,ϵϵͳԱ"); //e.printStackTrace(); } } diff --git a/src/main/java/com/emr/controller/beHospitaledController.java b/src/main/java/com/emr/controller/beHospitaledController.java index 52f7f7dd..99506a6a 100644 --- a/src/main/java/com/emr/controller/beHospitaledController.java +++ b/src/main/java/com/emr/controller/beHospitaledController.java @@ -376,15 +376,15 @@ public class beHospitaledController { if(bol==1) { archiveMaster.setIsscaned(archiveMasterVo.getIsscaned()); bol = archiveMasterService.updateByClo(archiveMaster); - if(archiveMaster.getCmtDoctor()==1) { + /*if(archiveMaster.getCmtDoctor()==1) { result = "归档医生提交"; }else if(archiveMaster.getCmtNurse()==1){ result = "归档护士提交"; - } + }*/ if(bol==1){ - result+="成功!"; + result="成功"; }else{ - result+= "失败!"; + result= "失败"; } } diff --git a/src/main/java/com/emr/util/PDFUtils.java b/src/main/java/com/emr/util/PDFUtils.java index 29291e3a..0cb870e0 100644 --- a/src/main/java/com/emr/util/PDFUtils.java +++ b/src/main/java/com/emr/util/PDFUtils.java @@ -6,9 +6,8 @@ */ package com.emr.util; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; +import java.awt.image.BufferedImage; +import java.io.*; import java.util.ArrayList; import java.util.List; @@ -17,7 +16,17 @@ import com.itextpdf.text.DocumentException; import com.itextpdf.text.pdf.PdfCopy; import com.itextpdf.text.pdf.PdfImportedPage; import com.itextpdf.text.pdf.PdfReader; +import org.apache.commons.io.FileUtils; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPageTree; +import org.apache.pdfbox.rendering.PDFRenderer; import org.springframework.beans.factory.annotation.Value; +import sun.misc.BASE64Decoder; +import sun.misc.BASE64Encoder; + +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; public class PDFUtils { @@ -179,6 +188,179 @@ public class PDFUtils { } + + /** + * 将base64字符串转换为PDF在显示到页面中 + * @param base64String + * @param httpServletResponse + */ + public static void base64StringToPDFToPage(String base64String, HttpServletResponse httpServletResponse){ + BASE64Decoder decoder = new BASE64Decoder(); + ByteArrayOutputStream baos = null; + ServletOutputStream sos = null; + try { + byte[] bytes = decoder.decodeBuffer(base64String); + baos = new ByteArrayOutputStream(); + baos.write(bytes); //把byte写进输出流里 + if (baos != null) { + httpServletResponse.setContentType("application/pdf"); + httpServletResponse.setContentLength(baos.size()); + httpServletResponse.setHeader("Expires", "0"); + httpServletResponse.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); + httpServletResponse.setHeader("Pragma", "public"); + // 设置打印PDF的文件名 + String fileName = "社保证明文件.pdf"; + fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1"); + httpServletResponse.setHeader("Content-Disposition", "filename=" + fileName); + sos = httpServletResponse.getOutputStream(); + baos.writeTo(sos); //byte输出流写入servlet输出流 + sos.flush(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + sos.close(); + baos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 将base64编码转换成PDF + * @param base64String + * 1.使用BASE64Decoder对编码的字符串解码成字节数组 + * 2.使用底层输入流ByteArrayInputStream对象从字节数组中获取数据; + * 3.建立从底层输入流中读取数据的BufferedInputStream缓冲输出流对象; + * 4.使用BufferedOutputStream和FileOutputSteam输出数据到指定的文件中 + */ + public static void base64StringToPDF(String base64String, String pdfPath/*File file*/){ + File file = new File(pdfPath);// 将原来参数修改为字符串 + BASE64Decoder decoder = new BASE64Decoder(); + BufferedInputStream bin = null; + FileOutputStream fout = null; + BufferedOutputStream bout = null; + try { + //将base64编码的字符串解码成字节数组 + byte[] bytes = decoder.decodeBuffer(base64String); + //创建一个将bytes作为其缓冲区的ByteArrayInputStream对象 + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + //创建从底层输入流中读取数据的缓冲输入流对象 + bin = new BufferedInputStream(bais); + //创建到指定文件的输出流 + fout = new FileOutputStream(file); + //为文件输出流对接缓冲输出流对象 + bout = new BufferedOutputStream(fout); + + byte[] buffers = new byte[1024]; + int len = bin.read(buffers); + while(len != -1){ + bout.write(buffers, 0, len); + len = bin.read(buffers); + } + //刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题 + bout.flush(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + bout.close(); + fout.close(); + bin.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * PDF转换为Base64编码 + * @param file + * @return + */ + public static String pdfToBase64(File file) { + BASE64Encoder encoder = new BASE64Encoder(); + FileInputStream fin =null; + BufferedInputStream bin =null; + ByteArrayOutputStream baos = null; + BufferedOutputStream bout =null; + try { + fin = new FileInputStream(file); + bin = new BufferedInputStream(fin); + baos = new ByteArrayOutputStream(); + bout = new BufferedOutputStream(baos); + byte[] buffer = new byte[1024]; + int len = bin.read(buffer); + while(len != -1){ + bout.write(buffer, 0, len); + len = bin.read(buffer); + } + //刷新此输出流并强制写出所有缓冲的输出字节 + bout.flush(); + byte[] bytes = baos.toByteArray(); + return encoder.encodeBuffer(bytes).trim(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + fin.close(); + bin.close(); + baos.close(); + bout.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * pdf转jpg + * @param pdfPath + * @param jpgPath + */ + public static void pdfToJpg(String pdfPath,String jpgPath){ + long start = System.currentTimeMillis(); + //pdf路径 + InputStream stream = null; + try { + stream = new FileInputStream(new File(pdfPath));//URLUtil.getStream(url); + // 加载解析PDF文件 + PDDocument doc = PDDocument.load(stream); + PDFRenderer pdfRenderer = new PDFRenderer(doc); + PDPageTree pages = doc.getPages(); + int pageCount = pages.getCount(); + for (int i = 0; i < pageCount; i++) { + BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 200); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + ImageIO.write(bim, "jpg", os); + byte[] datas = os.toByteArray(); + FileUtils.writeByteArrayToFile(new File(jpgPath),datas); + } + long end = System.currentTimeMillis(); + long time = (end - start) / 1000; + System.out.println("pdf转jpg耗时: {}s"+time); + }catch (Exception e){ + + } + + } + + /** + * base64转jpg + * @param val + * @param pdfFile + * @param jpgFile + */ + public static void base64ToJPG(String val,String pdfFile,String jpgFile){ + base64StringToPDF(val,pdfFile); + pdfToJpg(pdfFile,jpgFile); + } } diff --git a/src/main/webapp/WEB-INF/views/faultDir/faultList.jsp b/src/main/webapp/WEB-INF/views/faultDir/faultList.jsp index de756130..99730d17 100644 --- a/src/main/webapp/WEB-INF/views/faultDir/faultList.jsp +++ b/src/main/webapp/WEB-INF/views/faultDir/faultList.jsp @@ -238,7 +238,7 @@ this.pageSize = currPageSize; } - var url = window.location.href; + /*var url = window.location.href; var deptName = url.substring(url.lastIndexOf('&') + 1).replace("depts=", ""); var len = ($("#deptName").val()).length; @@ -247,6 +247,13 @@ if (deptNameT.indexOf("") == -1) { deptName = $("#deptName").val().toString(); } + }*/ + + var deptName = $("#deptName").val(); + if (deptName.indexOf("") != -1) { + deptName = ""; + } else { + deptName = $("#deptName").val().toString(); } var temp = { @@ -259,7 +266,7 @@ visitId:""+$("#visitId").val(), name:""+$("#name").val(), archivestate:"" + $("#archivestate").val(), - deptName: deptName.toString() + deptName: deptName }; return temp; diff --git a/src/main/webapp/WEB-INF/views/lastVerifyDir/lastVerifyList.jsp b/src/main/webapp/WEB-INF/views/lastVerifyDir/lastVerifyList.jsp index 584715e1..3a05a110 100644 --- a/src/main/webapp/WEB-INF/views/lastVerifyDir/lastVerifyList.jsp +++ b/src/main/webapp/WEB-INF/views/lastVerifyDir/lastVerifyList.jsp @@ -2961,7 +2961,7 @@ field: 'inpNo', align: 'left', valign: 'middle', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { //console.log(row); var redFlag = row.numb; var a = ""; @@ -2972,14 +2972,14 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '住院次数', field: 'visitId', align: 'center', valign: 'middle', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (redFlag == 0) { @@ -2989,14 +2989,14 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '姓名', field: 'name', align: 'left', valign: 'middle', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (redFlag == 0) { @@ -3010,14 +3010,14 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '性别', field: 'sex', align: 'center', valign: 'middle', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (value == null || value == "null") { @@ -3030,7 +3030,7 @@ a = '' + a + ''; } return a; - } + }*/ }, // { // title: '身份证号', @@ -3044,7 +3044,7 @@ field: 'deptName', align: 'left', valign: 'middle', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (redFlag == 0) { @@ -3054,13 +3054,13 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '出院日期', field: 'dischargeDateTime', align: 'center', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (value != null && value != "") { @@ -3073,7 +3073,7 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '主管医生', @@ -3111,7 +3111,7 @@ title: '医生', field: 'doctorName', align: 'left', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { //调接口 参数:工号 返回:名字 var redFlag = row.numb; var a = ""; @@ -3125,14 +3125,14 @@ a = '' + a + ''; } return a; - } + }*/ }, { title: '医生提交日期', field: 'cmtDoctorDate', align: 'center', visible: false, - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (value != null && value != "") { @@ -3147,7 +3147,7 @@ a = '' + a + ''; } return a; - } + }*/ }, { title: '护士是否提交', @@ -3179,7 +3179,7 @@ title: '护士', field: 'nurseName', align: 'left', - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (value == null || value == "null") { @@ -3192,14 +3192,14 @@ a = '' + a + ''; } return a; - } + }*/ }, { title: '护士提交日期', field: 'cmtNurseDate', align: 'center', visible: false, - formatter: function (value, row, index) { + /*formatter: function (value, row, index) { var redFlag = row.numb; var a = ""; if (value != null && value != "") { @@ -3216,7 +3216,7 @@ a = '' + value + ''; } return a; - } + }*/ }, { title: '是否死亡', field: 'deathFlag', @@ -3285,7 +3285,7 @@ } } else { //有缺陷显示红色 - a = '' + value + ''; + a = '' + value + ''; } return a; } @@ -3315,7 +3315,7 @@ if (redFlag == 0) { a = ''+showVal+''; }else{ - a = ''+showVal+''; + a = ''+showVal+''; } return a; }