diff --git a/WebContent/Frame/page/js/as_debug.js b/WebContent/Frame/page/js/as_debug.js index e622d0a9a..65a0667e8 100644 --- a/WebContent/Frame/page/js/as_debug.js +++ b/WebContent/Frame/page/js/as_debug.js @@ -34,8 +34,12 @@ var AsDebug = { d.showModal(); }, + alert:function(title,message,width,height,mask,time,okButton,openCallback,closeCallback,flag) { + this.showMessage(title,message,width,height,mask,time,okButton,openCallback,closeCallback,flag); + }, showMessage:function(title,message,width,height,mask,time,okButton,openCallback,closeCallback,flag){ var d; + if(typeof(mask) == "undefined") mask = true; if(!okButton){ d = top.dialog({ id: 'dialog-message', diff --git a/WebContent/Tenwa/Lease/DistributorManage/DistributorApproval/LDistributorInfo.jsp b/WebContent/Tenwa/Lease/DistributorManage/DistributorApproval/LDistributorInfo.jsp index 61bff98f7..b2253aa20 100644 --- a/WebContent/Tenwa/Lease/DistributorManage/DistributorApproval/LDistributorInfo.jsp +++ b/WebContent/Tenwa/Lease/DistributorManage/DistributorApproval/LDistributorInfo.jsp @@ -50,7 +50,7 @@ + <%@ include file="/Tenwa/Core/FlowManager/BaseFlowList/BaseFlowApplyListEnd.jspf"%> diff --git a/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/ActualPaymentCarTempList.jsp b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/ActualPaymentCarTempList.jsp new file mode 100644 index 000000000..f645e42be --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/ActualPaymentCarTempList.jsp @@ -0,0 +1,350 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2017-06-06 + Content: + History Log: + */ + String sFileSaveMode = CurConfig.getConfigure("FileSaveMode"); + String sFileSavePath = CurConfig.getConfigure("FileSavePath"); + String sFileNameType = CurConfig.getConfigure("FileNameType"); + + String phaseNo = CurPage.getParameter("PhaseNo"); + String rightType = CurComp.getParameter("RightType"); + String flowunid = CurPage.getParameter("FlowUnid"); + String ishistory = CurPage.getParameter("IsHistory"); + String contract_id = CurPage.getParameter("contract_id"); + String projectId = CurPage.getParameter("ProjectId"); + ASObjectModel doTemp = new ASObjectModel("ActualPaymentCarTempList"); +/* if(null!=ishistory&&ishistory.equals("true")){ + doTemp.setDataQueryClass("com.tenwa.flow.flowHistory.FlowDataListHistory"); + } */ + String customertype = null; + String customer_id = null; + String project_id = null; + String product_id = null; + String contract_number = null; + ASResultSet rs = Sqlca.getASResultSet(new SqlObject("select customertype,contract_number,customer_id,LC_FUND_INCOME_TEMP.project_id,Product_Id from LC_FUND_INCOME_TEMP left join LB_CONTRACT_INFO lpi on lpi.PROJECT_ID=LC_FUND_INCOME_TEMP.PROJECT_ID left join LB_UNION_LESSEE ul on LC_FUND_INCOME_TEMP.contract_id=ul.contract_id and ul.is_main='Y' left join CUSTOMER_INFO cu on ul.customer_id=cu.customerid where LC_FUND_INCOME_TEMP.contract_id = "+contract_id)); + if(rs.next()){ + customertype = rs.getString("customertype"); + customer_id = rs.getString("customer_id"); + project_id = rs.getString("project_id"); + product_id = rs.getString("Product_Id"); + contract_number = rs.getString("contract_number"); + }else{ + customertype = "gaoxiao"; + } + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.MultiSelect = true; + dwTemp.ReadOnly = "0"; + dwTemp.ShowSummary = "1"; +/* if("0030".equals(phaseNo)){ + rightType = "ReadOnly"; + dwTemp.ReadOnly = "1"; + } */ + if("ReadOnly".equals(rightType)){ + dwTemp.MultiSelect = false; + } + dwTemp.setPageSize(pageSize == null?10:Integer.parseInt(pageSize)); + ASDataObject ado = dwTemp.getDataObject(); + ado.setLockCount(2); + ado.setReadOnly("PAYMENT_NUMBER", true); + ado.setReadOnly("PROJECT_NAME", true); + ado.setReadOnly("PLAN_ID", true); + ado.setReadOnly("FEE_TYPE", true); + ado.setReadOnly("SETTLE_METHOD", true); + ado.setReadOnly("PLAN_DATE", true); + ado.setReadOnly("ACCOUNT", true); + ado.setReadOnly("ACC_NUMBER", true); + if("0010".equals(phaseNo)){ + ado.setReadOnly("FACT_DATE", true); + ado.setReadOnly("BANK", true); + } + if("0020".equals(phaseNo)||"0030".equals(phaseNo)){ + ado.setReadOnly("BANK", true); + ado.setRequired("BANK", false); + } + ado.setHtmlEvent("FACT_MONEY", "onchange", "checkEquipAmtMoney"); + ado.setHtmlEvent("FEE_ADJUST", "onchange", "checkEquipAmtMoney"); + ado.setHtmlEvent("MEMO", "onmouseover", "showMemo"); + ado.setHtmlEvent("MEMO", "onmouseout", "hideMemo"); + ado.setHtmlEvent("MEMO", "onkeyup", "synchMemo"); + dwTemp.genHTMLObjectWindow(flowunid); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String[][] sButtons = null; + if("ReadOnly".equals(rightType)){ + sButtons = new String[][]{ + }; + }else if("0050".equals(phaseNo)){ + sButtons = new String[][]{ + {"true","","Button","删除","删除","doDelete()","","","","btn_icon_delete",""} + }; + }else if("0010".equals(phaseNo)){ + sButtons = new String[][]{ + /* {"true","","Button","保存","保存","as_save(0,'setColRequired()')","","","","btn_icon_saveNew",""}, + {"true","","Button","批量修改","批量修改","batchModify()","","","","btn_icon_detail",""}, */ + {"true","","Button","删除","删除","doDelete()","","","","btn_icon_delete",""}, }; + }else if("0020".equals(phaseNo)||"0030".equals(phaseNo)){ + sButtons = new String[][]{ + {"true","","Button","保存","保存","as_save(0,'setColRequired()')","","","","btn_icon_saveNew",""} , + {"true","","Button","批量修改","批量修改","batchModify()","","","","btn_icon_detail",""} + }; + }else{ + sButtons = new String[][]{ + {"true","","Button","保存","保存","as_save(0,'setColRequired()')","","","","btn_icon_saveNew",""}, + {"true","","Button","批量修改","批量修改","batchModify()","","","","btn_icon_detail",""}, + {"true","","Button","导出付款明细","导出付款明细","createFundIncomeExcel()","","","","btn_icon_up",""}, + }; + + } +%><%@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/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/CheckApplyPassContract.jsp b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/CheckApplyPassContract.jsp new file mode 100644 index 000000000..b9605deb7 --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/CheckApplyPassContract.jsp @@ -0,0 +1,13 @@ +<%@page import="jbo.app.tenwa.calc.LC_FUND_INCOME"%> +<%@page import="jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP"%> +<%@page import="jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT"%> +<%@page import="com.amarsoft.are.jbo.BizObject"%> +<%@page import="com.amarsoft.are.jbo.JBOFactory"%> +<%@page import="com.amarsoft.are.jbo.JBOTransaction"%> +<%@page import="java.math.BigDecimal"%> +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/IncludeBeginMDAJAX.jsp"%><% + //String result = Sqlca.getString(new SqlObject("select case when count(1)>0 then 'true' else 'false' end from lc_fund_income O left join(select contract_id,sum(nvl(overmoney,0)) overmoney from vi_lc_fund_plan where fee_type in ('feetype1','feetype2','feetype27') group by contract_id) vlfp on vlfp.contract_id=O.contract_id where O.pay_status='apply_pass' and vlfp.overmoney = 0 and not exists (select 1 from lc_fund_income_temp where O.plan_id=plan_id and is_flowing='0')")); + String result = Sqlca.getString(new SqlObject("select case when count(1)>0 then 'true' else 'false' end from vi_actual_fund_plan")); + out.println(result); +%><%@ include file="/IncludeEndAJAX.jsp"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/GetActualPayNumber.jsp b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/GetActualPayNumber.jsp new file mode 100644 index 000000000..94188459a --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/GetActualPayNumber.jsp @@ -0,0 +1,6 @@ +<%@page import="com.tenwa.util.SerialNumberUtil"%> +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/IncludeBeginMDAJAX.jsp"%><% + String serialNumber = SerialNumberUtil.getActualPayNumber(Sqlca); + out.println(serialNumber); +%><%@ include file="/IncludeEndAJAX.jsp"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/LBActualPaymentInfoTemp.jsp b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/LBActualPaymentInfoTemp.jsp new file mode 100644 index 000000000..253be410f --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/LBActualPaymentInfoTemp.jsp @@ -0,0 +1,22 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><% + /* + Author: undefined 2017-12-28 + Content: 示例详情页面 + History Log: + */ + String flowunid = CurPage.getParameter("FlowUnid"); + String sTempletNo = "LBActualPaymentInfoTemp";//--模板号-- + ASObjectModel doTemp = new ASObjectModel(sTempletNo); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request); + dwTemp.Style = "2";//freeform + dwTemp.ReadOnly = "1";//只读模式 + dwTemp.genHTMLObjectWindow(flowunid); + + String sButtons[][] = { + }; + sButtonPosition = "south"; +%><%@ 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/Tenwa/Lease/Flow/Fund/ActualPayment/VIActualFundPlan.jsp b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/VIActualFundPlan.jsp new file mode 100644 index 000000000..c5e85aafd --- /dev/null +++ b/WebContent/Tenwa/Lease/Flow/Fund/ActualPayment/VIActualFundPlan.jsp @@ -0,0 +1,57 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2017-12-28 + Content: + History Log: + */ + String flowunid = CurPage.getAttribute("FlowUnid"); + String phaseNo = CurPage.getAttribute("PhaseNo"); + String ishistory = CurPage.getAttribute("IsHistory"); + ASObjectModel doTemp = new ASObjectModel("VIActualFundPlan"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + if(!ishistory.equals("true")&&"0010".equals(phaseNo)){ + dwTemp.MultiSelect = true; //多选 + } + dwTemp.ShowSummary="1"; //汇总 + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(pageSize == null ? 30 : Integer.parseInt(pageSize)); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String[][] sButtons = null; + if(null!=ishistory&&ishistory.equals("true")){ + sButtons = new String[][]{}; + }else if("0010".equals(phaseNo)){ + sButtons = new String[][]{ + {"true","All","Button","生成本次付款明细","生成本次付款明细","createIncome()","","","","btn_icon_add",""} + }; + }else{ + sButtons = new String[][]{ + }; + } + +%><%@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/WebContent/WEB-INF/etc/jbo/jbo_calc.xml b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml index 4329b4bb5..d60dfd48c 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml @@ -1383,6 +1383,7 @@ + @@ -1446,6 +1447,7 @@ + @@ -3008,6 +3010,78 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml index d7935aea8..e8cde8c3f 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_lease.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_lease.xml @@ -104,6 +104,7 @@ + @@ -225,6 +226,7 @@ + diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index 127d10933..937f59b1c 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -2,12 +2,18 @@ package com.tenwa.reckon.executor; import java.io.InputStream; import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; import jbo.app.tenwa.calc.LC_CALC_CONDITION; import jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP; @@ -31,6 +37,7 @@ import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.json.JSONEncoder; import com.amarsoft.are.util.json.JSONObject; +import com.amarsoft.awe.util.SqlObject; import com.tenwa.comm.exception.BusinessException; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.officetempalte.util.ExcelVersionEnum; @@ -69,7 +76,17 @@ public class CreateTransactionExecutor implements Transaction { private String plannumber; private String productId; private String planCName; - /** + private String startDate; + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + /** * 正常测算 */ @Override @@ -164,6 +181,109 @@ public class CreateTransactionExecutor implements Transaction { } } + /** + * 车贷起租测算 + * @param Sqlca + * @return + * @throws Exception + */ + public String carRunOnhire(com.amarsoft.awe.util.Transaction Sqlca) throws Exception { + BizObjectManager Bm=JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME, Sqlca); + BizObject boLCC = Bm.createQuery("contract_id='" + contractId + "'").getSingleResult(true); + //获取期次 + if(boLCC!=null){ + int incomeNumber = boLCC.getAttribute("INCOME_NUMBER").getInt(); + String periodType = boLCC.getAttribute("PERIOD_TYPE").getString(); + String incomeIntervalMonth = boLCC.getAttribute("INCOME_INTERVAL_MONTH").getInt() + ""; + List planDateList = getPlanDateList(incomeNumber, periodType, incomeIntervalMonth, startDate); + Sqlca.executeSQL(new SqlObject("insert into lc_rent_plan select * from lc_pay_rent_plan where payment_number = '" + this.plannumber + "'")); + Connection conn = Sqlca.getConnection(Sqlca); + PreparedStatement ps = conn.prepareStatement("update lc_rent_plan set plan_date = ? where payment_number = '" + this.plannumber + "' and plan_list = ?"); + for(int i = 0; i < planDateList.size(); i ++) { + ps.setString(1, planDateList.get(i)); + ps.setString(2, (i + 1) + ""); + ps.addBatch(); + } + ps.executeBatch(); + boLCC.setAttributeValue("start_date", startDate); + boLCC.setAttributeValue("lease_amt_date", startDate); + if(planDateList.size()>0)boLCC.setAttributeValue("first_plan_date", planDateList.get(0)); + if(planDateList.size()>1)boLCC.setAttributeValue("second_plan_date", planDateList.get(1)); + Bm.saveObject(boLCC); + Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + planDateList.get(planDateList.size() - 1) + "' where payment_number = '" + this.plannumber + "' and pay_type = 'pay_type_out' and fee_type != 'feetype10'")); + Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and pay_type = 'pay_type_in' and fee_type != 'feetype4' and fee_type != 'feetype12'")); + Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and fee_type = 'feetype10'")); + this.setCashFlow(this.plannumber, this.productId, Sqlca); + } + return "success"; + } + public void setCashFlow(String paymentNumber, String productId, com.amarsoft.awe.util.Transaction Sqlca) throws Exception { + String sql = ""; + sql += "INSERT INTO LC_CASH_FLOW (id,project_id,project_plan_number,contract_id,contract_plan_number,payment_number"; + sql += ",plan_date"; + sql += ",fund_in"; + sql += ",fund_in_details"; + sql += ",fund_out"; + sql += ",fund_out_details"; + sql += ",net_flow"; + //sql += ",flowunid";//create_date,creator_ "+DateUtil.getSystemDate()+"' create_date ,'"+SecurityUtil.getPrincipal().getId()+"' creator_" + sql += " )"; + + sql +=" select sys_guid() id,max(t.project_id),max(t.project_plan_number),max(t.contract_id),max(t.contract_plan_number),max(t.payment_number),t.plan_date,sum(t.flowin) fundin,nvl(wmsys.wm_concat(case when t.flowindetail='' then null else t.flowindetail end ),'-') fundindetails, "; + sql +=" sum(t.flowout) fundout ,nvl(wmsys.wm_concat(case when t.flowoutdetail='' then null else t.flowoutdetail end),'-') fundoutdetails,sum(t.cleanfow)netflow " ; + sql +=" from (" ; + sql +=" select cfrp.project_id,cfrp.project_plan_number,cfrp.contract_id,cfrp.contract_plan_number,cfrp.payment_number,cfrp.plan_date,cfrp.rent flowin,'第'||cfrp.plan_list||'期租金:'||to_char(cfrp.rent,'FM9,999,999,999,999,999,999,999,990.00') flowindetail,0 flowout,'' flowoutdetail,cfrp.rent-0 cleanfow " ; + sql +=" from lc_rent_plan cfrp" ; + sql +=" where cfrp.payment_number='" + paymentNumber + "'" ; + sql +=" union all " ; + sql +=" select fundplan.project_id,fundplan.project_plan_number,fundplan.contract_id,fundplan.contract_plan_number,fundplan.payment_number,fundplan.plan_date,case when fundplan.pay_type='pay_type_in'then fundplan.plan_money else 0 end flowin, "; + sql +=" case when fundplan.pay_type='pay_type_in'then concat(concat(tdd.itemname,':'),to_char(fundplan.plan_money,'FM9,999,999,999,999,999,999,999,990.00')) else ''end, " ; + sql +=" case when fundplan.pay_type='pay_type_out'then fundplan.plan_money else 0 end flowout, " ; + sql +=" case when fundplan.pay_type='pay_type_out' then tdd.itemname||':'||to_char(fundplan.plan_money,'FM9,999,999,999,999,999,999,999,990.00') else ''end flowoutdetail, " ; + sql +=" case when fundplan.pay_type='pay_type_in' then fundplan.plan_money else -fundplan.plan_money end cleanfow " ; + sql +=" from lc_fund_plan fundplan " ; + sql +=" left join code_library tdd on fundplan.fee_type = tdd.itemno " ; + sql +=" where fundplan.payment_number='" + paymentNumber + "'"; + if(productId != null){ + Map> productCashInIRRList = ProductParamUtil.getProductComponentType(productId, "PRD0315"); + Set>> entry = productCashInIRRList.entrySet(); + for(Entry> e : entry){ + Map parameMap = e.getValue(); + boolean flag = false; + if("N".equals(parameMap.get("CostType10"))){ + flag = true; + } + if(flag){ + sql +=" and tdd.relativecode<>'"+e.getKey()+"' "; + } + } + } + sql +=" )t group by t.plan_date "; + Sqlca.executeSQL(new SqlObject(sql)); + } + + public static List getPlanDateList(int incomeNumber, String periodType, String incomeIntervalMonth, String startDate) throws ParseException { + List planDate = new ArrayList(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(com.amarsoft.app.als.sys.tools.DateUtil.parseStringToDate(startDate, "yyyy/MM/dd")); + int day = calendar.get(Calendar.DAY_OF_MONTH); + int addMonth = Integer.parseInt(incomeIntervalMonth); + for(int i = 0; i < incomeNumber; i ++) { + if(!("period_type_1".equals(periodType) && i == 0)) {//期末加上还款间隔 + calendar.add(Calendar.MONTH, addMonth); + if(day != calendar.get(Calendar.DAY_OF_MONTH)) { + if(day > calendar.getActualMaximum(Calendar.DAY_OF_MONTH)) { + calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); + } else { + calendar.set(Calendar.DAY_OF_MONTH, day); + } + } + } + planDate.add(com.amarsoft.app.als.sys.tools.DateUtil.formatDateToString(calendar.getTime(), "yyyy/MM/dd")); + } + return planDate; + } + /** * 中途中止 */ diff --git a/src/com/amarsoft/app/als/sys/tools/DateUtil.java b/src/com/amarsoft/app/als/sys/tools/DateUtil.java index c656e0273..0239f5a04 100644 --- a/src/com/amarsoft/app/als/sys/tools/DateUtil.java +++ b/src/com/amarsoft/app/als/sys/tools/DateUtil.java @@ -1,7 +1,9 @@ package com.amarsoft.app.als.sys.tools; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import com.amarsoft.are.lang.DateX; /** @@ -12,6 +14,7 @@ import com.amarsoft.are.lang.DateX; public class DateUtil { public final static String BusinessDate=""; + public final static SimpleDateFormat sdf = new SimpleDateFormat(); /** * 获得当前日期 @@ -52,4 +55,14 @@ public class DateUtil { return theday; } + public static Date parseStringToDate(String date, String format) throws ParseException { + sdf.applyPattern(format); + return sdf.parse(date); + } + + public static String formatDateToString(Date date, String format) throws ParseException { + sdf.applyPattern(format); + return sdf.format(date); + } + } diff --git a/src_core/com/tenwa/util/SerialNumberUtil.java b/src_core/com/tenwa/util/SerialNumberUtil.java index 19c09c603..9005b54f1 100644 --- a/src_core/com/tenwa/util/SerialNumberUtil.java +++ b/src_core/com/tenwa/util/SerialNumberUtil.java @@ -36,7 +36,9 @@ public class SerialNumberUtil { public static synchronized String getProjectSerialNumber(String orgId,JBOTransaction tx) throws Exception{ return SerialNumberUtil.getSerialNumber("P{year}{month}{day}{maxOrderNumber}",6,null, "项目编号"+orgId, null, tx); } - + public static synchronized String getActualPayNumber(JBOTransaction tx) throws Exception{ + return SerialNumberUtil.getSerialNumber("PAY{year}{month}{day}{maxOrderNumber}",4,null, "实际放款号", null, tx); + } public static synchronized String getEbankSerialNumber(String orgId,JBOTransaction tx) throws Exception{ return SerialNumberUtil.getSerialNumber("E-{year}{month}{maxOrderNumber}",3,null, "网银编号"+orgId, null, tx); } diff --git a/src_tenwa/com/tenwa/flow/bussinessapprove/BussinessStatusAndDetailAction.java b/src_tenwa/com/tenwa/flow/bussinessapprove/BussinessStatusAndDetailAction.java new file mode 100644 index 000000000..02d877b12 --- /dev/null +++ b/src_tenwa/com/tenwa/flow/bussinessapprove/BussinessStatusAndDetailAction.java @@ -0,0 +1,115 @@ +package com.tenwa.flow.bussinessapprove; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import jbo.com.tenwa.lease.carbrand.BUSINESS_STATUS; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; +import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +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.amarsoft.context.ASUser; +import com.tenwa.reckon.util.UUIDUtil; + +/** + * 更新业务状态与业务详情表记录 + * @author jianghd + * + */ +public class BussinessStatusAndDetailAction { + //1.后续随项目进行到一定阶段时对业务状态与详情的处理 + public static String stageRun(JBOTransaction tx,String CurUserID,String ProjectIdOrContractId,String statusCode) throws Exception{ + BizObjectManager bsBom = JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx); + Transaction tran = Transaction.createTransaction(tx); + ASUser user = ASUser.getUser(CurUserID, tran); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + String now = sdf.format(new Date(System.currentTimeMillis())); + SqlObject lpi = new SqlObject("SELECT LPI.CONTRACT_NUMBER FROM LB_PROJECT_INFO LPI WHERE LPI.ID='"+ProjectIdOrContractId+"'"); + SqlObject lci = new SqlObject("SELECT LPI.CONTRACT_NUMBER FROM LB_CONTRACT_INFO LPI WHERE LPI.ID='"+ProjectIdOrContractId+"'"); + ASResultSet ass = tran.getASResultSet(lpi); + String contractNumber = ""; + SqlObject so; + String bStatus =""; + if(ass.next()){ + contractNumber = ass.getString("CONTRACT_NUMBER"); + bStatus = bsBom.createQuery("CONTRACT_NUMBER=:ContractNumber").setParameter("ContractNumber", contractNumber).getSingleResult(true).getAttribute("BUSINESS_STATUS").getString(); + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='"+statusCode+"',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+now+"' WHERE CONTRACT_NUMBER='"+contractNumber+"'").executeUpdate(); + + so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME,BEFORE_STATUS) SELECT SYS_GUID(),CONTRACT_NUMBER,'"+statusCode+"','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"','"+bStatus+"' FROM LB_PROJECT_INFO WHERE ID='"+ProjectIdOrContractId+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so); + }else{ + ass = tran.getASResultSet(lci); + if(ass.next()){contractNumber = ass.getString("CONTRACT_NUMBER");} + BizObject bo = bsBom.createQuery("CONTRACT_NUMBER=:ContractNumber").setParameter("ContractNumber", contractNumber).getSingleResult(true); + if(bo!=null){ + bStatus = bo.getAttribute("BUSINESS_STATUS").getString(); + }else{//初始化BussinessStatus + bo = bsBom.newObject(); + bo.setAttributeValue("BUSINESS_STATUS","1"); + bo.setAttributeValue("CONTRACT_NUMBER",contractNumber); + bo.setAttributeValue("INPUTUSERID",user.getUserID()); + bo.setAttributeValue("INPUTORGID",user.getOrgID()); + bo.setAttributeValue("INPUTTIME",now); + bsBom.saveObject(bo); + bStatus = "1"; + } + + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='"+statusCode+"',UPDATEUSERID='"+user.getUserID()+"',UPDATEORGID='"+user.getOrgID()+"',UPDATETIME='"+now+"' WHERE CONTRACT_NUMBER='"+contractNumber+"'").executeUpdate(); + so = new SqlObject("INSERT INTO BUSINESS_DETAIL(ID,CONTRACT_NUMBER,BUSINESS_STATUS,INPUTUSERID,INPUTORGID,INPUTTIME,BEFORE_STATUS) SELECT SYS_GUID(),CONTRACT_NUMBER,'"+statusCode+"','"+user.getUserID()+"','"+user.getOrgID()+"','"+StringFunction.getTodayNow().replaceAll(":", "△")+"','"+bStatus+"' FROM LB_CONTRACT_INFO WHERE ID='"+ProjectIdOrContractId+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("△", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("△", ":")); + so.setRunSql(so.getRunSql().replaceAll("△", ":")); + tran.executeSQL(so); + } + return "true"; + } + //2.取消时的处理 + public static String CancelRun(JBOTransaction tx,String CurUserID,String ProjectIdOrContractId,String delCode)throws Exception{ + Transaction tran = Transaction.createTransaction(tx); + SqlObject lpi = new SqlObject("SELECT LPI.CONTRACT_NUMBER FROM LB_PROJECT_INFO LPI WHERE LPI.ID='"+ProjectIdOrContractId+"'"); + SqlObject lci = new SqlObject("SELECT LPI.CONTRACT_NUMBER FROM LB_CONTRACT_INFO LPI WHERE LPI.ID='"+ProjectIdOrContractId+"'"); + ASResultSet ass = tran.getASResultSet(lpi); + String contractNumber = ""; + SqlObject so; + String bStatus =""; + if(ass.next()){ + contractNumber = ass.getString("CONTRACT_NUMBER"); + so = new SqlObject("select before_status from BUSINESS_DETAIL where CONTRACT_NUMBER='"+contractNumber+"' and BUSINESS_STATUS='"+delCode+"'"); + ASResultSet rs = tran.getASResultSet(so); + if(rs.next()){ + bStatus = rs.getString("before_status"); + } + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='"+bStatus+"' WHERE CONTRACT_NUMBER='"+contractNumber+"'").executeUpdate(); + so = new SqlObject("DELETE FROM BUSINESS_DETAIL WHERE CONTRACT_NUMBER='"+contractNumber+"' AND BUSINESS_STATUS='"+delCode+"'"); + tran.executeSQL(so); + }else{ + ass = tran.getASResultSet(lci); + if(ass.next()){contractNumber = ass.getString("CONTRACT_NUMBER");} + contractNumber = ass.getString("CONTRACT_NUMBER"); + so = new SqlObject("select before_status from BUSINESS_DETAIL where CONTRACT_NUMBER='"+contractNumber+"' and BUSINESS_STATUS='"+delCode+"'"); + ASResultSet rs = tran.getASResultSet(so); + if(rs.next()){ + bStatus = rs.getString("before_status"); + } + JBOFactory.getBizObjectManager(BUSINESS_STATUS.CLASS_NAME,tx) + .createQuery("UPDATE O SET BUSINESS_STATUS='"+bStatus+"' WHERE CONTRACT_NUMBER='"+contractNumber+"'").executeUpdate(); + so = new SqlObject("DELETE FROM BUSINESS_DETAIL WHERE CONTRACT_NUMBER='"+contractNumber+"' AND BUSINESS_STATUS='"+delCode+"'"); + tran.executeSQL(so); + } + return "true"; + } + +} diff --git a/src_tenwa/com/tenwa/flow/fund/actualpayment/CopyContractFundFormalToTemp.java b/src_tenwa/com/tenwa/flow/fund/actualpayment/CopyContractFundFormalToTemp.java new file mode 100644 index 000000000..e3c9940aa --- /dev/null +++ b/src_tenwa/com/tenwa/flow/fund/actualpayment/CopyContractFundFormalToTemp.java @@ -0,0 +1,37 @@ +package com.tenwa.flow.fund.actualpayment; + +import jbo.app.tenwa.calc.LB_ACTUAL_PAYMENT_INFO_TEMP; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.util.Transaction; +import com.amarsoft.context.ASUser; +import com.tenwa.flow.baseBussion.BaseBussiness; + +/** + * 拷贝申请通过的付款计划到临时表 + * @author tenwapc + */ +public class CopyContractFundFormalToTemp extends BaseBussiness{ + public Object run(Transaction Sqlca) throws Exception{ + this.initBussinessParam(Sqlca.getTransaction()); + String sFlowUnid = (String)this.getAttribute("ObjectNo"); + String userId = (String)this.getAttribute("CurUserID"); + String applyDate = (String)this.getAttribute("FlowKey"); + ASUser user = ASUser.getUser(userId, Sqlca); + BizObjectManager bomLAPIT = JBOFactory.getBizObjectManager(LB_ACTUAL_PAYMENT_INFO_TEMP.CLASS_NAME,Sqlca); + BizObject boLAPIT = bomLAPIT.newObject(); + boLAPIT.setAttributeValue("flowunid", sFlowUnid); + boLAPIT.setAttributeValue("contract_count", 0); + boLAPIT.setAttributeValue("total_money", 0); + boLAPIT.setAttributeValue("apply_date", applyDate); + boLAPIT.setAttributeValue("inputuserid", user.getUserID()); + boLAPIT.setAttributeValue("inputorgid", user.getOrgID()); + boLAPIT.setAttributeValue("inputtime", StringFunction.getTodayNow()); + bomLAPIT.saveObject(boLAPIT); + String sMessage="true"; + return sMessage; + } +} diff --git a/src_tenwa/com/tenwa/flow/fund/actualpayment/FundIncomeEndRentPlanModify.java b/src_tenwa/com/tenwa/flow/fund/actualpayment/FundIncomeEndRentPlanModify.java new file mode 100644 index 000000000..825ffc68b --- /dev/null +++ b/src_tenwa/com/tenwa/flow/fund/actualpayment/FundIncomeEndRentPlanModify.java @@ -0,0 +1,261 @@ +package com.tenwa.flow.fund.actualpayment; + +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import jbo.app.tenwa.calc.LC_CALC_CONDITION_STATUS; +import jbo.app.tenwa.calc.LC_CASH_FLOW; +import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; + +import com.amarsoft.app.awe.config.InitDBType; +import com.amarsoft.app.util.ProductParamUtil; +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.tenwa.flow.baseBussion.BaseBussiness; +import com.tenwa.reckon.executor.CreateTransactionExecutor; +/** + * 实际付款申请通过后,根据付款日期修改租金计划 + * @author zhulh + * + */ + +public class FundIncomeEndRentPlanModify extends BaseBussiness{ + public Object run(Transaction Sqlca) throws Exception{ + this.initBussinessParam(Sqlca.getTransaction()); + String sFlowUnid = (String)this.getAttribute("ObjectNo"); + BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME); + Sqlca.join(bomLFIT); + //查询付款类型为车辆款的付款项的合同id(contract_id) 条件为设备款,不为货扣,不为退回的,并且支付成功的数据才默认为放款成功! + @SuppressWarnings("unchecked") + List bos = bomLFIT.createQuery("flowunid=:flowunid and pay_type='pay_type_out' and fee_type='feetype10' and settle_method <> 'settlemethod11' and pay_status<>'apply_return' and ebank_status='05'") + .setParameter("flowunid", sFlowUnid).getResultList(false); + //SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd"); + try{ + if(bos.size() > 0){ + for(BizObject bo:bos){ + String payment_number=bo.getAttribute("payment_number").toString(); + String contractId=bo.getAttribute("contract_id").toString(); + String productId = Sqlca.getString("select product_id from lb_contract_info where id='"+contractId+"'"); + String calType = "onHire_process"; + CreateTransactionExecutor cre = new CreateTransactionExecutor(); + cre.setCalType(calType); + cre.setContractId(contractId); + cre.setProductId(productId); + cre.setPlannumber(payment_number); + cre.setFlowunid(contractId); + cre.setStartDate(bo.getAttribute("fact_date").toString()); + cre.carRunOnhire(Sqlca); +/* Date fact_date=df.parse(bo.getAttribute("fact_date").toString()); + Date base_date=fact_date; + Calendar calendar = new GregorianCalendar(); + //计算出第一期租金的日期 + calendar.setTime(base_date); + int date=calendar.get(Calendar.DATE); + if(date<=20){ + calendar.add(Calendar.MONTH, 1); + }else{ + calendar.add(Calendar.MONTH, 2); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM"); + //取得年利率 + BizObjectManager bomLCC = JBOFactory.getBizObjectManager(LC_CALC_CONDITION.CLASS_NAME); + Sqlca.join(bomLCC); + BizObject boc=bomLCC.createQuery("payment_number=:payment_number") + .setParameter("payment_number", payment_number).getSingleResult(true); + String first_date = sdf.format(calendar.getTime())+"/"+boc.getAttribute("rent_day").getString(); + BigDecimal year_rate=new BigDecimal(boc.getAttribute("year_rate").toString()); + //取出还款间隔(月) + int income_interval_month = boc.getAttribute("income_interval_month").getInt(); + //取得租金计算方式 + String settle_method= boc.getAttribute("SETTLE_METHOD").toString(); + boc.setAttributeValue("start_date", bo.getAttribute("fact_date").toString()); + boc.setAttributeValue("first_plan_date", first_date); + bomLCC.saveObject(boc); + + //获取lc_rent_plan表数据并进行修改 + BizObjectManager bomLRP = JBOFactory.getBizObjectManager(LC_PAY_RENT_PLAN.CLASS_NAME); + BizObjectManager bomLR = JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME,Sqlca); + Sqlca.join(bomLRP); + List bors = bomLRP.createQuery("payment_number=:payment_number order by plan_list") + .setParameter("payment_number", payment_number).getResultList(false); + if(bors.size() > 0){ + for(int i = 0 ; i < bors.size() ; i++){ + BizObject bor=bors.get(i); + list=bor.getAttribute("plan_list").getInt(); + if((settle_method.equals("even_rent")||settle_method.equals("even_corpus"))&&list==1){ + Date plan_date=df.parse(bor.getAttribute("plan_date").toString()); + long betweendays = (long) ((fact_date.getTime() - plan_date.getTime())/ + (24*3600*1000));// 天数间隔 + //计算日利率 + BigDecimal day_rate=year_rate.divide(new BigDecimal("360"),6,BigDecimal.ROUND_HALF_UP); + //计算实际利息差 + BigDecimal otherinterest=day_rate.multiply(new BigDecimal(betweendays)); + //计算出第一期利息 + BigDecimal interest=new BigDecimal(bor.getAttribute("interest").toString()).add(otherinterest); + //计算出第一期业务利息 + BigDecimal interest_business=new BigDecimal(bor.getAttribute("interest_business").toString()).add(otherinterest); + //计算出第一期租金 + BigDecimal rent=new BigDecimal(bor.getAttribute("rent").toString()).add(otherinterest); + //回写租金计划 + bor.setAttributeValue("interest", interest); + bor.setAttributeValue("interest_business", interest_business); + bor.setAttributeValue("rent", rent); + bor.setAttributeValue("plan_date", first_date); + BizObject bolr = bomLR.newObject(); + DataOperatorUtil.coptyJBOPropertyNoKey(bor, bolr); + bomLR.saveObject(bolr); + }else{ + Date fdate= df.parse(first_date); + calendar.setTime(fdate); + calendar.add(Calendar.MONTH, income_interval_month*i); + String datefact = df.format(calendar.getTime()); + bor.setAttributeValue("plan_date", datefact); + BizObject bolr = bomLR.newObject(); + DataOperatorUtil.coptyJBOPropertyNoKey(bor, bolr); + bomLR.saveObject(bolr); + } + } + } + this.delete(payment_number, Sqlca.getTransaction()); + this.add(contract_id, payment_number, productId, Sqlca.getTransaction());*/ + //插入起租层 + BizObjectManager bm = JBOFactory.getBizObjectManager(LC_CALC_CONDITION_STATUS.CLASS_NAME,Sqlca); + BizObject boLCCS=bm.newObject(); + boLCCS.setAttributeValue("contract_id", contractId); + boLCCS.setAttributeValue("payment_number", payment_number); + boLCCS.setAttributeValue("PLAN_STATUS", "31"); + bm.saveObject(boLCCS); + //修改合同状态也为31 + BizObjectManager cibm = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,Sqlca); + BizObject cibo = cibm.createQuery("ID=:id").setParameter("id", contractId).getSingleResult(true); + cibo.setAttributeValue("CONTRACT_STATUS", "31"); + cibm.saveObject(cibo); + } + } + }catch(Exception e){ + e.printStackTrace(); + throw new RuntimeException("起租导表异常"); + } + String sMessage="true"; + return sMessage; + } + + private void add(String contractID,String paymentNumber,String productId,JBOTransaction tx) throws Exception{ + String sql = ""; + if("MYSQL".equals(InitDBType.DBTYPE)){ + sql += "INSERT INTO lc_cash_flow (id,contract_id,payment_number"; + sql += ",plan_date"; + sql += ",fund_in"; + sql += ",fund_in_details"; + sql += ",fund_out"; + sql += ",fund_out_details"; + sql += ",net_flow"; + sql += ",fund_in_company"; + sql += ",fund_in_details_company"; + sql += ",fund_out_company"; + sql += ",fund_out_details_company"; + sql += ",net_flow_company)"; + + sql +=" select replace(uuid(),'-','') id,'"+contractID+"' contract_id,'"+paymentNumber+"',t.plan_date,sum(t.flowin) fundin,ifnull(group_concat(if(t.flowindetail='',null,t.flowindetail)),'-') fundindetails, "; + sql +=" sum(t.flowout) fundout ,ifnull(group_concat(if(t.flowoutdetail='',null,t.flowoutdetail)),'-')fundoutdetails,sum(t.cleanfow)netflow " ; + sql+=",sum(t.flowin_compay) fundin_company,ifnull(group_concat(if(t.flowindetail_company='',null,t.flowindetail_company)),'-') fundindetails_company, "; + sql +=" sum(t.flowout_company) fundout_company ,ifnull(group_concat(if(t.flowoutdetail_company='',null,t.flowoutdetail_company)),'-')fundoutdetails_company,sum(t.cleanfow_company)netflow_company" ; + sql +=" from (" ; + sql +=" select cfrp.plan_date,cfrp.rent flowin,concat('第',cfrp.plan_list,'期租金:',cfrp.rent) flowindetail,0 flowout,'' flowoutdetail,cfrp.rent-0 cleanfow " ; + sql +=" ,cfrp.rent_company flowin_company,concat('第',cfrp.plan_list,'期租金:',cfrp.rent_company) flowindetail_company,0 flowout_company,'' flowoutdetail_company,cfrp.rent_company-0 cleanfow_company"; + sql +=" from lc_rent_plan cfrp" ; + sql +=" where cfrp.payment_number = '"+paymentNumber+"'" ; + sql +=" union all " ; + sql +=" select fundplan.plan_date,if(fundplan.pay_type='pay_type_in',fundplan.plan_money,0)flowin, "; + sql +=" if(fundplan.pay_type='pay_type_in',concat(tdd.itemname,':',fundplan.plan_money),''), " ; + sql +=" if(fundplan.pay_type='pay_type_out',fundplan.plan_money,0)flowout, " ; + sql +=" if(fundplan.pay_type='pay_type_out',concat(tdd.itemname,':',fundplan.plan_money),'')flowoutdetail, " ; + sql +=" if(fundplan.pay_type='pay_type_in',fundplan.plan_money,-fundplan.plan_money) cleanfow " ; + + sql+=",if(fundplan.pay_type='pay_type_in',fundplan.plan_money_company,0)flowin_company, "; + sql +=" if(fundplan.pay_type='pay_type_in',concat(tdd.itemname,':',fundplan.plan_money_company),''), " ; + sql +=" if(fundplan.pay_type='pay_type_out',fundplan.plan_money_company,0)flowout_company, " ; + sql +=" if(fundplan.pay_type='pay_type_out',concat(tdd.itemname,':',fundplan.plan_money_company),'')flowoutdetail_company, " ; + sql +=" if(fundplan.pay_type='pay_type_in',fundplan.plan_money_company,-fundplan.plan_money_company) cleanfow_company " ; + + sql +=" from lc_fund_plan fundplan " ; + sql +=" left join code_library tdd on fundplan.fee_type = tdd.itemno " ; + sql +=" where fundplan.payment_number = '"+paymentNumber+"'"; + }else if("ORACLE".equals(InitDBType.DBTYPE)){ + sql += "INSERT INTO lc_cash_flow (id,contract_id,payment_number"; + sql += ",plan_date"; + sql += ",fund_in"; + sql += ",fund_in_details"; + sql += ",fund_out"; + sql += ",fund_out_details"; + sql += ",net_flow"; + sql += ",fund_in_company"; + sql += ",fund_in_details_company"; + sql += ",fund_out_company"; + sql += ",fund_out_details_company"; + sql += ",net_flow_company)"; + + sql +=" select sys_guid() id,'"+contractID+"' contract_id,'"+paymentNumber+"' payment_number,t.plan_date,sum(t.flowin) fundin,nvl(wmsys.wm_concat(case when t.flowindetail='' then null else t.flowindetail end ),'-') fundindetails, "; + sql +=" sum(t.flowout) fundout ,nvl(wmsys.wm_concat(case when t.flowoutdetail='' then null else t.flowoutdetail end),'-') fundoutdetails,sum(t.cleanfow)netflow "; + + sql+=",sum(t.flowin_company) fundin_company,nvl(wmsys.wm_concat(case when t.flowindetail_company='' then null else t.flowindetail_company end ),'-') fundindetails_company, "; + sql +=" sum(t.flowout_company) fundout_company ,nvl(wmsys.wm_concat(case when t.flowoutdetail_company='' then null else t.flowoutdetail_company end),'-') fundoutdetails_company,sum(t.cleanfow_company)netflow_company "; + sql +=" from (" ; + sql +=" select cfrp.plan_date,cfrp.rent flowin,'第'||cfrp.plan_list||'期租金:'||cfrp.rent flowindetail,0 flowout,'' flowoutdetail,cfrp.rent-0 cleanfow " ; + + sql +=" ,cfrp.rent_company flowin_company,'第'||cfrp.plan_list||'期租金:'||cfrp.rent_company flowindetail_company,0 flowout_company,'' flowoutdetail_company,cfrp.rent_company-0 cleanfow_company " ; + + sql +=" from lc_rent_plan cfrp" ; + sql +=" where cfrp.payment_number = '"+paymentNumber+"'"; + sql +=" union all " ; + sql +=" select fundplan.plan_date,case when fundplan.pay_type='pay_type_in'then fundplan.plan_money else 0 end flowin, "; + sql +=" case when fundplan.pay_type='pay_type_in'then concat(concat(tdd.itemname,':'),fundplan.plan_money) else ''end, " ; + sql +=" case when fundplan.pay_type='pay_type_out'then fundplan.plan_money else 0 end flowout, " ; + sql +=" case when fundplan.pay_type='pay_type_out' then tdd.itemname||':'||fundplan.plan_money else ''end flowoutdetail, " ; + sql +=" case when fundplan.pay_type='pay_type_in' then fundplan.plan_money else -fundplan.plan_money end cleanfow " ; + + sql +=" ,case when fundplan.pay_type='pay_type_in'then fundplan.plan_money_company else 0 end flowin_company, "; + sql +=" case when fundplan.pay_type='pay_type_in'then concat(concat(tdd.itemname,':'),fundplan.plan_money_company) else ''end, " ; + sql +=" case when fundplan.pay_type='pay_type_out'then fundplan.plan_money_company else 0 end flowout_company, " ; + sql +=" case when fundplan.pay_type='pay_type_out' then tdd.itemname||':'||fundplan.plan_money_company else ''end flowoutdetail_company, " ; + sql +=" case when fundplan.pay_type='pay_type_in' then fundplan.plan_money_company else -fundplan.plan_money_company end cleanfow_company " ; + + sql +=" from lc_fund_plan fundplan " ; + sql +=" left join code_library tdd on fundplan.fee_type = tdd.itemno " ; + sql +=" where fundplan.payment_number = '"+paymentNumber+"'"; + } + if(productId != null){ + Map> productCashInIRRList = ProductParamUtil.getProductComponentType(productId, "PRD0315"); + Set>> entry = productCashInIRRList.entrySet(); + for(Entry> e : entry){ + Map parameMap = e.getValue(); + boolean flag = false; + if("N".equals(parameMap.get("CostType10"))){ + flag = true; + } + if(flag){ + sql +=" and tdd.relativecode<>'"+e.getKey()+"' "; + } + } + } + sql +=" )t group by t.plan_date "; + Transaction Sqlca =null; + Sqlca = Transaction.createTransaction(tx); + SqlObject asql = new SqlObject(sql); + Sqlca.executeSQL(asql); + } + + private void delete(String paymentNumber,JBOTransaction tx) throws Exception{ + BizObjectManager bm=JBOFactory.getBizObjectManager(LC_CASH_FLOW.CLASS_NAME, tx); + String sql = " delete from O where payment_number='"+paymentNumber+"'"; + bm.createQuery(sql).executeUpdate(); + } +} diff --git a/src_tenwa/com/tenwa/flow/fund/fundcollection/FundIncomeMethod.java b/src_tenwa/com/tenwa/flow/fund/fundcollection/FundIncomeMethod.java index 44c198117..e9d478b7a 100644 --- a/src_tenwa/com/tenwa/flow/fund/fundcollection/FundIncomeMethod.java +++ b/src_tenwa/com/tenwa/flow/fund/fundcollection/FundIncomeMethod.java @@ -1,7 +1,9 @@ package com.tenwa.flow.fund.fundcollection; import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; +import java.util.Map; import jbo.app.tenwa.calc.LC_EBANK_PROCESS; import jbo.app.tenwa.calc.LC_EBANK_TEMP; @@ -9,12 +11,19 @@ import jbo.app.tenwa.calc.LC_FUND_INCOME; import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP; import jbo.app.tenwa.calc.LC_FUND_PLAN; import jbo.app.tenwa.calc.VI_LC_FUND_PLAN; +import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT; 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.are.util.StringFunction; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.flow.bussinessapprove.BussinessStatusAndDetailAction; public class FundIncomeMethod { @@ -27,6 +36,11 @@ public class FundIncomeMethod { private String oldFactMoney; private String newFactMoney; private String isChanged; + private String CONTRACT_ID; + private String contractIds; + private String userId; + private String orgId; + private String status; public String getIsChanged() { return isChanged; @@ -100,6 +114,46 @@ public class FundIncomeMethod { this.newFactMoney = newFactMoney; } + public String getCONTRACT_ID() { + return CONTRACT_ID; + } + + public void setCONTRACT_ID(String cONTRACT_ID) { + CONTRACT_ID = cONTRACT_ID; + } + + public String getContractIds() { + return contractIds; + } + + public void setContractIds(String contractIds) { + this.contractIds = contractIds; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getOrgId() { + return orgId; + } + + public void setOrgId(String orgId) { + this.orgId = orgId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + public String setFundDataToFundIncome(JBOTransaction tx) throws JBOException{ try{ boolean flag = false; @@ -225,4 +279,57 @@ public class FundIncomeMethod { } return "SUCCESS"; } + public String createActualPayment(JBOTransaction tx) throws JBOException{ + try{ + //获取本方账户 + BizObject boOA = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME,tx) + .createQuery("account_purpose='default' and state_='0010'").getSingleResult(false); + for(String contractId : contractIds.split("@")){ + @SuppressWarnings("unchecked") + List bos = JBOFactory.getBizObjectManager(LC_FUND_INCOME.CLASS_NAME) + .createQuery("contract_id='"+contractId+"' and pay_type='pay_type_out' and pay_status='apply_pass'") + .getResultList(false); + BigDecimal totalMoney = new BigDecimal("0"); + int contractCount = 0; + if(bos.size() > 0){ + Map fromCondition = new HashMap(); + Map otherProperty = new HashMap(); + for(BizObject bo:bos){ + fromCondition.clear(); + fromCondition.put("ID", bo.getAttribute("ID").getString()); + fromCondition.put(LC_FUND_INCOME.SETTLE_METHOD, "settlemethod6"); + otherProperty.clear(); + otherProperty.put("FlowUnid", flowunid); + otherProperty.put("IS_FLOWING", "0"); + otherProperty.put("ACCOUNTING_DATE", StringFunction.getTodayNow().split(" ")[0]); + otherProperty.put("BANK", boOA.getAttribute("ACC_BANK").getString()); + otherProperty.put("ACCOUNT", boOA.getAttribute("ACC_NAME").getString()); + otherProperty.put("ACC_NUMBER", boOA.getAttribute("ACC_NUMBER").getString()); + otherProperty.put("INCOME_ID", bo.getAttribute("ID").getString()); + otherProperty.put(LC_FUND_INCOME.EBANK_STATUS, "01"); + DataOperatorUtil.copySingleJBO(LC_FUND_INCOME.CLASS_NAME, fromCondition,LC_FUND_INCOME_TEMP.CLASS_NAME, null, otherProperty,tx); + BussinessStatusAndDetailAction.stageRun( tx, userId, contractId, "30"); + } + } + Transaction sqlTran = Transaction.createTransaction(tx); + ASResultSet rs = sqlTran.getResultSet(new SqlObject("select count(1) contract_count,sum(fact_money) total_money from lc_fund_income_temp where flowunid='"+flowunid+"' and pay_status<>'apply_return' group by flowunid")); + if(rs.next()){ + totalMoney = new BigDecimal(rs.getString("total_money")); + contractCount = Integer.parseInt(rs.getString("contract_count")); + SqlObject so = new SqlObject("update lb_actual_payment_info_temp set contract_count='"+contractCount+"',total_money='"+totalMoney+"',updateuserid='"+userId+"',updateorgid='"+orgId+"',updatetime='"+StringFunction.getTodayNow().replaceAll(":", "@")+"' where flowunid='"+flowunid+"'"); + so.setDebugSql(so.getDebugSql().replaceAll("@", ":")); + so.setOriginalSql(so.getOriginalSql().replaceAll("@", ":")); + so.setRunSql(so.getRunSql().replaceAll("@", ":")); + sqlTran.executeSQL(so); + so = new SqlObject("update flow_bussiness_object set proj_name=(substr(proj_name,1,instr(proj_name,'实际付款')-1)||'实际付款,金额为:"+totalMoney+"') where flow_unid='"+flowunid+"'"); + sqlTran.executeSQL(so); + } + } + }catch(Exception e){ + e.printStackTrace(); + tx.rollback(); + return "ERROR"; + } + return "SUCCESS"; + } }