邮储放款--凭证(初版)

This commit is contained in:
ap007 2021-07-26 19:04:15 +08:00
parent dc33138164
commit 9a92efde0d
3 changed files with 310 additions and 50 deletions

View File

@ -1,13 +1,19 @@
package com.tenwa.voucher.serviceImp;
import com.amarsoft.are.jbo.*;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.amarsoft.dict.als.manage.NameManager;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.flow.util.FlowUtil;
import com.tenwa.reckon.util.DateUtil;
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 java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
@ -15,17 +21,27 @@ import java.util.List;
import java.util.Map;
public class FundIncomeVoucherInfoServiceImpl implements VoucherInfoService {
//todo 这个字段是自增的更新生产时先在生产配置然后根据生产的编号再更改
private static final String VOUCHER_CONFIGNO = "PZ2021072100000020";//凭证号
private static final String EVIDENCE_MESSAGE = "凭证输出";//查看凭证表发现只有这一个值目前先设置为固定值
private static final String EAS_FLAG = "0";//导入财务系统状态 默认0 (同上只有这一个值)
public void run() {
private final String voucherConfigNo = "PZ2021072600000003";
public void run() throws JBOException {
JBOTransaction tx = null;
Transaction Sqlca =null;
try {
tx = JBOFactory.createJBOTransaction();
//凭证编号
String voucherNo ="k" + FlowUtil.getVoucher_Number(tx);
System.out.println(voucherNo+"======");
Sqlca = Transaction.createTransaction(tx);
List<Map<String,String>> loanInfoList = this.getHasLoanContract("PSBC");
for(Map<String,String> loanInfo : loanInfoList){
String voucherNo ="k" + FlowUtil.getVoucher_Number(tx);
loanInfo.put("voucherNo",voucherNo);
String customerNo = this.getCustomerNoByContractId(loanInfo.get("contractId"),Sqlca);
loanInfo.put("customerNo",customerNo);
//获取最终参数
List<Map<String,String>> paramList = this.getFinalParam(loanInfo,tx);
//生成凭证
this.createVoucher(paramList,tx);
//更新凭证信息状态
updateVoucherStatus(loanInfo.get("loan_no"),Sqlca);
}
System.out.println("=============凭证生成完毕============");
} catch (JBOException e) {
e.printStackTrace();
} catch (Exception e) {
@ -33,45 +49,112 @@ public class FundIncomeVoucherInfoServiceImpl implements VoucherInfoService {
}finally {
try {
tx.commit();
if(Sqlca!=null){
Sqlca.disConnect();
Sqlca = null;
}
} catch (JBOException e) {
e.printStackTrace();
tx.rollback();
}
}
}
public void createVoucher(List<Map<String, String>> list, JBOTransaction tx) throws Exception {
/**
* 生成每个合同的凭证
* @param paramList
* @param tx
* @throws Exception
*/
public void createVoucher(List<Map<String, String>> paramList, JBOTransaction tx) throws Exception {
BizObjectManager bomV8 = JBOFactory.getBizObjectManager(VOUCHER_V8.CLASS_NAME,tx);
List<Map<String,String>> loanInfoList = this.getHasLoanContract(tx);
for(Map<String,String> loanInfo : loanInfoList){
loanInfo = this.getCommonParam(loanInfo,tx);
List<Map<String,String>> paramList = getParamOfVoucher(tx);
for(Map<String,String> param : paramList){
param.putAll(loanInfo);
BizObject boV8 = bomV8.newObject();
boV8.setAttributesValue(this.getFinalParam(param));
bomV8.saveObject(boV8);
}
for(Map<String, String> param :paramList){
BizObject boV8 = bomV8.newObject();
boV8.setAttributesValue(param);
bomV8.saveObject(boV8);
}
}
public List<Map<String,String>> getHasLoanContract(JBOTransaction tx) throws Exception {
//todo 目前为邮储九江的时候将where条件更改参数
String sql = "select frl.loan_no,frl.customer_name,frl.loan_date,frl.loan_amt,frl.business_rate,frl.TRANS_AMT,fr.CONTRACT_ID,fr.CONTRACT_NO " +
/**
* 获取最终的参数
* @param loanInfo
* @param tx
* @return
* @throws Exception
*/
public List<Map<String,String>> getFinalParam(Map<String,String> loanInfo ,JBOTransaction tx) throws Exception {
List<Map<String,String>> paramList = getParamOfVoucher(voucherConfigNo);
for(Map<String,String> param : paramList){
//将公共参数放到凭证配置的每个凭证信息中
param.putAll(this.getCommonParam(loanInfo));
//将定制参数放入
String money = "";
//邮政储蓄银行
if("100219".equals(param.get("subjectsCode"))){
money=param.get("TRANS_AMT");
param.put("contractNo","");
param.put("customerNo","");
param.put("customerName","");
//应财务要求邮储放款填固定值
param.put("cashFlow","11213");
}
//长期应收款\回租\汽车\本金
if("1531020101".equals(param.get("subjectsCode"))){
money=param.get("TRANS_AMT");
}
//未实现融资收益\回租\汽车 长期应收款\回租\汽车\利息
if("15320201".equals(param.get("subjectsCode"))||"1531020102".equals(param.get("subjectsCode"))){
money=this.getInterestTotalByContractId(param.get("contractId"));
}
//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);
}
//转译的凭证信息
param.putAll(this.getConvertParam(param));
}
return paramList;
}
/**
* 获取需要生成凭证的合同以及对应信息
* @return
* @throws Exception
*/
public List<Map<String,String>> getHasLoanContract(String channelNo) throws Exception {
String sql = "select frl.loan_no,frl.customer_name as customerName,frl.loan_date,frl.business_rate,frl.TRANS_AMT,fr.CONTRACT_ID as contractId,fr.CONTRACT_NO as contractNo " +
"from fc_request_loan frl " +
"left join fc_request fr on frl.LOAN_NO = fr.FC_LOAN_ID " +
"where frl.del_flag='0' and fr.DEL_FLAG='0' and voucher_status='0' and fr.CHANNEL_NO='PSBC' ";
return DataOperatorUtil.getDataBySql(sql,tx);
"where frl.del_flag='0' and fr.DEL_FLAG='0' and voucher_status='0' and fr.CHANNEL_NO='"+channelNo+"' ";
return DataOperatorUtil.getDataBySql(sql);
}
public Map<String,String> getCommonParam(Map<String,String> loanInfo,JBOTransaction tx) throws Exception {
String contractId = loanInfo.get("CONTRACT_ID");
String voucherNo ="k" + FlowUtil.getVoucher_Number(tx);
loanInfo.put("voucherNo",voucherNo);
/**
* 获取生成凭证所需的公共参数(每个合同为单位)
* 在传来值的基础上增添
* @param loanInfo
* @return
* @throws Exception
*/
public Map<String,String> getCommonParam(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);
//日期
String loanDate = loanInfo.get("loan_date").substring(0,8);
String periodYear = loanDate.substring(0,4);
@ -81,50 +164,113 @@ public class FundIncomeVoucherInfoServiceImpl implements VoucherInfoService {
loanInfo.put("periodYear",periodYear);
loanInfo.put("periodMonth",periodMonth);
loanInfo.put("accountingDate",loanDate);
loanInfo.put("generate_date", DateUtil.getSystemDateDetailTime());
loanInfo.put("generateDate", DateUtil.getSystemDateDetailTime());
//主体信息
String contractId = loanInfo.get("contractId");
loanInfo.putAll(this.getSubjectInfoByContractId(contractId));
return loanInfo;
}
public List<Map<String,String>> getParamOfVoucher(JBOTransaction tx) 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 " +
/**
* 根据contractId获取对应的利息总和
* 放款流程结束时生成的利息凭证计算逻辑用的是lc_pay_rent_plan表邮储放款时生成利息凭证要和此相同
* @param contractId
* @return
* @throws Exception
*/
public String getInterestTotalByContractId(String contractId) throws Exception {
String interestTotal = "select sum(interest) as interestTotal from lc_pay_rent_plan where contract_id='"+contractId+"'";
return DataOperatorUtil.getDataBySql(interestTotal).get(0).get("interestTotal");
}
/**
* 根据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;
}
/**
* 根据凭证配置编号获取对应的每条凭证参数
* @return
* @throws Exception
*/
public List<Map<String,String>> getParamOfVoucher(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='"+VOUCHER_CONFIGNO+"'";
return DataOperatorUtil.getDataBySql(sql,tx);
"where lvc.VOUCHER_NO='"+voucherConfigNo+"'";
return DataOperatorUtil.getDataBySql(sql);
}
public Map<String,String> getFinalParam(Map<String,String> param){
/**
* 将最终获取的参数转换为凭证表voucher_v8对应的字段
* 注意新增时注意param中字段不可修改
* @param param
* @return
*/
public Map<String,String> getConvertParam(Map<String,String> param){
Map<String,String> finalParam = new HashMap<>();
finalParam.put("evidence_message",EVIDENCE_MESSAGE);//固定值凭证输出
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("periodYear"));//借方金额
finalParam.put("f8",param.get("periodYear"));//贷方金额
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("CONTRACT_NO"));//业务合同编号
finalParam.put("f48",param.get("periodYear"));//本方信息No
finalParam.put("f49",param.get("periodYear"));//所属公司ID注意实际此字段存的是code_library表中codeno='ManySubject' itemno 字段
finalParam.put("f50",param.get("periodYear"));//所属公司名称
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("CONTRACT_NO"));//业务合同号与f47相同尚不明为何重复
finalParam.put("f61",param.get("customer_name"));//客户名称
finalParam.put("f60",param.get("contractNo"));//业务合同号与f47相同尚不明为何重复
finalParam.put("f61",param.get("customerName"));//客户名称
finalParam.put("f62",param.get("loanSubject"));//科目表id与f6相同尚不明为何重复
finalParam.put("f65",VOUCHER_CONFIGNO);//凭证配置编号
finalParam.put("f65",param.get("customerNo"));//客商编号取值customer_info表中customer_num字段
finalParam.put("f74",param.get("cashFlow"));//客商编号取值customer_info表中customer_num字段
finalParam.put("v8_status","已完整");//凭证状态 已完整未完整
finalParam.put("generate_date",param.get("generate_date"));//创建时间
finalParam.put("v8_flag",EAS_FLAG);//导入财务系统状态 默认0尚不知有何逻辑目前整个表中全部为0
finalParam.put("module_name",param.get("subjectsName"));//凭证名称
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;
}
public void updateVoucherStatus(String loanNo ,Transaction Sqlca) throws Exception {
String sql = "update fc_request_loan set voucher_status = '1' where loan_no = '"+loanNo+"'";
SqlObject sqlObject = new SqlObject(sql);
Sqlca.executeSQL(sqlObject);
}
public String getCustomerNoByContractId(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;
}
public int getCashFlowProjectNoByCustId(String custId) throws JBOException {
int custCount =JBOFactory.createBizObjectQuery(CUSTOMER_LIST.CLASS_NAME, "CUST_ID='"+custId+"'").getTotalCount();
return custCount;
}
}

View File

@ -0,0 +1,113 @@
package com.tenwa.voucher.serviceImp;
import com.amarsoft.are.jbo.*;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.amarsoft.dict.als.manage.NameManager;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.flow.util.FlowUtil;
import com.tenwa.reckon.util.DateUtil;
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 java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FundIncomeVoucherPSBC extends FundIncomeVoucherInfoServiceImpl {
private final String voucherConfigNo = "PZ2021072600000003";
@Override
public void run() throws JBOException {
JBOTransaction tx = null;
Transaction Sqlca =null;
try {
tx = JBOFactory.createJBOTransaction();
Sqlca = Transaction.createTransaction(tx);
List<Map<String,String>> loanInfoList = getHasLoanContract("PSBC");
for(Map<String,String> loanInfo : loanInfoList){
String voucherNo ="k" + FlowUtil.getVoucher_Number(tx);
loanInfo.put("voucherNo",voucherNo);
String customerNo = getCustomerNoByContractId(loanInfo.get("contractId"),Sqlca);
loanInfo.put("customerNo",customerNo);
//获取最终参数
List<Map<String,String>> paramList = getFinalParam(loanInfo,tx);
//生成凭证
createVoucher(paramList,tx);
//更新凭证信息状态
updateVoucherStatus(loanInfo.get("loan_no"),Sqlca);
}
System.out.println("=============邮储放款凭证生成完毕============");
} catch (JBOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
tx.commit();
if(Sqlca!=null){
Sqlca.disConnect();
Sqlca = null;
}
} catch (JBOException e) {
e.printStackTrace();
tx.rollback();
}
}
}
/**
* 获取最终的参数
* @param loanInfo
* @param tx
* @return
* @throws Exception
*/
@Override
public List<Map<String,String>> getFinalParam(Map<String,String> loanInfo ,JBOTransaction tx) throws Exception {
List<Map<String,String>> paramList = getParamOfVoucher(this.voucherConfigNo);
for(Map<String,String> param : paramList){
//将公共参数放到凭证配置的每个凭证信息中
param.putAll(this.getCommonParam(loanInfo));
//将定制参数放入
String money = "";
//邮政储蓄银行
if("100219".equals(param.get("subjectsCode"))){
money=param.get("TRANS_AMT");
param.put("contractNo","");
param.put("customerNo","");
param.put("customerName","");
//应财务要求邮储放款填固定值
param.put("cashFlow","11213");
}
//长期应收款\回租\汽车\本金
if("1531020101".equals(param.get("subjectsCode"))){
money=param.get("TRANS_AMT");
}
//未实现融资收益\回租\汽车 长期应收款\回租\汽车\利息
if("15320201".equals(param.get("subjectsCode"))||"1531020102".equals(param.get("subjectsCode"))){
money=this.getInterestTotalByContractId(param.get("contractId"));
}
//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);
}
//转译的凭证信息
param.putAll(getConvertParam(param));
}
return paramList;
}
}

View File

@ -8,6 +8,7 @@ import com.tenwa.voucher.CreateVoucherProcess.InsertVoucherRentCompensatory;
import com.tenwa.voucher.CreateVoucherProcess.InsertVoucherRentIncome;
import com.tenwa.voucher.service.VoucherInfoService;
import com.tenwa.voucher.serviceImp.FundIncomeVoucherInfoServiceImpl;
import com.tenwa.voucher.serviceImp.FundIncomeVoucherPSBC;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@ -28,7 +29,7 @@ public class CorpusSourceFundIncomeCreateVoucherJob implements Job {
try{
tx = JBOFactory.createJBOTransaction();
//
VoucherInfoService voucher = new FundIncomeVoucherInfoServiceImpl();
VoucherInfoService voucher = new FundIncomeVoucherPSBC();
voucher.run();
QuartzUtil.insertLog(startime,"com.tenwa.comm.message.controller.BusinessCancelJob", "success", "³É¹¦", curUserId);