diff --git a/WebContent/WEB-INF/etc/jbo/jbo_oti.xml b/WebContent/WEB-INF/etc/jbo/jbo_oti.xml index d7190b017..6f26d0323 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_oti.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_oti.xml @@ -392,7 +392,7 @@ - + @@ -410,6 +410,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -425,5 +484,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/sql/insertIntoCashFlow.xml b/WebContent/WEB-INF/etc/sql/insertIntoCashFlow.xml new file mode 100644 index 000000000..251916275 --- /dev/null +++ b/WebContent/WEB-INF/etc/sql/insertIntoCashFlow.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + dataSource + false + +
+
\ No newline at end of file diff --git a/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanInfo.jsp b/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanInfo.jsp new file mode 100644 index 000000000..4e1a3ea38 --- /dev/null +++ b/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanInfo.jsp @@ -0,0 +1,26 @@ +<%@ page contentType="text/html; charset=GBK"%><%@ + include file="/Frame/resources/include/include_begin_info.jspf"%><% + + String fcPrepayQueryID = CurPage.getParameter("fcPrepayQueryID"); + + ASObjectModel doTemp = new ASObjectModel("FC_YC_PREPAY_QUERY"); + doTemp.setJboWhere("id='"+fcPrepayQueryID+"'"); + + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="2"; //设置DW风格 1:Grid 2:Freeform + dwTemp.ReadOnly = "1"; //设置是否只读 1:只读 0:可写 + dwTemp.genHTMLObjectWindow(""); + + String sButtons[][] = { + {"true","","Button","返回","返回","returnList()","","","",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_info.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanList.jsp b/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanList.jsp new file mode 100644 index 000000000..c8abe1a46 --- /dev/null +++ b/WebContent/com/tenwa/apzl/settleLoan/CorpusSourceSettleLoanList.jsp @@ -0,0 +1,33 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2021-08-04 + Content: + History Log: + */ + ASObjectModel doTemp = new ASObjectModel("FC_YC_PREPAY_QUERY"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(20); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/src_jbo/jbo/oti/FC_REQUEST_CHANNEL_LOG.java b/src_jbo/jbo/oti/FC_REQUEST_CHANNEL_LOG.java new file mode 100644 index 000000000..7921750f1 --- /dev/null +++ b/src_jbo/jbo/oti/FC_REQUEST_CHANNEL_LOG.java @@ -0,0 +1,51 @@ +package jbo.oti; + +/** +* 接口资料表 - JBO命名常量类

+* Note: This file is generated by ADE tools, dont modify it.
+ +*/ +public interface FC_REQUEST_CHANNEL_LOG { + /** + * 接口资料表

+ * 代表本类映射的BizObjectClass + */ + public static final String CLASS_NAME = "jbo.oti.LC_PROFIT_PLAN"; + /** + * 唯一标识 STRING(32)
+ */ + public static final String ID = "ID"; + /** + * 资方请求id STRING(32)
+ */ + public static final String FC_REQUEST_ID = "FC_REQUEST_ID"; + /** + * 修改前资方编号 STRING(32)
+ */ + public static final String PRE_CHANNEL_NO = "PRE_CHANNEL_NO"; + /** + * 修改前资方名称 STRING(32)
+ */ + public static final String PRE_CHANNEL_NAME = "PRE_CHANNEL_NAME"; + /** + * 修改后资方编号 STRING(32)
+ */ + public static final String CHANNEL_NO = "CHANNEL_NO"; + /** + * 修改后资方名称 STRING(32)
+ */ + public static final String CHANNEL_NAME = "CHANNEL_NAME"; + /** + * 描述 STRING(32)
+ */ + public static final String REMARK = "REMARK"; + /** + * 变更结果 STRING(32)
+ */ + public static final String CHANGE_RESULT = "CHANGE_RESULT"; + /** + * 创建时间 STRING(32)
+ */ + public static final String CREATETIME = "CREATETIME"; + +} \ No newline at end of file diff --git a/src_jbo/jbo/oti/FC_YC_FILE_REPAY_RESULT.java b/src_jbo/jbo/oti/FC_YC_FILE_REPAY_RESULT.java new file mode 100644 index 000000000..814f1ed02 --- /dev/null +++ b/src_jbo/jbo/oti/FC_YC_FILE_REPAY_RESULT.java @@ -0,0 +1,79 @@ +package jbo.oti; + +/** +* 接口资料表 - JBO命名常量类

+* Note: This file is generated by ADE tools, dont modify it.
+ +*/ +public interface FC_YC_FILE_REPAY_RESULT { + /** + * 接口资料表

+ * 代表本类映射的BizObjectClass + */ + public static final String CLASS_NAME = "jbo.oti.FC_YC_FILE_REPAY_RESULT"; + /** + * 唯一标识 STRING(32)
+ */ + public static final String ID = "ID"; + /** + * 文件ID STRING(32)
+ */ + public static final String FC_FILE_ID = "FC_FILE_ID"; + /** + * 放款请求编号 STRING(32)
+ */ + public static final String LOAN_NO = "LOAN_NO"; + /** + * 期次 STRING(32)
+ */ + public static final String LEND_TERM = "TERM_NO"; + /** + * 还款日期 STRING(32)
+ */ + public static final String ANS_REPAYMENT_DATE = "NEW_REPAY_DATE"; + /** + * 本金 STRING(32)
+ */ + public static final String ANS_PRINCIPAL = "ALR_PRINCIPAL"; + /** + * 利息 STRING(32)
+ */ + public static final String ANS_INTEREST = "ALR_INTEREST"; + /** + * 罚息 STRING(32)
+ */ + public static final String ALR_PENALTY = "ALR_PENALTY"; + /** + * 归还合计 STRING(32)
+ */ + public static final String ANS_REPAYMENT_MONEY = "ALR_REPAYMENT_MONEY"; + /** + * 还款标识:0-当期正常结清 、当期逾期结清、1-提前部分还款、2-逾期、3-提前结清 STRING(32)
+ */ + public static final String REPAYMENT_FLAG = "REPAYMENT_FLAG"; + /** + * 还款来源标识:0:借款人本人账户;1:非借款人本人账户 STRING(32)
+ */ + public static final String REPAYMENT_SOURCE = "REPAYMENT_SOURCE"; + /** + * 提前还款费用 STRING(32)
+ */ + public static final String TRADE_FEE = "TRADE_FEE"; + /** + * 还款账号 STRING(32)
+ */ + public static final String REPAYMENT_ACCOUNT_NO = "REPAYMENT_ACCOUNT_NO"; + /** + * 流水号 STRING(32)
+ */ + public static final String FLOWNO = "FLOWNO"; + /** + * 创建时间 STRING(32)
+ */ + public static final String CREATE_TIME = "CREATE_TIME"; + /** + * 修改时间 STRING(32)
+ */ + public static final String UPDATE_TIME = "UPDATE_TIME"; + +} \ No newline at end of file diff --git a/src_jbo/jbo/oti/FC_YC_PREPAY_QUERY.java b/src_jbo/jbo/oti/FC_YC_PREPAY_QUERY.java new file mode 100644 index 000000000..397b2b9ea --- /dev/null +++ b/src_jbo/jbo/oti/FC_YC_PREPAY_QUERY.java @@ -0,0 +1,108 @@ +package jbo.oti; + +import java.lang.String; + +/** +* 提前结清试算接口内容 - JBO命名常量类

+* Note: This file is generated by ADE tools, dont modify it.
+ +*/ +public interface FC_YC_PREPAY_QUERY{ + /** + * 提前结清试算接口内容

+ * 代表本类映射的BizObjectClass + */ + public static final String CLASS_NAME = "jbo.oti.FC_YC_PREPAY_QUERY"; + /** + * 唯一标识 STRING(32)
+ */ + public static final String ID = "ID"; + /** + * 资金渠道文件ID STRING(32)
+ */ + public static final String FC_FILE_ID = "FC_FILE_ID"; + /** + * 资金渠道申请ID STRING(32)
+ */ + public static final String FC_REQUEST_ID = "FC_REQUEST_ID"; + /** + * 放款申请编号 STRING(32)
+ */ + public static final String LOAN_NO = "LOAN_NO"; + /** + * 贷款余额 STRING(32)
+ */ + public static final String LOAN_CAPITAL_BALANCE = "LOAN_CAPITAL_BALANCE"; + /** + * STRING(32)
+ */ + public static final String FC_FILE_PUSH_NAME = "FC_FILE_PUSH_NAME"; + /** + * 币种 STRING(32)
+ */ + public static final String CURRENCY = "CURRENCY"; + /** + * 贷款利率 STRING(32)
+ */ + public static final String LOAN_RATE = "LOAN_RATE"; + /** + * 还款方式 STRING(32)
+ */ + public static final String REPAY_KIND = "REPAY_KIND"; + /** + * 贷款起期 STRING(32)
+ */ + public static final String LOAN_BEGIN_DATE = "LOAN_BEGIN_DATE"; + /** + * 贷款止期 STRING(32)
+ */ + public static final String LOAN_END_DATE = "LOAN_END_DATE"; + /** + * 还款账号 STRING(32)
+ */ + public static final String REPAY_ACC_NO = "REPAY_ACC_NO"; + /** + * 还款账号余额 STRING(32)
+ */ + public static final String REPAY_BALANCE = "REPAY_BALANCE"; + /** + * 提前还款类型 STRING(32)
+ */ + public static final String REPAY_TYPE = "REPAY_TYPE"; + /** + * 当期应还本息金额 STRING(32)
+ */ + public static final String CURRENT_CAPITAL_BALANCE = "CURRENT_CAPITAL_BALANCE"; + /** + * 当前应还利息 STRING(32)
+ */ + public static final String CURRENT_CAPITAL_INT = "CURRENT_CAPITAL_INT"; + /** + * 拖欠本金 STRING(32)
+ */ + public static final String OVERDUE_CAPITAL_BALANCE = "OVERDUE_CAPITAL_BALANCE"; + /** + * 拖欠利息 STRING(32)
+ */ + public static final String OVERDUE_CAPITAL_INT = "OVERDUE_CAPITAL_INT"; + /** + * 申请日期 STRING(32)
+ */ + public static final String RECORD_DATE = "RECORD_DATE"; + /** + * 归还本息金额 STRING(32)
+ */ + public static final String PREREPAY_AMOUNT = "PREREPAY_AMOUNT"; + /** + * 提前归还本金金额 STRING(32)
+ */ + public static final String PREREPAY_AMOUNT1 = "PREREPAY_AMOUNT1"; + /** + * 创建时间 STRING(32)
+ */ + public static final String CREATE_TIME = "CREATE_TIME"; + /** + * 修改时间 STRING(32)
+ */ + public static final String UPDATE_TIME = "UPDATE_TIME"; +} \ No newline at end of file diff --git a/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceFileCopy.java b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceFileCopy.java index 691cb7e35..71d50f68d 100644 --- a/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceFileCopy.java +++ b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceFileCopy.java @@ -7,10 +7,13 @@ import com.amarsoft.awe.util.Transaction; import com.base.util.QuartzUtil; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.reckon.executor.CreateTransactionExecutor; -import jbo.app.tenwa.calc.LC_CALC_CONDITION; -import jbo.app.tenwa.calc.LC_RENT_PLAN; -import jbo.app.tenwa.calc.LC_RENT_PLAN_HIS; +import jbo.app.tenwa.calc.*; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP; import jbo.oti.FC_FILE_PUSH; +import jbo.oti.FC_REQUEST_CHANNEL_LOG; import jbo.oti.FC_YC_FILE_REPAY_PLAN; import jbo.oti.LC_PROFIT_PLAN; import org.quartz.Job; @@ -20,10 +23,7 @@ import org.quartz.JobExecutionException; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static java.math.BigDecimal.ROUND_HALF_UP; @@ -35,11 +35,8 @@ public class CorpusSourceFileCopy { private String contractId; private String fileType; - public void doCopy(JBOTransaction tx) throws JobExecutionException { + public void doCopy(JBOTransaction tx) throws Exception { BizObjectManager ffpBom = null; - Transaction Sqlca = null; - try { - Sqlca = Transaction.createTransaction(tx); ffpBom = JBOFactory.getBizObjectManager(FC_FILE_PUSH.CLASS_NAME,tx); //todo 添加渠道商的选择,哪些需要拷表哪些不需要 String fileSql = "select ID,FILE_STS from O where FILE_TYPE='"+fileType+"' and FILE_STS='2'"; @@ -55,18 +52,6 @@ public class CorpusSourceFileCopy { ffpBo.setAttributeValue("FILE_STS_DESC","拷贝成功"); ffpBom.saveObject(ffpBo); } - Sqlca.commit(); - } catch (Exception e) { - e.printStackTrace(); - try { - if (Sqlca != null) { - Sqlca.rollback(); - } - } catch (JBOException e1) { - e1.printStackTrace(); - } - throw new JobExecutionException(e); - } } /** @@ -100,7 +85,7 @@ public class CorpusSourceFileCopy { Transaction Sqlca = Transaction.createTransaction(tx); //===顺序不能错=== //0.将租金计划拷贝到历史表 - copyRentPlanFormatToHis(contractMap,tx); + copyRentPlanFormatToHis(contractMap,"安鹏原正式租金计划",tx); //1.更新租金计划表(直接文件每条信息更新,不需要遍历) updateRentPlan(fyfrpBoList,tx); for(Map.Entry entry : contractMap.entrySet()){ @@ -139,18 +124,79 @@ public class CorpusSourceFileCopy { * @param tx * @throws Exception */ - public void copyRentPlanFormatToHis(Map contractMap ,JBOTransaction tx) throws Exception { + public void copyRentPlanFormatToHis(Map contractMap ,String memo,JBOTransaction tx) throws Exception { for(Map.Entry entry: contractMap.entrySet()){ - Map fromCondtion=new HashMap(); - fromCondtion.put("CONTRACT_ID",entry.getKey()); - - Map otherProperty=new HashMap(); - otherProperty.put("MEMO", "安鹏原正式租金计划"); - otherProperty.put("FLOWUNID", entry.getValue()); - - DataOperatorUtil.copyJBOSet(LC_RENT_PLAN.CLASS_NAME, fromCondtion, LC_RENT_PLAN_HIS.CLASS_NAME,null, otherProperty, null, tx); + this.copyRentPlanFormatToHis(entry.getKey(),entry.getValue(),memo,tx); } } + + /** + * copy租金计划到历史表 + * @param contractId + * @param fcRequestId + * @param tx + * @throws Exception + */ + public void copyRentPlanFormatToHis(String contractId,String fcRequestId,String memo,JBOTransaction tx) throws Exception { + + Map fromCondtion=new HashMap(); + fromCondtion.put("CONTRACT_ID",contractId); + + Map otherProperty=new HashMap(); + otherProperty.put("MEMO", memo); + otherProperty.put("FLOWUNID", fcRequestId); + + copyRentPlanFormatToHis(fromCondtion,null,otherProperty,tx); + + } + + /** + * copy租金计划到历史表 + * @param fromCondtion + * @param toCondtion + * @param otherProperty + * @param tx + * @throws Exception + */ + public void copyRentPlanFormatToHis(Map fromCondtion,Map toCondtion,Map otherProperty,JBOTransaction tx) throws Exception { + + DataOperatorUtil.copyJBOSet(LC_RENT_PLAN.CLASS_NAME, fromCondtion, LC_RENT_PLAN_HIS.CLASS_NAME,toCondtion, otherProperty, null, tx); + + } + + /** + * copy租金计划到历史表 + * @param contractId + * @param fcRequestId + * @param tx + * @throws Exception + */ + public void copyCashFlowFormatToHis(String contractId,String fcRequestId,JBOTransaction tx) throws Exception { + + Map fromCondtion=new HashMap(); + fromCondtion.put("CONTRACT_ID",contractId); + + Map otherProperty=new HashMap(); + otherProperty.put("FLOWUNID", fcRequestId); + + copyCashFlowFormatToHis(fromCondtion,null,otherProperty,tx); + + } + + /** + * copy租金计划到历史表 + * @param fromCondtion + * @param toCondtion + * @param otherProperty + * @param tx + * @throws Exception + */ + public void copyCashFlowFormatToHis(Map fromCondtion,Map toCondtion,Map otherProperty,JBOTransaction tx) throws Exception { + + DataOperatorUtil.copyJBOSet(LC_CASH_FLOW.CLASS_NAME, fromCondtion, LC_CASH_FLOW_HIS.CLASS_NAME,toCondtion, otherProperty, null, tx); + + } + /** * 获取对应的合同ID * @param fyfrpBoList @@ -197,7 +243,6 @@ public class CorpusSourceFileCopy { lrpBo.setAttributeValue("CORPUS_BUSINESS",principal); lrpBo.setAttributeValue("INTEREST_BUSINESS",interest); lrpBo.setAttributeValue("PLAN_DATE",repaymentDate); - lrpBo.setAttributeValue("RENT",repaymentMoney); lrpBom.saveObject(lrpBo); } } @@ -337,6 +382,181 @@ public class CorpusSourceFileCopy { insertProfitPlan(param,tx); } + /** + * 变更资方 + * @param param + * @param tx + * @throws JBOException + */ + public void changeCorpusSource(Map param,JBOTransaction tx) throws JBOException { + String sql = "update O set corpus_source='AP' where "; + JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx).createQuery(sql+"id=:projectId").setParameter("projectId",param.get("projectId")).executeUpdate(); + JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx).createQuery(sql+"project_id=:projectId").setParameter("projectId",param.get("projectId")).executeUpdate(); + JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME,tx).createQuery(sql+"project_no=:projectNo").setParameter("projectNo",param.get("projectNo")).executeUpdate(); + JBOFactory.getBizObjectManager(LB_CONTRACT_INFO_TEMP.CLASS_NAME,tx).createQuery(sql+"project_id=:projectId").setParameter("projectId",param.get("projectId")).executeUpdate(); + + } + + /** + * 资方变更插入日志 + * @param param + * @param tx + * @throws JBOException + */ + public void saveCorpusSourceChangeLog(Map param ,int result,JBOTransaction tx) throws JBOException { + BizObjectManager frclBom = JBOFactory.getBizObjectManager(FC_REQUEST_CHANNEL_LOG.CLASS_NAME,tx); + BizObject frclBo = frclBom.newObject(); + frclBo.setAttributeValue("FC_REQUEST_ID",param.get("fcRequestId")); + frclBo.setAttributeValue("PRE_CHANNEL_NO",param.get("channelNo")); + frclBo.setAttributeValue("PRE_CHANNEL_NAME",param.get("channelName")); + frclBo.setAttributeValue("CHANNEL_NO","AP"); + frclBo.setAttributeValue("CHANNEL_NAME","安鹏自有资金"); + frclBo.setAttributeValue("REMARK","回购为安鹏自有资金"); + frclBo.setAttributeValue("CHANGE_RESULT",result); + frclBo.setAttributeValue("CREATETIME",StringFunction.getTodayNow()); + frclBom.saveObject(frclBo); + } + + /** + * 更新租金计划(提前结清) + * @param param + * @param tx + * @throws JBOException + */ + public void updateSettleRentPlan(Map param ,JBOTransaction tx) throws JBOException { + BizObjectManager lrpBom = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,tx); + //更新租金计划信息(提前结清当期期次) + BizObject lrpBo = lrpBom.createQuery("contract_id=:contractId and plan_list=:planList").setParameter("contractId",param.get("contractId")).setParameter("planList",param.get("termNo")).getSingleResult(true); + lrpBo.setAttributeValue("PLAN_DATE",param.get("repaymentDate")); + lrpBo.setAttributeValue("RENT",param.get("rent")); + lrpBo.setAttributeValue("CORPUS",param.get("principal")); + lrpBo.setAttributeValue("INTEREST",param.get("interest")); + lrpBo.setAttributeValue("CORPUS_BUSINESS",param.get("principal")); + lrpBo.setAttributeValue("INTEREST_BUSINESS",param.get("interest")); + lrpBo.setAttributeValue("ALL_REMAIN_CORPUS",param.get("0.00")); + lrpBom.saveObject(lrpBo); + //删除租金计划信息(大于提前结清当期期次的) + lrpBom.createQuery("delete from O where contract_id=:contractId and plan_list>:plan_list").setParameter("contractId",param.get("contractId")).setParameter("planList",param.get("termNo")).executeUpdate(); + } + + /** + * 获取插入租金实收表的所有参数 + * @param fyfrrBoList + * @param tx + * @return + * @throws Exception + */ + public List> getAllParam(List fyfrrBoList, JBOTransaction tx) throws Exception { + List> rentIncomeParams = new ArrayList<>(); + Set contractIdSet = new HashSet<>(); + BizObjectManager lrpBom = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME); + BizObjectQuery lrpBomQuery = lrpBom.createQuery("select ID from O where contract_id=:contractId and plan_list=:planList"); + for(BizObject bo : fyfrrBoList){ + Map rentIncomeParam = new HashMap<>(); + //获取参数 + String fcRequestId = bo.getAttribute("FC_REQUEST_ID").toString(); + String contractId = bo.getAttribute("CONTRACT_ID").toString(); + String termNo = bo.getAttribute("TERM_NO").toString(); + String principal = bo.getAttribute("ALR_PRINCIPAL").toString(); + String interest = bo.getAttribute("ALR_INTEREST").toString(); + String penalty = bo.getAttribute("ALR_PENALTY").toString(); + String rent = new BigDecimal(principal).add(new BigDecimal(interest)).toString(); + String repaymentMoney = bo.getAttribute("ALR_REPAYMENT_MONEY").toString(); + String repaymentDate = bo.getAttribute("NEW_REPAY_DATE").toString(); + //转换日期格式 + Date date = new SimpleDateFormat("yyyyMMdd").parse(repaymentDate); + repaymentDate = new SimpleDateFormat("yyyy/MM/dd").format(date); + String rentPlanId = null; + if(!contractIdSet.contains(contractId)){ + //获取对应租金计划Id + BizObject lrpBo = lrpBomQuery.setParameter("contractId",contractId).setParameter("planList",termNo).getSingleResult(false); + rentPlanId = lrpBo.getAttribute("ID").toString(); + //将由合同id获取的参数放进来 + Map param = getParamByContractId(contractId,tx); + rentIncomeParam.putAll(param); + + contractIdSet.add(contractId); + } + //存入参数 + rentIncomeParam.put("fcRequestId",fcRequestId); + rentIncomeParam.put("contractId",contractId); + rentIncomeParam.put("termNo",termNo); + rentIncomeParam.put("rentPlanId",rentPlanId); + rentIncomeParam.put("rent",rent); + rentIncomeParam.put("principal",principal); + rentIncomeParam.put("interest",interest); + rentIncomeParam.put("penalty",penalty); + rentIncomeParam.put("repaymentMoney",repaymentMoney); + rentIncomeParam.put("repaymentDate",repaymentDate); + + rentIncomeParams.add(rentIncomeParam); + } + return rentIncomeParams; + } + + /** + * 插入租金实收表 + * @param param + * @param tx + * @throws Exception + */ + public void insertRentIncome(Map param, JBOTransaction tx) throws Exception { + BizObjectManager lriBom = JBOFactory.getBizObjectManager(LC_RENT_INCOME.CLASS_NAME,tx); + + BizObject lriBo = lriBom.newObject(); + lriBo.setAttributeValue("PROJECT_ID",param.get("projectId")); + lriBo.setAttributeValue("PROJECT_PLAN_NUMBER",param.get("projectPlanNumber")); + lriBo.setAttributeValue("CONTRACT_ID",param.get("contractId")); + lriBo.setAttributeValue("CONTRACT_PLAN_NUMBER",param.get("contractPlanNumber")); + lriBo.setAttributeValue("PAYMENT_NUMBER",param.get("paymentNumber")); + lriBo.setAttributeValue("PLAN_ID",param.get("rentPlanId")); + lriBo.setAttributeValue("CORPUS_ADJUST","0.00"); + lriBo.setAttributeValue("INTEREST_ADJUST","0.00"); + lriBo.setAttributeValue("PENALTY_ADJUST","0.00"); + lriBo.setAttributeValue("SETTLE_METHOD","settlemethod6"); + lriBo.setAttributeValue("HIRE_BANK",param.get("bankName")); + lriBo.setAttributeValue("HIRE_ACCOUNT",param.get("account")); + lriBo.setAttributeValue("HIRE_NUMBER",param.get("accNumber")); + lriBo.setAttributeValue("ROLL_BACK","0"); + lriBo.setAttributeValue("charge_way","PSBC"); + lriBo.setAttributeValue("RENT",param.get("repaymentMoney")); + lriBo.setAttributeValue("CORPUS",param.get("principal")); + lriBo.setAttributeValue("INTEREST",param.get("interest")); + lriBo.setAttributeValue("PENALTY",param.get("penalty")); + lriBo.setAttributeValue("PLAN_LIST",param.get("termNo")); + lriBo.setAttributeValue("HIRE_LIST","1"); + lriBo.setAttributeValue("PLAN_DATE",param.get("repaymentDate")); + lriBo.setAttributeValue("INPUTUSERID","8009U00000002");//定时任务管理员 + lriBo.setAttributeValue("INPUTTIME",StringFunction.getTodayNow()); + lriBom.saveObject(lriBo); + } + + /** + * 更新租金计划状态 + * @param param + * @param tx + * @throws JBOException + */ + public void updateRentPlanStatus(Map param ,JBOTransaction tx) throws JBOException { + BizObjectManager lrpBom = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,tx); + BizObject lrpBo = lrpBom.createQuery("contract_id=:contractId and plan_list=:planList").setParameter("contractId",param.get("contractId")).setParameter("planList",param.get("termNo")).getSingleResult(true); + lrpBo.setAttributeValue("COLLECT_STATUS","批量收款"); + lrpBo.setAttributeValue("COLLECT_MSG","邮储代收"); + lrpBom.saveObject(lrpBo); + } + /** + * 更新合同状态 + * @param contractId + * @param tx + * @throws JBOException + */ + public void updateContractStatus(String contractId ,String sts,JBOTransaction tx) throws JBOException { + BizObjectManager lciBom = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx); + BizObject lciBo = lciBom.createQuery("ID=:contractId").setParameter("contractId",contractId).getSingleResult(true); + lciBo.setAttributeValue("CONTRACT_STATUS",sts); + lciBom.saveObject(lciBo); + } + public String getContractId() { return contractId; } diff --git a/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentPlanCopy.java b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentPlanCopy.java index 831f46ba0..96d93ccc5 100644 --- a/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentPlanCopy.java +++ b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentPlanCopy.java @@ -75,7 +75,7 @@ public class CorpusSourceRentPlanCopy extends CorpusSourceFileCopy implements Jo Transaction Sqlca = Transaction.createTransaction(tx); //===顺序不能错=== //0.将租金计划拷贝到历史表 - copyRentPlanFormatToHis(contractMap,tx); + copyRentPlanFormatToHis(contractMap,"安鹏原正式租金计划",tx); //1.更新租金计划表(直接文件每条信息更新,不需要遍历) updateRentPlan(fyfrpBoList,tx); for(Map.Entry entry : contractMap.entrySet()){ @@ -108,5 +108,4 @@ public class CorpusSourceRentPlanCopy extends CorpusSourceFileCopy implements Jo return fyfrpBoList; } - } diff --git a/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentResultCopy.java b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentResultCopy.java new file mode 100644 index 000000000..43ff9ebbe --- /dev/null +++ b/src_tenwa/com/tenwa/lease/app/quartzmession/CorpusSourceRentResultCopy.java @@ -0,0 +1,214 @@ +package com.tenwa.lease.app.quartzmession; + +import com.amarsoft.app.als.sys.tools.Tools; +import com.amarsoft.app.util.ProductParamUtil; +import com.amarsoft.app.util.XMLDataUtil; +import com.amarsoft.are.ARE; +import com.amarsoft.are.jbo.*; +import com.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.base.util.QuartzUtil; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.reckon.util.DateUtils; +import com.tenwa.reckon.util.IRRCalculateUtil; +import com.tenwa.reckon.util.IrrTools; +import jbo.app.tenwa.calc.LC_RENT_INCOME; +import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP; +import jbo.oti.FC_REQUEST; +import jbo.oti.FC_REQUEST_CHANNEL_LOG; +import jbo.oti.FC_YC_FILE_REPAY_RESULT; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; + + +/** + * 资方租金计划拷贝 + */ +public class CorpusSourceRentResultCopy extends CorpusSourceFileCopy implements Job { + + @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(); + + JBOTransaction tx = null; + try { + tx = JBOFactory.createJBOTransaction(); + setFileType("RepayResult"); + doCopy(tx); + tx.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 (tx != null) { + tx.rollback(); + } + } catch (JBOException e1) { + e1.printStackTrace(); + } + throw new JobExecutionException(e); + } + } + + /** + * 执行自己类所需的操作 + * @param fyfrpBoList + * @param tx + * @throws Exception + */ + @Override + public void respectiveDo(List fyfrpBoList , JBOTransaction tx) throws Exception { + Transaction Sqlca = Transaction.createTransaction(tx); + //0.获取所有参数(以文件信息为基础,将合同参数补充进去) + List> allParam = this.getAllParam(fyfrpBoList,tx); + for(Map param : allParam){ + //1.插入租金实收表 + this.insertRentIncome(param,tx); + // 2.0根据状态的不同,来进行不同的操作 + //2.1如果当期正常结清或者当期逾期结清, + if("0".equals(param.get("REPAYMENT_FLAG"))){ + updateRentPlanStatus(param,tx); + //2.2如果提前结清 并且 为借款人本人账户,则视为客户本人提前结清,直接变更租金计划表租金计划 + }else if("3".equals(param.get("REPAYMENT_FLAG"))&&"0".equals(param.get("REPAYMENT_SOURCE"))){ + //租金计划,现金流存历史表 + //每个合同只有一次提前结清,只有提前结清才会走这里,所以按照合同id来执行 + copyRentPlanFormatToHis(param.get("contractId"),param.get("fcRequestId"),"邮储提前结清前租金计划",tx); + copyCashFlowFormatToHis(param.get("contractId"),param.get("fcRequestId"),tx); + //变更租金计划 + updateSettleRentPlan(param,tx); + //变更合同状态 + updateContractStatus(param.get("contractId"),"100",tx); + //变更现金流 + createCashFlow(param,Sqlca); + //重新Irr计算 + + //2.3如果提请结清 并且 为非借款人本人账户,则视为我方回购,需改变资方状态,我方能继续扣款 + }else if("3".equals(param.get("REPAYMENT_FLAG"))&&"1".equals(param.get("REPAYMENT_SOURCE"))){ + int result = 1; + //变更资方资源(要有日志) + try{ + changeCorpusSource(param,tx); + }catch (JBOException e){ + result = 0; + e.printStackTrace(); + ARE.getLog().error(param.get("contractNo")+":变更资方时遇见错误"); + throw new Exception("变更资方时遇见错误"); + }finally{ + //存日志 + saveCorpusSourceChangeLog(param,result,tx); + } + + } + } + + } + + /** + * 根据文件ID获取《租金实收》信息 + * @param fcFileId + * @return + * @throws Exception + */ + @Override + public List getFileInfoByFileId(String fcFileId) throws Exception { + String sql = "select fr.CONTRACT_ID,O.FC_REQUEST_ID,O.TERM_NO,O.NEW_REPAY_DATE,O.ALR_PRINCIPAL,O.ALR_INTEREST,O.ALR_PENALTY,O.ALR_REPAYMENT_MONEY,REPAYMENT_FLAG,REPAYMENT_SOURCE from O left join jbo.oti.FC_REQUEST fr on O.LOAN_NO=fr.FC_LOAN_ID where fr.DEL_FLAG='0' and O.FC_FILE_ID=:fcFileId"; + BizObjectManager fyfrrBom = JBOFactory.getBizObjectManager(FC_YC_FILE_REPAY_RESULT.CLASS_NAME); + List fyfrrBoList = fyfrrBom.createQuery(sql).setParameter("fcFileId",fcFileId).getResultList(false); + if(fyfrrBoList.size()==0){ + ARE.getLog().error("未找到FC_REQUEST_ID: "+fcFileId+" 对应的资方还款计划"); + throw new Exception("未找到FC_REQUEST_ID: "+fcFileId+" 对应的资方还款计划"); + } + return fyfrrBoList; + } + + /** + * + * @throws JBOException + */ + public void createCashFlow(Mapparam ,Transaction Sqlca) throws Exception { + //0.删除原有现金流 + String deleteSql = "delete from lc_cash_flow where contract_id=:contractId"; + SqlObject sql = new SqlObject(deleteSql); + sql.setParameter("contractId",param.get("contractId")); + Sqlca.executeSQL(sql); + //1.插入新的现金流 + String appendInfo = " "; + String sqlPath = "/etc/sql/insertIntoCashFlow.xml"; + String xmlPath=ARE.getProperty("PRD_HOME").replace("/WEB-INF", "")+sqlPath; + Map xmlFile= XMLDataUtil.readTableInfoFromXmlFile(xmlPath); + String sqlCode=xmlFile.get("table_sql").replaceAll("\r|\n|\t", " "); + + String GPSDifference= ProductParamUtil.getProductParameterValue(param.get("product_id"),"PRD0390","GPSDifference","GPSDifference"); + if(GPSDifference!=null&&!"".equals(GPSDifference)){ + appendInfo = "union all select '','','','','',plan_date,'"+GPSDifference+"' flowin,'GPS差额:"+GPSDifference+"' flowindetail,'' flowout,'' flowoutdetil,'"+GPSDifference+"' cleanfow from lc_fund_plan where contract_id =:contractId and fee_type='feetype10' "; + } + sql = new SqlObject(sqlCode); + sql.setParameter("appendInfo",appendInfo); + sql.setParameter("contractId",param.get("contractId")); + Sqlca.executeSQL(sql); + } + + public String calcIRR(Map param,JBOTransaction tx) throws Exception { + String cashSql = "select NET_FLOW,PLAN_DATE from lc_cash_flow where contract_id='"+param.get("contractId")+"' order by plan_date"; + List> cashes = DataOperatorUtil.getDataBySql(tx, cashSql, null); + List netList = new ArrayList(); + List dateList = new ArrayList(); + for(Map cash :cashes){ + netList.add(cash.get("NET_FLOW")); + dateList.add(cash.get("PLAN_DATE")); + } + String irr=""; + if("STAGE_IRR".equals(IrrType)){//按期IRR + BigDecimal issueRate= IRRCalculateUtil.getIRR2(netList); + irr=issueRate.multiply( new BigDecimal(1200/cb.getIncomeIntervalMonth())).setScale(6,BigDecimal.ROUND_HALF_UP).toString(); + }else if("MONTH_IRR".equals(IrrType)){//按月IRR + String upperListDate=""; + List newNetList=new ArrayList(); + List newDateList=new ArrayList(); + for(int i=0;i inflowPour=new ArrayList(); + String plandate=""; + for(int i=0;i1){ + for(int y=1;y