103 lines
3.7 KiB
Java

package com.tenwa.lease.app.quartzmession;
import java.util.ArrayList;
import java.util.List;
import jbo.app.tenwa.calc.LC_RENT_INCOME_TEMP;
import jbo.com.tenwa.lease.comm.LC_OCCUPY_RENT_LIST;
import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN;
import jbo.sys.FLOW_OBJECT;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.quartz.Trigger;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.Configure;
import com.base.util.QuartzUtil;
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
import com.tenwa.comm.util.date.DateAssistant;
public class AutoBuckle implements Job {
private JobInitUserName jboName;
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
CollectAuditInfoCache ca = new CollectAuditInfoCache();
JBOTransaction tx = null;
String plan_date = DateAssistant.getToday();
Object userId = arg0.getTrigger().getJobDataMap().get("CurUserId");
String curUserId = userId == null? "system" : userId.toString();
// 获取传递过来的参数
try {
//
tx = JBOFactory.createJBOTransaction();
//and (O.rent<>'' or O.rent<>'0' or O.rent<>'0.0')
List<BizObject> bos = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and O.PLAN_DATE <= '"+plan_date+"' and ( O.BATCH_STATUS<>'process' or o.BATCH_STATUS IS NULL ) ").getResultList(true);
List<BizObject> bol = JBOFactory.createBizObjectQuery(LC_OCCUPY_RENT_LIST.CLASS_NAME,"FLOW_NAME='网银收款'").getResultList(false);
//获取租金占用表里的数据有哪些是网银收款占用的
List<String> planIDs = new ArrayList<String>();
if(bol.size()>0){
for(int i=0;i<bol.size();i++){
String flowunid = bol.get(i).getAttribute("FLOWUNID").toString();
List<BizObject> bof = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid", flowunid).getResultList(false);
if(bof.size()>0){
for(int j=0;j<bof.size();j++){
String planID = bof.get(j).getAttribute("PLAN_ID").toString();
planIDs.add(planID);
}
}
}
}
StringBuffer ids = new StringBuffer();
if(bos.size()>0){
a:for(BizObject bo : bos){
String pid = bo.getAttribute("id").getString();
if(planIDs.size()>0){
for(int i=0;i<planIDs.size();i++){
if(pid.equals(planIDs.get(i))){
continue a;
}
}
}
ids.append(pid+"@");
}
System.out.println("本次扣款的plan_id:"+ids.toString());
ca.setId(ids.toString().substring(0, ids.toString().length()-1));
Configure CurConfig = Configure.getInstance();
ca.setFileSavePath(CurConfig.getConfigure("InterfaceFileSavePath"));
ca.setInputuserid(jboName.getUserId(arg0, tx));
ca.setInputorgid("system");
ca.batchCollectManage(tx);
ca.queryBatchCollectStatus(tx);
}
QuartzUtil.insertLog(plan_date,"com.tenwa.lease.app.quartzmession.AutoBuckle", "success", "成功", curUserId);
} catch (Exception e) {
e.printStackTrace();
QuartzUtil.insertLog(plan_date,"com.tenwa.lease.app.quartzmession.AutoBuckle", "error", "失败", curUserId);
if (tx != null) {
try {
tx.rollback();
tx=null;
} catch (JBOException e1) {
e1.printStackTrace();
}
}
}finally{
try {
if(tx !=null){
tx.commit();
}
} catch (JBOException e) {
e.printStackTrace();
}
}
}
}