|
@@ -40,8 +40,10 @@ import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.utils.FileUtil;
|
|
import org.springblade.core.tool.utils.FileUtil;
|
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.evisa.redissionUtil.DistributedRedisLock;
|
|
import org.springblade.evisa.redissionUtil.DistributedRedisLock;
|
|
import org.springblade.evisa.service.EVisaService;
|
|
import org.springblade.evisa.service.EVisaService;
|
|
|
|
+import org.springblade.evisa.utils.PDFUtils;
|
|
import org.springblade.evisa.vo.EVisaMakeSealVO;
|
|
import org.springblade.evisa.vo.EVisaMakeSealVO;
|
|
import org.springblade.evisa.vo.EVisaTaskApprovalVO;
|
|
import org.springblade.evisa.vo.EVisaTaskApprovalVO;
|
|
import org.springblade.evisa.vo.SealPdfVO;
|
|
import org.springblade.evisa.vo.SealPdfVO;
|
|
@@ -57,6 +59,10 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|
|
|
+import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
|
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.client.RestTemplate;
|
|
@@ -70,10 +76,7 @@ import javax.imageio.stream.ImageOutputStream;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
@@ -106,6 +109,9 @@ public class EVisaServiceImpl implements EVisaService {
|
|
@Autowired
|
|
@Autowired
|
|
StringRedisTemplate RedisTemplate;
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public String certification(String pdfUrl, String fileName, String contractId) {
|
|
public String certification(String pdfUrl, String fileName, String contractId) {
|
|
try {
|
|
try {
|
|
@@ -213,6 +219,83 @@ public class EVisaServiceImpl implements EVisaService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
|
|
+
|
|
|
|
+ //获取任务对应表格的电签配置(合同张)
|
|
|
|
+ String sysBatch = ParamCache.getValue(CommonConstant.SYS_USER_TASK_BATCH);
|
|
|
|
+ int batch = 2;
|
|
|
|
+ if (CommonUtil.checkIsBigDecimal(sysBatch)) {
|
|
|
|
+ batch = new Integer(sysBatch);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (DistributedRedisLock.acquire(AuthUtil.getUserId().toString(), batch)) {
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ List<String> eVisaConfigList = PDFUtils.getPdfSignIds(finalPdfUrl);
|
|
|
|
+ if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
|
|
|
|
+ return finalPdfUrl;
|
|
|
|
+ }
|
|
|
|
+ String contractId = this.taskClient.queryTaskContractId(task.getParallelProcessInstanceId());
|
|
|
|
+
|
|
|
|
+ String ids = String.join(",", eVisaConfigList);
|
|
|
|
+ String sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,b.certificate_password,b.certificate_user_name from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + contractId + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
|
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlinfo);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //准备签章策略
|
|
|
|
+ List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
|
|
+ for (Map<String, Object> eVisaConfig : maps) {
|
|
|
|
+ //设置签章策略
|
|
|
|
+ SealStrategyVO vo = new SealStrategyVO();
|
|
|
|
+ vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + eVisaConfig.get("id"));
|
|
|
|
+ vo.setSealPassword(eVisaConfig.get("certificate_password")+"");
|
|
|
|
+ vo.setSealPerson(eVisaConfig.get("certificate_user_name")+"" + System.currentTimeMillis());
|
|
|
|
+ //设置签字文件
|
|
|
|
+ vo.setImageUrl(eVisaConfig.get("signature_file_url")+"");
|
|
|
|
+ vo.setSealType("3");
|
|
|
|
+ vo.setCompanySeal(true);
|
|
|
|
+ vo.setKeyword(eVisaConfig.get("id")+"");
|
|
|
|
+ vo.setOffSetX(eVisaConfig.get("pyzbx")+"");
|
|
|
|
+ vo.setOffSetY(eVisaConfig.get("pyzby")+"");
|
|
|
|
+ sealStrategyVOS.add(vo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SealPdfVO pdfVO = new SealPdfVO();
|
|
|
|
+ pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
|
+
|
|
|
|
+ //获取字节
|
|
|
|
+ byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(finalPdfUrl));
|
|
|
|
+ //执行电签
|
|
|
|
+ Object[] result = this.signPdfByAXQZ(pdfVO, fileByte);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ if (result[0] != null) {
|
|
|
|
+ MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[]) result[0])));
|
|
|
|
+ //重新上传
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFileByInputStream(newFiles);
|
|
|
|
+ if (bladeFile != null) {
|
|
|
|
+ finalPdfUrl = bladeFile.getLink();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //释放锁
|
|
|
|
+ DistributedRedisLock.release(AuthUtil.getUserId().toString());
|
|
|
|
+
|
|
|
|
+ return finalPdfUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 合同章 签字
|
|
|
|
+ *
|
|
|
|
+ * @param task
|
|
|
|
+ * @param finalPdfUrl
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ public String eVisaContractSeal222(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
//获取任务对应表格的电签配置(合同张)
|
|
//获取任务对应表格的电签配置(合同张)
|
|
List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), task.getUserId(), "true");
|
|
List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), task.getUserId(), "true");
|
|
if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
|
|
if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
|
|
@@ -237,6 +320,8 @@ public class EVisaServiceImpl implements EVisaService {
|
|
System.out.println(AuthUtil.getUserId().toString());
|
|
System.out.println(AuthUtil.getUserId().toString());
|
|
if (DistributedRedisLock.acquire(AuthUtil.getUserId().toString(), batch)) {
|
|
if (DistributedRedisLock.acquire(AuthUtil.getUserId().toString(), batch)) {
|
|
try {
|
|
try {
|
|
|
|
+
|
|
|
|
+
|
|
//准备签章策略
|
|
//准备签章策略
|
|
List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
for (JSONObject eVisaConfig : eVisaConfigList) {
|
|
for (JSONObject eVisaConfig : eVisaConfigList) {
|
|
@@ -320,70 +405,62 @@ public class EVisaServiceImpl implements EVisaService {
|
|
return NOT_PFX_OR_FILE;
|
|
return NOT_PFX_OR_FILE;
|
|
}
|
|
}
|
|
|
|
|
|
- //获取任务对应表格的电签配置
|
|
|
|
- List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), task.getUserId(), "false");
|
|
|
|
- if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
|
|
|
|
- //没有电签配置,默认当前任务为不签字审批,返回成功
|
|
|
|
- RedisTemplate.delete("sign-" + task.getFormDataId());
|
|
|
|
- return SUCCESS + "@@@@" + taskFile.getApprovalFileList().get(0).getFileUrl();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //获取当前用户的证书信息
|
|
|
|
- List<SignPfxFile> userPfxList = this.signPfxClient.querySignPfxByUserIdOrContractId(task.getUserId().toString(), "");
|
|
|
|
- if (userPfxList == null || userPfxList.size() <= 0) {
|
|
|
|
- //没有签章,不执行电签
|
|
|
|
- RedisTemplate.delete("sign-" + task.getFormDataId());
|
|
|
|
- return NOT_PFX_OR_FILE;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//上锁
|
|
//上锁
|
|
- //if (DistributedRedisLock.acquire(task.getUserId().toString(), batch)) {
|
|
|
|
|
|
+ //if (DistributedRedisLock.acquire(task.getUserId().toString(), batch)) {*/
|
|
try {
|
|
try {
|
|
//获取需要签章的数据
|
|
//获取需要签章的数据
|
|
List<TaskApprovalVO.ApprovalFile> files = taskFile.getApprovalFileList();
|
|
List<TaskApprovalVO.ApprovalFile> files = taskFile.getApprovalFileList();
|
|
//这里的文件只会是一张拼接好的PDF
|
|
//这里的文件只会是一张拼接好的PDF
|
|
for (TaskApprovalVO.ApprovalFile file : files) {
|
|
for (TaskApprovalVO.ApprovalFile file : files) {
|
|
-
|
|
|
|
if (file.getFileName().contains("(关联试验文件)") || file.getFileName().contains("(关联试验工程部位信息文件)") || file.getFileName().contains("(原材料检测报告)")) {
|
|
if (file.getFileName().contains("(关联试验文件)") || file.getFileName().contains("(关联试验工程部位信息文件)") || file.getFileName().contains("(原材料检测报告)")) {
|
|
//TODO ============== 试验相关的关联文件不电签 liuYC 2023-03-17 ==============
|
|
//TODO ============== 试验相关的关联文件不电签 liuYC 2023-03-17 ==============
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ String pdfUrl = file.getFileUrl();
|
|
|
|
+ List<String> eVisaConfigList = PDFUtils.getPdfSignIds(pdfUrl);
|
|
|
|
+ if (eVisaConfigList == null || eVisaConfigList.size() == 0) {
|
|
|
|
+ //没有电签配置,默认当前任务为不签字审批,返回成功
|
|
|
|
+ RedisTemplate.delete("sign-" + task.getFormDataId());
|
|
|
|
+ return SUCCESS + "@@@@" + taskFile.getApprovalFileList().get(0).getFileUrl();
|
|
|
|
+ }
|
|
|
|
+ String contractId = this.taskClient.queryTaskContractId(task.getParallelProcessInstanceId());
|
|
|
|
+ String ids = String.join(",", eVisaConfigList);
|
|
|
|
+ String sqlinfo = " SELECT a.id,a.pyzbx ,a.pyzby,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + task.getUserId() + "' and is_deleted=0 ) as signature_file_url from m_textdict_info a where a.id in (" + ids + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c where c.contract_id=" + contractId + " and user_id=" + task.getUserId() + " and a.is_deleted=0 )";
|
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlinfo);
|
|
|
|
+ System.out.println("user-id"+task.getUserId()+"--SQL="+sqlinfo);
|
|
|
|
+ if (maps == null || maps.size() <= 0) {
|
|
|
|
+ //没有签章,不执行电签
|
|
|
|
+ RedisTemplate.delete("sign-" + task.getFormDataId());
|
|
|
|
+ return NOT_PFX_OR_FILE;
|
|
|
|
+ }
|
|
//准备签章策略
|
|
//准备签章策略
|
|
List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
- for (JSONObject eVisaConfig : eVisaConfigList) {
|
|
|
|
|
|
+ for (Map<String, Object> eVisaConfig : maps) {
|
|
//设置签章策略
|
|
//设置签章策略
|
|
SealStrategyVO vo = new SealStrategyVO();
|
|
SealStrategyVO vo = new SealStrategyVO();
|
|
vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + task.getUserId());
|
|
vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + task.getUserId());
|
|
vo.setSealPassword(task.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
|
|
vo.setSealPassword(task.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
|
|
vo.setSealPerson(task.getNickName());
|
|
vo.setSealPerson(task.getNickName());
|
|
//设置签字文件
|
|
//设置签字文件
|
|
- vo.setImageUrl(userPfxList.get(0).getSignatureFileUrl());
|
|
|
|
|
|
+ vo.setImageUrl(eVisaConfig.get("signature_file_url") + "");
|
|
vo.setSealType("3");
|
|
vo.setSealType("3");
|
|
-
|
|
|
|
- vo.setKeyword(eVisaConfig.getString("KEY"));
|
|
|
|
- vo.setOffSetX(eVisaConfig.getString("X"));
|
|
|
|
- vo.setOffSetY(eVisaConfig.getString("Y"));
|
|
|
|
|
|
+ vo.setKeyword(eVisaConfig.get("id") + "");
|
|
|
|
+ vo.setOffSetX(eVisaConfig.get("pyzbx") + "");
|
|
|
|
+ vo.setOffSetY(eVisaConfig.get("pyzby") + "");
|
|
sealStrategyVOS.add(vo);
|
|
sealStrategyVOS.add(vo);
|
|
}
|
|
}
|
|
SealPdfVO pdfVO = new SealPdfVO();
|
|
SealPdfVO pdfVO = new SealPdfVO();
|
|
pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
|
|
|
//获取字节
|
|
//获取字节
|
|
- byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(file.getFileUrl()));
|
|
|
|
|
|
+ byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(pdfUrl));
|
|
//执行电签
|
|
//执行电签
|
|
Object[] result = this.signPdfByAXQZ(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])));
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
|
|
+ MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[]) result[0])));
|
|
//重新上传
|
|
//重新上传
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + ".pdf",dataUrl);
|
|
|
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFileByInputStream(newFiles);
|
|
if (bladeFile != null) {
|
|
if (bladeFile != null) {
|
|
resultMessage = SUCCESS + "@@@@" + bladeFile.getLink();
|
|
resultMessage = SUCCESS + "@@@@" + bladeFile.getLink();
|
|
} else {
|
|
} else {
|