diff --git a/WebContent/Tenwa/Lease/Flow/Comm/BigdataPengyuan/query_report/pengyuandata.jsp b/WebContent/Tenwa/Lease/Flow/Comm/BigdataPengyuan/query_report/pengyuandata.jsp index 32a43eecb..434330f09 100644 --- a/WebContent/Tenwa/Lease/Flow/Comm/BigdataPengyuan/query_report/pengyuandata.jsp +++ b/WebContent/Tenwa/Lease/Flow/Comm/BigdataPengyuan/query_report/pengyuandata.jsp @@ -112,6 +112,9 @@ <% } finally { diff --git a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/CapgeminiReport.jsp b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/CapgeminiReport.jsp index 5f980e2d1..d09d26ddb 100644 --- a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/CapgeminiReport.jsp +++ b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/CapgeminiReport.jsp @@ -36,7 +36,7 @@ if(roleList.contains("800R00000051")){ doTemp.appendJboWhere(" and O.distributor_no='"+distributor_no+"'"); - template = "cff950db664c4faeb1f4656629176004"; + template = "5addef5e8b56470688949d554cad4b24"; } ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); @@ -71,6 +71,7 @@ //生成文件关联关系 tempParam["OBJECTTYPE"]="经销商租金计划报表"; tempParam["FLOW_UNID"]="<%=new java.util.Date().getTime()%>"; + tempParam["distributor_no"]="<%=distributor_no%>"; //生成模板固定参数 tempParam["CurUserId"]="<%=CurUser.getUserID()%>"; diff --git a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/ClearingDataReport.jsp b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/ClearingDataReport.jsp index d4a4b54c3..a81b101cc 100644 --- a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/ClearingDataReport.jsp +++ b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/ClearingDataReport.jsp @@ -36,7 +36,7 @@ if(roleList.contains("800R00000051")){ doTemp.appendJboWhere(" and O.distributor_no='"+distributor_no+"'"); - template = "6d2b46cb97c84867b38e1f39d4e9a092"; + template = "6a3c4a11c86048928d8823f796ee9423"; } ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); @@ -69,6 +69,7 @@ //生成文件关联关系 tempParam["OBJECTTYPE"]="经销商结清数据报表"; tempParam["FLOW_UNID"]="<%=new java.util.Date().getTime()%>"; + tempParam["distributor_no"]="<%=distributor_no%>"; //生成模板固定参数 tempParam["CurUserId"]="<%=CurUser.getUserID()%>"; diff --git a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/DealerCollection.jsp b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/DealerCollection.jsp new file mode 100644 index 000000000..28cd07a23 --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/DealerCollection.jsp @@ -0,0 +1,102 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%> +<%@ page import="org.apache.commons.lang.StringUtils" %> +<% + /* + Author: undefined 2018-10-30 + Content: + History Log: + */ + String userid=CurUser.getUserID(); + ASObjectModel doTemp = new ASObjectModel("dealer_collection"); + + //加权限 + BizObjectManager manager = JBOFactory.getBizObjectManager("jbo.awe.USER_ROLE"); + List roleListObject = manager.createQuery("userid=:userid").setParameter("userid", userid).getResultList(false); + List roleList = new ArrayList(); + String roleid = ""; + for(BizObject bo : roleListObject){ + roleid = bo.getAttribute("roleid").toString(); + roleList.add(roleid); + } + + //导出模板编号 + String template = ""; + + //登录人属于经销商角色 401:经销商roleid + if(roleList.contains("401") && !roleList.contains("800R00000051")){ + doTemp.appendJboWhere(" and lci.project_manage='"+userid+"'"); + //导出有权限 + template = "05d55e01017a4d80945d5b6c8a8c5faf"; + }else{ + template = "05d55e01017a4d80945d5b6c8a8c5faf"; + } + String belongorg = Sqlca.getString("select belongorg from user_info where userid='"+userid+"'"); + String distributor_no = Sqlca.getString("select distributor_no from distributor_info where orgid='"+belongorg+"'"); + + if(roleList.contains("800R00000051")){ + doTemp.appendJboWhere(" and O.distributor_no='"+distributor_no+"'"); + template = "c5af519f27ec4b62bacde30b0014f101"; + } + + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.ShowSummary="1"; //汇总 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, + //{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + {"true","","Button","导出excel","导出excel","exportExcel()","","","","btn_icon_up",""}, + //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/FundIncomeReport.jsp b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/FundIncomeReport.jsp index 0e83b5f84..6bb823e58 100644 --- a/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/FundIncomeReport.jsp +++ b/WebContent/Tenwa/Lease/Flow/RentCollection/rentcollection/FundIncomeReport.jsp @@ -1,134 +1,135 @@ -<%@ page contentType="text/html; charset=GBK"%> -<%@ include file="/Frame/resources/include/include_begin_list.jspf"%> -<%@ page import="org.apache.commons.lang.StringUtils" %> -<% - /* - Author: undefined 2018-10-30 - Content: - History Log: - */ - String userid=CurUser.getUserID(); - ASObjectModel doTemp = new ASObjectModel("FundIncomeReport"); - - //加权限 - BizObjectManager manager = JBOFactory.getBizObjectManager("jbo.awe.USER_ROLE"); - List roleListObject = manager.createQuery("userid=:userid").setParameter("userid", userid).getResultList(false); - List roleList = new ArrayList(); - String roleid = ""; - for(BizObject bo : roleListObject){ - roleid = bo.getAttribute("roleid").toString(); - roleList.add(roleid); - } - //roleid:800R00000044 北财合作方 - //String roleId = "800R00000044"; - - //roleid:800R00000045 rolename: bccuishou - //如果登录人属于bccuishou角色,可以看到北财下的所有的合同 - /* if(roleList.contains("800R00000045")){ - List userObjectList = manager.createQuery("roleid=:roleid").setParameter("roleid", roleId).getResultList(false); - String userId = ""; - List useridList = new ArrayList(); - for(BizObject bo : userObjectList){ - userId = bo.getAttribute("userid").toString(); - useridList.add("'"+userId+"'"); - } - String useridStr = StringUtils.join(useridList.toArray(), ","); - doTemp.appendJboWhere(" and O.project_manage in (" + useridStr + ")"); - } */ - - //导出模板编号 - String template = ""; - - //登录人属于经销商角色 401:经销商roleid - if(roleList.contains("401") && !roleList.contains("800R00000051")){ - doTemp.appendJboWhere(" and lci.project_manage='"+userid+"'"); - //导出有权限 - template = "2cd25a9b1c6248c8abacaeeaf7cda303"; - }else{ - //导出无权限 - template = "a87e9bea25694013b9cc39216cac831e"; - } - String belongorg = Sqlca.getString("select belongorg from user_info where userid='"+userid+"'"); - String distributor_no = Sqlca.getString("select distributor_no from distributor_info where orgid='"+belongorg+"'"); - - if(roleList.contains("800R00000051")){ - doTemp.appendJboWhere(" and lci.distributor_id='"+distributor_no+"'"); - template = "2cd25a9b1c6248c8abacaeeaf7cda303"; - }else{ - template = "a87e9bea25694013b9cc39216cac831e"; - } - - ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); - dwTemp.Style="1"; //--设置为Grid风格-- - dwTemp.ReadOnly = "1"; //只读模式 - dwTemp.ShowSummary="1"; //汇总 - dwTemp.setPageSize(10); - dwTemp.genHTMLObjectWindow(""); - - //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 - String sButtons[][] = { - //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, - //{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, - {"true","","Button","导出excel","导出excel","exportExcel()","","","","btn_icon_up",""}, - //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, - }; -%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> - +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%> +<%@ page import="org.apache.commons.lang.StringUtils" %> +<% + /* + Author: undefined 2018-10-30 + Content: + History Log: + */ + String userid=CurUser.getUserID(); + ASObjectModel doTemp = new ASObjectModel("FundIncomeReport"); + + //加权限 + BizObjectManager manager = JBOFactory.getBizObjectManager("jbo.awe.USER_ROLE"); + List roleListObject = manager.createQuery("userid=:userid").setParameter("userid", userid).getResultList(false); + List roleList = new ArrayList(); + String roleid = ""; + for(BizObject bo : roleListObject){ + roleid = bo.getAttribute("roleid").toString(); + roleList.add(roleid); + } + //roleid:800R00000044 北财合作方 + //String roleId = "800R00000044"; + + //roleid:800R00000045 rolename: bccuishou + //如果登录人属于bccuishou角色,可以看到北财下的所有的合同 + /* if(roleList.contains("800R00000045")){ + List userObjectList = manager.createQuery("roleid=:roleid").setParameter("roleid", roleId).getResultList(false); + String userId = ""; + List useridList = new ArrayList(); + for(BizObject bo : userObjectList){ + userId = bo.getAttribute("userid").toString(); + useridList.add("'"+userId+"'"); + } + String useridStr = StringUtils.join(useridList.toArray(), ","); + doTemp.appendJboWhere(" and O.project_manage in (" + useridStr + ")"); + } */ + + //导出模板编号 + String template = ""; + + + String belongorg = Sqlca.getString("select belongorg from user_info where userid='"+userid+"'"); + String distributor_no = Sqlca.getString("select distributor_no from distributor_info where orgid='"+belongorg+"'"); + +// if("DSTB20190516003654".equals(distributor_no)){//测试环境18 + if("DSTB20190510003636".equals(distributor_no)){//正式环境 + doTemp.appendJboWhere(" and lci.distributor_id ='"+distributor_no+"'"); + template = "56c237b623a54732b61196c0b64b8238"; + + }else if(roleList.contains("401")){ + doTemp.appendJboWhere(" and lci.project_manage='"+userid+"'"); + //导出有权限 + template = "2cd25a9b1c6248c8abacaeeaf7cda303"; + }else{ + //导出无权限 + template = "a87e9bea25694013b9cc39216cac831e"; + } + + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.ShowSummary="1"; //汇总 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, + //{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + {"true","","Button","导出excel","导出excel","exportExcel()","","","","btn_icon_up",""}, + //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + <%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/jbo/jbo_customer.xml b/WebContent/WEB-INF/etc/jbo/jbo_customer.xml index 4e35dbda9..03442445f 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_customer.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_customer.xml @@ -3183,41 +3183,41 @@ - - - + + - - - - - - + + - - - - - - - - + + + + + + + + + + - - + + + + + @@ -3235,8 +3235,8 @@ - + @@ -3265,7 +3265,6 @@ - @@ -3273,6 +3272,7 @@ + diff --git a/WebContent/fileTemplate/璧勯噾瀹炴敹鎶ヨ〃瀵煎嚭3.xlsx b/WebContent/fileTemplate/璧勯噾瀹炴敹鎶ヨ〃瀵煎嚭3.xlsx new file mode 100644 index 000000000..c957fe64c Binary files /dev/null and b/WebContent/fileTemplate/璧勯噾瀹炴敹鎶ヨ〃瀵煎嚭3.xlsx differ diff --git a/src/com/tenwa/channelportal/action/ContractSignAction.java b/src/com/tenwa/channelportal/action/ContractSignAction.java index e5a35a59a..cc380e0ba 100644 --- a/src/com/tenwa/channelportal/action/ContractSignAction.java +++ b/src/com/tenwa/channelportal/action/ContractSignAction.java @@ -1,2617 +1,2617 @@ -package com.tenwa.channelportal.action; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP; -import jbo.app.tenwa.customer.CUSTOMER_PERSON; -import jbo.app.tenwa.customer.CUSTOMER_PERSON_TEMP; -import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; -import jbo.app.tenwa.doc.LB_DOCLIBRARY; -import jbo.app.tenwa.doc.LB_DOCRELATIVE; -import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; -import jbo.app.tenwa.doc.LB_ONEDIMENSIONALCODE; -import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; -import jbo.com.tenwa.lease.carbrand.BUSINESS_STATUS; -import jbo.com.tenwa.lease.carbrand.LB_CONTRACT_SIGN_LOG; -import jbo.com.tenwa.lease.comm.LB_CONTRACT_TEMPLATE; -import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT_TEMP; -import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; -import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP; -import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE; -import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE_TEMP; -import jbo.sys.CODE_LIBRARY; - -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.amarsoft.are.util.StringFunction; -import com.amarsoft.awe.Configure; -import com.amarsoft.awe.util.ASResultSet; -import com.amarsoft.awe.util.SqlObject; -import com.amarsoft.awe.util.Transaction; -import com.amarsoft.context.ASUser; -import com.caucho.hessian.client.HessianProxyFactory; -import com.tenwa.app.dao.ContractSignInfo; -import com.tenwa.lease.app.service.HttpRequestAppService; -import com.tenwa.lease.flow.contract.contractapproval.ContractTemplateCache; -import com.tenwa.makeContract.util.MakeOneCodeAndContractModel; -import com.tenwa.channelportal.action.generativecontract.Word2PdfUtil; -import com.tenwa.channelportal.action.generativecontract.WordToPDFUtil; -import com.tenwa.comm.util.date.DateAssistant; -import com.tenwa.comm.util.jboutil.DataOperatorUtil; -import com.tenwa.doc.util.BASE64; -import com.tenwa.officetempalte.util.FileOperatorUtil; -import com.tenwa.quartz.DateUtil; -import com.tenwa.reckon.util.UUIDUtil; - -public class ContractSignAction{ - public String file_id; - public String cust_phone; - public String cust_id; - public String library_id; - public String customerType; - public String CurUserID; - public String ProjectId; - public String contract_id; - public String FlowUnid; - public String InputOrgid; - public String id; - private String attrId; - public String flagType; - public HessianProxyFactory factory = new HessianProxyFactory(); - public HttpRequestAppService requestService; - public String PAYMENT_NUMBER; - public String PLAN_LIST; - public String Ttype; - public String contractNo; - public String leasform; - private static Logger logger=Logger.getLogger(ContractSignAction.class); - @SuppressWarnings("deprecation") - public static String getConfigRequestUrl() throws Exception{ - return Configure.getInstance().getConfigure("RequestHessionUrl"); - } - @SuppressWarnings("deprecation") - public static String getFileSavePath() throws Exception{ - return Configure.getInstance().getConfigure("FileSavePath"); - } - - public String getCurUserID() { - return CurUserID; - } - - public String getContract_id() { - return contract_id; - } - - public void setContract_id(String contract_id) { - this.contract_id = contract_id; - } - - public void setCurUserID(String curUserID) { - CurUserID = curUserID; - } - - public String getCustomerType() { - return customerType; - } - - public void setCustomerType(String customerType) { - this.customerType = customerType; - } - - public String getFile_id() { - return file_id; - } - - public void setFile_id(String file_id) { - this.file_id = file_id; - } - - - public String getCust_id() { - return cust_id; - } - - public void setCust_id(String cust_id) { - this.cust_id = cust_id; - } - - public String getCust_phone() { - return cust_phone; - } - public void setCust_phone(String cust_phone) { - this.cust_phone = cust_phone; - } - - public String getLibrary_id() { - return library_id; - } - public void setLibrary_id(String library_id) { - this.library_id = library_id; - } - - public String getProjectId() { - return ProjectId; - } - - public void setProjectId(String projectId) { - ProjectId = projectId; - } - - public String getFlowUnid() { - return FlowUnid; - } - - public void setFlowUnid(String flowUnid) { - FlowUnid = flowUnid; - } - - public String getInputOrgid() { - return InputOrgid; - } - - public void setInputOrgid(String inputOrgid) { - InputOrgid = inputOrgid; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - //类型 - public String getFlagType() { - return flagType; - } - - public void setFlagType(String flagType) { - this.flagType = flagType; - } - public String getAttrId() { - return attrId; - } - public void setAttrId(String attrId) { - this.attrId = attrId; - } - - - public String getPAYMENT_NUMBER() { - return PAYMENT_NUMBER; - } - public void setPAYMENT_NUMBER(String pAYMENT_NUMBER) { - PAYMENT_NUMBER = pAYMENT_NUMBER; - } - public String getPLAN_LIST() { - return PLAN_LIST; - } - public void setPLAN_LIST(String pLAN_LIST) { - PLAN_LIST = pLAN_LIST; - } - public String getTtype() { - return Ttype; - } - public void setTtype(String ttype) { - Ttype = ttype; - } - public String getContractNo() { - return contractNo; - } - public void setContractNo(String contractNo) { - this.contractNo = contractNo; - } - public String getLeasform() { - return leasform; - } - public void setLeasform(String leasform) { - this.leasform = leasform; - } - /** - * 自然人电子签约 - * - * @author tenwa518 - * @param tx - * @return - * @throws Exception - */ - @SuppressWarnings("unchecked") - public String signIng(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); - BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObjectManager lcslBom = JBOFactory.getBizObjectManager(LB_CONTRACT_SIGN_LOG.CLASS_NAME,tx); - Map> map = new HashMap>(); - ContractSignInfo con = null; - List bo = null; - BizObject ldclBo = null; - try { - //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); - 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).getResultList(true); - for (BizObject keys : bo) { - String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); - StringBuffer manyPeople = this.manyPeople(); - if(manyPeople.length()>0){ - info=info+"@applicant,"+manyPeople.deleteCharAt(manyPeople.length() - 1); - } - List list = map.get(info); - if (list == null) { - list = new ArrayList(); - map.put(info, list); - } - con = new ContractSignInfo(); - con.setCustname(keys.getAttribute("DOC_NAME").toString()); - con.setCustphone(keys.getAttribute("TELEPHONE").toString()); - con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(keys.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = keys.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - list.add(con); - } - Map fromCondtion = new HashMap(); - Map otherProperty = new HashMap(); - Map resultMap = requestService.createContractSign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - //记录项目进程日志 - /*Transaction tran = Transaction.createTransaction(tx); - ASUser user = ASUser.getUser(CurUserID, tran); - JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) - .createQuery("UPDATE O SET BUSINESS_STATUS='8',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM "+LB_PROJECT_INFO.CLASS_NAME+" LPI WHERE LPI.ID='"+ProjectId+"')").executeUpdate(); - SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'8','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+ProjectId+"'"); - so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); - so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); - so.setRunSql(so.getRunSql().replaceAll("△", ":")); - tran.executeSQL(so);*/ - return "success"; - } else { - Boolean flag = false; - String getMessage = resultMap.get("error"); - logger.info("契约锁反馈的异常信息" + getMessage); - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1 && !"error".equals(key)) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - if ("1".equals(sendProcess)) { - flag = true; - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - }else if("2".equals(sendProcess)){ - ldclBo.setAttributeValue("MESSAGE",getMessage ); - } - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - } - } - // 判断不同的异常反馈给前端 - if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { - getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); - return flag + "@" + getMessage; - } else if (getMessage.indexOf("contractId不能为空") != -1) { - return flag + "@" + getMessage; - } else { - return flag + "@" + "error"; - } - } - } catch (Exception e) { - tx.rollback(); - e.printStackTrace(); - logger.info("自然人电子签约异常:" + e.getMessage()); - return "flase@error"; - } - } - /** - * 法人客户在生成合同是直接盖章 - * @param tx - * @return - * @throws Exception - */ - - @SuppressWarnings("unchecked") - public String compnySignIng(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); - BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - Map map = new HashMap(); - ContractSignInfo con = null; - List bo = null; - BizObject ldclBo = null; - try { - //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); - 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).getResultList(true); - for (BizObject keys : bo) { - String info = keys.getAttribute("id").toString(); - con = new ContractSignInfo(); - con.setCustname(keys.getAttribute("DOC_NAME").toString()); - con.setCustphone(keys.getAttribute("TELEPHONE").toString()); - con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(keys.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = keys.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(info, con); - } - Map fromCondtion = new HashMap(); - Map otherProperty = new HashMap(); - Map resultMap = requestService.compnySign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SIGN_TYPE", "COMPLETE");//法人客户当盖完章改为完成状态 - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - downloadDoc(tx); - return "success"; - } else { - Boolean flag = false; - String getMessage = resultMap.get("error"); - logger.info("契约锁反馈的异常信息" + getMessage); - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1 && !"error".equals(key)) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - if ("1".equals(sendProcess)) { - flag = true; - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - }else if("2".equals(sendProcess)){ - ldclBo.setAttributeValue("MESSAGE",getMessage ); - } - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - } - } - // 判断不同的异常反馈给前端 - if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { - getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); - return flag + "@" + getMessage; - } else if (getMessage.indexOf("contractId不能为空") != -1) { - return flag + "@" + getMessage; - } else { - return flag + "@" + "error"; - } - } - } catch (Exception e) { - tx.rollback(); - e.printStackTrace(); - logger.info("法人客户生成合同盖章失败" + e.getMessage()); - return "flase@error"; - } - } - - //获取电子签约人员列表 - public StringBuffer manyPeople() throws JBOException{ - //获取担保人信息 - StringBuffer info = new StringBuffer(); - 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){ - info.append(name+"@"+mobile+"@guarantee,"); - } - } - //获取共同申请人的信息 - 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){ - info.append(name+"@"+mobile+"@comm,"); - } - } - - return info; - } - - /** - * 法人租金委托代偿电子签约 - * @author tenwa518 - * @param tx - * @return - * @throws Exception - */ - @SuppressWarnings("unchecked") - public String companySignIng(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - Map> map = new HashMap>(); - ContractSignInfo con = null; - List bo = null; - BizObject ldclBo = null; - try { - BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); - // 查询lb_doc_contract_list表 - bo = contBom.createQuery("project_id=:projectId and file_flag='yes' and (sendprocess='0' or sendprocess='2' ) and doc_name='租金代偿函'").setParameter("projectId", ProjectId).getResultList(true); - for (BizObject keys : bo) { - String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); - List list = map.get(info); - if (list == null) { - list = new ArrayList(); - map.put(info, list); - } - con = new ContractSignInfo(); - con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); - con.setCustphone(keys.getAttribute("TELEPHONE").toString()); - con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(keys.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = keys.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - list.add(con); - } - - Map fromCondtion=new HashMap(); - MapotherProperty=new HashMap(); - Map resultMap = requestService.createComContractSign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1) { - fromCondtion.clear(); - otherProperty.clear(); - //契约锁合同号 - String contractId=resultMap.get("contract_" + key); - String sendProcess=resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - ldclBo.setAttributeValue("SENDPROCESS",sendProcess); - contBom.saveObject(ldclBo); - - String contractDocId =ldclBo .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("project_status","8");//状态改成电子签约,签署中 - pbm.saveObject(pbo); - //记录项目进程日志 - Transaction tran = Transaction.createTransaction(tx); - ASUser user = ASUser.getUser(CurUserID, tran); - JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) - .createQuery("UPDATE O SET BUSINESS_STATUS='8',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM "+LB_PROJECT_INFO.CLASS_NAME+" LPI WHERE LPI.ID='"+ProjectId+"')").executeUpdate(); - SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'8','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+ProjectId+"'"); - so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); - so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); - so.setRunSql(so.getRunSql().replaceAll("△", ":")); - tran.executeSQL(so); - return "success"; - } else { - Boolean falg=false; - String getMessage = resultMap.get("error"); - logger.info("契约锁反馈的异常信息" + getMessage); - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1 && !"error".equals(key)) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - if ("1".equals(sendProcess)) { - falg=true; - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - }else if ("2".equals(sendProcess)) { - ldclBo.setAttributeValue("MESSAGE", getMessage); - } - contBom.saveObject(ldclBo); - - String contractDocId=ldclBo.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); - } - } - // 判断不同的异常反馈给前端 - if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { - getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); - return getMessage; - } else if (getMessage.indexOf("contractId不能为空") != -1) { - return getMessage; - } else { - return "error"; - } - } - } catch (Exception e) { - tx.rollback(); - e.printStackTrace(); - return "error"; - } - - } - - /** - * (扣款卡变更)自然人委托扣款授权书电子签约,还有租金代偿函 - * @author tenwa518 - * @param tx - * @return - * @throws Exception - */ - public String PersonDeductSignIng(JBOTransaction tx) throws Exception{ - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - Map> map = new HashMap>(); - ContractSignInfo con = null; - List bo = null; - BizObject ldclBo = null; - try { - // 查询lb_doc_contract_list表 - bo = contBom.createQuery("flow_unid=:flow_unid and (sendprocess='0' or sendprocess='2' ) and file_flag='yes'").setParameter("flow_unid", FlowUnid).getResultList(true); - - for (BizObject keys : bo) { - String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); - List list = map.get(info); - if (list == null) { - list = new ArrayList(); - map.put(info, list); - } - con = new ContractSignInfo(); - con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); - con.setCustphone(keys.getAttribute("TELEPHONE").toString()); - con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(keys.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = keys.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - list.add(con); - } - - - Map fromCondtion=new HashMap(); - MapotherProperty=new HashMap(); - Map resultMap = null; - if ("01".equals(customerType)) { - resultMap = requestService.createComContractSign(map); - } else { - resultMap = requestService.createEntrustmentSign(map); - } - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - fromCondtion.clear(); - otherProperty.clear(); - //契约锁合同号 - String contractId=resultMap.get("contract_" + key); - String sendProcess=resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - ldclBo.setAttributeValue("SENDPROCESS",sendProcess); - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - } - } - - return "success"; - - } else { - Boolean flag = false; - String getMessage = resultMap.get("error"); - logger.info("契约锁反馈的异常信息" + getMessage); - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1 && !"error".equals(key)) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - if ("1".equals(sendProcess)) { - flag = true; - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - }else if("2".equals(sendProcess)){ - ldclBo.setAttributeValue("MESSAGE",getMessage ); - } - contBom.saveObject(ldclBo); - - - String contractDocId = ldclBo.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); - } - } - // 判断不同的异常反馈给前端 - if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { - getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); - return getMessage; - } else if (getMessage.indexOf("contractId不能为空") != -1) { - return getMessage; - } else { - return "error"; - } - } - } catch (Exception e) { - tx.rollback(); - e.printStackTrace(); - return "error"; - } - } - - /** - * 提前结清 申请书进行电子签约 - * - * @author - * @param - * @return - * @throws Exception - */ - public String AdjustFordSignIng(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - Map> map = new HashMap>(); - ContractSignInfo con = null; - List bo = null; - BizObject ldclBo = null; - try { - // 查询lb_doc_contract_list表 - bo = contBom.createQuery("flow_unid=:flow_unid and file_flag='yes'").setParameter("flow_unid", FlowUnid).getResultList(true); - for (BizObject keys : bo) { - String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); - List list = map.get(info); - if (list == null) { - list = new ArrayList(); - map.put(info, list); - } - con = new ContractSignInfo(); - con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); - con.setCustphone(keys.getAttribute("TELEPHONE").toString()); - con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(keys.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = keys.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - list.add(con); - } - Map fromCondtion = new HashMap(); - Map otherProperty = new HashMap(); - Map resultMap = null; - resultMap = requestService.createAdjustFordContractDSign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); -// ldclBo.setAttributeValue("PROCESS", "4"); - contBom.saveObject(ldclBo); - - String contractDocId = ldclBo.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); - } - } - return "success"; - } else { - Boolean flag = false; - String getMessage = resultMap.get("error"); - logger.info("契约锁反馈的异常信息" + getMessage); - for (String key : resultMap.keySet()) { - // 存储契约锁返回的合同id和合同文件id - if (key.indexOf("contract_") == -1 && !"error".equals(key)) { - fromCondtion.clear(); - otherProperty.clear(); - // 契约锁合同号 - String contractId = resultMap.get("contract_" + key); - String sendProcess = resultMap.get("contract_" + contractId); - ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); - ldclBo.setAttributeValue("SENDPROCESS", sendProcess); - if ("1".equals(sendProcess)) { - flag = true; - ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); - } else if ("2".equals(sendProcess)) { - ldclBo.setAttributeValue("MESSAGE", getMessage); - } - contBom.saveObject(ldclBo); - String contractDocId = ldclBo.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); - } - } - // 判断不同的异常反馈给前端 - if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { - getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); - return getMessage; - } else if (getMessage.indexOf("contractId不能为空") != -1) { - return getMessage; - } else { - return "error"; - } - } - } catch (Exception e) { - tx.rollback(); - e.printStackTrace(); - return "error"; - } - - } -/** - * 提前结清查询签约状态 - * @param tx - * @return - * @throws Exception - */ - public String getAdjustFordSignStatus(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); - List ldclBoList = ldclBom.createQuery("flow_unid='" + FlowUnid + "' and file_flag='yes' and " - + "sendprocess='1'").getResultList(true); - String signContractId = ""; - String customerName = ""; - String contractDocId = ""; - StringBuffer result = new StringBuffer(); - Map fromCondtion = new HashMap(); - Map otherProperty = new HashMap(); - for (BizObject key : ldclBoList) { - signContractId = key.getAttribute("singcontract_id").toString(); - customerName = key.getAttribute("customername").toString(); - contractDocId = key.getAttribute("id").toString(); - try { - String signType = requestService.getContractSignStatus(signContractId); - String signstatus = clBom.createQuery("itemno='" + signType + "'").getSingleResult(false).getAttribute("itemname").toString(); - key.setAttributeValue("sign_type", signType); - if("COMPLETE".equals(signType)){ - key.setAttributeValue("PROCESS", "5.1"); - } - ldclBom.saveObject(key); - result.append("," + customerName + "电子签约状态:" + signstatus); - //日志记录 - - fromCondtion.put("ID", contractDocId); - otherProperty.put("SIGNPROCESS", "1");// 查询状态 - 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); - } catch (Exception e) { - fromCondtion.put("ID", contractDocId); - otherProperty.put("SIGNPROCESS", "1");// 查询状态 - otherProperty.put("CONTRACTDOCID", contractDocId); - otherProperty.put("MESSAGE", e.getMessage()); - otherProperty.put("INPUTTIME", DateAssistant.getTodayNow()); - DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion, LB_CONTRACT_SIGN_LOG.CLASS_NAME, null, - otherProperty, tx); - return "error"+"@"+e.getMessage(); - } - - } - return result.toString().substring(1); - } - - /** - * (扣款卡变更)自然人委托扣款授权书获取电子签约状态 ,法人租金代偿 - * - * @throws Exception - */ - public String contractSignStatusForContract(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); - List ldclBoList = ldclBom.createQuery("flow_unid='" + FlowUnid + "' and file_flag='yes' and " - + "sendprocess='1'").getResultList(true); - String signContractId = ""; - String customerName = ""; - String contractDocId = ""; - StringBuffer result = new StringBuffer(); - Map fromCondtion = new HashMap(); - Map otherProperty = new HashMap(); - for (BizObject key : ldclBoList) { - signContractId = key.getAttribute("singcontract_id").toString(); - customerName = key.getAttribute("customername").toString(); - contractDocId = key.getAttribute("id").toString(); - try { - String signType = requestService.getContractSignStatus(signContractId); - String signstatus = clBom.createQuery("itemno='" + signType + "'").getSingleResult(false).getAttribute("itemname").toString(); - key.setAttributeValue("sign_type", signType); - if("COMPLETE".equals(signType)){ - key.setAttributeValue("PROCESS", "5.1"); - } - ldclBom.saveObject(key); - result.append("," + customerName + "电子签约状态:" + signstatus); - //日志记录 - - fromCondtion.put("ID", contractDocId); - otherProperty.put("SIGNPROCESS", "1");// 查询状态 - 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); - } catch (Exception e) { - fromCondtion.put("ID", contractDocId); - otherProperty.put("SIGNPROCESS", "1");// 查询状态 - otherProperty.put("CONTRACTDOCID", contractDocId); - otherProperty.put("MESSAGE", e.getMessage()); - otherProperty.put("INPUTTIME", DateAssistant.getTodayNow()); - DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion, LB_CONTRACT_SIGN_LOG.CLASS_NAME, null, - otherProperty, tx); - return "error"+"@"+e.getMessage(); - } - - } - return result.toString().substring(1); - } - - /** - * 获取电子签约状态 - * - * @throws Exception - */ - public String contractSignStatus(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); - BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); - BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObjectManager ldBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); - BizObject pbo = pbm.createQuery("FLOWUNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(true); - String status = ""; - String peopleStatus=""; - String sql = ""; - if ("01".equals(customerType)) { - sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函' and sendprocess='1'"; - } else { - sql = "project_id=:projectId and file_flag='yes' and sendprocess='1'"; - } - @SuppressWarnings("unchecked") - List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); - if (bo != null) { - boolean flag = true; - Map map = new HashMap(); - for (BizObject keys : bo) { - map.put(keys.getAttribute("singcontract_id").toString(), keys.getAttribute("customername").toString()); - } - for (String key : map.keySet()) { - try { - String signStatu = requestService.getContractSignStatus(key); - int index = signStatu.indexOf("$"); - String signStatus = signStatu.substring(0, index); - peopleStatus = signStatu.substring(index+1); - String signStatusName = - clBom.createQuery("itemno='" + signStatus + "'").getSingleResult(false).getAttribute("itemname").toString(); - List ldclList = - contBom.createQuery("project_id=:projectId and file_flag='yes' and singcontract_id='" + key + "'") - .setParameter("projectId", ProjectId).getResultList(true); - for (BizObject keys : ldclList) { - keys.setAttributeValue("SIGN_TYPE", signStatus); - // 客户签署完成,合同制作过程为4 - if ("REQUIRED".equals(signStatus)) { - this.sign(tx); - downloadDoc(tx); - keys.setAttributeValue("PROCESS", "4"); - } - contBom.saveObject(keys); - } - if (!"REQUIRED".equals(signStatus) && !"COMPLETE".equals(signStatus) ) { - flag = false; - } - if ("REQUIRED".equals(signStatus)) { - status += ";
客户" + map.get(key) + "签约状态:已签名"; - } else { - status += ";
客户" + map.get(key) + "签约状态:" + signStatusName; - } - } catch (Exception e) { - e.printStackTrace(); - return "获取签约状态失败!"; - } - } - // 合同签约已完成 - if (flag) { - pbo.setAttributeValue("DATA_STATE", "4");// 状态改成已完成电子签约 - pbm.saveObject(pbo); - // 记录项目进程日志 - /* Transaction tran = Transaction.createTransaction(tx); - ASUser user = ASUser.getUser(CurUserID, tran); - JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME, tx) - .createQuery("UPDATE O SET BUSINESS_STATUS='4',UPDATEUSERID='" + user.getUserID() + "',UPDATEORGID='" - + user.getOrgID() + "',UPDATETIME='" + StringFunction.getTodayNow() - + "' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM " + LB_PROJECT_INFO.CLASS_NAME - + " LPI WHERE LPI.ID='" + ProjectId + "')") - .executeUpdate(); - SqlObject so = new SqlObject( - "INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'4','" - + user.getUserID() + "','" + user.getOrgID() + "','" + StringFunction.getTodayNow().replaceAll(":", "△") - + "' FROM LB_PROJECT_INFO WHERE ID='" + ProjectId + "'"); - so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); - so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); - so.setRunSql(so.getRunSql().replaceAll("△", ":")); - tran.executeSQL(so);*/ - for (BizObject keys : bo) { - /* ldBom.createQuery("update O set status='' where id='" + keys.getAttribute("attribute_id").toString() + "'") - .executeUpdate();*/ - } - status = ";
已经完成电子签约"; - } - } - if (status.length() < 1) { - return "获取签约状态失败,没有合同文件"; - } else { - status = status.substring(5); - String[] peopleStat = peopleStatus.split(","); - if(peopleStat.length>1){ - status = status+"
"; - for(int i=0;i map = new HashMap(); - - map.put(ldb.getAttribute("TEMPLATE_ID").toString(),lul.getAttribute("CUSTOMER_NAME").toString()); - - for (String key : map.keySet()) { - try { - String signStatu = requestService.getContractSignStatus(key); - int index = signStatu.indexOf("$"); - String signStatus = signStatu.substring(0, index); - peopleStatus = signStatu.substring(index+1); - String signStatusName = - clBom.createQuery("itemno='" + signStatus + "'").getSingleResult(false).getAttribute("itemname").toString(); - BizObject ldl = ldlMange.createQuery("RELATIVE_ID=:relativeid").setParameter("relativeid", ldb.getAttribute("ID").getString()).getSingleResult(false); - lda = ldaMange.createQuery("LIBRARY_ID=:libraryid").setParameter("libraryid", ldl.getAttribute("ID").getString()).getSingleResult(true); - if (signStatu.indexOf("已签署")>0) { - signStatus = "REQUIRED"; - }else{ - flag = false; - } - if ("REQUIRED".equals(signStatus)) { - status += ";
客户" + map.get(key) + "签约状态:已签名"; - } else { - status += ";
客户" + map.get(key) + "签约状态:" + signStatusName; - } - } catch (Exception e) { - e.printStackTrace(); - return "获取签约状态失败!"; - } - } - // 合同签约已完成 - if (flag) { - lda.setAttributeValue("REMARK", "COMPLETE");// 状态改成已完成电子签约 - BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); - if(ldcl != null){ - ldcl.setAttributeValue("sign_type", "COMPLETE"); - ldclManage.saveObject(ldcl); - } - ldaMange.saveObject(lda); - status = ";
已经完成电子签约"; - changedownloadDoc(tx); - } - } - - if (status.length() < 1) { - return "获取签约状态失败,没有合同文件"; - } else { - status = status.substring(5); - String[] peopleStat = peopleStatus.split(","); - if(peopleStat.length>1){ - status = status+"
"; - for(int i=0;i contractIds = new ArrayList(); - if ("01".equals(customerType)) { - sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函' and sendprocess='1'"; - } else { - sql = "project_id=:projectId and file_flag='yes' and sendprocess='1'"; - } - @SuppressWarnings("unchecked") - List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); - if (bo != null) { - boolean flag = true; - Map map = new HashMap(); - for (BizObject keys : bo) { - map.put(keys.getAttribute("singcontract_id").toString(), keys.getAttribute("customername").toString()); - contractIds.add(keys.getAttribute("singcontract_id").toString()); - } - - Map resultMap = requestService.getContractSignListStatus(contractIds); - } - return ""; - } - - /** - * 盖企业章 - * - * @param tx - * @return - * @throws MalformedURLException - * @throws Exception - */ - public String sign(JBOTransaction tx) throws MalformedURLException, Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - @SuppressWarnings("unchecked") - List bo = contBom.createQuery("project_id=:projectId and file_flag='yes'") - .setParameter("projectId", ProjectId).getResultList(true); - if (bo != null) { - Map> map = new HashMap>(); - for (BizObject keys : bo) { - List list = map.get(keys.getAttribute("singcontract_id").toString()); - if (list == null) { - list = new ArrayList(); - } - list.add(keys.getAttribute("DOCUMENT_ID").toString()+"@"+keys.getAttribute("doc_name").toString()); - map.put(keys.getAttribute("singcontract_id").toString(), list); - } - Map resultMap = requestService.Sign(map); - String statu = resultMap.get("error"); - if (statu == null) { - return "success"; - } - } - - return "error"; - } - - /** - * 根据document_id下载合同 - * - * @param tx - * @return - * @throws Exception - * @throws MalformedURLException - */ - public String downloadDoc(JBOTransaction tx) throws MalformedURLException, Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - String sql = ""; - if ("01".equals(customerType)) { - sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函'"; - } else { - sql = "project_id=:projectId and file_flag='yes'"; - } - try { - - @SuppressWarnings("unchecked") - List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); - if (bo != null) { - Map map = new HashMap(); - for (BizObject keys : bo) { - map.put(keys.getAttribute("DOCUMENT_ID").toString(), keys.getAttribute("FULLPATH").toString()); - } - Map result = requestService.downloadDoc(map); - if (!result.containsKey("error")) { - for (String contractId : map.keySet()) { - try { - if ("success".equals(result.get(contractId))) { - String fileString = result.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - return "success"; - } else { - return "error"; - } - } - } catch (Exception e) { - return "error"; - } - return "success"; - } - - /** - * 扣款卡信息变更根据document_id下载合同 - * - * @param tx - * @return - * @throws Exception - * @throws MalformedURLException - */ - public String changedownloadDoc(JBOTransaction tx) throws MalformedURLException, Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager ldMange = JBOFactory.getBizObjectManager(LB_DOCRELATIVE.CLASS_NAME, tx); - String sql = "OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid "; - @SuppressWarnings("unchecked") - BizObject ldb = ldMange.createQuery(sql).setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); - BizObjectManager clBom = JBOFactory.getBizObjectManager(LB_DOCLIBRARY.CLASS_NAME, tx); - try { - if (ldb != null) { - BizObject ldl = clBom.createQuery("RELATIVE_ID=:relativeid").setParameter("relativeid", ldb.getAttribute("ID").getString()).getSingleResult(false); - BizObjectManager ldaMange = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - BizObject lda = ldaMange.createQuery("LIBRARY_ID=:libraryid").setParameter("libraryid", ldl.getAttribute("ID").getString()).getSingleResult(false); - Map map = new HashMap(); - map.put(ldl.getAttribute("REMARK").toString(), lda.getAttribute("FULLPATH").toString()); - Map result = requestService.downloadDoc(map); - if (!result.containsKey("error")) { - for (String contractId : map.keySet()) { - try { - if ("success".equals(result.get(contractId))) { - String fileString = result.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - return "success"; - } else { - return "error"; - } - } - } catch (Exception e) { - return "error"; - } - return "success"; - } - -//扣款卡变更下载合同 - public String downloadDocContract(JBOTransaction tx) throws MalformedURLException, Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - String sql = ""; - sql = "flow_unid=:flow_unid and file_flag='yes'"; - String attributeId = ""; - try { - @SuppressWarnings("unchecked") - List bo = contBom.createQuery(sql).setParameter("flow_unid", FlowUnid).getResultList(true); - if (bo != null) { - Map map = new HashMap(); - for (BizObject keys : bo) { - map.put(keys.getAttribute("DOCUMENT_ID").toString(), keys.getAttribute("FULLPATH").toString()); - attributeId = keys.getAttribute("ATTRIBUTE_ID").toString(); - } - Map result = requestService.downloadDoc(map); - - if (!result.containsKey("error")) { - for (String contractId : map.keySet()) { - try { - if ("success".equals(result.get(contractId))) { - String fileString = result.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result.get(contractId))) { - return "error@"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - return "success@" + attributeId; - } else { - return "error@"; - } - } else { - System.out.println("没有文件可下载"); - return "error@"; - } - } catch (Exception e) { - e.printStackTrace(); - return "error@"; - } - } - -/** - * 扣款卡变更下载zip合同 - * @param tx - * @return - * @throws Exception - * @throws MalformedURLException - */ -public String downloadZipContract(JBOTransaction tx) throws MalformedURLException, Exception{ - requestService = (HttpRequestAppService) factory.create( - HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - try{ - String path=null; - @SuppressWarnings("unchecked") - String sql=""; - sql="flow_unid=:flow_unid and file_flag='yes'"; - @SuppressWarnings("unchecked") - List bo = contBom.createQuery(sql).setParameter("flow_unid",FlowUnid).getResultList(true); - - if(bo!=null){ - Map map=new HashMap(); - for(BizObject keys:bo){ - path="D://"+keys.getAttribute("singcontract_id").toString()+"DocList.zip"; - map.put(keys.getAttribute("singcontract_id").toString(),path); - } - String result=requestService.download(map); - if(result.equals("success")){ - return "success"; - }else{ - return "error"; - } - } - }catch(Exception e){ - return "error"; - } - return "success"; -} - - -/** - * 根据contract_id下载合同 - * @param tx - * @return - * @throws Exception - * @throws MalformedURLException - */ -public String download(JBOTransaction tx) throws MalformedURLException, Exception{ - requestService = (HttpRequestAppService) factory.create( - HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - try{ - String path=null; - @SuppressWarnings("unchecked") - List bo = contBom.createQuery("project_id=:projectId and file_flag='yes'").setParameter("projectId",ProjectId).getResultList(true); - if(bo!=null){ - Map map=new HashMap(); - for(BizObject keys:bo){ - path="D://"+keys.getAttribute("singcontract_id").toString()+"DocList.zip"; - map.put(keys.getAttribute("singcontract_id").toString(),path); - } - String result=requestService.download(map); - if(result.equals("success")){ - return "success"; - }else{ - return "error"; - } - } - }catch(Exception e){ - return "error"; - } - return "success"; -} - -/** - *jar包方式word转换pdf - *用jar方法 - *word转换pdf - */ -public void wordToPdfJar(JBOTransaction tx){ - try { - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - String sql=""; - if(flagType==null || "word".equals(flagType)){ - sql="project_id='"+ProjectId+"' and file_flag='yes' and process='1'"; - }else if("contract".equals(flagType)){ - sql="contract_id='"+contract_id+"' and file_flag='yes' and process='1'"; - }else if("pdfFalse".equals(flagType)){ - sql="project_id='"+ProjectId+"' and file_flag='yes' and process='3'"; - }else if ("flowunid".equals(flagType)){ - sql = "flow_unid='"+FlowUnid+"' and file_flag='yes' and process='1'"; - } - List bo = contBom.createQuery(sql).getResultList(false); - if(bo!=null){ - for(BizObject key:bo){ - String lastFilePath= key.getAttribute("FULLPATH").toString().replace(".docx", ".pdf"); - try { - WordToPdfThread wtpt = new WordToPdfThread(key.getAttribute("FULLPATH").toString(),lastFilePath,key.getAttribute("ATTRIBUTE_ID").toString()); - wtpt.start(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } catch (JBOException e) { - e.printStackTrace(); - - } -} -/** - * LibreOffice实现word转换pdf - * word转换pdf - * @throws JBOException - */ - @SuppressWarnings({ "unchecked", "static-access" }) - public void wordToPdf(JBOTransaction tx) throws JBOException { - try { - BizObjectManager fbo = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME, tx); - BizObject fbos = fbo.createQuery("FLOW_UNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(false); - //获取用户信息 - BizObjectManager lult = JBOFactory.getBizObjectManager(LB_UNION_LESSEE_TEMP.CLASS_NAME); - BizObjectManager customer = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME); - BizObject lults = lult.createQuery("flowunid=:flowUnid").setParameter("flowUnid", FlowUnid).getSingleResult(false); - BizObject cust = customer.createQuery("flowunid=:flowUnid and customerid=:customerid").setParameter("flowUnid", FlowUnid).setParameter("customerid", lults.getAttribute("customer_id").toString()).getSingleResult(false); - String customername = null; - String telephone = null; - String ids =null; - - if(cust!=null){ - customername = cust.getAttribute("FULLNAME").toString(); - telephone = cust.getAttribute("mobile").toString(); - ids = cust.getAttribute("CUSTOMERID").toString(); - } - - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObjectManager attrBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - WordToPDFUtil wordTopdf = new WordToPDFUtil(); - File file = null; - Boolean result = null; - String sql = ""; - /*if (flagType == null || "word".equals(flagType)) { - sql = "project_id='" + ProjectId + "' and file_flag='yes' and process='1'"; - } else if ("contract".equals(flagType)) { - sql = "contract_id='" + contract_id + "' and file_flag='yes' and process='1'"; - } else if ("pdfFalse".equals(flagType)) { - sql = "project_id='" + ProjectId + "' and file_flag='yes' and process='3'"; - } else if ("flowunid".equals(flagType)){ - sql = "flow_unid='"+FlowUnid+"' and file_flag='yes' and (process='1' or process='3')"; - }*/ - List bo = contBom.createQuery("flow_unid=:flowUnid and file_flag='yes' and process='1'").setParameter("flowUnid", FlowUnid).getResultList(true); - if (bo != null) { - for (BizObject contBo : bo) { - String attrId = contBo.getAttribute("ATTRIBUTE_ID").toString(); - BizObject attrBo = attrBom.createQuery("id='" +attrId+"'").getSingleResult(true); - String path = attrBo.getAttribute("FULLPATH").toString(); - String lastFilePath = path.replace(".docx", ".pdf"); - File filePath = new File(path); - if(!filePath.exists()){ - logger.info("word转换pdf的源文件不存在"); - continue; - } - String lastFilePathpdf = filePath.getParent(); - try { - result = wordTopdf.Word2Pdf(path, lastFilePathpdf); - } catch (Exception e) { - result = false; - e.printStackTrace(); - } - if (result) { - file =new File(lastFilePath); - contBo.setAttributeValue("FULLPATH",lastFilePath); - contBo.setAttributeValue("FILENAME",contBo.getAttribute("FILENAME").toString().replace(".docx",".pdf" )); - contBo.setAttributeValue("FILEPATH",contBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); - contBo.setAttributeValue("CONTENT_TYPE","application/pdf"); - contBo.setAttributeValue("PROCESS","2"); - contBo.setAttributeValue("PROJECT_ID",fbos.getAttribute("proj_id").toString()); - contBo.setAttributeValue("CUSTOMERNAME",customername); - contBo.setAttributeValue("TELEPHONE",telephone); - contBo.setAttributeValue("IDS",ids); - contBom.saveObject(contBo); - attrBo.setAttributeValue("FULLPATH",attrBo.getAttribute("FULLPATH").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FILENAME",attrBo.getAttribute("FILENAME").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FILEPATH",attrBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FileSize",file.length()); - attrBo.setAttributeValue("CONTENT_TYPE","application/pdf"); - attrBom.saveObject(attrBo); - }else{ - contBo.setAttributeValue("PROCESS","3"); - contBom.saveObject(contBo); - } - } - } - } catch (JBOException e) { - e.printStackTrace(); - } - } - - /** - * 租金通知书附件用LibreOffice实现word转换pdf - * word转换pdf - * @throws JBOException - */ - @SuppressWarnings({ "unchecked", "static-access" }) - public String wordToPdfAnnex(JBOTransaction tx) throws JBOException { - - PLAN_LIST=PLAN_LIST.split("\\.")[0]; - BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); - BizObject DOCRELATIVE = null; - if("null".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - }else if("rights".equals(PLAN_LIST)){ - DOCRELATIVE = bom.createQuery("CONTRACT_ID=:CONTRACT_ID and objecttype='rights'").setParameter("CONTRACT_ID",contract_id).getSingleResult(false); - }else if("settle".equals(PLAN_LIST)){ - DOCRELATIVE = bom.createQuery("CONTRACT_ID=:CONTRACT_ID and objecttype='settle'").setParameter("CONTRACT_ID",contract_id).getSingleResult(false); - }else if("TX".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype='AdjustInterst' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - }else if("ChangeCar".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("transfer".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='transfer' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("AdjustmentNotice".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='AdjustmentNotice' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("TriditionCollection".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionCollection' and plan_number=:plan_number").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - }else if("TriditionSuspension".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionSuspension' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); - }else if("settletradition".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='settletradition' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); - }else if("LetterApprova".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LetterApprova' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); - }else if("LoanNotice".equals(PLAN_LIST)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LoanNotice' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); - } - else{ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number and plan_list=:plan_list").setParameter("plan_number",PAYMENT_NUMBER).setParameter("plan_list", PLAN_LIST).getSingleResult(false); - } - - BizObjectManager attrBom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCATTRIBUTE.CLASS_NAME); - BizObject attrBo=null; - WordToPDFUtil wordTopdf = new WordToPDFUtil(); - File file = null; - Boolean result = null; - String sql = ""; - try { - if (DOCRELATIVE != null) { - - String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); - BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); - String DOCLIBRARYid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); - attrBo = attrBom.createQuery("library_id=:library_id").setParameter("library_id", DOCLIBRARYid).getSingleResult(true); - - String path = attrBo.getAttribute("FULLPATH").toString(); - String lastFilePath = path.replace(".docx", ".pdf"); - File filePath = new File(path); - if(!filePath.exists()){ - logger.info("word转换pdf的源文件不存在"); - } - String lastFilePathpdf = filePath.getParent(); - try { - result = wordTopdf.Word2Pdf(path, lastFilePathpdf); - } catch (Exception e) { - result = false; - e.printStackTrace(); - } - if (result) { - file =new File(lastFilePath); - attrBo.setAttributeValue("FULLPATH",attrBo.getAttribute("FULLPATH").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FILENAME",attrBo.getAttribute("FILENAME").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FILEPATH",attrBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); - attrBo.setAttributeValue("FileSize",file.length()); - attrBo.setAttributeValue("CONTENT_TYPE","application/pdf"); - attrBom.saveObject(attrBo); - }else{ - } - if("ChangeCar".equals(PLAN_LIST)){ - BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); - file =new File(lastFilePath); - ldcl.setAttributeValue("FULLPATH",lastFilePath); - ldcl.setAttributeValue("FILENAME",ldcl.getAttribute("FILENAME").toString().replace(".docx",".pdf" )); - ldcl.setAttributeValue("FILEPATH",ldcl.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); - ldcl.setAttributeValue("CONTENT_TYPE","application/pdf"); - ldcl.setAttributeValue("PROCESS","2"); - ldclManage.saveObject(ldcl); - } - } - - } catch (JBOException e) { - e.printStackTrace(); - } - return attrBo.getAttribute("ID").toString(); - } - /** - * 多线程word转换pdf - * @author tenwa518 - * - */ -class WordToPdfThread extends Thread{ - final String fullPath; - final String lastFilePath; - final String attrId; - public WordToPdfThread(String fullPath,String lastFilePath,String attrId){ - this.fullPath = fullPath; - this.lastFilePath = lastFilePath; - this.attrId = attrId; - - } - @Override - public void run() { - Word2PdfUtil wP = new Word2PdfUtil(); -// WordToPDFUtil w2P = new WordToPDFUtil(); - try { -// w2P.Word2Pdf(fullPath, lastFilePathpdf); - wP.doc2pdf(fullPath,lastFilePath,attrId); - } catch (Exception e) { - e.printStackTrace(); - } - } -} -/** - * 查看word文件是否都转为pdf - * @param tx - * @return - * @throws JBOException - */ -public String getMakeContractProcess(JBOTransaction tx) throws JBOException{ - BizObjectManager ldclBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - int wordIng=0; - int pdfFalse=0; - int pdfTrue=0; - List ldclBo2=ldclBom.createQuery("project_id='"+ProjectId+"' and file_flag='yes' ").getResultList(false); - if(ldclBo2.size()>0){ - for(BizObject key:ldclBo2){ - String process = key.getAttribute("process").toString(); - if("1".equals(process)){ - wordIng++; -// return "error"; - }else if("2".equals(process)){ - pdfTrue++; -// return "wording"; - }else if("3".equals(process)){ - pdfFalse++; -// return "success"; - } - } - }else{ - //制作合同 - return "0"; - } - if(wordIng>0 && pdfFalse>0 && pdfTrue>0){ - //word转换PDF部分失败 - return "1"; - }else if(wordIng==0 && pdfFalse>0 && pdfTrue>0){ - //word转PDF失败 - return "2"; - }else if(wordIng==0 && pdfFalse>0 && pdfTrue>0){ - //word转换PDF部分失败, - return "3"; - }else if(wordIng>0 && pdfFalse==0 && pdfTrue>0){ - //word正在转换pdf - return "4"; - }else if(wordIng>0 && pdfFalse==0 && pdfTrue==0){ - //word没有转换pdf - return "5"; - }else if(wordIng==0 && pdfFalse==0 && pdfTrue>0){ - //word转换PDF成功 - return "6"; - } - return "error"; -} -//(扣款卡变更)根据合同号获取文件状态 -public String getMakeContractProcessContract(JBOTransaction tx) throws JBOException{ - BizObjectManager ldclBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - BizObject ldclBo = null; - ldclBo=ldclBom.createQuery("flow_unid='"+FlowUnid+"'and file_flag='yes' ").getSingleResult(false); - if(ldclBo!=null){ - String process = ldclBo.getAttribute("process").toString(); - String signType = ldclBo.getAttribute("sign_type").toString(); - if("1".equals(process)){ - return "isDoc"; - }else if("2".equals(process)&&"DRAFT".equals(signType)){ - return "isPdf"; - }else if("COMPLETE".equals(signType)){ - return "complete"; - }else if("SIGNING".equals(signType)){ - return "isSigning"; - } - } - //表示不存在这个文件 - return "notExsit"; -} -/** - * 转账授权申请书 - * @param tx - * @return - * @throws InterruptedException - */ -@SuppressWarnings("unchecked") -public String AccountAccreditSign(JBOTransaction tx){ - try{ - this.wordToPdf(tx); - tx.commit(); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - List boList = contBom.createQuery("file_flag='yes' and (process='2' or process='5') and flow_unid='"+FlowUnid+"'").getResultList(true); - if(boList.size()>0){ - try { - String result =this.accountSign(tx,FlowUnid,InputOrgid); - if("success".equals(result)){ - return "success"; - }else{ - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - }else{ - return "error"; - } - } catch (JBOException e) { - e.printStackTrace(); - return "error"; - } -} -public String accountSign(JBOTransaction tx,String flowunid,String orgid) throws Exception{ - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObjectManager attrBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); - Map map=new HashMap(); - ContractSignInfo con=null; - BizObject ldclBo=null; - try{ - //查询lb_doc_contract_list表 - ldclBo = ldclBom.createQuery("file_flag='yes' and process='2' and flow_unid='" + flowunid + "'").getSingleResult(true); - if (ldclBo != null) { - con = new ContractSignInfo(); - con.setFileid(ldclBo.getAttribute("ATTRIBUTE_ID").toString()); - con.setFilename(ldclBo.getAttribute("FILENAME").toString()); - // 获取生成文件路径 - String makefullPath = ldclBo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(flowunid, con); - Map resultMap = null; - if (orgid.indexOf("8002003001") >= 0) { - // 西城转账授权 - resultMap = requestService.createAccountContractSign(map); - } else { - // 东城转账授权 - resultMap = requestService.createAccountContractDSign(map); - } - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - ldclBo.setAttributeValue("SINGCONTRACT_ID", resultMap.get("contract_" + key)); - } - } - ldclBo.setAttributeValue("PROCESS", "5"); - ldclBom.saveObject(ldclBo); - tx.commit(); - } else { - return "error"; - } - } - //拉取文件 - ldclBo = ldclBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + flowunid + "'").getSingleResult(true); - if (ldclBo != null) { - BizObject attrBo = attrBom.createQuery("id='"+ldclBo.getAttribute("attribute_id")+"'").getSingleResult(true); - Map mapFile = new HashMap(); - String fileName = ldclBo.getAttribute("FILENAME").toString(); - String fullPath =FileOperatorUtil.getuploadFileDir(this.getFileSavePath())+UUIDUtil.getUUID()+"_"+fileName; - String filePath = fullPath.replaceAll(this.getFileSavePath(),""); - mapFile.put(ldclBo.getAttribute("DOCUMENT_ID").toString(),fullPath); - Map result = requestService.downloadDoc(mapFile); - if (!result.containsKey("error")) { - for (String documentId : mapFile.keySet()) { - try { - if ("success".equals(result.get(documentId))) { - String fileString = result.get("file_" + documentId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(mapFile.get(documentId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result.get(documentId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - ldclBo.setAttributeValue("FILEPATH",filePath); - ldclBo.setAttributeValue("FULLPATH",fullPath); - ldclBo.setAttributeValue("PROCESS", "6"); - ldclBom.saveObject(ldclBo); - attrBo.setAttributeValue("FILEPATH",filePath); - attrBo.setAttributeValue("FULLPATH",fullPath); - attrBo.setAttributeValue("FileSize",new File(fullPath).length()); - attrBom.saveObject(attrBo); - return "success"; - } else { - return "error"; - } - } else { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - -} -public String getFlowUnid(JBOTransaction tx) throws JBOException{ - BizObjectManager fboBom=JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME,tx); - BizObject fboBo=fboBom.createQuery("CHANNELAPPLYID='"+id+"'").getSingleResult(false); - return fboBo.getAttribute("flow_unid").toString(); -} - -/* - * 重新发送短信 - * */ -public String sendMessageAgain(JBOTransaction tx) { - try{ - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - List bo = null; - String file = new String(); - Map contractmap = new HashMap(); - List list = new ArrayList(); - 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).getResultList(true); - for (BizObject temp : bo) { - String singcontractid = temp.getAttribute("singcontract_id").toString(); - String filename = temp.getAttribute("filename").toString(); - contractmap.put(singcontractid, filename); - } - list.addAll(contractmap.keySet()); - Map map = requestService.sendNotice(list); - if(!map.containsKey("error")){ - return "success"; - }else{ - for(String singcontractid:map.keySet()){ - String sendStatus = map.get(singcontractid); - if("2"==sendStatus){ - file += contractmap.get(singcontractid)+";"; - } - } - return file; - } - - } catch (Exception e) { - try { - tx.rollback(); - } catch (JBOException e1) { - e1.printStackTrace(); - } - e.printStackTrace(); - return "error"; - } -} - - /* - * 扣款卡信息变更重新发送短信 - * */ - public String ChangesendMessageAgain(JBOTransaction tx) { - try{ - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - List bo = null; - String file = new String(); - Map contractmap = new HashMap(); - List list = new ArrayList(); - BizObjectManager ldMange = JBOFactory.getBizObjectManager(LB_DOCRELATIVE.CLASS_NAME, tx); - String status = ""; - String peopleStatus=""; - String sql = "OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid "; - @SuppressWarnings("unchecked") - BizObject ldb = ldMange.createQuery(sql).setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); - if(ldb!=null){ - String singcontractid = ldb.getAttribute("TEMPLATE_ID").toString(); - contractmap.put(singcontractid, "直租个人授权协议书.pdf"); - } - list.addAll(contractmap.keySet()); - Map map = requestService.sendNotice(list); - if(!map.containsKey("error")){ - return "success"; - }else{ - for(String singcontractid:map.keySet()){ - String sendStatus = map.get(singcontractid); - if("2"==sendStatus){ - file += contractmap.get(singcontractid)+";"; - } - } - return file; - } - - } catch (Exception e) { - try { - tx.rollback(); - } catch (JBOException e1) { - e1.printStackTrace(); - } - e.printStackTrace(); - return "error"; - } - } - -public String getProcess(JBOTransaction tx){ - try { - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObject bo = contBom.createQuery("file_flag='yes' and process is not null and flow_unid='"+FlowUnid+"'").getSingleResult(false); - if(bo==null){ - return "success"; - }else{ - return bo.getAttribute("PROCESS").toString(); - } - } catch (JBOException e) { - e.printStackTrace(); - return "error"; - } - -} - -public String claimSign(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); - ContractSignInfo con = null; - BizObject bo = null; - String doc_name = new String(); - String[] attrIdList=attrId.split("@"); - try{ - for(String attribute_id:attrIdList){ - Map map=new HashMap(); - bo = contBom.createQuery("file_flag='yes' and process='2' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); - if(bo != null){ - con = new ContractSignInfo(); - con.setFileid(attribute_id); - con.setFilename(bo.getAttribute("FILENAME").toString()); - String makefullPath = bo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(FlowUnid, con); - Map resultMap = null; - //调代理的接口 - doc_name = bo.getAttribute("doc_name").toString(); - if("租金支付表".equals(doc_name)){ - //租金支付表 - resultMap = requestService.createPaymentofHireSign(map); - } - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - bo.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); - bo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - } - } - bo.setAttributeValue("PROCESS", "5"); - contBom.saveObject(bo); - tx.commit(); - } else { - return "error"; - } - } - bo = contBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); - if (bo != null) { - Map map1 = new HashMap(); - map1.put(bo.getAttribute("DOCUMENT_ID").toString(), bo.getAttribute("FULLPATH").toString()); - Map result1 = requestService.downloadDoc(map1); - if (!result1.containsKey("error")) { - for (String contractId : map1.keySet()) { - try { - if ("success".equals(result1.get(contractId))) { - String fileString = result1.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result1.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - bo.setAttributeValue("PROCESS", "6"); - contBom.saveObject(bo); - } else { - return "error"; - } - } else { - return "error"; - } - } - return "success"; - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } -} - - /** - * 打印租金通知书并发短信给客户 - * @param tx - * @return - * @throws Exception - */ - public String claimSignA(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - String libraryid=""; - PLAN_LIST=PLAN_LIST.split("\\.")[0]; - BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); - BizObject DOCRELATIVE=bom.createQuery("plan_number=:plan_number and plan_list=:plan_list").setParameter("plan_number",PAYMENT_NUMBER).setParameter("plan_list", PLAN_LIST).getSingleResult(false); - if (DOCRELATIVE != null) { - String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); - BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); - libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); - } - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - ContractSignInfo con = null; - BizObject bo = null; -// String contract_id=""; - String info=""; - try{ - //获取承租人的姓名和电话号 - BizObjectManager lulManager = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME, tx); - String customerid = lulManager.createQuery("CONTRACT_ID=:contractId").setParameter("contractId", contract_id).getSingleResult(false).getAttribute("CUSTOMER_ID").toString(); - BizObjectManager crManage = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); - BizObject cr = crManage.createQuery("CUSTOMERID=:customerid").setParameter("customerid", customerid).getSingleResult(false); - if(cr != null){ - info = cr.getAttribute("FULLNAME").toString() + "@" + cr.getAttribute("mobile").toString()+"@"+flagType; - }else{ - info = "flagType@flagType@"+flagType; - } - //获取需要盖章的文件信息 - Map map=new HashMap(); - bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); - if(bo != null){ - id = bo.getAttribute("id").toString(); - con = new ContractSignInfo(); - con.setFileid(id); - con.setFilename(bo.getAttribute("FILENAME").toString()); - String makefullPath = bo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(info, con); - Map resultMap = null; - //调代理的接口 -// doc_name = bo.getAttribute("doc_name").toString(); -// if("租金支付表".equals(doc_name)){ - //租金支付表 - resultMap = requestService.createPaymentofHireSign(map); -// } - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { -// bo.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); -// bo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); - contract_id = resultMap.get(key); - } - } -// bo.setAttributeValue("PROCESS", "5"); -// contBom.saveObject(bo); -// tx.commit(); - } else { - return "error"; - } - } -// bo = contBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); - if (bo != null) { - Map map1 = new HashMap(); - map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); - Map result1 = requestService.downloadDoc(map1); - if (!result1.containsKey("error")) { - for (String contractId : map1.keySet()) { - try { - if ("success".equals(result1.get(contractId))) { - String fileString = result1.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result1.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } -// bo.setAttributeValue("PROCESS", "6"); -// contBom.saveObject(bo); - } else { - return "error"; - } - } else { - return "error"; - } - - return "success"; - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - } - - /** - * 扣款卡信息变更发电子签约 - * @param tx - * @return - * @throws Exception - */ - public String changeCarSignA(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - String libraryid=""; - BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME,tx); - BizObjectManager bom1=null; - BizObject DOCRELATIVE= null; - BizObject library= null; - DOCRELATIVE=bom.createQuery("OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); - if (DOCRELATIVE != null) { - String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); - bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME,tx); - library=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(true); - libraryid = library.getAttribute("id").toString(); - } - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - ContractSignInfo con = null; - BizObject bo = null; -// String contract_id=""; - String info=""; - try{ - //获取承租人的姓名和电话号 - BizObjectManager lulManager = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME, tx); - String customerid = lulManager.createQuery("CONTRACT_ID=:contractId").setParameter("contractId", contract_id).getSingleResult(false).getAttribute("CUSTOMER_ID").toString(); - BizObjectManager crManage = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); - BizObject cr = crManage.createQuery("CUSTOMERID=:customerid").setParameter("customerid", customerid).getSingleResult(false); - if(cr != null){ - info = cr.getAttribute("FULLNAME").toString() + "@" + cr.getAttribute("mobile").toString()+"@"+flagType; - }else{ - return "error"; - } - //获取需要盖章的文件信息 - Map map=new HashMap(); - bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); - if(bo != null){ - id = bo.getAttribute("id").toString(); - con = new ContractSignInfo(); - con.setFileid(id); - con.setFilename(bo.getAttribute("FILENAME").toString()); - String makefullPath = bo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(info, con); - Map resultMap = null; - resultMap = requestService.createAccountContractDSign(map); - - if (!resultMap.containsKey("error")) { - BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); - if(ldcl != null){ - ldcl.setAttributeValue("sign_type", "SIGNING"); - ldclManage.saveObject(ldcl); - } - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { -// DOCRELATIVE.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); - DOCRELATIVE.setAttributeValue("TEMPLATE_ID", resultMap.get("contract_" + key)); - library.setAttributeValue("REMARK",resultMap.get(key)); - bo.setAttributeValue("REMARK","SIGNING"); - contract_id = resultMap.get(key); - } - } - bom.saveObject(DOCRELATIVE); - bom1.saveObject(library); - contBom.saveObject(bo); - tx.commit(); - } else { - return "error"; - } - } - return "success"; - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - } - - /** - * 催收函盖公司章 - * @param tx - * @return - * @throws Exception - */ - public String collectionSignA(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - String libraryid=""; - BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); - BizObject DOCRELATIVE = null; - if("settle".equals(flagType)){ - DOCRELATIVE=bom.createQuery("CONTRACT_ID=:contractid and objecttype='settle' ").setParameter("contractid",contract_id).getSingleResult(false); - }else if("LetterApprova".equals(flagType)){ - DOCRELATIVE=bom.createQuery("PROJ_ID=:projectId and objecttype='LetterApprova' ").setParameter("projectId",ProjectId).getSingleResult(false); - }else{ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype LIKE '%打印催款函%' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - } - if (DOCRELATIVE != null) { - String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); - BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); - libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); - } - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - ContractSignInfo con = null; - BizObject bo = null; - String info=""; - try{ - info = libraryid + "@" + libraryid+"@"+flagType; - //获取需要盖章的文件信息 - Map map=new HashMap(); - bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); - if(bo != null){ - id = bo.getAttribute("id").toString(); - con = new ContractSignInfo(); - con.setFileid(id); - con.setFilename(bo.getAttribute("FILENAME").toString()); - String makefullPath = bo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(info, con); - Map resultMap = null; - resultMap = requestService.createPaymentofHireSign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - contract_id = resultMap.get(key); - } - } - } else { - return "error"; - } - } - if (bo != null) { - Map map1 = new HashMap(); - map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); - Map result1 = requestService.downloadDoc(map1); - if (!result1.containsKey("error")) { - for (String contractId : map1.keySet()) { - try { - if ("success".equals(result1.get(contractId))) { - String fileString = result1.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result1.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - } else { - return "error"; - } - } else { - return "error"; - } - - return "success"; - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - } - - - - /*** - * 已经生成的合同,作废, - * @param tx - * @return - * @throws JBOException - */ - - public String updateDocContractStatus(JBOTransaction tx) throws JBOException{ -// BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx);ProjectId - BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObjectManager lpiManager=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); - try{ -// BizObject lcl = lclManager.createQuery("file_flag='yes' and attribute_id='"+file_id+"'").getSingleResult(true); - - lclManager.createQuery("update O set file_flag='no',message='1' where attribute_id=:attributeid").setParameter("attributeid",file_id).executeUpdate(); - lpiManager.createQuery("update O set PROJECT_STATUS=13 where id=:id").setParameter("id",ProjectId).executeUpdate(); - //attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); - tx.commit(); - }catch(Exception e){ - tx.rollback(); - e.printStackTrace(); - System.out.println(e.getMessage()); - return "error"; - } - return "success"; - } - - public String companyUpdateDocContractStatus(JBOTransaction tx) throws Exception{ - BizObjectManager fboManger=JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME,tx); - BizObjectManager lctManger=JBOFactory.getBizObjectManager(LB_CONTRACT_TEMPLATE.CLASS_NAME,tx); - BizObject fbo = fboManger.createQuery("flow_unid=:flowunid").setParameter("flowunid",FlowUnid).getSingleResult(false); - BizObject lct = lctManger.createQuery("Contract_id=:contractid").setParameter("contractid", fbo.getAttribute("CONTRACT_ID").getString()).getSingleResult(false); - String attId = ContractTemplateCache.getContractTemplateID(lct.getAttribute("ID").getString()); - lctManger.deleteObject(lct); - BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); - BizObjectManager lpiManager=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); - try{ - lclManager.createQuery("update O set file_flag='no',message='1' where attribute_id=:attributeid").setParameter("attributeid",attId).executeUpdate(); - lpiManager.createQuery("update O set PROJECT_STATUS=13 where id=:id").setParameter("id",ProjectId).executeUpdate(); - //attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); - tx.commit(); - }catch(Exception e){ - tx.rollback(); - e.printStackTrace(); - System.out.println(e.getMessage()); - return "error"; - } - return "success"; - } - - /** - * 传统合同盖章 - * @param tx - * @return - * @throws Exception - - */ - public String TcollectionSignA(JBOTransaction tx) throws Exception { - requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); - String libraryid=""; - BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); - BizObject DOCRELATIVE = null; - if("transfer".equals(flagType)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='transfer' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("AdjustmentNotice".equals(flagType)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='AdjustmentNotice' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("TriditionCollection".equals(flagType)){ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype='TriditionCollection' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - }else if("TriditionSuspension".equals(flagType)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionSuspension' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); - }else if("settletradition".equals(flagType)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='settletradition' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); - }else if("LoanNotice".equals(flagType)){ - DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LoanNotice' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); - }else{ - DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype LIKE '%打印催款函%' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); - } - if (DOCRELATIVE != null) { - String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); - BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); - libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); - } - BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); - ContractSignInfo con = null; - BizObject bo = null; - String info=""; - try{ - info = libraryid + "@" + libraryid+"@"+flagType; - //获取需要盖章的文件信息 - Map map=new HashMap(); - bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); - if(bo != null){ - id = bo.getAttribute("id").toString(); - con = new ContractSignInfo(); - con.setFileid(id); - con.setFilename(bo.getAttribute("FILENAME").toString()); - String makefullPath = bo.getAttribute("FULLPATH").toString(); - File file = new File(makefullPath); - if (!file.exists()) { - throw new RuntimeException("要读取的文件不存在"); - } - con.setInputfile(BASE64.encodeImgageToBase64(file)); - map.put(info, con); - Map resultMap = null; - resultMap = requestService.createPaymentofHireSign(map); - if (!resultMap.containsKey("error")) { - for (String key : resultMap.keySet()) { - if (key.indexOf("contract_") == -1) { - contract_id = resultMap.get(key); - } - } - } else { - return "error"; - } - } - if (bo != null) { - Map map1 = new HashMap(); - map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); - Map result1 = requestService.downloadDoc(map1); - if (!result1.containsKey("error")) { - for (String contractId : map1.keySet()) { - try { - if ("success".equals(result1.get(contractId))) { - String fileString = result1.get("file_" + contractId); - InputStream fileInput = BASE64.encodeFileToBase64(fileString); - OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO - byte[] buffByte = new byte[1024]; - int size = 0; - while ((size = fileInput.read(buffByte)) != -1) { - fileOut.write(buffByte, 0, size); - } - fileInput.close(); - fileOut.close(); - } else if ("error".equals(result1.get(contractId))) { - return "error"; - } - } catch (Exception e) { - e.printStackTrace(); - - } - } - } else { - return "error"; - } - } else { - return "error"; - } - - return "success"; - } catch (Exception e) { - e.printStackTrace(); - return "error"; - } - } - //生成一维 - public String SystemMakeOneDimensionalCode(JBOTransaction tx){ - Configure CurConfig = Configure.getInstance(); - try { - String diskPath=CurConfig.getConfigure("OneDimensionalCode"); - MakeOneCodeAndContractModel mocacm = new MakeOneCodeAndContractModel(); - BizObjectManager loManage = JBOFactory.getBizObjectManager(LB_ONEDIMENSIONALCODE.CLASS_NAME,tx); - BizObject lom = loManage.createQuery(" PROJECT_ID=:projectid and CONTRACT_NO=:contractNo and CONTRACT_ID=:contractId").setParameter("projectid", ProjectId).setParameter("contractNo", contractNo).setParameter("contractId", contract_id).getSingleResult(false); - if(lom == null){ - //生成一维码 - mocacm.MOneDimensionalCode(contractNo, contract_id, ProjectId, diskPath, tx); - } - String outPdfFile = CurConfig.getConfigure("BQcontract"); - mocacm.pdfAndMark(outPdfFile, "", contract_id,leasform, tx); - }catch (Exception e) { - e.printStackTrace(); - return "error"; - } - return "success"; - } +package com.tenwa.channelportal.action; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import jbo.app.tenwa.customer.CUSTOMER_FAMILY_TEMP; +import jbo.app.tenwa.customer.CUSTOMER_PERSON; +import jbo.app.tenwa.customer.CUSTOMER_PERSON_TEMP; +import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; +import jbo.app.tenwa.doc.LB_DOCLIBRARY; +import jbo.app.tenwa.doc.LB_DOCRELATIVE; +import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; +import jbo.app.tenwa.doc.LB_ONEDIMENSIONALCODE; +import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; +import jbo.com.tenwa.lease.carbrand.BUSINESS_STATUS; +import jbo.com.tenwa.lease.carbrand.LB_CONTRACT_SIGN_LOG; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_TEMPLATE; +import jbo.com.tenwa.lease.comm.LB_GUARANTEE_UNIT_TEMP; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP; +import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE; +import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE_TEMP; +import jbo.sys.CODE_LIBRARY; + +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.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.Configure; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.amarsoft.context.ASUser; +import com.caucho.hessian.client.HessianProxyFactory; +import com.tenwa.app.dao.ContractSignInfo; +import com.tenwa.lease.app.service.HttpRequestAppService; +import com.tenwa.lease.flow.contract.contractapproval.ContractTemplateCache; +import com.tenwa.makeContract.util.MakeOneCodeAndContractModel; +import com.tenwa.channelportal.action.generativecontract.Word2PdfUtil; +import com.tenwa.channelportal.action.generativecontract.WordToPDFUtil; +import com.tenwa.comm.util.date.DateAssistant; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.doc.util.BASE64; +import com.tenwa.officetempalte.util.FileOperatorUtil; +import com.tenwa.quartz.DateUtil; +import com.tenwa.reckon.util.UUIDUtil; + +public class ContractSignAction{ + public String file_id; + public String cust_phone; + public String cust_id; + public String library_id; + public String customerType; + public String CurUserID; + public String ProjectId; + public String contract_id; + public String FlowUnid; + public String InputOrgid; + public String id; + private String attrId; + public String flagType; + public HessianProxyFactory factory = new HessianProxyFactory(); + public HttpRequestAppService requestService; + public String PAYMENT_NUMBER; + public String PLAN_LIST; + public String Ttype; + public String contractNo; + public String leasform; + private static Logger logger=Logger.getLogger(ContractSignAction.class); + @SuppressWarnings("deprecation") + public static String getConfigRequestUrl() throws Exception{ + return Configure.getInstance().getConfigure("RequestHessionUrl"); + } + @SuppressWarnings("deprecation") + public static String getFileSavePath() throws Exception{ + return Configure.getInstance().getConfigure("FileSavePath"); + } + + public String getCurUserID() { + return CurUserID; + } + + public String getContract_id() { + return contract_id; + } + + public void setContract_id(String contract_id) { + this.contract_id = contract_id; + } + + public void setCurUserID(String curUserID) { + CurUserID = curUserID; + } + + public String getCustomerType() { + return customerType; + } + + public void setCustomerType(String customerType) { + this.customerType = customerType; + } + + public String getFile_id() { + return file_id; + } + + public void setFile_id(String file_id) { + this.file_id = file_id; + } + + + public String getCust_id() { + return cust_id; + } + + public void setCust_id(String cust_id) { + this.cust_id = cust_id; + } + + public String getCust_phone() { + return cust_phone; + } + public void setCust_phone(String cust_phone) { + this.cust_phone = cust_phone; + } + + public String getLibrary_id() { + return library_id; + } + public void setLibrary_id(String library_id) { + this.library_id = library_id; + } + + public String getProjectId() { + return ProjectId; + } + + public void setProjectId(String projectId) { + ProjectId = projectId; + } + + public String getFlowUnid() { + return FlowUnid; + } + + public void setFlowUnid(String flowUnid) { + FlowUnid = flowUnid; + } + + public String getInputOrgid() { + return InputOrgid; + } + + public void setInputOrgid(String inputOrgid) { + InputOrgid = inputOrgid; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + //类型 + public String getFlagType() { + return flagType; + } + + public void setFlagType(String flagType) { + this.flagType = flagType; + } + public String getAttrId() { + return attrId; + } + public void setAttrId(String attrId) { + this.attrId = attrId; + } + + + public String getPAYMENT_NUMBER() { + return PAYMENT_NUMBER; + } + public void setPAYMENT_NUMBER(String pAYMENT_NUMBER) { + PAYMENT_NUMBER = pAYMENT_NUMBER; + } + public String getPLAN_LIST() { + return PLAN_LIST; + } + public void setPLAN_LIST(String pLAN_LIST) { + PLAN_LIST = pLAN_LIST; + } + public String getTtype() { + return Ttype; + } + public void setTtype(String ttype) { + Ttype = ttype; + } + public String getContractNo() { + return contractNo; + } + public void setContractNo(String contractNo) { + this.contractNo = contractNo; + } + public String getLeasform() { + return leasform; + } + public void setLeasform(String leasform) { + this.leasform = leasform; + } + /** + * 自然人电子签约 + * + * @author tenwa518 + * @param tx + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public String signIng(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObjectManager lcslBom = JBOFactory.getBizObjectManager(LB_CONTRACT_SIGN_LOG.CLASS_NAME,tx); + Map> map = new HashMap>(); + ContractSignInfo con = null; + List bo = null; + BizObject ldclBo = null; + try { + //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); + 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).getResultList(true); + for (BizObject keys : bo) { + String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); + StringBuffer manyPeople = this.manyPeople(); + if(manyPeople.length()>0){ + info=info+"@applicant,"+manyPeople.deleteCharAt(manyPeople.length() - 1); + } + List list = map.get(info); + if (list == null) { + list = new ArrayList(); + map.put(info, list); + } + con = new ContractSignInfo(); + con.setCustname(keys.getAttribute("DOC_NAME").toString()); + con.setCustphone(keys.getAttribute("TELEPHONE").toString()); + con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(keys.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = keys.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + list.add(con); + } + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + Map resultMap = requestService.createContractSign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + //记录项目进程日志 + /*Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='8',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM "+LB_PROJECT_INFO.CLASS_NAME+" LPI WHERE LPI.ID='"+ProjectId+"')").executeUpdate(); + SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'8','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+ProjectId+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so);*/ + return "success"; + } else { + Boolean flag = false; + String getMessage = resultMap.get("error"); + logger.info("契约锁反馈的异常信息" + getMessage); + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1 && !"error".equals(key)) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + if ("1".equals(sendProcess)) { + flag = true; + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + }else if("2".equals(sendProcess)){ + ldclBo.setAttributeValue("MESSAGE",getMessage ); + } + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + } + } + // 判断不同的异常反馈给前端 + if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { + getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); + return flag + "@" + getMessage; + } else if (getMessage.indexOf("contractId不能为空") != -1) { + return flag + "@" + getMessage; + } else { + return flag + "@" + "error"; + } + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + logger.info("自然人电子签约异常:" + e.getMessage()); + return "flase@error"; + } + } + /** + * 法人客户在生成合同是直接盖章 + * @param tx + * @return + * @throws Exception + */ + + @SuppressWarnings("unchecked") + public String compnySignIng(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + Map map = new HashMap(); + ContractSignInfo con = null; + List bo = null; + BizObject ldclBo = null; + try { + //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); + 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).getResultList(true); + for (BizObject keys : bo) { + String info = keys.getAttribute("id").toString(); + con = new ContractSignInfo(); + con.setCustname(keys.getAttribute("DOC_NAME").toString()); + con.setCustphone(keys.getAttribute("TELEPHONE").toString()); + con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(keys.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = keys.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(info, con); + } + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + Map resultMap = requestService.compnySign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SIGN_TYPE", "COMPLETE");//法人客户当盖完章改为完成状态 + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + downloadDoc(tx); + return "success"; + } else { + Boolean flag = false; + String getMessage = resultMap.get("error"); + logger.info("契约锁反馈的异常信息" + getMessage); + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1 && !"error".equals(key)) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + if ("1".equals(sendProcess)) { + flag = true; + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + }else if("2".equals(sendProcess)){ + ldclBo.setAttributeValue("MESSAGE",getMessage ); + } + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + } + } + // 判断不同的异常反馈给前端 + if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { + getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); + return flag + "@" + getMessage; + } else if (getMessage.indexOf("contractId不能为空") != -1) { + return flag + "@" + getMessage; + } else { + return flag + "@" + "error"; + } + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + logger.info("法人客户生成合同盖章失败" + e.getMessage()); + return "flase@error"; + } + } + + //获取电子签约人员列表 + public StringBuffer manyPeople() throws JBOException{ + //获取担保人信息 + StringBuffer info = new StringBuffer(); + 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){ + info.append(name+"@"+mobile+"@guarantee,"); + } + } + //获取共同申请人的信息 + 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){ + info.append(name+"@"+mobile+"@comm,"); + } + } + + return info; + } + + /** + * 法人租金委托代偿电子签约 + * @author tenwa518 + * @param tx + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public String companySignIng(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + Map> map = new HashMap>(); + ContractSignInfo con = null; + List bo = null; + BizObject ldclBo = null; + try { + BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); + // 查询lb_doc_contract_list表 + bo = contBom.createQuery("project_id=:projectId and file_flag='yes' and (sendprocess='0' or sendprocess='2' ) and doc_name='租金代偿函'").setParameter("projectId", ProjectId).getResultList(true); + for (BizObject keys : bo) { + String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); + List list = map.get(info); + if (list == null) { + list = new ArrayList(); + map.put(info, list); + } + con = new ContractSignInfo(); + con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); + con.setCustphone(keys.getAttribute("TELEPHONE").toString()); + con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(keys.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = keys.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + list.add(con); + } + + Map fromCondtion=new HashMap(); + MapotherProperty=new HashMap(); + Map resultMap = requestService.createComContractSign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1) { + fromCondtion.clear(); + otherProperty.clear(); + //契约锁合同号 + String contractId=resultMap.get("contract_" + key); + String sendProcess=resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + ldclBo.setAttributeValue("SENDPROCESS",sendProcess); + contBom.saveObject(ldclBo); + + String contractDocId =ldclBo .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("project_status","8");//状态改成电子签约,签署中 + pbm.saveObject(pbo); + //记录项目进程日志 + Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='8',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM "+LB_PROJECT_INFO.CLASS_NAME+" LPI WHERE LPI.ID='"+ProjectId+"')").executeUpdate(); + SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'8','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+ProjectId+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so); + return "success"; + } else { + Boolean falg=false; + String getMessage = resultMap.get("error"); + logger.info("契约锁反馈的异常信息" + getMessage); + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1 && !"error".equals(key)) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + if ("1".equals(sendProcess)) { + falg=true; + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + }else if ("2".equals(sendProcess)) { + ldclBo.setAttributeValue("MESSAGE", getMessage); + } + contBom.saveObject(ldclBo); + + String contractDocId=ldclBo.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); + } + } + // 判断不同的异常反馈给前端 + if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { + getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); + return getMessage; + } else if (getMessage.indexOf("contractId不能为空") != -1) { + return getMessage; + } else { + return "error"; + } + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + return "error"; + } + + } + + /** + * (扣款卡变更)自然人委托扣款授权书电子签约,还有租金代偿函 + * @author tenwa518 + * @param tx + * @return + * @throws Exception + */ + public String PersonDeductSignIng(JBOTransaction tx) throws Exception{ + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + Map> map = new HashMap>(); + ContractSignInfo con = null; + List bo = null; + BizObject ldclBo = null; + try { + // 查询lb_doc_contract_list表 + bo = contBom.createQuery("flow_unid=:flow_unid and (sendprocess='0' or sendprocess='2' ) and file_flag='yes'").setParameter("flow_unid", FlowUnid).getResultList(true); + + for (BizObject keys : bo) { + String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); + List list = map.get(info); + if (list == null) { + list = new ArrayList(); + map.put(info, list); + } + con = new ContractSignInfo(); + con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); + con.setCustphone(keys.getAttribute("TELEPHONE").toString()); + con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(keys.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = keys.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + list.add(con); + } + + + Map fromCondtion=new HashMap(); + MapotherProperty=new HashMap(); + Map resultMap = null; + if ("01".equals(customerType)) { + resultMap = requestService.createComContractSign(map); + } else { + resultMap = requestService.createEntrustmentSign(map); + } + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + fromCondtion.clear(); + otherProperty.clear(); + //契约锁合同号 + String contractId=resultMap.get("contract_" + key); + String sendProcess=resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + ldclBo.setAttributeValue("SENDPROCESS",sendProcess); + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + } + } + + return "success"; + + } else { + Boolean flag = false; + String getMessage = resultMap.get("error"); + logger.info("契约锁反馈的异常信息" + getMessage); + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1 && !"error".equals(key)) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + if ("1".equals(sendProcess)) { + flag = true; + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + }else if("2".equals(sendProcess)){ + ldclBo.setAttributeValue("MESSAGE",getMessage ); + } + contBom.saveObject(ldclBo); + + + String contractDocId = ldclBo.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); + } + } + // 判断不同的异常反馈给前端 + if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { + getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); + return getMessage; + } else if (getMessage.indexOf("contractId不能为空") != -1) { + return getMessage; + } else { + return "error"; + } + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + return "error"; + } + } + + /** + * 提前结清 申请书进行电子签约 + * + * @author + * @param + * @return + * @throws Exception + */ + public String AdjustFordSignIng(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + Map> map = new HashMap>(); + ContractSignInfo con = null; + List bo = null; + BizObject ldclBo = null; + try { + // 查询lb_doc_contract_list表 + bo = contBom.createQuery("flow_unid=:flow_unid and file_flag='yes'").setParameter("flow_unid", FlowUnid).getResultList(true); + for (BizObject keys : bo) { + String info = keys.getAttribute("CUSTOMERNAME").toString() + "@" + keys.getAttribute("TELEPHONE").toString(); + List list = map.get(info); + if (list == null) { + list = new ArrayList(); + map.put(info, list); + } + con = new ContractSignInfo(); + con.setCustname(keys.getAttribute("CUSTOMERNAME").toString()); + con.setCustphone(keys.getAttribute("TELEPHONE").toString()); + con.setFileid(keys.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(keys.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = keys.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + list.add(con); + } + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + Map resultMap = null; + resultMap = requestService.createAdjustFordContractDSign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); +// ldclBo.setAttributeValue("PROCESS", "4"); + contBom.saveObject(ldclBo); + + String contractDocId = ldclBo.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); + } + } + return "success"; + } else { + Boolean flag = false; + String getMessage = resultMap.get("error"); + logger.info("契约锁反馈的异常信息" + getMessage); + for (String key : resultMap.keySet()) { + // 存储契约锁返回的合同id和合同文件id + if (key.indexOf("contract_") == -1 && !"error".equals(key)) { + fromCondtion.clear(); + otherProperty.clear(); + // 契约锁合同号 + String contractId = resultMap.get("contract_" + key); + String sendProcess = resultMap.get("contract_" + contractId); + ldclBo = contBom.createQuery("ATTRIBUTE_ID='" + key + "'").getSingleResult(true); + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", contractId); + ldclBo.setAttributeValue("SENDPROCESS", sendProcess); + if ("1".equals(sendProcess)) { + flag = true; + ldclBo.setAttributeValue("SIGN_TYPE", "SIGNING"); + } else if ("2".equals(sendProcess)) { + ldclBo.setAttributeValue("MESSAGE", getMessage); + } + contBom.saveObject(ldclBo); + String contractDocId = ldclBo.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); + } + } + // 判断不同的异常反馈给前端 + if (getMessage.indexOf("用户认证信息与合同签署方信息不匹配") != -1) { + getMessage = getMessage.substring((getMessage.indexOf("message")) + 10, (getMessage.indexOf("code")) - 3); + return getMessage; + } else if (getMessage.indexOf("contractId不能为空") != -1) { + return getMessage; + } else { + return "error"; + } + } + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + return "error"; + } + + } +/** + * 提前结清查询签约状态 + * @param tx + * @return + * @throws Exception + */ + public String getAdjustFordSignStatus(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); + List ldclBoList = ldclBom.createQuery("flow_unid='" + FlowUnid + "' and file_flag='yes' and " + + "sendprocess='1'").getResultList(true); + String signContractId = ""; + String customerName = ""; + String contractDocId = ""; + StringBuffer result = new StringBuffer(); + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + for (BizObject key : ldclBoList) { + signContractId = key.getAttribute("singcontract_id").toString(); + customerName = key.getAttribute("customername").toString(); + contractDocId = key.getAttribute("id").toString(); + try { + String signType = requestService.getContractSignStatus(signContractId); + String signstatus = clBom.createQuery("itemno='" + signType + "'").getSingleResult(false).getAttribute("itemname").toString(); + key.setAttributeValue("sign_type", signType); + if("COMPLETE".equals(signType)){ + key.setAttributeValue("PROCESS", "5.1"); + } + ldclBom.saveObject(key); + result.append("," + customerName + "电子签约状态:" + signstatus); + //日志记录 + + fromCondtion.put("ID", contractDocId); + otherProperty.put("SIGNPROCESS", "1");// 查询状态 + 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); + } catch (Exception e) { + fromCondtion.put("ID", contractDocId); + otherProperty.put("SIGNPROCESS", "1");// 查询状态 + otherProperty.put("CONTRACTDOCID", contractDocId); + otherProperty.put("MESSAGE", e.getMessage()); + otherProperty.put("INPUTTIME", DateAssistant.getTodayNow()); + DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion, LB_CONTRACT_SIGN_LOG.CLASS_NAME, null, + otherProperty, tx); + return "error"+"@"+e.getMessage(); + } + + } + return result.toString().substring(1); + } + + /** + * (扣款卡变更)自然人委托扣款授权书获取电子签约状态 ,法人租金代偿 + * + * @throws Exception + */ + public String contractSignStatusForContract(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); + List ldclBoList = ldclBom.createQuery("flow_unid='" + FlowUnid + "' and file_flag='yes' and " + + "sendprocess='1'").getResultList(true); + String signContractId = ""; + String customerName = ""; + String contractDocId = ""; + StringBuffer result = new StringBuffer(); + Map fromCondtion = new HashMap(); + Map otherProperty = new HashMap(); + for (BizObject key : ldclBoList) { + signContractId = key.getAttribute("singcontract_id").toString(); + customerName = key.getAttribute("customername").toString(); + contractDocId = key.getAttribute("id").toString(); + try { + String signType = requestService.getContractSignStatus(signContractId); + String signstatus = clBom.createQuery("itemno='" + signType + "'").getSingleResult(false).getAttribute("itemname").toString(); + key.setAttributeValue("sign_type", signType); + if("COMPLETE".equals(signType)){ + key.setAttributeValue("PROCESS", "5.1"); + } + ldclBom.saveObject(key); + result.append("," + customerName + "电子签约状态:" + signstatus); + //日志记录 + + fromCondtion.put("ID", contractDocId); + otherProperty.put("SIGNPROCESS", "1");// 查询状态 + 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); + } catch (Exception e) { + fromCondtion.put("ID", contractDocId); + otherProperty.put("SIGNPROCESS", "1");// 查询状态 + otherProperty.put("CONTRACTDOCID", contractDocId); + otherProperty.put("MESSAGE", e.getMessage()); + otherProperty.put("INPUTTIME", DateAssistant.getTodayNow()); + DataOperatorUtil.copySingleJBO(LB_DOC_CONTRACT_LIST.CLASS_NAME, fromCondtion, LB_CONTRACT_SIGN_LOG.CLASS_NAME, null, + otherProperty, tx); + return "error"+"@"+e.getMessage(); + } + + } + return result.toString().substring(1); + } + + /** + * 获取电子签约状态 + * + * @throws Exception + */ + public String contractSignStatus(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + //BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME, tx); + BizObjectManager clBom = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME, tx); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObjectManager ldBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + //BizObject pbo = pbm.createQuery("id=:id").setParameter("id", ProjectId).getSingleResult(true); + BizObject pbo = pbm.createQuery("FLOWUNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(true); + String status = ""; + String peopleStatus=""; + String sql = ""; + if ("01".equals(customerType)) { + sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函' and sendprocess='1'"; + } else { + sql = "project_id=:projectId and file_flag='yes' and sendprocess='1'"; + } + @SuppressWarnings("unchecked") + List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); + if (bo != null) { + boolean flag = true; + Map map = new HashMap(); + for (BizObject keys : bo) { + map.put(keys.getAttribute("singcontract_id").toString(), keys.getAttribute("customername").toString()); + } + for (String key : map.keySet()) { + try { + String signStatu = requestService.getContractSignStatus(key); + int index = signStatu.indexOf("$"); + String signStatus = signStatu.substring(0, index); + peopleStatus = signStatu.substring(index+1); + String signStatusName = + clBom.createQuery("itemno='" + signStatus + "'").getSingleResult(false).getAttribute("itemname").toString(); + List ldclList = + contBom.createQuery("project_id=:projectId and file_flag='yes' and singcontract_id='" + key + "'") + .setParameter("projectId", ProjectId).getResultList(true); + for (BizObject keys : ldclList) { + keys.setAttributeValue("SIGN_TYPE", signStatus); + // 客户签署完成,合同制作过程为4 + if ("REQUIRED".equals(signStatus)) { + this.sign(tx); + downloadDoc(tx); + keys.setAttributeValue("PROCESS", "4"); + } + contBom.saveObject(keys); + } + if (!"REQUIRED".equals(signStatus) && !"COMPLETE".equals(signStatus) ) { + flag = false; + } + if ("REQUIRED".equals(signStatus)) { + status += ";
客户" + map.get(key) + "签约状态:已签名"; + } else { + status += ";
客户" + map.get(key) + "签约状态:" + signStatusName; + } + } catch (Exception e) { + e.printStackTrace(); + return "获取签约状态失败!"; + } + } + // 合同签约已完成 + if (flag) { + pbo.setAttributeValue("DATA_STATE", "4");// 状态改成已完成电子签约 + pbm.saveObject(pbo); + // 记录项目进程日志 + /* Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME, tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='4',UPDATEUSERID='" + user.getUserID() + "',UPDATEORGID='" + + user.getOrgID() + "',UPDATETIME='" + StringFunction.getTodayNow() + + "' WHERE CONTRACT_NUMBER=(SELECT LPI.CONTRACT_NUMBER FROM " + LB_PROJECT_INFO.CLASS_NAME + + " LPI WHERE LPI.ID='" + ProjectId + "')") + .executeUpdate(); + SqlObject so = new SqlObject( + "INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'4','" + + user.getUserID() + "','" + user.getOrgID() + "','" + StringFunction.getTodayNow().replaceAll(":", "△") + + "' FROM LB_PROJECT_INFO WHERE ID='" + ProjectId + "'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so);*/ + for (BizObject keys : bo) { + /* ldBom.createQuery("update O set status='' where id='" + keys.getAttribute("attribute_id").toString() + "'") + .executeUpdate();*/ + } + status = ";
已经完成电子签约"; + } + } + if (status.length() < 1) { + return "获取签约状态失败,没有合同文件"; + } else { + status = status.substring(5); + String[] peopleStat = peopleStatus.split(","); + if(peopleStat.length>1){ + status = status+"
"; + for(int i=0;i map = new HashMap(); + + map.put(ldb.getAttribute("TEMPLATE_ID").toString(),lul.getAttribute("CUSTOMER_NAME").toString()); + + for (String key : map.keySet()) { + try { + String signStatu = requestService.getContractSignStatus(key); + int index = signStatu.indexOf("$"); + String signStatus = signStatu.substring(0, index); + peopleStatus = signStatu.substring(index+1); + String signStatusName = + clBom.createQuery("itemno='" + signStatus + "'").getSingleResult(false).getAttribute("itemname").toString(); + BizObject ldl = ldlMange.createQuery("RELATIVE_ID=:relativeid").setParameter("relativeid", ldb.getAttribute("ID").getString()).getSingleResult(false); + lda = ldaMange.createQuery("LIBRARY_ID=:libraryid").setParameter("libraryid", ldl.getAttribute("ID").getString()).getSingleResult(true); + if (signStatu.indexOf("已签署")>0) { + signStatus = "REQUIRED"; + }else{ + flag = false; + } + if ("REQUIRED".equals(signStatus)) { + status += ";
客户" + map.get(key) + "签约状态:已签名"; + } else { + status += ";
客户" + map.get(key) + "签约状态:" + signStatusName; + } + } catch (Exception e) { + e.printStackTrace(); + return "获取签约状态失败!"; + } + } + // 合同签约已完成 + if (flag) { + lda.setAttributeValue("REMARK", "COMPLETE");// 状态改成已完成电子签约 + BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); + if(ldcl != null){ + ldcl.setAttributeValue("sign_type", "COMPLETE"); + ldclManage.saveObject(ldcl); + } + ldaMange.saveObject(lda); + status = ";
已经完成电子签约"; + changedownloadDoc(tx); + } + } + + if (status.length() < 1) { + return "获取签约状态失败,没有合同文件"; + } else { + status = status.substring(5); + String[] peopleStat = peopleStatus.split(","); + if(peopleStat.length>1){ + status = status+"
"; + for(int i=0;i contractIds = new ArrayList(); + if ("01".equals(customerType)) { + sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函' and sendprocess='1'"; + } else { + sql = "project_id=:projectId and file_flag='yes' and sendprocess='1'"; + } + @SuppressWarnings("unchecked") + List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); + if (bo != null) { + boolean flag = true; + Map map = new HashMap(); + for (BizObject keys : bo) { + map.put(keys.getAttribute("singcontract_id").toString(), keys.getAttribute("customername").toString()); + contractIds.add(keys.getAttribute("singcontract_id").toString()); + } + + Map resultMap = requestService.getContractSignListStatus(contractIds); + } + return ""; + } + + /** + * 盖企业章 + * + * @param tx + * @return + * @throws MalformedURLException + * @throws Exception + */ + public String sign(JBOTransaction tx) throws MalformedURLException, Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + @SuppressWarnings("unchecked") + List bo = contBom.createQuery("project_id=:projectId and file_flag='yes'") + .setParameter("projectId", ProjectId).getResultList(true); + if (bo != null) { + Map> map = new HashMap>(); + for (BizObject keys : bo) { + List list = map.get(keys.getAttribute("singcontract_id").toString()); + if (list == null) { + list = new ArrayList(); + } + list.add(keys.getAttribute("DOCUMENT_ID").toString()+"@"+keys.getAttribute("doc_name").toString()); + map.put(keys.getAttribute("singcontract_id").toString(), list); + } + Map resultMap = requestService.Sign(map); + String statu = resultMap.get("error"); + if (statu == null) { + return "success"; + } + } + + return "error"; + } + + /** + * 根据document_id下载合同 + * + * @param tx + * @return + * @throws Exception + * @throws MalformedURLException + */ + public String downloadDoc(JBOTransaction tx) throws MalformedURLException, Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + String sql = ""; + if ("01".equals(customerType)) { + sql = "project_id=:projectId and file_flag='yes' and doc_name='租金代偿函'"; + } else { + sql = "project_id=:projectId and file_flag='yes'"; + } + try { + + @SuppressWarnings("unchecked") + List bo = contBom.createQuery(sql).setParameter("projectId", ProjectId).getResultList(true); + if (bo != null) { + Map map = new HashMap(); + for (BizObject keys : bo) { + map.put(keys.getAttribute("DOCUMENT_ID").toString(), keys.getAttribute("FULLPATH").toString()); + } + Map result = requestService.downloadDoc(map); + if (!result.containsKey("error")) { + for (String contractId : map.keySet()) { + try { + if ("success".equals(result.get(contractId))) { + String fileString = result.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + return "success"; + } else { + return "error"; + } + } + } catch (Exception e) { + return "error"; + } + return "success"; + } + + /** + * 扣款卡信息变更根据document_id下载合同 + * + * @param tx + * @return + * @throws Exception + * @throws MalformedURLException + */ + public String changedownloadDoc(JBOTransaction tx) throws MalformedURLException, Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager ldMange = JBOFactory.getBizObjectManager(LB_DOCRELATIVE.CLASS_NAME, tx); + String sql = "OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid "; + @SuppressWarnings("unchecked") + BizObject ldb = ldMange.createQuery(sql).setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); + BizObjectManager clBom = JBOFactory.getBizObjectManager(LB_DOCLIBRARY.CLASS_NAME, tx); + try { + if (ldb != null) { + BizObject ldl = clBom.createQuery("RELATIVE_ID=:relativeid").setParameter("relativeid", ldb.getAttribute("ID").getString()).getSingleResult(false); + BizObjectManager ldaMange = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + BizObject lda = ldaMange.createQuery("LIBRARY_ID=:libraryid").setParameter("libraryid", ldl.getAttribute("ID").getString()).getSingleResult(false); + Map map = new HashMap(); + map.put(ldl.getAttribute("REMARK").toString(), lda.getAttribute("FULLPATH").toString()); + Map result = requestService.downloadDoc(map); + if (!result.containsKey("error")) { + for (String contractId : map.keySet()) { + try { + if ("success".equals(result.get(contractId))) { + String fileString = result.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + return "success"; + } else { + return "error"; + } + } + } catch (Exception e) { + return "error"; + } + return "success"; + } + +//扣款卡变更下载合同 + public String downloadDocContract(JBOTransaction tx) throws MalformedURLException, Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + String sql = ""; + sql = "flow_unid=:flow_unid and file_flag='yes'"; + String attributeId = ""; + try { + @SuppressWarnings("unchecked") + List bo = contBom.createQuery(sql).setParameter("flow_unid", FlowUnid).getResultList(true); + if (bo != null) { + Map map = new HashMap(); + for (BizObject keys : bo) { + map.put(keys.getAttribute("DOCUMENT_ID").toString(), keys.getAttribute("FULLPATH").toString()); + attributeId = keys.getAttribute("ATTRIBUTE_ID").toString(); + } + Map result = requestService.downloadDoc(map); + + if (!result.containsKey("error")) { + for (String contractId : map.keySet()) { + try { + if ("success".equals(result.get(contractId))) { + String fileString = result.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result.get(contractId))) { + return "error@"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + return "success@" + attributeId; + } else { + return "error@"; + } + } else { + System.out.println("没有文件可下载"); + return "error@"; + } + } catch (Exception e) { + e.printStackTrace(); + return "error@"; + } + } + +/** + * 扣款卡变更下载zip合同 + * @param tx + * @return + * @throws Exception + * @throws MalformedURLException + */ +public String downloadZipContract(JBOTransaction tx) throws MalformedURLException, Exception{ + requestService = (HttpRequestAppService) factory.create( + HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + try{ + String path=null; + @SuppressWarnings("unchecked") + String sql=""; + sql="flow_unid=:flow_unid and file_flag='yes'"; + @SuppressWarnings("unchecked") + List bo = contBom.createQuery(sql).setParameter("flow_unid",FlowUnid).getResultList(true); + + if(bo!=null){ + Map map=new HashMap(); + for(BizObject keys:bo){ + path="D://"+keys.getAttribute("singcontract_id").toString()+"DocList.zip"; + map.put(keys.getAttribute("singcontract_id").toString(),path); + } + String result=requestService.download(map); + if(result.equals("success")){ + return "success"; + }else{ + return "error"; + } + } + }catch(Exception e){ + return "error"; + } + return "success"; +} + + +/** + * 根据contract_id下载合同 + * @param tx + * @return + * @throws Exception + * @throws MalformedURLException + */ +public String download(JBOTransaction tx) throws MalformedURLException, Exception{ + requestService = (HttpRequestAppService) factory.create( + HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + try{ + String path=null; + @SuppressWarnings("unchecked") + List bo = contBom.createQuery("project_id=:projectId and file_flag='yes'").setParameter("projectId",ProjectId).getResultList(true); + if(bo!=null){ + Map map=new HashMap(); + for(BizObject keys:bo){ + path="D://"+keys.getAttribute("singcontract_id").toString()+"DocList.zip"; + map.put(keys.getAttribute("singcontract_id").toString(),path); + } + String result=requestService.download(map); + if(result.equals("success")){ + return "success"; + }else{ + return "error"; + } + } + }catch(Exception e){ + return "error"; + } + return "success"; +} + +/** + *jar包方式word转换pdf + *用jar方法 + *word转换pdf + */ +public void wordToPdfJar(JBOTransaction tx){ + try { + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + String sql=""; + if(flagType==null || "word".equals(flagType)){ + sql="project_id='"+ProjectId+"' and file_flag='yes' and process='1'"; + }else if("contract".equals(flagType)){ + sql="contract_id='"+contract_id+"' and file_flag='yes' and process='1'"; + }else if("pdfFalse".equals(flagType)){ + sql="project_id='"+ProjectId+"' and file_flag='yes' and process='3'"; + }else if ("flowunid".equals(flagType)){ + sql = "flow_unid='"+FlowUnid+"' and file_flag='yes' and process='1'"; + } + List bo = contBom.createQuery(sql).getResultList(false); + if(bo!=null){ + for(BizObject key:bo){ + String lastFilePath= key.getAttribute("FULLPATH").toString().replace(".docx", ".pdf"); + try { + WordToPdfThread wtpt = new WordToPdfThread(key.getAttribute("FULLPATH").toString(),lastFilePath,key.getAttribute("ATTRIBUTE_ID").toString()); + wtpt.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } catch (JBOException e) { + e.printStackTrace(); + + } +} +/** + * LibreOffice实现word转换pdf + * word转换pdf + * @throws JBOException + */ + @SuppressWarnings({ "unchecked", "static-access" }) + public void wordToPdf(JBOTransaction tx) throws JBOException { + try { + BizObjectManager fbo = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME, tx); + BizObject fbos = fbo.createQuery("FLOW_UNID=:flowunid").setParameter("flowunid", FlowUnid).getSingleResult(false); + //获取用户信息 + BizObjectManager lult = JBOFactory.getBizObjectManager(LB_UNION_LESSEE_TEMP.CLASS_NAME); + BizObjectManager customer = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME); + BizObject lults = lult.createQuery("flowunid=:flowUnid").setParameter("flowUnid", FlowUnid).getSingleResult(false); + BizObject cust = customer.createQuery("flowunid=:flowUnid and customerid=:customerid").setParameter("flowUnid", FlowUnid).setParameter("customerid", lults.getAttribute("customer_id").toString()).getSingleResult(false); + String customername = null; + String telephone = null; + String ids =null; + + if(cust!=null){ + customername = cust.getAttribute("FULLNAME").toString(); + telephone = cust.getAttribute("mobile").toString(); + ids = cust.getAttribute("CUSTOMERID").toString(); + } + + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObjectManager attrBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + WordToPDFUtil wordTopdf = new WordToPDFUtil(); + File file = null; + Boolean result = null; + String sql = ""; + /*if (flagType == null || "word".equals(flagType)) { + sql = "project_id='" + ProjectId + "' and file_flag='yes' and process='1'"; + } else if ("contract".equals(flagType)) { + sql = "contract_id='" + contract_id + "' and file_flag='yes' and process='1'"; + } else if ("pdfFalse".equals(flagType)) { + sql = "project_id='" + ProjectId + "' and file_flag='yes' and process='3'"; + } else if ("flowunid".equals(flagType)){ + sql = "flow_unid='"+FlowUnid+"' and file_flag='yes' and (process='1' or process='3')"; + }*/ + List bo = contBom.createQuery("flow_unid=:flowUnid and file_flag='yes' and process='1'").setParameter("flowUnid", FlowUnid).getResultList(true); + if (bo != null) { + for (BizObject contBo : bo) { + String attrId = contBo.getAttribute("ATTRIBUTE_ID").toString(); + BizObject attrBo = attrBom.createQuery("id='" +attrId+"'").getSingleResult(true); + String path = attrBo.getAttribute("FULLPATH").toString(); + String lastFilePath = path.replace(".docx", ".pdf"); + File filePath = new File(path); + if(!filePath.exists()){ + logger.info("word转换pdf的源文件不存在"); + continue; + } + String lastFilePathpdf = filePath.getParent(); + try { + result = wordTopdf.Word2Pdf(path, lastFilePathpdf); + } catch (Exception e) { + result = false; + e.printStackTrace(); + } + if (result) { + file =new File(lastFilePath); + contBo.setAttributeValue("FULLPATH",lastFilePath); + contBo.setAttributeValue("FILENAME",contBo.getAttribute("FILENAME").toString().replace(".docx",".pdf" )); + contBo.setAttributeValue("FILEPATH",contBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); + contBo.setAttributeValue("CONTENT_TYPE","application/pdf"); + contBo.setAttributeValue("PROCESS","2"); + contBo.setAttributeValue("PROJECT_ID",fbos.getAttribute("proj_id").toString()); + contBo.setAttributeValue("CUSTOMERNAME",customername); + contBo.setAttributeValue("TELEPHONE",telephone); + contBo.setAttributeValue("IDS",ids); + contBom.saveObject(contBo); + attrBo.setAttributeValue("FULLPATH",attrBo.getAttribute("FULLPATH").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FILENAME",attrBo.getAttribute("FILENAME").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FILEPATH",attrBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FileSize",file.length()); + attrBo.setAttributeValue("CONTENT_TYPE","application/pdf"); + attrBom.saveObject(attrBo); + }else{ + contBo.setAttributeValue("PROCESS","3"); + contBom.saveObject(contBo); + } + } + } + } catch (JBOException e) { + e.printStackTrace(); + } + } + + /** + * 租金通知书附件用LibreOffice实现word转换pdf + * word转换pdf + * @throws JBOException + */ + @SuppressWarnings({ "unchecked", "static-access" }) + public String wordToPdfAnnex(JBOTransaction tx) throws JBOException { + + PLAN_LIST=PLAN_LIST.split("\\.")[0]; + BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); + BizObject DOCRELATIVE = null; + if("null".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and OBJECTTYPE='打印催款函' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + }else if("rights".equals(PLAN_LIST)){ + DOCRELATIVE = bom.createQuery("CONTRACT_ID=:CONTRACT_ID and objecttype='rights'").setParameter("CONTRACT_ID",contract_id).getSingleResult(false); + }else if("settle".equals(PLAN_LIST)){ + DOCRELATIVE = bom.createQuery("CONTRACT_ID=:CONTRACT_ID and objecttype='settle'").setParameter("CONTRACT_ID",contract_id).getSingleResult(false); + }else if("TX".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype='AdjustInterst' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + }else if("ChangeCar".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("transfer".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='transfer' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("AdjustmentNotice".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='AdjustmentNotice' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("TriditionCollection".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionCollection' and plan_number=:plan_number").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + }else if("TriditionSuspension".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionSuspension' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); + }else if("settletradition".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='settletradition' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); + }else if("LetterApprova".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LetterApprova' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); + }else if("LoanNotice".equals(PLAN_LIST)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LoanNotice' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); + } + else{ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and plan_list=:plan_list").setParameter("plan_number",PAYMENT_NUMBER).setParameter("plan_list", PLAN_LIST).getSingleResult(false); + } + + BizObjectManager attrBom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCATTRIBUTE.CLASS_NAME); + BizObject attrBo=null; + WordToPDFUtil wordTopdf = new WordToPDFUtil(); + File file = null; + Boolean result = null; + String sql = ""; + try { + if (DOCRELATIVE != null) { + + String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); + BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); + String DOCLIBRARYid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); + attrBo = attrBom.createQuery("library_id=:library_id").setParameter("library_id", DOCLIBRARYid).getSingleResult(true); + + String path = attrBo.getAttribute("FULLPATH").toString(); + String lastFilePath = path.replace(".docx", ".pdf"); + File filePath = new File(path); + if(!filePath.exists()){ + logger.info("word转换pdf的源文件不存在"); + } + String lastFilePathpdf = filePath.getParent(); + try { + result = wordTopdf.Word2Pdf(path, lastFilePathpdf); + } catch (Exception e) { + result = false; + e.printStackTrace(); + } + if (result) { + file =new File(lastFilePath); + attrBo.setAttributeValue("FULLPATH",attrBo.getAttribute("FULLPATH").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FILENAME",attrBo.getAttribute("FILENAME").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FILEPATH",attrBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FileSize",file.length()); + attrBo.setAttributeValue("CONTENT_TYPE","application/pdf"); + attrBom.saveObject(attrBo); + }else{ + } + if("ChangeCar".equals(PLAN_LIST)){ + BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); + file =new File(lastFilePath); + ldcl.setAttributeValue("FULLPATH",lastFilePath); + ldcl.setAttributeValue("FILENAME",ldcl.getAttribute("FILENAME").toString().replace(".docx",".pdf" )); + ldcl.setAttributeValue("FILEPATH",ldcl.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); + ldcl.setAttributeValue("CONTENT_TYPE","application/pdf"); + ldcl.setAttributeValue("PROCESS","2"); + ldclManage.saveObject(ldcl); + } + } + + } catch (JBOException e) { + e.printStackTrace(); + } + return attrBo.getAttribute("ID").toString(); + } + /** + * 多线程word转换pdf + * @author tenwa518 + * + */ +class WordToPdfThread extends Thread{ + final String fullPath; + final String lastFilePath; + final String attrId; + public WordToPdfThread(String fullPath,String lastFilePath,String attrId){ + this.fullPath = fullPath; + this.lastFilePath = lastFilePath; + this.attrId = attrId; + + } + @Override + public void run() { + Word2PdfUtil wP = new Word2PdfUtil(); +// WordToPDFUtil w2P = new WordToPDFUtil(); + try { +// w2P.Word2Pdf(fullPath, lastFilePathpdf); + wP.doc2pdf(fullPath,lastFilePath,attrId); + } catch (Exception e) { + e.printStackTrace(); + } + } +} +/** + * 查看word文件是否都转为pdf + * @param tx + * @return + * @throws JBOException + */ +public String getMakeContractProcess(JBOTransaction tx) throws JBOException{ + BizObjectManager ldclBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + int wordIng=0; + int pdfFalse=0; + int pdfTrue=0; + List ldclBo2=ldclBom.createQuery("project_id='"+ProjectId+"' and file_flag='yes' ").getResultList(false); + if(ldclBo2.size()>0){ + for(BizObject key:ldclBo2){ + String process = key.getAttribute("process").toString(); + if("1".equals(process)){ + wordIng++; +// return "error"; + }else if("2".equals(process)){ + pdfTrue++; +// return "wording"; + }else if("3".equals(process)){ + pdfFalse++; +// return "success"; + } + } + }else{ + //制作合同 + return "0"; + } + if(wordIng>0 && pdfFalse>0 && pdfTrue>0){ + //word转换PDF部分失败 + return "1"; + }else if(wordIng==0 && pdfFalse>0 && pdfTrue>0){ + //word转PDF失败 + return "2"; + }else if(wordIng==0 && pdfFalse>0 && pdfTrue>0){ + //word转换PDF部分失败, + return "3"; + }else if(wordIng>0 && pdfFalse==0 && pdfTrue>0){ + //word正在转换pdf + return "4"; + }else if(wordIng>0 && pdfFalse==0 && pdfTrue==0){ + //word没有转换pdf + return "5"; + }else if(wordIng==0 && pdfFalse==0 && pdfTrue>0){ + //word转换PDF成功 + return "6"; + } + return "error"; +} +//(扣款卡变更)根据合同号获取文件状态 +public String getMakeContractProcessContract(JBOTransaction tx) throws JBOException{ + BizObjectManager ldclBom=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + BizObject ldclBo = null; + ldclBo=ldclBom.createQuery("flow_unid='"+FlowUnid+"'and file_flag='yes' ").getSingleResult(false); + if(ldclBo!=null){ + String process = ldclBo.getAttribute("process").toString(); + String signType = ldclBo.getAttribute("sign_type").toString(); + if("1".equals(process)){ + return "isDoc"; + }else if("2".equals(process)&&"DRAFT".equals(signType)){ + return "isPdf"; + }else if("COMPLETE".equals(signType)){ + return "complete"; + }else if("SIGNING".equals(signType)){ + return "isSigning"; + } + } + //表示不存在这个文件 + return "notExsit"; +} +/** + * 转账授权申请书 + * @param tx + * @return + * @throws InterruptedException + */ +@SuppressWarnings("unchecked") +public String AccountAccreditSign(JBOTransaction tx){ + try{ + this.wordToPdf(tx); + tx.commit(); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + List boList = contBom.createQuery("file_flag='yes' and (process='2' or process='5') and flow_unid='"+FlowUnid+"'").getResultList(true); + if(boList.size()>0){ + try { + String result =this.accountSign(tx,FlowUnid,InputOrgid); + if("success".equals(result)){ + return "success"; + }else{ + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + }else{ + return "error"; + } + } catch (JBOException e) { + e.printStackTrace(); + return "error"; + } +} +public String accountSign(JBOTransaction tx,String flowunid,String orgid) throws Exception{ + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager attrBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + Map map=new HashMap(); + ContractSignInfo con=null; + BizObject ldclBo=null; + try{ + //查询lb_doc_contract_list表 + ldclBo = ldclBom.createQuery("file_flag='yes' and process='2' and flow_unid='" + flowunid + "'").getSingleResult(true); + if (ldclBo != null) { + con = new ContractSignInfo(); + con.setFileid(ldclBo.getAttribute("ATTRIBUTE_ID").toString()); + con.setFilename(ldclBo.getAttribute("FILENAME").toString()); + // 获取生成文件路径 + String makefullPath = ldclBo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(flowunid, con); + Map resultMap = null; + if (orgid.indexOf("8002003001") >= 0) { + // 西城转账授权 + resultMap = requestService.createAccountContractSign(map); + } else { + // 东城转账授权 + resultMap = requestService.createAccountContractDSign(map); + } + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + ldclBo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + ldclBo.setAttributeValue("SINGCONTRACT_ID", resultMap.get("contract_" + key)); + } + } + ldclBo.setAttributeValue("PROCESS", "5"); + ldclBom.saveObject(ldclBo); + tx.commit(); + } else { + return "error"; + } + } + //拉取文件 + ldclBo = ldclBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + flowunid + "'").getSingleResult(true); + if (ldclBo != null) { + BizObject attrBo = attrBom.createQuery("id='"+ldclBo.getAttribute("attribute_id")+"'").getSingleResult(true); + Map mapFile = new HashMap(); + String fileName = ldclBo.getAttribute("FILENAME").toString(); + String fullPath =FileOperatorUtil.getuploadFileDir(this.getFileSavePath())+UUIDUtil.getUUID()+"_"+fileName; + String filePath = fullPath.replaceAll(this.getFileSavePath(),""); + mapFile.put(ldclBo.getAttribute("DOCUMENT_ID").toString(),fullPath); + Map result = requestService.downloadDoc(mapFile); + if (!result.containsKey("error")) { + for (String documentId : mapFile.keySet()) { + try { + if ("success".equals(result.get(documentId))) { + String fileString = result.get("file_" + documentId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(mapFile.get(documentId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result.get(documentId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + ldclBo.setAttributeValue("FILEPATH",filePath); + ldclBo.setAttributeValue("FULLPATH",fullPath); + ldclBo.setAttributeValue("PROCESS", "6"); + ldclBom.saveObject(ldclBo); + attrBo.setAttributeValue("FILEPATH",filePath); + attrBo.setAttributeValue("FULLPATH",fullPath); + attrBo.setAttributeValue("FileSize",new File(fullPath).length()); + attrBom.saveObject(attrBo); + return "success"; + } else { + return "error"; + } + } else { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + +} +public String getFlowUnid(JBOTransaction tx) throws JBOException{ + BizObjectManager fboBom=JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME,tx); + BizObject fboBo=fboBom.createQuery("CHANNELAPPLYID='"+id+"'").getSingleResult(false); + return fboBo.getAttribute("flow_unid").toString(); +} + +/* + * 重新发送短信 + * */ +public String sendMessageAgain(JBOTransaction tx) { + try{ + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + List bo = null; + String file = new String(); + Map contractmap = new HashMap(); + List list = new ArrayList(); + 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).getResultList(true); + for (BizObject temp : bo) { + String singcontractid = temp.getAttribute("singcontract_id").toString(); + String filename = temp.getAttribute("filename").toString(); + contractmap.put(singcontractid, filename); + } + list.addAll(contractmap.keySet()); + Map map = requestService.sendNotice(list); + if(!map.containsKey("error")){ + return "success"; + }else{ + for(String singcontractid:map.keySet()){ + String sendStatus = map.get(singcontractid); + if("2"==sendStatus){ + file += contractmap.get(singcontractid)+";"; + } + } + return file; + } + + } catch (Exception e) { + try { + tx.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + return "error"; + } +} + + /* + * 扣款卡信息变更重新发送短信 + * */ + public String ChangesendMessageAgain(JBOTransaction tx) { + try{ + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + List bo = null; + String file = new String(); + Map contractmap = new HashMap(); + List list = new ArrayList(); + BizObjectManager ldMange = JBOFactory.getBizObjectManager(LB_DOCRELATIVE.CLASS_NAME, tx); + String status = ""; + String peopleStatus=""; + String sql = "OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid "; + @SuppressWarnings("unchecked") + BizObject ldb = ldMange.createQuery(sql).setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); + if(ldb!=null){ + String singcontractid = ldb.getAttribute("TEMPLATE_ID").toString(); + contractmap.put(singcontractid, "直租个人授权协议书.pdf"); + } + list.addAll(contractmap.keySet()); + Map map = requestService.sendNotice(list); + if(!map.containsKey("error")){ + return "success"; + }else{ + for(String singcontractid:map.keySet()){ + String sendStatus = map.get(singcontractid); + if("2"==sendStatus){ + file += contractmap.get(singcontractid)+";"; + } + } + return file; + } + + } catch (Exception e) { + try { + tx.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + return "error"; + } + } + +public String getProcess(JBOTransaction tx){ + try { + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObject bo = contBom.createQuery("file_flag='yes' and process is not null and flow_unid='"+FlowUnid+"'").getSingleResult(false); + if(bo==null){ + return "success"; + }else{ + return bo.getAttribute("PROCESS").toString(); + } + } catch (JBOException e) { + e.printStackTrace(); + return "error"; + } + +} + +public String claimSign(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + ContractSignInfo con = null; + BizObject bo = null; + String doc_name = new String(); + String[] attrIdList=attrId.split("@"); + try{ + for(String attribute_id:attrIdList){ + Map map=new HashMap(); + bo = contBom.createQuery("file_flag='yes' and process='2' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); + if(bo != null){ + con = new ContractSignInfo(); + con.setFileid(attribute_id); + con.setFilename(bo.getAttribute("FILENAME").toString()); + String makefullPath = bo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(FlowUnid, con); + Map resultMap = null; + //调代理的接口 + doc_name = bo.getAttribute("doc_name").toString(); + if("租金支付表".equals(doc_name)){ + //租金支付表 + resultMap = requestService.createPaymentofHireSign(map); + } + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + bo.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); + bo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + } + } + bo.setAttributeValue("PROCESS", "5"); + contBom.saveObject(bo); + tx.commit(); + } else { + return "error"; + } + } + bo = contBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); + if (bo != null) { + Map map1 = new HashMap(); + map1.put(bo.getAttribute("DOCUMENT_ID").toString(), bo.getAttribute("FULLPATH").toString()); + Map result1 = requestService.downloadDoc(map1); + if (!result1.containsKey("error")) { + for (String contractId : map1.keySet()) { + try { + if ("success".equals(result1.get(contractId))) { + String fileString = result1.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result1.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + bo.setAttributeValue("PROCESS", "6"); + contBom.saveObject(bo); + } else { + return "error"; + } + } else { + return "error"; + } + } + return "success"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } +} + + /** + * 打印租金通知书并发短信给客户 + * @param tx + * @return + * @throws Exception + */ + public String claimSignA(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + String libraryid=""; + PLAN_LIST=PLAN_LIST.split("\\.")[0]; + BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); + BizObject DOCRELATIVE=bom.createQuery("plan_number=:plan_number and plan_list=:plan_list").setParameter("plan_number",PAYMENT_NUMBER).setParameter("plan_list", PLAN_LIST).getSingleResult(false); + if (DOCRELATIVE != null) { + String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); + BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); + libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); + } + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + ContractSignInfo con = null; + BizObject bo = null; +// String contract_id=""; + String info=""; + try{ + //获取承租人的姓名和电话号 + BizObjectManager lulManager = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME, tx); + String customerid = lulManager.createQuery("CONTRACT_ID=:contractId").setParameter("contractId", contract_id).getSingleResult(false).getAttribute("CUSTOMER_ID").toString(); + BizObjectManager crManage = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); + BizObject cr = crManage.createQuery("CUSTOMERID=:customerid").setParameter("customerid", customerid).getSingleResult(false); + if(cr != null){ + info = cr.getAttribute("FULLNAME").toString() + "@" + cr.getAttribute("mobile").toString()+"@"+flagType; + }else{ + info = "flagType@flagType@"+flagType; + } + //获取需要盖章的文件信息 + Map map=new HashMap(); + bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); + if(bo != null){ + id = bo.getAttribute("id").toString(); + con = new ContractSignInfo(); + con.setFileid(id); + con.setFilename(bo.getAttribute("FILENAME").toString()); + String makefullPath = bo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(info, con); + Map resultMap = null; + //调代理的接口 +// doc_name = bo.getAttribute("doc_name").toString(); +// if("租金支付表".equals(doc_name)){ + //租金支付表 + resultMap = requestService.createPaymentofHireSign(map); +// } + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { +// bo.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); +// bo.setAttributeValue("DOCUMENT_ID", resultMap.get(key)); + contract_id = resultMap.get(key); + } + } +// bo.setAttributeValue("PROCESS", "5"); +// contBom.saveObject(bo); +// tx.commit(); + } else { + return "error"; + } + } +// bo = contBom.createQuery("file_flag='yes' and process='5' and flow_unid='" + FlowUnid + "' and attribute_id= '"+attribute_id+"'").getSingleResult(true); + if (bo != null) { + Map map1 = new HashMap(); + map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); + Map result1 = requestService.downloadDoc(map1); + if (!result1.containsKey("error")) { + for (String contractId : map1.keySet()) { + try { + if ("success".equals(result1.get(contractId))) { + String fileString = result1.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result1.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } +// bo.setAttributeValue("PROCESS", "6"); +// contBom.saveObject(bo); + } else { + return "error"; + } + } else { + return "error"; + } + + return "success"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + /** + * 扣款卡信息变更发电子签约 + * @param tx + * @return + * @throws Exception + */ + public String changeCarSignA(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + String libraryid=""; + BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME,tx); + BizObjectManager bom1=null; + BizObject DOCRELATIVE= null; + BizObject library= null; + DOCRELATIVE=bom.createQuery("OBJECTTYPE='ChangeCar' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(true); + if (DOCRELATIVE != null) { + String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); + bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME,tx); + library=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(true); + libraryid = library.getAttribute("id").toString(); + } + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + ContractSignInfo con = null; + BizObject bo = null; +// String contract_id=""; + String info=""; + try{ + //获取承租人的姓名和电话号 + BizObjectManager lulManager = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME, tx); + String customerid = lulManager.createQuery("CONTRACT_ID=:contractId").setParameter("contractId", contract_id).getSingleResult(false).getAttribute("CUSTOMER_ID").toString(); + BizObjectManager crManage = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME, tx); + BizObject cr = crManage.createQuery("CUSTOMERID=:customerid").setParameter("customerid", customerid).getSingleResult(false); + if(cr != null){ + info = cr.getAttribute("FULLNAME").toString() + "@" + cr.getAttribute("mobile").toString()+"@"+flagType; + }else{ + return "error"; + } + //获取需要盖章的文件信息 + Map map=new HashMap(); + bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); + if(bo != null){ + id = bo.getAttribute("id").toString(); + con = new ContractSignInfo(); + con.setFileid(id); + con.setFilename(bo.getAttribute("FILENAME").toString()); + String makefullPath = bo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(info, con); + Map resultMap = null; + resultMap = requestService.createAccountContractDSign(map); + + if (!resultMap.containsKey("error")) { + BizObjectManager ldclManage=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObject ldcl = ldclManage.createQuery(" FLOW_UNID=:flowunid and CONTRACT_ID=:contractid and file_flag='yes' ").setParameter("flowunid", FlowUnid).setParameter("contractid", contract_id).getSingleResult(true); + if(ldcl != null){ + ldcl.setAttributeValue("sign_type", "SIGNING"); + ldclManage.saveObject(ldcl); + } + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { +// DOCRELATIVE.setAttributeValue("SINGCONTRACT_ID",resultMap.get("contract_" + key)); + DOCRELATIVE.setAttributeValue("TEMPLATE_ID", resultMap.get("contract_" + key)); + library.setAttributeValue("REMARK",resultMap.get(key)); + bo.setAttributeValue("REMARK","SIGNING"); + contract_id = resultMap.get(key); + } + } + bom.saveObject(DOCRELATIVE); + bom1.saveObject(library); + contBom.saveObject(bo); + tx.commit(); + } else { + return "error"; + } + } + return "success"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + /** + * 催收函盖公司章 + * @param tx + * @return + * @throws Exception + */ + public String collectionSignA(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + String libraryid=""; + BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); + BizObject DOCRELATIVE = null; + if("settle".equals(flagType)){ + DOCRELATIVE=bom.createQuery("CONTRACT_ID=:contractid and objecttype='settle' ").setParameter("contractid",contract_id).getSingleResult(false); + }else if("LetterApprova".equals(flagType)){ + DOCRELATIVE=bom.createQuery("PROJ_ID=:projectId and objecttype='LetterApprova' ").setParameter("projectId",ProjectId).getSingleResult(false); + }else{ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype LIKE '%打印催款函%' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + } + if (DOCRELATIVE != null) { + String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); + BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); + libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); + } + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + ContractSignInfo con = null; + BizObject bo = null; + String info=""; + try{ + info = libraryid + "@" + libraryid+"@"+flagType; + //获取需要盖章的文件信息 + Map map=new HashMap(); + bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); + if(bo != null){ + id = bo.getAttribute("id").toString(); + con = new ContractSignInfo(); + con.setFileid(id); + con.setFilename(bo.getAttribute("FILENAME").toString()); + String makefullPath = bo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(info, con); + Map resultMap = null; + resultMap = requestService.createPaymentofHireSign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + contract_id = resultMap.get(key); + } + } + } else { + return "error"; + } + } + if (bo != null) { + Map map1 = new HashMap(); + map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); + Map result1 = requestService.downloadDoc(map1); + if (!result1.containsKey("error")) { + for (String contractId : map1.keySet()) { + try { + if ("success".equals(result1.get(contractId))) { + String fileString = result1.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result1.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + } else { + return "error"; + } + } else { + return "error"; + } + + return "success"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + + + /*** + * 已经生成的合同,作废, + * @param tx + * @return + * @throws JBOException + */ + + public String updateDocContractStatus(JBOTransaction tx) throws JBOException{ +// BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx);ProjectId + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager lpiManager=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); + try{ +// BizObject lcl = lclManager.createQuery("file_flag='yes' and attribute_id='"+file_id+"'").getSingleResult(true); + + lclManager.createQuery("update O set file_flag='no',message='1' where attribute_id=:attributeid").setParameter("attributeid",file_id).executeUpdate(); + lpiManager.createQuery("update O set PROJECT_STATUS=13 where id=:id").setParameter("id",ProjectId).executeUpdate(); + //attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + tx.commit(); + }catch(Exception e){ + tx.rollback(); + e.printStackTrace(); + System.out.println(e.getMessage()); + return "error"; + } + return "success"; + } + + public String companyUpdateDocContractStatus(JBOTransaction tx) throws Exception{ + BizObjectManager fboManger=JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME,tx); + BizObjectManager lctManger=JBOFactory.getBizObjectManager(LB_CONTRACT_TEMPLATE.CLASS_NAME,tx); + BizObject fbo = fboManger.createQuery("flow_unid=:flowunid").setParameter("flowunid",FlowUnid).getSingleResult(false); + BizObject lct = lctManger.createQuery("Contract_id=:contractid").setParameter("contractid", fbo.getAttribute("CONTRACT_ID").getString()).getSingleResult(false); + String attId = ContractTemplateCache.getContractTemplateID(lct.getAttribute("ID").getString()); + lctManger.deleteObject(lct); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager lpiManager=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); + try{ + lclManager.createQuery("update O set file_flag='no',message='1' where attribute_id=:attributeid").setParameter("attributeid",attId).executeUpdate(); + lpiManager.createQuery("update O set PROJECT_STATUS=13 where id=:id").setParameter("id",ProjectId).executeUpdate(); + //attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + tx.commit(); + }catch(Exception e){ + tx.rollback(); + e.printStackTrace(); + System.out.println(e.getMessage()); + return "error"; + } + return "success"; + } + + /** + * 传统合同盖章 + * @param tx + * @return + * @throws Exception + + */ + public String TcollectionSignA(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + String libraryid=""; + BizObjectManager bom=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME); + BizObject DOCRELATIVE = null; + if("transfer".equals(flagType)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='transfer' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("AdjustmentNotice".equals(flagType)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='AdjustmentNotice' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("TriditionCollection".equals(flagType)){ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype='TriditionCollection' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + }else if("TriditionSuspension".equals(flagType)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='TriditionSuspension' and FLOW_UNID=:flowunid ").setParameter("flowunid",FlowUnid).getSingleResult(false); + }else if("settletradition".equals(flagType)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='settletradition' and FLOW_UNID=:flowunid and CONTRACT_ID=:contractid ").setParameter("flowunid",FlowUnid).setParameter("contractid",contract_id).getSingleResult(false); + }else if("LoanNotice".equals(flagType)){ + DOCRELATIVE=bom.createQuery(" OBJECTTYPE='LoanNotice' and PROJ_ID=:projectId ").setParameter("projectId",ProjectId).getSingleResult(false); + }else{ + DOCRELATIVE=bom.createQuery("plan_number=:plan_number and objecttype LIKE '%打印催款函%' ").setParameter("plan_number",PAYMENT_NUMBER).getSingleResult(false); + } + if (DOCRELATIVE != null) { + String DOCRELATIVEid=DOCRELATIVE.getAttribute("id").toString(); + BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); + libraryid=bom1.createQuery("relative_id=:relative_id").setParameter("relative_id", DOCRELATIVEid).getSingleResult(false).getAttribute("id").toString(); + } + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME, tx); + ContractSignInfo con = null; + BizObject bo = null; + String info=""; + try{ + info = libraryid + "@" + libraryid+"@"+flagType; + //获取需要盖章的文件信息 + Map map=new HashMap(); + bo = contBom.createQuery("library_id=:libraryid").setParameter("libraryid", libraryid).getSingleResult(true); + if(bo != null){ + id = bo.getAttribute("id").toString(); + con = new ContractSignInfo(); + con.setFileid(id); + con.setFilename(bo.getAttribute("FILENAME").toString()); + String makefullPath = bo.getAttribute("FULLPATH").toString(); + File file = new File(makefullPath); + if (!file.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + con.setInputfile(BASE64.encodeImgageToBase64(file)); + map.put(info, con); + Map resultMap = null; + resultMap = requestService.createPaymentofHireSign(map); + if (!resultMap.containsKey("error")) { + for (String key : resultMap.keySet()) { + if (key.indexOf("contract_") == -1) { + contract_id = resultMap.get(key); + } + } + } else { + return "error"; + } + } + if (bo != null) { + Map map1 = new HashMap(); + map1.put(contract_id, bo.getAttribute("FULLPATH").toString()); + Map result1 = requestService.downloadDoc(map1); + if (!result1.containsKey("error")) { + for (String contractId : map1.keySet()) { + try { + if ("success".equals(result1.get(contractId))) { + String fileString = result1.get("file_" + contractId); + InputStream fileInput = BASE64.encodeFileToBase64(fileString); + OutputStream fileOut = new FileOutputStream(map1.get(contractId));// TODO + byte[] buffByte = new byte[1024]; + int size = 0; + while ((size = fileInput.read(buffByte)) != -1) { + fileOut.write(buffByte, 0, size); + } + fileInput.close(); + fileOut.close(); + } else if ("error".equals(result1.get(contractId))) { + return "error"; + } + } catch (Exception e) { + e.printStackTrace(); + + } + } + } else { + return "error"; + } + } else { + return "error"; + } + + return "success"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + //生成一维 + public String SystemMakeOneDimensionalCode(JBOTransaction tx){ + Configure CurConfig = Configure.getInstance(); + try { + String diskPath=CurConfig.getConfigure("OneDimensionalCode"); + MakeOneCodeAndContractModel mocacm = new MakeOneCodeAndContractModel(); + BizObjectManager loManage = JBOFactory.getBizObjectManager(LB_ONEDIMENSIONALCODE.CLASS_NAME,tx); + BizObject lom = loManage.createQuery(" PROJECT_ID=:projectid and CONTRACT_NO=:contractNo and CONTRACT_ID=:contractId").setParameter("projectid", ProjectId).setParameter("contractNo", contractNo).setParameter("contractId", contract_id).getSingleResult(false); + if(lom == null){ + //生成一维码 + mocacm.MOneDimensionalCode(contractNo, contract_id, ProjectId, diskPath, tx); + } + String outPdfFile = CurConfig.getConfigure("BQcontract"); + mocacm.pdfAndMark(outPdfFile, "", contract_id,leasform, tx); + }catch (Exception e) { + e.printStackTrace(); + return "error"; + } + return "success"; + } } \ No newline at end of file diff --git a/src_tenwa/com/tenwa/lease/flow/project/commcheck/MakingContractCarCheck.java b/src_tenwa/com/tenwa/lease/flow/project/commcheck/MakingContractCarCheck.java index f5997e2df..d5c56ba7d 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/commcheck/MakingContractCarCheck.java +++ b/src_tenwa/com/tenwa/lease/flow/project/commcheck/MakingContractCarCheck.java @@ -42,7 +42,7 @@ public class MakingContractCarCheck extends DefaultBussinessCheck { if(ldcl!=null){ BizObject psl = psltMange.createQuery("productid=:productid").setParameter("productid", lcit.getAttribute("PRODUCT_ID").getString()).getSingleResult(false); if(psl!=null){ - if("03".equals(ci.getAttribute("CUSTOMERTYPE").getString())&&!"BAIC_MOTOR".equals(psl.getAttribute("operationType").toString())&&!"DYCD".equals(psl.getAttribute("operationType").toString())&&!"ZYC".equals(psl.getAttribute("operationType").toString())&&!"KJZL".equals(psl.getAttribute("operationType").toString())){ + if("03".equals(ci.getAttribute("CUSTOMERTYPE").getString())&&!"BAIC_MOTOR".equals(psl.getAttribute("operationType").toString())&&!"DYCD".equals(psl.getAttribute("operationType").toString())&&!"ZYC".equals(psl.getAttribute("operationType").toString())&&!"KJZL".equals(psl.getAttribute("operationType").toString())&&!"KHSQ".equals(psl.getAttribute("operationType").toString())){ if("4".equals(ldcl.getAttribute("PROCESS").getString())){ putMsg("已完成电子签约!"); setPass(true);