apzl_leasing/src_tenwa/com/tenwa/flow/rent/copyrent/InsertRentPlanStatus.java

54 lines
2.9 KiB
Java

package com.tenwa.flow.rent.copyrent;
import java.math.BigDecimal;
import java.util.List;
import jbo.app.tenwa.calc.LC_RENT_INCOME;
import jbo.app.tenwa.calc.LC_RENT_INCOME_TEMP;
import jbo.app.tenwa.calc.LC_RENT_PLAN;
import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO;
import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.util.Transaction;
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
import com.tenwa.flow.baseBussion.BaseBussiness;
public class InsertRentPlanStatus extends BaseBussiness{
public Object run(Transaction Sqlca) throws Exception{
this.initBussinessParam(Sqlca.getTransaction());
String flowunid = (String)this.getAttribute("ObjectNo");
List<BizObject> boLRITs=JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME,"flowunid=:flowunid").setParameter("flowunid", flowunid).getResultList(false);
BizObjectManager bomLRP = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME, Sqlca.getTransaction());
CollectAuditInfoCache calc = new CollectAuditInfoCache();
for(int i=0;i<boLRITs.size();i++){
BizObject boLRIT = boLRITs.get(i);
String contractId = boLRIT.getAttribute("CONTRACT_ID").toString();
String planList = boLRIT.getAttribute("PLAN_LIST").toString();
String rentPlanId = boLRIT.getAttribute("PLAN_ID").toString();
String rent = boLRIT.getAttribute("rent").toString();
calc.writeBackDistributor(rentPlanId, rent, Sqlca);
//ÅжÏÊÇ·ñ»¹Íê
String sSql = "SELECT SUM(IFNULL(O.rent,0)) + SUM(IFNULL(O.penalty,0)) + SUM(IFNULL(O.corpus_adjust,0)) + SUM(IFNULL(O.interest_adjust,0)) + SUM(IFNULL(O.penalty_adjust,0)) - lrp.rent - getRentPenalty(lrp.payment_number,lrp.plan_list,DATE_FORMAT(SYSDATE(),'%Y/%m/%d')) AS flag FROM lc_rent_income O LEFT JOIN LC_RENT_PLAN lrp ON O.plan_id=lrp.id WHERE O.PLAN_ID='"+rentPlanId+"'";
String money = Sqlca.getString(sSql);
BigDecimal balance_money = new BigDecimal(money).setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println("===========×â½ð²î¶îΪ£º "+money);
//Èç¹ûΪ´ú³¥µÄ£¬ÔòÒÀÈ»ÊÇ´ú³¥×´Ì¬£¬Èç¹û·Ç´ú³¥£¬Ôò״̬Ϊ²¿·ÖÊÕ¿î
if(balance_money.compareTo(new BigDecimal("0"))==-1){
bomLRP.createQuery("update O set COLLECT_STATUS='²¿·ÖÊÕ¿î',COLLECT_MSG='ÍøÒøÊÕ¿î' where CONTRACT_ID=:CONTRACT_ID and PLAN_LIST=:PLAN_LIST and (collect_status <>'´ú³¥' or collect_status is null)")
.setParameter("CONTRACT_ID", contractId).setParameter("PLAN_LIST", planList).executeUpdate();
}else{
bomLRP.createQuery("update O set COLLECT_STATUS='ÍøÒøÊÕ¿î',COLLECT_MSG='ÍøÒøÊÕ¿î' where CONTRACT_ID=:CONTRACT_ID and PLAN_LIST=:PLAN_LIST")
.setParameter("CONTRACT_ID", contractId).setParameter("PLAN_LIST", planList).executeUpdate();
}
}
String sMessage="true";
return sMessage;
}
}