apzl_leasing/src_tenwa/com/tenwa/lease/app/quartzmession/SelectActualPaymentDate.java

206 lines
8.7 KiB
Java

package com.tenwa.lease.app.quartzmession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP;
import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT;
import jbo.com.tenwa.lease.comm.LC_FUND_INCOME_CALLBACK_DETAIL_TEMP;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
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.tenwa.sdk.VO.SDKCheckPayDateBackVO;
import com.tenwa.sdk.VO.SDKCheckPayDateDetail;
import com.tenwa.sdk.VO.SDKInfoVO;
import com.tenwa.sdk.VO.SDKToCheckPayDate;
import com.tenwa.sdk.VO.SDKTsinfx;
import com.tenwa.sdk.utils.HttpRequest;
import com.tenwa.sdk.utils.XMLStream;
import com.thoughtworks.xstream.XStream;
/**
* 1:获取实际付款流程的实际支付时间
* @author tangfutang
*/
public class SelectActualPaymentDate implements Job{
public void execute(JobExecutionContext arg0) throws JobExecutionException {
JBOTransaction tx=null;
try{
tx = JBOFactory.createJBOTransaction();
BizObjectManager lficdtMange = JBOFactory.getBizObjectManager(LC_FUND_INCOME_CALLBACK_DETAIL_TEMP.CLASS_NAME, tx);
List<BizObject> lficdtList = lficdtMange.createQuery(" isPaymentDate is null ").getResultList(true);
if(lficdtList!=null&&lficdtList.size()>0){
//查询深圳账户信息
BizObjectManager accountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME);
List<BizObject> accountBoList = accountManager.createQuery("select o.acc_number,o.acc_bank,o.acc_name,o.branch_code,oi.OWN_NAME from o left join jbo.com.tenwa.entity.comm.own.OWN_INFO oi on o.own_id = oi.OWN_NUMBER where o.money_type='01' and o.state_='0010' and o.acc_type='0010' and o.FbSdk='Y' and (o.account_type='out_account' or o.account_type='inAndOut_account') and oi.OWN_NAME='安鹏国际融资租赁(深圳)有限公司'").getResultList(false);
BizObject accountBo = accountBoList.get(0);
List<BizObject> accountBoList_tj = accountManager.createQuery("select o.acc_number,o.acc_bank,o.acc_name,o.branch_code,oi.OWN_NAME from o left join jbo.com.tenwa.entity.comm.own.OWN_INFO oi on o.own_id = oi.OWN_NUMBER where o.money_type='01' and o.state_='0010' and o.acc_type='0010' and o.FbSdk='Y' and (o.account_type='out_account' or o.account_type='inAndOut_account') and oi.OWN_NAME='安鹏融资租赁(天津)有限公司'").getResultList(false);
BizObject accountBo_tj = accountBoList_tj.get(0);
String nowDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
Calendar now = Calendar.getInstance();
now.add(Calendar.DAY_OF_MONTH, -2);
String startDate = new SimpleDateFormat("yyyyMMdd").format(now.getTime());
// String LGNNAM = "安鹏经办";
// String LGNNAM = "银企直连测试用户113";
Configure config = Configure.getInstance();
String LGNNAM = config.getConfigure("LGNNAM");
String FUNNAM = "GetTransInfo";
int DATTYP = 2;
SDKToCheckPayDate toCheckVO = new SDKToCheckPayDate();
SDKInfoVO checkInfo = new SDKInfoVO();
checkInfo.setDATTYP(DATTYP);
checkInfo.setFUNNAM(FUNNAM);
checkInfo.setLGNNAM(LGNNAM);
toCheckVO.setINFO(checkInfo);
List<SDKTsinfx> TsinfxList = new ArrayList<SDKTsinfx>();
SDKTsinfx tsinfx_sz = new SDKTsinfx();
tsinfx_sz.setBBKNBR(accountBo.getAttribute("branch_code").toString());
//tsinfx_sz.setC_BBKNBR(accountBo.getAttribute("acc_name").toString());
tsinfx_sz.setACCNBR(accountBo.getAttribute("acc_number").toString());
tsinfx_sz.setBGNDAT(startDate);
tsinfx_sz.setENDDAT(nowDate);
TsinfxList.add(tsinfx_sz);
/*SDKTsinfx tsinfx_tj = new SDKTsinfx();
tsinfx_tj.setC_BBKNBR(accountBo_tj.getAttribute("acc_name").toString());
tsinfx_tj.setACCNBR(accountBo_tj.getAttribute("acc_number").toString());
tsinfx_tj.setBGNDAT(startDate);
tsinfx_tj.setENDDAT(nowDate);
TsinfxList.add(tsinfx_tj);*/
toCheckVO.setSDKTSINFX(tsinfx_sz);
XStream xStream = new XMLStream();
xStream.alias("SDKTSINFX", SDKTsinfx.class);
xStream.alias("CMBSDKPGK", SDKToCheckPayDate.class);
String xmlStr = xStream.toXML(toCheckVO);
xmlStr = xmlStr.replace("<ntstLinFxList>", "").replace("</ntstLinFxList>", "").replace("<ntstLinFxList/>", "");
HttpRequest request = new HttpRequest();
String data = xmlStr;
SDKCheckPayDateBackVO result = request.sendPayDateRequest(data);
if(result==null) {
System.out.println("请求出错!!!");
}
if(result.getInfo().getSTATUS()==1) {
for (BizObject lficdt : lficdtList) {
List<SDKCheckPayDateDetail> details = result.getDetails();
if(details!=null&&details.size()>0){
for (SDKCheckPayDateDetail detail : details) {
if(lficdt.getAttribute("REQNBR").toString().equals(detail.getREQNBR())){
BizObjectManager lfitManage = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME, tx);
BizObject lfit = lfitManage.createQuery(" flowunid=:flowunid and contract_id=:contractid and pay_type='pay_type_out' ").setParameter("flowunid", lficdt.getAttribute("flowunid").toString()).setParameter("contractid", lficdt.getAttribute("contract_id").toString()).getSingleResult(true);
if(lfit == null){
System.out.println(lficdt.getAttribute("REQNBR").toString()+"该流程实例没有找到对应的付款计划");
break;
}else{
String format = detail.getETYDAT();
String date = format.substring(0, 4)+"/"+format.substring(4,6)+"/"+format.substring(6, 8);
lfit.setAttributeValue("FACT_DATE", date);
lfitManage.saveObject(lfit);
lficdt.setAttributeValue("isPaymentDate", "01");
lficdt.setAttributeValue("PaymentDate",date);
lficdtMange.saveObject(lficdt);
break;
}
}
}
}
}
}
TsinfxList.clear();
SDKTsinfx tsinfx_tj = new SDKTsinfx();
tsinfx_tj.setBBKNBR(accountBo_tj.getAttribute("branch_code").toString());
//tsinfx_sz.setC_BBKNBR(accountBo.getAttribute("acc_name").toString());
tsinfx_tj.setACCNBR(accountBo_tj.getAttribute("acc_number").toString());
tsinfx_tj.setBGNDAT(startDate);
tsinfx_tj.setENDDAT(nowDate);
TsinfxList.add(tsinfx_tj);
toCheckVO.setSDKTSINFX(tsinfx_tj);
xStream = new XMLStream();
xStream.alias("SDKTSINFX", SDKTsinfx.class);
xStream.alias("CMBSDKPGK", SDKToCheckPayDate.class);
xmlStr = xStream.toXML(toCheckVO);
xmlStr = xmlStr.replace("<ntstLinFxList>", "").replace("</ntstLinFxList>", "").replace("<ntstLinFxList/>", "");
request = new HttpRequest();
data = xmlStr;
result = request.sendPayDateRequest(data);
if(result==null) {
System.out.println("请求出错!!!");
}
if(result.getInfo().getSTATUS()==1) {
for (BizObject lficdt : lficdtList) {
List<SDKCheckPayDateDetail> details = result.getDetails();
if(details!=null&&details.size()>0){
for (SDKCheckPayDateDetail detail : details) {
if(lficdt.getAttribute("REQNBR").toString().equals(detail.getREQNBR())){
BizObjectManager lfitManage = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME, tx);
BizObject lfit = lfitManage.createQuery(" flowunid=:flowunid AND contract_id=:contractid and pay_type='pay_type_out' ").setParameter("flowunid", lficdt.getAttribute("flowunid").toString()).setParameter("contractid", lficdt.getAttribute("contract_id").toString()).getSingleResult(true);
if(lfit == null){
System.out.println(lficdt.getAttribute("REQNBR").toString()+"该流程实例没有找到对应的付款计划");
break;
}else{
String format = detail.getETYDAT();
String date = format.substring(0, 4)+"/"+format.substring(4,6)+"/"+format.substring(6, 8);
lfit.setAttributeValue("FACT_DATE", date);
lfitManage.saveObject(lfit);
lficdt.setAttributeValue("isPaymentDate", "01");
lficdt.setAttributeValue("PaymentDate", date);
lficdtMange.saveObject(lficdt);
break;
}
}
}
}
}
}
}
}catch(Exception e){
try {
tx.rollback();
} catch (JBOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}finally {
if(tx!=null) {
try {
tx.commit();
} catch (JBOException e) {
e.printStackTrace();
}
}
}
}
}