|
@@ -0,0 +1,529 @@
|
|
|
+package org.springblade.evisa.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import cfca.paperless.base.util.Base64;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.io.file.FileReader;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.feign.TaskClient;
|
|
|
+import org.springblade.business.vo.TaskSignInfoVO;
|
|
|
+import org.springblade.common.constant.EVisaConstant;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.evisa.service.EVDataService;
|
|
|
+import org.springblade.evisa.service.EVisaService;
|
|
|
+import org.springblade.evisa.utils.FileUtils;
|
|
|
+import org.springblade.evisa.utils.PDFUtils;
|
|
|
+import org.springblade.evisa.utils.SignFtpUtil;
|
|
|
+import org.springblade.evisa.vo.*;
|
|
|
+import org.springblade.manager.entity.ProjectInfo;
|
|
|
+import org.springblade.manager.feign.ProjectClient;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class EVDataServiceImpl implements EVDataService {
|
|
|
+
|
|
|
+ //jdbc对象
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final ProjectClient projectClient;
|
|
|
+ private final TaskClient taskClient;
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+ //电签服务类
|
|
|
+ private final EVisaService eVisaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StringRedisTemplate RedisTemplate;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 电签主要流程
|
|
|
+ *
|
|
|
+ * @param taskApp
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void signTaskBatch(TaskSignInfoVO taskApp) {
|
|
|
+ //获取pdf 文件
|
|
|
+ this.getSignPdfInfo(taskApp);
|
|
|
+ if (taskApp.getSigState() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String fileUrl = CommonUtil.replaceOssUrl(taskApp.getSignPdfUrl());
|
|
|
+ List<String> eVisaConfigList = PDFUtils.getPdfSignIds(fileUrl);
|
|
|
+ String ids = String.join(",", eVisaConfigList);
|
|
|
+ if (taskApp.getRemarkType().equals("1")) { //安心签
|
|
|
+ //添加电签策略
|
|
|
+ List<SealStrategyVO> strategyListByAXQ = getStrategyListByAXQ(taskApp, ids);
|
|
|
+ if (taskApp.getSigState() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //调用签字逻辑
|
|
|
+ signTaskBatchByAXQZ(strategyListByAXQ, taskApp);
|
|
|
+ if (taskApp.getSigState() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 回归处理
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ if (taskApp.getSigState() != 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else if (taskApp.getRemarkType().equals("2")) { //东方中讯
|
|
|
+ //添加电签策略
|
|
|
+ List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp, ids);
|
|
|
+ //调用签字逻辑
|
|
|
+ signTaskBatchByDFZX(strategyListByDFZX, fileUrl);
|
|
|
+ // 回归处理
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断签章信息
|
|
|
+ String sql = "SELECT a.* from u_task_parallel a where a.process_instance_id=(SELECT process_instance_id from u_task_parallel b where b.parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "') and is_deleted=0 and initiative<>2 ";
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
+ if (maps == null || maps.size() == 0) {
|
|
|
+ taskApp.setSigType(2);
|
|
|
+ if (taskApp.getRemarkType().equals("1")) { //安心签
|
|
|
+ //添加电签策略
|
|
|
+ List<SealStrategyVO> strategyListByAXQ = getStrategyListByAXQ(taskApp, ids);
|
|
|
+ //调用签字逻辑
|
|
|
+ signTaskBatchByAXQZ(strategyListByAXQ, taskApp);
|
|
|
+ // 回归处理
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+
|
|
|
+ } else if (taskApp.getRemarkType().equals("2")) { //东方中讯
|
|
|
+ //添加电签策略
|
|
|
+ List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp, ids);
|
|
|
+ //调用签字逻辑
|
|
|
+ signTaskBatchByDFZX(strategyListByDFZX, fileUrl);
|
|
|
+ // 回归处理
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取pdf 文件
|
|
|
+ @Transactional
|
|
|
+ public void SignBackPdfInfo(TaskSignInfoVO taskApp) {
|
|
|
+ Integer totalCount= this.jdbcTemplate.queryForObject("select exe_count from u_task_parallel where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'",Integer.class);
|
|
|
+ //上报类型: 1填报资料,2工程文件,3日志资料
|
|
|
+ //档案:4档案数据 ,
|
|
|
+ //计量: 5中间计量申请,6材料计量单 ,7开工预付款计量单, 8变更令
|
|
|
+ try {
|
|
|
+ if (taskApp.getApprovalType() == 1) {
|
|
|
+ if (taskApp.getSigType() == 2) {
|
|
|
+ this.jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status=2,update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "' ");
|
|
|
+ this.jdbcTemplate.execute("update u_task set status=2,update_time=SYSDATE() where id=" + taskApp.getId());
|
|
|
+ } else {
|
|
|
+ this.jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "', update_time=SYSDATE() where id='" + taskApp.getFormDataId() + "'");
|
|
|
+ this.jdbcTemplate.execute("update u_task_parallel set status=2,initiative=2 ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
|
|
|
+ this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
|
|
|
+ RedisTemplate.delete("sign-" + taskApp.getFormDataId());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (taskApp.getApprovalType() == 2) {
|
|
|
+
|
|
|
+ } else if (taskApp.getApprovalType() == 3) {
|
|
|
+
|
|
|
+ } else if (taskApp.getApprovalType() == 4) {
|
|
|
+
|
|
|
+ } else if (taskApp.getApprovalType() == 5) {
|
|
|
+ if (taskApp.getSigState() == 1) { //成功
|
|
|
+ this.jdbcTemplate.execute("update s_interim_pay_certificate set approve_status=" + taskApp.getSigType() + ",update_time=SYSDATE(), raw_url='" + taskApp.getLastFilePdfUrl() + "' where contract_period_id = " + taskApp.getFormDataId());
|
|
|
+ this.jdbcTemplate.execute("update u_task_parallel set e_visa_status=1,e_visa_content='" + taskApp.getSignSmg() + "' , status=2 , initiative=2 ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
|
|
|
+ this.jdbcTemplate.execute("update u_task set status=" + taskApp.getSigType() + " ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
|
|
|
+ this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
|
|
|
+ } else {
|
|
|
+ this.jdbcTemplate.execute("update s_interim_pay_certificate set approve_status=1,update_time=SYSDATE() where contract_period_id = " + taskApp.getFormDataId());
|
|
|
+ this.jdbcTemplate.execute("update u_task_parallel set exe_count=(exe_count+1), e_visa_status=99,e_visa_content='" + taskApp.getSignSmg() + "' ,update_time=SYSDATE() where parallel_process_instance_id='" + taskApp.getParallelProcessInstanceId() + "'");
|
|
|
+ this.jdbcTemplate.execute("update u_task set status=1 ,update_time=SYSDATE() where id='" + taskApp.getTaskId() + "'");
|
|
|
+ if(totalCount>=3){
|
|
|
+ this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RedisTemplate.delete("sign-" + taskApp.getFormDataId());
|
|
|
+ } else if (taskApp.getApprovalType() == 6 || taskApp.getApprovalType() == 7) {
|
|
|
+ this.jdbcTemplate.execute("update s_material_start_statement set raw_url='" + taskApp.getLastFilePdfUrl() + "' where meter_period_id = " + taskApp.getFormDataId());
|
|
|
+ this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
|
|
|
+ RedisTemplate.delete("sign-" + taskApp.getFormDataId());
|
|
|
+ } else if (taskApp.getApprovalType() == 8) {
|
|
|
+ if (taskApp.getSigType() == 2) {
|
|
|
+ this.jdbcTemplate.execute("update u_entrust_info set sample_status=2,status=" + (taskApp.getSigType() + 1) + ",entrust_e_pdf='" + taskApp.getLastFilePdfUrl() + "' where id=(SELECT wbs_id from u_information_query where id='" + taskApp.getFormDataId() + "')");
|
|
|
+ }
|
|
|
+ jdbcTemplate.execute("update u_information_query set e_visa_pdf_url='" + taskApp.getLastFilePdfUrl() + "',status=" + taskApp.getSigType() + " where id='" + taskApp.getFormDataId() + "'");
|
|
|
+ this.jdbcTemplate.execute("delete from u_task_batch where id=" + taskApp.getId());
|
|
|
+ RedisTemplate.delete("sign-" + taskApp.getFormDataId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("修改业务数据异常-请联系开发人员");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取pdf 文件
|
|
|
+ public void getSignPdfInfo(TaskSignInfoVO taskApp) {
|
|
|
+ //上报类型: 1填报资料,2工程文件,3日志资料
|
|
|
+ //档案:4档案数据 ,
|
|
|
+ //计量: 5中间计量申请,6材料计量单 ,7开工预付款计量单, 8变更令
|
|
|
+ taskApp.setSigType(1);
|
|
|
+ taskApp.setSigState(1);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ if (taskApp.getApprovalType() == 1) {
|
|
|
+ map = this.jdbcTemplate.queryForMap("select * from u_information_query where is_deleted=0 and id = " + taskApp.getFormDataId());
|
|
|
+ String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
|
|
|
+ taskApp.setSignPdfUrl(url);
|
|
|
+ taskApp.setContractId(map.get("contract_id") + "");
|
|
|
+ taskApp.setProjectId(map.get("project_id") + "");
|
|
|
+ } else if (taskApp.getApprovalType() == 2) {
|
|
|
+ map = this.jdbcTemplate.queryForMap("select * from u_information_query where is_deleted=0 and id = " + taskApp.getFormDataId());
|
|
|
+ String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
|
|
|
+ taskApp.setSignPdfUrl(url);
|
|
|
+ taskApp.setContractId(map.get("contract_id") + "");
|
|
|
+ taskApp.setProjectId(map.get("project_id") + "");
|
|
|
+ } else if (taskApp.getApprovalType() == 3) {
|
|
|
+ map = this.jdbcTemplate.queryForMap("select * from u_information_query where is_deleted=0 and id = " + taskApp.getFormDataId());
|
|
|
+ String url = StringUtils.isNotEmpty(map.get("e_visa_pdf_url") + "") ? map.get("e_visa_pdf_url") + "" : map.get("pdf_url") + "";
|
|
|
+ taskApp.setSignPdfUrl(url);
|
|
|
+ taskApp.setContractId(map.get("contract_id") + "");
|
|
|
+ taskApp.setProjectId(map.get("project_id") + "");
|
|
|
+ } else if (taskApp.getApprovalType() == 4) {
|
|
|
+
|
|
|
+ } else if (taskApp.getApprovalType() == 5) {
|
|
|
+ map = this.jdbcTemplate.queryForMap("select * from s_interim_pay_certificate where is_deleted=0 and contract_period_id = " + taskApp.getFormDataId());
|
|
|
+ taskApp.setSignPdfUrl(map.get("raw_url") + "");
|
|
|
+ taskApp.setContractId(map.get("contract_id") + "");
|
|
|
+ taskApp.setProjectId(map.get("project_id") + "");
|
|
|
+ } else if (taskApp.getApprovalType() == 6 || taskApp.getApprovalType() == 7) {
|
|
|
+ map = this.jdbcTemplate.queryForMap("select * from s_material_start_statement where is_deleted=0 and meter_period_id = " + taskApp.getFormDataId());
|
|
|
+ taskApp.setSignPdfUrl(map.get("raw_url") + "");
|
|
|
+ taskApp.setContractId(map.get("contract_id") + "");
|
|
|
+ taskApp.setProjectId(map.get("project_id") + "");
|
|
|
+ } else if (taskApp.getApprovalType() == 8) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (taskApp.getSignPdfUrl() == null || taskApp.getSignPdfUrl() == "" || Func.isEmpty(taskApp.getSignPdfUrl()) || taskApp.getSignPdfUrl().length() <= 10) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("未获取到PDF信息");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (taskApp.getContractId() == null || taskApp.getContractId() == "" || Func.isEmpty(taskApp.getContractId()) || taskApp.getContractId().length() <= 10) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("未获取到合同段Id");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (taskApp.getProjectId() == null || taskApp.getProjectId() == "" || Func.isEmpty(taskApp.getProjectId()) || taskApp.getProjectId().length() <= 10) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("未获取项目Id");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ProjectInfo projectInfo = projectClient.getById(taskApp.getProjectId());
|
|
|
+ if (projectInfo == null || Func.isEmpty(projectInfo)) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("未获取项目信息");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ Integer remarkType = projectInfo.getRemarkType();
|
|
|
+ if (remarkType != null && Func.isNotEmpty(remarkType) && remarkType == 2) {
|
|
|
+ taskApp.setRemarkType("2");
|
|
|
+ } else {
|
|
|
+ taskApp.setRemarkType("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("获取pdf信息异常");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加电签策略 -- 安心签
|
|
|
+ public List<Map<String, Object>> getStrategyListByDFZX(TaskSignInfoVO task, String ids) {
|
|
|
+
|
|
|
+ String sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(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.type =2 and a.id in (" + ids + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c where c.contract_id=" + task.getContractId() + " and user_id=" + task.getUserId() + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
|
|
|
+ if (task.getSigType() == 2) {
|
|
|
+ sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sqlinfo);
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
|
|
|
+ .collect(Collectors.groupingBy(hada -> (Func.toStr(hada.get("id")))));
|
|
|
+
|
|
|
+ for (String keyId : peopleByAge.keySet()) {
|
|
|
+ int exId = 0;
|
|
|
+ List<Map<String, Object>> keyList = peopleByAge.get(keyId);
|
|
|
+ if (keyList != null && keyList.size() == 1) {
|
|
|
+ maps.addAll(keyList);
|
|
|
+ exId = 1;
|
|
|
+ } else if (keyList != null && keyList.size() >= 2) {
|
|
|
+ for (Map<String, Object> datax : keyList) {
|
|
|
+ if ((datax.get("project_id") + "").equals(task.getProjectId())) {
|
|
|
+ maps.add(datax);
|
|
|
+ exId = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (exId == 0) {
|
|
|
+ maps.add(keyList.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return maps;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加电签策略 -- 安心签
|
|
|
+ public List<SealStrategyVO> getStrategyListByAXQ(TaskSignInfoVO task, String ids) {
|
|
|
+ List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
|
+ String sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(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.type =2 and a.id in (" + ids + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c where c.contract_id=" + task.getContractId() + " and user_id=" + task.getUserId() + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
|
|
|
+ if (task.getSigType() == 2) {
|
|
|
+ sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sqlinfo);
|
|
|
+ if (maps2 == null && maps2.size() <= 0) {
|
|
|
+ task.setSigState(2);
|
|
|
+ task.setSignSmg("未查询到电签策略");
|
|
|
+ SignBackPdfInfo(task);
|
|
|
+ return sealStrategyVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
|
|
|
+ .collect(Collectors.groupingBy(hada -> (Func.toStr(hada.get("id")))));
|
|
|
+
|
|
|
+ for (String keyId : peopleByAge.keySet()) {
|
|
|
+ int exId = 0;
|
|
|
+ List<Map<String, Object>> keyList = peopleByAge.get(keyId);
|
|
|
+ if (keyList != null && keyList.size() == 1) {
|
|
|
+ maps.addAll(keyList);
|
|
|
+ exId = 1;
|
|
|
+ } else if (keyList != null && keyList.size() >= 2) {
|
|
|
+ for (Map<String, Object> datax : keyList) {
|
|
|
+ if ((datax.get("project_id") + "").equals(task.getProjectId())) {
|
|
|
+ maps.add(datax);
|
|
|
+ exId = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (exId == 0) {
|
|
|
+ maps.add(keyList.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (maps == null || maps.size() <= 0) {
|
|
|
+ task.setSigState(2);
|
|
|
+ task.setSignSmg("没有签字体的数据");
|
|
|
+ SignBackPdfInfo(task);
|
|
|
+ return sealStrategyVOS;
|
|
|
+ }
|
|
|
+ //准备签章策略
|
|
|
+
|
|
|
+ for (Map<String, Object> eVisaConfig : maps) {
|
|
|
+ //设置签章策略
|
|
|
+ SealStrategyVO vo = new SealStrategyVO();
|
|
|
+ if (task.getSigType() == 1) {
|
|
|
+ String userId = task.getUserId() + "";
|
|
|
+ vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + userId);
|
|
|
+ if (userId.length() <= EVisaConstant.USER_ID_SUB) {
|
|
|
+ vo.setSealPassword(task.getUserId().toString());
|
|
|
+ } else {
|
|
|
+ vo.setSealPassword(task.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
|
|
|
+ }
|
|
|
+ vo.setSealPerson(task.getNickName());
|
|
|
+ //设置签字文件
|
|
|
+ vo.setImageUrl(eVisaConfig.get("signature_file_url") + "");
|
|
|
+ vo.setSealType("3");
|
|
|
+ vo.setKeyword(eVisaConfig.get("id") + "");
|
|
|
+ vo.setOffSetX(eVisaConfig.get("pyzbx") + "");
|
|
|
+ vo.setOffSetY(eVisaConfig.get("pyzby") + "");
|
|
|
+ } else if (task.getSigType() == 2) {
|
|
|
+ vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + eVisaConfig.get("sfId"));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return sealStrategyVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加电签策略 -- 东方中讯
|
|
|
+ public String signTaskBatchByDFZX(List<Map<String, Object>> maps, String pdfUrl) {
|
|
|
+ if (maps != null && maps.size() > 0) {
|
|
|
+ String fileUrl = pdfUrl;
|
|
|
+ for (Map<String, Object> dataMap : maps) {
|
|
|
+ HashMap<String, Object> daMa = new HashMap<>();
|
|
|
+ daMa.put("keyWord", dataMap.get("keyWord"));
|
|
|
+ daMa.put("sealId", dataMap.get("sealId"));
|
|
|
+ // 设置图片显示大小
|
|
|
+ daMa.put("showHeight", 30);
|
|
|
+ daMa.put("showWidth", 60);
|
|
|
+ //设置显示签字体的位置
|
|
|
+ String yzx = dataMap.get("pyzby") + "";
|
|
|
+ String xzx = dataMap.get("pyzbx") + "";
|
|
|
+ Double sealOffsetY = Func.toDouble(yzx) - 15;
|
|
|
+ Double sealOffsetX = Func.toDouble(xzx) - 30;
|
|
|
+ daMa.put("sealOffsetX", sealOffsetX);
|
|
|
+ daMa.put("sealOffsetY", sealOffsetY);
|
|
|
+ byte[] fileByte = new byte[0];
|
|
|
+ if (fileUrl.indexOf("aliyuncs.com") >= 0 || fileUrl.indexOf("183.247.216.148") >= 0 || fileUrl.indexOf("152.168.2.15") >= 0) {
|
|
|
+ try {
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(pdfUrl);
|
|
|
+ fileByte = IOUtils.toByteArray(inputStreamByUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("123");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ FileReader fileReader = new FileReader(fileUrl);
|
|
|
+ fileByte = fileReader.readBytes();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String originalFileB64 = Base64.toBase64String(fileByte);
|
|
|
+ daMa.put("fileB64", originalFileB64);
|
|
|
+ daMa.put("lastSignFlag", false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ String reData = eVisaService.signPdfByDFZX(daMa);
|
|
|
+ if (reData.indexOf("success@") >= 0) {
|
|
|
+ fileUrl = reData.split("@@@@")[1];
|
|
|
+ } else {
|
|
|
+ return reData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fileUrl.indexOf("aliyuncs.com") >= 0) {
|
|
|
+ System.out.println("电签失败");
|
|
|
+ } else {
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.length()), fileUrl);
|
|
|
+ if (bladeFile != null) {
|
|
|
+ System.out.println("pdf上传=" + bladeFile.getLink());
|
|
|
+ return "sucess@@@@" + bladeFile.getLink();
|
|
|
+ } else {
|
|
|
+ return "电签成功";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return "sucess@@@@" + pdfUrl;
|
|
|
+ }
|
|
|
+ return "sucess@@@@" + pdfUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 安心签 - 关键字策略
|
|
|
+ public void signTaskBatchByAXQZ(List<SealStrategyVO> list, TaskSignInfoVO taskApp) {
|
|
|
+ String pdfUrl = taskApp.getSignPdfUrl();
|
|
|
+ if (Func.isEmpty(pdfUrl) || list == null) {
|
|
|
+ taskApp.setLastFilePdfUrl(pdfUrl);
|
|
|
+ }
|
|
|
+ String sysLocalFileUrl = FileUtils.getSysLocalFileUrl();
|
|
|
+ String filecode = SnowFlakeUtil.getId() + "";
|
|
|
+ String dataFileUrl = sysLocalFileUrl + "/pdf/" + filecode + ".pdf";
|
|
|
+
|
|
|
+ SealPdfVO pdfVO = new SealPdfVO();
|
|
|
+ pdfVO.setStrategyVoList(list);
|
|
|
+ byte[] fileByte;
|
|
|
+ if (pdfUrl.indexOf("aliyuncs.com") >= 0 || pdfUrl.indexOf("183.247.216.148") >= 0 || pdfUrl.indexOf("152.168.2.15") >= 0) {
|
|
|
+ try {
|
|
|
+ InputStream inputStreamByUrl = CommonUtil.getOSSInputStreamTow(pdfUrl);
|
|
|
+ fileByte = IOUtils.toByteArray(inputStreamByUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("获取PDF字符流失败");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ FileReader fileReader = new FileReader(pdfUrl);
|
|
|
+ fileByte = fileReader.readBytes();
|
|
|
+ }
|
|
|
+
|
|
|
+ Object[] result = null;
|
|
|
+ String fileUrl = pdfUrl;
|
|
|
+ if (list.size() >= 15 || fileByte.length > 10 * 1000 * 1000) {
|
|
|
+ String inUrl = "/inp/" + DateUtil.today();
|
|
|
+ String outUrl = "/out/" + DateUtil.today();
|
|
|
+ SignFtpUtil.FTPCreateDir(inUrl);
|
|
|
+ SignFtpUtil.FTPCreateDir(outUrl);
|
|
|
+ String locPdfUrl = inUrl + "/" + filecode + ".pdf";
|
|
|
+ String OutPdfUrl = outUrl + "/" + filecode + ".pdf";
|
|
|
+
|
|
|
+ InputStream inputStream = new ByteArrayInputStream(fileByte);
|
|
|
+ int i = SignFtpUtil.uploadFile(locPdfUrl, inputStream);
|
|
|
+ if (i == 1) {
|
|
|
+ result = eVisaService.signPdfByAXQZ(pdfVO, locPdfUrl, OutPdfUrl);
|
|
|
+ int i1 = SignFtpUtil.downloadFile(dataFileUrl, OutPdfUrl);
|
|
|
+ fileUrl = dataFileUrl;
|
|
|
+ SignFtpUtil.FTPDeleteDir(locPdfUrl);
|
|
|
+ SignFtpUtil.FTPDeleteDir(OutPdfUrl);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result = eVisaService.signPdfByAXQZ(pdfVO, fileByte);
|
|
|
+ //执行电签
|
|
|
+ if (result != null) {
|
|
|
+ try {
|
|
|
+ ByteArrayInputStream inputStream = new ByteArrayInputStream((byte[]) result[0]);
|
|
|
+ FileOutputStream fout = new FileOutputStream(dataFileUrl);
|
|
|
+ int bytesRead = 0;
|
|
|
+ byte[] buffer = new byte[8192];
|
|
|
+ while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
|
|
|
+ fout.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ fout.close();
|
|
|
+ fileUrl = dataFileUrl;
|
|
|
+ } catch (Exception e) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("二进制流读取本地失败");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileUrl.indexOf("aliyuncs.com") >= 0 || fileUrl.indexOf("183.247.216.148") >= 0 || fileUrl.indexOf("152.168.2.15") >= 0) {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("电签后-无法读取本地文件");
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + ".pdf", fileUrl);
|
|
|
+ if (bladeFile != null) {
|
|
|
+ taskApp.setLastFilePdfUrl(bladeFile.getLink());
|
|
|
+ taskApp.setSignSmg("电签成功");
|
|
|
+ } else {
|
|
|
+ taskApp.setSigState(2);
|
|
|
+ taskApp.setSignSmg("上传OSS失败"+fileUrl);
|
|
|
+ SignBackPdfInfo(taskApp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|