增加定时任务,将还款文件信息拷贝至租金计划表

This commit is contained in:
ap007 2021-07-07 16:08:41 +08:00
parent d56af5de4b
commit 71bf132799
6 changed files with 377 additions and 49 deletions

View File

@ -301,6 +301,7 @@
</managerProperties>
</manager>
</class>
<class name="FC_REQUEST" label="接口状态表" describe="邮储/九江申请状态页面" keyAttributes="ID">
<attributes>
<attribute name="ID" label="资金渠道申请ID" type="STRING" length="32" />
@ -331,6 +332,7 @@
</managerProperties>
</manager>
</class>
<class name="FC_REQUEST_FILE" label="接口资料表" describe="邮储/九江资料页面" keyAttributes="ID">
<attributes>
<attribute name="ID" label="唯一标识" type="STRING" length="32" />
@ -340,6 +342,7 @@
<attribute name="FC_FILE_CODE" label="资方:文件编号" type="STRING" length="32"/>
<attribute name="FC_FILE_CODE_NAME" label="资方:文件编号名称" type="STRING" length="32"/>
<attribute name="FC_FILE_TYPE" label="资方文件类型JPG,PNG,FDP等" type="STRING" length="32"/>
<attribute name="FILE_TYPE" label="例如image/jpeg等" type="STRING" length="32"/>
<attribute name="FILE_NAME" label="文件名称" type="STRING" length="32"/>
<attribute name="FILE_PATH" label="文件路径" type="STRING" length="32"/>
<attribute name="FC_FILE_STS" label="文件状态" type="STRING" length="32"/>
@ -357,19 +360,47 @@
</managerProperties>
</manager>
</class>
<class name="FC_REQUEST_FILE_PUSH" label="接口资料推送状态" describe="接口资料推送状态" keyAttributes="ID">
<class name="FC_FILE_PUSH" label="对账文件信息" describe="对账文件信息" keyAttributes="ID">
<attributes>
<attribute name="ID" label="唯一标识" type="STRING" length="32" />
<attribute name="FC_REQUEST_ID" label="资金渠道申请ID" type="STRING" length="32"/>
<attribute name="PUSH_STS" label="文件状态" type="STRING" length="32"/>
<attribute name="PUSH_STS_DESC" label="文件状态描述" type="STRING" length="32"/>
<attribute name="CHANNEL_NO" label="渠道编码" type="STRING" length="32"/>
<attribute name="CHANNEL_NAME" label="渠道名称" type="STRING" length="32"/>
<attribute name="FC_FILE_PUSH_NAME" label="当前推送文件名称" type="STRING" length="32"/>
<attribute name="FILE_TYPE" label="文件类型" type="STRING" length="32"/>
<attribute name="FILE_NAME" label="文件名称" type="STRING" length="32"/>
<attribute name="FILE_PATH" label="文件路径" type="STRING" length="32"/>
<attribute name="FILE_STS" label="文件状态0,下载失败1、解析失败2、解析成功3、拷贝成功" type="STRING" length="32"/>
<attribute name="FILE_STS_DESC" label="文件状态描述" type="STRING" length="32"/>
<attribute name="ORDER_COUNT" label="文件包含订单数量" type="STRING" length="32"/>
<attribute name="CREATE_TIME" label="创建时间" type="STRING" length="32"/>
<attribute name="UPDATE_TIME" label="修改时间" type="STRING" length="32"/>
<attribute name="DEL_FLAG" label="有效标志" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="fc_request_file_push"/>
<property name="table" value="fc_file_push"/>
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
<class name="FC_YC_FILE_REPAY_PLAN" label="资方租金计划信息" describe="资方租金计划信息" keyAttributes="ID">
<attributes>
<attribute name="ID" label="唯一标识" type="STRING" length="32" />
<attribute name="FC_FILE_ID" label="资金渠道申请ID" type="STRING" length="32"/>
<attribute name="FC_REQUEST_ID" label="资金渠道申请ID" type="STRING" length="32"/>
<attribute name="LOAN_NO" label="放款申请编号" type="STRING" length="32"/>
<attribute name="LEND_TERM" label="期次" type="STRING" length="32"/>
<attribute name="ANS_REPAYMENT_DATE" label="还款日期" type="STRING" length="32"/>
<attribute name="ANS_PRINCIPAL" label="本金" type="STRING" length="32"/>
<attribute name="ANS_INTEREST" label="利息" type="STRING" length="32"/>
<attribute name="ANS_REPAYMENT_MONEY" label="租金" type="STRING" length="32"/>
<attribute name="CREATE_TIME" label="创建时间" type="STRING" length="32"/>
<attribute name="UPDATE_TIME" label="修改时间" type="STRING" length="32"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="fc_yc_file_repay_plan"/>
<property name="createKey" value="true" />
</managerProperties>
</manager>

View File

@ -0,0 +1,64 @@
package jbo.oti;
/**
* 接口资料表 - JBO命名常量类<br><br>
* Note: This file is generated by ADE tools, <em>dont</em> modify it.<br>
*/
public interface FC_FILE_PUSH {
/**
* 接口资料表<br><br>
* 代表本类映射的BizObjectClass
*/
public static final String CLASS_NAME = "jbo.oti.FC_FILE_PUSH";
/**
* 唯一标识 STRING(32)<br>
*/
public static final String ID = "ID";
/**
* 渠道编号 STRING(32)<br>
*/
public static final String CHANNEL_NO = "CHANNEL_NO";
/**
* 渠道名称 STRING(32)<br>
*/
public static final String CHANNEL_NAME = "CHANNEL_NAME";
/**
* 当前推送文件名称 STRING(32)<br>
*/
public static final String FC_FILE_PUSH_NAME = "FC_FILE_PUSH_NAME";
/**
* 文件类型 STRING(32)<br>
*/
public static final String FILE_TYPE = "FILE_TYPE";
/**
* 文件名称 STRING(32)<br>
*/
public static final String FILE_NAME = "FILE_NAME";
/**
* 文件路径 STRING(32)<br>
*/
public static final String FILE_PATH = "FILE_PATH";
/**
* 文件状态 STRING(32)<br>
*/
public static final String FILE_STS = "FILE_STS";
/**
* 文件状态描述 STRING(32)<br>
*/
public static final String FILE_STS_DESC = "FILE_STS_DESC";
/**
* 包含订单数量 STRING(32)<br>
*/
public static final String ORDER_COUNT = "ORDER_COUNT";
/**
* 创建时间 STRING(32)<br>
*/
public static final String CREATE_TIME = "CREATE_TIME";
/**
* 修改时间 STRING(32)<br>
*/
public static final String UPDATE_TIME = "UPDATE_TIME";
}

View File

@ -41,6 +41,10 @@ public interface FC_REQUEST_FILE{
* 资方文件类型JPG,PNG,FDP等 STRING(32)<br>
*/
public static final String FC_FILE_TYPE = "FC_FILE_TYPE";
/**
* 资方文件类型JPG,PNG,FDP等 STRING(32)<br>
*/
public static final String FILE_TYPE = "FILE_TYPE";
/**
* 文件名称 STRING(32)<br>
*/

View File

@ -1,43 +0,0 @@
package jbo.oti;
/**
* 接口资料表 - JBO命名常量类<br><br>
* Note: This file is generated by ADE tools, <em>dont</em> modify it.<br>
*/
public interface FC_REQUEST_FILE_PUSH {
/**
* 接口资料表<br><br>
* 代表本类映射的BizObjectClass
*/
public static final String CLASS_NAME = "jbo.oti.FC_REQUEST_FILE_PUSH";
/**
* 唯一标识 STRING(32)<br>
*/
public static final String ID = "ID";
/**
* 资金渠道申请ID STRING(32)<br>
*/
public static final String FC_REQUEST_ID = "FC_REQUEST_ID";
/**
* 文件状态 STRING(32)<br>
*/
public static final String FC_FILE_STS = "PUSH_STS";
/**
* 文件状态描述 STRING(32)<br>
*/
public static final String FC_FILE_STS_DESC = "PUSH_STS_DESC";
/**
* 创建时间 STRING(32)<br>
*/
public static final String CREATE_TIME = "CREATE_TIME";
/**
* 修改时间 STRING(32)<br>
*/
public static final String UPDATE_TIME = "UPDATE_TIME";
/**
* 有效标志 STRING(32)<br>
*/
public static final String DEL_FLAG = "DEL_FLAG";
}

View File

@ -0,0 +1,59 @@
package jbo.oti;
/**
* 接口资料表 - JBO命名常量类<br><br>
* Note: This file is generated by ADE tools, <em>dont</em> modify it.<br>
*/
public interface FC_YC_FILE_REPAY_PLAN {
/**
* 接口资料表<br><br>
* 代表本类映射的BizObjectClass
*/
public static final String CLASS_NAME = "jbo.oti.FC_YC_FILE_REPAY_PLAN";
/**
* 唯一标识 STRING(32)<br>
*/
public static final String ID = "ID";
/**
* 文件ID STRING(32)<br>
*/
public static final String FC_FILE_ID = "FC_FILE_ID";
/**
* 资金渠道申请ID STRING(32)<br>
*/
public static final String FC_REQUEST_ID = "FC_REQUEST_ID";
/**
* 放款请求编号 STRING(32)<br>
*/
public static final String LOAN_NO = "LOAN_NO";
/**
* 期次 STRING(32)<br>
*/
public static final String LEND_TERM = "LEND_TERM";
/**
* 还款日期 STRING(32)<br>
*/
public static final String ANS_REPAYMENT_DATE = "ANS_REPAYMENT_DATE";
/**
* 本金 STRING(32)<br>
*/
public static final String ANS_PRINCIPAL = "ANS_PRINCIPAL";
/**
* 利息 STRING(32)<br>
*/
public static final String ANS_INTEREST = "ANS_INTEREST";
/**
* 租金 STRING(32)<br>
*/
public static final String ANS_REPAYMENT_MONEY = "ANS_REPAYMENT_MONEY";
/**
* 创建时间 STRING(32)<br>
*/
public static final String CREATE_TIME = "CREATE_TIME";
/**
* 修改时间 STRING(32)<br>
*/
public static final String UPDATE_TIME = "UPDATE_TIME";
}

View File

@ -0,0 +1,213 @@
package com.tenwa.lease.app.quartzmession;
import com.amarsoft.are.jbo.*;
import com.amarsoft.are.util.StringFunction;
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.reckon.executor.CreateTransactionExecutor;
import jbo.app.tenwa.calc.LC_CALC_CONDITION;
import jbo.app.tenwa.calc.LC_RENT_PLAN;
import jbo.oti.FC_FILE_PUSH;
import jbo.oti.FC_YC_FILE_REPAY_PLAN;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static java.math.BigDecimal.ROUND_HALF_UP;
/**
* 资方租金计划拷贝
*/
public class CorpusSourceRentPlanCopy implements Job {
Set<String> contractSet = null;
JBOTransaction tx = null;
Transaction Sqlca = null;
{
try {
tx = JBOFactory.createJBOTransaction();
Sqlca = Transaction.createTransaction(tx);
} catch (JBOException e) {
e.printStackTrace();
try {
if (Sqlca != null) {
Sqlca.rollback();
}
} catch (JBOException e1) {
e1.printStackTrace();
}
}
}
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
String startime = StringFunction.getTodayNow();
Object userId = jobExecutionContext.getTrigger().getJobDataMap().get("CurUserId");
String curUserId = userId == null? "system" : userId.toString();
BizObjectManager ffpBom = null;
BizObjectManager fyfrpBom = null;
try {
ffpBom = JBOFactory.getBizObjectManager(FC_FILE_PUSH.CLASS_NAME,tx);
fyfrpBom = JBOFactory.getBizObjectManager(FC_YC_FILE_REPAY_PLAN.CLASS_NAME,tx);
//todo 添加渠道商的选择哪些需要拷表哪些不需要
List<BizObject> ffpBoList = ffpBom.createQuery("select ID,FILE_STS from O where FILE_STS='2'").getResultList(true);
for(BizObject ffpBo : ffpBoList){
String fcFileId = ffpBo.getAttribute("ID").toString();
//更新租金计划租金信息并获取每个文件的contract_id
String sql = "select fr.CONTRACT_ID,O.LEND_TERM,O.ANS_REPAYMENT_DATE,O.ANS_PRINCIPAL,O.ANS_INTEREST,ANS_REPAYMENT_MONEY from O left join jbo.oti.FC_REQUEST fr on O.FC_REQUEST_ID=fr.ID where fr.DEL_FLAG='0' and O.FC_FILE_ID=:fcFileId";
List<BizObject> fyfrpBoList = fyfrpBom.createQuery(sql).setParameter("fcFileId",fcFileId).getResultList(false);
contractSet = this.updateRentPlan(fyfrpBoList);
//更新租金计划剩余本金
updateAllRemainCorpus();
//更新租金计划分润信息
updateSplitSP();
ffpBo.setAttributeValue("FILE_STS","3");
ffpBo.setAttributeValue("FILE_STS_DESC","拷贝成功");
ffpBom.saveObject(ffpBo);
}
Sqlca.commit();
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.CorpusSourceRentPlanCopy", "success", "成功", curUserId);
} catch (Exception e) {
e.printStackTrace();
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.CorpusSourceRentPlanCopy", "error", "失败", curUserId);
try {
if (Sqlca != null) {
Sqlca.rollback();
}
} catch (JBOException e1) {
e1.printStackTrace();
}
throw new JobExecutionException(e);
}
}
/**
* 租金计划拷贝
* @param fyfrpBoList 每个回执文件包含的租金计划信息
* @return 每个回执文件包含的contract_id
* @throws JBOException
* @throws ParseException
*/
public Set<String> updateRentPlan(List<BizObject> fyfrpBoList) throws JBOException, ParseException {
BizObjectManager lrpBom = null;
lrpBom = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,tx);
contractSet = new HashSet<>();
//更新租金计划表
for(BizObject bo : fyfrpBoList){
//获取参数
String contractId = bo.getAttribute("CONTRACT_ID").toString();
String lendTerm = bo.getAttribute("LEND_TERM").toString();
String principal = bo.getAttribute("ANS_PRINCIPAL").toString();
String interest = bo.getAttribute("ANS_INTEREST").toString();
String repaymentMoney = bo.getAttribute("ANS_REPAYMENT_MONEY").toString();
String repaymentDate = bo.getAttribute("ANS_REPAYMENT_DATE").toString();
//转换日期格式
Date date = new SimpleDateFormat("yyyyMMdd").parse(repaymentDate);
repaymentDate = new SimpleDateFormat("yyyy/MM/dd").format(date);
//更新租金计划表
BizObject lrpBo = lrpBom.createQuery("CONTRACT_ID=:contractId and PLAN_LIST=:lendTerm").setParameter("contractId",contractId).setParameter("lendTerm",lendTerm).getSingleResult(true);
lrpBo.setAttributeValue("RENT",repaymentMoney);
lrpBo.setAttributeValue("CORPUS",principal);
lrpBo.setAttributeValue("INTEREST",interest);
lrpBo.setAttributeValue("CORPUS_BUSINESS",principal);
lrpBo.setAttributeValue("INTEREST_BUSINESS",interest);
lrpBo.setAttributeValue("PLAN_DATE",repaymentDate);
lrpBo.setAttributeValue("RENT",repaymentMoney);
lrpBom.saveObject(lrpBo);
//放进set去重
contractSet.add(contractId);
}
return contractSet;
}
/**
* 更新剩余本金信息
* @throws JBOException
*/
public void updateAllRemainCorpus() throws JBOException {
BizObjectManager lrpBom = null;
lrpBom = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,tx);
BizObjectManager lccBom = null;
lccBom = JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME,tx);
//根据contractId遍历循环来更新租金计划表中剩余本金字段
for(String contractId : contractSet){
BizObject lccBo = lccBom.createQuery("select CLEAN_LEASE_MONEY from O where contract_id=:contractId").setParameter("contractId",contractId).getSingleResult(false);
String clean_lease_money = lccBo.getAttribute("CLEAN_LEASE_MONEY").toString();
BigDecimal cleanLeaseMoneyBd = new BigDecimal(clean_lease_money);
List<BizObject> lrpBos= lrpBom.createQuery("contract_id=:contractId order by plan_list").setParameter("contractId",contractId).getResultList(true);
for(BizObject bo :lrpBos){
String corpus = bo.getAttribute("corpus").toString();
BigDecimal corpusBd = new BigDecimal(corpus);
cleanLeaseMoneyBd = cleanLeaseMoneyBd.subtract(corpusBd).setScale(2,ROUND_HALF_UP);
bo.setAttributeValue("ALL_REMAIN_CORPUS",cleanLeaseMoneyBd.toString());
lrpBom.saveObject(bo);
}
}
}
/**
* 更新分润信息
* @throws Exception
*/
public void updateSplitSP() throws Exception {
for(String contractId : contractSet) {
String sql = "select lci.product_id,lci.distributor_id,lcc.payment_number from lb_contract_info lci left join lc_calc_condition lcc on lci.id=lcc.contract_id where lci.id='" + contractId + "'";
SqlObject sqlBo = null;
String productId = null;
String distributorId = null;
String paymentNumber = null;
ASResultSet rs = null;
try {
sqlBo = new SqlObject(sql);
rs = Sqlca.getASResultSet(sqlBo);
if ( rs.next() ) {
productId = rs.getString( "product_id" );
distributorId = rs.getString( "distributor_id" );
paymentNumber = rs.getString( "payment_number" );
String splitType = Sqlca.getString("select attribute5 from business_type where typeno = '" + productId + "'");
String splittingRatio = Sqlca.getString("select splitting_ratio from lb_splitting_ratio where distributor_id='" + distributorId + "' and product_id='" + productId + "'");
if (!"".equals(splittingRatio) && splittingRatio != null) {
CreateTransactionExecutor cre = new CreateTransactionExecutor();
cre.setPlannumber(paymentNumber);
cre.insertRentPlan_SP(splittingRatio, Sqlca, splitType);
}
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}finally {
rs.close();
}
}
}
public Set<String> getContractSet() {
return contractSet;
}
public void setContractSet(Set<String> contractSet) {
this.contractSet = contractSet;
}
}