1478 lines
62 KiB
Java
1478 lines
62 KiB
Java
package com.tenwa.reckon.executor;
|
||
|
||
import com.amarsoft.app.util.ProductParamUtil;
|
||
import com.amarsoft.are.jbo.*;
|
||
import com.amarsoft.are.util.json.JSONEncoder;
|
||
import com.amarsoft.are.util.json.JSONObject;
|
||
import com.amarsoft.awe.util.ASResultSet;
|
||
import com.amarsoft.awe.util.SqlObject;
|
||
import com.tenwa.comm.exception.BusinessException;
|
||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||
import com.tenwa.lease.flow.comm.service.LeaseFlowBaseService;
|
||
import com.tenwa.lease.flow.comm.service.ServiceOperatorEnum;
|
||
import com.tenwa.lease.flow.comm.serviceImp.LeaseFlowBaseServiceImp;
|
||
import com.tenwa.officetempalte.util.ExcelVersionEnum;
|
||
import com.tenwa.quartz.StringUtil;
|
||
import com.tenwa.reckon.bean.*;
|
||
import com.tenwa.reckon.executor.rentChange.RentChangeExe;
|
||
import com.tenwa.reckon.executor.rentTerminate.RentTerminateExe;
|
||
import com.tenwa.reckon.help.*;
|
||
import com.tenwa.reckon.util.*;
|
||
import jbo.app.tenwa.calc.*;
|
||
import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT;
|
||
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
|
||
import jbo.com.tenwa.lease.comm.LB_EQUIPMENT_TEMP;
|
||
import jbo.com.tenwa.lease.comm.LC_PAY_CONDTION_TEMP;
|
||
import jbo.prd.LB_SPLITTING_RATIO;
|
||
import jbo.sys.CODE_LIBRARY;
|
||
|
||
import java.io.InputStream;
|
||
import java.math.BigDecimal;
|
||
import java.sql.Connection;
|
||
import java.sql.PreparedStatement;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
import java.util.Map.Entry;
|
||
|
||
/**
|
||
*
|
||
* @author chuang ×â½ð²âËãÖ÷Èë¿Ú
|
||
*/
|
||
public class CreateTransactionExecutor implements Transaction {
|
||
|
||
private String calType;
|
||
private String flowunid;
|
||
private String rentOrRate;
|
||
private String cleanLeasemoney;
|
||
private String equipEndValue;
|
||
private String contractId;
|
||
private String paydayAdjust;
|
||
private String plannumber;
|
||
private String productId;
|
||
private String planCName;
|
||
private String startDate;
|
||
private String userID;
|
||
private String orgID;
|
||
private String flow_name;
|
||
private String ebanknumber;
|
||
private String projectId;
|
||
private String distributorId;
|
||
|
||
|
||
public String getStartDate() {
|
||
return startDate;
|
||
}
|
||
|
||
public void setStartDate(String startDate) {
|
||
this.startDate = startDate;
|
||
}
|
||
|
||
/**
|
||
* Õý³£²âËã
|
||
*/
|
||
@Override
|
||
public String run() {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
String irr = "";
|
||
JBOTransaction tx=null;
|
||
ASResultSet rs = null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
this.deletePayCondition(this.getFlowunid(),bean.getPlanCName(), bean.getPlanCValue(), tx);
|
||
DictTools.setYearRate(bean);
|
||
//»ñÈ¡²úÆ·ÀàÐÍ
|
||
com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx);
|
||
rs = Sqlca.getASResultSet(new SqlObject("select attribute2, attribute5 from business_type where typeno='"+productId+"'"));
|
||
String productType = "";
|
||
if ( rs.next() ) {
|
||
productType = rs.getString( "attribute2" );
|
||
bean.getCb().setFlexible( rs.getString( "attribute5" ) );
|
||
}
|
||
String yearRate = bean.getCb().getYearRate();
|
||
this.preHandle(bean.getCb(),bean);
|
||
checkYearRate( bean.getCb(), bean, new BigDecimal( bean.getCb().getYearRate() ) );//µ±³õÀí½â´íÎ󣬳ɱ¾ÀûÂʺÍÄêÀûÂʲ»Ò»Ñù
|
||
if(bean.getCb().getRentOrRate().equals("rent")&&new BigDecimal(bean.getCb().getIncomeNumber()).multiply(new BigDecimal(bean.getCb().getRentValue())).compareTo(new BigDecimal(bean.getCb().getCleanLeaseMoney()))<0){
|
||
throw new BusinessException("°´×â½ðËãÄêÀûÂÊ×â½ð×ܺͲ»ÄÜСÓÚÈÚ×ʶî");
|
||
}
|
||
bean.setProductType(productType);
|
||
bean.getCb().setProductType(productType);
|
||
jsonObject.appendElement("year_rate", yearRate);
|
||
FundRentPlanBean rentPlan = this.createRentPlan(bean,tx);
|
||
this.createFundPlan(rentPlan, bean,tx);
|
||
irr = this.createCashFlow(bean,tx);
|
||
|
||
jsonObject.appendElement("result", "true");
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
|
||
// ·µ»Ø²ÎÊýÉÏ×ö´¦Àí
|
||
return JSONEncoder.encode(jsonObject);
|
||
}catch(BusinessException e){
|
||
e.printStackTrace();
|
||
try {
|
||
tx.rollback();
|
||
} catch (JBOException e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
}
|
||
String message = e.getMessage();
|
||
if ( message == null ) {
|
||
message = "²âËãʧ°Ü";
|
||
}
|
||
jsonObject.appendElement("message", message);
|
||
return JSONEncoder.encode(jsonObject);
|
||
}catch (Exception e) {
|
||
try {
|
||
tx.rollback();
|
||
} catch (JBOException e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
return irr;
|
||
}finally{
|
||
try {
|
||
if ( rs != null ) rs.close();
|
||
} catch ( Exception e ) {
|
||
e.printStackTrace();
|
||
}
|
||
if(tx!=null){
|
||
try {
|
||
tx.commit();
|
||
} catch (JBOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public void checkYearRate( ConditionBean cb, TabCalBean tcb, BigDecimal yearRate ) throws BusinessException {
|
||
if ( "Y".equals( cb.getFlexible() ) ) {
|
||
// Áé»î²úÆ·ÑéÖ¤ÄêÀûÂÊÇø¼ä
|
||
try {
|
||
Map<String, Map<String, String>> productRevenues = ProductParamUtil.getProductComponentType( tcb.getProductId(), "PRD0390" );
|
||
tcb.setProductRevenues( productRevenues );
|
||
|
||
Map<String, Map<String, String>> productRates = ProductParamUtil.getProductComponentType(productId, "PRD0350");
|
||
Map<String, String> productRate = productRates.get("product_rate");
|
||
String isFixedRate = productRate.get("isFixedRate");
|
||
if("Y".equals(isFixedRate)){//¹Ì¶¨ÀûÂÊУÑé
|
||
String prodRate = productRate.get("ProductRate");
|
||
if(!(yearRate.compareTo(new BigDecimal( prodRate )) == 0) ){
|
||
throw new BusinessException( "²âËãÄêÀûÂʸú²úÆ·ÅäÖõIJ»ÏàµÈ£¬Çë¼ì²é£¡" );
|
||
}
|
||
}
|
||
//Çø¼äÀûÂÊУÑé
|
||
String rateMin = productRate.get("RateTermScope-MIN");
|
||
String rateMax = productRate.get("RateTermScope-MAX");
|
||
if ( !( yearRate.compareTo( new BigDecimal( rateMax ) ) <= 0 && yearRate.compareTo( new BigDecimal( rateMin ) ) >= 0 ) ) {
|
||
throw new BusinessException( "ÄêÀûÂÊ: " + yearRate.setScale( 6, 4 ).toString() + "£¬²»ÔÚ²úÆ·ÅäÖÃÇø¼ä·¶Î§ÄÚ" );
|
||
}
|
||
} catch ( Exception e ) {
|
||
e.printStackTrace();
|
||
throw new BusinessException( e.getMessage() );
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Õý³£²âËã
|
||
*/
|
||
@Override
|
||
public void runTrans( JBOTransaction tx ) throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
TabCalBean bean = TbBeanTools.getTabInfoTrans( calType, flowunid, plannumber, productId, tx );
|
||
this.deletePayCondition(this.getFlowunid(),bean.getPlanCName(), bean.getPlanCValue(), tx);
|
||
DictTools.setYearRate(bean);
|
||
String yearRate = bean.getCb().getYearRate();
|
||
this.preHandle(bean.getCb(),bean);
|
||
if(bean.getCb().getRentOrRate().equals("rent")&&new BigDecimal(bean.getCb().getIncomeNumber()).multiply(new BigDecimal(bean.getCb().getRentValue())).compareTo(new BigDecimal(bean.getCb().getCleanLeaseMoney()))<0){
|
||
throw new BusinessException("°´×â½ðËãÄêÀûÂÊ×â½ð×ܺͱØÐë´óÓÚÈÚ×ʶî");
|
||
}
|
||
//»ñÈ¡²úÆ·ÀàÐÍ
|
||
com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx);
|
||
String productType = Sqlca.getString(new SqlObject("select attribute2 from business_type where typeno='"+productId+"'"));
|
||
bean.setProductType(productType);
|
||
bean.getCb().setProductType(productType);
|
||
jsonObject.appendElement("year_rate", yearRate);
|
||
FundRentPlanBean rentPlan = this.createRentPlan(bean,tx);
|
||
this.createFundPlan(rentPlan, bean,tx);
|
||
String irr = this.createCashFlow(bean,tx);
|
||
|
||
jsonObject.appendElement("result", "true");
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* Æð×â²âËã
|
||
*/
|
||
@Override
|
||
public String runOnhire() {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
String irr = "";
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
FundRentPlanBean rentPlan = this.createRentPlan(bean,tx);
|
||
this.createFundPlan(rentPlan, bean,tx);
|
||
irr = this.createCashFlow(bean,tx);
|
||
jsonObject.appendElement("result", "true");
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
|
||
// ·µ»Ø²ÎÊýÉÏ×ö´¦Àí
|
||
return JSONEncoder.encode(jsonObject);
|
||
} catch (Exception e) {
|
||
try {
|
||
tx.rollback();
|
||
} catch (JBOException e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
return irr;
|
||
}finally{
|
||
if(tx!=null){
|
||
try {
|
||
tx.commit();
|
||
} catch (JBOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* ³µ´ûÆð×â²âËã
|
||
* @param Sqlca
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String carRunOnhire(com.amarsoft.awe.util.Transaction Sqlca) throws Exception {
|
||
JBOTransaction tx=null;
|
||
BizObjectManager Bm=JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME, Sqlca);
|
||
BizObject boLCC = Bm.createQuery("contract_id='" + contractId + "'").getSingleResult(true);
|
||
BizObjectManager bmLCI=JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, Sqlca);
|
||
BizObject boLCI = bmLCI.createQuery("id='" + contractId + "'").getSingleResult(false);
|
||
//»ñÈ¡ÆÚ´Î
|
||
if(boLCC != null) {
|
||
String settleMethod = boLCC.getAttribute("SETTLE_METHOD").getString();
|
||
String defaultDueDay = ProductParamUtil.getProductParameterValue(productId, "PRD0301", settleMethod, "DefaultDueDay");
|
||
int incomeNumber = boLCC.getAttribute("INCOME_NUMBER").getInt();
|
||
//ÆÚ³õ-ÆÚÄ©
|
||
String periodType = boLCC.getAttribute("PERIOD_TYPE").getString();
|
||
String incomeIntervalMonth = boLCC.getAttribute("INCOME_INTERVAL_MONTH").getInt() + "";
|
||
List<String> planDateList = null;
|
||
//ÊÇ·ñΪÖгµ²úÆ·(ÎÞÂÛÆÚ³õÆÚÄ©£¬ÎÞÂÛÊǰ´¹Ì¶¨»¹¿îÈÕ»¹Êǰ´Æð×âÈÕ£¬Ö»ÒªÊÇÖгµµÄ£¬Ò»Âɰ´ÕâÌ×Âß¼À´---ÌÆ¸£ÌÃ)
|
||
String channel = boLCI.getAttribute("CHANNEL")==null?"":boLCI.getAttribute("CHANNEL").toString();
|
||
if("ZC".equals(channel)){
|
||
planDateList = getPlanDateListZC(incomeNumber, incomeIntervalMonth, startDate);
|
||
}else{
|
||
if("02".equals(defaultDueDay)) {
|
||
planDateList = getPlanDateListFixed(incomeNumber, periodType, incomeIntervalMonth, startDate);
|
||
} else {
|
||
planDateList = getPlanDateList(incomeNumber, periodType, incomeIntervalMonth, startDate);
|
||
}
|
||
}
|
||
|
||
String insertSql="insert into lc_rent_plan(id,quot_id,cust_id, project_id, project_plan_number,contract_id,contract_plan_number,payment_number,plan_list,plan_date,plan_status,rent,corpus,interest,penalty,corpus_business,interest_business,rent_adjust,all_remain_corpus,settle_method,coin,year_rate,memo,flowunid,inputuserid,inputorgid,inputtime,updateuserid,updateorgid,updatetime,interest_date) select id,quot_id,cust_id, project_id, project_plan_number,contract_id,contract_plan_number,payment_number,plan_list,plan_date,plan_status,rent,corpus,interest,penalty,corpus_business,interest_business,rent_adjust,all_remain_corpus,settle_method,coin,year_rate,memo,flowunid,inputuserid,inputorgid,inputtime,updateuserid,updateorgid,updatetime,interest_date from lc_pay_rent_plan where payment_number = '" + this.plannumber + "'";
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
Connection conn = Sqlca.getConnection(Sqlca);
|
||
//ʵ¼Ê×â½ð¼Æ»®ÈÕÆÚ£¨¿ªÊ¼£©
|
||
PreparedStatement ps = null;
|
||
try {
|
||
ps = conn.prepareStatement("update lc_rent_plan set plan_date = ? where payment_number = '" + this.plannumber + "' and plan_list = ?");
|
||
for(int i = 0; i < planDateList.size(); i ++) {
|
||
ps.setString(1, planDateList.get(i));
|
||
ps.setString(2, (i + 1) + "");
|
||
ps.addBatch();
|
||
}
|
||
ps.executeBatch();
|
||
} catch(Exception e) {
|
||
e.printStackTrace();
|
||
throw new RuntimeException("´æ´¢Êý¾ÝÒì³£");
|
||
} finally {
|
||
if(ps != null) ps.close();
|
||
}
|
||
boLCC.setAttributeValue("start_date", startDate);
|
||
boLCC.setAttributeValue("lease_amt_date", startDate);
|
||
if(planDateList.size()>0)boLCC.setAttributeValue("first_plan_date", planDateList.get(0));
|
||
if(planDateList.size()>1)boLCC.setAttributeValue("second_plan_date", planDateList.get(1));
|
||
Bm.saveObject(boLCC);
|
||
//ʵ¼Ê×â½ð¼Æ»®ÈÕÆÚ£¨½áÊø£©
|
||
Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + planDateList.get(planDateList.size() - 1) + "' where payment_number = '" + this.plannumber + "' and pay_type = 'pay_type_out' and fee_type != 'feetype10'"));
|
||
Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and pay_type = 'pay_type_in' and fee_type != 'feetype4' and fee_type != 'feetype12'"));
|
||
Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and fee_type = 'feetype10'"));
|
||
this.setCashFlow(this.plannumber, this.productId, Sqlca);
|
||
|
||
|
||
|
||
}
|
||
return "success";
|
||
}
|
||
|
||
/**
|
||
* ²åÈë·ÖÈ󼯻®
|
||
* @param splittingRatio,Sqlca
|
||
* @return
|
||
* @throws JBOException
|
||
* @throws Exception
|
||
*/
|
||
public void insertRentPlan_SP (String splittingRatio,com.amarsoft.awe.util.Transaction Sqlca,String splitType) throws Exception{
|
||
BizObjectManager BmLRP=JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME, Sqlca);
|
||
BizObjectManager BmLCC=JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME, Sqlca);
|
||
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy/MM/dd");
|
||
|
||
List<BizObject> BoLRP = BmLRP.createQuery("payment_number=:payment_number order by plan_list").setParameter("payment_number", this.plannumber).getResultList(false);
|
||
BizObject boLCC = BmLCC.createQuery("select IRR,CAUTION_MONEY,HANDLING_CHARGE_MONEY from O where payment_number=:payment_number").setParameter("payment_number", this.plannumber).getSingleResult(false);
|
||
String irr = boLCC.getAttribute("IRR").toString();
|
||
String cautionMoney = boLCC.getAttribute("CAUTION_MONEY").toString();
|
||
String handlingChargeMoney = boLCC.getAttribute("HANDLING_CHARGE_MONEY").toString();
|
||
BigDecimal irr_b = new BigDecimal(irr).divide(new BigDecimal("100"));
|
||
BigDecimal cautionMoney_b = new BigDecimal(cautionMoney);
|
||
BigDecimal handlingChargeMoney_b = new BigDecimal(handlingChargeMoney);
|
||
Connection conn = Sqlca.getConnection(Sqlca);
|
||
PreparedStatement ps = null;
|
||
BigDecimal corpus_sp = new BigDecimal("0.00");
|
||
BigDecimal interest_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"));
|
||
//ÊÇ·ñÁé»î·ÖÈó
|
||
if("Y".equals(splitType)){
|
||
BigDecimal baseMoney;
|
||
if(i==0){
|
||
baseMoney = corpus.add(allRemainCorpus).subtract(cautionMoney_b).subtract(handlingChargeMoney_b);
|
||
}else{
|
||
baseMoney = corpus.add(allRemainCorpus).subtract(cautionMoney_b);
|
||
}
|
||
|
||
if(baseMoney.compareTo(new BigDecimal("0"))==1){
|
||
// ·ÖÈó½ð¶î = (±¾ÆÚÊ£Óà±¾½ð+±¾ÆÚ±¾½ð-±£Ö¤½ð£©*£¨¶Ô¿ÍIRR-°²Åô¸øÇþµÀIRR£©/12
|
||
interest_sp = baseMoney.multiply(irr_b.subtract(ratio)).divide(new BigDecimal("12"),2,BigDecimal.ROUND_HALF_UP);
|
||
corpus_sp = interest.subtract(interest_sp);
|
||
}else{
|
||
interest_sp = new BigDecimal("0.00");
|
||
corpus_sp = interest.subtract(interest_sp);
|
||
}
|
||
}else{
|
||
corpus_sp = corpus.add(allRemainCorpus).multiply(ratio).multiply(new BigDecimal("30")).divide(new BigDecimal("360"),2,BigDecimal.ROUND_HALF_UP);
|
||
interest_sp = interest.subtract(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();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public String getSplitByProductId(JBOTransaction tx) {
|
||
try{
|
||
com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx);
|
||
String splitType = Sqlca.getString( "select attribute5 from business_type where typeno = '" + productId + "'" );
|
||
BizObjectManager bmLSR = JBOFactory.getBizObjectManager(LB_SPLITTING_RATIO.CLASS_NAME,tx);
|
||
BizObjectManager bmLCI = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx);
|
||
BizObjectManager bmLRP = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,tx);
|
||
BizObject boLSR= bmLSR.createQuery("product_id=:productId and distributor_id=:distributorId").setParameter("productId",productId).setParameter("distributorId",distributorId).getSingleResult(false);
|
||
String splitRatio = boLSR.getAttribute("splitting_ratio").toString();
|
||
|
||
List<BizObject> boLCIs = bmLCI.createQuery("product_id=:productId and distributor_id=:distributorId").setParameter("productId",productId).setParameter("distributorId",distributorId).getResultList(false);
|
||
if(boLCIs.size()>0){
|
||
int i=0;
|
||
for(BizObject boLCI : boLCIs){
|
||
String contractId = boLCI.getAttribute("ID").toString();
|
||
BizObject boLRP = bmLRP.createQuery("contract_id=:contractId and corpus_sp is null").setParameter("contractId",contractId).getSingleResult(false);
|
||
if(boLRP!=null){
|
||
setPlannumber(boLRP.getAttribute("PAYMENT_NUMBER").toString());
|
||
insertRentPlan_SP(splitRatio,Sqlca,splitType);
|
||
}else{
|
||
i++;
|
||
}
|
||
}
|
||
if(i==0){
|
||
return "µ±Ç°²úÆ·ºÍ¾ÏúÉÌÏÂµÄÆð×âºÏͬ¾ùÒѾÓзÖÈó";
|
||
}else{
|
||
return "¹²ÓÐ"+i+"ÌõºÏִͬÐгɹ¦";
|
||
}
|
||
}else{
|
||
return "δÕÒµ½¶ÔÓ¦µÄÆð×âºÏͬ";
|
||
}
|
||
}catch (Exception e){
|
||
return "²Ù×÷ʧ°Ü";
|
||
}
|
||
|
||
|
||
}
|
||
public void insertRentPlan_SP_Flexible(String ratio,Transaction Sqlca){
|
||
|
||
}
|
||
|
||
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";
|
||
sql += ",plan_date";
|
||
sql += ",fund_in";
|
||
sql += ",fund_in_details";
|
||
sql += ",fund_out";
|
||
sql += ",fund_out_details";
|
||
sql += ",net_flow";
|
||
//sql += ",flowunid";//create_date,creator_ "+DateUtil.getSystemDate()+"' create_date ,'"+SecurityUtil.getPrincipal().getId()+"' creator_"
|
||
sql += " )";
|
||
|
||
sql +=" select replace(uuid(),'-','') id,max(t.project_id),max(t.project_plan_number),max(t.contract_id),max(t.contract_plan_number),max(t.payment_number),t.plan_date,sum(t.flowin) fundin,ifnull(group_concat(if(t.flowindetail='',null,t.flowindetail)),'-') fundindetails, ";
|
||
sql +=" sum(t.flowout) fundout ,ifnull(group_concat(if(t.flowoutdetail='',null,t.flowoutdetail)),'-')fundoutdetails ,sum(t.cleanfow)netflow " ;
|
||
sql +=" from (" ;
|
||
sql +=" select cfrp.project_id,cfrp.project_plan_number,cfrp.contract_id,cfrp.contract_plan_number,cfrp.payment_number,cfrp.plan_date,cfrp.rent flowin,concat('µÚ',cfrp.plan_list,'ÆÚ×â½ð:',format(cfrp.rent,2)) flowindetail,0 flowout,'' flowoutdetail,cfrp.rent-0 cleanfow " ;
|
||
sql +=" from lc_rent_plan cfrp" ;
|
||
sql +=" where cfrp.payment_number='" + paymentNumber + "'" ;
|
||
sql +=" union all " ;
|
||
sql +=" select fundplan.project_id,fundplan.project_plan_number,fundplan.contract_id,fundplan.contract_plan_number,fundplan.payment_number,fundplan.plan_date,if(fundplan.pay_type='pay_type_in',fundplan.plan_money,0)flowin, ";
|
||
sql +=" if(fundplan.pay_type='pay_type_in',concat(tdd.itemname,':',format(fundplan.plan_money,2)),''), " ;
|
||
sql +=" if(fundplan.pay_type='pay_type_out',fundplan.plan_money,0)flowout, " ;
|
||
sql +=" if(fundplan.pay_type='pay_type_out',concat(tdd.itemname,':',format(fundplan.plan_money,2)),'')flowoutdetail, " ;
|
||
sql +=" if(fundplan.pay_type='pay_type_in',fundplan.plan_money,-fundplan.plan_money) cleanfow " ;
|
||
sql +=" from lc_fund_plan fundplan " ;
|
||
sql +=" left join code_library tdd on fundplan.fee_type = tdd.itemno " ;
|
||
sql +=" where fundplan.payment_number='" + paymentNumber + "'";
|
||
if(productId != null){
|
||
Map<String,Map<String,String>> productCashInIRRList = ProductParamUtil.getProductComponentType(productId, "PRD0315");
|
||
Set<Entry<String,Map<String,String>>> entry = productCashInIRRList.entrySet();
|
||
for(Entry<String,Map<String,String>> e : entry){
|
||
Map<String,String> parameMap = e.getValue();
|
||
boolean flag = false;
|
||
if("N".equals(parameMap.get("CostType10"))){
|
||
flag = true;
|
||
}
|
||
if(flag){
|
||
sql +=" and tdd.relativecode<>'"+e.getKey()+"' ";
|
||
}
|
||
}
|
||
}
|
||
sql +=" )t group by t.plan_date ";
|
||
Sqlca.executeSQL(new SqlObject(sql));
|
||
}
|
||
//Öгµ²úÆ·»ñÈ¡»¹¿îÈÕ
|
||
public static List<String> getPlanDateListZC(int incomeNumber, String incomeIntervalMonth, String startDate) throws ParseException {
|
||
List<String> planDate = new ArrayList<String>();
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(com.amarsoft.app.als.sys.tools.DateUtil.parseStringToDate(startDate, "yyyy/MM/dd"));
|
||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||
calendar.set(Calendar.DAY_OF_MONTH, 15);
|
||
if(day <= 15){
|
||
calendar.add(Calendar.MONTH, 1);
|
||
}else{
|
||
calendar.add(Calendar.MONTH, 2);
|
||
}
|
||
int addMonth = Integer.parseInt(incomeIntervalMonth);
|
||
for(int i = 0; i < incomeNumber; i ++) {
|
||
if(i!=0){
|
||
calendar.add(Calendar.MONTH, addMonth);
|
||
}
|
||
planDate.add(com.amarsoft.app.als.sys.tools.DateUtil.formatDateToString(calendar.getTime(), "yyyy/MM/dd"));
|
||
}
|
||
return planDate;
|
||
}
|
||
//¹Ì¶¨»¹¿îÈÕ
|
||
public static List<String> getPlanDateListFixed(int incomeNumber, String periodType, String incomeIntervalMonth, String startDate) throws ParseException {
|
||
List<String> planDate = new ArrayList<String>();
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(com.amarsoft.app.als.sys.tools.DateUtil.parseStringToDate(startDate, "yyyy/MM/dd"));
|
||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||
boolean flag = false;
|
||
//ÆÚÄ©
|
||
if("period_type_0".equals(periodType)) {
|
||
if(day >= 1 && day <= 9) {
|
||
day = 5;
|
||
} else if(day >= 10 && day <= 19) {
|
||
day = 15;
|
||
} else {
|
||
day = 25;
|
||
}
|
||
} else {
|
||
if(day >= 6 && day <= 15) {
|
||
day = 15;
|
||
} else if(day >= 16 && day <= 25) {
|
||
day = 25;
|
||
} else {
|
||
if(day >= 26 && day <= 31) {
|
||
flag = true;
|
||
}
|
||
day = 5;
|
||
}
|
||
}
|
||
int addMonth = Integer.parseInt(incomeIntervalMonth);
|
||
for(int i = 0; i < incomeNumber; i ++) {
|
||
if(!("period_type_1".equals(periodType) && i == 0 && !flag)) {//ÆÚÄ©¼ÓÉÏ»¹¿î¼ä¸ô
|
||
calendar.add(Calendar.MONTH, addMonth);
|
||
if(day != calendar.get(Calendar.DAY_OF_MONTH)) {
|
||
if(day > calendar.getActualMaximum(Calendar.DAY_OF_MONTH)) {
|
||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||
} else {
|
||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||
}
|
||
}
|
||
} else {
|
||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||
}
|
||
planDate.add(com.amarsoft.app.als.sys.tools.DateUtil.formatDateToString(calendar.getTime(), "yyyy/MM/dd"));
|
||
}
|
||
return planDate;
|
||
}
|
||
|
||
|
||
//Æð×âÈÕ¼´Îª»¹¿îÈÕ
|
||
public static List<String> getPlanDateList(int incomeNumber, String periodType, String incomeIntervalMonth, String startDate) throws ParseException {
|
||
List<String> planDate = new ArrayList<String>();
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(com.amarsoft.app.als.sys.tools.DateUtil.parseStringToDate(startDate, "yyyy/MM/dd"));
|
||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||
int addMonth = Integer.parseInt(incomeIntervalMonth);
|
||
for(int i = 0; i < incomeNumber; i ++) {
|
||
if(!("period_type_1".equals(periodType) && i == 0)) {//ÆÚÄ©¼ÓÉÏ»¹¿î¼ä¸ô
|
||
calendar.add(Calendar.MONTH, addMonth);
|
||
if(day != calendar.get(Calendar.DAY_OF_MONTH)) {
|
||
if(day > calendar.getActualMaximum(Calendar.DAY_OF_MONTH)) {
|
||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||
} else {
|
||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||
}
|
||
}
|
||
}
|
||
planDate.add(com.amarsoft.app.als.sys.tools.DateUtil.formatDateToString(calendar.getTime(), "yyyy/MM/dd"));
|
||
}
|
||
return planDate;
|
||
}
|
||
|
||
/**
|
||
* ÖÐ;ÖÐÖ¹
|
||
*/
|
||
@Override
|
||
public String runTerminate() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
//×éװʵÌåbean
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
BizObject bo = JBOFactory.getFactory().getManager(LC_FUND_RENT_ADJUST_TEMP.CLASS_NAME).createQuery("flowunid =:flowunid").setParameter("flowunid", flowunid).getSingleResult(true);
|
||
//AdjustBean ab = ObjectConvertUtils.converBizObjectToBean(AdjustBean.class, bo);
|
||
RentTerminateExe exe = new RentTerminateExe(tx);
|
||
FundRentPlanBean rentPlan = exe.create(bean.getCb(), bo, bean);
|
||
this.createFundPlanTerminate(rentPlan, bean,tx,bo);
|
||
this.createCashFlow(bean,tx);
|
||
jsonObject.appendElement("result", "true");
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
|
||
// ·µ»Ø²ÎÊýÉÏ×ö´¦Àí
|
||
} catch (Exception e) {
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
jsonObject.appendElement("result", "false");
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
|
||
/**
|
||
* ɾ³ý·½°¸
|
||
* @param tx
|
||
* @return
|
||
*/
|
||
public String deletePlan(JBOTransaction tx){
|
||
|
||
Map<String,String> condtion=new HashMap<String, String>();
|
||
condtion.put("flowunid", flowunid);
|
||
condtion.put(this.planCName, plannumber);
|
||
try{
|
||
DataOperatorUtil.deleteJBOByCondtion(LC_CALC_CONDITION_TEMP.CLASS_NAME, condtion, tx);
|
||
DataOperatorUtil.deleteJBOByCondtion(LC_CALC_RULES_TEMP.CLASS_NAME, condtion, tx);
|
||
DataOperatorUtil.deleteJBOByCondtion(LC_CASH_FLOW_TEMP.CLASS_NAME, condtion, tx);
|
||
DataOperatorUtil.deleteJBOByCondtion(LC_FUND_PLAN_TEMP.CLASS_NAME, condtion, tx);
|
||
DataOperatorUtil.deleteJBOByCondtion(LC_RENT_PLAN_TEMP.CLASS_NAME, condtion, tx);
|
||
}catch(Exception e){
|
||
e.printStackTrace();
|
||
return "ɾ³ýʧ°Ü£¡";
|
||
}
|
||
return "ɾ³ý³É¹¦£¡";
|
||
}
|
||
|
||
/**
|
||
* ɾ³ý¸¶¿îǰÌá
|
||
* @param flowunid
|
||
* @param planCName
|
||
* @param planCValue
|
||
* @param tx
|
||
* @throws JBOException
|
||
*/
|
||
public void deletePayCondition(String flowunid,String planCName,String planCValue,JBOTransaction tx) throws JBOException{
|
||
String sql="";
|
||
if(planCName.equals("PAYMENT_NUMBER")){
|
||
sql="delete from O where flowunid=:flowunid and PAYMENT_NUMBER=:plannumber";
|
||
}else{
|
||
sql="delete from O where flowunid=:flowunid and PLAN_NUMBER=:plannumber";
|
||
}
|
||
JBOFactory.getBizObjectManager(LC_PAY_CONDTION_TEMP.CLASS_NAME, tx).createQuery(sql).setParameter("flowunid", flowunid).setParameter("plannumber", planCValue).executeUpdate();
|
||
}
|
||
|
||
@Override
|
||
public FundRentPlanBean createRentPlan(TabCalBean bean,JBOTransaction tx) throws Exception {
|
||
ConditionBean cb = bean.getCb();
|
||
|
||
bean.setCb(cb);
|
||
DictTools.getReversDict(cb);
|
||
String settleMethod = cb.getSettleMethod();
|
||
FundRentPlanExecutor executor;
|
||
FundRentPlanBean planBean = new FundRentPlanBean();
|
||
if (settleMethod.equals("even_interest")) {
|
||
executor = new EvenInterestExecutor(tx);
|
||
} else if (settleMethod.equals("even_corpus")||settleMethod.equals("even_corpus_rate")) {
|
||
executor = new EvenCorpusExecutor(tx);
|
||
}else if(settleMethod.equals("even_rent_day")){
|
||
executor=new EvenRentDayExecutor(tx);
|
||
}else if(settleMethod.equals("even_subsection")){
|
||
executor=new EvenSubsectionExecutor(tx);
|
||
}else if(settleMethod.equals("car_even_interest")){
|
||
executor=new CarEvenInterestExecutor(tx,bean.getProductId());//³µ´û¾ùÏ¢Èë¿Ú
|
||
}else if(settleMethod.equals("car_even_rent")){
|
||
executor=new CarEvenRentExecutor(tx,bean.getProductId());//³µ´ûµÈ×âÈë¿Ú
|
||
} else {
|
||
executor = new EvenRentExecutor(tx);
|
||
}
|
||
if(bean.getCalType().equals("onHire_process")){
|
||
planBean = executor.createOnhire(bean);
|
||
}else{
|
||
planBean= executor.create(bean,1);
|
||
}
|
||
if (planBean.getPlanDateList() != null&& planBean.getPlanDateList().size() > 0) {
|
||
cb.setLastPlanDate(planBean.getPlanDateList().get(planBean.getPlanDateList().size() - 1));//Ä©ÆÚ×â½ð»¹¿îÈÕÆÚ
|
||
String endDate=DateUtil.addDate(cb.getStartDate(),DateUtil.TIME_MONTH,cb.getLeaseTerm());
|
||
cb.setEndDate(endDate);
|
||
if(cb.getPeriodType().equals("0")){
|
||
cb.setEndPlanDate(endDate);
|
||
}else{
|
||
cb.setEndPlanDate(DateUtil.addDate(cb.getLastPlanDate(),DateUtil.TIME_MONTH,cb.getIncomeIntervalMonth()));
|
||
}
|
||
}
|
||
return planBean;
|
||
}
|
||
|
||
@Override
|
||
public void createFundPlan(FundRentPlanBean planBean, TabCalBean bean,JBOTransaction tx)
|
||
throws Exception {
|
||
FundFundPlanExecutor fundFundExecutor = new FundFundPlanExecutor();
|
||
fundFundExecutor.run(bean.getCb(), bean, planBean,tx);
|
||
}
|
||
@Override
|
||
public void createFundPlanTerminate(FundRentPlanBean planBean, TabCalBean bean,JBOTransaction tx,BizObject bo)
|
||
throws Exception {
|
||
FundFundPlanExecutor fundFundExecutor = new FundFundPlanExecutor();
|
||
fundFundExecutor.runTerminate(bean.getCb(), bean, planBean,tx,bo);
|
||
}
|
||
|
||
@Override
|
||
public String createCashFlow(TabCalBean bean,JBOTransaction tx) throws Exception {
|
||
CashFlowExecutor executor = new CashFlowExecutor(tx);
|
||
return executor.run(bean.getCb(), bean);
|
||
}
|
||
|
||
/**
|
||
* ÒÑÖª×â½ð²âË㠵ȶî×â½ð ¾ùÏ¢·¨ ¸ù¾Ý×â½ðËãÄêÀûÂÊ
|
||
*/
|
||
@Override
|
||
public void preHandle(ConditionBean cb,TabCalBean bean) throws Exception {
|
||
CalYearRateFromRent calYearRate = CalYearRateFromRent.getInstance();
|
||
calYearRate.calDo(cb,bean);
|
||
}
|
||
/**
|
||
* ·µÐ´ÉÌÎñÌõ¼þ ×âÁÞÆÚÏÞ IRR ÏîÄ¿´ÖÀû »¹¿î´ÎÊý ¾»ÊÚÐŶî
|
||
*/
|
||
@Override
|
||
public void callBack(JSONObject jsonObject,ConditionBean cb,TabCalBean bean,FundRentPlanBean rentPlan,Boolean flag,JBOTransaction tx) throws Exception {
|
||
ConditionHelper helper = new ConditionHelper();
|
||
helper.setTx(tx);
|
||
helper.run(jsonObject, cb, bean, rentPlan,flag);
|
||
}
|
||
|
||
|
||
|
||
|
||
/**
|
||
* ɾ³ýÒÑÖª¹æÔò
|
||
*/
|
||
@Override
|
||
public String runDelteKnowing() throws Exception{
|
||
|
||
TabCalBean tcb=TbBeanTools.getTabInfo(this.calType);
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getRuleTb());
|
||
bm.createQuery("delete from O where flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("flowunid",this.flowunid).setParameter("plannumber",this.plannumber).executeUpdate();
|
||
BizObjectManager bm2=JBOFactory.getBizObjectManager(tcb.getPeriodTb());
|
||
bm2.createQuery("delete from O where flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("flowunid",this.flowunid).setParameter("plannumber",this.plannumber).executeUpdate();
|
||
|
||
return null;
|
||
}
|
||
/**
|
||
* ɾ³ý
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String runDeleSubsection() throws Exception{
|
||
TabCalBean tcb=TbBeanTools.getTabInfo(this.calType);
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getSubsectionTb());
|
||
bm.createQuery("delete from O where flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("flowunid",this.flowunid).setParameter("plannumber",this.plannumber).executeUpdate();
|
||
return null;
|
||
}
|
||
/**
|
||
* ÒÑÖª¹æÔò
|
||
* @throws Exception
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
@Override
|
||
public String checkKnowingConfig() throws Exception {
|
||
try {
|
||
TabCalBean tcb=TbBeanTools.getTabInfo(this.calType);
|
||
BizObjectManager manager = JBOFactory.getBizObjectManager(tcb.getRuleTb());
|
||
BigDecimal corpusTotal = new BigDecimal(MoneyUtils.getZeroStr(this.cleanLeasemoney)).subtract(new BigDecimal(MoneyUtils.getZeroStr(this.equipEndValue)));
|
||
List<BizObject> libX =manager.createQuery("flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("plannumber",this.plannumber).setParameter("flowunid", this.flowunid).getResultList(false);
|
||
BigDecimal planMoneyTotal = BigDecimal.ZERO;
|
||
for(BizObject obj : libX){
|
||
int startList = obj.getAttribute("start_list").getInt();
|
||
int endList = obj.getAttribute("end_list").getInt();
|
||
for(int i = startList ; i<=endList ; i++){
|
||
planMoneyTotal = planMoneyTotal.add(new BigDecimal(obj.getAttribute("plan_money").getDouble()));
|
||
}
|
||
}
|
||
if(this.rentOrRate.equals("knowing_rent")){
|
||
if(planMoneyTotal.compareTo(corpusTotal) > 0){
|
||
return "";
|
||
}else{
|
||
return "×â½ð×ܶîÐè´óÓÚÈÚ×ʶ";
|
||
}
|
||
}else if(this.rentOrRate.equals("knowing_corpus")){
|
||
if(planMoneyTotal.compareTo(corpusTotal) == 0){
|
||
return "";
|
||
}else{
|
||
return "±¾½ð¹æÔò±¾½ð×ܶîÐèµÈÓÚÈÚ×ʶ";
|
||
}
|
||
}
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getPeriodTb());
|
||
List<BizObject> periodList=bm.createQuery("flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("plannumber",this.plannumber).setParameter("flowunid", this.flowunid).getResultList(false);
|
||
planMoneyTotal=BigDecimal.ZERO;
|
||
for(BizObject bo:periodList){
|
||
planMoneyTotal=planMoneyTotal.add(new BigDecimal(bo.getAttribute("PLAN_MONEY").getString()));
|
||
}
|
||
if(this.rentOrRate.equals("rent_period")){
|
||
if(planMoneyTotal.compareTo(corpusTotal) > 0){
|
||
return "";
|
||
}else{
|
||
return "×â½ð×ܶîÐè´óÓÚÈÚ×ʶ";
|
||
}
|
||
}else if(this.rentOrRate.equals("corpus_period")){
|
||
if(planMoneyTotal.compareTo(corpusTotal) == 0){
|
||
return "";
|
||
}else{
|
||
return "±¾½ð¹æÔò±¾½ð×ܶîÐèµÈÓÚÈÚ×ʶ";
|
||
}
|
||
}
|
||
return "";
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
return "·þÎñÆ÷·±Ã¦£¬ÇëÉÔºóÔÙÊÔ£¡";
|
||
}
|
||
}
|
||
|
||
/**
|
||
* ×â½ð¼Æ»®ÐÝÃß
|
||
*/
|
||
@Override
|
||
public String runRentdormant() throws Exception{
|
||
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
//×éװʵÌåbean
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
ConditionBean cb = bean.getCb();
|
||
cb = DictTools.getReversDict(cb);
|
||
bean.setCb(cb);
|
||
BizObject bo = JBOFactory.getFactory().getManager("jbo.app.tenwa.calc.LC_DORMANT_RENT_ADJUST_TEMP").createQuery("flowunid =:flowunid and payment_number=:payment_number").setParameter("flowunid", flowunid).setParameter("payment_number", plannumber).getSingleResult(false);
|
||
int startList = bo.getAttribute("START_LIST").getInt();
|
||
int endList = bo.getAttribute("END_LIST").getInt();
|
||
String dormantYearRate = bo.getAttribute("DORMANT_YEAR_RATE").toString();
|
||
BizObjectManager bomLRPT = JBOFactory.getFactory().getManager(LC_RENT_PLAN_TEMP.CLASS_NAME,tx);
|
||
List<BizObject> bolLRPT = bomLRPT.createQuery("flowunid =:flowunid and payment_number=:payment_number order by plan_list").setParameter("flowunid", flowunid).setParameter("payment_number", plannumber).getResultList(true);
|
||
String ALL_REMAIN_CORPUS = bolLRPT.get(startList-1).getAttribute("ALL_REMAIN_CORPUS").toString();
|
||
String CORPUS = bolLRPT.get(startList-1).getAttribute("CORPUS").toString();
|
||
BigDecimal allRemainCorpus = new BigDecimal(ALL_REMAIN_CORPUS).add(new BigDecimal(CORPUS));
|
||
BigDecimal dormantInterest = allRemainCorpus.multiply(new BigDecimal(dormantYearRate)).divide(new BigDecimal("100")).divide(new BigDecimal("12"),2,BigDecimal.ROUND_HALF_UP);
|
||
|
||
BigDecimal finalPayment = new BigDecimal(cb.getFinalPayment()==null?"0":cb.getFinalPayment());
|
||
String preRate = RateTools.getPreRate(cb.getYearRate(), cb.getIncomeNumberYear(),cb.getRateAdjustType());
|
||
String rent = new BigDecimal(RentTools.getPMT(preRate, bolLRPT.size()-endList + "", "-"+allRemainCorpus.toString(), finalPayment.toString(), cb.getPeriodType())).toString();
|
||
List<String> rentList = new ArrayList<>();
|
||
for(int i=0;i<bolLRPT.size()-endList;i++){
|
||
rentList.add(i,rent);
|
||
}
|
||
// ¼ÓÔØÀûÏ¢Áбí
|
||
InterestCalServiceImpl icsi = new InterestCalServiceImpl();
|
||
List<String> interests = icsi.getInterestList(rentList, allRemainCorpus.toString(), cb.getYearRate(), cb.getPeriodType(), cb.getGrace(), cb.getIncomeNumberYear(), cb.getEquipEndValue(),cb.getRateAdjustType());
|
||
|
||
// ¼ÓÔØ±¾½ðÁбí103196.63*(1.0075)
|
||
CorpusServiceImpl csi = new CorpusServiceImpl();
|
||
List<String> corpusList = csi.getCorpusList(rentList, interests);
|
||
|
||
FundRentPlanBean frpb = new FundRentPlanBean();
|
||
frpb.setRentList(rentList);
|
||
frpb.setCorpusBusinessList(corpusList);
|
||
frpb.setInterestBusinessList(interests);
|
||
|
||
// ¼ÓÔØµ÷ÕûÐÅÏ¢Áбí
|
||
RentPlanServiceImpl rpsi = new RentPlanServiceImpl();
|
||
rpsi.adjustLastRentPlan(frpb, allRemainCorpus.toString(), cb.getEquipEndValue());
|
||
|
||
// ¼ÓÔØ±¾½ðÓà¶îÁбí
|
||
List<String> corpusOverageBusinessList = TransRateHelper.getCorpusOvergeList(allRemainCorpus.toString(), frpb.getCorpusBusinessList());
|
||
|
||
for(int i=0;i<bolLRPT.size();i++){
|
||
int planNo = bolLRPT.get(i).getAttribute("PLAN_LIST").getInt();
|
||
if(planNo>=startList&&planNo<=endList){
|
||
String interest = dormantInterest.toString();
|
||
String remainCorpus = allRemainCorpus.toString();
|
||
bolLRPT.get(i).setAttributeValue("RENT",interest);
|
||
bolLRPT.get(i).setAttributeValue("CORPUS","0.00");
|
||
bolLRPT.get(i).setAttributeValue("INTEREST",interest);
|
||
bolLRPT.get(i).setAttributeValue("CORPUS_BUSINESS","0.00");
|
||
bolLRPT.get(i).setAttributeValue("INTEREST_BUSINESS",interest);
|
||
bolLRPT.get(i).setAttributeValue("ALL_REMAIN_CORPUS",remainCorpus);
|
||
}else if (planNo>endList){
|
||
bolLRPT.get(i).setAttributeValue("RENT",frpb.getRentList().get(i-endList));
|
||
bolLRPT.get(i).setAttributeValue("CORPUS",frpb.getCorpusBusinessList().get(i-endList));
|
||
bolLRPT.get(i).setAttributeValue("INTEREST",frpb.getInterestBusinessList().get(i-endList));
|
||
bolLRPT.get(i).setAttributeValue("CORPUS_BUSINESS",frpb.getCorpusBusinessList().get(i-endList));
|
||
bolLRPT.get(i).setAttributeValue("INTEREST_BUSINESS",frpb.getInterestBusinessList().get(i-endList));
|
||
bolLRPT.get(i).setAttributeValue("ALL_REMAIN_CORPUS",corpusOverageBusinessList.get(i-endList));
|
||
|
||
}
|
||
bomLRPT.saveObject(bolLRPT.get(i));
|
||
}
|
||
String irr = this.createCashFlow(bean,tx);
|
||
BizObjectManager bomLCCT = JBOFactory.getFactory().getManager(LC_CALC_CONDITION_TEMP.CLASS_NAME);
|
||
BizObject boLCCT = bomLCCT.createQuery("flowunid =:flowunid and payment_number=:payment_number").setParameter("flowunid", flowunid).setParameter("payment_number", plannumber).getSingleResult(true);
|
||
boLCCT.setAttributeValue("IRR",irr);
|
||
bomLCCT.saveObject(boLCCT);
|
||
|
||
jsonObject.appendElement("result", "true");
|
||
} catch (Exception e) {
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
jsonObject.appendElement("result", "false");
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
/**
|
||
* ×â½ð¼Æ»®±ä¸ü
|
||
*/
|
||
@Override
|
||
public String runRentChange() throws Exception{
|
||
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
//×éװʵÌåbean
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
BizObject bo = JBOFactory.getFactory().getManager(LC_FUND_RENT_ADJUST_TEMP.CLASS_NAME).createQuery("flowunid =:flowunid and payment_number=:plannumber").setParameter("flowunid", flowunid).setParameter("plannumber", plannumber).getSingleResult(true);
|
||
AdjustBean ab = ObjectConvertUtils.converBizObjectToBean(AdjustBean.class, bo);
|
||
RentChangeExe exe = new RentChangeExe(tx);
|
||
ConditionBean csOld=bean.getCb().clone();
|
||
csOld.setOldIncomeNumber(csOld.getIncomeNumber());
|
||
FundRentPlanBean rentPlan = exe.create(bean.getCb(), ab, bean);
|
||
//ÉèÖÃеÄ
|
||
csOld.setIncomeNumber(ab.getAdjustList());
|
||
csOld.setLeaseTerm(bean.getCb().getLeaseTerm());
|
||
csOld.setYearRate(ab.getYearRate().toString());
|
||
bean.setCb(csOld);
|
||
//this.createFundPlan(rentPlan, bean,tx);
|
||
this.createCashFlow(bean,tx);
|
||
jsonObject.appendElement("result", "true");
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,true,tx);
|
||
// ·µ»Ø²ÎÊýÉÏ×ö´¦Àí
|
||
} catch (Exception e) {
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
jsonObject.appendElement("result", "false");
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
/**
|
||
* È¡Ïû±ä¸ü
|
||
*/
|
||
@Override
|
||
public String cancelRentChange(JBOTransaction tx) throws Exception {
|
||
BizObjectManager manager = JBOFactory.getFactory().getManager(LC_FUND_RENT_ADJUST_TEMP.CLASS_NAME);
|
||
//ɾ³ý±ä¸ü¼Ç¼
|
||
BizObject bo = manager.createQuery("flowunid =:flowunid and payment_number=:plannumber").setParameter("flowunid", flowunid).setParameter("plannumber", plannumber).getSingleResult(true);
|
||
if(bo != null ){
|
||
manager.deleteObject(bo);
|
||
}
|
||
//ÖØÐ¸´ÖÆÕýʽ±í×â½ð¼Æ»®µ½ÁÙʱ±í
|
||
Map<String, String> fromCondition = new HashMap<String, String>();
|
||
Map<String,String> toCondition=new HashMap<String, String>();
|
||
toCondition.put("flowunid", this.getFlowunid());
|
||
toCondition.put("payment_number", this.getPlannumber());
|
||
Map<String, String> otherProperty = new HashMap<String, String>();
|
||
fromCondition.put("payment_number",this.getPlannumber());
|
||
otherProperty.put("flowunid", flowunid);
|
||
DataOperatorUtil.copyJBOSet(LC_RENT_PLAN.CLASS_NAME, fromCondition,LC_RENT_PLAN_TEMP.CLASS_NAME ,toCondition, otherProperty,null, tx);
|
||
DataOperatorUtil.copyJBOSet(LC_CALC_CONDITION.CLASS_NAME, fromCondition,LC_CALC_CONDITION_TEMP.CLASS_NAME ,toCondition, otherProperty,null, tx);
|
||
DataOperatorUtil.copyJBOSet(LC_FUND_PLAN.CLASS_NAME, fromCondition,LC_FUND_PLAN_TEMP.CLASS_NAME ,toCondition, otherProperty,null, tx);
|
||
DataOperatorUtil.copyJBOSet(LC_CASH_FLOW.CLASS_NAME, fromCondition,LC_CASH_FLOW_TEMP.CLASS_NAME ,toCondition, otherProperty,null, tx);
|
||
String mage = deleteEbank(tx);
|
||
if(!"Success".equals(mage)){
|
||
return "false";
|
||
}
|
||
return "true";
|
||
|
||
}
|
||
/**
|
||
* ÅжÏ×â½ð±ä¸üÐÅÏ¢ÊÇ·ñ´æÔÚ
|
||
*/
|
||
@Override
|
||
public String checkIsRentChange() throws Exception {
|
||
try{
|
||
BizObject bo = JBOFactory.getFactory().getManager(LC_FUND_RENT_ADJUST_TEMP.CLASS_NAME).createQuery("flowunid =:flowunid and PAYMENT_NUMBER=:plannumber").setParameter("flowunid", flowunid).setParameter("plannumber", plannumber).getSingleResult(true);
|
||
if(bo == null){
|
||
return "true";
|
||
}else{
|
||
return "false";
|
||
}
|
||
}catch(Exception e){
|
||
return "false";
|
||
}
|
||
}
|
||
|
||
/**
|
||
* ÅжÏÉÌÎñÌõ¼þÊÇ·ñ±£´æ
|
||
*/
|
||
@Override
|
||
public String checkIsSaveCondition() throws Exception {
|
||
try{
|
||
TabCalBean tcb=TbBeanTools.getTabInfo(this.calType);
|
||
BizObject bo = JBOFactory.getFactory().getManager(tcb.getCondition_tb()).createQuery("flowunid =:flowunid and "+this.planCName+"='"+this.plannumber+"'").setParameter("flowunid", flowunid).getSingleResult(true);
|
||
if(bo == null){
|
||
return "false";
|
||
}else{
|
||
return "true";
|
||
}
|
||
}catch(Exception e){
|
||
return "false";
|
||
}
|
||
}
|
||
@SuppressWarnings("unchecked")
|
||
public String updateConditionFund() throws Exception{
|
||
List<BizObject> funds=JBOFactory.createBizObjectQuery(LC_FUND_PLAN_TEMP.CLASS_NAME,"flowunid=:flowunid and payment_number=:paymentnumber").setParameter("flowunid",this.flowunid).setParameter("paymentnumber",this.plannumber).getResultList(false);
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(LC_CALC_CONDITION_TEMP.CLASS_NAME);
|
||
BizObject condition=bm.createQuery("flowunid=:flowunid and payment_number=:paymentnumber").setParameter("flowunid",this.flowunid).setParameter("paymentnumber",this.plannumber).getSingleResult(true);
|
||
Map<String,BigDecimal> map=new HashMap<String, BigDecimal>();
|
||
List<BizObject> fundConfig=JBOFactory.createBizObjectQuery(CODE_LIBRARY.CLASS_NAME,"codeno='FeeType'").getResultList(false);
|
||
Map<String,String> fundCol=new HashMap<String, String>();
|
||
for(BizObject config:fundConfig){
|
||
map.put(config.getAttribute("itemno").getString(),BigDecimal.ZERO);
|
||
fundCol.put(config.getAttribute("itemno").getString(),config.getAttribute("relativecode").getString());
|
||
if(config.getAttribute("itemno").getString().equals("feetype16")){//µÖ¿Û±£Ö¤½ð
|
||
fundCol.put(config.getAttribute("itemno").getString(),"CAUTION_DEDUCTION_MONEY");
|
||
}
|
||
if(config.getAttribute("itemno").getString().equals("feetype17")){//ÍË»¹±£Ö¤½ð
|
||
fundCol.put(config.getAttribute("itemno").getString(),"CAUTION_MONEY_REMAIN");
|
||
}
|
||
if(config.getAttribute("itemno").getString().equals("feetype12")){//ÆÚÄ©ÓàÖµ
|
||
fundCol.remove(config.getAttribute("itemno").getString());
|
||
map.remove(config.getAttribute("itemno").getString());
|
||
}
|
||
}
|
||
for(BizObject fund:funds){
|
||
map.put(fund.getAttribute("FEE_TYPE").getString(), map.get(fund.getAttribute("FEE_TYPE").getString()).add(new BigDecimal(fund.getAttribute("PLAN_MONEY").getString())));
|
||
}
|
||
if(map.get("feetype2").compareTo(map.get("feetype16").add(map.get("feetype17")))!=0){
|
||
return "±£Ö¤½ð²»µÈÓÚ±£Ö¤½ðµÖ¿Û¼Ó±£Ö¤½ðÍË»¹£¬Çë¼ì²é";
|
||
}
|
||
Map<String,String> fundColMoney=new HashMap<String, String>();
|
||
for(String key:map.keySet()){
|
||
fundColMoney.put(fundCol.get(key), map.get(key).toString());
|
||
}
|
||
|
||
Map<String,Map<String,String>> fundmap=ProductParamUtil.getProductComponentType(productId, "PRD0315");
|
||
Map<String,String> fundColMoneyRatio=new HashMap<String, String>();
|
||
fundColMoneyRatio.putAll(fundColMoney);
|
||
for(Map.Entry<String,String> entry:fundColMoney.entrySet()){
|
||
String key=entry.getKey();
|
||
if(fundmap.containsKey(key)&&!key.equals("EQUIP_AMT")){
|
||
String q= StringUtil.nullToString(fundmap.get(key).get("CostType07"));
|
||
if(q.equals("EquipAmt")){
|
||
fundColMoneyRatio.put(key+"_RATIO",new BigDecimal(fundColMoney.get(key)).multiply(new BigDecimal(100)).divide(new BigDecimal(condition.getAttribute("EQUIP_AMT").getString()),6,BigDecimal.ROUND_HALF_UP).toString() );
|
||
}else if(q.equals("EquipEndAmt")){
|
||
fundColMoneyRatio.put(key+"_RATIO",new BigDecimal(fundColMoney.get(key)).multiply(new BigDecimal(100)).divide(new BigDecimal(condition.getAttribute("CLEAN_LEASE_MONEY").getString()),6,BigDecimal.ROUND_HALF_UP).toString() );
|
||
}
|
||
}
|
||
}
|
||
condition.setAttributesValue(fundColMoneyRatio);
|
||
bm.saveObject(condition);
|
||
return "true";
|
||
}
|
||
/**
|
||
* ¸üÐÂÏÖ½ðÁ÷
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@Override
|
||
public String updateCashFlow() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", this.flowunid).getSingleResult(false);
|
||
String productId;
|
||
if(flow!=null){
|
||
productId=flow.getAttribute("productId").getString();
|
||
}else{
|
||
productId=this.productId;
|
||
}
|
||
TabCalBean tcb = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
RentPlanContrCalDAOImpl rpccdi = new RentPlanContrCalDAOImpl();
|
||
FundRentPlanBean frpb = rpccdi.getRentAndDateByTcb(tcb, 1,tx);
|
||
this.createCashFlow(tcb,tx);
|
||
jsonObject.appendElement("result", "true");
|
||
jsonObject.appendElement("IRR",tcb.getCb().getIrr());
|
||
this.callBack(jsonObject, tcb.getCb(), tcb,frpb,false,tx);
|
||
} catch (Exception e) {
|
||
tx.rollback();
|
||
jsonObject.appendElement("result", "false");
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
/**
|
||
* µ¼Èë×â½ð±í ±¾½ð±í
|
||
* @param fileName
|
||
* @param sourceFile
|
||
* @param sourceMap
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String importRentOrCorpusTable(String fileName, InputStream sourceFile,Map<String,String>sourceMap) throws Exception{
|
||
|
||
TabCalBean tcb=TbBeanTools.getTabInfo(sourceMap.get("calType"));
|
||
String suffix = fileName.substring(fileName.lastIndexOf(".")+1);
|
||
ExcelVersionEnum type;
|
||
if(suffix.equalsIgnoreCase("xlsx")){
|
||
type = ExcelVersionEnum.VERSION2007;
|
||
}else{
|
||
type = ExcelVersionEnum.VERSION2003;
|
||
}
|
||
List<Map<String, String>> result = ExcelReader.readExcelDatas(sourceFile,type);
|
||
List<KnowingTableBean> tableBeans = new ArrayList<KnowingTableBean>();
|
||
for(int i = 0 ; i < result.size() ; i++ ){
|
||
Map<String, String>tableBean = result.get(i);
|
||
for(Map.Entry<String,String> entry:tableBean.entrySet()){
|
||
if(entry.getKey().equals("plandate")){
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ");
|
||
Date date=sdf.parse(tableBean.get(entry.getKey()));
|
||
tableBean.put(entry.getKey(), DateUtil.getSystemTimeByFormat(date, "yyyy/MM/dd"));
|
||
}
|
||
}
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.putAll(tableBean);
|
||
KnowingTableBean table = ObjectConvertUtils.convertMapToBean(KnowingTableBean.class, map);
|
||
KnowingTableBean.checkKnowingTableBean(table, i);
|
||
tableBeans.add(table);
|
||
}
|
||
|
||
//ÏÈУÑé±¾½ðÖ®ºÍÊÇ·ñµÈÓÚÈÚ×ʶî
|
||
BigDecimal moneyTotal = BigDecimal.ZERO;
|
||
Date upperDate=null;
|
||
for(KnowingTableBean tablePlan : tableBeans){
|
||
moneyTotal = moneyTotal.add(new BigDecimal(tablePlan.getPlanMoney()));
|
||
if(upperDate!=null&&DateUtil.getIntervalDays(DateUtil.getTimeByFormat(tablePlan.getPlandate(), "yyyy/MM/dd"), upperDate)>0){
|
||
throw new BusinessException("ÉÏ´«ExcelÖеÚ"+tablePlan.getPalnList()+"ÆÚ ÈÕÆÚСÓÚÉÏÒ»ÆÚ£¬Çë¼ì²é£¡");
|
||
}else{
|
||
upperDate=DateUtil.getTimeByFormat(tablePlan.getPlandate(), "yyyy/MM/dd");
|
||
}
|
||
}
|
||
String cleanLeaseMoney=sourceMap.get("CLEAN_LEASE_MONEY");
|
||
String rentOrRate=sourceMap.get("RENT_OR_RATE");
|
||
if(rentOrRate.equals("rent_period")&&moneyTotal.compareTo(new BigDecimal(cleanLeaseMoney))<=0){
|
||
throw new BusinessException("ÉÏ´«ExcelÖÐ×â½ðÖ®ºÍÐè´óÓÚÈÚ×ʶÇëºËʵºóÔÙ½øÐÐÉÏ´«£¡");
|
||
}else if(rentOrRate.equals("corpus_period")&&moneyTotal.compareTo(new BigDecimal(cleanLeaseMoney).subtract(new BigDecimal(sourceMap.get("EQUIP_END_VALUE"))))!=0){
|
||
throw new BusinessException("ÉÏ´«ExcelÖеı¾½ðÖ®ºÍÐèÒªµÈÓÚÈÚ×ʶÇëºËʵºóÔÙ½øÐÐÉÏ´«£¡");
|
||
}
|
||
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getPeriodTb());
|
||
bm.createQuery("delete from O where flowunid=:flowunid and "+sourceMap.get("planCName")+"=:plannumber").setParameter("flowunid", sourceMap.get("flowunid")).setParameter("plannumber", sourceMap.get("plannumber")).executeUpdate();
|
||
JSONObject json=JSONObject.createObject();
|
||
json.appendElement("firstplan","");
|
||
json.appendElement("second","");
|
||
for(KnowingTableBean tablePlan : tableBeans){
|
||
BizObject bo=bm.newObject();
|
||
bo.setAttributeValue("PLAN_LIST", tablePlan.getPalnList());
|
||
bo.setAttributeValue("PLAN_DATE", tablePlan.getPlandate());
|
||
bo.setAttributeValue("PLAN_MONEY", tablePlan.getPlanMoney());
|
||
bo.setAttributeValue("flowunid", sourceMap.get("flowunid"));
|
||
bo.setAttributeValue(sourceMap.get("planCName"),sourceMap.get("plannumber"));
|
||
bm.saveObject(bo);
|
||
if(tablePlan.getPalnList().equals("1")){
|
||
json.appendElement("firstplan", tablePlan.getPlandate());
|
||
}else if(tablePlan.getPalnList().equals("2")){
|
||
json.appendElement("second", tablePlan.getPlandate());
|
||
}
|
||
}
|
||
json.appendElement("index", tableBeans.size());
|
||
return JSONEncoder.encode(json);
|
||
}
|
||
|
||
/**
|
||
* ²»¹æÔò²âËã µ¼Èë×â½ð¼Æ»®
|
||
* */
|
||
@Override
|
||
public int importRentPlan(String fileName, InputStream sourceFile,Map<String,String>sourceMap) throws Exception {
|
||
JBOTransaction tx=null;
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
try{
|
||
tx=JBOFactory.createJBOTransaction();
|
||
this.flowunid = sourceMap.get("flowunid");
|
||
this.plannumber=sourceMap.get("plannumber");
|
||
this.calType=sourceMap.get("calType");
|
||
TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId);
|
||
IrregularRentCalExecutor exe = new IrregularRentCalExecutor(tx);
|
||
List<FundRentPlanIrr> irrPlans = exe.preCreate(fileName, sourceFile, bean);
|
||
FundRentPlanBean rentPlan = exe.create(bean, 1, irrPlans);
|
||
bean.getCb().setFirstPlanDate(rentPlan.getPlanDateList().get(0));
|
||
if(rentPlan.getPlanDateList().size()>1){//µ±²»¹æÔòµ¼Èëʱ£¬×â½ðÆÚ´ÎµÈÓÚ1£¬Ôò²»ÐèÒªÉèÖõڶþÆÚ×â½ðÖ§¸¶ÈÕ
|
||
bean.getCb().setSecondPlanDate(rentPlan.getPlanDateList().get(1));
|
||
}
|
||
bean.setProductType("business_product");
|
||
bean.getCb().setProductType("business_product");
|
||
this.createFundPlan(rentPlan, bean,tx);
|
||
this.createCashFlow(bean,tx);
|
||
jsonObject.appendElement("result", "true");
|
||
bean.getCb().setIncomeNumber(rentPlan.getRentList().size());
|
||
this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx);
|
||
// ·µ»Ø²ÎÊýÉÏ×ö´¦Àí
|
||
return irrPlans.size();
|
||
}catch(BusinessException e){
|
||
tx.rollback();
|
||
throw e;
|
||
}catch(Exception e){
|
||
|
||
tx.rollback();
|
||
return 0;
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
/**
|
||
* ×â½ð¼Æ»®±ä¸ü ¸üÐÂÏÖ½ðÁ÷ǰÏȼÆËãÔöֵ˰
|
||
* @param
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String updateRentTax() throws Exception{
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(LC_RENT_PLAN_TEMP.CLASS_NAME);
|
||
@SuppressWarnings("unchecked")
|
||
List<BizObject> rentplans=bm.createQuery("select * from O where flowunid=:flowunid and payment_number=:payment_number order by plan_list")
|
||
.setParameter("flowunid",this.flowunid).setParameter("payment_number",this.plannumber).getResultList(true);
|
||
//»ñȡ˰ÂÊ
|
||
/*BizObject projOrCont=JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO_TEMP.CLASS_NAME,"flowunid=:flowunid").setParameter("flowunid",this.flowunid).getSingleResult(false);
|
||
String lesae="02";//»Ø×â
|
||
if(projOrCont!=null&&projOrCont.getAttribute("LEAS_FORM").getString().length()>0){
|
||
lesae=projOrCont.getAttribute("LEAS_FORM").getString();
|
||
}
|
||
BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false);
|
||
String productId=flow.getAttribute("productId").getString();
|
||
Map<String, List<Map<String, String>>> map=ProductParamUtil.getProductComponentDecisionTable(productId, "PRD0340","LeasForm","TaxRate");
|
||
BigDecimal rate=BigDecimal.ONE;
|
||
for(int i=0;i<map.get("CalcRate").size();i++){
|
||
if(map.get("CalcRate").get(i).get("LeasForm").equals(lesae)){
|
||
rate=new BigDecimal(map.get("CalcRate").get(i).get("TaxRate")).add(rate);
|
||
}
|
||
}*/
|
||
BizObject condition=JBOFactory.createBizObjectQuery(LC_CALC_CONDITION_TEMP.CLASS_NAME,"flowunid=:flowunid").setParameter("flowunid", this.flowunid).getSingleResult(false);
|
||
BigDecimal cleanmoney=new BigDecimal(condition.getAttribute("CLEAN_LEASE_MONEY").getString());
|
||
for(BizObject rent:rentplans){
|
||
cleanmoney= cleanmoney.subtract(new BigDecimal(rent.getAttribute(LC_RENT_PLAN_TEMP.CORPUS).getString()));
|
||
rent.setAttributeValue("ALL_REMAIN_CORPUS", cleanmoney.toString());
|
||
/*if(lesae.equals("01")){//Ö±×â
|
||
rent.setAttributeValue("tax",new BigDecimal(rent.getAttribute("rent").getString()).subtract(new BigDecimal(rent.getAttribute("rent").getString()).divide(rate, 2,BigDecimal.ROUND_HALF_UP)));
|
||
rent.setAttributeValue("tax_free_corpus",new BigDecimal(rent.getAttribute("corpus").getString()).divide(rate, 2,BigDecimal.ROUND_HALF_UP));
|
||
rent.setAttributeValue("tax_free_interest",rent.getAttribute("rent").getDouble()-rent.getAttribute("tax").getDouble()-rent.getAttribute("tax_free_corpus").getDouble());
|
||
}else{
|
||
rent.setAttributeValue("tax",new BigDecimal(rent.getAttribute("interest").getString()).subtract(new BigDecimal(rent.getAttribute("interest").getString()).divide(rate, 2,BigDecimal.ROUND_HALF_UP)));
|
||
rent.setAttributeValue("tax_free_corpus",rent.getAttribute("corpus"));
|
||
rent.setAttributeValue("tax_free_interest",rent.getAttribute("rent").getDouble()-rent.getAttribute("tax").getDouble()-rent.getAttribute("tax_free_corpus").getDouble());
|
||
}*/
|
||
bm.saveObject(rent);
|
||
}
|
||
return "true";
|
||
}
|
||
/**
|
||
* Ìáǰ½áÇåÍøÒø¿¼±í²Ù×÷
|
||
* @return
|
||
*/
|
||
public String copyLCEbankTemp(JBOTransaction tx) throws Exception {
|
||
Map<String,String> fromCondtion = new HashMap<String, String>();
|
||
fromCondtion.put("id",contractId);
|
||
Map<String,String> otherProperty = new HashMap<String,String>();
|
||
otherProperty.put("FlowUnid", flowunid);
|
||
otherProperty.put("HAD_MONEY", "0.00");
|
||
// otherProperty.put("ID", id);
|
||
LeaseFlowBaseService service=new LeaseFlowBaseServiceImp();
|
||
service.copyEbankInfo(tx, fromCondtion, null,otherProperty, ServiceOperatorEnum.FormalToTemp);
|
||
//ÍøÒø¿¼ÁÙʱ±í
|
||
Map<String,String> fromCondtion1 = new HashMap<String, String>();
|
||
fromCondtion1.put("id",contractId);
|
||
fromCondtion1.put("userID",userID);
|
||
fromCondtion1.put("orgID",orgID);
|
||
Map<String,String> otherProperty1 = new HashMap<String,String>();
|
||
otherProperty1.put("FlowUnid", flowunid);
|
||
otherProperty1.put("flow_name", flow_name);
|
||
LeaseFlowBaseService service1=new LeaseFlowBaseServiceImp();
|
||
service1.copyEbankInfoToProcess(tx, fromCondtion1, null,otherProperty1, ServiceOperatorEnum.FormalToTemp);
|
||
|
||
String sMessage="true";
|
||
return "";
|
||
}
|
||
/**
|
||
* ɾ³ý¶ÔÓ¦ºËÏú¹ý³Ì±í
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String deleteLCEbankTemp(JBOTransaction tx) throws Exception {
|
||
BizObjectManager leManage = JBOFactory.getBizObjectManager(LC_EBANK.CLASS_NAME, tx);
|
||
BizObject le = leManage.createQuery("EBANK_SN=:EBANK_SN").setParameter("EBANK_SN", ebanknumber).getSingleResult(false);
|
||
BizObjectManager lepManage = JBOFactory.getBizObjectManager(LC_EBANK_PROCESS.CLASS_NAME, tx);
|
||
lepManage.createQuery("delete from O where flowunid=:flowunid and EBANK_NUMBER=:ebanknumber").setParameter("flowunid", flowunid).setParameter("ebanknumber", le.getAttribute("ID").getString()).executeUpdate();
|
||
return "true";
|
||
}
|
||
//Ìáǰ½áÇå¸üÐÂLC_EBANK_TEMP±í
|
||
public String updateEbank(JBOTransaction tx)throws Exception{
|
||
BizObjectManager letManage = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME, tx);
|
||
List<BizObject> lets = letManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowunid).getResultList(true);
|
||
Double advanceMoney = new Double(cleanLeasemoney);
|
||
for (BizObject let : lets) {
|
||
Double mayopeMoney = new Double(let.getAttribute("MAYOPE_MONEY").getString());
|
||
Double factMoney = new Double(let.getAttribute("FACT_MONEY").getString());
|
||
if(mayopeMoney>=advanceMoney){
|
||
Double mayopeMoneyNew = mayopeMoney-advanceMoney;
|
||
let.setAttributeValue("HAD_MONEY", factMoney - mayopeMoneyNew);
|
||
let.setAttributeValue("MAYOPE_MONEY", mayopeMoneyNew);
|
||
letManage.saveObject(let);
|
||
break;
|
||
}else{
|
||
let.setAttributeValue("HAD_MONEY", factMoney);
|
||
advanceMoney = advanceMoney-mayopeMoney;
|
||
let.setAttributeValue("MAYOPE_MONEY", 0);
|
||
letManage.saveObject(let);
|
||
}
|
||
}
|
||
tx.commit();
|
||
return "Success";
|
||
}
|
||
|
||
//Ìáǰ½áÇå¸üÐÂLC_EBANK_TEMP±í
|
||
public String deleteEbank(JBOTransaction tx)throws Exception{
|
||
BizObjectManager letManage = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME, tx);
|
||
List<BizObject> lets = letManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid",flowunid).getResultList(true);
|
||
for (BizObject let : lets) {
|
||
Double mayopeMoney = new Double(let.getAttribute("MAYOPE_MONEY").getString());
|
||
Double hadMoney = new Double(let.getAttribute("HAD_MONEY").getString());
|
||
let.setAttributeValue("HAD_MONEY", 0);
|
||
let.setAttributeValue("MAYOPE_MONEY", mayopeMoney+hadMoney);
|
||
letManage.saveObject(let);
|
||
}
|
||
tx.commit();
|
||
return "Success";
|
||
}
|
||
|
||
//УÑéÈÚ×ʽð¶îÊÇ·ñ³¬¶î
|
||
public String checkMoney()throws Exception{
|
||
BigDecimal sumMoney = new BigDecimal("0") ;
|
||
BizObjectManager letManage = JBOFactory.getBizObjectManager(LB_EQUIPMENT_TEMP.CLASS_NAME);
|
||
List<BizObject> letms = letManage.createQuery("flowunid=:flowunid").setParameter("flowunid", this.flowunid).getResultList(false);
|
||
for(BizObject letm:letms){
|
||
sumMoney = new BigDecimal(letm.getAttribute("EQUIP_PRICE").getString()).add(sumMoney);
|
||
}
|
||
sumMoney = sumMoney.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||
return sumMoney.toString();
|
||
}
|
||
|
||
|
||
public String getCalType() {
|
||
return calType;
|
||
}
|
||
|
||
public void setCalType(String calType) {
|
||
this.calType = calType;
|
||
}
|
||
|
||
|
||
public String getFlowunid() {
|
||
return flowunid;
|
||
}
|
||
|
||
public void setFlowunid(String flowunid) {
|
||
this.flowunid = flowunid;
|
||
}
|
||
|
||
public String getRentOrRate() {
|
||
return rentOrRate;
|
||
}
|
||
|
||
public void setRentOrRate(String rentOrRate) {
|
||
this.rentOrRate = rentOrRate;
|
||
}
|
||
|
||
|
||
|
||
public String getCleanLeasemoney() {
|
||
return cleanLeasemoney;
|
||
}
|
||
|
||
public void setCleanLeasemoney(String cleanLeasemoney) {
|
||
this.cleanLeasemoney = cleanLeasemoney;
|
||
}
|
||
|
||
|
||
|
||
public String getEquipEndValue() {
|
||
return equipEndValue;
|
||
}
|
||
|
||
public void setEquipEndValue(String equipEndValue) {
|
||
this.equipEndValue = equipEndValue;
|
||
}
|
||
|
||
public String getContractId() {
|
||
return contractId;
|
||
}
|
||
|
||
public void setContractId(String contractId) {
|
||
this.contractId = contractId;
|
||
}
|
||
|
||
public String getPaydayAdjust() {
|
||
return paydayAdjust;
|
||
}
|
||
|
||
public void setPaydayAdjust(String paydayAdjust) {
|
||
this.paydayAdjust = paydayAdjust;
|
||
}
|
||
|
||
public String getPlannumber() {
|
||
return plannumber;
|
||
}
|
||
|
||
public void setPlannumber(String plannumber) {
|
||
this.plannumber = plannumber;
|
||
}
|
||
|
||
public String getProductId() {
|
||
return productId;
|
||
}
|
||
|
||
public void setProductId(String productId) {
|
||
this.productId = productId;
|
||
}
|
||
|
||
public String getPlanCName() {
|
||
return planCName;
|
||
}
|
||
|
||
public void setPlanCName(String planCName) {
|
||
this.planCName = planCName;
|
||
}
|
||
|
||
public String getUserID() {
|
||
return userID;
|
||
}
|
||
|
||
public void setUserID(String userID) {
|
||
this.userID = userID;
|
||
}
|
||
|
||
public String getOrgID() {
|
||
return orgID;
|
||
}
|
||
|
||
public void setOrgID(String orgID) {
|
||
this.orgID = orgID;
|
||
}
|
||
|
||
public String getFlow_name() {
|
||
return flow_name;
|
||
}
|
||
|
||
public void setFlow_name(String flow_name) {
|
||
this.flow_name = flow_name;
|
||
}
|
||
|
||
public String getEbanknumber() {
|
||
return ebanknumber;
|
||
}
|
||
|
||
public void setEbanknumber(String ebanknumber) {
|
||
this.ebanknumber = ebanknumber;
|
||
}
|
||
|
||
public String getProjectId() {
|
||
return projectId;
|
||
}
|
||
|
||
public void setProjectId(String projectId) {
|
||
this.projectId = projectId;
|
||
}
|
||
public String getDistributorId() {
|
||
return distributorId;
|
||
}
|
||
public void setDistributorId(String distributorId) {
|
||
this.distributorId = distributorId;
|
||
}
|
||
|
||
|
||
}
|