邮储逾期回购生成凭证
This commit is contained in:
parent
df4a641f16
commit
63a789bde2
@ -0,0 +1,503 @@
|
||||
package com.tenwa.voucher.serviceImp;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.*;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
|
||||
import com.amarsoft.dict.als.manage.NameManager;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tenwa.app.manage.qiyuesuo.v2.ContractSignVtwoUtils;
|
||||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||||
import com.tenwa.flow.util.FlowUtil;
|
||||
import com.tenwa.reckon.util.DateUtil;
|
||||
import com.tenwa.reckon.util.UUIDUtil;
|
||||
import com.tenwa.voucher.service.VoucherInfoService;
|
||||
import jbo.app.VOUCHER_V8;
|
||||
import jbo.app.tenwa.customer.CUSTOMER_LIST;
|
||||
import jbo.com.tenwa.entity.comm.own.OWN_INFO;
|
||||
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 代偿-资方邮储逾期回购-助贷-购置融资租赁资产
|
||||
*/
|
||||
public class OverdueRepurchaseVoucherPSBC implements VoucherInfoService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OverdueRepurchaseVoucherPSBC.class);
|
||||
|
||||
private static final String VOUCHER_CONFIG_NO_1 = "PZ2021081700000026";//代偿-资方邮储逾期回购-助贷-购置融资租赁资产凭证编号
|
||||
private static final String VOUCHER_CONFIG_NO_2 = "PZ2021081800000029";//代偿-资方邮储逾期回购-助贷-合同起租凭证编号
|
||||
private static final String CORPUS_CHANNEL_NO = "PSBC";//邮储银行编号
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Transaction Sqlca =null;
|
||||
try {
|
||||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||||
generateVoucher(Sqlca);
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if(Sqlca!=null){
|
||||
Sqlca.disConnect();
|
||||
Sqlca = null;
|
||||
}
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
Sqlca.rollback();
|
||||
} catch (JBOException jboException) {
|
||||
jboException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成所有凭证
|
||||
* @param Sqlca
|
||||
* @throws Exception
|
||||
*/
|
||||
public void generateVoucher(Transaction Sqlca) throws Exception {
|
||||
Sqlca.getConnection();
|
||||
JBOTransaction tx = Sqlca.getTransaction();
|
||||
//获取所有需要生成凭证的合同
|
||||
List<Map<String,String>> loanInfoList = findHasLoanContract(CORPUS_CHANNEL_NO);
|
||||
if(CollectionUtils.isEmpty(loanInfoList)){
|
||||
logger.warn("OverdueRepurchaseVoucherPSBC20210818 获取所有需要生成凭证的合同 记录为空 -- 定时任务执行结束");
|
||||
return;
|
||||
}
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 获取所有需要生成凭证的合同 记录条数:" + loanInfoList.size());
|
||||
//遍历所有需要生成凭证的合同
|
||||
for(Map<String,String> loanInfo : loanInfoList){
|
||||
//金额计算
|
||||
String contractId = loanInfo.get("contractId");//合同id
|
||||
String actualPaymentBackAmount = loanInfo.get("buyback_money");//实际偿还总额
|
||||
String outstandingPrincipal = findOutstandingPrincipal(contractId, Sqlca);//未还本金
|
||||
String outstandingInterest = findOutstandingInterest(contractId, Sqlca);//未还利息
|
||||
String overdueInterest = findOverdueInterest(actualPaymentBackAmount, outstandingPrincipal);//未还罚息利息
|
||||
String customerNo = findCustomerNoByContractId(contractId, Sqlca);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 查找客户编号信息:customerNo=" + customerNo);
|
||||
loanInfo.put("customerNo", customerNo);
|
||||
for(String voucherConfigNo : Lists.newArrayList(VOUCHER_CONFIG_NO_1, VOUCHER_CONFIG_NO_2)){
|
||||
String voucherNo ="k" + FlowUtil.getVoucher_Number(tx);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 voucherNo=" + voucherNo);
|
||||
loanInfo.put("voucherNo", voucherNo);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 开始收集参数:initFinalParam");
|
||||
//获取最终参数
|
||||
List<Map<String,String>> paramList = initFinalParam(loanInfo, voucherConfigNo,
|
||||
actualPaymentBackAmount, outstandingPrincipal, outstandingInterest, overdueInterest);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 收集参数完毕:initFinalParam, paramList=" + JSONObject.toJSONString(paramList));
|
||||
//生成凭证
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 开始生成凭证:createVoucher, voucherNo=" + voucherNo);
|
||||
createVoucher(paramList,tx);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 生成凭证结束:createVoucher, voucherNo=" + voucherNo);
|
||||
}
|
||||
//更新凭证信息状态
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 开始更新凭证信息状态:updateVoucherStatus, contractId=" + contractId);
|
||||
updateVoucherStatus(loanInfo.get("overdue_back_id"), Sqlca);
|
||||
//逾期信息添加
|
||||
addOverdueRepayPlan(loanInfo, Sqlca);
|
||||
logger.info("OverdueRepurchaseVoucherPSBC20210818 更新凭证信息状态结束:updateVoucherStatus, overdue_back_id=" + loanInfo.get("overdue_back_id"));
|
||||
logger.info("定时任务 ============="+CORPUS_CHANNEL_NO+":合同编号为"+loanInfo.get("contractNo")+"的放款凭证生成完毕============");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 未还本金
|
||||
* @return
|
||||
*/
|
||||
private String findOutstandingPrincipal(String contractId, Transaction Sqlca) throws Exception {
|
||||
String sqlPrincipal = "SELECT SUM(CORPUS) from lc_rent_plan WHERE CONTRACT_ID='"+contractId+"'";//总本金
|
||||
String sqlRepaymentPrincipal = "SELECT SUM(CORPUS) from lc_rent_income WHERE CONTRACT_ID='"+contractId+"'";//已还本金
|
||||
String amountPrincipal = Sqlca.getString(sqlPrincipal);
|
||||
String amountRepaymentPrincipal = Sqlca.getString(sqlRepaymentPrincipal);
|
||||
if(StringUtils.isEmpty(amountPrincipal) || StringUtils.isEmpty(amountRepaymentPrincipal)){
|
||||
logger.warn("contractId="+ contractId + "生成凭证,查询本金信息失败。");
|
||||
throw new Exception("contractId="+ contractId + "生成凭证,查询本金信息失败。");
|
||||
}
|
||||
BigDecimal amount = new BigDecimal(amountPrincipal).subtract(new BigDecimal(amountRepaymentPrincipal));
|
||||
return amount.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逾期罚息利息
|
||||
* @param actualPaymentBackAmount 回购金额
|
||||
* @param outstandingPrincipal 未还本金
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String findOverdueInterest(String actualPaymentBackAmount, String outstandingPrincipal) throws Exception {
|
||||
if(StringUtils.isEmpty(actualPaymentBackAmount) || StringUtils.isEmpty(outstandingPrincipal)){
|
||||
logger.warn("生成凭证,查询逾期罚息利息信息失败。");
|
||||
throw new Exception("生成凭证,查询逾期罚息利息信息失败。");
|
||||
}
|
||||
BigDecimal amount = new BigDecimal(actualPaymentBackAmount).subtract(new BigDecimal(outstandingPrincipal));
|
||||
return amount.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 未到期利息总额
|
||||
* @return
|
||||
*/
|
||||
private String findOutstandingInterest(String contractId, Transaction Sqlca) throws Exception {
|
||||
String sqlInterest = "SELECT SUM(INTEREST) from lc_rent_plan WHERE CONTRACT_ID='"+contractId+"'";//总利息
|
||||
String sqlRepaymentInterest = "SELECT SUM(INTEREST) from lc_rent_income WHERE CONTRACT_ID='"+contractId+"'";//已还利息
|
||||
String amountInterest = Sqlca.getString(sqlInterest);
|
||||
String amountRepaymentInterest = Sqlca.getString(sqlRepaymentInterest);
|
||||
if(StringUtils.isEmpty(amountInterest) || StringUtils.isEmpty(amountRepaymentInterest)){
|
||||
logger.warn("contractId="+ contractId + "生成凭证,查询未到期利息总额信息失败。");
|
||||
throw new Exception("contractId="+ contractId + "生成凭证,查询未到期利息总额信息失败。");
|
||||
}
|
||||
BigDecimal amount = new BigDecimal(amountInterest).subtract(new BigDecimal(amountRepaymentInterest));
|
||||
return amount.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要生成凭证的合同以及对应信息
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<Map<String,String>> findHasLoanContract(String channelNo) throws Exception {
|
||||
// : 2021/8/19 buyback_money 实际支付回购金额
|
||||
String sql = "select frc.id as overdue_back_id, fr.customer_name as customerName,frc.inputtime as createTime, " +
|
||||
" fr.CONTRACT_ID as contractId,fr.CONTRACT_NO as contractNo,fr.ID as fc_request_id,frc.buyback_money " +
|
||||
"from fc_buyback_info frc " +
|
||||
"left join fc_yc_file_repay_result ffr on frc.fc_request_id = ffr.FC_REQUEST_ID " +
|
||||
"left join fc_request fr on frc.fc_request_id = fr.ID " +
|
||||
"where frc.voucher_status='0' and fr.DEL_FLAG='0' and fr.CHANNEL_NO='"+channelNo+"' and ffr.REPAYMENT_FLAG='3' and ffr.REPAYMENT_SOURCE='1' and ffr.ID is not null ";
|
||||
return DataOperatorUtil.getDataBySql(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据合同id查询客户编号
|
||||
* @param contractId
|
||||
* @param Sqlca
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String findCustomerNoByContractId(String contractId,Transaction Sqlca) throws Exception {
|
||||
String sql = "select ci.customer_num from customer_info ci left join lb_union_lessee lul on lul.CUSTOMER_ID=ci.customerid and lul.IS_MAIN='Y' where lul.CONTRACT_ID='"+contractId+"'";
|
||||
String customerNo = Sqlca.getString(sql);
|
||||
return customerNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最终的参数
|
||||
* @param loanInfo
|
||||
* @param voucherConfigNo
|
||||
* @param actualPaymentBackAmount 实际偿还总额
|
||||
* @param outstandingPrincipal 未还本金
|
||||
* @param outstandingInterest 未还利息
|
||||
* @param overdueInterest 未还罚息利息
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<Map<String,String>> initFinalParam(Map<String,String> loanInfo, String voucherConfigNo,String actualPaymentBackAmount,
|
||||
String outstandingPrincipal, String outstandingInterest, String overdueInterest) throws Exception {
|
||||
List<Map<String,String>> paramList = findParamOfVoucher(voucherConfigNo);
|
||||
for(Map<String,String> param : paramList){
|
||||
//将公共参数放到凭证配置参数里
|
||||
param.putAll(initCommonParam(loanInfo));
|
||||
//将差别参数放进去
|
||||
addRespectiveParam(param, voucherConfigNo, actualPaymentBackAmount, outstandingPrincipal, outstandingInterest, overdueInterest);
|
||||
//转译的凭证信息
|
||||
param.putAll(initConvertParam(param));
|
||||
}
|
||||
return paramList;
|
||||
}
|
||||
//助贷-购置融资租赁资产
|
||||
private static final String FINANCIAL_LEASING_ASSETS = "14610201";//借--【融资租赁资产】-【承租人未还本金】-【客商+合同号码】
|
||||
private static final String LONG_TERM_LEASEBACK_OVERDUE_INTEREST = "1531020102";//借--【长期应收-回租-汽车-利息】-【逾期利息+罚息等】-【客商+合同号码】
|
||||
private static final String BANK_DEPOSIT = "100219";//贷--【银行存款-邮储银行】-【代偿总额】-【现金流,集团外客商,用11213】
|
||||
//助贷-合同起租
|
||||
private static final String LONG_TERM_RECEIVABLES_LEASEBACK_PRINCIPAL = "1531020101";//借--【长期应收-回租-汽车-本金】-【承租人未还本金】-【客商+合同号码】
|
||||
// private static final String LONG_TERM_LEASEBACK_INTEREST = "1531020102";//借--【长期应收-回租-汽车-利息】-【未到期利息总额】-【客商+合同号码】
|
||||
// private static final String FINANCIAL_LEASING_ASSETS = "14610201";//贷--【融资租赁资产】-【承租人未还本金】-【客商+合同号码】
|
||||
private static final String UNREALIZED_INCOME_LEASEBACK_AUTOMOBILE = "15320201";//贷--【未实现融资收益-回租-汽车】-【未到期利息总额】-【客商+合同号码】
|
||||
|
||||
/**
|
||||
* 每条凭证各自差异数据放到参数List
|
||||
* @param param
|
||||
* @param actualPaymentBackAmount 实际偿还总额
|
||||
* @param outstandingPrincipal 未还本金
|
||||
* @param outstandingInterest 未还利息
|
||||
* @param overdueInterest 未还罚息利息
|
||||
* @throws Exception
|
||||
*/
|
||||
public void addRespectiveParam(Map<String,String> param, String voucherConfigNo, String actualPaymentBackAmount,
|
||||
String outstandingPrincipal, String outstandingInterest, String overdueInterest) throws Exception {
|
||||
String money = "";
|
||||
String subjectsCode = param.get("subjectsCode");
|
||||
//银行存款-邮储银行【100219】
|
||||
if(BANK_DEPOSIT.equals(subjectsCode)){
|
||||
money=actualPaymentBackAmount;//实际回购支付总额
|
||||
param.put("contractNo","");
|
||||
param.put("customerNo","");
|
||||
param.put("customerName","");
|
||||
//应财务要求邮储放款填固定值
|
||||
param.put("cashFlow","11213");
|
||||
}
|
||||
//【长期应收-回租-汽车-利息】-【逾期利息+罚息等】-【客商+合同号码】
|
||||
//【长期应收-回租-汽车-利息】-【未到期利息总额】-【客商+合同号码】
|
||||
else if(LONG_TERM_LEASEBACK_OVERDUE_INTEREST.equals(subjectsCode)){
|
||||
money=overdueInterest;//未还罚息利息
|
||||
if(VOUCHER_CONFIG_NO_2.equals(voucherConfigNo)){//合同起租,取未还利息
|
||||
money=outstandingInterest;//未还利息
|
||||
}
|
||||
}
|
||||
//【未实现融资收益-回租-汽车】-【未到期利息总额】-【客商+合同号码】
|
||||
else if(UNREALIZED_INCOME_LEASEBACK_AUTOMOBILE.equals(subjectsCode)){
|
||||
money=outstandingInterest;//未还利息
|
||||
}
|
||||
//【融资租赁资产】-【承租人未还本金】-【客商+合同号码】
|
||||
//【长期应收-回租-汽车-本金】-【承租人未还本金】-【客商+合同号码】
|
||||
else if(FINANCIAL_LEASING_ASSETS.equals(subjectsCode)||LONG_TERM_RECEIVABLES_LEASEBACK_PRINCIPAL.equals(subjectsCode)){
|
||||
money=outstandingPrincipal;//
|
||||
}else {
|
||||
logger.warn("生成凭证,当前凭证类型匹配失败。subjectsCode=" + subjectsCode);
|
||||
throw new Exception("生成凭证,当前凭证类型匹配失败。subjectsCode=" + subjectsCode);
|
||||
}
|
||||
if(StringUtils.isEmpty(money)){
|
||||
logger.warn("生成凭证,查询凭证相关金额信息失败。");
|
||||
throw new Exception("生成凭证,查询凭证相关金额信息失败。");
|
||||
}
|
||||
//debit:借;credit:贷
|
||||
if("1".equals(param.get("entrydc"))) {
|
||||
param.put("debitMoney",money);
|
||||
param.put("creditMoney","0.00");
|
||||
}else{
|
||||
param.put("debitMoney","0.00");
|
||||
param.put("creditMoney",money);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据凭证配置编号获取对应的每条凭证参数
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<Map<String,String>> findParamOfVoucher(String voucherConfigNo) throws Exception {
|
||||
String sql = "select lvl.SORT_NUMBER as sortNumber,lvl.LOAN_SUBJECT as loanSubject, " +
|
||||
" CASE WHEN lvl.loan_direction = '1' THEN '1' ELSE '-1' END as entrydc, " +
|
||||
" lvl.VALUE_ABSTRACT as valueAbstract,lsc.SUBJECTS_CODE as subjectsCode, " +
|
||||
" lsc.SUBJECTS_NAME as subjectsName,lvc.MODULAR_NUMBER as modularName " +
|
||||
" from lv_voucher_loan lvl " +
|
||||
" left join LV_STACTS_CONFIG lsc on lvl.LOAN_SUBJECT=lsc.id " +
|
||||
" left join lv_voucher_config lvc on lvl.VOUCHER_ID=lvc.id " +
|
||||
" where lvc.VOUCHER_NO='"+voucherConfigNo+"'";
|
||||
List<Map<String,String>> paramList = DataOperatorUtil.getDataBySql(sql);
|
||||
if(paramList.size()==0){
|
||||
logger.warn(voucherConfigNo + "通过凭证配置编号未找到对应配置信息");
|
||||
throw new Exception(voucherConfigNo + "通过凭证配置编号未找到对应配置信息");
|
||||
}
|
||||
return paramList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生成凭证所需的公共参数(每个合同为单位)
|
||||
* 在传来值的基础上增添
|
||||
* @param loanInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Map<String,String> initCommonParam(Map<String,String> loanInfo) throws Exception {
|
||||
|
||||
//固定值部分
|
||||
String evidenceMessage = "凭证输出";//查看凭证表,发现只有这一个值,目前先设置为固定值
|
||||
String easFlag = "0";//导入财务系统状态 默认0 (同上,只有这一个值)
|
||||
String userId = "administrator";//操作人
|
||||
String userName = NameManager.getUserName(userId);
|
||||
loanInfo.put("evidenceMessage",evidenceMessage);
|
||||
loanInfo.put("easFlag",easFlag);
|
||||
loanInfo.put("userId",userId);
|
||||
loanInfo.put("userName",userName);
|
||||
|
||||
//日期:【 2021/08/11 17:48:17】
|
||||
String createTime = loanInfo.get("createTime").substring(0,10);
|
||||
String periodYear = createTime.substring(0,4);
|
||||
String periodMonth = createTime.substring(5,7);
|
||||
loanInfo.put("periodYear",periodYear);
|
||||
loanInfo.put("periodMonth",periodMonth);
|
||||
loanInfo.put("accountingDate",createTime);
|
||||
loanInfo.put("generateDate", DateUtil.getSystemDateDetailTime());
|
||||
|
||||
//主体信息
|
||||
String contractId = loanInfo.get("contractId");
|
||||
loanInfo.putAll(this.getSubjectInfoByContractId(contractId));
|
||||
return loanInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建凭证
|
||||
* @param paramList
|
||||
* @param tx
|
||||
* @throws Exception
|
||||
*/
|
||||
private void createVoucher(List<Map<String, String>> paramList, JBOTransaction tx) throws Exception {
|
||||
BizObjectManager bomV8 = JBOFactory.getBizObjectManager(VOUCHER_V8.CLASS_NAME,tx);
|
||||
for(Map<String, String> param :paramList){
|
||||
logger.info("创建凭证 createVoucher VoucherNo=" + param.get("f3") + ";configNo=" + param.get("f2"));
|
||||
BizObject boV8 = bomV8.newObject();
|
||||
boV8.setAttributesValue(param);
|
||||
bomV8.saveObject(boV8);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据contractId获取主体信息
|
||||
* @param contractId
|
||||
* @return
|
||||
* @throws JBOException
|
||||
*/
|
||||
public Map<String,String> getSubjectInfoByContractId(String contractId) throws JBOException {
|
||||
Map<String,String> subject = new HashMap<>();
|
||||
BizObjectManager bomLCI = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
|
||||
BizObject boLCI = bomLCI.createQuery("id=:id").setParameter("id",contractId).getSingleResult(false);
|
||||
String subjectId = boLCI.getAttribute("SUBJECTID").toString();
|
||||
String subjectName = boLCI.getAttribute("SUBJECTNAME").toString();
|
||||
BizObjectManager bomOI = JBOFactory.getBizObjectManager(OWN_INFO.CLASS_NAME);
|
||||
BizObject boOI = bomOI.createQuery("OWN_NAME=:subjectName").setParameter("subjectName",subjectName).getSingleResult(false);
|
||||
String ownNumber = boOI.getAttribute("OWN_NUMBER").toString();
|
||||
subject.put("subjectId",subjectId);
|
||||
subject.put("subjectName",subjectName);
|
||||
subject.put("ownNumber",ownNumber);
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将最终获取的参数转换为凭证表voucher_v8对应的字段
|
||||
* 注意:新增时注意param中字段不可修改
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> initConvertParam(Map<String,String> param){
|
||||
Map<String,String> finalParam = new HashMap<>();
|
||||
finalParam.put("evidence_message",param.get("evidenceMessage"));//固定值:凭证输出
|
||||
finalParam.put("periodyear",param.get("periodYear")); //年
|
||||
finalParam.put("f1",param.get("accountingDate"));//会计日期
|
||||
finalParam.put("f2",param.get("subjectsCode"));//科目编码
|
||||
finalParam.put("f3",param.get("voucherNo"));//凭证编号
|
||||
finalParam.put("f5",param.get("valueAbstract"));//摘要
|
||||
finalParam.put("f6",param.get("loanSubject"));//科目表id
|
||||
finalParam.put("f7",param.get("debitMoney"));//借方金额
|
||||
finalParam.put("f8",param.get("creditMoney"));//贷方金额
|
||||
finalParam.put("f12",param.get("userName"));//操作人
|
||||
finalParam.put("f15",param.get("accountingDate"));//日期(与会计日期相同)
|
||||
finalParam.put("f47",param.get("contractNo"));//业务合同编号
|
||||
finalParam.put("f48",param.get("ownNumber"));//本方信息No
|
||||
finalParam.put("f49",param.get("subjectId"));//所属公司ID(注意:实际此字段存的是code_library表中codeno='ManySubject' 的 itemno 字段)
|
||||
finalParam.put("f50",param.get("subjectName"));//所属公司名称
|
||||
finalParam.put("f51",param.get("periodYear"));//会计期间-年(与上面 ‘年’ 相同)
|
||||
finalParam.put("f52",param.get("periodMonth"));//会计期间-月
|
||||
finalParam.put("f59",param.get("sortNumber"));//凭证配置中排序号
|
||||
finalParam.put("f60",param.get("contractNo"));//业务合同号,与f47相同(尚不明为何重复)
|
||||
finalParam.put("f61",param.get("customerName"));//客户名称
|
||||
finalParam.put("f62",param.get("loanSubject"));//科目表id,与f6相同(尚不明为何重复)
|
||||
finalParam.put("f65",param.get("customerNo"));//客商编号(取值customer_info表中customer_num字段)
|
||||
finalParam.put("f74",param.get("cashFlow"));// 现金流项目
|
||||
finalParam.put("v8_status","已完整");//凭证状态 : 已完整;未完整
|
||||
finalParam.put("generate_date",param.get("generateDate"));//创建时间
|
||||
finalParam.put("v8_flag",param.get("easFlag"));//导入财务系统状态 默认0(尚不知有何逻辑,目前整个表中全部为0)
|
||||
finalParam.put("module_name",param.get("modularName"));//凭证模型名称
|
||||
finalParam.put("entrydc",param.get("entrydc"));//借贷:1,借;-1,贷
|
||||
finalParam.put("inputuserid",param.get("userId"));//操作人id
|
||||
return finalParam;
|
||||
}
|
||||
private void updateVoucherStatus(String id ,Transaction Sqlca) throws Exception {
|
||||
String sql = "update fc_buyback_info set voucher_status = '1' where id = '"+id+"'";
|
||||
SqlObject sqlObject = new SqlObject(sql);
|
||||
Sqlca.executeSQL(sqlObject);
|
||||
}
|
||||
|
||||
//fc_yc_overdue_repay_plan
|
||||
|
||||
/**
|
||||
* 逾期回购时,新增逾期回购中逾期的进行备注
|
||||
* @param loanInfo
|
||||
* @param Sqlca
|
||||
* @throws Exception
|
||||
*/
|
||||
private void addOverdueRepayPlan(Map<String,String> loanInfo ,Transaction Sqlca) throws Exception {
|
||||
String sqlQuery = "SELECT plan_list from report_rent_plan WHERE contract_number='"+loanInfo.get("contractNo") +"' and batch_status='未完成' and over_days > 0";
|
||||
List<Map<String,String>> paramList = DataOperatorUtil.getDataBySql(sqlQuery);
|
||||
if(paramList.size()==0 || paramList.size()>2 ){
|
||||
logger.warn(loanInfo.get("contractNo") + "逾期回购生成凭证之后,查询是否有逾期数据,或逾期数据大于2。");
|
||||
return;
|
||||
}
|
||||
String sqlQuery2 = "SELECT * from fc_buyback_info WHERE fc_request_id='"+loanInfo.get("fc_request_id") +"'";
|
||||
List<Map<String,String>> paramList2 = DataOperatorUtil.getDataBySql(sqlQuery2);
|
||||
if(paramList2.size()==0 || paramList2.size()>1){
|
||||
logger.warn(loanInfo.get("contractNo") + "逾期回购生成凭证之后,查询是否有逾期数据2,或逾期数据大于1。");
|
||||
return;
|
||||
}
|
||||
Map<String, String> overduePlan = paramList2.get(0);
|
||||
String firstOverduePenalty = overduePlan.get("first_overdue_penalty");
|
||||
String secondOverduePenalty = overduePlan.get("second_overdue_penalty");
|
||||
if(paramList.size()==1){
|
||||
paramList.get(0).put("overduePenalty", firstOverduePenalty);
|
||||
}else if(paramList.size() == 2){
|
||||
int firstTerm = Integer.parseInt(paramList.get(0).get("plan_list"));
|
||||
int secondTerm = Integer.parseInt(paramList.get(1).get("plan_list"));
|
||||
if(firstTerm < secondTerm){
|
||||
paramList.get(0).put("overduePenalty", firstOverduePenalty);
|
||||
paramList.get(1).put("overduePenalty", secondOverduePenalty);
|
||||
}else {
|
||||
paramList.get(0).put("overduePenalty", secondOverduePenalty);
|
||||
paramList.get(1).put("overduePenalty", firstOverduePenalty);
|
||||
}
|
||||
}
|
||||
for(Map<String, String> planList : paramList){
|
||||
String term = planList.get("plan_list");
|
||||
String overduePenalty = planList.get("overduePenalty");
|
||||
String sqlRentPlan = "SELECT ID from lc_rent_plan WHERE CONTRACT_ID='"+loanInfo.get("contractId")
|
||||
+"' and PLAN_LIST='"+term+"'";//租金计划id
|
||||
String rentPlanId = Sqlca.getString(sqlRentPlan);
|
||||
String sql = "insert into fc_yc_overdue_repay_plan (" +
|
||||
"id," +
|
||||
"fc_request_id," +
|
||||
"contract_id," +
|
||||
"contract_no," +
|
||||
"lend_term," +
|
||||
"rent_plan_id," +
|
||||
"yc_overdue_amount," +
|
||||
"yc_overdue_repay_amount," +
|
||||
"create_time," +
|
||||
"update_time" +
|
||||
") values" +
|
||||
" (" +
|
||||
"'"+ UUIDUtil.getUUID() +"',"+
|
||||
"'"+ loanInfo.get("fc_request_id") +"',"+
|
||||
"'"+ loanInfo.get("contractId") +"',"+
|
||||
"'"+ loanInfo.get("contractNo") +"',"+
|
||||
""+ term +","+
|
||||
"'"+ rentPlanId +"',"+
|
||||
"'"+ overduePenalty +"',"+
|
||||
"'0',"+
|
||||
"'"+ DateUtil.getSystemTimeByFormat("yyyyMMddHHmmss") +"',"+
|
||||
"'"+ DateUtil.getSystemTimeByFormat("yyyyMMddHHmmss") +"'"+
|
||||
")" ;
|
||||
SqlObject sqlObject = new SqlObject(sql);
|
||||
Sqlca.executeSQL(sqlObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.tenwa.lease.app.quartzmession;
|
||||
import com.amarsoft.are.util.StringFunction;
|
||||
import com.base.util.QuartzUtil;
|
||||
import com.tenwa.voucher.service.VoucherInfoService;
|
||||
import com.tenwa.voucher.serviceImp.FundIncomeVoucherPSBC;
|
||||
import com.tenwa.voucher.serviceImp.OverdueRepurchaseVoucherPSBC;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* 逾期回购生成凭证-定时任务
|
||||
* @author zl
|
||||
*/
|
||||
public class CorpusSourceOverdueRepurchaseCreateVoucherJob implements Job {
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext arg0) throws JobExecutionException {
|
||||
String startime = StringFunction.getTodayNow();
|
||||
Object userId = arg0.getTrigger().getJobDataMap().get("CurUserId");
|
||||
String curUserId = userId == null? "system" : userId.toString();
|
||||
try{
|
||||
VoucherInfoService voucher = new OverdueRepurchaseVoucherPSBC();
|
||||
voucher.run();
|
||||
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.CorpusSourceOverdueRepurchaseCreateVoucherJob", "success", "成功", curUserId);
|
||||
} catch (Exception e) {
|
||||
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.CorpusSourceOverdueRepurchaseCreateVoucherJob", "error", "失败", curUserId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user