195 lines
7.3 KiB
Java
195 lines
7.3 KiB
Java
package com.tenwa.reckon.help;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import jbo.app.tenwa.calc.LC_ADJUST_CONTRACT;
|
|
import jbo.app.tenwa.calc.LC_ADJUST_CONTRACT_TEMP;
|
|
import jbo.app.tenwa.calc.LC_FUND_PLAN;
|
|
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
|
|
|
import com.amarsoft.app.awe.config.InitDBType;
|
|
import com.amarsoft.are.ARE;
|
|
import com.amarsoft.are.jbo.BizObject;
|
|
import com.amarsoft.are.jbo.BizObjectManager;
|
|
import com.amarsoft.are.jbo.BizObjectQuery;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
import com.amarsoft.are.log.Log;
|
|
import com.amarsoft.dict.als.manage.NameManager;
|
|
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
|
import com.tenwa.reckon.bean.FundPlanBean;
|
|
import com.tenwa.reckon.bean.FundRentPlanBean;
|
|
import com.tenwa.reckon.bean.InterContBean;
|
|
import com.tenwa.reckon.util.ObjectConvertUtils;
|
|
|
|
/**
|
|
*
|
|
* @author SHIHONGFEI
|
|
* @version 1.0
|
|
* @copyright (C) TENWA 2011
|
|
* @date 2011-2-17
|
|
* @desc ( 公用交易结构dao处理类)
|
|
*/
|
|
|
|
public class FundPlanDAOImpl {
|
|
private static Log logger=ARE.getLog();
|
|
|
|
|
|
/**
|
|
*
|
|
* ( 根据表信息,从数据库中读取租金计划信息,合同的)
|
|
*
|
|
* @param tcb
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public FundRentPlanBean findContractFundRentPlanList(String paymentnumber) throws Exception {
|
|
@SuppressWarnings("unchecked")
|
|
List<BizObject> rentList=JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME,"select * from O where payment_number=:paymentnumber order by plan_date asc").setParameter("paymentnumber", paymentnumber).getResultList(false);
|
|
FundRentPlanBean frpb = new FundRentPlanBean();
|
|
for (BizObject rent : rentList) {
|
|
frpb.getPlanDateList().add(rent.getAttribute("plan_date").getString() );
|
|
frpb.getYearRateList().add(rent.getAttribute("year_rate").getString());
|
|
frpb.getRentAdjustList().add(rent.getAttribute("rent_adjust").getString().length()==0?"0":rent.getAttribute("rent_adjust").getString());
|
|
|
|
frpb.getRentList().add(rent.getAttribute("rent").getString());
|
|
frpb.getCorpusOverageBusinessList().add(rent.getAttribute("ALL_REMAIN_CORPUS").getString());
|
|
frpb.getCorpusBusinessList().add(rent.getAttribute("corpus").getString());
|
|
frpb.getInterestBusinessList().add(rent.getAttribute("interest").getString());
|
|
frpb.getInterestDateList().add(rent.getAttribute("INTEREST_DATE").getString());
|
|
|
|
|
|
frpb.getColumn_1().add(rent.getAttribute("corpus_business").getString());
|
|
frpb.getColumn_2().add(rent.getAttribute("interest_business").getString());
|
|
|
|
|
|
}
|
|
return frpb;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 查询资金收付计划
|
|
* @param contractId
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public List<FundPlanBean> findFundPlanList(String paymentnumber){
|
|
List<FundPlanBean> fundPlanList = new ArrayList<FundPlanBean>();
|
|
try {
|
|
List<BizObject> fundList=JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME,"payment_number=:paymentnumber").setParameter("paymentnumber",paymentnumber).getResultList(false);
|
|
for(BizObject fund:fundList){
|
|
FundPlanBean fundPlan = new FundPlanBean();
|
|
fundPlan.setId(fund.getAttribute("id").getString());
|
|
fundPlan.setFeeType(fund.getAttribute("fee_type").getString());
|
|
fundPlan.setFeeTypeName(NameManager.getItemName("FeeType", fund.getAttribute("fee_type").getString()));
|
|
fundPlan.setPaymentId(fund.getAttribute("PLAN_LIST").getString());
|
|
fundPlan.setPayObj(fund.getAttribute("pay_obj").getString());
|
|
fundPlan.setPayType(fund.getAttribute("pay_type").getString());
|
|
fundPlan.setPayTypeName(NameManager.getItemName("pay_type", fund.getAttribute("pay_type").getString()));
|
|
fundPlan.setPlanDate(fund.getAttribute("plan_date").getString());
|
|
fundPlan.setPlanMoney(fund.getAttribute("plan_money").getString());
|
|
fundPlanList.add(fundPlan);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return fundPlanList;
|
|
}
|
|
|
|
|
|
/**
|
|
* 资金收付计划中的的与Dicts对应的值
|
|
* @param conn
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public Map<String,Object> findDictsOfFeeType() throws Exception{
|
|
JBOFactory f = JBOFactory.getFactory();
|
|
String jdoName = "jbo.sys.CODE_LIBRARY";
|
|
BizObjectManager m = f.getManager(jdoName);
|
|
BizObjectQuery q = m.createQuery("select * from O where codeno = 'FeeType' ");
|
|
List<BizObject> bizObjects=q.getResultList(false);
|
|
return ObjectConvertUtils.convertListToMap(bizObjects);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 查询当前合同的上一次调息记录
|
|
*
|
|
* @param contract_id
|
|
* @param rent_list_start
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
public String findLastTranRateYearRate(String paymentnumber, int startList) throws Exception {
|
|
try {
|
|
List<BizObject> list=JBOFactory.createBizObjectQuery(LC_ADJUST_CONTRACT.CLASS_NAME,"payment_number=:paymentnumber and start_list=:startlist ORDER BY ADJUST_DATE DESC").setParameter("paymentnumber", paymentnumber).setParameter("startlist", startList).getResultList(false);
|
|
if(list != null && list.size() > 0){
|
|
return list.get(0).getAttribute("rate_adjust").getString();
|
|
}
|
|
BizObject rent=JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME, "payment_number=:paymentnumber and plan_list=:startlist").setParameter("paymentnumber", paymentnumber).setParameter("startlist", startList).getSingleResult(false);
|
|
if(rent!=null){
|
|
return rent.getAttribute("YEAR_RATE").getString();
|
|
}
|
|
} catch (Exception e) {
|
|
logger.error("查询历史调息记录时错误:" + e.getMessage(), e);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 查询当前合同某期之后回笼的租金
|
|
* @param contractId
|
|
* @param startList
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String findRentIncomeByRentList(String payment_number, int startList) throws Exception{
|
|
String rent = "0";
|
|
JBOTransaction tx=JBOFactory.createJBOTransaction();
|
|
try {
|
|
String sql = "select ifnull(sum(rent),0) RENT from lc_rent_income where payment_number='" + payment_number + "' and plan_list>=" + startList ;
|
|
if("ORACLE".equals(InitDBType.DBTYPE)){
|
|
sql="select nvl(sum(rent),0) RENT from lc_rent_income where payment_number='" + payment_number + "' and plan_list>=" + startList ;
|
|
}
|
|
List<Map<String, String>> resultList =DataOperatorUtil.getDataBySql(tx, sql, null);
|
|
if(resultList != null && resultList.size() > 0){
|
|
rent = resultList.get(0).get("RENT");
|
|
}
|
|
} catch (Exception e) {
|
|
logger.error("查询当前合同某期之后回笼的租金时错误:" + e.getMessage(), e);
|
|
}finally{
|
|
tx.commit();
|
|
}
|
|
return rent;
|
|
}
|
|
/**
|
|
* 插入调息临时表
|
|
*/
|
|
public void insertLastStandInfo(InterContBean icb,JBOTransaction tx) throws Exception {
|
|
|
|
BizObjectManager bm=JBOFactory.getBizObjectManager(LC_ADJUST_CONTRACT_TEMP.CLASS_NAME, tx);
|
|
|
|
BizObject adjust=bm.newObject();
|
|
adjust.setAttributeValue("ADJUST_ID",icb.getAdjustId());
|
|
adjust.setAttributeValue("START_LIST",icb.getStartList());
|
|
adjust.setAttributeValue("RATE_ORIGINAL",icb.getOldYearRate());
|
|
adjust.setAttributeValue("RATE_ADJUST",icb.getNewYearRate());
|
|
adjust.setAttributeValue("OLD_IRR",icb.getOldIrr());
|
|
adjust.setAttributeValue("NEW_IRR",icb.getNewIrr());
|
|
adjust.setAttributeValue("flowunid",icb.getDocId());
|
|
adjust.setAttributeValue("ADJUST_DATE",icb.getAdjustDate());
|
|
adjust.setAttributeValue("MOD_REASON",icb.getModReason());
|
|
adjust.setAttributeValue("STATUS",icb.getStatus());
|
|
adjust.setAttributeValue("payment_number",icb.getPaymentNumber());
|
|
adjust.setAttributeValue("contract_id",icb.getContractId());
|
|
bm.saveObject(adjust);
|
|
}
|
|
}
|