diff --git a/src/main/java/com/emr/service/ipml/CaSignServiceImpl.java b/src/main/java/com/emr/service/ipml/CaSignServiceImpl.java index 72d1824f..4cd2c0e9 100644 --- a/src/main/java/com/emr/service/ipml/CaSignServiceImpl.java +++ b/src/main/java/com/emr/service/ipml/CaSignServiceImpl.java @@ -103,8 +103,9 @@ public class CaSignServiceImpl { String todayDate = fmt.format(new Date()); //签章后地址 String newpdfPath = newPath + File.separator + todayDate+".pdf"; + backupsPdf(pdfPath,newpdfPath); //进行签章 - boolean isSign = caSign(pdfPath, newpdfPath, caReqParam); + boolean isSign = caSign(newpdfPath, caReqParam); if (isSign) { idList.add(dto.getId()); dto.setPdfPath(newpdfPath); @@ -126,6 +127,18 @@ public class CaSignServiceImpl { e.printStackTrace(); } } + private void backupsPdf(String pdfPath,String newpdfPath){ + try (InputStream inputStream = new FileInputStream(pdfPath); + OutputStream outputStream = new FileOutputStream(newpdfPath)) { + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } catch (IOException e) { + e.printStackTrace(); + } + } /** * @Description: updateCaFileState方法是更新ca签章 @@ -199,20 +212,19 @@ public class CaSignServiceImpl { * * z:docus/caTemp/masterId/病案首页 */ - private boolean caSign(String fileSrc, String newpdfPath, Archive_Detail_ca_reqParam caReqParam) throws Exception { - System.out.println("fileSrc:" + fileSrc); + private boolean caSign(String newpdfPath, Archive_Detail_ca_reqParam caReqParam) throws Exception { //定义是否成功 boolean flag = false; PdfReader pdfReader = null; try { - pdfReader = new PdfReader(fileSrc); + pdfReader = new PdfReader(newpdfPath); } catch (Exception e) { e.printStackTrace(); } if (pdfReader != null) { try { anySignClientTool = new AnySignClientTool(caServerIp, caServerPort); - File file = new File(fileSrc); + File file = new File(newpdfPath); byte[] pdfBty = ClientUtil.readFileToByteArray(file); //pdf验章 ChannelMessage messageExist = anySignClientTool.pdfVerify(pdfBty); @@ -252,7 +264,7 @@ public class CaSignServiceImpl { e.printStackTrace(); } } else { - log.error("进行签章pdf:" + fileSrc + "不存在或损坏"); + log.error("进行签章pdf:" + newpdfPath + "不存在或损坏"); } System.out.println("完成"); return flag; diff --git a/src/main/resources/mapper/ArchiveDetailCaCopyMapper.xml b/src/main/resources/mapper/ArchiveDetailCaCopyMapper.xml index 27c026dd..3c3f37c7 100644 --- a/src/main/resources/mapper/ArchiveDetailCaCopyMapper.xml +++ b/src/main/resources/mapper/ArchiveDetailCaCopyMapper.xml @@ -35,7 +35,7 @@ values (#{item.id},#{item.pdfPath},#{item.masterID},#{item.upLoadDateTime},#{item.assortID},#{item.source},#{item.subAssort},#{item.title},#{item.flag} - ,#{item.Sys},#{item.applyId},#{item.pageNumber},#{item.checkReportId},#{item.crecoverPdfPath},#{item.fileCode},#{item.cType},#{item.fileContext} + ,#{item.Sys},#{item.applyId},#{item.pageNumber},#{item.checkReportId},#{item.recoverPdfPath},#{item.fileCode},#{item.cType},#{item.fileContext} ,#{item.pageCount})