diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp index bcb296cae..db03bcb10 100644 --- a/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp @@ -14,6 +14,7 @@ String flowunid = CurPage.getParameter("FlowUnid"); String action = CurPage.getParameter("action"); String SubjectId=CurPage.getParameter("SubjectId");//获取主体ID + String operationType = CurPage.getParameter("operationType"); ASObjectModel doTemp = new ASObjectModel("LBContractPrintList"); ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); @@ -123,7 +124,13 @@ } //自然人电子签约 - var sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","signIng","ProjectId=<%=projectId%>,CurUserID=<%=CurUser.getUserID()%>,FlowUnid=<%=flowunid%>,,SubjectId=<%=SubjectId%>"); + var operationType = "<%=operationType%>"; + var sReturn = ""; + if("LHZL"==operationType){ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwo","signIng","ProjectId=<%=projectId%>,CurUserID=<%=CurUser.getUserID()%>,FlowUnid=<%=flowunid%>,,SubjectId=<%=SubjectId%>"); + }else{ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","signIng","ProjectId=<%=projectId%>,CurUserID=<%=CurUser.getUserID()%>,FlowUnid=<%=flowunid%>,,SubjectId=<%=SubjectId%>"); + } var sReturns = sReturn.split("@"); if("success"==sReturns[0]){ AsDebug.showMessage("提示","电子签约发起成功!","","",true,"","","",function(){ @@ -168,7 +175,13 @@ return; } var sParams="ProjectId=<%=projectId%>,customerType=<%=custtype%>,FlowUnid=<%=flowunid%>,CurUserID=<%=CurUser.getUserID()%>,SubjectId=<%=SubjectId%>"; - var sReturn=RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","contractSignStatus",sParams); + var operationType = "<%=operationType%>"; + var sReturn = ""; + if("LHZL"==operationType){ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwo","contractSignStatus",sParams); + }else{ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","contractSignStatus",sParams); + } AsDebug.showMessage("提示",sReturn,"","",true,'','','',function(){ <%-- var sReturns = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","downloadDoc","ProjectId=<%=projectId%>,CurUserID=<%=CurUser.getUserID()%>"); --%> window.location.reload(); @@ -315,7 +328,13 @@ AsDebug.showMessage("提示","没有发起电子签约,无法发送短信!","","",true); return; } - var sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","sendMessageAgain","ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + var operationType = "<%=operationType%>"; + var sReturn = ""; + if("LHZL"==operationType){ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwo","sendMessageAgain","ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + }else{ + sReturn = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","sendMessageAgain","ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + } if("success"==sReturn){ AsDebug.showMessage("提示","短信发送成功!","","",true); }else{ diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp index 8acd56f89..3e694bc9f 100644 --- a/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp @@ -353,7 +353,13 @@ return; } if(("01"=="<%=customertype%>"&&"Auto" == "<%=sealType%>" )||("Auto" == "<%=sealType%>" && "Hand" == "<%=signType%>" )){ - var falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + var falg = ""; + var operationType = "<%=CurPage.getParameter("operationType")%>"; + if("LHZL"==operationType){ + falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwo","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + }else{ + falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>"); + } if("success"!= falg ){ RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","companyUpdateDocContractStatus","FlowUnid=<%=flowunid%>"+",ProjectId=<%=projectId%>"); alert("生成失败!!!"); diff --git a/WebContent/WEB-INF/lib/sdk-java-3.1.8.jar b/WebContent/WEB-INF/lib/sdk-java-3.1.8.jar new file mode 100644 index 000000000..d42bc03b4 Binary files /dev/null and b/WebContent/WEB-INF/lib/sdk-java-3.1.8.jar differ diff --git a/WebContent/fileTemplate/鑱斿悎绉熻祦鈥斺旇瀺璧勭璧佸悎鍚-淇鐗-20200806.docx b/WebContent/fileTemplate/鑱斿悎绉熻祦鈥斺旇瀺璧勭璧佸悎鍚-淇鐗-20200806.docx new file mode 100644 index 000000000..9df297452 Binary files /dev/null and b/WebContent/fileTemplate/鑱斿悎绉熻祦鈥斺旇瀺璧勭璧佸悎鍚-淇鐗-20200806.docx differ diff --git a/config/qiyuesuo.properties b/config/qiyuesuo.properties new file mode 100644 index 000000000..41246ddf6 --- /dev/null +++ b/config/qiyuesuo.properties @@ -0,0 +1,37 @@ +#-----深圳参数-------- +#契约锁正式环境:https://openapi.qiyuesuo.com ,测试环境:https://openapi.qiyuesuo.me +SZ_Url=https://openapi.qiyuesuo.cn +#third.interface.contractserverUrl=www.qiyuesuo.me +#契约锁 接入令牌 +SZ_Key=fjHd9oRRkQ +#契约锁接入密钥 +SZ_Secret=PZXX3xiQbjRfzPqGlXv8BwRbo9FVnl +#合同专用章 +SZ_OfficialSealId=2448774302840676963 +#公司名称(安鹏国际融资租赁(测试)有限公司) +SZ_CompanyName=\u5b89\u9e4f\u56fd\u9645\u878d\u8d44\u79df\u8d41\uff08\u6d4b\u8bd5\uff09\u6709\u9650\u516c\u53f8 + +#-----天津参数-------- +#契约锁正式环境:https://openapi.qiyuesuo.com ,测试环境:https://openapi.qiyuesuo.me +TJ_Url=https://openapi.qiyuesuo.cn +#third.interface.contractserverUrl=www.qiyuesuo.me +#契约锁 接入令牌 +TJ_Key=jx2QW1PHOW +#契约锁接入密钥 +TJ_Secret=AcpV0fxN8fKwDU9UwKHNvcs8K2g9rK +#合同专用章 +TJ_OfficialSealId=2627811629303075416 +#公司名称 +#TJ_CompanyName=安鹏租赁测试子公司 +TJ_CompanyName=\u5b89\u9e4f\u5929\u6d25\u6709\u9650\u516c\u53f8 + + +#-----子公司参数(辉煌)-------- +#公司名称 +#HH_CompanyName=安鹏租赁测试子公司 +HH_CompanyName=\u5b89\u9e4f\u79df\u8d41\u6d4b\u8bd5\u5b50\u516c\u53f8 +#合同专用章 +HH_OfficialSealId=2730629214314173089 + + + diff --git a/src/com/tenwa/app/baseFileTemplate/handle/FileTemplateUtil.java b/src/com/tenwa/app/baseFileTemplate/handle/FileTemplateUtil.java index 9321f6adb..35eb37322 100644 --- a/src/com/tenwa/app/baseFileTemplate/handle/FileTemplateUtil.java +++ b/src/com/tenwa/app/baseFileTemplate/handle/FileTemplateUtil.java @@ -169,6 +169,8 @@ public class FileTemplateUtil { return "[{'fileTemplate':\""+"[{'text':'C端直租','value':'59f109e144c347d1b0d61da63a4fe822'}]"+"\"}]"; }else if ("SYCSHHZ".equals(operationType)){ return "[{'fileTemplate':\""+"[{'text':'合同(融资租赁商用车)','value':'7acb675c671b4f92ab8b45d26e477055'}]"+"\"}]"; + }else if("LHZL".equals(operationType)){ + return "[{'fileTemplate':\""+"[{'text':'联合租赁','value':'7ae245ef8b644b62a4658069adab6c32'}]"+"\"}]"; }else{ if("01".equals(leasform)){ return "[{'fileTemplate':\""+"[{'text':'合同(直租)','value':'333cd5b36cd846938e618516ba9c8cbb'}]"+"\"}]"; diff --git a/src/com/tenwa/app/manage/util/ContractSignActionTwoUtil.java b/src/com/tenwa/app/manage/util/ContractSignActionTwoUtil.java new file mode 100644 index 000000000..ac8c27da2 --- /dev/null +++ b/src/com/tenwa/app/manage/util/ContractSignActionTwoUtil.java @@ -0,0 +1,404 @@ +package com.tenwa.app.manage.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import com.qiyuesuo.sdk.v2.SdkClient; +import com.qiyuesuo.sdk.v2.bean.Action; +import com.qiyuesuo.sdk.v2.bean.Contract; +import com.qiyuesuo.sdk.v2.bean.Signatory; +import com.qiyuesuo.sdk.v2.bean.Stamper; +import com.qiyuesuo.sdk.v2.bean.User; +import com.qiyuesuo.sdk.v2.http.StreamFile; +import com.qiyuesuo.sdk.v2.json.JSONUtils; +import com.qiyuesuo.sdk.v2.param.SignParam; +import com.qiyuesuo.sdk.v2.request.ContractDetailRequest; +import com.qiyuesuo.sdk.v2.request.ContractDraftRequest; +import com.qiyuesuo.sdk.v2.request.ContractNoticeRequest; +import com.qiyuesuo.sdk.v2.request.ContractSendRequest; +import com.qiyuesuo.sdk.v2.request.ContractSignCompanyRequest; +import com.qiyuesuo.sdk.v2.request.DocumentAddByFileRequest; +import com.qiyuesuo.sdk.v2.request.DocumentDownloadRequest; +import com.qiyuesuo.sdk.v2.response.DocumentAddResult; +import com.qiyuesuo.sdk.v2.response.SdkResponse; +import com.qiyuesuo.sdk.v2.utils.IOUtils; +import com.tenwa.util.MultiSubjectUtil; + +public class ContractSignActionTwoUtil { + + private static final ResourceBundle resourceBunlde = ResourceBundle.getBundle("qiyuesuo"); + + + //深圳公司参数 + private static final String sZ_Url = resourceBunlde.getString("SZ_Url"); + private static final String sZ_Key = resourceBunlde.getString("SZ_Key"); + private static final String sZ_Secret = resourceBunlde.getString("SZ_Secret"); + private static final String sZ_OfficialSealId = resourceBunlde.getString("SZ_OfficialSealId"); + private static final String sZ_CompanyName = resourceBunlde.getString("SZ_CompanyName"); + + //天津公司参数 + private static final String tJ_Url = resourceBunlde.getString("TJ_Url"); + private static final String tJ_Key = resourceBunlde.getString("TJ_Key"); + private static final String tJ_Secret = resourceBunlde.getString("TJ_Secret"); + private static final String tJ_OfficialSealId = resourceBunlde.getString("TJ_OfficialSealId"); + private static final String tJ_CompanyName = resourceBunlde.getString("TJ_CompanyName"); + + //子公司参数(辉煌) + private static final String hH_CompanyName = resourceBunlde.getString("HH_CompanyName"); + private static final String hH_OfficialSealId = resourceBunlde.getString("HH_OfficialSealId"); + + + public static void main(String[] args) { + System.out.println(sZ_Url); + System.out.println(sZ_CompanyName); + + } + + private SdkClient getSdkClient(String subjectId){ + if(MultiSubjectUtil.SZSUBJECTID.equals(subjectId)){ + return new SdkClient(sZ_Url, sZ_Key, sZ_Secret); + }else if (MultiSubjectUtil.TJSUBJECTID.equals(subjectId)){ + return new SdkClient(sZ_Url, sZ_Key, sZ_Secret);//应客户要求,现在都是以深圳主体发起 + //return new SdkClient(tJ_Url, tJ_Key, tJ_Secret); + } + return null; + } + + private String getComPanyName(String subjectId){ + if(MultiSubjectUtil.SZSUBJECTID.equals(subjectId)){ + return sZ_CompanyName; + }else if (MultiSubjectUtil.TJSUBJECTID.equals(subjectId)){ + return tJ_CompanyName; + } + return null; + } + //创建合同 + public SdkResponse createContract(Map>> parameter,String subjectId,String fileNme) throws Exception { + SdkClient client = this.getSdkClient(subjectId); + Contract draftContract = new Contract(); + draftContract.setSubject(fileNme); + draftContract.setOrdinal(false); + List> list = parameter.get("PERSONAL"); + if(list!=null && list.size()>0){ + for (Map map : list) { + Signatory persoanlSignatory = new Signatory(); + persoanlSignatory.setTenantType("PERSONAL"); + persoanlSignatory.setTenantName(map.get("name")); + persoanlSignatory.setReceiver(new User(map.get("type"), map.get("mobile"), "MOBILE")); + draftContract.addSignatory(persoanlSignatory); + } + } + list = parameter.get("COMPANY"); + if(list!=null && list.size()>0){ + for (Map map : list) { + Signatory platformSignatory = new Signatory(); + platformSignatory.setTenantType("COMPANY"); + Action sealAction = new Action(); + sealAction.setType("COMPANY"); + if ("1".equals(map.get("type"))) { + if(MultiSubjectUtil.SZSUBJECTID.equals(subjectId)){ + platformSignatory.setTenantName(sZ_CompanyName); + sealAction.setName(sZ_CompanyName); + sealAction.setSealId(new Long(sZ_OfficialSealId)); + }else if (MultiSubjectUtil.TJSUBJECTID.equals(subjectId)){ + platformSignatory.setTenantName(tJ_CompanyName); + sealAction.setName(tJ_CompanyName); + sealAction.setSealId(new Long(tJ_OfficialSealId)); + } + } else { + platformSignatory.setTenantName(hH_CompanyName); + sealAction.setName(hH_CompanyName); + sealAction.setSealId(new Long(hH_OfficialSealId) ); + } + platformSignatory.setReceiver(new User(map.get("mobile"), "MOBILE"));//子公司必须设置接收方,不管是否是子公司,都设置了一个 + platformSignatory.addAction(sealAction); + draftContract.addSignatory(platformSignatory); + } + } + draftContract.setSend(false); + String response = null; + try { + response = client.service(new ContractDraftRequest(draftContract)); + } catch (Exception e) { + throw new Exception("创建合同草稿请求服务/器失败,失败原因:" + e.getMessage()); + } + SdkResponse sdkResponse = JSONUtils.toQysResponse(response, + Contract.class); + if (!sdkResponse.getCode().equals(0)) { + throw new Exception("创建合同草稿失败,失败原因:" + sdkResponse.getMessage()); + } + return sdkResponse; + } + + //添加本地文件 + public SdkResponse addDocumentByFile(String filePath,String subjectId,Long contractId)throws Exception { + SdkClient client = this.getSdkClient(subjectId); + // 进入本地文件 + StreamFile file = new StreamFile(new FileInputStream(new File(filePath))); + String response = null; + try { + // PDF为本地文件的类型,请修改为对应的本地文件类型 + response = client.service(new DocumentAddByFileRequest(contractId,file, "pdf", "由文件创建文档")); + } catch (Exception e) { + throw new Exception("根据文件添加文档请求服务器失败,失败原因:" + e.getMessage()); + } + SdkResponse sdkResponse = JSONUtils.toQysResponse( + response, DocumentAddResult.class); + if (!sdkResponse.getCode().equals(0)) { + throw new Exception("根据文件添加文档失败,失败原因:" + sdkResponse.getMessage()); + } + return sdkResponse; + } + + //发起合同 + public SdkResponse send(List> personList,String subjectId, Long contractId,Long documentId) throws Exception { + SdkClient client = this.getSdkClient(subjectId); + Contract draft = getContract(subjectId, contractId).getResult(); + + List stampers = new LinkedList(); + // 获取SignatoryId与ActionId,用于指定签署位置,公司签署位置需要指定ActionId,个人签署位置需要指定SignatoryId + Long platformSignatoryId = null; + Long personalSignatoryId = null; + Long companySealActionId = null; + int dbcont = 0; + for (Signatory signatory : draft.getSignatories()) { + // 获取个人签署方 + if (signatory.getTenantType().equals("PERSONAL")) { + personalSignatoryId = signatory.getId(); + String typeName = signatory.getTenantName(); + //User user = signatory.getReceiver(); + String type = ""; + if(personList != null && personList.size()>0){ + for (Map person : personList) { + if(person.get("name").equals(typeName)){ + type = person.get("type"); + break; + } + } + } + Stamper personalStamper = new Stamper(); + personalStamper.setType("PERSONAL"); + personalStamper.setSignatoryId(personalSignatoryId); + personalStamper.setDocumentId(documentId); + if("sq".equals(type)){ + personalStamper.setKeyword("承租人(签字/盖章):"); + //personalStamper.setOffsetX(0.6); + personalStamper.setOffsetY(-0.02); + }else if("gt".equals(type)){ + personalStamper.setKeyword("共同申请人/法定代表人/委托代理人:"); + personalStamper.setOffsetX(-0.15); + personalStamper.setOffsetY(-0.05); + }else if("db".equals(type)){ + if(dbcont==0){ + personalStamper.setKeyword("出租人1(盖章):"); + personalStamper.setOffsetX(0.01); + personalStamper.setOffsetY(-0.12); + }else if(dbcont==1){ + personalStamper.setKeyword("出租人2(盖章)"); + personalStamper.setOffsetX(0.01); + personalStamper.setOffsetY(-0.12); + }else if(dbcont==2){ + personalStamper.setKeyword("承租人(签字/盖章):"); + personalStamper.setOffsetX(-0.01); + personalStamper.setOffsetY(-0.12); + } + dbcont++; + } + stampers.add(personalStamper); + } + // 获取平台方SignatoryId,以及对应的公章签署ActionId和法人章签署ActionId + if (signatory.getTenantType().equals("COMPANY")) { + platformSignatoryId = signatory.getId(); + for (Action action : signatory.getActions()) { + if (action.getName().equals(sZ_CompanyName)||action.getName().equals(tJ_CompanyName)) { + companySealActionId = action.getId(); + Stamper sealStamper = new Stamper(); + sealStamper.setType("COMPANY"); + sealStamper.setActionId(companySealActionId); + sealStamper.setSignatoryId(platformSignatoryId); + sealStamper.setDocumentId(documentId); + sealStamper.setKeyword("出租人2(盖章)"); + sealStamper.setOffsetX(-0.08); + sealStamper.setOffsetY(-0.06); + stampers.add(sealStamper); + } else { + companySealActionId = action.getId(); + Stamper sealStamper = new Stamper(); + sealStamper.setType("COMPANY"); + sealStamper.setActionId(companySealActionId); + sealStamper.setSignatoryId(platformSignatoryId); + sealStamper.setDocumentId(documentId); + sealStamper.setKeyword("出租人1(盖章)"); + sealStamper.setOffsetX(-0.08); + sealStamper.setOffsetY(-0.06); + stampers.add(sealStamper); + } + } + } + } + String response = null; + try { + response = client.service(new ContractSendRequest(draft.getId(),stampers)); + } catch (Exception e) { + throw new Exception("发起合同请求服务器失败,失败原因:" + e.getMessage()); + } + SdkResponse sdkResponse = JSONUtils.toQysResponse(response); + if (!sdkResponse.getCode().equals(0)) { + throw new Exception("发起合同失败,失败原因:" + sdkResponse.getMessage()); + } + return sdkResponse; + } + + //公司盖章 + public SdkResponse companySealSign(String subjectId,Long contractId) throws Exception { + String response = null; + try { + SdkClient client = this.getSdkClient(subjectId); + Contract contract = this.getContract(subjectId,contractId).getResult(); + List signatories = contract.getSignatories(); + if(signatories!=null && signatories.size()>0){ + for (Signatory signatory : signatories) { + String tenantType = signatory.getTenantType(); + String status = signatory.getStatus(); + if(tenantType!=null && "COMPANY".equals(tenantType) && status!=null && "SIGNING".equals(status)){ + SignParam param = new SignParam(); + param.setContractId(contractId); + String company = signatory.getTenantName(); + System.out.println("盖章公司名称:"+company); + param.setTenantName(company); + + if(sZ_CompanyName.equals(company)){ + param.setSealId(new Long(sZ_OfficialSealId)); + }else if(tJ_CompanyName.equals(company)){ + param.setSealId(new Long(tJ_OfficialSealId)); + }else if(hH_CompanyName.equals(company)){ + param.setSealId(new Long(hH_OfficialSealId)); + } + response = client.service(new ContractSignCompanyRequest(param)); + } + } + } + } catch (Exception e) { + throw new Exception("公章签署请求服务器失败,失败原因:" + e.getMessage()); + } + SdkResponse sdkResponse = JSONUtils.toQysResponse(response); + if (!sdkResponse.getCode().equals(0)) { + throw new Exception("公章签署失败,失败原因:" + sdkResponse.getMessage()); + } + return sdkResponse; + } + + public String getContractStatus(String subjectId, Long contractId) throws Exception{ + Contract contract = this.getContract(subjectId,contractId).getResult(); + boolean stu = true; + StringBuffer sb = new StringBuffer(); + List signatories = contract.getSignatories(); + if(signatories!=null && signatories.size()>0){ + for (Signatory signatory : signatories) { + String tenantType = signatory.getTenantType(); + String status = signatory.getStatus(); + if(tenantType!=null && "PERSONAL".equals(tenantType)){ + if(stu && status != null && (!status.equals("SIGNED")) ){ + stu = false ; + } + String statusName = ""; + switch (status) { + case "DRAFT": + statusName="草稿"; + break; + case "RECALLED": + statusName="已撤回"; + break; + case "SIGNING": + statusName="签署中"; + break; + case "REJECTED": + statusName="已退回"; + break; + case "SIGNED": + statusName="已完成"; + break; + case "EXPIRED": + statusName="已过期"; + break; + case "FILLING": + statusName="拟定中"; + break; + case "WAITING": + statusName="待签署"; + break; + case "INVALIDING": + statusName="作废中"; + break; + case "INVALIDED": + statusName="已作废"; + break; + default: + statusName="状态未匹配"; + break; + } + sb.append(signatory.getTenantName()).append(":").append(statusName).append(";"); + } + } + } + if(stu){ + return "success"; + }else{ + return sb.substring(0, sb.length()-1); + } + } + public SdkResponse getContract(String subjectId, Long contractId) throws Exception { + SdkClient client = this.getSdkClient(subjectId); + ContractDetailRequest request = new ContractDetailRequest(contractId); + String response; + try { + response = client.service(request); + } catch (Exception e) { + throw new Exception("合同详情查询,失败原因:" + e.getMessage()); + } + SdkResponse sdkResponse = JSONUtils.toQysResponse(response, Contract.class); + if (!sdkResponse.getCode().equals(0)) { + throw new Exception("合同详情查询,失败原因:" + sdkResponse.getMessage()); + } + return sdkResponse; + } + //合同下载 + public String contractDownload(String subjectId, Long documentId, String filePath) throws Exception { + SdkClient client = this.getSdkClient(subjectId); + DocumentDownloadRequest request = new DocumentDownloadRequest(documentId); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(filePath); + client.download(request, fos); + IOUtils.safeClose(fos); + } catch (FileNotFoundException e) { + throw new Exception("合同文件下载,失败原因:" + e.getMessage()); + }finally{ + fos.close(); + } + return "合同下载成功!"; + } + + public String messageSend(String subjectId,Long signContractId){ + SdkClient client = this.getSdkClient(subjectId); + ContractNoticeRequest request = new ContractNoticeRequest(signContractId); + String response = client.service(request); + SdkResponse responseObj = JSONUtils.toQysResponse(response); + if(responseObj.getCode() == 0) { + return "success"; + } else { + System.out.println("短信重发失败:"+responseObj.getCode()+":"+responseObj.getMessage()); + return responseObj.getMessage(); + } + } +} diff --git a/src/com/tenwa/channelportal/action/ContractSignActionTwo.java b/src/com/tenwa/channelportal/action/ContractSignActionTwo.java new file mode 100644 index 000000000..75e4dcf58 --- /dev/null +++ b/src/com/tenwa/channelportal/action/ContractSignActionTwo.java @@ -0,0 +1,316 @@ +package com.tenwa.channelportal.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP; +import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; +import jbo.com.tenwa.lease.carbrand.LB_CONTRACT_SIGN_LOG; +import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT_TEMP; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOException; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +import com.qiyuesuo.sdk.v2.bean.Contract; +import com.qiyuesuo.sdk.v2.response.DocumentAddResult; +import com.qiyuesuo.sdk.v2.response.SdkResponse; +import com.tenwa.app.manage.util.ContractSignActionTwoUtil; +import com.tenwa.comm.util.date.DateAssistant; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.lease.app.service.HttpRequestAppService; + +public class ContractSignActionTwo { + + private String FlowUnid; + private String flagType; + private String ProjectId; + private String SubjectId; + private String customerType; + private String CurUserID; + + //直接添加公司公章 + public String compnySignIng(JBOTransaction tx) throws Exception { + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObject bo = null; + try { + ContractSignActionTwoUtil catu = new ContractSignActionTwoUtil(); + BizObject pbo = pbm.createQuery("FLOWUNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(true); + // 查询lb_doc_contract_list表 + bo = contBom.createQuery("project_id=:projectId and flow_unid=:flowunid and file_flag='yes' and (sendprocess='0' or sendprocess='2' ) ") + .setParameter("projectId", ProjectId).setParameter("flowunid", FlowUnid).getSingleResult(true); + if(bo == null ){ + throw new RuntimeException("请检查合同文件是否生成!"); + } else { + Map>> parameter = new HashMap>>(); + List> companyPar = new LinkedList>(); + // 添加公司公章 + Map param1 = new HashMap(); + param1.put("type", "1");// 1标识当期发起公司公章,2标识当前公司下的子公司 + param1.put("mobile", "12599998888");//子公司添加接收手机号,如果不需要接收,直接填写一个虚拟不存在就行,如果需要传真实手机号 + companyPar.add(param1); + Map param2 = new HashMap(); + param2.put("type", "2");// 1标识当期发起公司公章,2标识当前公司下的子公司 + param2.put("mobile", "12599998888");//子公司添加接收手机号,如果不需要接收,直接填写一个虚拟不存在就行,如果需要传真实手机号 + companyPar.add(param2); + parameter.put("COMPANY", companyPar); + //创建合同 + SdkResponse createContract = catu.createContract(parameter, SubjectId,bo.getAttribute("filename").getString()); + Long contractId = createContract.getResult().getId(); + //添加本地生成的合同文件 + String makefullPath = bo.getAttribute("FULLPATH").toString();// 获取生成文件路径 + SdkResponse addDocumentByFile = catu.addDocumentByFile(makefullPath, SubjectId, contractId); + Long documentId = addDocumentByFile.getResult().getDocumentId(); + //发起合同 + catu.send(null, SubjectId, contractId, documentId); + //调用公司盖章 + catu.companySealSign(SubjectId, contractId); + bo.setAttributeValue("DOCUMENT_ID",documentId); + bo.setAttributeValue("SINGCONTRACT_ID", contractId); + bo.setAttributeValue("SIGN_TYPE", "COMPLETE");// 法人客户当盖完章改为完成状态 + bo.setAttributeValue("SENDPROCESS", "2"); + contBom.saveObject(bo); + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + String contractDocId = bo.getAttribute("id") + .toString(); + fromCondtion.put("id", contractDocId); + otherProperty.put("SIGNPROCESS", "0");// 发起电子签约 + otherProperty.put("CONTRACTDOCID", contractDocId);// 发起电子签约 + otherProperty.put("INPUTTIME",DateAssistant.getTodayNow()); + // 拷表的方法 + DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion,LB_CONTRACT_SIGN_LOG.CLASS_NAME, null,otherProperty, tx); + + pbo.setAttributeValue("DATA_STATE", "8");// 状态改成电子签约,签署中 + pbm.saveObject(pbo); + String downloadstatus = catu.contractDownload(SubjectId, documentId, makefullPath); + System.out.println("合同下载log===" + downloadstatus); + return "success"; + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + System.out.println("法人客户生成合同盖章失败" + e.getMessage()); + return "flase@error"; + } + } + + //个人直接发起电子签约 + public String signIng(JBOTransaction tx) throws Exception { + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObject bo = null; + try { + BizObject pbo = pbm.createQuery("FLOWUNID=:flowunid") + .setParameter("flowunid", FlowUnid).getSingleResult(true); + // 查询lb_doc_contract_list表 + bo = contBom.createQuery("project_id=:projectId and file_flag='yes' and (sendprocess='0' or sendprocess='2' ) ") + .setParameter("projectId", ProjectId).getSingleResult(true); + if(bo == null ){ + throw new RuntimeException("请检查合同文件是否生成!"); + } else { + Map>> parameter = new HashMap>>(); + List> companyPar = new LinkedList>(); + // 添加公司公章 + Map param1 = new HashMap(); + param1.put("type", "1");// 1标识当期发起公司公章,2标识当前公司下的子公司 + param1.put("mobile", "12599998888");//子公司添加接收手机号,如果不需要接收,直接填写一个虚拟不存在就行,如果需要传真实手机号 + companyPar.add(param1); + Map param2 = new HashMap(); + param2.put("type", "2");// 1标识当期发起公司公章,2标识当前公司下的子公司 + param2.put("mobile", "12599998888");//子公司添加接收手机号,如果不需要接收,直接填写一个虚拟不存在就行,如果需要传真实手机号 + companyPar.add(param2); + parameter.put("COMPANY", companyPar); + //添加个人基本信息 + List> personPar = new LinkedList>(); + Map sqPar = new HashMap(); + sqPar.put("name",bo.getAttribute("CUSTOMERNAME").toString()); + sqPar.put("type", "sq"); + sqPar.put("mobile",bo.getAttribute("TELEPHONE").toString()); + personPar.add(sqPar); + Map gtPar = new HashMap(); + //获取共同申请人的信息 + BizObjectManager cftm = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY_TEMP.CLASS_NAME); + BizObject cft = cftm.createQuery("flowunid=:FLowUnid and Partner_='Y'").setParameter("FLowUnid", FlowUnid).getSingleResult(false); + if(cft!=null){ + String name = cft.getAttribute("name").toString(); + String mobile = cft.getAttribute("tel").toString(); + if(name.length()>0 && mobile.length()>0){ + gtPar.put("name",name); + gtPar.put("type", "gt"); + gtPar.put("mobile",mobile); + personPar.add(gtPar); + } + } + //获取担保人信息 + BizObjectManager cptm = JBOFactory.getBizObjectManager(LB_GUARANTEE_UNIT_TEMP.CLASS_NAME); + List cpts = cptm.createQuery("select * from O where flowunid=:flowUnid").setParameter("flowUnid", FlowUnid).getResultList(false); + for(BizObject cpt:cpts){ + String name = cpt.getAttribute("FULLNAME").toString(); + String mobile = cpt.getAttribute("mobile").toString(); + if(name.length()>0 && mobile.length()>0){ + Map dbPar = new HashMap(); + dbPar.put("name",name); + dbPar.put("type", "db"); + dbPar.put("mobile",mobile); + personPar.add(dbPar); + } + } + parameter.put("PERSONAL", personPar); + ContractSignActionTwoUtil catu = new ContractSignActionTwoUtil(); + //创建合同 + SdkResponse createContract = catu.createContract(parameter, SubjectId,bo.getAttribute("filename").getString()); + Long contractId = createContract.getResult().getId(); + //添加本地生成的合同文件 + String makefullPath = bo.getAttribute("FULLPATH").toString();// 获取生成文件路径 + SdkResponse addDocumentByFile = catu.addDocumentByFile(makefullPath, SubjectId, contractId); + Long documentId = addDocumentByFile.getResult().getDocumentId(); + //发起合同 + catu.send(personPar, SubjectId, contractId, documentId); + + bo.setAttributeValue("DOCUMENT_ID",documentId); + bo.setAttributeValue("SINGCONTRACT_ID", contractId); + bo.setAttributeValue("SIGN_TYPE", "SIGNING"); + bo.setAttributeValue("SENDPROCESS", "1"); + contBom.saveObject(bo); + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + String contractDocId = bo.getAttribute("id") + .toString(); + fromCondtion.put("id", contractDocId); + otherProperty.put("SIGNPROCESS", "0");// 发起电子签约 + otherProperty.put("CONTRACTDOCID", contractDocId);// 发起电子签约 + otherProperty.put("INPUTTIME",DateAssistant.getTodayNow()); + // 拷表的方法 + DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion,LB_CONTRACT_SIGN_LOG.CLASS_NAME, null,otherProperty, tx); + + pbo.setAttributeValue("DATA_STATE", "8");// 状态改成电子签约,签署中 + pbm.saveObject(pbo); + return "success"; + } + + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + System.out.println("自然人电子签约异常:" + e.getMessage()); + return "flase@error"; + } + } + + //查出签约结果 + public String contractSignStatus(JBOTransaction tx) throws Exception { + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + // 查询lb_doc_contract_list表 + BizObject bo = contBom.createQuery("project_id=:projectId and file_flag='yes' and (sendprocess='0' or sendprocess='1' ) ") + .setParameter("projectId", ProjectId).getSingleResult(true); + if(bo == null ){ + return "请检查合同文件是否生成!"; + } else { + long signContractId = new Long(bo.getAttribute("SINGCONTRACT_ID")==null ? null : bo.getAttribute("SINGCONTRACT_ID").getString()); + long documentId = new Long(bo.getAttribute("DOCUMENT_ID")==null ? null : bo.getAttribute("DOCUMENT_ID").getString()); + String makefullPath = bo.getAttribute("FULLPATH")==null ? null : bo.getAttribute("FULLPATH").getString();// 获取生成文件路径 + + ContractSignActionTwoUtil catu = new ContractSignActionTwoUtil(); + String contractStatus = catu.getContractStatus(SubjectId, signContractId); + if("success".equals(contractStatus)){ + //调用公司盖章 + catu.companySealSign(SubjectId, signContractId); + bo.setAttributeValue("SIGN_TYPE", "COMPLETE"); + bo.setAttributeValue("SENDPROCESS", "1"); + contBom.saveObject(bo); + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + String contractDocId = bo.getAttribute("id").toString(); + fromCondtion.put("id", contractDocId); + otherProperty.put("SIGNPROCESS", "0");// 发起电子签约 + otherProperty.put("CONTRACTDOCID", contractDocId);// 发起电子签约 + otherProperty.put("INPUTTIME",DateAssistant.getTodayNow()); + // 拷表的方法 + DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion,LB_CONTRACT_SIGN_LOG.CLASS_NAME, null,otherProperty, tx); + + BizObject pbo = pbm.createQuery("FLOWUNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(true); + pbo.setAttributeValue("DATA_STATE", "8");// 状态改成电子签约,签署中 + pbm.saveObject(pbo); + String downloadstatus = catu.contractDownload(SubjectId, documentId, makefullPath); + System.out.println("合同下载log===" + downloadstatus); + return "已完成"; + }else{ + return contractStatus; + } + } + } + + public String sendMessageAgain(JBOTransaction tx) { + try{ + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObject bo = null; + bo = contBom.createQuery("select singcontract_id,filename from O where project_id =:projectId" + +" and file_flag = 'yes' and sendprocess = '1' and sign_type = 'SIGNING'") + .setParameter("projectId", ProjectId).getSingleResult(true); + if(bo == null ){ + return "请检查合同文件是否生成!"; + } else { + long signContractId =new Long(bo.getAttribute("SINGCONTRACT_ID")==null ? null : bo.getAttribute("SINGCONTRACT_ID").getString()); + ContractSignActionTwoUtil catu = new ContractSignActionTwoUtil(); + return catu.messageSend(SubjectId, signContractId); + } + } catch (Exception e) { + try { + tx.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + return "error"; + } + } + + public String getFlowUnid() { + return FlowUnid; + } + public void setFlowUnid(String flowUnid) { + FlowUnid = flowUnid; + } + public String getFlagType() { + return flagType; + } + public void setFlagType(String flagType) { + this.flagType = flagType; + } + public String getProjectId() { + return ProjectId; + } + public void setProjectId(String projectId) { + ProjectId = projectId; + } + public String getSubjectId() { + return SubjectId; + } + public void setSubjectId(String subjectId) { + SubjectId = subjectId; + } + + public String getCustomerType() { + return customerType; + } + + public void setCustomerType(String customerType) { + this.customerType = customerType; + } + + public String getCurUserID() { + return CurUserID; + } + + public void setCurUserID(String curUserID) { + CurUserID = curUserID; + } + +} diff --git a/src_sql/鎶曚骇SQL/v20200915/tft_20200915.sql b/src_sql/鎶曚骇SQL/v20200915/tft_20200915.sql index 818d5ecd1..7de488310 100644 --- a/src_sql/鎶曚骇SQL/v20200915/tft_20200915.sql +++ b/src_sql/鎶曚骇SQL/v20200915/tft_20200915.sql @@ -81,3 +81,14 @@ Insert Into AWE_MENU_INFO (menuid,menuname,displayname,sortno,url,urlparam,targe Insert Into AWE_Role_Menu (roleid,menuid) Values ('099','2000100100'); Insert Into AWE_Role_Menu (roleid,menuid) Values ('401','2000100100'); +-- 添加联合租赁数据字典 +Insert Into Code_Library (codeno,itemno,itemname,bankno,sortno,isinuse,itemdescribe,itemattribute,relativecode,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,inputuser,inputorg,inputtime,updateuser,updatetime,remark,helptext) Values ('operationType','LHZL','联合租赁','','0130','1','','','','','','','','','','','','SYS_Designer',null,'2020/08/10 17:48:32','SYS_Designer','2020/08/10 17:48:32','',''); +-- 添加联合租赁模板 +insert into `BF_TEMPLATE` (`ID`, `SERIALNO`, `SORTNUMBER`, `TEMPLATENAME`, `TEMPLATESHOWNAME`, `TEMPLATEPATH`, `TEMPLATETYPE`, `OPERATETYPE`, `CALLBACK`, `CREATEMETHOD`, `DOCTYPE`, `ONECLASSIFY`, `TWOCLASSIFY`, `THREECLASSIFY`, `FOURCLASSIFY`, `TEMPLATEVERSION`, `STATUS`, `REMARK`, `INPUTUSERID`, `INPUTORGID`, `INPUTTIME`, `UPDATEUSERID`, `UPDATEORGID`, `UPDATETIME`, `CREATECONDITION`, `CREATESHEETCONDITION`) values('7ae245ef8b644b62a4658069adab6c32',NULL,'','联合融资租赁合同','联合融资租赁合同{contractNo}.docx','联合租赁——融资租赁合同-修订版-20200806.docx','word','create','',NULL,'030','030002','','','','1','','','administrator','8009001','2020/08/10 17:41:46','administrator','8009001','2020/08/19 17:30:02','',''); +-- 添加联合租赁导出配置 +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('11e08087fd854e738d199f40f93c36f7','975294b526544d83b806e3fc2f99cd16','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('12b9dfb9ca584f0aa1713d8aed9589f9','ced1455267d64183ba1b270a9eda6089','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('51d1387dbb964b30bebc6dc77d099c5a','484815c4a7a14cf6bdbf69939e5b060e','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('8fbac8e4d5534b1296d81045bca4ef0f','9ba1a7844e4447fe9cb115323a37736f','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('b99e0d5dd6654d0a9a49d09903c53892','755698c1c27a43efa6c23310757c6163','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); +insert into `bf_templatelable` (`ID`, `LABLEID`, `TEMPLATEID`, `INPUTUSERID`, `INPUTORGID`, `UPDATEUSERID`, `UPDATEORGID`, `INPUTTIME`, `UPDATETIME`) values('ed6f64afce91422980cc7efd5f8c9aae','be101123ef74413eb0d8acad8b6b22b9','7ae245ef8b644b62a4658069adab6c32',NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/src_tenwa/com/tenwa/makeContract/util/MakeOneCodeAndContractModel.java b/src_tenwa/com/tenwa/makeContract/util/MakeOneCodeAndContractModel.java index 629026722..77df60d02 100644 --- a/src_tenwa/com/tenwa/makeContract/util/MakeOneCodeAndContractModel.java +++ b/src_tenwa/com/tenwa/makeContract/util/MakeOneCodeAndContractModel.java @@ -280,19 +280,23 @@ public class MakeOneCodeAndContractModel { }else{ return "error"; } + String filename = cont.getAttribute("filename")+""; PdfReader reader = new PdfReader(InPdfFile, "PDF".getBytes()); int pages = reader.getNumberOfPages();//获取pdf的总页数 PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(newPath)); Image img = Image.getInstance(markImagePath);//插入水印 - //设置图片宽度和高度 - img.scaleAbsolute(160, 22); - //设置图片水印的位置。 - img.setAbsolutePosition(400, 785); - + if(filename.indexOf("联合")>=0){ + //设置图片宽度和高度 + img.scaleAbsolute(160, 15); + //设置图片水印的位置。 + img.setAbsolutePosition(265, 820); + }else{ + img.scaleAbsolute(160, 22); + img.setAbsolutePosition(400, 785); + } PdfContentByte under = stamp.getUnderContent(1); under.addImage(img); - String filename = cont.getAttribute("filename")+""; - if(pages>2&&"02".equals(leasform)&&filename.indexOf("BJ90形式售后回租")<0){ + if(pages>2&&"02".equals(leasform)&&filename.indexOf("BJ90形式售后回租")<0 && filename.indexOf("联合")<0){ PdfContentByte under2 = stamp.getUnderContent(3); under2.addImage(img); }