476 lines
21 KiB
Java
476 lines
21 KiB
Java
package com.tenwa.reckon.executor;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import jbo.app.tenwa.calc.LC_CALC_CONDITION;
|
||
import jbo.app.tenwa.calc.LC_RENT_INCOME;
|
||
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
||
import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT;
|
||
import jbo.com.tenwa.lease.comm.LC_CAR_DISPOSE;
|
||
import jbo.com.tenwa.lease.comm.LC_OCCUPY_RENT_LIST;
|
||
|
||
import com.amarsoft.app.awe.config.InitDBType;
|
||
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.jbo.JBOTransaction;
|
||
import com.amarsoft.are.util.json.JSONEncoder;
|
||
import com.amarsoft.are.util.json.JSONObject;
|
||
import com.tenwa.reckon.util.Conn;
|
||
import com.tenwa.reckon.util.DateUtil;
|
||
import com.tenwa.reckon.util.DateUtils;
|
||
/**
|
||
* 合同中途中止
|
||
* @author tenwapc
|
||
*
|
||
*/
|
||
public class RentCalHelper {
|
||
|
||
private String contractId;
|
||
private String startList;
|
||
private String paydayAdjust;
|
||
private String paymentnumber;
|
||
private String planId;
|
||
|
||
|
||
/**
|
||
* 根据中止日期算金额
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String calculationContractCarInit() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try{
|
||
tx=JBOFactory.createJBOTransaction();
|
||
Conn conn = new Conn(tx);
|
||
String lcSql = "SELECT payment_number,YEAR_RATE,contract_id,NOMINAL_PRICE,caution_money,PROJECT_ID from LC_CALC_CONDITION where CONTRACT_ID='"+this.contractId+"'";
|
||
List<Map<String, String>> lcSqlRes = conn.executeQuery(lcSql);
|
||
Map<String, String> lcSqlInfo = lcSqlRes.get(0);
|
||
jsonObject.appendElement("yearrate", lcSqlInfo.get("year_rate"));
|
||
jsonObject.appendElement("nominalPrice", lcSqlInfo.get("nominal_price"));
|
||
jsonObject.appendElement("cautionmoney", lcSqlInfo.get("caution_money"));
|
||
jsonObject.appendElement("paymentnumber", lcSqlInfo.get("payment_number"));
|
||
jsonObject.appendElement("flowunid", lcSqlInfo.get("flowunid"));
|
||
jsonObject.appendElement("contractId", this.contractId);
|
||
String projectId = lcSqlInfo.get("project_id");
|
||
String projectSql = "select EarlySettleBreachRatio from PRD_SPECIFIC_LIBRARY where productid=(" +
|
||
"SELECT PRODUCT_ID from lb_project_info where id='"+ projectId +"')";
|
||
List<Map<String, String>> projectSqlRes = conn.executeQuery(projectSql);
|
||
Map<String, String> projectSqlInfo = projectSqlRes.get(0);
|
||
jsonObject.appendElement("ratio", projectSqlInfo.get("earlysettlebreachratio"));
|
||
return JSONEncoder.encode(jsonObject);
|
||
}catch(Exception e){
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
return "";
|
||
}finally{
|
||
tx.commit();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取开始期次是否回笼
|
||
* @return
|
||
*/
|
||
public String findPlanDateByRentList() {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
try {
|
||
BizObject rentplan=JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME,"PAYMENT_NUMBER=:paymentnumber and plan_list=:planlist")
|
||
.setParameter("paymentnumber", paymentnumber).setParameter("planlist", startList).getSingleResult(false);
|
||
|
||
@SuppressWarnings("unchecked")
|
||
List<BizObject> rentincome=JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME,"plan_id=:planid and ROLL_BACK='0'").setParameter("planid", rentplan.getAttribute("ID").getString()).getResultList(false);
|
||
|
||
//先去判断当前期次是否已回笼
|
||
if(rentincome.size()>0){
|
||
jsonObject.appendElement("result", "false");
|
||
jsonObject.appendElement("message","当前期次已回笼或部分回笼,请重新选择回笼期次!");
|
||
}else{
|
||
jsonObject.appendElement("result", "true");
|
||
jsonObject.appendElement("message",rentplan.getAttribute("plan_date").getString());
|
||
}
|
||
} catch (JBOException e) {
|
||
jsonObject.appendElement("result", "false");
|
||
jsonObject.appendElement("message","服务器繁忙,请稍后再试!");
|
||
e.printStackTrace();
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
|
||
public String findConditionInfo() {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
try {
|
||
JBOFactory f = JBOFactory.getFactory();
|
||
BizObjectManager m = f.getManager(LC_CALC_CONDITION.CLASS_NAME);
|
||
BizObjectQuery q = m.createQuery("CONTRACT_ID = :contractId").setParameter("contractId", this.contractId);
|
||
BizObject bo = q.getSingleResult(true);
|
||
if(bo!=null){
|
||
jsonObject.appendElement("ADJUSTLIST", bo.getAttribute("INCOMENUMBER").getString());
|
||
jsonObject.appendElement("YEARRATE", bo.getAttribute("YEARRATE").getString());
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
return "";
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
return "";
|
||
}
|
||
}
|
||
/**
|
||
* 校验中止日期是否合法
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String checkPaydayAdjust() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try{
|
||
tx=JBOFactory.createJBOTransaction();
|
||
String checkSql = " select max(plan_date) maxdate,min(plan_date) mindate from LC_RENT_PLAN where contract_id = ? and payment_number=?";
|
||
Conn conn = new Conn(tx);
|
||
List<Map<String, String>> results = conn.executeQuery(checkSql, this.contractId,this.getPaymentnumber());
|
||
String maxdate = results.get(0).get("maxdate");
|
||
String mindate = results.get(0).get("mindate");
|
||
Date max = DateUtil.getTimeByFormat(maxdate, "yyyy/MM/dd");
|
||
Date min = DateUtil.getTimeByFormat(mindate, "yyyy/MM/dd");
|
||
Date payDayAdjust = DateUtil.getTimeByFormat(this.paydayAdjust, "yyyy/MM/dd");
|
||
// if(payDayAdjust.compareTo(min) >= 0 && payDayAdjust.compareTo(max) <= 0){
|
||
if(payDayAdjust.compareTo(max) <= 0){
|
||
//约定终止日不能落在已汇款的租金计划的区间段
|
||
checkSql = "select max(rp.plan_date) maxdate from LC_RENT_PLAN rp left join lc_rent_income ci on rp.id=ci.plan_id where (rp.COLLECT_STATUS <> '未收款' AND rp.COLLECT_STATUS IS NOT NULL AND LENGTH(rp.COLLECT_STATUS)>0 ) and ci.id is not null and rp.contract_id = ? and rp.payment_number=?";
|
||
results = conn.executeQuery(checkSql, this.contractId,this.paymentnumber);
|
||
String maxDate = results.get(0).get("maxdate");
|
||
if(maxDate != null){
|
||
max = DateUtil.getTimeByFormat(maxDate, "yyyy/MM/dd");
|
||
if(payDayAdjust.compareTo(max) > 0 ){
|
||
jsonObject.appendElement("result", "true");
|
||
}else{
|
||
jsonObject.appendElement("result", "false");
|
||
jsonObject.appendElement("msg","约定终止日不能落在已汇款的租金计划的区间段!!!");
|
||
}
|
||
}else{
|
||
jsonObject.appendElement("result", "true");
|
||
}
|
||
}else{
|
||
jsonObject.appendElement("result", "false");
|
||
// jsonObject.appendElement("msg","预定终止日应不能大于最后一期租金支付日期,也不能小于第一期租金支付日期!!!");
|
||
jsonObject.appendElement("msg","约定终止日应不能大于最后一期租金支付日期!!!");
|
||
}
|
||
}catch(Exception e){
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
jsonObject.appendElement("result", "false");
|
||
jsonObject.appendElement("msg","服务器正忙,请稍后再试!!!");
|
||
}finally{
|
||
tx.commit();
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
|
||
public String getLcCarDispose() throws Exception{
|
||
BizObjectManager lcdManage = JBOFactory.getBizObjectManager(LC_CAR_DISPOSE.CLASS_NAME);
|
||
BizObject lcd = lcdManage.createQuery("select * from O left join jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO lci on lci.contract_no=O.contract_no where lci.id=:id ").setParameter("id", contractId).getSingleResult(false);
|
||
if(lcd!=null){
|
||
return lcd.getAttribute("collect_fees").getString()+"@"+lcd.getAttribute("dispose_money").getString();
|
||
}
|
||
return "";
|
||
}
|
||
/**
|
||
* 根据中止日期算金额
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String getTerminateInfo() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
JBOTransaction tx=null;
|
||
try{
|
||
tx=JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME);
|
||
Conn conn = new Conn(tx);
|
||
String sql = "select sum(case when DATE_FORMAT(t.plandate,'%Y/%m/%d') >= DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.remaincorpus else 0 end ) remaincorpus,"
|
||
+" sum(case when DATE_FORMAT(t.plandate,'%Y/%m/%d') >= DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') and t.planlist >12 then t.remaincorpus else 0 end ) remaincorpusbreak," //一年以内的,违约费用13期包括13的剩余本金计算 ;一年以外的,用剩余本金计算
|
||
+ " sum(case when DATE_FORMAT(t.plandate,'%Y/%m/%d') > DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.remaininterest else 0 end ) remaininterest, "
|
||
+" sum(case when DATE_FORMAT(t.plandate,'%Y/%m/%d') > DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.corpus else 0 end ) remainfincorpus,"
|
||
+ "sum(case when DATE_FORMAT(t.plandate,'%Y/%m/%d') < DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.penalty else 0 end ) remainfpenalty,"
|
||
+" sum(case when DATE_FORMAT( t.plandate,'%Y/%m/%d') > DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.interest else 0 end ) remainfininterest,"
|
||
+" sum(case when DATE_FORMAT( t.plandate,'%Y/%m/%d') < DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.overduerent else 0 end ) overduerent,"
|
||
+ "sum(case when t.cou< t.planlist and t.planlist-t.cou<=12-t.cou and DATE_FORMAT( t.plandate,'%Y/%m/%d') > DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.interest else 0 end)"
|
||
+ "+sum(case when t.cou=t.planlist and t.planlist-t.cou<=12-t.cou and DATE_FORMAT( t.plandate,'%Y/%m/%d') > DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.remainint else 0 end) fist_rent,"
|
||
+ " sum(case when t.cou< t.planlist and t.planlist-t.cou>12-t.cou then t.corpus else 0 end) fist_corpus,"
|
||
+ " max( case when DATE_FORMAT(t.plandate, '%Y/%m/%d') < DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') then t.plandate else '0' end) plandate,"
|
||
+ "sum(CASE WHEN DATE_FORMAT(t.plandate,'%Y/%m/%d') < DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d') THEN "
|
||
+ " t.sumpenalty"
|
||
+ " else 0 end"
|
||
+ ") sumpenalty "
|
||
+ " from ("
|
||
+ " select "
|
||
+ " t1.corpus-ifnull(t2.sumincomecorpus,0) remaincorpus,"
|
||
+ " t1.interestbusiness - ifnull(t2.sumincomeinterest,0) remaininterest,"
|
||
+ " t1.rent - ifnull(t2.sumincomerent,0) overduerent, t1.rent,"
|
||
+ " t1.corpus,"
|
||
+ " t1.interest, t1.interest-ifnull(t2.sumincomeinterest,0) remainint,"
|
||
+ " IFNULL(t1.penalty,0)-ifnull(t2.sumincomepenalty,0) penalty,"
|
||
+ " t1.plandate,"
|
||
+ " t1.planlist,IFNULL(t2.planlist,0) cou,"
|
||
+ " getRentPenalty('"+this.getPaymentnumber()+"',t1.planlist,DATE_FORMAT('"+this.paydayAdjust+"','%Y/%m/%d'))-IFNULL(t2.sumincomepenalty,0)-IFNULL(t2.sumincomepenaltyadjust,0) sumpenalty"
|
||
+ " from ("
|
||
+ " select cfrp.plan_date plandate,"
|
||
+ " cfrp.plan_list planlist,"
|
||
+ " cfrp.rent,"
|
||
+ " cfrp.interest,"
|
||
+ " cfrp.corpus,"
|
||
+ " cfrp.penalty,"
|
||
+ " cfrp.corpus_business corpusbusiness,"
|
||
+ " cfrp.interest_business interestbusiness,"
|
||
+ " cfrp.contract_id contractid"
|
||
+ " from LC_RENT_PLAN cfrp "
|
||
+ " where cfrp.contract_id = ? and payment_number=?"
|
||
+ " ) t1"
|
||
+ " left join "
|
||
+ " (select sum( cfri.corpus ) sumincomecorpus"
|
||
+ " ,sum(cfri.interest ) sumincomeinterest,"
|
||
+ " sum( cfri.rent ) sumincomerent,"
|
||
+ " sum( cfri.penalty ) sumincomepenalty, "
|
||
+ " sum( cfri.penalty_adjust ) sumincomepenaltyadjust,"
|
||
+ " min(cfri.contract_id) contractid,"
|
||
+ " cfri.plan_list planlist "
|
||
+ " from LC_RENT_INCOME cfri "
|
||
+ " where cfri.contract_id = ? and payment_number=?"
|
||
+ " group by cfri.plan_list"
|
||
+ " )t2 on t2.contractid = t1.contractid and t2.planlist = t1.planlist"
|
||
+ " ) t ";
|
||
if("ORACLE".equals(InitDBType.DBTYPE)){
|
||
sql=sql.replaceAll("DATE_FORMAT", "to_date");
|
||
sql=sql.replaceAll("ifnull", "nvl");
|
||
}
|
||
List<Map<String, String>> results = conn.executeQuery(sql, this.contractId,this.getPaymentnumber(),this.contractId,this.getPaymentnumber());
|
||
Map<String, String> detailInfo = results.get(0);
|
||
for(String key : detailInfo.keySet()){
|
||
jsonObject.appendElement(key, detailInfo.get(key));
|
||
}
|
||
if(detailInfo.size()>0){
|
||
String planDate=detailInfo.get("plandate");
|
||
BigDecimal fistCorpus= new BigDecimal(detailInfo.get("fist_corpus"));
|
||
// long numberDay=DateUtils.DateDays(this.paydayAdjust, planDate);
|
||
BizObject bo=bm.createQuery(" select * from O where contract_id=:contract_id").setParameter("contract_id", this.contractId).getSingleResult(false);
|
||
BigDecimal yearRate= new BigDecimal(bo!=null?bo.getAttribute(LC_CALC_CONDITION.YEAR_RATE).toString():"");
|
||
// BigDecimal repaymentInterest=fistCorpus.multiply(yearRate).divide(new BigDecimal(360), 20, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(numberDay));
|
||
// jsonObject.appendElement("REPAYMENT_INTEREST", repaymentInterest.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}catch(Exception e){
|
||
tx.rollback();
|
||
e.printStackTrace();
|
||
return "";
|
||
}finally{
|
||
tx.commit();
|
||
}
|
||
}
|
||
/**
|
||
* 获取投放方案 应收 应退
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String getTerminateOtherInfo() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
String fundSql = "select t2.sumplanin-ifnull(t1.sumchargein,0) fundin,t2.sumplanout- ifnull(t1.sumchargeout,0) fundout,max(lc.NOMINAL_PRICE) nominalprice from ( "
|
||
+ " select sum(case ffc.pay_type when 'pay_type_in' then ffc.fact_money else 0 end )sumchargein, "
|
||
+ " sum(case ffc.pay_type when 'pay_type_out' then ffc.fact_money else 0 end )sumchargeout, "
|
||
+ " min(ffc.contract_id) contractid,min(ffc.payment_number) paymentnumber "
|
||
+ " from LC_FUND_INCOME ffc where ffc.contract_id = ? and ffc.payment_number=? "
|
||
+ " )t1 right join "
|
||
+ " (select sum(case ffp.pay_type when 'pay_type_in' then ffp.plan_money else 0 end )sumplanin, "
|
||
+ " sum(case ffp.pay_type when 'pay_type_out' then ffp.plan_money else 0 end)sumplanout, "
|
||
+ " min(ffp.contract_id) contractid,min(ffp.payment_number) paymentnumber "
|
||
+ " from LC_FUND_PLAN ffp "
|
||
+ " where ffp.contract_id = ? and ffp.payment_number=? "
|
||
+ " )t2 on t1.contractid = t2.contractid and t1.paymentnumber=t2.paymentnumber left join lc_calc_condition lc on lc.CONTRACT_ID=t2.contractid";
|
||
if("ORACLE".equals(InitDBType.DBTYPE)){
|
||
fundSql=fundSql.replaceAll("ifnull", "nvl");
|
||
}
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
Conn conn = new Conn(tx);
|
||
List<Map<String, String>> list = conn.executeQuery(fundSql, this.contractId ,this.getPaymentnumber(), this.contractId,this.getPaymentnumber());
|
||
if(null != list && list.size() > 0 ){
|
||
Map<String, String> fundMap = list.get(0);
|
||
jsonObject.appendElement("OTHER_IN",fundMap.get("fundin"));
|
||
jsonObject.appendElement("OTHER_OUT",fundMap.get("fundout"));
|
||
jsonObject.appendElement("NOMINAL_PRICE",fundMap.get("nominalprice"));
|
||
}else{
|
||
jsonObject.appendElement("OTHER_IN","0");
|
||
jsonObject.appendElement("OTHER_OUT","0");
|
||
jsonObject.appendElement("NOMINAL_PRICE","0");
|
||
}
|
||
} catch (JBOException e) {
|
||
tx.rollback();
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
public String getTerminateOtherInfoFinish() throws Exception {
|
||
JSONObject jsonObject = JSONObject.createObject();
|
||
String fundSql = "select t2.sumplanin,t2.sumplanout,max(lc.NOMINAL_PRICE) nominalprice from ( "
|
||
+ " select sum(case ffc.pay_type when 'pay_type_in' then ffc.fact_money else 0 end )sumchargein, "
|
||
+ " sum(case ffc.pay_type when 'pay_type_out' then ffc.fact_money else 0 end )sumchargeout, "
|
||
+ " min(ffc.contract_id) contractid,min(ffc.payment_number) paymentnumber "
|
||
+ " from LC_FUND_INCOME ffc where ffc.contract_id = ? and ffc.payment_number=? "
|
||
+ " )t1 right join "
|
||
+ " (select sum(case ffp.pay_type when 'pay_type_in' then ffp.plan_money else 0 end )sumplanin, "
|
||
+ " sum(case ffp.pay_type when 'pay_type_out' then ffp.plan_money else 0 end)sumplanout, "
|
||
+ " min(ffp.contract_id) contractid,min(ffp.payment_number) paymentnumber "
|
||
+ " from LC_FUND_PLAN ffp "
|
||
+ " where ffp.contract_id = ? and ffp.payment_number=? and ffp.FEE_TYPE='feetype16' "
|
||
+ " )t2 on t1.contractid = t2.contractid and t1.paymentnumber=t2.paymentnumber left join lc_calc_condition lc on lc.CONTRACT_ID=t2.contractid";
|
||
if("ORACLE".equals(InitDBType.DBTYPE)){
|
||
fundSql=fundSql.replaceAll("ifnull", "nvl");
|
||
}
|
||
JBOTransaction tx=null;
|
||
try {
|
||
tx=JBOFactory.createJBOTransaction();
|
||
Conn conn = new Conn(tx);
|
||
List<Map<String, String>> list = conn.executeQuery(fundSql, this.contractId ,this.getPaymentnumber(), this.contractId,this.getPaymentnumber());
|
||
if(null != list && list.size() > 0 ){
|
||
Map<String, String> fundMap = list.get(0);
|
||
jsonObject.appendElement("OTHER_IN",fundMap.get("sumplanin"));
|
||
jsonObject.appendElement("OTHER_OUT",fundMap.get("sumplanout"));
|
||
jsonObject.appendElement("NOMINAL_PRICE",fundMap.get("nominalprice"));
|
||
}else{
|
||
jsonObject.appendElement("OTHER_IN","0");
|
||
jsonObject.appendElement("OTHER_OUT","0");
|
||
jsonObject.appendElement("NOMINAL_PRICE","0");
|
||
}
|
||
} catch (JBOException e) {
|
||
tx.rollback();
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(tx!=null){
|
||
tx.commit();
|
||
}
|
||
}
|
||
return JSONEncoder.encode(jsonObject);
|
||
}
|
||
|
||
public String rentPlanDate(){
|
||
JBOTransaction tx = null;
|
||
try {
|
||
tx = JBOFactory.createJBOTransaction();
|
||
String sql = "SELECT CASE WHEN COUNT(*) > 0 THEN MAX(PLAN_DATE) ELSE 'null' END date FROM lc_rent_plan WHERE DATE_FORMAT(PLAN_DATE, '%Y/%m/%d') <= DATE_FORMAT('"+this.paydayAdjust+"', '%Y/%m/%d') AND contract_id =?";
|
||
Conn conn = new Conn(tx);
|
||
List<Map<String, String>> dates = conn.executeQuery(sql, this.contractId);
|
||
Map<String, String> map = dates.get(0);
|
||
if("null".equals(map.get("date"))){
|
||
BizObjectManager lccMange = JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME);
|
||
BizObject lcc = lccMange.createQuery("contract_id=:contractid").setParameter("contractid", this.contractId).getSingleResult(false);
|
||
return lcc==null?"error":lcc.getAttribute("START_DATE").getString();
|
||
}else{
|
||
return map.get("date");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally {
|
||
try {
|
||
if(tx !=null) {
|
||
tx.commit();
|
||
}
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
return "error";
|
||
|
||
}
|
||
|
||
//校验合同是否有保证金代偿
|
||
public String isCompensation() throws Exception{
|
||
BizObjectManager lrpManage = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME);
|
||
List<BizObject> lrps = lrpManage.createQuery(" contract_id=:contractId AND COLLECT_STATUS='代偿' ").setParameter("contractId", contractId).getResultList(false);
|
||
if(lrps.size()>0){
|
||
return "false";
|
||
}
|
||
return "true";
|
||
}
|
||
//校验合同是否有正在卡扣中
|
||
public String isAutoBuckle() throws Exception{
|
||
BizObjectManager lrpManage = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME);
|
||
List<BizObject> lrps = lrpManage.createQuery(" contract_id=:contractId AND batch_status='process' and (collect_status in ('代偿','未收款','部分收款','') or collect_status is null)").setParameter("contractId", contractId).getResultList(false);
|
||
if(lrps.size()>0){
|
||
return "false";
|
||
}
|
||
return "true";
|
||
}
|
||
//校验合同是否有正在卡扣中
|
||
public String isAutoBuckleByPlanId() throws Exception{
|
||
String [] planIds = planId.split("@");
|
||
BizObjectManager lrpManage = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME);
|
||
for(int i= 0;i<planIds.length;i++){
|
||
List<BizObject> lrps = lrpManage.createQuery(" id=:planId AND batch_status='process' and (collect_status in ('代偿','未收款','部分收款','') or collect_status is null)").setParameter("planId", planIds[i]).getResultList(false);
|
||
if(lrps.size()>0){
|
||
return "false";
|
||
}
|
||
}
|
||
return "true";
|
||
}
|
||
//检验合同是否正在网银收款中(提前结清适用)
|
||
public String isOccupyRent() throws Exception{
|
||
List<BizObject> bol = JBOFactory.createBizObjectQuery(LC_OCCUPY_RENT_LIST.CLASS_NAME,"FLOW_NAME in ('网银收款','微信银联收款','微信支付收款') and payment_number=:payment_number").setParameter("payment_number", paymentnumber).getResultList(false);
|
||
if(bol.size()>0){
|
||
return "false";
|
||
}
|
||
return "true";
|
||
}
|
||
public String getContractId() {
|
||
return contractId;
|
||
}
|
||
|
||
public void setContractId(String contractId) {
|
||
this.contractId = contractId;
|
||
}
|
||
|
||
|
||
public String getStartList() {
|
||
return startList;
|
||
}
|
||
|
||
public void setStartList(String startList) {
|
||
this.startList = startList;
|
||
}
|
||
|
||
public String getPaydayAdjust() {
|
||
return paydayAdjust;
|
||
}
|
||
|
||
public void setPaydayAdjust(String paydayAdjust) {
|
||
this.paydayAdjust = paydayAdjust;
|
||
}
|
||
|
||
public String getPaymentnumber() {
|
||
return paymentnumber;
|
||
}
|
||
|
||
public void setPaymentnumber(String paymentnumber) {
|
||
this.paymentnumber = paymentnumber;
|
||
}
|
||
|
||
public String getPlanId() {
|
||
return planId;
|
||
}
|
||
|
||
public void setPlanId(String planId) {
|
||
this.planId = planId;
|
||
}
|
||
|
||
}
|