|
@@ -23,6 +23,7 @@ import cfca.paperless.dto.response.responsebody.tx40.VerifyPdfSealResponseBody;
|
|
import cfca.paperless.dto.response.tx20.MakeSealResponse;
|
|
import cfca.paperless.dto.response.tx20.MakeSealResponse;
|
|
import cfca.paperless.dto.response.tx40.CompoundSealPdfListDetachedResponse;
|
|
import cfca.paperless.dto.response.tx40.CompoundSealPdfListDetachedResponse;
|
|
import cfca.paperless.dto.response.tx40.VerifyPdfSealResponse;
|
|
import cfca.paperless.dto.response.tx40.VerifyPdfSealResponse;
|
|
|
|
+import cn.hutool.core.io.file.FileReader;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
@@ -50,8 +51,12 @@ import org.springblade.manager.feign.ContractClient;
|
|
import org.springblade.manager.feign.SignPfxClient;
|
|
import org.springblade.manager.feign.SignPfxClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.system.cache.ParamCache;
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
|
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
|
+import org.springframework.http.converter.HttpMessageConverter;
|
|
|
|
+import org.springframework.http.converter.StringHttpMessageConverter;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.imageio.*;
|
|
import javax.imageio.*;
|
|
@@ -60,12 +65,10 @@ import javax.imageio.metadata.IIOMetadata;
|
|
import javax.imageio.metadata.IIOMetadataNode;
|
|
import javax.imageio.metadata.IIOMetadataNode;
|
|
import javax.imageio.stream.ImageOutputStream;
|
|
import javax.imageio.stream.ImageOutputStream;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
-import java.io.ByteArrayInputStream;
|
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -167,7 +170,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
result = null;
|
|
result = null;
|
|
} else {
|
|
} else {
|
|
//普通文件签章
|
|
//普通文件签章
|
|
- result = this.signPdf(pdfVO, fileByte);
|
|
|
|
|
|
+ result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
}
|
|
}
|
|
if(result != null){
|
|
if(result != null){
|
|
if(result[0] != null){
|
|
if(result[0] != null){
|
|
@@ -196,9 +199,15 @@ public class EVisaServiceImpl implements EVisaService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 合同章 签字
|
|
|
|
+ * @param task
|
|
|
|
+ * @param finalPdfUrl
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
- //获取任务对应表格的电签配置
|
|
|
|
|
|
+ //获取任务对应表格的电签配置(合同张)
|
|
List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), "true");
|
|
List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), "true");
|
|
if(eVisaConfigList == null || eVisaConfigList.size() == 0){
|
|
if(eVisaConfigList == null || eVisaConfigList.size() == 0){
|
|
//没有电签配置,默认当前任务为不签字审批,返回成功
|
|
//没有电签配置,默认当前任务为不签字审批,返回成功
|
|
@@ -258,7 +267,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
//获取字节
|
|
//获取字节
|
|
byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(finalPdfUrl));
|
|
byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(finalPdfUrl));
|
|
//执行电签
|
|
//执行电签
|
|
- Object[] result = this.signPdf(pdfVO, fileByte);
|
|
|
|
|
|
+ Object[] result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
if(result != null){
|
|
if(result != null){
|
|
if(result[0] != null){
|
|
if(result[0] != null){
|
|
MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[])result[0])));
|
|
MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[])result[0])));
|
|
@@ -281,7 +290,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 电签信息
|
|
|
|
|
|
+ * 个人-电签信息
|
|
* @param task
|
|
* @param task
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -347,7 +356,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
//获取字节
|
|
//获取字节
|
|
byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(file.getFileUrl()));
|
|
byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(file.getFileUrl()));
|
|
//执行电签
|
|
//执行电签
|
|
- Object[] result = this.signPdf(pdfVO, fileByte);
|
|
|
|
|
|
+ Object[] result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
if(result != null){
|
|
if(result != null){
|
|
if(result[0] != null){
|
|
if(result[0] != null){
|
|
MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[])result[0])));
|
|
MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[])result[0])));
|
|
@@ -378,9 +387,72 @@ public class EVisaServiceImpl implements EVisaService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 签章
|
|
|
|
|
|
+ * 东方 中讯
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static void signPdfByDFZX(SealPdfVO pdfVO, byte[] fileByte) throws Exception {
|
|
|
|
+ String url = "http://192.168.0.120:9125/FrontSys/SealServicezx/FileSignByPoint";
|
|
|
|
+ HashMap<String, Object> request = new HashMap<>();
|
|
|
|
+ String picFilePath = "/Users/hongchuangyanfa/Desktop/pdf/1606191494346047488.pdf".toLowerCase();//测试文件的绝对路径
|
|
|
|
+
|
|
|
|
+ FileReader fileReader = new FileReader(picFilePath);
|
|
|
|
+ String originalFileB64 = Base64.toBase64String(fileReader.readBytes());
|
|
|
|
+ request.put("sealId", "abb54d49555b479b8216b0f3b03bf41f");
|
|
|
|
+ request.put("fileB64", originalFileB64);
|
|
|
|
+ request.put("pointX", 100);
|
|
|
|
+ request.put("pointY", 100);
|
|
|
|
+ request.put("showHeight", 1000);
|
|
|
|
+ request.put("showWidth", 600);
|
|
|
|
+ request.put("lastSignFlag", false);
|
|
|
|
+
|
|
|
|
+ HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
|
|
|
+ httpRequestFactory.setConnectionRequestTimeout(30000);
|
|
|
|
+ httpRequestFactory.setConnectTimeout(30000);
|
|
|
|
+ httpRequestFactory.setReadTimeout(30000);
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
|
|
|
|
+ // 设置编码格式为UTF-8
|
|
|
|
+ List<HttpMessageConverter<?>> converterList = restTemplate.getMessageConverters();
|
|
|
|
+ HttpMessageConverter<?> converterTarget = null;
|
|
|
|
+ for (HttpMessageConverter<?> item : converterList) {
|
|
|
|
+ if (item.getClass() == StringHttpMessageConverter.class) {
|
|
|
|
+ converterTarget = item;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (converterTarget != null) {
|
|
|
|
+ converterList.remove(converterTarget);
|
|
|
|
+ }
|
|
|
|
+ HttpMessageConverter<?> converter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
|
|
|
|
+ converterList.add(1, converter);
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> retData = restTemplate.postForObject(url, request, HashMap.class);
|
|
|
|
+
|
|
|
|
+ String code = retData.get("code").toString();
|
|
|
|
+ String msg = retData.get("msg").toString();
|
|
|
|
+
|
|
|
|
+ if (!"0".equals(code)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String fileB64 = retData.get("fileB64").toString();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ FileOutputStream fout = new FileOutputStream(picFilePath.replace(".pdf", "-签名后.pdf"));
|
|
|
|
+ fout.write(Base64.decode(fileB64));//生成base64字符串格式文件
|
|
|
|
+ fout.close();
|
|
|
|
+ System.out.println("文件保存成功");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("文件保存失败");
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 安心 - 签章
|
|
*/
|
|
*/
|
|
- private Object[] signPdf(SealPdfVO pdfVO, byte[] fileByte){
|
|
|
|
|
|
+ private Object[] signPdfByAXQZ(SealPdfVO pdfVO, byte[] fileByte){
|
|
Object[] result = new Object[3];
|
|
Object[] result = new Object[3];
|
|
try{
|
|
try{
|
|
PaperlessClient paperlessClient = new PaperlessClient(SIGN_HOST, SIGN_PORT, 300000, 36000000);
|
|
PaperlessClient paperlessClient = new PaperlessClient(SIGN_HOST, SIGN_PORT, 300000, 36000000);
|