2 次代码提交 a33efa8614 ... b285926478

作者 SHA1 备注 提交日期
  zhangchenm b285926478 Merge remote-tracking branch 'origin/v1.1-dev' into v1.1-dev 1 周之前
  zhangchenm 092398e75f 企业静默签署implementation 1 周之前

+ 0 - 8
trade-client/src/test/java/com/trade/client/ContractServiceTests.java

@@ -20,7 +20,6 @@ import com.trade.service.contract.dto.ContractSignInput;
 import com.trade.service.contract.entity.ESignFlow;
 import com.trade.service.contract.queue.MessageSender;
 import com.trade.service.contract.service.ContractService;
-import com.trade.service.contract.service.ContractTemplateRepository;
 import com.trade.service.contract.service.ESignFlowService;
 
 @SpringBootTest
@@ -29,17 +28,10 @@ public class ContractServiceTests {
     @Resource
     ContractService contractService;
     @Resource
-    private ContractTemplateRepository contractTemplateRepository;
-    @Resource
     private MessageSender messageSender;
     @Resource
     private ESignFlowService esignFlowService;
 
-    @Test
-    public void contractMapTest() {
-        System.out.println(contractTemplateRepository.getContractTemplates().get("123"));
-    }
-
     @Test
     public void contractGenerateTest() {
         // 生成合同

+ 16 - 0
trade-service/src/main/java/com/trade/service/contract/config/ContractConfigProperties.java

@@ -3,11 +3,15 @@ package com.trade.service.contract.config;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 
+import java.util.Map;
+
 @Configuration
 @ConfigurationProperties(prefix = "contract.base")
 public class ContractConfigProperties {
 
     private String dir;
+    // key: idNo, value: eSignSealId  (important: 如需静默签署,请在此处配置)
+    private Map<String, String> eSignSealIdMap;
 
     public String getDir() {
         return dir;
@@ -16,4 +20,16 @@ public class ContractConfigProperties {
     public void setDir(String dir) {
         this.dir = dir;
     }
+
+    public Map<String, String> getESignSealIdMap() {
+        return eSignSealIdMap;
+    }
+
+    public void setESignSealIdMap(Map<String, String> eSignSealIdMap) {
+        this.eSignSealIdMap = eSignSealIdMap;
+    }
+
+    public String getESignSealIdByIdNo(String idNo) {
+        return eSignSealIdMap.get(idNo);
+    }
 }

+ 6 - 0
trade-service/src/main/java/com/trade/service/contract/dto/SignCallback2Biz.java

@@ -57,6 +57,12 @@ public class SignCallback2Biz {
         private Long fileId;
         private String fileType;
 
+        public SignedFile2Biz(Long signedFileId, Long rawFileId, String fileType){
+            this.rawFileId = rawFileId;
+            this.fileId = signedFileId;
+            this.fileType = fileType;
+        }
+
         public Long getRawFileId() {
             return rawFileId;
         }

+ 0 - 25
trade-service/src/main/java/com/trade/service/contract/service/ContractTemplateRepository.java

@@ -1,25 +0,0 @@
-package com.trade.service.contract.service;
-
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-import java.util.Map;
-
-@Component
-@ConfigurationProperties(prefix = "contract.template")
-public class ContractTemplateRepository {
-    private Map<String, String> contractTemplates;
-
-    public Map<String, String> getContractTemplates() {
-        return contractTemplates;
-    }
-
-    public void setContractTemplates(Map<String, String> contractTemplates) {
-        this.contractTemplates = contractTemplates;
-    }
-
-    public String getContractTemplateByCode(String code) {
-        return contractTemplates.get(code);
-    }
-}

+ 38 - 13
trade-service/src/main/java/com/trade/service/contract/service/impl/ESignContractServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import com.trade.service.contract.config.ContractConfigProperties;
 import com.trade.service.contract.util.esign.bizprocess.BizProcessorFactory;
 import com.trade.service.contract.util.esign.bizprocess.SignedBizProcessor;
 import org.jsoup.helper.StringUtil;
@@ -68,6 +69,8 @@ public class ESignContractServiceImpl implements SignPlatformService {
     @Resource
     @Lazy
     private BizProcessorFactory bizProcessorFactory;
+    @Resource
+    private ContractConfigProperties contractConfigProperties;
 
     @Override
     @Transactional
@@ -136,7 +139,11 @@ public class ESignContractServiceImpl implements SignPlatformService {
             params.put("status", 2);
             messageSender.sendSignNotice2BizSys(JSON.toJSONString(params));
         }
-        // todo 判断所有人签署完成,手动调用归档
+        // 判断所有人签署完成,手动调用归档
+        List<ESignFlowSigner> signerList = esignFlowSignerService.getListByFlowId(eSignFlow.getFlowId());
+        if (signerList.stream().allMatch(e -> e.getStatus() == 1)) {
+            ESignRequest.archivESignFlow(eSignFlow.getFlowId());
+        }
     }
 
     /**
@@ -152,10 +159,6 @@ public class ESignContractServiceImpl implements SignPlatformService {
         }
         // 签署完成
         if (ESignConstant.SIGN_FLOW_STATUS_FINISH == eSignCallback.getFlowStatus()) {
-            // 归档签署文件
-            /*
-             * if (!eSignFlow.getAutoArchive()) { ESignRequest.archivESignFlow(eSignFlow.getFlowId()); }
-             */
             // 下载签署完成后的文件
             downloadSignedFile(eSignFlow);
             // 更新签署流程状态
@@ -196,14 +199,9 @@ public class ESignContractServiceImpl implements SignPlatformService {
         ESignFlow eSignFlow = esignFlowService.getByFlowId(flowId);
         if (ContractConstant.CONTRACT_SIGN_STATUS_SIGNED.equals(eSignFlow.getStatus())) {
             List<ESignFile> eSignFileList = esignFileService.getByFlowId(flowId);
-            List<SignCallback2Biz.SignedFile2Biz> signedFile2BizList = new ArrayList<>();
-            for (ESignFile eSignFile : eSignFileList) {
-                SignCallback2Biz.SignedFile2Biz file2Biz = new SignCallback2Biz.SignedFile2Biz();
-                file2Biz.setFileId(eSignFile.getSignedFileId());
-                file2Biz.setRawFileId(eSignFile.getRawFileId());
-                file2Biz.setFileType(eSignFile.getFileType());
-                signedFile2BizList.add(file2Biz);
-            }
+            List<SignCallback2Biz.SignedFile2Biz> signedFile2BizList = eSignFileList.stream().map(
+                    e -> new SignCallback2Biz.SignedFile2Biz(e.getSignedFileId(), e.getRawFileId(), e.getFileType()))
+                    .collect(Collectors.toList());
             callback.setSignedFiles(signedFile2BizList);
         }
         callback.setSignStatus(eSignFlow.getStatus());
@@ -362,8 +360,13 @@ public class ESignContractServiceImpl implements SignPlatformService {
                 }
                 signField = new ESignDoc(eSignFileId, accountMap.get(signer.getSignerIdNo()), actorIdentityType,
                         accountMap.get(salInfo.getSealIdNo()), null, 1, posBean, null, null, null);
+                if (handleAutoSign(flowId, salInfo, signField))
+                    continue;
             } else if (ESignConstant.CRED_PSN_CH_IDCARD.equals(signer.getSignerIdType())
                     || ESignConstant.CRED_PSN_PASSPORT.equals(signer.getSignerIdType())) {
+                        if (Boolean.TRUE.equals(salInfo.getAutoSign())) {
+                            throw new ServiceException("签署任务-个人签章暂不支持自动签章", HttpStatus.BAD_REQUEST);
+                        }
                         signField = new ESignDoc(eSignFileId, accountMap.get(signer.getSignerIdNo()), null, null, null,
                                 1, posBean, "1", null, null);
                     }
@@ -379,6 +382,28 @@ public class ESignContractServiceImpl implements SignPlatformService {
         saveSignFlowSigner(flowId, accountMap);
     }
 
+    /**
+     * 处理自动签章
+     * 
+     * @param flowId 签署流程id
+     * @param sealInfo 签章信息
+     * @param signField e签宝签署任务对象
+     * @return 是否自动签章
+     */
+    private boolean handleAutoSign(String flowId, ContractSeal sealInfo, ESignDoc signField) {
+        if (Boolean.TRUE.equals(sealInfo.getAutoSign())) {
+            String sealId = contractConfigProperties.getESignSealIdByIdNo(sealInfo.getSealIdNo());
+            if (null == sealId) {
+                throw new ServiceException("签署任务-签章信息-企业签章-自动签章-未配置签章ID", HttpStatus.BAD_REQUEST);
+            }
+            signField.setSealId(sealId);
+            // 调用自动签署方法
+            ESignRequest.addPlatformAutoSignArea(flowId, Collections.singletonList(signField));
+            return true;
+        }
+        return false;
+    }
+
     private void saveSignFlowSigner(String flowId, Map<String, String> accountMap) {
         for (String eAccountId : accountMap.values()) {
             ESignFlowSigner flowSigner = ESignFlowSigner.builder().flowId(flowId).eAccountId(eAccountId).build();

+ 3 - 3
trade-service/src/main/java/com/trade/service/contract/util/SignPubUtil.java

@@ -37,13 +37,13 @@ public class SignPubUtil {
                     }
                     sealInfo.setSigner(signer);
                 } else {
-                    resultMap.getOrDefault(sealInfo.getSigner().getSignerIdNo(),
-                            accountCreator.creatPersonalAccount(sealInfo.getSigner()));
+                    resultMap.computeIfAbsent(sealInfo.getSigner().getSignerIdNo(),
+                            v -> accountCreator.creatPersonalAccount(sealInfo.getSigner()));
                 }
                 // 若存在企业签章,则需创建企业账号
                 if (ESignConstant.CRED_ORG_USCC.equals(sealInfo.getSealIdType())
                         || ESignConstant.CRED_ORG_UNKNOWN.equals(sealInfo.getSealIdType())) {
-                    resultMap.getOrDefault(sealInfo.getSealIdNo(), accountCreator.createOrgAccount(sealInfo));
+                    resultMap.computeIfAbsent(sealInfo.getSealIdNo(), v -> accountCreator.createOrgAccount(sealInfo));
                 }
             });
         });