package com.amarsoft.dict.als.manage; import java.math.BigDecimal; import java.util.List; import jbo.app.tenwa.calc.LC_CALC_CONDITION; import jbo.app.tenwa.calc.LC_EBANK; import jbo.app.tenwa.calc.LC_FUND_INCOME; import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP; import jbo.app.tenwa.calc.LC_FUND_PLAN; import jbo.app.tenwa.calc.LC_RENT_INCOME; import jbo.app.tenwa.calc.LC_RENT_INCOME_TEMP; import jbo.app.tenwa.calc.LC_RENT_PLAN; import jbo.app.tenwa.calc.VI_LC_FUND_PLAN; import jbo.app.tenwa.calc.VI_LC_RENT_PLAN; import jbo.app.tenwa.customer.DISTRIBUTOR_ACCOUNT; import jbo.com.tenwa.entity.comm.own.DISTRICT_DISTRIBUTOR_RELATION; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import jbo.com.tenwa.lease.comm.LB_UNION_LESSEE; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; public class ColRelativeInfo { //根据合同ID获取经销商账号 public static String getAccNumberByContractID(String contractID) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME,"id=:contractID") .setParameter("contractID", contractID).getSingleResult(false); String distributorID = bo.getAttribute("distributor_id").getString(); BizObject bo2 = JBOFactory.createBizObjectQuery(DISTRIBUTOR_ACCOUNT.CLASS_NAME,"distributor_id=:distributorID") .setParameter("distributorID", distributorID).getSingleResult(false); return bo2 != null?bo2.getAttribute("acc_number").getString():""; } //根据合同ID获取客户名称 public static String getCustomerNameBycontractID(String contractID) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LB_UNION_LESSEE.CLASS_NAME,"CONTRACT_ID=:CONTRACT_ID and IS_MAIN='Y'") .setParameter("CONTRACT_ID", contractID).getSingleResult(false); return bo != null?bo.getAttribute("customer_name").getString():""; } //根据客户ID获取客户名称 public static String getCustNameByCUSTID(String custID) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LB_UNION_LESSEE.CLASS_NAME,"CUSTOMER_ID=:CUST_ID") .setParameter("CUST_ID", custID).getSingleResult(false); return bo != null?bo.getAttribute("customer_name").getString():""; } //获取某个支付对象的合同数量 public static String getCountByFactObject(String factObject,String flowunid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "select count(contract_id) as v.countMoney from O where fact_object=:fact_object and flowunid=:flowunid group by fact_object") .setParameter("fact_object", factObject).setParameter("flowunid", flowunid).getSingleResult(false); return bo != null?bo.getAttribute("countMoney").getString():"0"; } //获得某个支付对象的付款总额 public static String getTotalMoneyByFactObject(String factObject,String flowunid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "select sum(fact_money) as v.sumMoney from O where fact_object=:fact_object and flowunid=:flowunid group by fact_object") .setParameter("fact_object", factObject).setParameter("flowunid", flowunid).getSingleResult(false); return bo != null?bo.getAttribute("sumMoney").getString():"0.00"; } public static String getFundPlanMoney(String planID) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); return bo != null?bo.getAttribute("plan_money").getString():""; } public static String getFundOverMoney(String planID,String flowunid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_FUND_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); BizObject boLFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "select v.sum(fact_money)+v.sum(fee_adjust)as v.fmoney from O where plan_id=:PLANID and flowunid=:flowunid group by payment_number,plan_id") .setParameter("PLANID", planID).setParameter("flowunid", flowunid).getSingleResult(false); BigDecimal fmoney = new BigDecimal(0); if(boLFIT != null){ fmoney = fmoney.add(new BigDecimal(boLFIT.getAttribute("fmoney").getString())); } return bo != null?new BigDecimal(bo.getAttribute("allfact_money").getString()).subtract(fmoney).toString():"0.00"; } public static String getRentPlanMoney(String planID,String flowUnid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and FLOWUNID=:FLOWUNID") .setParameter("PLAN_ID", planID).setParameter("FLOWUNID", flowUnid).getSingleResult(false); BigDecimal rent = new BigDecimal(0); rent = rent.add(new BigDecimal(boLRIT.getAttribute("rent").getString())); return bo != null?new BigDecimal(bo.getAttribute("rent_over").getString()).add(rent).toString():rent.toString(); } public static String getCorpusOverMoney(String planID,String flowUnid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and FLOWUNID=:FLOWUNID") .setParameter("PLAN_ID", planID).setParameter("FLOWUNID", flowUnid).getSingleResult(false); BigDecimal corpus = new BigDecimal(0); corpus = corpus.add(new BigDecimal(boLRIT.getAttribute("corpus").getDouble())); return bo != null?new BigDecimal(bo.getAttribute("corpus_over").getDouble()).add(corpus).toString():corpus.toString(); } public static String getInterestOverMoney(String planID,String flowUnid) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and FLOWUNID=:FLOWUNID") .setParameter("PLAN_ID", planID).setParameter("FLOWUNID", flowUnid).getSingleResult(false); BigDecimal interest = new BigDecimal(0); interest = interest.add(new BigDecimal(boLRIT.getAttribute("interest").getDouble())); return bo != null?new BigDecimal(bo.getAttribute("interest_over").getDouble()).add(interest).toString():interest.toString(); } public static String getFundPlanDate(String planID) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME, "ID=:PLANID") .setParameter("PLANID", planID).getSingleResult(false); return bo != null?bo.getAttribute("plan_date").getString():""; } public static String getContractNumber(String conractID) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME, "ID=:CONTRACT_ID") .setParameter("CONTRACT_ID", conractID).getSingleResult(false); return bo != null?bo.getAttribute("CONTRACT_NUMBER").getString():""; } public static String getProjectName(String conractID) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME, "ID=:CONTRACT_ID") .setParameter("CONTRACT_ID", conractID).getSingleResult(false); return bo != null?bo.getAttribute("PRODUCT_NAME").getString():""; } public static String getCautionMoney(String payment_number) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LC_CALC_CONDITION.CLASS_NAME, "payment_number=:PAYMENT_NUMBER") .setParameter("PAYMENT_NUMBER", payment_number).getSingleResult(false); return bo != null?bo.getAttribute("CAUTION_MONEY").getString():""; } public static String getAllRentList(String payment_number) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LC_CALC_CONDITION.CLASS_NAME, "payment_number=:PAYMENT_NUMBER") .setParameter("PAYMENT_NUMBER", payment_number).getSingleResult(false); return bo != null?String.valueOf(bo.getAttribute("INCOME_NUMBER").getInt()+bo.getAttribute("GRACE").getInt()):""; } public static String getPlanDate(String payment_number,String rent_list) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME, "payment_number=:PAYMENT_NUMBER and plan_list=:RENT_LIST") .setParameter("PAYMENT_NUMBER", payment_number).setParameter("RENT_LIST", rent_list).getSingleResult(false); return bo != null?bo.getAttribute("PLAN_DATE").getString():""; } public static String getFundPlanPayStatus(String planID) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_FUND_PLAN.CLASS_NAME, "id=:planID").setParameter("planID", planID) .getSingleResult(false); double factMOney = bo.getAttribute("fact_money").getDouble(); double planmoney = bo.getAttribute("plan_money").getDouble(); double feeadjust = bo.getAttribute("fee_adjust").getDouble(); String paytype=bo.getAttribute("pay_type").getString(); if("pay_type_out".equals(paytype)){ if(factMOney+feeadjust == 0){ return "未付款"; }else if(planmoney-factMOney-feeadjust>0){ return "部分付款"; }else{ return "已付款"; } }else{ if(factMOney+feeadjust == 0){ return "未收款"; }else if(planmoney-factMOney-feeadjust>0){ return "部分收款"; }else{ return "已收款"; } } } public static String getRentPlanPayStatus(String planID) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "id=:planID").setParameter("planID", planID) .getSingleResult(false); double factMOney = bo.getAttribute("fact_rent").getDouble(); double rentOver = bo.getAttribute("rent_over").getDouble(); if(factMOney == 0){ return "未回笼"; }else if(rentOver == 0){ return "已回笼"; }else{ return "部分回笼"; } } public static String getFundPlanPayInStatus(String planID) throws Exception{ BizObject bo = JBOFactory.createBizObjectQuery(VI_LC_FUND_PLAN.CLASS_NAME, "id=:planID").setParameter("planID", planID) .getSingleResult(false); double factMOney = bo.getAttribute("fact_money").getDouble(); if(factMOney == 0){ return "未收款"; }else{ return "部分收款"; } } public static String getEbankClientName(String ebankNumber) throws JBOException{ BizObject bo = JBOFactory.createBizObjectQuery(LC_EBANK.CLASS_NAME, "id=:id") .setParameter("id", ebankNumber).getSingleResult(false); return bo != null?bo.getAttribute("client_name").getString():""; } public static String getMainCustName(String contractID) throws JBOException{ BizObject bo = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME).createQuery("select ci.customername from O left join jbo.app.tenwa.customer.CUSTOMER_INFO ci on O.customer_id=ci.customerid where O.contract_id=:contractID and O.is_main='Y'").setParameter("contractID", contractID).getSingleResult(false); return bo != null?bo.getAttribute("customername").getString():""; } public static String getPlanPenalty(String planID) throws JBOException{ BizObject boVLRP = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "select penalty,fact_penalty,penalty_adjust,penalty_over from O where id='"+planID+"'") .getSingleResult(false); String penalty = boVLRP.getAttribute("penalty").getString(); return penalty; } public static String getPenaltyOver(String flowunid,String planID) throws JBOException{ BizObject boVLRP = JBOFactory.createBizObjectQuery(VI_LC_RENT_PLAN.CLASS_NAME, "select penalty,fact_penalty,penalty_adjust,penalty_over from O where id='"+planID+"'") .getSingleResult(false); String penaltyOver = boVLRP.getAttribute("penalty_over").getString(); BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "select v.sum(penalty_adjust) as v.penalty_adjust from O where flowunid='"+flowunid+"' and plan_id='"+planID+"' group by plan_id") .getSingleResult(false); BigDecimal penaltyOverOther = new BigDecimal(penaltyOver); if(boLRIT != null){ penaltyOverOther = penaltyOverOther.add(new BigDecimal(boLRIT.getAttribute("penalty_adjust").getString())); } return penaltyOverOther.setScale(2).toString(); } public static String getNotPayApplyOver(String overmoney,String planID,String feeType) throws JBOException{ BigDecimal money = new BigDecimal(overmoney); if("feetype10".equals(feeType)){ List boLRITs = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "select O.id,v.round(O.fact_money+O.fee_adjust,2) as v.applyMoney from O where plan_id='"+planID+"' and O.roll_back='0' and O.pay_status='apply_pass'") .getResultList(false); for(BizObject bo:boLRITs){ money = money.subtract(new BigDecimal(bo.getAttribute("applyMoney").getString())); BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "select v.round(v.sum(O.fact_money)+v.sum(O.fee_adjust),2) as v.applyMoney from O where relative_id='"+bo.getAttribute("id").getString()+"' and O.roll_back='0' and O.pay_type='pay_type_out' and O.pay_status='apply_pass' group by O.relative_id") .getSingleResult(false); money = money.subtract(new BigDecimal(boLRIT == null?"0":boLRIT.getAttribute("applyMoney").getString())); } }else{ BizObject boLRIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "select v.round(v.sum(O.fact_money)+v.sum(O.fee_adjust),2) as v.applyMoney from O where plan_id='"+planID+"' and O.roll_back='0' and O.pay_status<>'apply_return' group by O.plan_id") .getSingleResult(false); money = money.subtract(new BigDecimal(boLRIT == null?"0":boLRIT.getAttribute("applyMoney").getString())); } return money.setScale(2).toString(); } public static String getProvinceByDistrict(String districode)throws JBOException{ String provices=""; if(districode!=null&&!"".equals(districode)){ List boLRITs = JBOFactory.createBizObjectQuery(DISTRICT_DISTRIBUTOR_RELATION.CLASS_NAME, "DISTRICT_CODE=:DISTRICT_CODE") .setParameter("DISTRICT_CODE", districode).getResultList(false); for(int i=0;i