diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp new file mode 100644 index 000000000..0d7f2142a --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBContract/LBContractPrintList.jsp @@ -0,0 +1,328 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2017-09-28 + Content: + History Log: + */ + String custtype = CurPage.getParameter("CustomerType"); + String projectId = CurPage.getParameter("ProjectId"); +// String signStatus = CurPage.getParameter("SignStatus"); + String contractNumber = CurPage.getParameter("ContractNumber"); + String productId = CurPage.getParameter("ProductId"); + String flowunid = CurPage.getParameter("FlowUnid"); + String action = CurPage.getParameter("action"); + ASObjectModel doTemp = new ASObjectModel("LBContractPrintList"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(20); + String id=projectId; + dwTemp.genHTMLObjectWindow(id+","+flowunid); + String btnflag = "true"; + String btnflagcom = "false"; + if("01".equals(custtype)){ + btnflagcom = "true"; + } + if("queryContract".equals(action)){ + btnflag = "false"; + btnflagcom = "false"; + } + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + {btnflag,"","Button","发起电子签约","电子签章合同","signOnLine()","","","","btn_icon_sign",""}, + {btnflag,"","Button","查询签约结果","查询签约结果","getStatus()","","","","btn_icon_obtain",""}, + {btnflag,"","Button","重新发送短信","重新发送短信","sendMessageAgain()","","","","btn_icon_refresh",""}, + {btnflagcom,"","Button","下载纸质合同","下载纸质合同","downFile()","","","","btn_icon_down",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + + +<%@ include file="/Frame/resources/include/include_end.jspf"%> diff --git a/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp b/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp index c3b7722c4..36a8837ad 100644 --- a/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp +++ b/WebContent/Tenwa/Lease/Flow/Comm/LBContractTemplate/contract_template.jsp @@ -198,7 +198,6 @@ alert("请勾选合同模板!"); return; } -alert(tempids); var param={}; var tempParam={}; var sparam=""; @@ -225,6 +224,7 @@ alert(tempids); if(sReturn0.length>2){ alert(sReturn0); }else{ + RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","wordToPdf","FlowUnid=<%=flowunid%>,flagType=word"); alert("生成成功"); } reloadSelf(); diff --git a/WebContent/Tenwa/Lease/Flow/Contract/ContractApproval/ContractApprovalApplyList.jsp b/WebContent/Tenwa/Lease/Flow/Contract/ContractApproval/ContractApprovalApplyList.jsp index 855072368..be2876198 100644 --- a/WebContent/Tenwa/Lease/Flow/Contract/ContractApproval/ContractApprovalApplyList.jsp +++ b/WebContent/Tenwa/Lease/Flow/Contract/ContractApproval/ContractApprovalApplyList.jsp @@ -16,11 +16,13 @@ //alert(getHtmlMessage('1'));//请选择一条信息! return; } + debugger; sReturn = sReturn.split("@"); var id=sReturn[0]; var product_id=sReturn[1]; var project_id = sReturn[2]; var project_name = sReturn[3]; + var customertype = sReturn[4]; var sParams = "ApplyType=<%=sApplyType%>,CurUserID=<%=CurUser.getUserID()%>"; sParams =sParams+",ProductId="+product_id+",ProjectId="+id+",ProjectNo="+project_id+",ProjectName="+project_name+",ApplyType=<%=sApplyType%>"; var sReturnInfo = RunJavaMethodTrans("com.tenwa.lease.flow.contract.contractapproval.ContractApprovalStartAction","initFLow",sParams); diff --git a/WebContent/WEB-INF/lib/aspose-words-18.1-jdk16.jar b/WebContent/WEB-INF/lib/aspose-words-18.1-jdk16.jar new file mode 100644 index 000000000..25610609d Binary files /dev/null and b/WebContent/WEB-INF/lib/aspose-words-18.1-jdk16.jar differ diff --git a/src/com/tenwa/channelportal/action/ContractSignAction.java b/src/com/tenwa/channelportal/action/ContractSignAction.java new file mode 100644 index 000000000..c4aeff29c --- /dev/null +++ b/src/com/tenwa/channelportal/action/ContractSignAction.java @@ -0,0 +1,1677 @@ +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_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.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; +import jbo.com.tenwa.lease.comm.BUSINESS_STATUS; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_SIGN_LOG; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_TEMPLATE; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; +import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE_TEMP; +import jbo.sys.CODE_LIBRARY; +import jbo.sys.USER_INFO; +import sun.security.krb5.Config; + +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.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; + 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; + } + + + /** + * 自然人电子签约 + * + * @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 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); + // 查询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[] customerName = keys.getAttribute("CUSTOMERNAME").toString().split(","); + String docName = keys.getAttribute("DOC_NAME").toString(); + // 自然人和调查表 + 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 = 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("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 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"; + } + } + + /** + * 法人租金委托代偿电子签约 + * @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 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); + String status = ""; + 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 signStatus = requestService.getContractSignStatus(key); + 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)) { + 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("project_status", "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 { + return status.substring(5); + } + } + /** + * 获取电子签约状态 + *待完善 + * @throws Exception + */ + public String contractSignStatusList(JBOTransaction tx) throws Exception { + requestService = (HttpRequestAppService) factory.create(HttpRequestAppService.class, this.getConfigRequestUrl()); + BizObjectManager pbm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.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); + String status = ""; + String sql = ""; + List 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()); + 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"; + } + +//扣款卡变更下载合同 + 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 = cust.getAttribute("FULLNAME").toString(); + String telephone = cust.getAttribute("mobile").toString(); + String 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(); + } + } + /** + * 多线程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 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 JBOException + */ + + public String updateDocContractStatus(JBOTransaction tx) throws JBOException{ +// BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.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(); + //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"; + } + +} \ No newline at end of file diff --git a/src/com/tenwa/channelportal/action/generativecontract/Word2PdfUtil.java b/src/com/tenwa/channelportal/action/generativecontract/Word2PdfUtil.java new file mode 100644 index 000000000..d1e521e72 --- /dev/null +++ b/src/com/tenwa/channelportal/action/generativecontract/Word2PdfUtil.java @@ -0,0 +1,104 @@ +package com.tenwa.channelportal.action.generativecontract; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; + +import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; +import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; + +import org.apache.log4j.Logger; + +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.aspose.words.Document; +import com.aspose.words.License; +import com.aspose.words.SaveFormat; + +public class Word2PdfUtil { + private static Logger logger = Logger.getLogger(Word2PdfUtil.class); + public static void main(String[] args) throws Exception { +// doc2pdf("D:/光大金融租赁公司融资租赁合同(201801-200385).docx", "D:/光大融资租赁公司抵押合同(201801-200385-D001).pdf","aa"); + } + + public static boolean getLicense() { + boolean result = false; + try { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("license.xml"); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + public static void doc2pdf(String inPath,String outPath,String attrid) throws JBOException { + if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生 + return; + } + Boolean flag=false; + try { + File inputFile = new File(inPath); + if (!inputFile.exists()) { + throw new RuntimeException("要读取的文件不存在"); + } + long old = System.currentTimeMillis(); + logger.info("============转换pdf开始============"); + File file = new File(outPath); // 新建一个空白pdf文档 + FileOutputStream os = new FileOutputStream(file); + Document doc = new Document(inPath); // Address是将要被转化的word文档 + doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, + // EPUB, XPS, SWF 相互转换 + long now = System.currentTimeMillis(); + logger.info("共耗时:" + (now - old) + "毫秒"); + logger.info("============转换pdf结束============"); + } catch (Exception e) { + e.printStackTrace(); + flag=true; + }finally{ + JBOTransaction tx = JBOFactory.createJBOTransaction(); + BizObjectManager contBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager attrBom = JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + if(flag){ + File file =new File(inPath); + BizObject contBo = contBom.createQuery("attribute_id='"+attrid+"'").getSingleResult(true); + contBo.setAttributeValue("FULLPATH",inPath); + contBo.setAttributeValue("FILENAME",contBo.getAttribute("FILENAME").toString().replace(".pdf",".docx" )); + contBo.setAttributeValue("FILEPATH",contBo.getAttribute("FILEPATH").toString().replace(".pdf", ".docx")); + contBo.setAttributeValue("CONTENT_TYPE","application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + contBo.setAttributeValue("PROCESS","3"); + contBom.saveObject(contBo); + BizObject attrBo = attrBom.createQuery("id='"+attrid+"'").getSingleResult(true); + attrBo.setAttributeValue("FULLPATH",inPath); + attrBo.setAttributeValue("FILENAME",contBo.getAttribute("FILENAME").toString().replace(".pdf", ".docx")); + attrBo.setAttributeValue("FILEPATH",contBo.getAttribute("FILEPATH").toString().replace(".pdf", ".docx")); + attrBo.setAttributeValue("FileSize",file.length()); + attrBo.setAttributeValue("CONTENT_TYPE","application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + attrBom.saveObject(attrBo); + tx.commit(); + }else{ + BizObject contBo = contBom.createQuery("attribute_id='"+attrid+"'").getSingleResult(true); + File file =new File(outPath); + contBo.setAttributeValue("FULLPATH",outPath); + 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"); + contBom.saveObject(contBo); + BizObject attrBo = attrBom.createQuery("id='"+attrid+"'").getSingleResult(true); + attrBo.setAttributeValue("FULLPATH",outPath); + attrBo.setAttributeValue("FILENAME",contBo.getAttribute("FILENAME").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FILEPATH",contBo.getAttribute("FILEPATH").toString().replace(".docx", ".pdf")); + attrBo.setAttributeValue("FileSize",file.length()); + attrBo.setAttributeValue("CONTENT_TYPE","application/pdf"); + attrBom.saveObject(attrBo); + tx.commit(); + } + } + } +} \ No newline at end of file diff --git a/src/com/tenwa/channelportal/action/generativecontract/WordToPDFUtil.java b/src/com/tenwa/channelportal/action/generativecontract/WordToPDFUtil.java new file mode 100644 index 000000000..2383f0721 --- /dev/null +++ b/src/com/tenwa/channelportal/action/generativecontract/WordToPDFUtil.java @@ -0,0 +1,54 @@ +package com.tenwa.channelportal.action.generativecontract; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; + +import org.apache.log4j.Logger; +public class WordToPDFUtil { + private static Logger logger = Logger.getLogger(WordToPDFUtil.class); + // 将word格式的文件转换为pdf格式 + public synchronized static Boolean Word2Pdf(String srcPath, String desPath) throws Exception { + // 源文件目录 + File inputFile = new File(srcPath); + if (!inputFile.exists()) { + System.out.println("word转换pdf,源文件不存在"); + return false; + } + // 输出文件目录 + File outputFile = new File(desPath); + if (!outputFile.getParentFile().exists()) { + outputFile.getParentFile().mkdirs(); + } + Process process = null; + //获取当前时间的毫秒数 + long start= System.currentTimeMillis(); + logger.info("============转换pdf开始============"); + try{ + String cmd = "D:\\office\\program\\soffice --headless -invisible --convert-to pdf "+srcPath+" --outdir "+desPath; + logger.info("python:"+cmd); + process = Runtime.getRuntime().exec(cmd); + String cmdMsg = ""; + BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream())); + while((cmdMsg=bufferedReader.readLine()) !=null){ + logger.info(cmdMsg); + } + process.waitFor(); + }catch(Exception e){ + e.printStackTrace(); + return false; + }finally{ + if(null!=process){ + process.destroy(); + } + long end = System.currentTimeMillis(); + //输出转换pdf所需毫秒数 + logger.info(end-start+"毫秒"); + logger.info("============转换pdf结束============"); + } + return true; + } + + public static void main(String[] args) throws Exception { + WordToPDFUtil.Word2Pdf("d:\\1、光大金融租赁公司融资租赁合同(法人)—保证保险模式.doc", "d:\\woqu"); + } +} diff --git a/src_core/com/tenwa/doc/util/BASE64.java b/src_core/com/tenwa/doc/util/BASE64.java new file mode 100644 index 000000000..552374f44 --- /dev/null +++ b/src_core/com/tenwa/doc/util/BASE64.java @@ -0,0 +1,47 @@ +package com.tenwa.doc.util; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import sun.misc.BASE64Decoder; +import sun.misc.BASE64Encoder; + +public class BASE64 { + /** + * 将本地图片进行Base64位编码 + * + * @param imgUrl + * 图片的url路径,如d:\\中文.jpg + * @return + */ + public static String encodeImgageToBase64(File imageFile) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理 + // 其进行Base64编码处理 + byte[] data = null; + // 读取图片字节数组 + try { + InputStream in = new FileInputStream(imageFile); + data = new byte[in.available()]; + in.read(data); + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + // 对字节数组Base64编码 + BASE64Encoder encoder = new BASE64Encoder(); + return encoder.encode(data);// 返回Base64编码过的字节数组字符串 + } + public static InputStream encodeFileToBase64(String filestr) { + InputStream stream=null; + try{ + BASE64Decoder decoder = new BASE64Decoder(); + byte[] bytes1 = decoder.decodeBuffer(filestr); + stream = new ByteArrayInputStream(bytes1); + } catch (IOException e) { + e.printStackTrace(); + } + return stream; + } +} diff --git a/src_core/com/tenwa/officetempalte/service/CreateOfficeCallBackService.java b/src_core/com/tenwa/officetempalte/service/CreateOfficeCallBackService.java index f22808604..934c3ba83 100644 --- a/src_core/com/tenwa/officetempalte/service/CreateOfficeCallBackService.java +++ b/src_core/com/tenwa/officetempalte/service/CreateOfficeCallBackService.java @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.Map; import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; +import jbo.app.tenwa.doc.LB_DOCCONFIG; import jbo.app.tenwa.doc.LB_DOCLIBRARY; import jbo.app.tenwa.doc.LB_DOCRELATIVE; +import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; @@ -89,5 +91,43 @@ public abstract class CreateOfficeCallBackService { } attr.setAttributeValue("FileSize",file.length()); attrBm.saveObject(attr); + + // 写入LB_DOC_CONTRACT_LIST + // 根据模板参数,获取到lb_docconfig表信息 + String attrId = attr.getAttribute("id").getString(); + BizObjectManager lbcontractBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME, tx); + Map contractMap = new HashMap(); + String[] ss = new String[] {"CUSTOMERNAME", "TELEPHONE", "CONTRACT_NO", "CONTRACT_ID", "PROJECT_ID", "PRODECT_ID", "IDS", + "FLOW_UNID"}; + for (int i = 0; i < ss.length; i++) { + if (paramMap.containsKey(ss[i])) { + contractMap.put(ss[i], paramMap.get(ss[i])); + } + } + BizObject contract = lbcontractBom.newObject(); + for (Map.Entry entry : contractMap.entrySet()) { + contract.setAttributeValue(entry.getKey(), entry.getValue()); + } + contract.setAttributeValue("InputUserId", paramMap.get("CurUserId")); + contract.setAttributeValue("InputOrgId", paramMap.get("CurOrgId")); + contract.setAttributeValue("FILENAME", attr.getAttribute("FILENAME").toString()); + contract.setAttributeValue("ATTRIBUTE_ID", attrId); + contract.setAttributeValue("LIBRARY_ID", libraryId); + contract.setAttributeValue("FILE_TYPE", "扫描件"); + contract.setAttributeValue("FILE_FLAG", "yes"); + contract.setAttributeValue("DOC_NAME", templateConfig.getAttribute("TEMPLATENAME").getString()); + contract.setAttributeValue("FILEPATH", attr.getAttribute("FILEPATH").toString()); + contract.setAttributeValue("FULLPATH", attr.getAttribute("FULLPATH").toString()); + contract.setAttributeValue("InputTime", StringFunction.getTodayNow()); +// contract.setAttributeValue("CONFIG_ID", templateConfig.getAttribute("CONFIG_ID").getString()); +// contract.setAttributeValue("DOC_CLASS_ITEMNO", bo.getAttribute("DOC_CLASS_ITEMNO").getString()); + if (fullpath.endsWith(".pdf")) { + contract.setAttributeValue("PROCESS", "2"); + } else if (fullpath.endsWith(".docx") || fullpath.endsWith(".doc")) { + contract.setAttributeValue("PROCESS", "1"); + } + contract.setAttributeValue("SIGN_TYPE", "DRAFT");// 签约状态默认为草稿 + contract.setAttributeValue("SENDPROCESS", "0");// 发送状态默认未发送 + lbcontractBom.saveObject(contract); } } diff --git a/src_tenwa/com/tenwa/action/channelportal/businesshanding/contractaward/ContractAward.java b/src_tenwa/com/tenwa/action/channelportal/businesshanding/contractaward/ContractAward.java new file mode 100644 index 000000000..2fd3b0b56 --- /dev/null +++ b/src_tenwa/com/tenwa/action/channelportal/businesshanding/contractaward/ContractAward.java @@ -0,0 +1,558 @@ +package com.tenwa.action.channelportal.businesshanding.contractaward; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jbo.app.tenwa.calc.LC_PROJ_CONDITION; +import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; +import jbo.app.tenwa.doc.LB_DOCLIBRARY; +import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; +import jbo.com.tenwa.lease.comm.BUSINESS_STATUS; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_STATUS; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; +import jbo.sys.CHANNEL_SUBMIT_APPLICATIONS; + +import com.amarsoft.app.als.bizobject.customer.CustomerManager; +import com.amarsoft.app.util.ProductParamUtil; +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.BizObjectQuery; +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.control.model.Page; +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.tenwa.channelportal.action.ContractSignAction; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; + +import common.Logger; +/** + * 合同签约 + * @author tenwa518 + * + */ +public class ContractAward { +private Logger logger=Logger.getLogger(this.getClass()); +public String libraryId; +public String project_id; +public String contract_id; +public String ProjectId; +public String CustomerType; +public String ProductId; +public String ContractId; +public Page CurPage; +public Configure Curconf; +public String CurUserID; +public String FlowUnid; + + +public String getFlowUnid() { + return FlowUnid; +} + +public void setFlowUnid(String flowUnid) { + FlowUnid = flowUnid; +} + +public String getCurUserID() { + return CurUserID; +} + +public void setCurUserID(String curUserID) { + CurUserID = curUserID; +} + +public String getContract_id() { + return contract_id; +} + +public void setContract_id(String contract_id) { + this.contract_id = contract_id; +} + +public Configure getCurconf() { + return Curconf; +} + +public void setCurconf(Configure curconf) { + Curconf = curconf; +} + +public Page getCurPage() { + return CurPage; +} + +public void setCurPage(Page curPage) { + CurPage = curPage; +} + + public String getContractId() { + return ContractId; +} + + +public void setContractId(String contractId) { + ContractId = contractId; +} + + + public String getProductId() { + return ProductId; +} + + +public void setProductId(String productId) { + ProductId = productId; +} + + + public String getCustomerType() { + return CustomerType; +} + + +public void setCustomerType(String customerType) { + CustomerType = customerType; +} + + + public String getProjectId() { + return ProjectId; +} + + +public void setProjectId(String projectId) { + ProjectId = projectId; +} + + + public String getLibraryId() { + return libraryId; +} + + +public void setLibraryId(String libraryId) { + this.libraryId = libraryId; +} + + + public String getProject_id() { + return project_id; +} + + +public void setProject_id(String project_id) { + this.project_id = project_id; +} + //校验退回的单子是否包含审批意见 + public String checkOpion(JBOTransaction tx){ + String sql = "select case when count(*)>0 then 'true' else 'false' end FLAG from lb_project_info O , lb_contract_approve A where O.id=A.Project_Id and O.id='"+project_id+"'"; + try { + List> data = DataOperatorUtil.getDataBySql(tx, sql, null); + return data.get(0).get("FLAG").toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return "true"; + } + public String GenerativeContractDelete(JBOTransaction tx){ + try{ + BizObjectManager bom1=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME); + @SuppressWarnings("unchecked") + BizObject doclib=bom1.createQuery("id=:id").setParameter("id", libraryId).getSingleResult(true); + String DOCRELATIVEid=doclib.getAttribute("relative_id").toString(); + BizObjectManager bom2=JBOFactory.getBizObjectManager(jbo.app.tenwa.doc.LB_DOCATTRIBUTE.CLASS_NAME); + List DOCATTRIBUTEids=bom2.createQuery("library_id=:library_id").setParameter("library_id",libraryId ).getResultList(false); + Map condtion= new HashMap(); + condtion.put("id", DOCRELATIVEid); + DataOperatorUtil.deleteJBOByCondtion(jbo.app.tenwa.doc.LB_DOCRELATIVE.CLASS_NAME, condtion, tx); + condtion.clear(); + condtion.put("id",libraryId ); + DataOperatorUtil.deleteJBOByCondtion(jbo.app.tenwa.doc.LB_DOCLIBRARY.CLASS_NAME, condtion, tx); + condtion.clear(); + for(BizObject key:DOCATTRIBUTEids){ + condtion.put("id", key.getAttribute("id").toString()); + DataOperatorUtil.deleteJBOByCondtion(jbo.app.tenwa.doc.LB_DOCATTRIBUTE.CLASS_NAME, condtion, tx); + } + }catch(Exception e){ + return "ERROR"; + } + return "SUCCESS"; + + } + public String selectAttributeId(JBOTransaction tx) throws JBOException{ + BizObjectManager bom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME); + String ids=""; + @SuppressWarnings("unchecked") + List bo=bom.createQuery("library_id=:libraryId").setParameter("libraryId",libraryId).getResultList(false); + for(BizObject key:bo){ + ids+=key.getAttribute("id").toString()+"@"; + } + System.out.println("附件id"+ids); + return ids; + } + public String uploadConFileChangeStatus(JBOTransaction tx)throws Exception{ + BizObjectManager bom = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME); + BizObjectManager libbom = JBOFactory.getBizObjectManager(LB_DOCLIBRARY.CLASS_NAME); + tx.join(bom); + BizObject libo=libbom.createQuery("id='"+libraryId+"'").getSingleResult(false); + String docName=libo.getAttribute("DOC_NAME").toString(); + //将合同状态改为已生成合同 + if(docName.equals("融资租赁合同") || docName.equals("担保人合同")){ + BizObjectQuery boq = bom.createQuery("update O set project_status = '5' where id=:project_id ").setParameter("project_id",project_id); + boq.executeUpdate(); + } + return "success"; + } + /*** + * 已经生成的合同,作废, + * @param tx + * @return + * @throws JBOException + */ + + public String updateDocContractStatus(JBOTransaction tx) throws JBOException{ + BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + try{ + List lcl=lclManager.createQuery("file_flag='yes' and project_id='"+project_id+"'").getResultList(false); + for(BizObject key:lcl){ + lclManager.createQuery("update O set file_flag='no',message='1' where id=:id").setParameter("id",key.getAttribute("id").toString()).executeUpdate(); + attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + } + }catch(Exception e){ + tx.rollback(); + e.printStackTrace(); + System.out.println(e.getMessage()); + return "error"; + } + return "success"; + } + //根据合同id改变合同文件的状态 + public String updateDocContractStatusContract(JBOTransaction tx) throws JBOException{ + BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + try{ + List lcl = null; + lcl=lclManager.createQuery("flow_unid='"+FlowUnid+"'and file_flag='yes' ").getResultList(false); + if(lcl!=null){ + for(BizObject key:lcl){ + lclManager.createQuery("update O set file_flag='no' where flow_unid=:flow_unid and file_flag='yes'").setParameter("flow_unid",key.getAttribute("flow_unid").toString()).executeUpdate(); + attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + } + } + + }catch(Exception e){ + tx.rollback(); + e.printStackTrace(); + System.out.println(e.getMessage()); + return "error"; + } + return "success"; + } + + public String projectStatus(JBOTransaction tx) throws JBOException{ + BizObjectManager bom = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); + BizObjectManager bomstatus = JBOFactory.getBizObjectManager(LB_CONTRACT_STATUS.CLASS_NAME,tx); + BizObjectManager ldclBom = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + Boolean flag=false; + List ldclBo = ldclBom.createQuery("project_id='"+project_id+"' and file_flag='yes' and sendprocess='1'").getResultList(false); + if(ldclBo.size()>0){ + flag=true; + } + BizObject bo=bom.createQuery("id='"+project_id+"'").getSingleResult(false); + BizObject bostatus=bomstatus.createQuery("status_code='"+bo.getAttribute("PROJECT_STATUS").toString()+"'").getSingleResult(false); + String projstatus=bostatus!=null?bostatus.getAttribute("STATUS_NAME").toString():""; + return bo.getAttribute("PROJECT_STATUS").toString()+"@"+projstatus+"@"+flag; + } + + public String customerinfo(JBOTransaction tx) throws JBOException, SQLException{ + Transaction Sqlca = Transaction.createTransaction(tx); + String customerinfo=""; + SqlObject sqlcustomer; + ASResultSet rs = null; + String sql = "SELECT ci.customerid,ci.customername,ct.telephone FROM lb_project_info O LEFT JOIN lb_union_lessee lul ON lul.project_id=O.id LEFT JOIN customer_info ci ON ci.customerid=lul.customer_id LEFT JOIN customer_tel ct ON ct.customerid=ci.customerid where O.id=:projectId"; + sqlcustomer = new SqlObject(sql); + sqlcustomer.setParameter("projectId",ProjectId); + rs = Sqlca.getASResultSet(sqlcustomer); + while(rs.next()){ + customerinfo+=rs.getStringValue("customerid").toString()+","+rs.getStringValue("customername")+","+rs.getStringValue("telephone")+"@"; + } + System.out.println(customerinfo); + return customerinfo; + + } + +/* public String backContractFileUp(JBOTransaction tx) throws JBOException{ + BizObjectManager csaManager = JBOFactory.getBizObjectManager(CHANNEL_SUBMIT_APPLICATIONS.CLASS_NAME,tx); + BizObjectManager aicManager = JBOFactory.getBizObjectManager(APPLY_INFO_CONTRACT.CLASS_NAME,tx); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + BizObjectManager lpiBom=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + Transaction Sqlca=Transaction.createTransaction(tx); + BizObject proj ; + try{ + proj = lpiBom.createQuery("select CONTRACT_NUMBER,PRODUCT_ID FROM O WHERE ID=:id ").setParameter("id",ProjectId).getSingleResult(false); + String contractNumber = proj.getAttribute("CONTRACT_NUMBER").getString(); + BizObject csa= csaManager.createQuery("select ID,APPLY_DATA FROM O WHERE CONTRACT_NUMBER=:contractnumber and FLOWNO='BusinessApproveFlow' and STATUS='approve_status05' ").setParameter("contractnumber",contractNumber).getSingleResult(false); + String channelApplyId = csa.getAttribute("ID").getString(); + @SuppressWarnings("unchecked") + List lcl=lclManager.createQuery("file_flag='yes' and project_id='"+ProjectId+"'").getResultList(false); + for(BizObject key:lcl){ + lclManager.createQuery("update O set file_flag='no' , message='0' where id=:id").setParameter("id",key.getAttribute("id").toString()).executeUpdate(); + attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + } + String sql="select lib.id from lb_docrelative rel left join lb_doclibrary lib on lib.relative_id = rel.id where rel.proj_id = '"+ProjectId+"' and rel.objecttype='PROJECT' and lib.doc_name in ('融资租赁合同','担保人合同','抵押物合同')"; + ASResultSet rs=Sqlca.getASResultSet(new SqlObject(sql)); + while(rs.next()){ + attBom.createQuery("update O set status='1' WHERE status is null and LIBRARY_ID='"+rs.getStringValue("id").toString()+"'").executeUpdate(); + } + Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + csaManager.createQuery("update O SET STATUS=:status where ID=:id ").setParameter("status","approve_status07").setParameter("id",channelApplyId).executeUpdate(); + aicManager.createQuery("update O SET STATUS=:status where ID=:id ").setParameter("status","approve_status07").setParameter("id",channelApplyId).executeUpdate(); + lpiBom.createQuery("update O set PROJECT_STATUS='7',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE id=:id " ).setParameter("id",ProjectId).executeUpdate(); + //记录项目进程日志 + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='7',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,'7','"+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); + }catch(Exception e){ + tx.rollback(); + return "error"; + } + System.out.println("success"+"&"+ProjectId+"&"+ProductId+"&"+CustomerType); + return "success"+"&"+ProjectId+"&"+ProductId+"&"+CustomerType; + } + + public String backContractSign(JBOTransaction tx) throws JBOException{ + BizObjectManager csaManager = JBOFactory.getBizObjectManager(CHANNEL_SUBMIT_APPLICATIONS.CLASS_NAME,tx); + BizObjectManager aicManager = JBOFactory.getBizObjectManager(APPLY_INFO_CONTRACT.CLASS_NAME,tx); + BizObjectManager lclManager=JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME,tx); + BizObjectManager attBom=JBOFactory.getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME,tx); + BizObjectManager libBom=JBOFactory.getBizObjectManager(LB_DOCLIBRARY.CLASS_NAME,tx); + BizObjectManager lpiBom=JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx); + Transaction Sqlca=Transaction.createTransaction(tx); + BizObject proj ; + try{ + proj = lpiBom.createQuery("select CONTRACT_NUMBER,PRODUCT_ID FROM O WHERE ID=:id ").setParameter("id",ProjectId).getSingleResult(false); + String contractNumber = proj.getAttribute("CONTRACT_NUMBER").getString(); + BizObject csa= csaManager.createQuery("select ID,APPLY_DATA FROM O WHERE CONTRACT_NUMBER=:contractnumber and FLOWNO='BusinessApproveFlow' and STATUS='approve_status05' ").setParameter("contractnumber",contractNumber).getSingleResult(false); + String channelApplyId = csa.getAttribute("ID").getString(); + List lcl=lclManager.createQuery("file_flag='yes' and project_id='"+ProjectId+"'").getResultList(false); + for(BizObject key:lcl){ + lclManager.createQuery("update O set file_flag='no' , message='0' where id=:id").setParameter("id",key.getAttribute("id").toString()).executeUpdate(); + attBom.createQuery("update O set status='1' WHERE id='"+key.getAttribute("ATTRIBUTE_ID").toString()+"'").executeUpdate(); + } + String sql="select lib.id from lb_docrelative rel left join lb_doclibrary lib on lib.relative_id = rel.id " + + "where rel.proj_id = '"+ProjectId+"' and rel.objecttype='PROJECT' and lib.doc_name in ('融资租赁合同','担保人合同','抵押物合同')"; + ASResultSet rs=Sqlca.getASResultSet(sql); + while(rs.next()){ + attBom.createQuery("update O set status='1' WHERE status is null and LIBRARY_ID='"+rs.getStringValue("id").toString()+"'").executeUpdate(); + } + Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + csaManager.createQuery("update O SET STATUS=:status where ID=:id ").setParameter("status","approve_status07").setParameter("id",channelApplyId).executeUpdate(); + aicManager.createQuery("update O SET STATUS=:status where ID=:id ").setParameter("status","approve_status07").setParameter("id",channelApplyId).executeUpdate(); + lpiBom.createQuery("update O set PROJECT_STATUS='7',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' WHERE id=:id " ).setParameter("id",ProjectId).executeUpdate(); + //记录项目进程日志 + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='7',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,'7','"+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); + }catch(Exception e){ + tx.rollback(); + return "error"; + } + System.out.println("success"); + return "success"; + } + */ + + public String selectmethodtype(JBOTransaction tx) throws Exception{ + String pranayamaType=""; + Map> map=ProductParamUtil.getProductComponentType(ProductId, "PRD0320"); + //是否调息 + if(!map.isEmpty()){ + Map maps=map.get("ADJUST_INTEREST"); + pranayamaType = maps.get("ISADJUST_INTEREST"); + } + BizObjectManager bom=JBOFactory.getBizObjectManager(LC_PROJ_CONDITION.CLASS_NAME, tx); + BizObject bo=bom.createQuery("project_id='"+ProjectId+"'").getSingleResult(false); + return bo.getAttribute("SETTLE_METHOD").toString()+"@"+pranayamaType; + } + /* public String docList(JBOTransaction tx) throws Exception{ + String sFlowNo= "PROJECT"; + String product=ProductId ; + Map docParam=new HashMap(); + Map other=new HashMap(); + docParam.put("ObjectType","PROJECT"); + docParam.put("proj_id",ProjectId ); + docParam.put("contract_id",ContractId); + List list=ProductParamUtil.getProductDocInfo(product,"PRD0412"); + String type=""; + String docList=""; + for(int i=0;i map=(Map)list.get(i); + if(sFlowNo.equals(map.get("FLOW_INFO").toString())){ + type=map.get("TYPE").toString(); + if("SingleRow".equals(type)){ + docList=map.get("DOCLIST").toString(); + }else{ + List l=(List)map.get("DOCCONFIG"); + docList=l.toString(); + } + } + } + //判断是否存在,不存在就从配置表倒到临时表 + DocListInitAction.initDocList(CurPage,docParam,other,docList,Curconf); + return "success"; + + }*/ +/** + * 判断法人是否有委托代偿 + * @param tx + * @return + */ +/*public String checkEntrustment(JBOTransaction tx){ + try{ + BizObjectManager ldcBom=JBOFactory.getBizObjectManager(LB_DEDUCT_CARD.CLASS_NAME,tx); + BizObject ldcBo=ldcBom.createQuery("project_id='"+ProjectId+"' and IS_CONSIGN_REPAY='yes'").getSingleResult(false); + if(ldcBo!=null){ + return ldcBo.getAttribute("id").toString()+","+ldcBo.getAttribute("ACCOUNT").toString()+","+ldcBo.getAttribute("CONSIGN_REPAY_PHONE").toString(); + } + }catch(Exception e){ + e.printStackTrace(); + return "false"; + } + return "false"; + + + +}*/ +/** + * 判断已婚自然人的租赁本金是否大于30万 + * @param tx + * @return + * @throws JBOException + */ +public String checkMarryPerson(JBOTransaction tx){ + try{ + //1.获取婚姻状况 + String sql="select case when cp.marriage='20' then 'true' else 'false' end marriage,"+ + "customer_name||'@'||(select cf.fullname from customer_family cf where cf.customerid=ul.customer_id) customername,"+ + "(select ct.telephone||'@'||(select cf1.mobilephone from customer_family cf1 where cf1.customerid=ul.customer_id) from customer_tel ct where ct.customerid = ul.customer_id ) telephone"+ + " from lb_project_info lpi left join lb_union_lessee ul on lpi.id=ul.project_id left join customer_person cp on ul.customer_id=cp.customerid where lpi.id='"+project_id+"'"; + List> ds = DataOperatorUtil.getDataBySql(tx, sql, null); + String marraged = ""; + if(ds.size()>0){ + marraged = ds.get(0).get("MARRIAGE").toString(); + } + String names = ""; + String phones = ""; + //2.已婚 + names = ds.get(0).get("CUSTOMERNAME").toString(); + phones = ds.get(0).get("TELEPHONE").toString(); + if("true".equals(marraged)){ + //获取租赁本金 + sql = "select case when CLEAN_LEASE_MONEY>300000 then 'true' else 'false' end moneyflag from lc_proj_condition where project_id='"+project_id+"'"; + List> ds1 = DataOperatorUtil.getDataBySql(tx, sql, null); + if(ds1.size()>0&&"true".equals(ds1.get(0).get("MONEYFLAG").toString())){ + return ds1.get(0).get("MONEYFLAG").toString()+","+names+","+phones; + }else{ + return "true"+","+names.split("@")[0]+","+phones.split("@")[0]; + } + }else{ + return "true"+","+names.replace("@","")+","+phones.replace("@",""); + } + + }catch(Exception e){ + e.printStackTrace(); + return "false"; + } +} + +/*public String updateProjectStatus(JBOTransaction tx) throws JBOException{ + BizObjectManager lpiBom; + BizObjectManager csaBom; + BizObjectManager aicBom; + try { + Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + lpiBom = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); + csaBom = JBOFactory.getBizObjectManager(CHANNEL_SUBMIT_APPLICATIONS.CLASS_NAME,tx); + aicBom = JBOFactory.getBizObjectManager(APPLY_INFO_CONTRACT.CLASS_NAME,tx); + //作废 + lpiBom.createQuery("update o set project_status='12',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' where id='"+project_id+"'").executeUpdate(); + //废弃 + csaBom.createQuery("update o set STATUS='approve_status06',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' where objectno='"+project_id+"' and (STATUS='approve_status05' or STATUS='approve_status07')").executeUpdate(); + aicBom.createQuery("update o set STATUS='approve_status06',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' where objectno='"+project_id+"' and (STATUS='approve_status05' or STATUS='approve_status07')").executeUpdate(); + + //记录项目进程日志 + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='12',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='"+project_id+"')").executeUpdate(); + SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'12','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+project_id+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so); + } catch (Exception e) { + tx.rollback(); + e.printStackTrace(); + return "error"; + } + return "success"; +}*/ +/** + * + * + * @return + * @throws Exception + */ +public String setProjectStatus(JBOTransaction tx) throws Exception{ + try { + Transaction tran = Transaction.createTransaction(tx); + BizObjectManager lpiBom = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx); + ASUser user = ASUser.getUser(CurUserID, tran); + //资料上传 + lpiBom.createQuery("update o set project_status='5',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+StringFunction.getTodayNow()+"' where id='"+project_id+"'").executeUpdate(); + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='5',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='"+project_id+"')").executeUpdate(); + SqlObject so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME) SELECT SYS_GUID(),CONTRACT_NUMBER,'5','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"' FROM LB_PROJECT_INFO WHERE ID='"+project_id+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so); + +// 拉取合同文件 + ContractSignAction csa = new ContractSignAction(); + csa.setProjectId(project_id); + csa.setCustomerType(CustomerType); + String result =""; + try{ + result=csa.downloadDoc(tx); + }catch(Exception e){ + e.printStackTrace(); + } + logger.info("合同拉取状态:"+result); + } catch (Exception e) { + e.printStackTrace(); + tx.rollback(); + return "error"; + } + return "success"; +} +} diff --git a/src_tenwa/com/tenwa/app/dao/ContractSignInfo.java b/src_tenwa/com/tenwa/app/dao/ContractSignInfo.java new file mode 100644 index 000000000..52768859b --- /dev/null +++ b/src_tenwa/com/tenwa/app/dao/ContractSignInfo.java @@ -0,0 +1,50 @@ +package com.tenwa.app.dao; + +import java.io.Serializable; + +public class ContractSignInfo implements Serializable{ + private String id; + private String fileid;//模板ID + private String custphone;//客户电话 + private String custname;//客户名称 + private String inputfile;//文件流 + private String filename;//文件名称 + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getFileid() { + return fileid; + } + public void setFileid(String fileid) { + this.fileid = fileid; + } + public String getCustphone() { + return custphone; + } + public void setCustphone(String custphone) { + this.custphone = custphone; + } + public String getCustname() { + return custname; + } + public void setCustname(String custname) { + this.custname = custname; + } + public String getInputfile() { + return inputfile; + } + public void setInputfile(String inputfile) { + this.inputfile = inputfile; + } + public String getFilename() { + return filename; + } + public void setFilename(String filename) { + this.filename = filename; + } + +} + diff --git a/src_tenwa/com/tenwa/lease/app/service/HttpRequestAppService.java b/src_tenwa/com/tenwa/lease/app/service/HttpRequestAppService.java index e84a18f01..52b196bff 100644 --- a/src_tenwa/com/tenwa/lease/app/service/HttpRequestAppService.java +++ b/src_tenwa/com/tenwa/lease/app/service/HttpRequestAppService.java @@ -3,7 +3,7 @@ package com.tenwa.lease.app.service; import java.util.List; import java.util.Map; -import com.tenwa.lease.app.dao.ContractSignInfo; +import com.tenwa.app.dao.ContractSignInfo; public interface HttpRequestAppService { @@ -16,7 +16,7 @@ public interface HttpRequestAppService { * @param map * @return */ - Map createContractSign(Map> map); + Map createContractSign(Map> map); /** * 创建法人合同文本 * @param map