2022-02-27 13:57:21 +08:00

105 lines
5.3 KiB
Java
Raw Blame History

package com.tenwa.lease.app.quartzmession;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.Configure;
import com.amarsoft.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.base.util.QuartzUtil;
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
import com.tenwa.collectaudit.cache.CollectAuditInfoCacheTj;
import com.tenwa.comm.util.date.DateAssistant;
import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentQueryRun;
import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class AutoRefresh implements Job {
private static final Lock lock = new ReentrantLock();
private static boolean isHoldLock = false;
public static boolean getHoldLockStatus() {
return isHoldLock;
}
public static Lock getQuartzLock() {
return lock;
}
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
String plan_date = DateAssistant.getToday();
Object userId = arg0.getTrigger().getJobDataMap().get("CurUserId");
String curUserId = userId == null ? "system" : userId.toString();
boolean lockHoldStatus = lock.tryLock();
try {
if (lockHoldStatus) {
isHoldLock = true;
CollectAuditInfoCache ca = new CollectAuditInfoCache();
JBOTransaction tx = null;
try {
tx = JBOFactory.createJBOTransaction();
Transaction Sqlca = Transaction.createTransaction(tx);
String sSql = "SELECT STATUS FROM lb_card_buckle_status WHERE STATUS='Y' ";
SqlObject asql = new SqlObject(sSql);
ASResultSet rs = Sqlca.getASResultSet(asql);
if (rs.next()) {
return;
}
List<BizObject> bos = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('δ<>տ<EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>','<27><><EFBFBD><EFBFBD>') and O.SUBJECTID='aa740e4111c111eaaa0000163e0e11e6' and O.collect_type='YLcollect' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '" + plan_date + "'").getResultList(true);
StringBuilder ids = new StringBuilder();
if (bos != null && bos.size() > 0) {
for (BizObject bo : bos) {
ids.append(bo.getAttribute("id").getString()).append("@");
}
ca.setId(ids.toString().substring(0, ids.toString().length() - 1));
ca.setFileSavePath(Configure.getInstance().getConfigure("InterfaceFileSavePath"));
ca.setInputuserid("system");
ca.setInputorgid("system");
ca.queryBatchCollectStatus(tx);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
CollectAuditInfoCacheTj caTj = new CollectAuditInfoCacheTj();
List<BizObject> bosTj = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('δ<>տ<EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>','<27><><EFBFBD><EFBFBD>') and O.SUBJECTID='d989246c11c111eaaa0000163e0e11e6' and O.collect_type='YLcollect' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '" + plan_date + "'").getResultList(true);
StringBuilder idsTj = new StringBuilder();
if (bosTj != null && bosTj.size() > 0) {
for (BizObject bo : bosTj) {
idsTj.append(bo.getAttribute("id").getString()).append("@");
}
caTj.setId(idsTj.toString().substring(0, idsTj.toString().length() - 1));
caTj.setFileSavePath(Configure.getInstance().getConfigure("InterfaceFileSavePath"));
caTj.setInputuserid("system");
caTj.setInputorgid("system");
caTj.queryBatchCollectStatus(tx);
}
tx.commit();
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ۻ<EFBFBD><DBBB><EFBFBD>
new AllinpayPaymentQueryRun().allinpayPaymentQuerySt();
QuartzUtil.insertLog(plan_date, "com.tenwa.lease.app.quartzmession.AutoRefresh", "success", "<EFBFBD>ɹ<EFBFBD>", curUserId);
} catch (Exception e) {
if (tx != null) tx.rollback();
e.printStackTrace();
QuartzUtil.insertLog(plan_date, "com.tenwa.lease.app.quartzmession.AutoRefresh", "error", "ʧ<EFBFBD><EFBFBD>", curUserId);
}
} else {
QuartzUtil.insertLog(plan_date, "com.tenwa.lease.app.quartzmession.AutoRefresh", "lockerror", "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>", curUserId);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (lockHoldStatus) {
lock.unlock();
isHoldLock = false;
}
}
}
}