测算事物

This commit is contained in:
lixuebo 2019-08-20 11:55:48 +08:00
parent 678122df68
commit 26264c140a

View File

@ -126,7 +126,7 @@ public class CreateTransactionExecutor implements Transaction {
irr = this.createCashFlow(bean,tx);
//额外生成分润的租金计划
/*String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio");
String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio");
System.out.println("==========================分润利率:"+splittingRatio+"==========================");
if("".equals(splittingRatio)||splittingRatio==null){}
else{
@ -136,7 +136,7 @@ public class CreateTransactionExecutor implements Transaction {
bean_sp.setRentPlan_tb("jbo.app.tenwa.calc.LC_RENT_PLAN_SP_TEMP");
bean_sp.getCb().setYearRate(splittingRatio);
FundRentPlanBean rentPlan_sp = this.createRentPlan(bean_sp,tx);
}*/
}
jsonObject.appendElement("result", "true");
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
@ -197,6 +197,19 @@ public class CreateTransactionExecutor implements Transaction {
this.createFundPlan(rentPlan, bean,tx);
String irr = this.createCashFlow(bean,tx);
//额外生成分润的租金计划
String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio");
System.out.println("==========================分润利率:"+splittingRatio+"==========================");
if("".equals(splittingRatio)||splittingRatio==null){}
else{
TabCalBean bean_sp = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
bean_sp.setProductType(productType);
bean_sp.getCb().setProductType(productType);
bean_sp.setRentPlan_tb("jbo.app.tenwa.calc.LC_RENT_PLAN_SP_TEMP");
bean_sp.getCb().setYearRate(splittingRatio);
FundRentPlanBean rentPlan_sp = this.createRentPlan(bean_sp,tx);
}
jsonObject.appendElement("result", "true");
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
}
@ -301,70 +314,6 @@ public class CreateTransactionExecutor implements Transaction {
}
return "success";
}
/**
* 插入分润计划
* @param planDateList,Sqlca
* @return
* @throws JBOException
* @throws Exception
*/
public void insertRentPlan_SP (String splittingRatio,com.amarsoft.awe.util.Transaction Sqlca) throws Exception{
BizObjectManager BmLRP=JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME, Sqlca);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy/MM/dd");
String day ="0";
Long start = format.parse(startDate).getTime();
List<BizObject> BoLRP = BmLRP.createQuery("payment_number=:payment_number order by plan_list").setParameter("payment_number", this.plannumber).getResultList(false);
Connection conn = Sqlca.getConnection(Sqlca);
PreparedStatement ps = null;
BigDecimal corpus_sum = new BigDecimal("0.00");
BigDecimal corpus_all = new BigDecimal("0.00");
BigDecimal corpus_sp = new BigDecimal("0.00");
try{
ps = conn.prepareStatement("update lc_rent_plan set CORPUS_SP = ?,INTEREST_SP = ? where payment_number = '" + this.plannumber + "' and plan_list = ?");
for(int i = 0; i < BoLRP.size(); i ++){
BigDecimal corpus = new BigDecimal(BoLRP.get(i).getAttribute("CORPUS").toString());
BigDecimal allRemainCorpus =new BigDecimal(BoLRP.get(i).getAttribute("ALL_REMAIN_CORPUS").toString());
BigDecimal interest =new BigDecimal(BoLRP.get(i).getAttribute("INTEREST").toString());
BigDecimal ratio = new BigDecimal(splittingRatio).divide(new BigDecimal("100"));
Long planDate = BoLRP.get(i).getAttribute("PLAN_DATE").getDate().getTime();
//第一期的话用计划日期减去起租日第一期本金加剩余总本金等于总本金
if(i==0){
day = String.valueOf((planDate-start)/(24*60*60*1000));
corpus_all = corpus.add(allRemainCorpus);
}else{
day = String.valueOf((planDate-(BoLRP.get(i-1).getAttribute("PLAN_DATE").getDate().getTime()))/(24*60*60*1000));
}
//如果是最后一期则倒减
if(i==(BoLRP.size()-1)){
corpus_sp = corpus_all.multiply(ratio).subtract(corpus_sum);
}else{
corpus_sp = corpus.add(allRemainCorpus).multiply(ratio).divide(new BigDecimal("360"),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(day));
}
BigDecimal interest_sp = interest.subtract(corpus_sp);
corpus_sum = corpus_sum.add(corpus_sp);
ps.setString(1, corpus_sp.toString());
ps.setString(2, interest_sp.toString());
ps.setString(3, (i + 1) + "");
ps.addBatch();
}
ps.executeBatch();
}catch(Exception e){
e.printStackTrace();
throw new RuntimeException("存储数据异常");
} finally {
if(ps != null) ps.close();
}
}
private Double Double(String splittingRatio) {
// TODO Auto-generated method stub
return null;
}
public void setCashFlow(String paymentNumber, String productId, com.amarsoft.awe.util.Transaction Sqlca) throws Exception {
String sql = "";
sql += "INSERT INTO LC_CASH_FLOW (id,project_id,project_plan_number,contract_id,contract_plan_number,payment_number";
@ -627,7 +576,8 @@ public class CreateTransactionExecutor implements Transaction {
*/
@Override
public void callBack(JSONObject jsonObject,ConditionBean cb,TabCalBean bean,FundRentPlanBean rentPlan,Boolean flag,JBOTransaction tx) throws Exception {
ConditionHelper helper = ConditionHelper.getInstance(tx);
ConditionHelper helper = new ConditionHelper();
helper.setTx(tx);
helper.run(jsonObject, cb, bean, rentPlan,flag);
}