fix:新版合同模板上线

This commit is contained in:
maliang 2021-01-08 10:00:30 +08:00
parent 33d90ed5c4
commit 1c920812d5
4 changed files with 814 additions and 28 deletions

View File

@ -13,8 +13,8 @@
*/
String sPrevUrl = CurPage.getParameter("PrevUrl");
String customertype = CurPage.getParameter("customertype");//获取客户类型,用于判断生成合同的方法
String flowunid=CurPage.getParameter("FlowUnid");
String ishistory=CurPage.getParameter("IsHistory");
String proj_id=CurPage.getParameter("proj_id");
@ -27,7 +27,7 @@
String contractid=CurPage.getParameter("ContractId");//获取合同id
String isnetcar=CurPage.getParameter("isNetCar");//获取是否是网约车
String SubjectId=CurPage.getParameter("SubjectId");//获取主体ID
if(null==contractNo ||"null".equals(contractNo) ){
contractNo=FlowKey;
}
@ -40,7 +40,7 @@
String leasform = CurPage.getParameter("leasform");
if(sPrevUrl == null) sPrevUrl = "";
String sTempletNo = "BaseFileTemplateSelect";//--模板号--
String product_id = Sqlca.getString("select PRODUCT_ID from lb_project_info where id='"+projectId+"'");
//获取盖章模式
String sealType = Sqlca.getString("select sealType from PRD_SPECIFIC_LIBRARY where productid='"+product_id+"'");
@ -101,7 +101,7 @@
Netaddress = address;
}
}
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
String a="false";//融资租赁
String b="false";//保理
@ -129,7 +129,7 @@
}else{
LeaseType="NoBusiness";
} */
doTemp.setHtmlEvent("ONECLASSIFY","onchange","initTwoClass");
doTemp.setHtmlEvent("TWOCLASSIFY","onchange","initThreeClass");
doTemp.setHtmlEvent("THREECLASSIFY","onchange","initFourClass");
@ -157,10 +157,10 @@
{phaseno.equals("0010")&&(!RightType.equals("ReadOnly"))?"true":"false","","Button","生成合同","生成合同","createContractByTemplate()","","","","btn_icon_up",""}
};
}
dwTemp.replaceColumn("contracttemplate", "<div id=\"filetemplatemodel\" style=\"heigth:100%,width:100px\">请稍等。。。。。。</div>", CurPage.getObjectWindowOutput());
dwTemp.replaceColumn("contracttemplate", "<div id=\"filetemplatemodel\" style=\"heigth:100%,width:100px\">请稍等。。。。。。</div>", CurPage.getObjectWindowOutput());
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
var docno = "";
var docno = "";
$(document).ready(function(){
var RightType="<%=RightType%>";
var phaseno="<%=phaseno%>";
@ -179,8 +179,8 @@
initFileTemplate(eval("("+jsonData[0].fileTemplate+")"));
// initOneClass();
});
//加载一级分类选项
function initOneClass(status){
var oneClass=getItemValue(0,0,"ONECLASSIFY");
@ -205,7 +205,7 @@
}else{
setItemValue(0,0,"TWOCLASSIFY","");
}
initThreeClass(status);
initThreeClass(status);
}
//加载三级分类选项
function initThreeClass(status){
@ -224,7 +224,7 @@
//加载四级分类选项
function initFourClass(status){
var threeClass=getItemValue(0,0,"THREECLASSIFY");
if(threeClass==""){threeClass=" ";}
var fourClass=getItemValue(0,0,"FOURCLASSIFY");
var sql="select itemno,itemname from code_library where codeno='ProductContractTemplate' and itemno like '"+threeClass+"%' AND LENGTH(itemno)=9";
@ -236,7 +236,7 @@
}
loadFileTemplateClasses(4);
}
function loadFileTemplateClasses(cindex){
cindex=4;
var templateType=['ONECLASSIFY','TWOCLASSIFY','THREECLASSIFY','FOURCLASSIFY'];
@ -268,16 +268,16 @@
}
$("#filetemplatemodel").append("</table>");
}
function createContractByTemplate(){
var checkbox=$("#filetemplatemodel").html()||"";
if(checkbox==""){alert("请选择合同模板下面的分类,或分类下面没有模板");return false;}
var tempids="";
$('input[name="fileTemplate"]:checked').each(function(){
var tempids="";
$('input[name="fileTemplate"]:checked').each(function(){
if(tempids.length>0){
tempids+="&";
}
tempids += $(this).attr('value');
}
tempids += $(this).attr('value');
});
if(tempids.length<=0){
alert("请勾选合同模板!");
@ -328,22 +328,30 @@
tempParam["NETCERTID"]="<%=NetCertid%>";
tempParam["NETMOBILE"]="<%=NetMobile%>";
tempParam["NETADDRESS"]="<%=Netaddress%>";
tempParam["fileSavePath"]="<%=CurConfig.getConfigure("FileSavePath")%>";
param["templateIds"]=tempids;//选择的模板ID
//专用车产品、网约车、大通 使用手签的模板生成合同
var operationType2 = "<%=CurPage.getParameter("operationType")%>";
//alert(operationType2);
if("ZYC"==operationType2||"WYC"==operationType2||"DT"==operationType2){
param["templateIds"]='5c494617683548a49cfc050f60067ea2';//选择的模板ID
}else{
param["templateIds"]=tempids;//选择的模板ID
}
param["templateParam"]=JSON.stringify(tempParam).replace(/,/g,"@");//生成模板的参数据
for(var key in param){
if(sparam.length>0){sparam+=",";}
sparam+=key+"="+param[key];
}
var sReturn0 = RunJavaMethodTrans("com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil","createContractTemplate",sparam);
if(sReturn0.length>2){
alert(sReturn0);
}else{
RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","wordToPdf","FlowUnid=<%=flowunid%>,flagType=word");
var pdfPath=RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","wordToPdf","FlowUnid=<%=flowunid%>,flagType=word");
<%-- if("01"=="<%=customertype%>"||"1"=="<%=CurPage.getParameter("isNetCar")%>"||"BAIC_MOTOR"=="<%=CurPage.getParameter("operationType")%>"||"ZYC"=="<%=CurPage.getParameter("operationType")%>"||"KHSQ"=="<%=CurPage.getParameter("operationType")%>"||"KJZL"=="<%=CurPage.getParameter("operationType")%>"){ --%>
var OwmMessage = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","SystemMakeOneDimensionalCode","ProjectId=<%=projectId%>,contract_id=<%=sContractId%>,contractNo=<%=contractNo%>,leasform=<%=leasform%>");
if("error"==OwmMessage){
@ -357,7 +365,10 @@
var operationType = "<%=CurPage.getParameter("operationType")%>";
if("LHZL"==operationType || "SQSYC"==operationType){
falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwo","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>,operationType="+operationType);
}else{
//商用车一车一挂、专用车产品、网约车、大通、C端直租、客户手签、
}else if ("SYCSHHZ"==operationType||"ZYC"==operationType||"WYC"==operationType||"DT"==operationType||"CDZZ"==operationType||"5c494617683548a49cfc050f60067ea2"==tempids){
falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignActionTwoOwn","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>,tempid="+tempids);
} else{
falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>,SubjectId=<%=SubjectId%>");
}
if("success"!= falg ){
@ -367,7 +378,7 @@
return;
}
}
alert("生成成功");
}
reloadSelf();

View File

@ -0,0 +1,349 @@
package com.tenwa.channelportal.action;
import com.amarsoft.are.jbo.*;
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.qiyuesuo.v2.ContractSignEnums;
import com.tenwa.app.manage.qiyuesuo.v2.ContractSignVtwoUtils;
import com.tenwa.comm.util.date.DateAssistant;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
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 java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class ContractSignActionTwoOwn {
private String FlowUnid;
private String flagType;
private String ProjectId;
private String SubjectId;
private String customerType;
private String CurUserID;
private String operationType;
private String tempid;
//直接添加公司公章
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 {
ContractSignActionTwoOwnUtil catu = new ContractSignActionTwoOwnUtil();
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<String, List<Map<String, String>>> parameter = new HashMap<String, List<Map<String, String>>>();
List<Map<String, String>> companyPar = new LinkedList<Map<String, String>>();
Map<String, String> param1 = new HashMap<String, String>();
param1.put("type", "1");// 1标识当期发起公司公章2标识当前公司下的子公司
param1.put("mobile", "12599998888");//子公司添加接收手机号如果不需要接收直接填写一个虚拟不存在就行如果需要传真实手机号
companyPar.add(param1);
// 添加公司公章
if("LHZL".equals(operationType)){
Map<String, String> param2 = new HashMap<String, String>();
param2.put("type", "2");// 1标识当期发起公司公章2标识当前公司下的子公司
param2.put("mobile", "12599998888");//子公司添加接收手机号如果不需要接收直接填写一个虚拟不存在就行如果需要传真实手机号
companyPar.add(param2);
}
parameter.put("COMPANY", companyPar);
//创建合同
SdkResponse<Contract> createContract = catu.createContract(parameter, SubjectId,bo.getAttribute("filename").getString());
Long contractId = createContract.getResult().getId();
//添加本地生成的合同文件
String makefullPath = bo.getAttribute("FULLPATH").toString();// 获取生成文件路径
SdkResponse<DocumentAddResult> addDocumentByFile = catu.addDocumentByFile(makefullPath, SubjectId, contractId);
Long documentId = addDocumentByFile.getResult().getDocumentId();
//发起合同
catu.send(null, SubjectId, contractId, documentId,tempid);
//调用公司盖章
catu.companySealSign(SubjectId, contractId);
// ContractSignVtwoUtils contractSignVtwoUtils = new ContractSignVtwoUtils();
// System.out.println("claimSignInsuranceTwo 发起公司盖章");
// String tempId="5c494617683548a49cfc050f60067ea2";
// String fileName=bo.getAttribute("filename").getString();
// String filePath=makefullPath;
// String res = contractSignVtwoUtils.sign(ContractSignEnums.ContractSignTypeEnum.SIGNATURE_DEFAULT,
// tempId, SubjectId, fileName, filePath, null);
bo.setAttributeValue("DOCUMENT_ID",documentId);
bo.setAttributeValue("SINGCONTRACT_ID", contractId);
bo.setAttributeValue("SIGN_TYPE", "COMPLETE");// 法人客户当盖完章改为完成状态
bo.setAttributeValue("SENDPROCESS", "2");
contBom.saveObject(bo);
Map<String, String> fromCondtion = new HashMap<String, String>();
Map<String, String> otherProperty = new HashMap<String, String>();
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<String, List<Map<String, String>>> parameter = new HashMap<String, List<Map<String, String>>>();
List<Map<String, String>> companyPar = new LinkedList<Map<String, String>>();
// 添加公司公章
Map<String, String> param1 = new HashMap<String, String>();
param1.put("type", "1");// 1标识当期发起公司公章2标识当前公司下的子公司
param1.put("mobile", "12599998888");//子公司添加接收手机号如果不需要接收直接填写一个虚拟不存在就行如果需要传真实手机号
companyPar.add(param1);
if( "LHZL".equals(operationType) ){
Map<String, String> param2 = new HashMap<String, String>();
param2.put("type", "2");// 1标识当期发起公司公章2标识当前公司下的子公司
param2.put("mobile", "12599998888");//子公司添加接收手机号如果不需要接收直接填写一个虚拟不存在就行如果需要传真实手机号
companyPar.add(param2);
}
parameter.put("COMPANY", companyPar);
//添加个人基本信息
List<Map<String, String>> personPar = new LinkedList<Map<String, String>>();
Map<String, String> sqPar = new HashMap<String, String>();
sqPar.put("name",bo.getAttribute("CUSTOMERNAME").toString());
sqPar.put("type", "sq");
sqPar.put("mobile",bo.getAttribute("TELEPHONE").toString());
personPar.add(sqPar);
Map<String, String> gtPar = new HashMap<String, String>();
//获取共同申请人的信息
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<BizObject> cpts = cptm.createQuery("select * from O where flowunid=:flowUnid and CERTTYPE='Ind01' ").setParameter("flowUnid", FlowUnid).getResultList(false);
int count = 0;
if(cpts!=null && cpts.size()>2){
count = 2;
}else{
count = cpts.size();
}
for(int i=0;i<count;i++){
BizObject cpt = cpts.get(i);
String name = cpt.getAttribute("FULLNAME").toString();
String mobile = cpt.getAttribute("mobile").toString();
if(name.length()>0 && mobile.length()>0){
Map<String, String> dbPar = new HashMap<String, String>();
dbPar.put("name",name);
dbPar.put("type", "db");
dbPar.put("mobile",mobile);
personPar.add(dbPar);
}
}
parameter.put("PERSONAL", personPar);
ContractSignActionTwoOwnUtil catu = new ContractSignActionTwoOwnUtil();
//创建合同
SdkResponse<Contract> createContract = catu.createContract(parameter, SubjectId,bo.getAttribute("filename").getString());
Long contractId = createContract.getResult().getId();
//添加本地生成的合同文件
String makefullPath = bo.getAttribute("FULLPATH").toString();// 获取生成文件路径
SdkResponse<DocumentAddResult> addDocumentByFile = catu.addDocumentByFile(makefullPath, SubjectId, contractId);
Long documentId = addDocumentByFile.getResult().getDocumentId();
//发起合同
catu.send(personPar, SubjectId, contractId, documentId,tempid);
bo.setAttributeValue("DOCUMENT_ID",documentId);
bo.setAttributeValue("SINGCONTRACT_ID", contractId);
bo.setAttributeValue("SIGN_TYPE", "SIGNING");
bo.setAttributeValue("SENDPROCESS", "1");
contBom.saveObject(bo);
Map<String, String> fromCondtion = new HashMap<String, String>();
Map<String, String> otherProperty = new HashMap<String, String>();
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();// 获取生成文件路径
ContractSignActionTwoOwnUtil catu = new ContractSignActionTwoOwnUtil();
String contractStatus = catu.getContractStatus(SubjectId, signContractId);
if("success".equals(contractStatus)){
//调用公司盖章
catu.companySealSign(SubjectId, signContractId);
bo.setAttributeValue("SIGN_TYPE", "COMPLETE");
bo.setAttributeValue("PROCESS", "5");
// contBom.saveObject(bo);
Map<String, String> fromCondtion = new HashMap<String, String>();
Map<String, String> otherProperty = new HashMap<String, String>();
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);
bo.setAttributeValue("PROCESS", "6");
contBom.saveObject(bo);
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());
ContractSignActionTwoOwnUtil catu = new ContractSignActionTwoOwnUtil();
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;
}
public String getOperationType() {
return operationType;
}
public void setOperationType(String operationType) {
this.operationType = operationType;
}
public String getTempid() {
return tempid;
}
public void setTempid(String tempid) {
this.tempid = tempid;
}
}

View File

@ -0,0 +1,397 @@
package com.tenwa.channelportal.action;
import com.amarsoft.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
import com.qiyuesuo.sdk.v2.SdkClient;
import com.qiyuesuo.sdk.v2.bean.*;
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.*;
import com.qiyuesuo.sdk.v2.response.DocumentAddResult;
import com.qiyuesuo.sdk.v2.response.SdkResponse;
import com.qiyuesuo.sdk.v2.utils.IOUtils;
import com.tenwa.app.manage.qiyuesuo.v2.StamperVo;
import com.tenwa.util.MultiSubjectUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.*;
public class ContractSignActionTwoOwnUtil {
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<Contract> createContract(Map<String, List<Map<String, String>>> parameter,String subjectId,String fileNme) throws Exception {
SdkClient client = this.getSdkClient(subjectId);
Contract draftContract = new Contract();
draftContract.setSubject(fileNme);
draftContract.setOrdinal(false);
List<Map<String, String>> list = parameter.get("PERSONAL");
if(list!=null && list.size()>0){
for (Map<String, String> 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<String, String> 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());
}
System.out.println(response);
SdkResponse<Contract> sdkResponse = JSONUtils.toQysResponse(response,
Contract.class);
if (!sdkResponse.getCode().equals(0)) {
throw new Exception("创建合同草稿失败,失败原因:" + sdkResponse.getMessage());
}
return sdkResponse;
}
//添加本地文件
public SdkResponse<DocumentAddResult> 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<DocumentAddResult> sdkResponse = JSONUtils.toQysResponse(
response, DocumentAddResult.class);
if (!sdkResponse.getCode().equals(0)) {
throw new Exception("根据文件添加文档失败,失败原因:" + sdkResponse.getMessage());
}
return sdkResponse;
}
//发起合同
public SdkResponse send(List<Map<String, String>> personList,String subjectId, Long contractId,Long documentId,String tempid) throws Exception {
SdkClient client = this.getSdkClient(subjectId);
Contract draft = getContract(subjectId, contractId).getResult();
String contractName = draft.getSubject();
List<Stamper> stampers = new LinkedList<Stamper>();
// 获取SignatoryId与ActionId用于指定签署位置公司签署位置需要指定ActionId,个人签署位置需要指定SignatoryId
Long platformSignatoryId = null;
Long personalSignatoryId = null;
Long companySealActionId = null;
int dbcont = 0;
for (Signatory signatory : draft.getSignatories()) {
// 获取平台方SignatoryId以及对应的公章签署ActionId和法人章签署ActionId
if (signatory.getTenantType().equals("COMPANY")) {
for (Action action : signatory.getActions()) {
platformSignatoryId = signatory.getId();
companySealActionId = action.getId();
stampers=getStampers(tempid,documentId,companySealActionId,platformSignatoryId);
// Stamper sealStamper = new Stamper();
// sealStamper.setPage(0);
// sealStamper.setType("COMPANY");
// sealStamper.setActionId(companySealActionId);
// sealStamper.setSignatoryId(platformSignatoryId);
// sealStamper.setDocumentId(documentId);
// if (action.getName().equals(sZ_CompanyName)||action.getName().equals(tJ_CompanyName)) {
//// sealStamper.setKeyword("甲方出租人1公章 ");
// sealStamper.setKeyword("甲方(出租人):(公章)");
// sealStamper.setOffsetX(-0.12);
//// sealStamper.setOffsetY(-0.04);
// sealStamper.setOffsetY(-0.13);
//
// //添加第二个盖章位置
// Stamper sealStamper2 = new Stamper();
// sealStamper2.setPage(0);
// sealStamper2.setType("COMPANY");
// sealStamper2.setActionId(companySealActionId);
// sealStamper2.setSignatoryId(platformSignatoryId);
// sealStamper2.setDocumentId(documentId);
// sealStamper2.setKeyword("抵押权人:安鹏融资租赁(天津)有限公司");
// sealStamper2.setOffsetX(-0.18);
// sealStamper2.setOffsetY(-0.10);
// stampers.add(sealStamper2);
// stampers.add(sealStamper);
// } else {
// //sealStamper.setKeyword("甲方出租人2公章");
// sealStamper.setKeyword("甲方出租人1公章 ");
// sealStamper.setOffsetX(-0.12);
//// sealStamper.setOffsetY(-0.13);
// sealStamper.setOffsetY(-0.04);
// 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;
}
/**
* 根据tempId获得签章的相关配置信息
* @param tempId
* @param documentId
* @param companySealActionId
* @param platformSignatoryId
* @return
* @throws Exception
*/
List<Stamper> getStampers(String tempId,Long documentId,Long companySealActionId,Long platformSignatoryId)throws Exception{
Transaction Sqlca=null;
List<Stamper> list = new ArrayList<>();
try {
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
String selSql = " select stamper_type, stamper_sub_type, keyword, offsetX, offsetY, keywordIndex from lb_contract_sign_stamper where temp_id='"+ tempId +"' " ;
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
while(rs.next()) {
Stamper stamper = new Stamper();
stamper.setPage(0);// 坐标页码0代表所有
stamper.setDocumentId(documentId);//合同文档ID
// 获取接口推送所需数据
stamper.setType(rs.getString("stamper_type")); // 签署类型COMPANY公章PERSONAL个人签名LP法人章TIMESTAMP时间戳ACROSS_PAGE骑缝章
stamper.setActionId(companySealActionId);
stamper.setSignatoryId(platformSignatoryId);
stamper.setKeyword(rs.getString("keyword")); // 关键字
stamper.setOffsetX(Double.parseDouble(rs.getString("offsetX"))); // 横坐标/关键字偏移量
stamper.setOffsetY(Double.parseDouble(rs.getString("offsetY"))); // 纵坐标/关键字偏移量
stamper.setKeywordIndex(Integer.parseInt(rs.getString("keywordIndex"))); // 关键字索引1代表第1个关键字0代表所有关键字-1代表倒数第1个关键字默认为1
list.add(stamper);
}
}catch (Exception e){
throw new Exception("ContractSignVtwoUtils#initQuerySql 签署位置sql查询失败原因" + e.getMessage());
}
return list;
}
//公司盖章
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<Signatory> 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<Signatory> 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<Contract> 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<Contract> 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();
}
}
}

View File

@ -269,9 +269,11 @@ public class MakeOneCodeAndContractModel {
String newPath = "";
String split ="";
String InPdfFile="";
String docName="";
if(cont!=null){
InPdfFile=cont.getAttribute("fullpath").toString();
split = cont.getAttribute("filepath").toString();
docName = cont.getAttribute("doc_name").toString();
File file = new File(outPdfFile+split.substring(0,split.lastIndexOf("/")));
if (!file.exists()) {
file.mkdirs();
@ -296,18 +298,45 @@ public class MakeOneCodeAndContractModel {
//设置图片水印的位置
img.setAbsolutePosition(380, 750);
}else{
img.scaleAbsolute(160, 22);
img.setAbsolutePosition(400, 785);
int width=180,height=32,x=405,y=790;
img.scaleAbsolute(width, height);
img.setAbsolutePosition(x, y);
}
PdfContentByte under = stamp.getUnderContent(1);
under.addImage(img);
if(pages>2&&"02".equals(leasform)&&filename.indexOf("BJ90形式售后回租")<0 && filename.indexOf("狮桥")<0){
PdfContentByte under2 = stamp.getUnderContent(3);
if(filename.indexOf("联合")>=0){
//<EFBFBD>零暠튬욱똑뵨멕똑
img.setAbsolutePosition(400, 800);
}
under2.addImage(img);
}
if(pages>6&&"C똥殮理".equals(docName)){
//났종슥쌈데彊丹
PdfContentByte under5 = stamp.getUnderContent(3);
img.scaleAbsolute(180, 32);
img.setAbsolutePosition(400, 800);
under5.addImage(img);
//理쏜連마깊彊丹
PdfContentByte under9 = stamp.getUnderContent(7);
img.scaleAbsolute(180, 32);
img.setAbsolutePosition(400, 800);
under9.addImage(img);
}
if((pages>8&&"02".equals(leasform)&&"북谿(簡빈쀼理)".equals(docName))
||(pages>8&&"02".equals(leasform)&&"북谿(簡빈쀼理)-<2D>痰났-친겼".equals(docName))){
//났종슥쌈데彊丹
PdfContentByte under5 = stamp.getUnderContent(5);
img.scaleAbsolute(180, 32);
img.setAbsolutePosition(400, 800);
under5.addImage(img);
//理쏜連마깊彊丹
PdfContentByte under9 = stamp.getUnderContent(9);
img.scaleAbsolute(180, 32);
img.setAbsolutePosition(400, 800);
under9.addImage(img);
}
stamp.close();// 关闭