package com.tenwa.app.baseFileTemplate.handle; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import jbo.app.tenwa.doc.LB_DOCRELATIVE; import jbo.app.tenwa.doc.LB_DOC_CONTRACT_LIST; import jbo.com.tenwa.entity.comm.officetempalte.BF_TEMPLATE; import jbo.com.tenwa.lease.comm.LB_CONTRACT_TEMPLATE; 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.json.JSONDecoder; import com.amarsoft.are.util.json.JSONObject; import com.amarsoft.awe.util.ASResultSet; import com.amarsoft.awe.util.SqlObject; import com.amarsoft.awe.util.Transaction; import com.amarsoft.dict.als.manage.NameManager; import com.tenwa.comm.exception.BusinessException; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.doc.action.DocListAction; import com.tenwa.officetempalte.service.CreateOfficeService; import com.tenwa.officetempalte.util.FileOperatorUtil; import com.tenwa.reckon.util.UUIDUtil; public class FileTemplateUtil { public String templateCalss;//模板文件分类 public String templateNo;//模板编号 public String templateParam; //模板参数 public String templateIds;//要生成的合同模板 public String flowunid;//用于查询已经生成的合同 public String leasform;//用判断租赁方式 public String getTemplateCalss() {return templateCalss;} public void setTemplateCalss(String templateCalss) {this.templateCalss = templateCalss;} public String getTemplateNo() { return templateNo; } public void setTemplateNo(String templateNo) { this.templateNo = templateNo; } public String getTemplateParam() { return templateParam; } public void setTemplateParam(String templateParam) { this.templateParam = templateParam; } public String getTemplateIds() { return templateIds; } public void setTemplateIds(String templateIds) { this.templateIds = templateIds; } public String getFlowunid() { return flowunid; } public void setFlowunid(String flowunid) { this.flowunid = flowunid; } public String getLeasform() { return leasform; } public void setLeasform(String leasform) { this.leasform = leasform; } public String getTemplateClass(Transaction Sqlca) throws Exception{ String fileClass=templateCalss.replaceAll("@", ","); ListtempFiles=new ArrayList(); JSONObject classJson=JSONDecoder.decode(fileClass); MapsercharMap=FileOperatorUtil.getJsonObjectToMap(classJson); String ONECLASSIFY=sercharMap.get("oneclassify"); if (ONECLASSIFY==null || ONECLASSIFY.length()<=0){ sercharMap.put("ONECLASSIFY", "invalid");// 在此人为加上该标记,以防一级分类没有选择的情况下加载所有模板,而导致不同产品之间可以相互生成合同 } Map sercharMapD=new HashMap(); String value=null; for(String key:sercharMap.keySet()){ value=sercharMap.get(key); if(value !=null && value.length()>0){ sercharMapD.put(key, value); } } String sql="SELECT id,TEMPLATENAME FROM BF_TEMPLATE WHERE "; sql=sql+DataOperatorUtil.getQuerySql(sercharMapD)+""; ASResultSet rs = null; SqlObject asql = new SqlObject(sql); asql = new SqlObject(sql); for(String key:sercharMapD.keySet()){ asql.setParameter(key, sercharMapD.get(key)); } rs = Sqlca.getASResultSet(asql); while (rs.next()){ tempFiles.add("{'text':'"+rs.getString("templatename")+"','value':'"+rs.getString("id")+"'}"); } String sReturn="[{'fileTemplate':\""+tempFiles.toString()+"\"}]"; // String sReturn="[{'fileTemplate':\""+"[{'text':'融资租赁合同-C端回租','value':'641c55a1168f4a488a5028ee68870156'}]"+"\"}]"; return sReturn; } public String getContractClass(Transaction Sqlca){ if("01".equals(leasform)){ /*return "[{'fileTemplate':\""+"[{'text':'融资租赁合同-C端直租','value':'24aba365e2794a018814ae81341486bf'}," + "{'text':'直租个人授权协议书','value':'3334eed6051248b88cd4f2a22e93ac96'},]"+"\"}]";*/ return "[{'fileTemplate':\""+"[{'text':'合同(直租)','value':'24aba365e2794a018814ae81341486bf'}]"+"\"}]"; }else{ /*return "[{'fileTemplate':\""+"[{'text':'融资租赁合同-C端回租','value':'641c55a1168f4a488a5028ee68870156'}," + "{'text':'回租个人授权协议书','value':'e980635a77124d5598be1717c062b877'}," + "{'text':'抵押合同','value':'ec90c114914d4725b57729107888511c'}]"+"\"}]";*/ return "[{'fileTemplate':\""+"[{'text':'合同(售后回租)','value':'641c55a1168f4a488a5028ee68870156'}]"+"\"}]"; } } public String createContractTemplate(JBOTransaction tx) throws Exception{ List message=new ArrayList(); String[] tempids=this.getTemplateIds().split("&"); //生成参数 String sTemplateParam=this.getTemplateParam().replaceAll("@", ","); JSONObject paramJson=JSONDecoder.decode(sTemplateParam); MapsourceMap=FileOperatorUtil.getJsonObjectToMap(paramJson); CreateOfficeService officeSer=new CreateOfficeService(tx); for(int i=0;i ldcls = ldclManager.createQuery("select * from O where file_flag='yes' and flow_unid=:flowunid").setParameter("flowunid", flowunid).getResultList(false); for(int i=0;i0){ docName=docName+"已存在,请先删除后再生成!"; } return docName; } }