|
|
|
@ -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;
|
|
|
|
|