Przeglądaj źródła

档案电签相关

liuyc 1 rok temu
rodzic
commit
b5f2396d2d

+ 1 - 1
blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/feign/EVisaClient.java

@@ -36,7 +36,7 @@ public interface EVisaClient {
      * 电签(自定义签章)
      */
     @PostMapping(API_PREFIX + "/eVisa/custom")
-    void eVisaCustom(@RequestBody org.springblade.evisa.vo.TaskArchiveDTO eVisaObj);
+    String eVisaCustom(@RequestBody org.springblade.evisa.vo.TaskArchiveDTO eVisaObj);
 
     /**
      * 创建印模

+ 46 - 0
blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/feign/EVisaClientFallBack.java

@@ -0,0 +1,46 @@
+package org.springblade.evisa.feign;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springblade.evisa.vo.CertBeanVO;
+import org.springblade.evisa.vo.EVisaMakeSealVO;
+import org.springblade.evisa.vo.EVisaTaskApprovalVO;
+import org.springblade.evisa.vo.TaskArchiveDTO;
+import org.springframework.stereotype.Component;
+
+@Component
+public class EVisaClientFallBack implements EVisaClient {
+
+    private static final Logger logger = LoggerFactory.getLogger(EVisaClientFallBack.class);
+
+    @Override
+    public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
+        return null;
+    }
+
+    @Override
+    public String eVisa(EVisaTaskApprovalVO task) {
+        return null;
+    }
+
+    @Override
+    public String eVisaCustom(TaskArchiveDTO eVisaObj) {
+        logger.info("-----------------远程feign调用电签自定义签章服务EVisaCustom方法失败-----------------");
+        return "500";
+    }
+
+    @Override
+    public String createSeal(EVisaMakeSealVO vo) {
+        return null;
+    }
+
+    @Override
+    public String certification(String pdfUrl, String fileName, String contractId) {
+        return null;
+    }
+
+    @Override
+    public CertBeanVO onlineCheckSeal(String pdfUrl) {
+        return null;
+    }
+}

+ 10 - 9
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileTaskController.java

@@ -103,20 +103,21 @@ public class ArchiveFileTaskController extends BladeController {
                             signList.add(sign);
                         }
                         eVISATaskArchiveDTO.setSealStrategy(signList);
+                        eVISATaskArchiveDTO.setTaskId(archiveFile.getId().toString());
+                        eVISATaskArchiveDTO.setType(2); //认证
 
-                        try {
-                            //TODO ============= 电签认证 =============
-                            eVISATaskArchiveDTO.setTaskId(archiveFile.getId().toString());
-                            eVISATaskArchiveDTO.setType(2); //认证
-                            this.eVisaClient.eVisaCustom(eVISATaskArchiveDTO);
-                        } catch (Exception e) {
-                            e.getStackTrace();
-                            throw new ServiceException("电签服务器调用失败,请联系管理员,原因:" + e.getMessage());
+                        //TODO ============= 电签认证 =============
+                        String resultMsg = this.eVisaClient.eVisaCustom(eVISATaskArchiveDTO);
+                        if (StringUtils.isEmpty(resultMsg) || ("500").equals(resultMsg)) {
+                            throw new ServiceException("电签服务发生异常,请联系管理员!");
+                        }
+                        if (resultMsg.contains("success@@@@")) {
+                            return R.data(true);
                         }
                     }
                 }
-                return R.data(true);
             }
+            return R.fail("操作失败");
         }
         return R.data(300, false, "没有找到证书文件或PDF文件");
     }

+ 24 - 24
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -618,36 +618,36 @@ public class TaskController extends BladeController {
                     //通过checkArchiveTaskUserByCurrent检查,说明当前登陆用户是该条任务的审批人,修改审批任务状态
                     Task task = jdbcTemplate.queryForObject("select process_instance_id,form_data_id from u_task where id = " + taskArchiveDTO.getTaskId(), new BeanPropertyRowMapper<>(Task.class));
                     if (task != null) {
-                        //TODO ============ 档案电签推送(每个人都要电签,按照顺序) ============
                         org.springblade.evisa.vo.TaskArchiveDTO eVisaObj = new org.springblade.evisa.vo.TaskArchiveDTO();
                         BeanUtils.copyProperties(taskArchiveDTO, eVisaObj);
                         eVisaObj.setType(1); //审批
-                        try {
-                            this.eVisaClient.eVisaCustom(eVisaObj);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                            throw new ServiceException("电签服务器调用失败,请联系管理员,原因:" + e.getMessage());
-                        }
 
-                        //获取审批任务关联用户的详情
-                        List<TaskParallel> taskParallels = jdbcTemplate.query("select id,process_instance_id,task_user,task_user_name from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
-                        if (taskParallels.size() > 0) {
-                            //当前用户任务
-                            TaskParallel taskParallelCurrentUser = taskParallels.stream().filter(f -> f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
-                            if (taskParallelCurrentUser != null) {
-                                //修改当前用户任务为已审批、电签任务状态为成功
-                                jdbcTemplate.execute("update u_task_parallel set status = 2,e_visa_status = 1 where id = " + taskParallelCurrentUser.getId());
-                            }
+                        //TODO ============ 电签审批(每个人都需要电签,按照顺序垂直审批) ============
+                        String resultMsg = this.eVisaClient.eVisaCustom(eVisaObj);
+                        if (StringUtils.isEmpty(resultMsg) || ("500").equals(resultMsg)) {
+                            throw new ServiceException("电签服务发生异常,请联系管理员!");
                         }
+                        if (resultMsg.contains("success@@@@")) {
+                            //获取审批任务关联用户的详情
+                            List<TaskParallel> taskParallels = jdbcTemplate.query("select id,process_instance_id,task_user,task_user_name from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
+                            if (taskParallels.size() > 0) {
+                                //当前用户任务
+                                TaskParallel taskParallelCurrentUser = taskParallels.stream().filter(f -> f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
+                                if (taskParallelCurrentUser != null) {
+                                    //修改当前用户任务为已审批、电签任务状态为成功
+                                    jdbcTemplate.execute("update u_task_parallel set status = 2,e_visa_status = 1 where id = " + taskParallelCurrentUser.getId());
+                                }
+                            }
 
-                        //获取最新任务状态,判断是否存在未完成的审批任务(最后一个人审批完成);如果没有就闭环,修改审批任务状态、业务数据状态
-                        List<TaskParallel> taskParallelsNow = jdbcTemplate.query("select status from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
-                        List<TaskParallel> pendingApprovalTask = taskParallelsNow.stream().filter(f -> f.getStatus() != 2).collect(Collectors.toList());
-                        if (pendingApprovalTask.size() == 0) {
-                            //修改审批任务状态
-                            jdbcTemplate.execute("update u_task set status = 2 where id = " + taskArchiveDTO.getTaskId());
-                            //修改业务数据状态
-                            jdbcTemplate.execute("update u_archive_file set status = 2 where id = " + task.getFormDataId());
+                            //获取最新任务状态,判断是否存在未完成的审批任务(最后一个人审批完成);如果没有就闭环,修改审批任务状态、业务数据状态
+                            List<TaskParallel> taskParallelsNow = jdbcTemplate.query("select status from u_task_parallel where process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
+                            List<TaskParallel> pendingApprovalTask = taskParallelsNow.stream().filter(f -> f.getStatus() != 2).collect(Collectors.toList());
+                            if (pendingApprovalTask.size() == 0) {
+                                //修改审批任务状态
+                                jdbcTemplate.execute("update u_task set status = 2 where id = " + taskArchiveDTO.getTaskId());
+                                //修改业务数据状态
+                                jdbcTemplate.execute("update u_archive_file set status = 2 where id = " + task.getFormDataId());
+                            }
                         }
                     }
                 }

+ 2 - 2
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/feign/EVisaClientImpl.java

@@ -48,8 +48,8 @@ public class EVisaClientImpl implements EVisaClient {
     }
 
     @Override
-    public void eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO eVisaObj) {
-        this.eVisaService.eVisaCustom(eVisaObj);
+    public String eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO eVisaObj) {
+        return this.eVisaService.eVisaCustom(eVisaObj);
     }
 
     @Override

+ 1 - 1
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/EVisaService.java

@@ -26,7 +26,7 @@ public interface EVisaService {
     /**
      * 电签(档案-批量自定义)
      */
-    void eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO eVisaObj);
+    String eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO eVisaObj);
 
     /**
      * 创建印模

+ 26 - 24
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVisaServiceImpl.java

@@ -241,7 +241,7 @@ public class EVisaServiceImpl implements EVisaService {
                 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);
                 System.out.println("合同-" + contractId + "--" + sqlinfo);
-                if(maps==null ||maps.isEmpty()){
+                if (maps == null || maps.isEmpty()) {
                     return finalPdfUrl;
                 }
                 //准备签章策略
@@ -436,17 +436,17 @@ public class EVisaServiceImpl implements EVisaService {
                     String sqlinfo = " SELECT a.id as keyWord,(SELECT acc_code from blade_user where id='" + task.getUserId() + "' and is_deleted=0  ) as sealId 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=" + contractId + " and user_id=" + task.getUserId() + " and c.is_deleted=0 )";
                     System.out.println("东方中讯-个人-user-id" + task.getUserId() + "--SQL=" + sqlinfo);
                     List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlinfo);
-                    if(maps != null && !maps.isEmpty()){
+                    if (maps != null && !maps.isEmpty()) {
                         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"));
+                        for (Map<String, Object> dataMap : maps) {
+                            HashMap<String, Object> daMa = new HashMap<>();
+                            daMa.put("keyWord", dataMap.get("keyWord"));
+                            daMa.put("sealId", dataMap.get("sealId"));
 
                             byte[] fileByte;
-                            if(fileUrl.indexOf("aliyuncs.com")>=0){
+                            if (fileUrl.indexOf("aliyuncs.com") >= 0) {
                                 fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(fileUrl));
-                            }else {
+                            } else {
                                 FileReader fileReader = new FileReader(fileUrl);
                                 fileByte = fileReader.readBytes();
                             }
@@ -454,23 +454,23 @@ public class EVisaServiceImpl implements EVisaService {
                             String originalFileB64 = Base64.toBase64String(fileByte);
                             daMa.put("fileB64", originalFileB64);
                             daMa.put("lastSignFlag", false);
-                            String reData =  signPdfByDFZX(daMa);
-                            if(reData.indexOf("success@")>=0){
+                            String reData = signPdfByDFZX(daMa);
+                            if (reData.indexOf("success@") >= 0) {
                                 fileUrl = reData.split("@@@@")[1];
                             }
                         }
-                        if(fileUrl.indexOf("aliyuncs.com")>=0){
+                        if (fileUrl.indexOf("aliyuncs.com") >= 0) {
                             return E_VISA_ERROR;
-                        }else{
-                            BladeFile bladeFile = this.newIOSSClient.uploadFile(fileUrl.substring(fileUrl.lastIndexOf("/")+1,fileUrl.length()),fileUrl);
+                        } else {
+                            BladeFile bladeFile = this.newIOSSClient.uploadFile(fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.length()), fileUrl);
                             if (bladeFile != null) {
-                                System.out.println("pdf上传="+bladeFile.getLink());
+                                System.out.println("pdf上传=" + bladeFile.getLink());
                                 return SUCCESS + "@@@@" + bladeFile.getLink();
                             } else {
                                 return E_VISA_ERROR;
                             }
                         }
-                    }else{
+                    } else {
                         RedisTemplate.delete("sign-" + task.getFormDataId());
                         return SUCCESS + "@@@@" + taskFile.getApprovalFileList().get(0).getFileUrl();
                     }
@@ -540,7 +540,7 @@ public class EVisaServiceImpl implements EVisaService {
      *
      * @param taskArchiveDTO
      */
-    public void eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO taskArchiveDTO) {
+    public String eVisaCustom(org.springblade.evisa.vo.TaskArchiveDTO taskArchiveDTO) {
         //type=1表示任务审批自定义签章,type=2表示认证电签签章(不涉及审批任务)
         if (taskArchiveDTO.getSealStrategy().size() > 0 && taskArchiveDTO.getType() == 1) {
             //获取档案任务
@@ -599,15 +599,18 @@ public class EVisaServiceImpl implements EVisaService {
                                     jdbcTemplate.execute("update u_archive_file set e_visa_file = '" + bladeFile.getLink() + "' where id = " + task.getFormDataId());
                                     String successMsg = SUCCESS + "@@@@" + bladeFile.getLink();
                                     logger.info(successMsg);
+                                    return successMsg;
                                 }
                             }
                         }
                     } catch (Exception e) {
                         logger.error(e.getMessage());
                         e.printStackTrace();
+                        return e.getMessage();
                     }
                 }
             }
+            return "";
         } else if (taskArchiveDTO.getSealStrategy().size() > 0 && taskArchiveDTO.getType() == 2) {
             //此时的taskArchiveDTO.taskId=档案数据业务id(档案认证不涉及审批流任务)
             //获取档案任务的文件信息(这里根据id再查询一次,入参的时候不想重新构造入参的dto了)
@@ -655,11 +658,6 @@ public class EVisaServiceImpl implements EVisaService {
                     //返回结果集
                     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);*/
-
                             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) {
@@ -667,15 +665,18 @@ public class EVisaServiceImpl implements EVisaService {
                                 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);
+                                return successMsg;
                             }
                         }
                     }
                 } catch (Exception e) {
                     logger.error(e.getMessage());
                     e.printStackTrace();
+                    return e.getMessage();
                 }
             }
         }
+        return "";
     }
 
   /*  public static void main(String[] args) throws Exception {
@@ -714,16 +715,17 @@ public class EVisaServiceImpl implements EVisaService {
             System.out.println(fileUrl);
         }
     }*/
+
     /**
      * 东方 中讯
      *
      * @throws Exception
      */
-    public static String signPdfByDFZX(HashMap<String, Object> request)  {
+    public static String signPdfByDFZX(HashMap<String, Object> request) {
         String url = "http://47.110.251.215:9125/FrontSysGs/SealServicezx/FileSignByKeyWord";
         String sysLocalFileUrl = FileUtils.getSysLocalFileUrl();
         String filecode = SnowFlakeUtil.getId() + "";
-        String dataFileUrl = sysLocalFileUrl+"/pdf/"+filecode+".pdf";
+        String dataFileUrl = sysLocalFileUrl + "/pdf/" + filecode + ".pdf";
         try {
             HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
             httpRequestFactory.setConnectionRequestTimeout(30000);
@@ -762,7 +764,7 @@ public class EVisaServiceImpl implements EVisaService {
             fout.close();
             return SUCCESS + "@@@@" + dataFileUrl;
         } catch (Exception e) {
-            return  ERROR + "@@@@异常出错";
+            return ERROR + "@@@@异常出错";
         }
     }