|
@@ -32,11 +32,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
|
import static org.jeecg.modules.app.esign.auth.ESignAuth.*;
|
|
|
-import static org.jeecg.modules.app.esign.fileAndTemplate.TemplateDemo.getTemplateCreateUrl;
|
|
|
-import static org.jeecg.modules.app.esign.fileAndTemplate.TemplateDemo.getTemplateEditUrl;
|
|
|
+import static org.jeecg.modules.app.esign.fileAndTemplate.TemplateDemo.*;
|
|
|
import static org.jeecg.modules.app.esign.members.MembersDemo.administrators;
|
|
|
-import static org.jeecg.modules.app.esign.seal.SealDemo.orgOwnSealList;
|
|
|
-import static org.jeecg.modules.app.esign.seal.SealDemo.orgSealsExternalAuth;
|
|
|
+import static org.jeecg.modules.app.esign.seal.SealDemo.*;
|
|
|
import static org.jeecg.modules.app.esign.sign.SignDemo.createByFile;
|
|
|
|
|
|
@Service
|
|
@@ -56,8 +54,8 @@ public class ESignServiceImpl implements IESignService {
|
|
|
private FamilyMembersMapper familyMembersMapper;
|
|
|
@Resource
|
|
|
private AppSiteMapper appSiteMapper;
|
|
|
- private static final String NOTIFY_URL = "http://xx.xx.86.172:8081/asyn/notify";
|
|
|
- private static final String REDIRECT_URL = "http://www.xx.cn/";
|
|
|
+ private static final String NOTIFY_URL = "";
|
|
|
+ private static final String REDIRECT_URL = "";
|
|
|
private static final String[] PERSON_AUTH_MODES = {"PSN_MOBILE3"};
|
|
|
private static final String[] WILLINGNESS_MODES = {"CODE_SMS"};
|
|
|
private static final String[] ORG_AUTH_MODES = {"ORG_ALIPAY_CREDIT", "ORG_LEGALREP"};
|
|
@@ -119,8 +117,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
@Override
|
|
|
public boolean uploadContractTemplate(AppContractInfoDTO appContractInfoDTO) throws EsignDemoException {
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-// String remoteUrl = "http://127.0.0.1:8080/jeecg-boot/sys/common/static/" + appContractInfoDTO.getFilePath();
|
|
|
- String remoteUrl = "E:/合同模板/test-template1.pdf";
|
|
|
+ String remoteUrl = "http://127.0.0.1:8080/jeecg-boot/sys/common/static/" + appContractInfoDTO.getFilePath();
|
|
|
String fileType = getFileExtension(appContractInfoDTO.getFilePath());
|
|
|
if (fileType.isEmpty()) {
|
|
|
throw new JeecgBootException("未指定文件类型");
|
|
@@ -140,6 +137,11 @@ public class ESignServiceImpl implements IESignService {
|
|
|
if (errCode == 0) {
|
|
|
appAccountMapper.delete(Wrappers.<AppContractInfo>lambdaQuery()
|
|
|
.eq(AppContractInfo::getOrgCode, user.getOrgCode()));
|
|
|
+ AppContractInfo appContractInfo = appAccountMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery()
|
|
|
+ .eq(AppContractInfo::getFileId, fileId));
|
|
|
+ if(null != appContractInfo){
|
|
|
+ appAccountMapper.deleteById(appContractInfo);
|
|
|
+ }
|
|
|
appAccountMapper.insert(new AppContractInfo()
|
|
|
.setOrgCode(user.getOrgCode())
|
|
|
.setFileId(fileId)
|
|
@@ -197,7 +199,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
*/
|
|
|
private JsonObject buildSignFlowDto(AppContractInfo contractInfo,
|
|
|
SysDepart sysDepart,
|
|
|
- FamilyMembers familyMembers) {
|
|
|
+ FamilyMembers familyMembers) throws EsignDemoException {
|
|
|
JsonObject dto = new JsonObject();
|
|
|
AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getOrgCode, sysDepart.getOrgCode()));
|
|
|
// 构建文档信息
|
|
@@ -255,7 +257,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
dto.add("signFlowInitiator", signFlowInitiator);
|
|
|
|
|
|
// 签署人信息
|
|
|
- dto.add("signers", buildSigners(contractInfo, familyMembers));
|
|
|
+ dto.add("signers", buildSigners(contractInfo, familyMembers,appSite.getEsignOrgId()));
|
|
|
|
|
|
return dto;
|
|
|
}
|
|
@@ -263,9 +265,11 @@ public class ESignServiceImpl implements IESignService {
|
|
|
/**
|
|
|
* 构建签署人信息
|
|
|
*/
|
|
|
- private JsonArray buildSigners(AppContractInfo contractInfo, FamilyMembers familyMembers) {
|
|
|
+ private JsonArray buildSigners(AppContractInfo contractInfo, FamilyMembers familyMembers,String orgId) throws EsignDemoException {
|
|
|
JsonArray signers = new JsonArray();
|
|
|
-
|
|
|
+ EsignHttpResponse getComponentsInfo = getComponentsInfo("12f41e8f364946369b8d93bd8710df67");
|
|
|
+ JsonObject getComponentsInfoObject = gson.fromJson(getComponentsInfo.getBody(), JsonObject.class);
|
|
|
+ System.err.println("查询模板详情返回:"+getComponentsInfoObject);
|
|
|
// 个人签署人
|
|
|
JsonObject signer1 = new JsonObject();
|
|
|
signer1.add("signConfig", buildSignConfig(1, 10));
|
|
@@ -283,42 +287,16 @@ public class ESignServiceImpl implements IESignService {
|
|
|
psnSignerInfo.add("psnInfo", psnInfo);
|
|
|
|
|
|
signer1.add("psnSignerInfo", psnSignerInfo);
|
|
|
- signer1.add("signFields", buildSignFields(contractInfo.getFileId(), 100, 200, 96, 100, 100,false));
|
|
|
-// "orgSignerInfo": {
|
|
|
-// "orgName": "XXXX企业名字",
|
|
|
-// "orgInfo": {
|
|
|
-// "orgIDCardNum": "911*******3",
|
|
|
-// "orgIDCardType": "CRED_ORG_USCC"
|
|
|
-// },
|
|
|
-// "transactorInfo": {
|
|
|
-// "psnAccount": "139****10",
|
|
|
-// "psnInfo": {
|
|
|
-// "psnName": "李四",
|
|
|
-// "psnIDCardNum": "3311********9",
|
|
|
-// "psnIDCardType": "CRED_PSN_CH_IDCARD"
|
|
|
-// }
|
|
|
-// }
|
|
|
-// },
|
|
|
-
|
|
|
+ signer1.add("signFields", buildSignFields(contractInfo.getFileId(), 100, 200, 96, 100, 100,false,""));
|
|
|
// 企业签署人
|
|
|
-// JsonObject signer2 = new JsonObject();
|
|
|
-//
|
|
|
-// JsonObject corporate = new JsonObject();
|
|
|
-// // 签署人信息
|
|
|
-// psnSignerInfo.addProperty("psnAccount", familyMembers.getPhone());
|
|
|
-//
|
|
|
-// corporate.addProperty("psnName", familyMembers.getFullName());
|
|
|
-// corporate.addProperty("psnIDCardNum", familyMembers.getIdentityCard());
|
|
|
-// corporate.addProperty("psnIDCardType", "CRED_PSN_CH_IDCARD");
|
|
|
-// psnSignerInfo.add("psnInfo", psnInfo);
|
|
|
-//
|
|
|
-// signer1.add("orgSignerInfo", psnSignerInfo);
|
|
|
-// signer2.add("signConfig", buildSignConfig(2, 10));
|
|
|
-// signer2.add("noticeConfig", buildNoticeConfig(""));
|
|
|
-// signer2.addProperty("signerType", 1);
|
|
|
-// signer2.add("signFields", buildSignFields(contractInfo.getFileId(), 300, 200, 159, 300, 100,true));
|
|
|
+ JsonObject signer2 = new JsonObject();
|
|
|
+ signer2.addProperty("signerType", 1);
|
|
|
+ JsonObject orgSignerInfo = new JsonObject();
|
|
|
+ orgSignerInfo.addProperty("orgId", orgId);
|
|
|
+ signer2.add("signFields", buildSignFields(contractInfo.getFileId(), 300, 200, 159, 300, 100,true,orgAuthorizedSeal(orgId)));
|
|
|
|
|
|
signers.add(signer1);
|
|
|
+ signers.add(signer2);
|
|
|
return signers;
|
|
|
}
|
|
|
|
|
@@ -347,7 +325,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
private JsonArray buildSignFields(String fileId,
|
|
|
int x, int y,
|
|
|
int size,
|
|
|
- int dateX, int dateY,boolean autoSign) {
|
|
|
+ int dateX, int dateY,boolean autoSign,String signature) {
|
|
|
JsonArray signFields = new JsonArray();
|
|
|
JsonObject field = new JsonObject();
|
|
|
|
|
@@ -363,6 +341,7 @@ public class ESignServiceImpl implements IESignService {
|
|
|
normalConfig.addProperty("psnSealStyles", "0,1");
|
|
|
normalConfig.addProperty("signFieldSize", String.valueOf(size));
|
|
|
normalConfig.addProperty("signFieldStyle", 1);
|
|
|
+ normalConfig.addProperty("assignedSealId", signature);
|
|
|
|
|
|
// 位置配置
|
|
|
JsonObject position = new JsonObject();
|
|
@@ -432,11 +411,15 @@ public class ESignServiceImpl implements IESignService {
|
|
|
@Override
|
|
|
public String createTemplate(String fileId) throws EsignDemoException {
|
|
|
AppContractInfo appContractInfo = appAccountMapper.selectOne(Wrappers.<AppContractInfo>lambdaQuery().eq(AppContractInfo::getFileId, fileId));
|
|
|
+ List<String> signerRoles = new ArrayList<>();
|
|
|
+ signerRoles.add("商户");
|
|
|
+ signerRoles.add("用户");
|
|
|
DocTemplateDTO docTemplateDTO = new DocTemplateDTO()
|
|
|
.setDocTemplateName(appContractInfo.getContractName())
|
|
|
.setDocTemplateType(0)
|
|
|
.setFileId(fileId)
|
|
|
- .setRedirectUrl(appContractInfo.getRedirectUrl());
|
|
|
+ .setRedirectUrl(appContractInfo.getRedirectUrl())
|
|
|
+ .setSignerRoles(signerRoles);
|
|
|
/* 获取制作合同模板页面*/
|
|
|
EsignHttpResponse getTemplateCreateUrl = getTemplateCreateUrl(docTemplateDTO);
|
|
|
Gson gson = new Gson();
|
|
@@ -554,6 +537,53 @@ public class ESignServiceImpl implements IESignService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String templatePreviewUrl(String docTemplateId) throws EsignDemoException {
|
|
|
+ EsignHttpResponse getTemplatePreview = getTemplatePreviewUrl(docTemplateId);
|
|
|
+ JsonObject getTemplatePreview1 = gson.fromJson(getTemplatePreview.getBody(), JsonObject.class);
|
|
|
+
|
|
|
+ // 检查 data 对象是否存在
|
|
|
+ if (!getTemplatePreview1.has("data") || !getTemplatePreview1.get("data").isJsonObject()) {
|
|
|
+ throw new EsignDemoException("响应中缺少 data 字段");
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonObject data = getTemplatePreview1.getAsJsonObject("data");
|
|
|
+
|
|
|
+ // 提取 docTemplatePreviewUrl
|
|
|
+ if (!data.has("docTemplatePreviewUrl") || !data.get("docTemplatePreviewUrl").isJsonPrimitive()) {
|
|
|
+ throw new EsignDemoException("缺少 docTemplatePreviewUrl 字段");
|
|
|
+ }
|
|
|
+
|
|
|
+ String previewUrl = data.get("docTemplatePreviewUrl").getAsString();
|
|
|
+ System.err.println("查询模板详情返回:" + previewUrl);
|
|
|
+ return previewUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String orgAuthorizedSeal(String orgId) throws EsignDemoException {
|
|
|
+ // 使用传入的 orgId
|
|
|
+ EsignHttpResponse orgAuthorizedSealList = orgAuthorizedSealList("585f3eabc65b42b1ad5ae56f4e2bdde6");
|
|
|
+ JsonObject orgAuthorizedSealListObject = gson.fromJson(orgAuthorizedSealList.getBody(), JsonObject.class);
|
|
|
+
|
|
|
+ // 检查 data.seals 是否存在
|
|
|
+ if (orgAuthorizedSealListObject.has("data") &&
|
|
|
+ orgAuthorizedSealListObject.getAsJsonObject("data").has("seals")) {
|
|
|
+
|
|
|
+ JsonArray seals = orgAuthorizedSealListObject.getAsJsonObject("data").getAsJsonArray("seals");
|
|
|
+
|
|
|
+ for (JsonElement sealElement : seals) {
|
|
|
+ JsonObject seal = sealElement.getAsJsonObject();
|
|
|
+ // 条件判断
|
|
|
+ if (orgId.equals(seal.get("authorizerOrgId").getAsString()) &&
|
|
|
+ "PUBLIC".equals(seal.get("sealBizType").getAsString())) {
|
|
|
+
|
|
|
+ return seal.get("sealId").getAsString(); // 返回匹配的 sealAuthBizId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null; // 无匹配项返回 null
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取文件扩展名
|
|
|
*/
|