|
@@ -23,29 +23,34 @@ import cfca.paperless.dto.response.responsebody.tx40.VerifyPdfSealResponseBody;
|
|
|
import cfca.paperless.dto.response.tx20.MakeSealResponse;
|
|
|
import cfca.paperless.dto.response.tx40.CompoundSealPdfListDetachedResponse;
|
|
|
import cfca.paperless.dto.response.tx40.VerifyPdfSealResponse;
|
|
|
+import cfca.sadk.com.itextpdf.styledxmlparser.jsoup.helper.DataUtil;
|
|
|
import cn.hutool.core.io.file.FileReader;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springblade.business.entity.ArchiveFile;
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
import org.springblade.business.feign.TaskClient;
|
|
|
import org.springblade.business.vo.TaskApprovalVO;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.constant.EVisaConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.common.utils.SystemUtils;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.FileUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.evisa.redissionUtil.DistributedRedisLock;
|
|
|
import org.springblade.evisa.service.EVisaService;
|
|
|
-import org.springblade.evisa.vo.EVisaMakeSealVO;
|
|
|
-import org.springblade.evisa.vo.EVisaTaskApprovalVO;
|
|
|
-import org.springblade.evisa.vo.SealPdfVO;
|
|
|
-import org.springblade.evisa.vo.SealStrategyVO;
|
|
|
+import org.springblade.evisa.vo.*;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
import org.springblade.manager.entity.SignPfxFile;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
@@ -57,6 +62,8 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
@@ -70,10 +77,8 @@ import javax.imageio.stream.ImageOutputStream;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@@ -103,6 +108,8 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
|
|
|
private final ContractClient contractClient;
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
@Autowired
|
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
@@ -376,14 +383,14 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
if (result != 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])));
|
|
|
|
|
|
byte[] byteArray = IOUtils.toByteArray(new ByteArrayInputStream((byte[]) result[0]));
|
|
|
- String dataUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/pdf/"+SnowFlakeUtil.getId() + ".pdf";
|
|
|
- File file1 =new File(dataUrl);
|
|
|
- FileUtil.copy(byteArray,file1);
|
|
|
+ String dataUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/pdf/" + SnowFlakeUtil.getId() + ".pdf";
|
|
|
+ File file1 = new File(dataUrl);
|
|
|
+ FileUtil.copy(byteArray, file1);
|
|
|
//重新上传
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + ".pdf",dataUrl);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + ".pdf", dataUrl);
|
|
|
if (bladeFile != null) {
|
|
|
resultMessage = SUCCESS + "@@@@" + bladeFile.getLink();
|
|
|
} else {
|
|
@@ -407,6 +414,156 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
return resultMessage;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 自定义签章-电签信息
|
|
|
+ *
|
|
|
+ * @param taskArchiveDTO
|
|
|
+ */
|
|
|
+ public void eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO taskArchiveDTO) {
|
|
|
+ //type=1表示任务审批自定义签章,type=2表示认证电签签章(不涉及审批任务)
|
|
|
+ if (taskArchiveDTO.getSealStrategy().size() > 0 && taskArchiveDTO.getType() == 1) {
|
|
|
+ //获取档案任务
|
|
|
+ Task task = jdbcTemplate.queryForObject("select form_data_id from u_task where id = " + taskArchiveDTO.getTaskId(), new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ if (task != null) {
|
|
|
+ //获取档案任务的文件信息
|
|
|
+ ArchiveFile archiveFile = jdbcTemplate.queryForObject("select pdf_file_url,e_visa_file from u_archive_file where id = " + task.getFormDataId(), new BeanPropertyRowMapper<>(ArchiveFile.class));
|
|
|
+ if (archiveFile != null && archiveFile.getPdfFileUrl() != null) {
|
|
|
+ String signPdfUrl;
|
|
|
+ if (ObjectUtil.isNotEmpty(archiveFile.getEVisaFile())) {
|
|
|
+ //如果e_visa_file有值,那么证明之前有过其他人进行电签,那么获取e_visa_file进行追加电签
|
|
|
+ signPdfUrl = archiveFile.getEVisaFile();
|
|
|
+ } else {
|
|
|
+ //否则使用原始pdf_file_url电签
|
|
|
+ signPdfUrl = archiveFile.getPdfFileUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //准备签章策略
|
|
|
+ SealPdfVO pdfVO = new SealPdfVO();
|
|
|
+ //获取当前用户的CA签字体证书信息、封装签章位置信息
|
|
|
+ List<TaskArchiveDTO.Sign> signList = taskArchiveDTO.getSealStrategy();
|
|
|
+ List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
|
+ for (TaskArchiveDTO.Sign index : signList) {
|
|
|
+ if (ObjectUtil.isNotEmpty(index.getUrl())) { //CA签字体证书不为空才签章
|
|
|
+ SealStrategyVO signVO = new SealStrategyVO();
|
|
|
+ signVO.setIsCenterCoordinate("1"); //左上角为原点
|
|
|
+ signVO.setSealCode(EVisaConstant.SIGN_SEAL_CODE + SecureUtil.getUserId());
|
|
|
+ signVO.setSealPassword(SecureUtil.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
|
|
|
+ signVO.setSealPerson(SecureUtil.getNickName());
|
|
|
+
|
|
|
+ //位置信息
|
|
|
+ signVO.setImageUrl(index.getUrl()); //CA签字体
|
|
|
+ signVO.setSealType("2");//坐标签章
|
|
|
+ signVO.setLx(index.getLx()); //x轴
|
|
|
+ signVO.setLy(index.getLy()); //y轴
|
|
|
+ signVO.setPage(index.getPage()); //page页码
|
|
|
+ sealStrategyVOS.add(signVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
+
|
|
|
+ //获取档案pdfUrl
|
|
|
+ byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(signPdfUrl));
|
|
|
+
|
|
|
+ //TODO ========== 执行电签 ==========
|
|
|
+ Object[] result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ if (result != null) {
|
|
|
+ if (result[0] != null) {
|
|
|
+ byte[] byteArray = IOUtils.toByteArray(new ByteArrayInputStream((byte[]) result[0]));
|
|
|
+
|
|
|
+ /*String dataUrl = "C:\\pdfFiles\\" + SnowFlakeUtil.getId() + ".pdf";
|
|
|
+ File file1 = new File(dataUrl);
|
|
|
+ FileUtils.writeByteArrayToFile(file1, byteArray);*/
|
|
|
+
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.updateFile(byteArray, SnowFlakeUtil.getId() + ".pdf");
|
|
|
+ if (bladeFile != null) {
|
|
|
+ //更新最新的电签pdfUrl
|
|
|
+ jdbcTemplate.execute("update u_archive_file set e_visa_file = '" + bladeFile.getLink() + "' where id = " + task.getFormDataId());
|
|
|
+ String successMsg = SUCCESS + "@@@@" + bladeFile.getLink();
|
|
|
+ logger.info(successMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (taskArchiveDTO.getSealStrategy().size() > 0 && taskArchiveDTO.getType() == 2) {
|
|
|
+ //此时的taskArchiveDTO.taskId=档案数据业务id(档案认证不涉及审批流任务)
|
|
|
+ //获取档案任务的文件信息(这里根据id再查询一次,入参的时候不想重新构造入参的dto了)
|
|
|
+ ArchiveFile archiveFile = jdbcTemplate.queryForObject("select pdf_file_url,e_visa_file from u_archive_file where id = " + taskArchiveDTO.getTaskId(), new BeanPropertyRowMapper<>(ArchiveFile.class));
|
|
|
+ if (archiveFile != null && archiveFile.getPdfFileUrl() != null) {
|
|
|
+ String signPdfUrl;
|
|
|
+ if (ObjectUtil.isNotEmpty(archiveFile.getEVisaFile())) {
|
|
|
+ //如果e_visa_file有值,那么证明之前有过其他人进行电签,那么获取e_visa_file进行追加电签
|
|
|
+ signPdfUrl = archiveFile.getEVisaFile();
|
|
|
+ } else {
|
|
|
+ //否则使用原始pdf_file_url电签
|
|
|
+ signPdfUrl = archiveFile.getPdfFileUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //准备签章策略
|
|
|
+ SealPdfVO pdfVO = new SealPdfVO();
|
|
|
+ //获取当前用户的CA签字体证书信息、封装签章位置信息
|
|
|
+ List<TaskArchiveDTO.Sign> signList = taskArchiveDTO.getSealStrategy();
|
|
|
+ List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
|
+ for (TaskArchiveDTO.Sign index : signList) {
|
|
|
+ if (ObjectUtil.isNotEmpty(index.getUrl())) { //CA签字体证书不为空才签章
|
|
|
+ SealStrategyVO signVO = new SealStrategyVO();
|
|
|
+ signVO.setIsCenterCoordinate("1"); //左上角为原点
|
|
|
+ signVO.setSealCode(EVisaConstant.SIGN_SEAL_CODE + SecureUtil.getUserId());
|
|
|
+ signVO.setSealPassword(SecureUtil.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
|
|
|
+ signVO.setSealPerson(SecureUtil.getNickName());
|
|
|
+
|
|
|
+ //位置信息
|
|
|
+ signVO.setImageUrl(index.getUrl()); //CA签字体
|
|
|
+ signVO.setSealType("2");//坐标签章
|
|
|
+ signVO.setLx(index.getLx()); //x轴
|
|
|
+ signVO.setLy(index.getLy()); //y轴
|
|
|
+ signVO.setPage(index.getPage()); //page页码
|
|
|
+ sealStrategyVOS.add(signVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
+
|
|
|
+ //获取档案pdfUrl
|
|
|
+ byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(signPdfUrl));
|
|
|
+
|
|
|
+ //TODO ========== 执行电签 ==========
|
|
|
+ Object[] result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ if (result != null) {
|
|
|
+ if (result[0] != null) {
|
|
|
+ byte[] byteArray = IOUtils.toByteArray(new ByteArrayInputStream((byte[]) result[0]));
|
|
|
+
|
|
|
+ /*String dataUrl = "C:\\pdfFiles\\" + SnowFlakeUtil.getId() + ".pdf";
|
|
|
+ File file1 = new File(dataUrl);
|
|
|
+ FileUtils.writeByteArrayToFile(file1, byteArray);*/
|
|
|
+
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.updateFile(byteArray, SnowFlakeUtil.getId() + ".pdf");
|
|
|
+ if (bladeFile != null) {
|
|
|
+ //更新最新的认证电签pdfUrl
|
|
|
+ jdbcTemplate.execute("update u_archive_file set is_certification = 1,e_visa_file = '" + bladeFile.getLink() + "',certification_time = '" + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + "' where id = " + taskArchiveDTO.getTaskId());
|
|
|
+ String successMsg = SUCCESS + "@@@@" + bladeFile.getLink();
|
|
|
+ logger.info(successMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 东方 中讯
|
|
|
*
|
|
@@ -605,12 +762,15 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
//对图片进行扣白底
|
|
|
imageData = ImageUtil.transferAlpha(imageData);
|
|
|
|
|
|
- //设置大小
|
|
|
- if (vo.isCompanySeal()) {
|
|
|
- imageData = ImageUtil.resizeImage(imageData, 540, 540);
|
|
|
- } else {
|
|
|
- imageData = ImageUtil.resizeImage(imageData, 480, 132);
|
|
|
-// imageData = ImageUtil.resizeImage(imageData,540,540);
|
|
|
+ //设置大小(首先排查档案水印章,因为水印章要保持原样)
|
|
|
+ if (!vo.getImageUrl().equals("https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230911/5b42583d931664b785ebf481c37d17bc.png")) {
|
|
|
+ if (vo.isCompanySeal()) {
|
|
|
+ //合同章
|
|
|
+ imageData = ImageUtil.resizeImage(imageData, 540, 540);
|
|
|
+ } else {
|
|
|
+ //非合同章
|
|
|
+ imageData = ImageUtil.resizeImage(imageData, 480, 132);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//图片dpi设置
|
|
@@ -635,7 +795,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
sealStrategy.setOffsetX(vo.getOffSetX());
|
|
|
sealStrategy.setOffsetY(vo.getOffSetY());
|
|
|
} else if (vo.getSealType().equals("2")) {
|
|
|
- //设置PDF坐标原点,签章图片定位点 默认为PDF左下角,签章图片定位为左下角
|
|
|
+ //设置PDF坐标原点,签章图片定位点,默认为PDF左下角,签章图片定位为左下角
|
|
|
if (StringUtils.isNotEmpty(vo.getIsCenterCoordinate())) {
|
|
|
sealStrategy.setIsCenterCoordinate(vo.getIsCenterCoordinate());
|
|
|
}
|