package com.amarsoft.app.base.util; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.List; import jbo.awe.AWE_ROLE_INFO; import jbo.sys.FLOW_CATALOG; import jbo.sys.ORG_INFO; //import jbo.sys.SADRE_DIMENSION; import jbo.sys.USER_INFO; import com.amarsoft.app.base.businessobject.BusinessObject; import com.amarsoft.app.base.config.impl.BusinessComponentConfig; import com.amarsoft.app.base.config.impl.SystemDBConfig; import com.amarsoft.app.base.util.DateHelper; import com.amarsoft.app.als.prd.config.loader.ProductConfig; 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.lang.StringX; import com.amarsoft.awe.Configure; import com.amarsoft.dict.als.cache.CodeCache; import com.amarsoft.dict.als.object.Item; /** * 名称转化 * @author qzhang1 * */ public class SYSNameManager{ //只能查询方案产品,基础产品返回空串 public static String getProductName(String productID) throws Exception{ if(StringX.isEmpty(productID)) return ""; BusinessObject prd = ProductConfig.getProduct(productID); if(prd == null || "01".equals(prd.getString("Attribute1"))) return ""; return prd.getString("TypeName") ; } public static String getProductNameByProductID(String productID) throws Exception{ if(StringX.isEmpty(productID)) return ""; BusinessObject prd = ProductConfig.getProduct(productID); if(prd == null ) return ""; return prd.getString("TypeName") ; } public static String getOrgNames(String orgIDs) throws Exception{ if(orgIDs == null || "".equals(orgIDs)) return ""; StringBuffer name = new StringBuffer(); String[] orgList = orgIDs.split(","); for(int i = 0; i < orgList.length ; i ++) { if(i < orgList.length-1) name.append(SystemDBConfig.getOrg(orgList[i]).getString("OrgName")+","); else name.append(SystemDBConfig.getOrg(orgList[i]).getString("OrgName")); } return name.toString(); } public static String getTermName(String termID) throws Exception{ if(termID==null||termID.equals("")) return ""; String TermName = ""; try{ BusinessObject bo = BusinessComponentConfig.getComponent(termID); if(bo==null) TermName=""; else TermName=bo.getAttribute("Name").getString(); }catch(Exception e){ e.printStackTrace(); } return TermName; } public static String getChangeFlag(String documentType,String documentNo,String parentTransSerialNo) throws Exception { String changeFlag = "原记录"; BizObjectManager bm=JBOFactory.getBizObjectManager("jbo.acct.ACCT_TRANSACTION"); //BizObjectQuery boq = bm.createQuery("DocumenType=:DocumentType and DocumentNo=:DocumentNo and ParentTransSerialNo= :ParentTransSerialNo"); BizObjectQuery boq = bm.createQuery("DocumentType=:DocumentType and DocumentNo=:DocumentNo"); boq.setParameter("DocumentType", documentType); boq.setParameter("DocumentNo", documentNo); //boq.setParameter("ParentTransSerialNo", parentTransSerialNo); BizObject bo = boq.getSingleResult(false); if(bo!=null) { changeFlag = bo.getAttribute("TransactionName").getString(); } if("jbo.guaranty.GUARANTY_CONTRACT".equals(documentType)){ BizObjectManager bom=JBOFactory.getBizObjectManager("jbo.guaranty.GUARANTY_CONTRACT_CHANGE"); BizObjectQuery bq1 = bom.createQuery("GCSerialNo=:GCSerialNo "); bq1.setParameter("GCSerialNo", documentNo); BizObject bo1 = bq1.getSingleResult(false); if(bo1 != null) { BizObjectQuery bq2 = bm.createQuery("DocumentType=:DocumentType and DocumentNo=:DocumentNo"); bq2.setParameter("DocumentType", "jbo.guaranty.GUARANTY_CONTRACT_CHANGE"); bq2.setParameter("DocumentNo", bo1.getAttribute("SerialNo").toString()); BizObject bo2 = bq2.getSingleResult(false); if(bo2 != null) changeFlag = bo2.getAttribute("TransactionName").getString(); } } return changeFlag; } //查询是否合作方 public static String getIsPartner(String CertType,String CertID,String CustomerID) throws Exception { String changeFlag = "否"; BizObjectManager bm=JBOFactory.getBizObjectManager("jbo.customer.CUSTOMER_LIST"); BizObjectQuery boq = bm.createQuery("CertType=:CertType and CertID=:CertID and CustomerID=:CustomerID"); boq.setParameter("CertType", CertType); boq.setParameter("CertID", CertID); boq.setParameter("CustomerID", CustomerID); BizObject bo = boq.getSingleResult(false); if(bo!=null) { changeFlag = "是"; } return changeFlag; } //截取行业类型,并拼出行业大类码值 public static String IndustryMain(String Industry) throws Exception { String IndustryFirst = substring(Industry, "0", "1"); if("".equals(IndustryFirst)){ return ""; }else{ return IndustryFirst ; } } //十级分类转换为五级分类 public static String[] getFiveClassify(String classifyResult) throws Exception{ if (classifyResult.equals("01") ||classifyResult.equals("02") ||classifyResult.equals("03")||classifyResult.equals("04")||classifyResult.equals("05")){ return new String[]{"01","正常"}; }else if (classifyResult.equals("06") ||classifyResult.equals("07")){ return new String[]{"02","关注"}; }else if (classifyResult.equals("08")){ return new String[]{"03","次级"}; }else if (classifyResult.equals("09")){ return new String[]{"04","可疑"}; }else return new String[]{"05","损失"}; } //字符串截取 public static String substring(String str,String beginIndex, String endIndex) { if(str == null || "".equals(str)) return ""; //modified by jqliang 2015-03-09 防止字符串越界 if(str.length()<=Integer.parseInt(beginIndex)) return ""; if(str.length()>Integer.parseInt(beginIndex) && str.length() -1){ String aa = Configure.getInstance().getConfigure("FileSavePath"); String ss = aa + PhaseOpinion.substring(2); File dFile = null; dFile = new File(ss); if((dFile.exists())){ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(ss))); String sLine; while((sLine = reader.readLine())!= null){ sb.append(sLine); } reader.close(); }else{ return "文件不存在!"; } return sb.toString(); } return PhaseOpinion; } public static String getLoanTypeAndName(String LoanType) throws Exception{ return LoanType+"-"+CodeCache.getItemName("BusinessType_Core", LoanType); } public static String getGuaranTorName(String AISerialNo) throws Exception{ BizObjectManager gc=JBOFactory.getBizObjectManager("jbo.guaranty.GUARANTY_CONTRACT"); BizObjectQuery gcq = gc.createQuery("select O.GuaranTorName from O where O.SerialNo=(select max(GR.GCSerialNo) from jbo.guaranty.GUARANTY_RELATIVE GR where GR.AssetSerialNo = :AssetSerialNo)"); gcq.setParameter("AssetSerialNo", AISerialNo); String GuarantorName = ""; BizObject bp = gcq.getSingleResult(false); if(bp!=null) { GuarantorName = bp.getAttribute("GuaranTorName").getString(); } return GuarantorName; } public static String getFloorMonth(String beginDate,String endDate) throws Exception{ return String.valueOf((int)Math.floor(DateHelper.getMonths(beginDate,endDate))); } public static String getModDay(String beginDate,String endDate) throws Exception{ int month = (int)Math.floor(DateHelper.getMonths(beginDate, endDate)); int day = DateHelper.getDays(DateHelper.getRelativeDate(beginDate, DateHelper.TERM_UNIT_MONTH, month), endDate); return String.valueOf(day); } /**根据传入的规则维度编号查询维度名称 * @param ids * @return * @throws JBOException */ public static String getSADREDimeItems(String ids) throws JBOException{ StringBuffer sb = new StringBuffer(); if(StringX.isEmpty(ids)){ sb.append(""); }else{ BizObjectManager bom = JBOFactory.getBizObjectManager("jbo.sys.SADRE_DIMENSION"); String [] idArray = ids.split(","); BizObject bo = null; for(int i=0;i boList = query.getResultList(false); for(BizObject biz : boList){ sb.append(biz.getAttribute("UserName").getString()).append(","); } } if(sb.toString().endsWith(",")){ return sb.toString().substring(0, sb.toString().length()-1); } return sb.toString(); } /**根据传入的 角色编号串编号查询角色名称串 * @param ids * @return * @throws JBOException */ public static String getSADRERoleItems(String ids) throws JBOException{ StringBuffer sb = new StringBuffer(); if(StringX.isEmpty(ids)){ sb.append(""); }else{ BizObjectManager bom = JBOFactory.getBizObjectManager(AWE_ROLE_INFO.CLASS_NAME); String [] idArray = ids.split(","); BizObject bo = null; for(int i=0;i