From 408ca1cc76878203b674a1817cd926a11e7409ae Mon Sep 17 00:00:00 2001 From: "chaojie.li" Date: Tue, 17 Dec 2024 16:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E9=93=B6=E6=94=B6=E6=AC=BE=E6=A0=B8?= =?UTF-8?q?=E9=94=80-=E7=A7=9F=E9=87=91-=E5=AE=A1=E6=89=B9=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2-=E7=A7=9F=E9=87=91=E8=AE=A1=E5=88=92=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=80=9F=E5=BA=A6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Rent/RentIncome/CheckPlanOverMoney.jsp | 133 +- .../Rent/RentIncome/GetBeforeRentOver.jsp | 18 +- .../Flow/Rent/RentIncome/VILCRentPlanList.jsp | 8 +- WebContent/WEB-INF/etc/jbo/jbo_loan.xml | 1 + config/fenix/flow/FundCollectionFlow.xml | 158 + src/com/amarsoft/awe/dw/ASDataObject.java | 2836 ++++++++--------- .../amarsoft/awe/dw/CustomASObjectModel.java | 42 + .../FenixListHtmlGenerator.java | 100 + .../rent/rentincome/RentIncomeMethod.java | 158 +- 9 files changed, 1854 insertions(+), 1600 deletions(-) create mode 100644 config/fenix/flow/FundCollectionFlow.xml create mode 100644 src/com/amarsoft/awe/dw/CustomASObjectModel.java create mode 100644 src_tenwa/com/tenwa/flow/comm/list_html_generator/FenixListHtmlGenerator.java diff --git a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/CheckPlanOverMoney.jsp b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/CheckPlanOverMoney.jsp index 608f5184f..3b633b75a 100644 --- a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/CheckPlanOverMoney.jsp +++ b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/CheckPlanOverMoney.jsp @@ -1,57 +1,76 @@ -<%@page import="com.amarsoft.are.jbo.BizObject"%> -<%@page import="jbo.app.tenwa.calc.VI_LC_RENT_PLAN"%> -<%@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 flowunid = CurPage.getParameter("flowunid"); - String factDate = CurPage.getParameter("factDate"); - String planIDs = CurPage.getParameter("planIDs"); - String overCorpuss = CurPage.getParameter("overCorpuss"); - String overInterests = CurPage.getParameter("overInterests"); - String overPenaltys = CurPage.getParameter("overPenaltys"); - String mayopeMoney = CurPage.getParameter("mayopeMoney"); - String[] planID = planIDs.split("@"); - String[] overCorpus = overCorpuss.split("@"); - String[] overInterest = overInterests.split("@"); - String[] overPenalty = overPenaltys.split("@"); - boolean flag = true; - SqlObject so = new SqlObject("select case when mayope_money != "+mayopeMoney+" then 0 else 1 end from lc_ebank_temp where flowunid='"+flowunid+"'"); - if("0".equals(Sqlca.getString(so))){ - flag = false; - } - boolean flagR = true; - boolean flagP = true; - for(int i=0;i<%@ include file="/IncludeEndAJAX.jsp"%> \ No newline at end of file +<%@page import="com.amarsoft.are.jbo.BizObject" %> +<%@page import="jbo.app.tenwa.calc.VI_LC_RENT_PLAN" %> +<%@page import="com.amarsoft.are.jbo.JBOFactory" %> +<%@page import="com.amarsoft.are.jbo.JBOTransaction" %> +<%@page import="java.math.BigDecimal" %> +<%@ page import="com.tenwa.util.SqlRunnerUtil" %> +<%@ page import="cn.hutool.db.Entity" %> +<%@ page import="cn.hutool.db.handler.EntityHandler" %> +<%@ page contentType="text/html; charset=GBK" %> +<%@ include file="/IncludeBeginMDAJAX.jsp" %> +<% + String flowunid = CurPage.getParameter("flowunid"); + String factDate = CurPage.getParameter("factDate"); + String planIDs = CurPage.getParameter("planIDs"); + String overCorpuss = CurPage.getParameter("overCorpuss"); + String overInterests = CurPage.getParameter("overInterests"); + String overPenaltys = CurPage.getParameter("overPenaltys"); + String mayopeMoney = CurPage.getParameter("mayopeMoney"); + String[] planID = planIDs.split("@"); + String[] overCorpus = overCorpuss.split("@"); + String[] overInterest = overInterests.split("@"); + String[] overPenalty = overPenaltys.split("@"); + boolean flag = true; + SqlObject so = new SqlObject("select case when mayope_money != " + mayopeMoney + " then 0 else 1 end from lc_ebank_temp where flowunid='" + flowunid + "'"); + if ("0".equals(Sqlca.getString(so))) { + flag = false; + } + boolean flagR = true; + boolean flagP = true; + Map sqlParamMap = new HashMap<>(); + for (int i = 0; i < planID.length; i++) { + sqlParamMap.clear(); + sqlParamMap.put("planId", planID[i]); + Entity entity1 = SqlRunnerUtil.query(Sqlca, "flow.FundCollectionFlow.queryRentPlanList", sqlParamMap, new EntityHandler()); +// String sql = "select case when (corpus_over != " + overCorpus[i] + " or interest_over != " + overInterest[i] + ") then 0 else 1 end from vi_lc_rent_plan where id='" + planID[i] + "'"; +// so = new SqlObject(sql); +// String result = Sqlca.getString(so); + if(new BigDecimal(overCorpus[i]).compareTo(entity1.getBigDecimal("corpus_over")) != 0 || new BigDecimal(overInterest[i]).compareTo(entity1.getBigDecimal("interest_over")) != 0) { + flagR = false; + } +// if ("0".equals(result)) { +// flagR = false; +// } + sqlParamMap.put("factDate", factDate.replaceAll("-", "/")); + Entity entity2 = SqlRunnerUtil.query(Sqlca, "flow.FundCollectionFlow.getRentPlanPenaltyByPlanId", sqlParamMap, new EntityHandler()); + if(new BigDecimal(overPenalty[i]).compareTo(entity2.getBigDecimal("penalty_over")) != 0) { + flagP = false; + } + +// sql = "select case when round(getRentPenalty(payment_number,plan_list,'" + factDate + "')-fact_penalty,2) != " + overPenalty[i] + " then 0 else 1 end from vi_lc_rent_plan where id='" + planID[i] + "'"; +// so = new SqlObject(sql); +// result = Sqlca.getString(so); + +// if ("0".equals(result)) { +// flagP = false; +// } + } + String outResult = ""; + if (!flagR) { + outResult += "ERROR"; + } else { + outResult += "SUCCESS"; + } + if (!flagP) { + outResult += "@ERROR"; + } else { + outResult += "@SUCCESS"; + } + if (!flag) { + outResult += "@ERROR"; + } else { + outResult += "@SUCCESS"; + } + out.println(outResult); +%> +<%@ include file="/IncludeEndAJAX.jsp" %> \ No newline at end of file diff --git a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp index 40dd5ea88..3180df918 100644 --- a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp +++ b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp @@ -1,13 +1,25 @@ <%@ page import="com.tenwa.jbo.manager.DataUtil" %> +<%@ page import="com.tenwa.util.SqlRunnerUtil" %> +<%@ page import="cn.hutool.db.handler.EntityListHandler" %> +<%@ page import="cn.hutool.db.Entity" %> +<%@ page import="java.math.BigDecimal" %> <%@ page contentType="text/html; charset=GBK"%> <%@ include file="/IncludeBeginMDAJAX.jsp"%><% String paymentNumber = CurPage.getParameter("paymentNumber"); String planList = CurPage.getParameter("planList"); //获取选择期次前所有的剩余租金的和,如果租金余额大于0,则返回false,禁止跨期核销 - String rentOver = DataUtil.getValueBySql("select sum(rent_over) from vi_rent_collect_4_ebank where payment_number = '"+paymentNumber+"' and plan_list < '"+planList+"';"); - double doubleRentOver = Double.parseDouble(rentOver); +// String rentOver = DataUtil.getValueBySql("select sum(rent_over) from vi_rent_collect_4_ebank where payment_number = '"+paymentNumber+"' and plan_list < '"+planList+"';"); + Map sqlParamMap = new HashMap<>(); + sqlParamMap.put("paymentNumber", paymentNumber); + sqlParamMap.put("plan_listLess", planList); + List resList = SqlRunnerUtil.query(Sqlca, "flow.FundCollectionFlow.queryRentPlanList", sqlParamMap, new EntityListHandler()); + BigDecimal allOver = new BigDecimal(0); + for (Entity entity : resList) { + allOver = allOver.add(entity.getBigDecimal("all_over")); + } +// double doubleRentOver = Double.parseDouble(rentOver); String result = ""; - if(doubleRentOver>0){ + if(allOver.compareTo(BigDecimal.ZERO) == 1){ result = "false"; }else{ result = "true"; diff --git a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/VILCRentPlanList.jsp b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/VILCRentPlanList.jsp index ec5d46162..38db69d39 100644 --- a/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/VILCRentPlanList.jsp +++ b/WebContent/Tenwa/Lease/Flow/Rent/RentIncome/VILCRentPlanList.jsp @@ -35,8 +35,9 @@ businessType="2,3"; } } - ASObjectModel doTemp = new ASObjectModel("VILCRentPlanList"); - doTemp.setDataQueryClass("com.amarsoft.awe.dw.ui.list.FlowMonitorListHtmlGenerator"); +// ASObjectModel doTemp = new ASObjectModel("VILCRentPlanList"); +// doTemp.setDataQueryClass("com.amarsoft.awe.dw.ui.list.FlowMonitorListHtmlGenerator"); + CustomASObjectModel doTemp = new CustomASObjectModel("VILCRentPlanList", "flow.FundCollectionFlow.queryRentPlanList" , true); CurPage.setAttribute("flowRowCount","100"); //检验客户名称是否为经销商 IsNullCheck inc = new IsNullCheck(); @@ -105,6 +106,9 @@ } function checkInputData(i){ + // if(getCheckedRows(0).length == 0) { + // return; + // } TableBuilder.iCurrentRow['myiframe0'] = i; TableBuilder.displaySelectedRows('myiframe0'); if($("#period").attr("checked") != "checked"){ diff --git a/WebContent/WEB-INF/etc/jbo/jbo_loan.xml b/WebContent/WEB-INF/etc/jbo/jbo_loan.xml index 389c46954..841fd46b5 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_loan.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_loan.xml @@ -687,6 +687,7 @@ + diff --git a/config/fenix/flow/FundCollectionFlow.xml b/config/fenix/flow/FundCollectionFlow.xml new file mode 100644 index 000000000..8ba6fa9c6 --- /dev/null +++ b/config/fenix/flow/FundCollectionFlow.xml @@ -0,0 +1,158 @@ + + + + select lrpi.id, + lrpi.contract_id, + lrpi.contract_number, + lrpi.payment_number, + lrpi.customer_name as customername, + lrpi.plan_list, + lrpi.plan_date, + lrpi.rent, + lrpi.corpus, + lrpi.interest, + lrpi.penalty, + round(lrpi.rent - lrpi.rent_sum - lrpi.rent_sum_temp, 2) as rent_over, + round(lrpi.corpus - lrpi.corpus_sum - lrpi.corpus_sum_temp, 2) as corpus_over, + round(lrpi.interest - lrpi.interest_sum - lrpi.interest_sum_temp, 2) as interest_over, + round(lrpi.penalty - lrpi.penalty_sum - lrpi.penalty_sum_temp, 2) as penalty_over, + round(lrpi.rent + lrpi.penalty - lrpi.rent_sum - lrpi.rent_sum_temp - lrpi.penalty_sum - + lrpi.penalty_sum_temp, 2) as all_over, + case + when lrpi.rent_sum + lrpi.rent_sum_temp = 0 and lrpi.penalty_sum + lrpi.penalty_sum_temp = 0 then '鏈洖绗' + when lrpi.rent - lrpi.rent_sum - lrpi.rent_sum_temp = 0 and + lrpi.penalty - lrpi.penalty_sum - lrpi.penalty_sum_temp = 0 then '宸插洖绗' + else '閮ㄥ垎鍥炵' end as planstatus, + round(lrpi.penalty_sum + lrpi.penalty_sum_temp, 2) as penalty_sum + from (select lrp.id, + lrp.contract_id, + lci.contract_number, + lrp.payment_number, + lul.customer_name, + lrp.plan_list, + lrp.plan_date, + lrp.rent, + lrp.corpus, + lrp.interest, + round(ifnull((select sum(lri.rent) + from lc_rent_income lri + where roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as rent_sum, + round(ifnull((select sum(lri.rent) + from lc_rent_income_temp lri + where is_flowing = '0' + and roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as rent_sum_temp, + round(ifnull((select sum(lri.corpus + lri.corpus_adjust) + from lc_rent_income lri + where roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as corpus_sum, + round(ifnull((select sum(lri.corpus + lri.corpus_adjust) + from lc_rent_income_temp lri + where is_flowing = '0' + and roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as corpus_sum_temp, + round(ifnull((select sum(lri.interest + lri.interest_adjust) + from lc_rent_income lri + where roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as interest_sum, + round(ifnull((select sum(lri.interest + lri.interest_adjust) + from lc_rent_income_temp lri + where is_flowing = '0' + and roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as interest_sum_temp, + round(ifnull((select sum(lri.penalty + penalty_adjust) + from lc_rent_income lri + where roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as penalty_sum, + round(ifnull((select sum(lri.penalty + penalty_adjust) + from lc_rent_income_temp lri + where is_flowing = '0' + and roll_back = '0' + and lri.payment_number = lrp.payment_number + and lri.plan_list = lrp.plan_list + ), 0), 2) as penalty_sum_temp, + getrentpenalty(lrp.payment_number, lrp.plan_list, date_format(now(), '%Y/%m/%d')) as penalty + from lc_rent_plan lrp + left join lb_contract_info lci on lrp.contract_id = lci.id + left join lb_union_lessee lul on lrp.contract_id = lul.contract_id and lul.is_main = 'Y' + left join customer_account ca on ca.contract_id = lci.id + where lrp.plan_status <> '宸插洖绗' + + + + + + + + and lrp.plan_date < date_add(date_format(current_date(), '%Y-%m-01'), interval 1 month) + and lci.contract_status = '31' + and (lci.corpus_source <> 'PSBC' or isnull(lci.corpus_source)) + and not exists(select 1 + from lc_occupy_rent_list lorl + where lorl.payment_number = lrp.payment_number + and ((lorl.plan_id = lrp.id and + lorl.flow_name in ('寰俊閾惰仈鏀舵', '寰俊鏀粯鏀舵', '缃戦摱鏀舵')) or + lorl.flow_name in ('鍚堝悓涓旂粓姝', '鎻愬墠缁撴竻鐢宠')) + ) + ) lrpi + + + + + select tt.penalty, + tt.fact_penalty, + tt.penalty_adjust, + tt.penalty - tt.fact_penalty - tt.penalty_adjust as penalty_over + from (select round(getrentpenalty(lrp.payment_number, lrp.plan_list, ${factDate}), + 2) as penalty, + round(ifnull(lri.fact_penalty, 0) + ifnull(lrit.fact_penalty, 0), 2) as fact_penalty, + round(ifnull(lri.penalty_adjust, 0) + ifnull(lrit.penalty_adjust, 0), 2) as penalty_adjust + from lc_rent_plan lrp + left join (select payment_number, + plan_list, + sum(penalty) as fact_penalty, + sum(penalty_adjust) as penalty_adjust + from lc_rent_income + where roll_back = '0' + @if{?planId != empty} + and (payment_number, plan_list) in (select lrp1.payment_number, lrp1.plan_list from lc_rent_plan lrp1 where id = #{planId}) + @end{} + + + ) lri on lrp.payment_number = lri.payment_number and lrp.plan_list = lri.plan_list + left join (select payment_number, + plan_list, + sum(penalty) as fact_penalty, + sum(penalty_adjust) as penalty_adjust + from lc_rent_income_temp + where is_flowing = '0' + and roll_back = '0' + @if{?planId != empty} + and (payment_number, plan_list) in (select lrp1.payment_number, lrp1.plan_list from lc_rent_plan lrp1 where id = #{planId}) + @end{} + + + ) lrit on lrp.payment_number = lrit.payment_number and lrp.plan_list = lrit.plan_list + + + + + + ) tt + + \ No newline at end of file diff --git a/src/com/amarsoft/awe/dw/ASDataObject.java b/src/com/amarsoft/awe/dw/ASDataObject.java index 2881cf27a..d15d09cac 100644 --- a/src/com/amarsoft/awe/dw/ASDataObject.java +++ b/src/com/amarsoft/awe/dw/ASDataObject.java @@ -37,6 +37,7 @@ import com.amarsoft.awe.dw.ui.validator.ValidateRule; import com.amarsoft.awe.res.LanguageManager; import com.amarsoft.context.ASUser; import com.amarsoft.dict.als.cache.AWEDataWindowCache; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -48,1530 +49,1437 @@ import java.util.Set; import java.util.Vector; public class ASDataObject - implements Serializable -{ - private static final long serialVersionUID = 1L; - private Hashtable repacedTableList = new Hashtable(); - private ArrayList repacedTableKeyList = new ArrayList(); - private Properties customProperties = new Properties(); - private transient CatalogModel objCatalogModel; - private String serializableName; - private List initParameters = new ArrayList(); - private List parameters = new ArrayList(); - private DWContext dwcontext; - private String clientID = ""; + implements Serializable { + private static final long serialVersionUID = 1L; + private Hashtable repacedTableList = new Hashtable(); + private ArrayList repacedTableKeyList = new ArrayList(); + private Properties customProperties = new Properties(); + private transient CatalogModel objCatalogModel; + private String serializableName; + private List initParameters = new ArrayList(); + private List parameters = new ArrayList(); + private DWContext dwcontext; + private String clientID = ""; - private String dataQueryClass = ""; - private ASFilterCustomWhereClauses filterCustomWhereClauses = null; + private String dataQueryClass = ""; + private ASFilterCustomWhereClauses filterCustomWhereClauses = null; + private String fullFenixId = ""; + private Boolean lazyLoad = false; - private boolean replaceClassName = true; + private boolean replaceClassName = true; - protected boolean editable = false; - public static final String DO_COLTYPE_NUMBER = "Number"; - public static final String DO_COLTYPE_String = "String"; - public static final String DO_COLUMNTYPE_DEFAULT = "1"; - public static final String DO_COLUMNTYPE_SUM = "2"; - public static final String DO_COLUMNTYPE_AVG = "3"; - public static final String DO_EDITSTYLE_TEXT = "Text"; - public static final String DO_EDITSTYLE_Textarea = "Textarea"; - public static final String DO_EDITSTYLE_Password = "Password"; - public static final String DO_EDITSTYLE_Select = "Select"; - public static final String DO_EDITSTYLE_Checkbox = "Checkbox"; - public static final String DO_EDITSTYLE_Date = "Date"; - public static final String DO_EDITSTYLE_YearMonth = "YearMonth"; - public static final String DO_EDITSTYLE_ParentSelect = "ParentSelect"; - public static final String DO_EDITSTYLE_Radiobox = "Radiobox"; - public static final String DO_EDITSTYLE_RadioboxV = "RadioboxV"; - public static final String DO_EDITSTYLE_PictureRadio = "PictureRadio"; - public static final String DO_EDITSTYLE_PictureRadioV = "PictureRadioV"; - public static final String DO_CHECKFORMAT_String = "1"; - public static final String DO_CHECKFORMAT_Number = "2"; - public static final String DO_CHECKFORMAT_Date = "3"; - public static final String DO_CHECKFORMAT_DateTime = "4"; - public static final String DO_CHECKFORMAT_Integer = "5"; - public static final String DO_CHECKFORMAT_WanYuan = "6"; - public static final String DO_CHECKFORMAT_WanYuan2 = "7"; - public static final String DO_CHECKFORMAT_RATE12 = "12"; - public static final String DO_CHECKFORMAT_RATE14 = "14"; - public static final String DO_CHECKFORMAT_RATE16 = "16"; - public static final String DO_CHECKFORMAT_CUSTOM = "99"; - public static final String DO_ALIGN_LEFT = "1"; - public static final String DO_ALIGN_CENTER = "2"; - public static final String DO_ALIGN_RIGHT = "3"; - public static final String DO_EDITSOURCETYPE_CODE = "Code"; - public static final String DO_EDITSOURCETYPE_CODETABLE = "CodeTable"; - public static final String DO_EDITSOURCETYPE_JBO = "Jbo"; - public static final String DO_EDITSOURCETYPE_RANGE = "@MIN_MAX"; - public static final String DO_EDITSOURCETYPE_CUSTOM = "Custom"; - public static final String DO_YESORNO_NO = "0"; - public static final String DO_YESORNO_YES = "1"; - public Vector Columns = new Vector(); + protected boolean editable = false; + public static final String DO_COLTYPE_NUMBER = "Number"; + public static final String DO_COLTYPE_String = "String"; + public static final String DO_COLUMNTYPE_DEFAULT = "1"; + public static final String DO_COLUMNTYPE_SUM = "2"; + public static final String DO_COLUMNTYPE_AVG = "3"; + public static final String DO_EDITSTYLE_TEXT = "Text"; + public static final String DO_EDITSTYLE_Textarea = "Textarea"; + public static final String DO_EDITSTYLE_Password = "Password"; + public static final String DO_EDITSTYLE_Select = "Select"; + public static final String DO_EDITSTYLE_Checkbox = "Checkbox"; + public static final String DO_EDITSTYLE_Date = "Date"; + public static final String DO_EDITSTYLE_YearMonth = "YearMonth"; + public static final String DO_EDITSTYLE_ParentSelect = "ParentSelect"; + public static final String DO_EDITSTYLE_Radiobox = "Radiobox"; + public static final String DO_EDITSTYLE_RadioboxV = "RadioboxV"; + public static final String DO_EDITSTYLE_PictureRadio = "PictureRadio"; + public static final String DO_EDITSTYLE_PictureRadioV = "PictureRadioV"; + public static final String DO_CHECKFORMAT_String = "1"; + public static final String DO_CHECKFORMAT_Number = "2"; + public static final String DO_CHECKFORMAT_Date = "3"; + public static final String DO_CHECKFORMAT_DateTime = "4"; + public static final String DO_CHECKFORMAT_Integer = "5"; + public static final String DO_CHECKFORMAT_WanYuan = "6"; + public static final String DO_CHECKFORMAT_WanYuan2 = "7"; + public static final String DO_CHECKFORMAT_RATE12 = "12"; + public static final String DO_CHECKFORMAT_RATE14 = "14"; + public static final String DO_CHECKFORMAT_RATE16 = "16"; + public static final String DO_CHECKFORMAT_CUSTOM = "99"; + public static final String DO_ALIGN_LEFT = "1"; + public static final String DO_ALIGN_CENTER = "2"; + public static final String DO_ALIGN_RIGHT = "3"; + public static final String DO_EDITSOURCETYPE_CODE = "Code"; + public static final String DO_EDITSOURCETYPE_CODETABLE = "CodeTable"; + public static final String DO_EDITSOURCETYPE_JBO = "Jbo"; + public static final String DO_EDITSOURCETYPE_RANGE = "@MIN_MAX"; + public static final String DO_EDITSOURCETYPE_CUSTOM = "Custom"; + public static final String DO_YESORNO_NO = "0"; + public static final String DO_YESORNO_YES = "1"; + public Vector Columns = new Vector(); - public Vector Filters = new Vector(); - private Vector columnDisplayRules = new Vector(); - private boolean receivedFilterData = false; - private boolean needFillDefaultValue = true; + public Vector Filters = new Vector(); + private Vector columnDisplayRules = new Vector(); + private boolean receivedFilterData = false; + private boolean needFillDefaultValue = true; - private String DONO = ""; - private String DONAME = ""; + private String DONO = ""; + private String DONAME = ""; - private int colCount = 1; - private String styleId = ""; - private ASDataObject subDataObject = null; + private int colCount = 1; + private String styleId = ""; + private ASDataObject subDataObject = null; - private String jboClass = ""; - private String jboFrom = ""; - private String jboWhere = ""; - private String jboWhereWhenNoFilter = ""; - private ArrayList alSelectFields = new ArrayList(); - private ArrayList alVirtualFields = new ArrayList(); - public int appendVirtualColumnSortIndex = 100; - private String jboGroup = ""; + private String jboClass = ""; + private String jboFrom = ""; + private String jboWhere = ""; + private String jboWhereWhenNoFilter = ""; + private ArrayList alSelectFields = new ArrayList(); + private ArrayList alVirtualFields = new ArrayList(); + public int appendVirtualColumnSortIndex = 100; + private String jboGroup = ""; - private String jboOrder = ""; - private String businessProcess = ""; - private Page curPage; - private ArrayList mapHtmlEvents = new ArrayList(); + private String jboOrder = ""; + private String businessProcess = ""; + private Page curPage; + private ArrayList mapHtmlEvents = new ArrayList(); - private String jboSql = ""; - private String jboSelect = ""; + private String jboSql = ""; + private String jboSelect = ""; - private String paramstr = ""; - private String[] virtualFields; - private String[] jboAttributes; - public Vector validateRules; - private int lockCount = 1; - private int pageSize = 20; + private String paramstr = ""; + private String[] virtualFields; + private String[] jboAttributes; + public Vector validateRules; + private int lockCount = 1; + private int pageSize = 20; - public List getInitParameters() - { - return this.initParameters; - } - public void setInitParameters(List initParameters) { - this.initParameters = initParameters; - } - public List getParameters() { - return this.parameters; - } - public void setParameters(List parameters) { - this.parameters = parameters; - } - - public DWContext getDwcontext() - { - return this.dwcontext; - } - - public String getSerializableName() { - return this.serializableName; - } - - public List getValidateTagList() { - if (this.dwcontext == null) return null; - return this.dwcontext.getTagMaps(); - } - - public void setValidateTagParams(String tagName, Object paramValues) - { - if (this.dwcontext == null) return; - TagMap.setTagParams(this.dwcontext.getTagMaps(), tagName, paramValues); - } - - public void setSerializableName(String serializableName) { - this.serializableName = serializableName; - } - - protected void setClientID(String clientID) - { - this.clientID = clientID; - } - public String getClientID() { - return this.clientID; - } - - private void setLanguage(String sLanguage) - { - if (this.objCatalogModel == null) return; - - ArrayList groups = this.objCatalogModel.getGroupList(); - for (GroupModel group : groups) { - group.setLanguage(sLanguage); + public List getInitParameters() { + return this.initParameters; } - List models = this.objCatalogModel.getLibraryList(); - for (LibraryModel model : models) - setColumnAttribute(model.getColName(), "COLHEADER", LanguageManager.getOWLanguage(sLanguage, getDONO(), model.getColHeader())); - } - - public ASFilterCustomWhereClauses getFilterCustomWhereClauses() - { - return this.filterCustomWhereClauses; - } - - public void setFilterCustomWhereClauses(ASFilterCustomWhereClauses filterCustomWhereClauses) - { - this.filterCustomWhereClauses = filterCustomWhereClauses; - } - - public Properties getCustomProperties() - { - return this.customProperties; - } - - public String getDataQueryClass() - { - return this.dataQueryClass; - } - - public void setDataQueryClass(String dataQueryClass) - { - this.dataQueryClass = dataQueryClass; - } - - public boolean isReplaceClassName() - { - return this.replaceClassName; - } - - public boolean isEditable() - { - return this.editable; - } - - public void setReplaceClassName(boolean replaceClassName) { - this.replaceClassName = replaceClassName; - } - - public String getScriptFunctions() throws JBOException { - if (this.objCatalogModel == null) - return ""; - List list = this.objCatalogModel.getFunctionList(); - StringBuffer sbResult = new StringBuffer(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - FunctionModel obj = (FunctionModel)list.get(i); - String sFunctionName = obj.getFunctionName(); - if (sFunctionName == null) - sFunctionName = ""; - String sFunctionParams = obj.getFunctionParams(); - if (sFunctionParams == null) - sFunctionParams = ""; - String sFunctionBody = obj.getFunctionBody(); - if (sFunctionBody == null) - sFunctionBody = ""; - sbResult.append(new StringBuilder().append("function ").append(sFunctionName).append("(").append(sFunctionParams).append("){\n").toString()); - sbResult.append(new StringBuilder().append(sFunctionBody).append("\n").toString()); - sbResult.append("}\n"); - } - return sbResult.toString(); + public void setInitParameters(List initParameters) { + this.initParameters = initParameters; } - return ""; - } - public boolean isNeedFillDefaultValue() - { - return this.needFillDefaultValue; - } - - public void setNeedFillDefaultValue(boolean needFillDefaultValue) { - this.needFillDefaultValue = needFillDefaultValue; - } - - public String getDoName() - { - return this.DONAME; - } - - public ASDataObject getSubDataObject() - { - return this.subDataObject; - } - - public void setSubDataObject(ASDataObject subDataObject) { - this.subDataObject = subDataObject; - try { - subDataObject.init(); - } catch (Exception e) { - e.printStackTrace(); - ARE.getLog().error(new StringBuilder().append("初始化子表格失败:").append(e.toString()).toString()); + public List getParameters() { + return this.parameters; } - } - public void setJboWhereWhenNoFilter(String jboWhereWhenNoFilter) - { - this.jboWhereWhenNoFilter = jboWhereWhenNoFilter; - } - - public void setJboGroup(String jboGroup) - { - this.jboGroup = jboGroup; - Collections.sort(this.repacedTableKeyList, new SortByKey()); - for (int i = 0; i < this.repacedTableKeyList.size(); i++) { - String sKey = this.repacedTableKeyList.get(i).toString(); - this.jboOrder = this.jboOrder.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); + public void setParameters(List parameters) { + this.parameters = parameters; } - } - public ArrayList getHtmlEvents() - { - return this.mapHtmlEvents; - } - - public void removeHtmlEvents(String colName) - { - ArrayList list = getHtmlEvents(colName); - this.mapHtmlEvents.removeAll(list); - } - - public void removeHtmlEvents(String colName, String eventType) - { - ArrayList result = new ArrayList(); - for (int i = 0; i < this.mapHtmlEvents.size(); i++) { - ASHtmlEvent event = (ASHtmlEvent)this.mapHtmlEvents.get(i); - if ((event.getColName().equalsIgnoreCase(colName)) && (eventType.equalsIgnoreCase(event.getEventType()))) - result.add(event); + public DWContext getDwcontext() { + return this.dwcontext; } - this.mapHtmlEvents.removeAll(result); - } - public ArrayList getHtmlEvents(String colName) - { - ArrayList result = new ArrayList(); - for (int i = 0; i < this.mapHtmlEvents.size(); i++) { - ASHtmlEvent event = (ASHtmlEvent)this.mapHtmlEvents.get(i); - if (event.getColName().equalsIgnoreCase(colName)) - result.add(event); + public String getSerializableName() { + return this.serializableName; } - return result; - } - public ASColulmnDistplayRule addColumnDisplayRule(String checkField, String validExpress, String applyFields, String applyCss) - { - ASColulmnDistplayRule rule = ASColulmnDistplayRule.createDisplayRegular(); - rule.setCheckField(checkField); - rule.setValidExpress(validExpress); - rule.setApplyFields(applyFields); - rule.setApplyCss(applyCss); - this.columnDisplayRules.add(rule); - return rule; - } - - public Vector getColumnDisplayRules() - { - return this.columnDisplayRules; - } - - public String[][] getColumnDisplayArray() - { - int iSize = this.columnDisplayRules.size(); - if (iSize == 0) - return new String[0][4]; - String[][] result = new String[iSize][4]; - for (int i = 0; i < iSize; i++) { - ASColulmnDistplayRule rule = (ASColulmnDistplayRule)this.columnDisplayRules.get(i); - result[i][0] = rule.getCheckField(); - result[i][1] = rule.getValidExpress(); - result[i][2] = rule.getApplyFields(); - result[i][3] = rule.getApplyCss(); + public List getValidateTagList() { + if (this.dwcontext == null) return null; + return this.dwcontext.getTagMaps(); } - return result; - } - public String[] getHtmlEvent(String colName, String eventType) - { - ArrayList result = new ArrayList(); - for (int i = 0; i < this.mapHtmlEvents.size(); i++) { - ASHtmlEvent event = (ASHtmlEvent)this.mapHtmlEvents.get(i); - if ((event.getColName().equalsIgnoreCase(colName)) && (event.getEventType().equalsIgnoreCase(eventType))) - result.add(new String[] { event.getEventFunction(), event.getEventParams() }); + public void setValidateTagParams(String tagName, Object paramValues) { + if (this.dwcontext == null) return; + TagMap.setTagParams(this.dwcontext.getTagMaps(), tagName, paramValues); } - return (String[])result.toArray(new String[result.size()]); - } - public void setHtmlEvent(String colNames, String event, String functionName) - { - setHtmlEvent(colNames, event, functionName, null); - } + public void setSerializableName(String serializableName) { + this.serializableName = serializableName; + } - public void setHtmlEvent(String colNames, String event, String functionName, String functionParams) - { - if ((colNames.trim().equals("")) || (colNames.trim().equals("*"))) { - for (int i = 0; i < this.Columns.size(); i++) { - ASColumn column = (ASColumn)this.Columns.get(i); - if ("1".equals(column.getAttribute("COLVISIBLE"))) { - if (i == 0) - colNames = column.getAttribute("colname"); - else - colNames = new StringBuilder().append(colNames).append(",").append(column.getAttribute("colname")).toString(); + protected void setClientID(String clientID) { + this.clientID = clientID; + } + + public String getClientID() { + return this.clientID; + } + + private void setLanguage(String sLanguage) { + if (this.objCatalogModel == null) return; + + ArrayList groups = this.objCatalogModel.getGroupList(); + for (GroupModel group : groups) { + group.setLanguage(sLanguage); } - } - } - String[] sColNameArray = colNames.split("\\,"); - if (sColNameArray == null) - return; - for (int i = 0; i < sColNameArray.length; i++) { - ASHtmlEvent asevent = new ASHtmlEvent(); - asevent.setColName(sColNameArray[i]); - asevent.setEventType(event); - asevent.setEventFunction(functionName); - asevent.setEventParams(functionParams); - this.mapHtmlEvents.add(asevent); - } - } - public Page getCurPage() { - return this.curPage; - } - - public void setCurPage(Page curPage) { - setLanguage(curPage.getUser().getLanguage()); - this.curPage = curPage; - } - - public void setColCount(int colCount) - { - this.colCount = colCount; - } - - public void setBusinessProcess(String businessProcess) - { - this.businessProcess = businessProcess; - } - - public String getBusinessProcess() - { - return this.businessProcess; - } - - public int getPageSize() - { - return this.pageSize; - } - - public void setPageSize(int pageSize) - { - this.pageSize = pageSize; - } - - public String getJboGroup() - { - return this.jboGroup; - } - - public String getJboOrder() - { - return this.jboOrder; - } - - public int getColCount() - { - return this.colCount; - } - - public String getStyleId() - { - return this.styleId; - } - - public String[] getJboAttributes() - { - return this.jboAttributes; - } - - public String[] getVirtualFields() { - return this.virtualFields; - } - - public void clearVirtualFields() { - this.virtualFields = null; - this.alVirtualFields.clear(); - } - - public String getJboFrom() - { - return this.jboFrom; - } - - public void setJboFrom(String jboFrom) - { - this.jboFrom = jboFrom.trim(); - } - - public void setJboOrder(String jboOrder) - { - if ((jboOrder == null) || (jboOrder.equals(""))) { - return; - } - if (jboOrder.indexOf(".") == -1) { - String[] arr = jboOrder.trim().split("\\s"); - String sColName = arr[0]; - if ((getColumnAttribute(sColName, "COLFILTERREFID") != null) && (getColumnAttribute(sColName, "COLFILTERREFID").trim().length() > 0)) - { - sColName = getColumnAttribute(sColName, "COLFILTERREFID"); - }String sTableName = getColumnAttribute(sColName, "COLTABLENAME"); - sTableName = sTableName.replaceAll(this.jboClass, "o"); - Iterator it = this.repacedTableList.keySet().iterator(); - while (it.hasNext()) { - String sKey = it.next().toString(); - sTableName = sTableName.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); - } - jboOrder = new StringBuilder().append(sTableName).append(".").append(getColumnAttribute(sColName, "COLACTUALNAME")).append(" ").append(arr[1]).toString(); + List models = this.objCatalogModel.getLibraryList(); + for (LibraryModel model : models) + setColumnAttribute(model.getColName(), "COLHEADER", LanguageManager.getOWLanguage(sLanguage, getDONO(), model.getColHeader())); } - this.jboOrder = jboOrder; - Collections.sort(this.repacedTableKeyList, new SortByKey()); - for (int i = 0; i < this.repacedTableKeyList.size(); i++) { - String sKey = this.repacedTableKeyList.get(i).toString(); - this.jboOrder = this.jboOrder.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); - } - } - - public String getJboSql() - { - return this.jboSql; - } - - public String getParamstr() - { - return this.paramstr; - } - - public void setParamstr(String paramstr) - { - this.paramstr = paramstr; - } - - public int getLockCount() - { - return this.lockCount; - } - - public void setLockCount(int iLockCount) - { - this.lockCount = iLockCount; - } - - public Vector getValidateRules() - { - return this.validateRules; - } - - public void appendValidateRule(ValidateRule validrule) - { - this.validateRules.add(validrule); - } - - public void removeValidateRule(String colName, String validateName) - { - ValidateRule.removeRule(this.validateRules, colName, validateName); - } - - public void removeValidateRule(String colName) - { - ValidateRule.removeRule(this.validateRules, colName, null); - } - - public String getJboClass() - { - return this.jboClass; - } - - public void setJboClass(String jBOClass) - { - this.jboClass = jBOClass.trim(); - } - - public String getJboWhere() - { - return this.jboWhere; - } - - public void setJboWhere(String jBOWhere) - { - this.jboWhere = jBOWhere; - } - - public void appendJboWhere(String jboWhere) - { - if (StringX.isSpace(jboWhere)) return; - jboWhere = jboWhere.trim(); - if (StringX.isSpace(this.jboWhere)) { - if (jboWhere.toLowerCase().startsWith("and ")) jboWhere = new StringBuilder().append("1 = 1 ").append(jboWhere).toString(); - } - else { if (!jboWhere.toLowerCase().startsWith("and ")) jboWhere = new StringBuilder().append("and ").append(jboWhere).toString(); - jboWhere = new StringBuilder().append(this.jboWhere).append(" ").append(jboWhere).toString(); - } - setJboWhere(jboWhere); - } - - public String getDONO() - { - return this.DONO; - } - - public void setDONO(String dONO) - { - this.DONO = dONO; - } - - public ASDataObject() throws Exception - { - } - - public ASDataObject(String[] headers) throws Exception { - this.DONO = ""; - init(headers); - } - - public ASDataObject(BizObjectManager manager) throws Exception { - this.DONO = manager.getManagedClass().getAbsoluteName(); - init(manager); - } - - public ASDataObject(String sDONo) throws Exception - { - if (sDONo.trim().toUpperCase().startsWith("SELECT ")) { - throw new Exception("不再支持Sql Select语句构造DataObject!"); - } - this.DONO = sDONo; - init(sDONo, ""); - } - - public ASDataObject(String sDONo, String sWhere) throws Exception - { - this.DONO = sDONo; - init(sDONo, sWhere); - } - - public ASDataObject(String sDONo, String sWhere, String sDatabase) throws Exception - { - this.DONO = sDONo; - init(sDONo, sWhere); - } - - public ASColumn createVirtualColumn(String colName, String colHeader, String colActualName) - throws Exception - { - ASColumn column = new ASColumn(colName); - String sColIndx = new StringBuilder().append("Z").append(this.appendVirtualColumnSortIndex++).toString(); - column.setAttribute("DONO", this.DONO); - column.setAttribute("COLINDEX", sColIndx); - column.setAttribute("SORTNO", sColIndx); - column.setAttribute("ISINUSE", "1"); - column.setAttribute("COLACTUALNAME", colActualName); - column.setAttribute("COLNAME", colName); - column.setAttribute("COLTYPE", "String"); - column.setAttribute("COLCOLUMNTYPE", "1"); - column.setAttribute("COLCHECKFORMAT", "1"); - column.setAttribute("COLALIGN", "1"); - column.setAttribute("COLDEFAULTVALUE", ""); - column.setAttribute("COLHEADER", colHeader); - column.setAttribute("COLUNIT", ""); - column.setAttribute("COLEDITSTYLE", "Text"); - column.setAttribute("COLEDITSOURCETYPE", ""); - column.setAttribute("COLEDITSOURCE", ""); - column.setAttribute("COLHTMLSTYLE", ""); - column.setAttribute("COLLIMIT", "0"); - column.setAttribute("COLVISIBLE", "1"); - column.setAttribute("COLREADONLY", "1"); - column.setAttribute("COLREQUIRED", "0"); - column.setAttribute("COLSORTABLE", "1"); - column.setAttribute("ISFILTER", "0"); - column.setAttribute("COLSPAN", ""); - column.setAttribute("ISAUTOCOMPLETE", "0"); - column.setAttribute("GROUPID", ""); - column.setAttribute("COLFILTERREFID", ""); - column.setAttribute("COLFILTERATTRS", ""); - return column; - } - - private void init(String[] headers) - throws Exception - { - this.colCount = 0; - this.styleId = ""; - this.jboClass = ""; - this.jboWhere = ""; - this.jboFrom = ""; - this.jboGroup = ""; - this.jboOrder = ""; - for (int i = 0; i < headers.length; i++) { - ASColumn column = createVirtualColumn(new StringBuilder().append("VCOLUMN_").append(i).toString(), headers[i], ""); - column.setAttribute("COLSORTABLE", "0"); - this.Columns.add(column); - } - } - - public void initQuery(String jboclazz, String queryStatement) - throws Exception - { - queryStatement = StringX.isSpace(queryStatement) ? "SELECT \"*\" FROM O" : StringX.trimAll(queryStatement); - this.DONO = jboclazz; - this.jboClass = jboclazz; - this.colCount = 0; - this.styleId = ""; - - String statement = queryStatement; - String statementUpper = queryStatement.toUpperCase(); - if (statementUpper.indexOf("ORDER") >= 0) { - this.jboOrder = statement.substring(statementUpper.indexOf("ORDER") + 5).trim(); - if (this.jboOrder.toUpperCase().matches("^BY\\s+[\\w\\W]+?$")) { - this.jboOrder = this.jboOrder.substring(2).trim(); - } - statement = statement.substring(0, statementUpper.indexOf("ORDER") - 1); } else { - this.jboOrder = ""; - } - if (statementUpper.indexOf("GROUP") >= 0) { - this.jboGroup = statement.substring(statementUpper.indexOf("GROUP") + 5).trim(); - if (this.jboGroup.toUpperCase().matches("^BY\\s+[\\w\\W]+?$")) { - this.jboGroup = this.jboGroup.substring(2).trim(); - } - statement = statement.substring(0, statementUpper.indexOf("GROUP") - 1); } else { - this.jboGroup = ""; - } - if (statementUpper.indexOf("WHERE") >= 0) { - this.jboWhere = statement.substring(statementUpper.indexOf("WHERE") + 5).trim(); - statement = statement.substring(0, statementUpper.indexOf("WHERE") - 1); } else { - this.jboWhere = ""; - } - if (statementUpper.indexOf("FROM") >= 0) { - this.jboFrom = statement.substring(statementUpper.indexOf("FROM") + 4).trim(); - statement = statement.substring(0, statementUpper.indexOf("FROM") - 1); } else { - this.jboFrom = "O"; + public ASFilterCustomWhereClauses getFilterCustomWhereClauses() { + return this.filterCustomWhereClauses; } - Parser p = Parser.parseQuery(JBOFactory.getBizObjectClass(jboclazz), queryStatement); - Element[] elementSequence = p.getElementSequence(); - for (int i = 0; i < elementSequence.length; i++) { - Element qe = elementSequence[i]; - if (qe.getType() == 5) { - JBOAttribute attr = (JBOAttribute)qe; - if (attr.getUsedIn() != 0) break; - String attrClazz = attr.getJboClass().getName(); - String classAlias = attr.getClassAlias(); - - BizObjectClass bizObjectClass = JBOFactory.getBizObjectClass(attrClazz); - DataElement element = bizObjectClass.getAttribute(attr.getName()); - addColumnByDataElement(bizObjectClass, classAlias, element); - } - } - } - - private void init(BizObjectManager manager) - throws Exception - { - this.colCount = 0; - this.styleId = ""; - this.jboWhere = ""; - this.jboFrom = "O"; - this.jboGroup = ""; - this.jboOrder = ""; - BizObjectClass bizObjectClass = manager.getManagedClass(); - this.jboClass = bizObjectClass.getAbsoluteName(); - for (int i = 0; i < bizObjectClass.getAttributeNumber(); i++) { - DataElement element = bizObjectClass.getAttributes()[i]; - addColumnByDataElement(bizObjectClass, "O", element); - } - } - - private void addColumnByDataElement(BizObjectClass bizObjectClass, String classAlias, DataElement element) throws Exception { - int iIndex = addColumn(element.getName()); - setColumnAttribute(iIndex, "DONO", this.jboClass); - setColumnAttribute(iIndex, "COLINDEX", new StringBuilder().append(iIndex).append("").toString()); - setColumnAttribute(iIndex, "SORTNO", new StringBuilder().append(iIndex).append("").toString()); - setColumnAttribute(iIndex, "ISINUSE", "1"); - setColumnAttribute(iIndex, "COLTABLENAME", classAlias); - setColumnAttribute(iIndex, "COLACTUALNAME", element.getName()); - setColumnAttribute(iIndex, "COLNAME", element.getName()); - if ((element.getType() == 1) || (element.getType() == 2) || (element.getType() == 4)) - { - setColumnAttribute(iIndex, "COLTYPE", "Number"); - setColumnAttribute(iIndex, "COLCOLUMNTYPE", "3"); - setColumnAttribute(iIndex, "COLLIMIT", "0"); - if ((element.getType() == 1) || (element.getType() == 2)) - { - setColumnAttribute(iIndex, "COLCHECKFORMAT", "5"); - } - else setColumnAttribute(iIndex, "COLCHECKFORMAT", "2"); - - setColumnAttribute(iIndex, "COLALIGN", "3"); - } else { - setColumnAttribute(iIndex, "COLTYPE", "String"); - setColumnAttribute(iIndex, "COLCOLUMNTYPE", "1"); - setColumnAttribute(iIndex, "COLLIMIT", String.valueOf(element.getLength())); - setColumnAttribute(iIndex, "COLCHECKFORMAT", "1"); - setColumnAttribute(iIndex, "COLALIGN", "1"); - } - setColumnAttribute(iIndex, "COLDEFAULTVALUE", ""); - setColumnAttribute(iIndex, "COLHEADER", element.getLabel()); - setColumnAttribute(iIndex, "COLUNIT", ""); - setColumnAttribute(iIndex, "COLHTMLSTYLE", ""); - setColumnAttribute(iIndex, "COLVISIBLE", "1"); - setColumnAttribute(iIndex, "COLSPAN", ""); - setColumnAttribute(iIndex, "ISAUTOCOMPLETE", "0"); - setColumnAttribute(iIndex, "GROUPID", ""); - setColumnAttribute(iIndex, "COLFILTERREFID", ""); - setColumnAttribute(iIndex, "COLFILTERATTRS", ""); - - AttributeUIHints h = bizObjectClass.getAttributeUIHint(element.getName()); - String sColEditstyle = "Text"; String sColEditSourceType = ""; String sColEditSource = ""; String sColAlign = "1"; - String sColReadOnly = "0"; String sColRequired = "0"; String sColSortable = "0"; String sIsFilter = "0"; - if (h != null) { - if (h.isDisplayOnly()) sColReadOnly = "1"; - if (h.isRequired()) sColRequired = "1"; - if (h.isSortingSuitable()) sColSortable = "1"; - if (h.isSortingSuitable()) sIsFilter = "1"; - - if ((h.getValueCharacter() == 1) && (!StringX.isEmpty(h.getCodeTable()))) { - String[] sCodeTableArray = StringX.parseArray(h.getCodeTable()); - String codeTableType = sCodeTableArray[0]; - String codeTableSource = sCodeTableArray[1]; - - String[] sCodeArray = null; - if ("datasource".equals(codeTableType)) - sCodeArray = Support.getCodes(codeTableSource, "JBO"); - else { - sCodeArray = Support.getCodes(codeTableSource, "CodeTable"); - } - ARE.getLog().trace(new StringBuilder().append("[").append(element.getLabel()).append("][codeTableSource]").append(codeTableSource).append(" [CodeArray length]").append(sCodeArray.length).toString()); - if (sCodeArray.length > 6) { - sColEditstyle = "Select"; - sColAlign = "2"; - } else { - sColEditstyle = "Radiobox"; - } - sColEditSourceType = "CodeTable"; - sColEditSource = StringFunction.toArrayString(sCodeArray, ","); - } - } - if (element.getType() == 16) { - sColEditstyle = "Date"; - sColEditSourceType = ""; - sColEditSource = ""; - sColAlign = "2"; - } - setColumnAttribute(iIndex, "COLEDITSTYLE", sColEditstyle); - setColumnAttribute(iIndex, "COLEDITSOURCETYPE", sColEditSourceType); - setColumnAttribute(iIndex, "COLEDITSOURCE", sColEditSource); - setColumnAttribute(iIndex, "COLALIGN", sColAlign); - setColumnAttribute(iIndex, "COLREADONLY", sColReadOnly); - setColumnAttribute(iIndex, "COLREQUIRED", sColRequired); - setColumnAttribute(iIndex, "COLSORTABLE", sColSortable); - setColumnAttribute(iIndex, "ISFILTER", sIsFilter); - } - - private String generateJboSelect(String colName) { - String sFieldName0 = ""; - String sColTableName = getColumnAttribute(colName, "ColTableName"); - String sColActualName = getColumnAttribute(colName, "ColActualName"); - String sColName = getColumnAttribute(colName, "ColName"); - if ((sColTableName == null) || (sColTableName.equals(""))) { - if (sColActualName == null) - sColActualName = ""; - int iDot0 = sColActualName.indexOf("("); - int iDot1 = sColActualName.indexOf("."); - if ((iDot1 > -1) && (iDot0 > -1) && (iDot1 < iDot0)) - { - sFieldName0 = ""; - this.alVirtualFields.add(colName); - } else { - sFieldName0 = new StringBuilder().append(sColActualName).append(" as v.").append(sColName).toString(); - } - } else { - if (this.repacedTableList.containsKey(sColTableName)) - sFieldName0 = new StringBuilder().append(this.repacedTableList.get(sColTableName).toString()).append(".").append(sColActualName).toString(); - else - sFieldName0 = new StringBuilder().append(sColTableName).append(".").append(sColActualName).toString(); - if ((!StringX.isSpace(sColName)) && (!sColName.equalsIgnoreCase(sColActualName))) sFieldName0 = new StringBuilder().append(sFieldName0).append(" as ").append(sColName).toString(); - } - return sFieldName0; - } - - public void init() throws Exception { - this.jboSelect = ""; - if (StringX.isEmpty(this.jboFrom)) - this.jboFrom = ""; - if (StringX.isEmpty(this.jboWhereWhenNoFilter)) - this.jboWhereWhenNoFilter = ""; - if (StringX.isEmpty(this.jboGroup)) - this.jboGroup = ""; - if (StringX.isEmpty(this.jboOrder)) { - this.jboOrder = ""; + public void setFilterCustomWhereClauses(ASFilterCustomWhereClauses filterCustomWhereClauses) { + this.filterCustomWhereClauses = filterCustomWhereClauses; } - if (this.replaceClassName) { - String sJboFromTmp = this.jboFrom; - sJboFromTmp = sJboFromTmp.replaceAll("\\s+(left|right|all|inner)\\s+join", ","); - int iDot = sJboFromTmp.toLowerCase().indexOf(" on "); - if (iDot > -1) - sJboFromTmp = sJboFromTmp.substring(0, iDot); - String[] tmp = sJboFromTmp.split("\\,"); - for (int i = 0; i < tmp.length; i++) { - String[] tmp2 = tmp[i].trim().split(" "); - if (tmp2.length == 1) { - if (!tmp2[0].equalsIgnoreCase("o")) - { - if (tmp2[0].equalsIgnoreCase(this.jboClass)) { - this.repacedTableList.put(tmp2[0], "o"); - this.repacedTableKeyList.add(tmp2[0]); - this.jboFrom = this.jboFrom.replaceAll(tmp2[0], "o"); - } else if (tmp2[0].indexOf(".") > -1) { - String sTmpR = tmp2[0].substring(tmp2[0].lastIndexOf(".") + 1); - this.repacedTableList.put(tmp2[0], sTmpR); - this.repacedTableKeyList.add(tmp2[0]); - this.jboFrom = this.jboFrom.replaceAll(tmp2[0], new StringBuilder().append(tmp2[0]).append(" ").append(sTmpR).toString()); - this.jboWhere = this.jboWhere.replaceAll(tmp2[0], sTmpR); - this.jboGroup = this.jboGroup.replaceAll(tmp2[0], sTmpR); - this.jboOrder = this.jboOrder.replaceAll(tmp2[0], sTmpR); + public Properties getCustomProperties() { + return this.customProperties; + } + + public String getDataQueryClass() { + return this.dataQueryClass; + } + + public void setDataQueryClass(String dataQueryClass) { + this.dataQueryClass = dataQueryClass; + } + + public String getFullFenixId() { + return fullFenixId; + } + + public void setFullFenixId(String fullFenixId) { + this.fullFenixId = fullFenixId; + } + + public Boolean getLazyLoad() { + return lazyLoad; + } + + public void setLazyLoad(Boolean lazyLoad) { + this.lazyLoad = lazyLoad; + } + + public boolean isReplaceClassName() { + return this.replaceClassName; + } + + public boolean isEditable() { + return this.editable; + } + + public void setReplaceClassName(boolean replaceClassName) { + this.replaceClassName = replaceClassName; + } + + public String getScriptFunctions() throws JBOException { + if (this.objCatalogModel == null) + return ""; + List list = this.objCatalogModel.getFunctionList(); + StringBuffer sbResult = new StringBuffer(); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + FunctionModel obj = (FunctionModel) list.get(i); + String sFunctionName = obj.getFunctionName(); + if (sFunctionName == null) + sFunctionName = ""; + String sFunctionParams = obj.getFunctionParams(); + if (sFunctionParams == null) + sFunctionParams = ""; + String sFunctionBody = obj.getFunctionBody(); + if (sFunctionBody == null) + sFunctionBody = ""; + sbResult.append(new StringBuilder().append("function ").append(sFunctionName).append("(").append(sFunctionParams).append("){\n").toString()); + sbResult.append(new StringBuilder().append(sFunctionBody).append("\n").toString()); + sbResult.append("}\n"); } - } } else if (tmp2.length == 2) { - this.repacedTableList.put(tmp2[0], tmp2[1]); - this.repacedTableKeyList.add(tmp2[0]); + return sbResult.toString(); } - } + return ""; } - this.alVirtualFields.clear(); - for (int i = 0; i < this.Columns.size(); i++) { - ASColumn column = getColumn(i); - if (!column.getAttribute("ISINUSE").equals("0")) - { - String sFieldName0 = generateJboSelect(column.getAttribute("COLNAME")); - if (sFieldName0.length() > 0) - this.jboSelect = new StringBuilder().append(this.jboSelect).append(",").append(sFieldName0).toString(); - this.alSelectFields.add(column.getAttribute("COLNAME")); - } - } - if (!this.jboSelect.equals("")) { - this.jboSelect = this.jboSelect.substring(1); - } - this.virtualFields = ((String[])this.alVirtualFields.toArray(new String[0])); - this.jboAttributes = ((String[])this.alSelectFields.toArray(new String[0])); - composeJboSql(); - - IValidateRulesFactory factory = new DefaultValidateRulesFactory(this); - this.validateRules = factory.getValidateRules(); - } - - private void init(String sDONo, String sWhere) throws Exception - { - this.objCatalogModel = AWEDataWindowCache.getInstance().getCatalogModel(sDONo); - if (this.objCatalogModel == null) { - throw new Exception(new StringBuilder().append("显示模板[").append(sDONo).append("]未定义!").toString()); + public boolean isNeedFillDefaultValue() { + return this.needFillDefaultValue; } - if (StringX.isSpace(this.objCatalogModel.getColCount())) - this.colCount = 0; - else - this.colCount = Integer.parseInt(this.objCatalogModel.getColCount()); - this.styleId = this.objCatalogModel.getModeId(); - this.jboClass = this.objCatalogModel.getJboClass().trim(); - this.jboWhere = this.objCatalogModel.getJboWhere(); - this.jboFrom = this.objCatalogModel.getJboFrom(); - this.DONAME = this.objCatalogModel.getDoName().trim(); - if ((this.jboFrom == null) || (this.jboFrom.equals(""))) - this.jboFrom = "o"; - this.jboGroup = this.objCatalogModel.getJboGroup(); - if (StringX.isEmpty(this.jboGroup)) - this.jboGroup = ""; - this.jboOrder = this.objCatalogModel.getJboOrder(); - if (StringX.isEmpty(this.jboOrder)) - this.jboOrder = ""; - this.businessProcess = this.objCatalogModel.getBusinessProcess(); - if ((sWhere == null) || (sWhere.equals(""))) { - if (this.objCatalogModel != null) { - List list = this.objCatalogModel.getLibraryList(); - if (list != null) - for (LibraryModel lm : list) { - int iIndex = addColumn(lm.getColName()); - setColumnAttribute(iIndex, "COLINDEX", lm.getColIndex()); - setColumnAttribute(iIndex, "SORTNO", lm.getSortNo()); - setColumnAttribute(iIndex, "ISINUSE", lm.getIsInuse()); - setColumnAttribute(iIndex, "COLTABLENAME", lm.getColTableName()); - setColumnAttribute(iIndex, "COLACTUALNAME", lm.getColActualName()); - setColumnAttribute(iIndex, "COLNAME", lm.getColName()); - setColumnAttribute(iIndex, "COLTYPE", lm.getColType()); - setColumnAttribute(iIndex, "COLDEFAULTVALUE", lm.getColDefaultValue()); - setColumnAttribute(iIndex, "COLHEADER", lm.getColHeader()); - setColumnAttribute(iIndex, "COLUNIT", lm.getColUnit()); - setColumnAttribute(iIndex, "COLCOLUMNTYPE", lm.getColColumnType()); - setColumnAttribute(iIndex, "COLEDITSTYLE", lm.getColEditsTyle()); - setColumnAttribute(iIndex, "COLCHECKFORMAT", lm.getColCheckFormat()); - setColumnAttribute(iIndex, "COLALIGN", lm.getColAlign()); - setColumnAttribute(iIndex, "COLEDITSOURCETYPE", lm.getColEditSourceType()); - setColumnAttribute(iIndex, "COLEDITSOURCE", lm.getColEditSource()); - setColumnAttribute(iIndex, "COLHTMLSTYLE", lm.getColHtmlStyle()); - setColumnAttribute(iIndex, "COLLIMIT", lm.getColLimit()); - setColumnAttribute(iIndex, "COLVISIBLE", lm.getColVisible()); - setColumnAttribute(iIndex, "COLREADONLY", lm.getColReadonly()); - setColumnAttribute(iIndex, "COLREQUIRED", lm.getColRequired()); - setColumnAttribute(iIndex, "COLSORTABLE", lm.getColSortable()); - setColumnAttribute(iIndex, "ISFILTER", lm.getIsFilter()); - setColumnAttribute(iIndex, "COLSPAN", new StringBuilder().append(lm.getColSpan()).append("").toString()); - setColumnAttribute(iIndex, "ISAUTOCOMPLETE", lm.getIsAutoComplete()); - setColumnAttribute(iIndex, "GROUPID", lm.getGroupId()); - setColumnAttribute(iIndex, "COLFILTERREFID", lm.getColFilterrefId()); - setColumnAttribute(iIndex, "ISAUDIT", lm.getIsAudit()); - setColumnAttribute(iIndex, "COLFILTERATTRS", lm.getColFilterAttrs()); - setColumnAttribute(iIndex, "COLTIPS", lm.getColTips()); - setColumnAttribute(iIndex, "COLINNERBTEVENT", lm.getColInnerBtEvent()); - setColumnAttribute(iIndex, "COLFILTEROPTIONS", lm.getColFilterOptions()); - } - } + public void setNeedFillDefaultValue(boolean needFillDefaultValue) { + this.needFillDefaultValue = needFillDefaultValue; } - else { - BizObjectManager managerDL = JBOFactory.getFactory().getManager("jbo.ui.system.DATAOBJECT_LIBRARY"); - String sQuery = "dono=:dono and isinuse='1'"; - if ((sWhere != null) && (!sWhere.equals(""))) - sQuery = new StringBuilder().append(sQuery).append(" and ").append(sWhere).toString(); - sQuery = new StringBuilder().append(sQuery).append(" order by sortno").toString(); - BizObjectQuery queryDL = managerDL.createQuery(sQuery).setParameter("dono", sDONo); - List list = queryDL.getResultList(false); - if (list != null) { - for (int i = 0; i < list.size(); i++) { - BizObject obj = (BizObject)list.get(i); - int iIndex = addColumn(obj.getAttribute("COLNAME").getString()); - for (int j = 0; j < MDataBuilder.ColumnsEN.length; j++) { - String sJboAttrName = MDataBuilder.ColumnsEN[j]; - if (sJboAttrName.equalsIgnoreCase("COLTIPS")) - sJboAttrName = "TIPS"; - setColumnAttribute(iIndex, MDataBuilder.ColumnsEN[j], obj.getAttribute(sJboAttrName).getString()); - } + + public String getDoName() { + return this.DONAME; + } + + public ASDataObject getSubDataObject() { + return this.subDataObject; + } + + public void setSubDataObject(ASDataObject subDataObject) { + this.subDataObject = subDataObject; + try { + subDataObject.init(); + } catch (Exception e) { + e.printStackTrace(); + ARE.getLog().error(new StringBuilder().append("初始化子表格失败:").append(e.toString()).toString()); } - } } - if (this.objCatalogModel != null) { - ArrayList listEvents = this.objCatalogModel.getColEventList(); - if (listEvents != null) { - for (int ii = 0; ii < listEvents.size(); ii++) { - ColEventModel boe = (ColEventModel)listEvents.get(ii); - ASHtmlEvent event = new ASHtmlEvent(); - event.setColName(boe.getColName()); - event.setEventType(boe.getEvent()); - event.setEventFunction(boe.getScript()); - if (boe.getEventParams() != null) { - event.setEventParams(boe.getEventParams()); - } - this.mapHtmlEvents.add(event); + + public void setJboWhereWhenNoFilter(String jboWhereWhenNoFilter) { + this.jboWhereWhenNoFilter = jboWhereWhenNoFilter; + } + + public void setJboGroup(String jboGroup) { + this.jboGroup = jboGroup; + Collections.sort(this.repacedTableKeyList, new SortByKey()); + for (int i = 0; i < this.repacedTableKeyList.size(); i++) { + String sKey = this.repacedTableKeyList.get(i).toString(); + this.jboOrder = this.jboOrder.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); } - } } - this.dwcontext = new DWContext(AWEDataWindowCache.getInstance().getDWContextString("OW", getDONO()), "OW", getDONO()); - } - - public void composeJboSql() - { - this.jboSelect = this.jboSelect.replaceAll(getJboClass(), "o"); - this.jboSql = new StringBuilder().append("select ").append(this.jboSelect.trim()).append(" from ").append(this.jboFrom.trim()).toString(); - if ((this.jboWhere == null) || (this.jboWhere.trim().equals(""))) { - this.jboWhere = " 1=1 "; - } - String sFilterWhereClause = getFilterWhereClause(); - String[] tmp = getJboFrom().split("\\,"); - for (int i = 0; i < tmp.length; i++) { - String[] tmp2 = tmp[i].split(" "); - if (tmp2.length == 1) { - if (!tmp2[0].equalsIgnoreCase("O")) - { - if (tmp2[0].equalsIgnoreCase(getJboClass())) { - sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], "O"); - } else if (tmp2[0].indexOf(".") > -1) { - String sTmpR = tmp2[0].substring(tmp2[0].lastIndexOf(".") + 1); - sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], sTmpR); - } - } } else if (tmp2.length == 2) { - sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], tmp2[1]); - } - } - if ((sFilterWhereClause != null) && (!sFilterWhereClause.equals(""))) { - sFilterWhereClause = sFilterWhereClause.replaceAll(getJboClass(), "O"); - this.jboWhere = new StringBuilder().append(this.jboWhere.trim()).append(" and ").append("(").append(sFilterWhereClause.trim()).append(")").toString(); + public ArrayList getHtmlEvents() { + return this.mapHtmlEvents; } - if ((StringX.isSpace(sFilterWhereClause)) && (this.jboWhereWhenNoFilter.trim().length() > 0)) { - if (this.jboWhereWhenNoFilter.toLowerCase().trim().startsWith("and")) - this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).append(" ").append(this.jboWhereWhenNoFilter.trim()).toString(); - else - this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).append(" and ").append(this.jboWhereWhenNoFilter.trim()).toString(); + public void removeHtmlEvents(String colName) { + ArrayList list = getHtmlEvents(colName); + this.mapHtmlEvents.removeAll(list); } - else this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).toString(); - if ((this.jboGroup != null) && (!this.jboGroup.equals(""))) { - this.jboSql = new StringBuilder().append(this.jboSql).append(" group by ").append(this.jboGroup.trim()).toString(); - } - if ((this.jboOrder != null) && (!this.jboOrder.equals(""))) - this.jboSql = new StringBuilder().append(this.jboSql).append(" order by ").append(this.jboOrder.trim()).toString(); - } - - public int addColumn(String sColumnName) - { - int iIndex = getColumnIndex(sColumnName); - if (iIndex == -1) { - this.Columns.addElement(new ASColumn(sColumnName)); - return this.Columns.size() - 1; - } - return iIndex; - } - - public int addColumn(int iPos, String sColumnName) - { - int iIndex = getColumnIndex(sColumnName); - if (iIndex == -1) { - this.Columns.add(iPos, new ASColumn(sColumnName)); - return iPos; - } - return iIndex; - } - - public int getColumnIndex(String sColumnName) - { - int iSize = this.Columns.size(); - - for (int i = 0; i < iSize; i++) - if (((ASColumn)this.Columns.get(i)).getAttribute("COLNAME").equalsIgnoreCase(sColumnName)) - return i; - return -1; - } - - public ASColumn getColumn(String sColumnName) - { - int iIndex = getColumnIndex(sColumnName); - if (iIndex >= 0) { - return (ASColumn)this.Columns.get(iIndex); - } - return null; - } - - public ASColumn getColumn(int iIndex) - { - if (iIndex >= 0) { - return (ASColumn)this.Columns.get(iIndex); - } - return null; - } - - public boolean setColumnFilter(String sColumnList, boolean isFilter) - { - if (isFilter) { - return setColumnAttribute(sColumnList, "ISFILTER", "1"); - } - return setColumnAttribute(sColumnList, "ISFILTER", "0"); - } - - public boolean setColumnAttribute(String sColumnList, String sAttributeName, String sAttributeValue) - { - int i = 0; - int iSize = 0; - int iIndex = 0; - if(sColumnList.equals("") || sColumnList.equals("*")) - { - iSize = Columns.size(); - for(i = 0; i < iSize; i++) - setColumnAttribute(i, sAttributeName, sAttributeValue); - - } else - { - iSize = StringFunction.getSeparateSum(sColumnList, ","); - for(i = 1; i <= iSize; i++) - { - String sColumnName = StringFunction.getSeparate(sColumnList, ",", i); - iIndex = getColumnIndex(sColumnName); - if(iIndex >= 0) - setColumnAttribute(iIndex, sAttributeName, sAttributeValue); - } - - } - return true; - } - - public boolean appendColumnAttribute(String sColumnList, String sAttributeName, String sAttributeValue) - { - if(sColumnList.equals("") || sColumnList.equals("*")) - { - int iSize = Columns.size(); - for(int i = 0; i < iSize; i++) - appendColumnAttribute(i, sAttributeName, sAttributeValue); - - } else - { - int iSize = StringFunction.getSeparateSum(sColumnList, ","); - for(int i = 1; i <= iSize; i++) - { - String sColumnName = StringFunction.getSeparate(sColumnList, ",", i); - int iIndex = getColumnIndex(sColumnName); - if(iIndex >= 0) - appendColumnAttribute(iIndex, sAttributeName, sAttributeValue); - } - - } - return true; - } - - public boolean setColumnAttribute(int iIndex, String sAttributeName, String sAttributeValue) - { - if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { - ASColumn ascTemp = (ASColumn)this.Columns.get(iIndex); - ascTemp.setAttribute(sAttributeName, sAttributeValue); - return true; - } - return false; - } - - public boolean appendColumnAttribute(int iIndex, String sAttributeName, String sAttributeValue) - { - if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { - ASColumn ascTemp = (ASColumn)this.Columns.get(iIndex); - ascTemp.setAttribute(sAttributeName, new StringBuilder().append(ascTemp.getAttribute(sAttributeName)).append(sAttributeValue).toString()); - return true; - } - return false; - } - - public String getColumnAttribute(String sColumnName, String sAttributeName) - { - int iSize = this.Columns.size(); - for (int i = 0; i < iSize; i++) { - int iIndex = getColumnIndex(sColumnName); - if (iIndex >= 0) - return getColumnAttribute(iIndex, sAttributeName); - } - return null; - } - - public String getColumnAttribute(int iIndex, String sAttributeName) - { - if ((iIndex >= 0) && (iIndex < this.Columns.size())) { - String sValue = ((ASColumn)this.Columns.get(iIndex)).getAttribute(sAttributeName); - if (sValue == null) - sValue = ""; - return sValue; - } - return null; - } - - public String getName(int iIndex) - { - if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { - return ((ASColumn)this.Columns.get(iIndex)).getAttribute("Name"); - } - return null; - } - - public void setType(int iIndex, String sType) - { - setType(getName(iIndex), sType); - } - - public void setType(String sColumnList, String sType) - { - setColumnAttribute(sColumnList, "COLTYPE", sType); - } - - public void setColTips(String sColumnList, String tips) { - setColumnAttribute(sColumnList, "COLTIPS", tips); - } - - public void setColInnerBtEvent(String sColumnList, String sInnerBtEvent) { - setColumnAttribute(sColumnList, "COLINNERBTEVENT", sInnerBtEvent); - } - - public void setColFilterOptions(String sColumnList, String sColFilterOptions) { - setColumnAttribute(sColumnList, "COLFILTEROPTIONS", sColFilterOptions); - } - - public void setColumnType(String sColumnList, String sColumnType) - { - setColumnAttribute(sColumnList, "COLCOLUMNTYPE", sColumnType); - } - - public void setVisible(String sColumnList, boolean bValue) - { - setColumnAttribute(sColumnList, "COLVISIBLE", bValue ? "1" : "0"); - } - - public void setReadOnly(String sColumnList, boolean bValue) - { - setColumnAttribute(sColumnList, "COLREADONLY", bValue ? "1" : "0"); - } - - public void setRequired(String sColumnList, boolean bValue) - { - setColumnAttribute(sColumnList, "COLREQUIRED", bValue ? "1" : "0"); - } - - public void setCheckFormat(String sColumnList, String sFormat) - { - setColumnAttribute(sColumnList, "COLCHECKFORMAT", sFormat); - } - - public void setDefaultValue(String sColumnList, String sValue) - { - setColumnAttribute(sColumnList, "COLDEFAULTVALUE", sValue); - } - - public void setAlign(String sColumnList, String sFormat) - { - setColumnAttribute(sColumnList, "COLALIGN", sFormat); - } - - public void setLimit(String sColumnList, int iLimit) - { - setColumnAttribute(sColumnList, "COLLIMIT", String.valueOf(iLimit)); - } - - public void setEditStyle(String sColumnList, String sStyle) - { - setColumnAttribute(sColumnList, "COLEDITSTYLE", sStyle); - } - - public void setHTMLStyle(String sColumnList, String sStyle) - { - setColumnAttribute(sColumnList, "COLHTMLSTYLE", sStyle); - } - - public void appendHTMLStyle(String sColumnList, String sStyle) - { - appendColumnAttribute(sColumnList, "COLHTMLSTYLE", sStyle); - } - - public void setDDDWCode(String sColumnList, String sCodeName) - { - setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "Code"); - setColumnAttribute(sColumnList, "COLEDITSOURCE", sCodeName); - } - - public void setDDDWJbo(String sColumnList, String sJbo) - { - setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "Jbo"); - setColumnAttribute(sColumnList, "COLEDITSOURCE", sJbo); - } - - public void setDDDWCodeTable(String sColumnList, String sCodeTable) - { - setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "CodeTable"); - setColumnAttribute(sColumnList, "COLEDITSOURCE", sCodeTable); - } - - public void setDDDWCodeTable(String sColumnList, String[] sCodeArray) - { - setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "CodeTable"); - setColumnAttribute(sColumnList, "COLEDITSOURCE", StringFunction.toArrayString(sCodeArray, ",")); - } - - public void setHeader(String sColumnList, String sValue) - { - setColumnAttribute(sColumnList, "COLHEADER", sValue); - } - - public void setHeader(String sValueList) - { - int iCount = StringFunction.getSeparateSum(sValueList, ","); - for (int i = 1; i <= iCount; i++) - setColumnAttribute(i - 1, "COLHEADER", StringFunction.getSeparate(sValueList, ",", i)); - } - - public void setHeader(String[][] sValueArray) - { - int iCount = sValueArray.length; - for (int i = 0; i < iCount; i++) { - int iIndex = getColumnIndex(sValueArray[i][0]); - if (iIndex >= 0) - setColumnAttribute(iIndex, "COLHEADER", sValueArray[i][1]); - } - } - - public void setUnit(String sColumnList, String sValue) - { - setColumnAttribute(sColumnList, "COLUNIT", sValue); - } - - public void setGroup(String sColumnList, String sValue) - { - setColumnAttribute(sColumnList, "GROUPID", sValue); - } - - public void appendFilter(ASDataObjectFilter dfFilter) - throws Exception - { - this.Filters.addElement(dfFilter); - setColumnAttribute(dfFilter.sFilterColumnID, "ISFILTER", "1"); - } - - public void generateFilters() - throws Exception - { - int iFilterID = 0; - for (int i = 0; i < this.Columns.size(); i++) { - ASColumn acTempColumn = (ASColumn)this.Columns.get(i); - if ("1".equals(acTempColumn.getAttribute("ISFILTER"))) { - iFilterID++; - setFilter(new StringBuilder().append("DF").append(iFilterID).toString(), acTempColumn.getAttribute("COLNAME"), null); - } - } - } - - public void setFilter(String sFilterID, String sColumnID, String sOptions) throws Exception - { - ASColumn acTempColumn = getColumn(sColumnID); - if (acTempColumn == null) { - throw new Exception(new StringBuilder().append("获得ASColumn失败。ColumnID:").append(sColumnID).toString()); - } - ASColumn refColumn = null; - if ((acTempColumn.getAttribute("COLFILTERREFID") != null) && (acTempColumn.getAttribute("COLFILTERREFID").length() > 0)) - { - refColumn = getColumn(acTempColumn.getAttribute("COLFILTERREFID")); - }ASDataObjectFilter dfFilter = new ASDataObjectFilter(sFilterID, acTempColumn, refColumn, sOptions); - appendFilter(dfFilter); - } - - public ASDataObjectFilter getFilter(String sFilterID) throws Exception - { - for (int i = 0; i < this.Filters.size(); i++) { - ASDataObjectFilter tmpFilter = (ASDataObjectFilter)this.Filters.get(i); - if (tmpFilter.sFilterID.equals(sFilterID)) - return tmpFilter; - } - return null; - } - - public ASDataObjectFilter getFilter(int i) throws Exception - { - return (ASDataObjectFilter)this.Filters.get(i); - } - - private String getFilterHtml() - throws Exception - { - String sReturn = ""; - - for (int i = 0; i < this.Filters.size(); i++) { - ASDataObjectFilter dofTemp = (ASDataObjectFilter)this.Filters.get(i); - sReturn = new StringBuilder().append(sReturn).append(dofTemp.getFilterHtml()).toString(); - } - return sReturn; - } - - public String getFilterHtml(Page page) - throws Exception - { - parseFilterData(page); - return getFilterHtml(); - } - - private void parseFilterData(Page page) - throws Exception - { - for (int i = 0; i < this.Filters.size(); i++) { - ASDataObjectFilter dofTemp = (ASDataObjectFilter)this.Filters.get(i); - - String sTempFilterOperator = page.getParameter(new StringBuilder().append("DOFILTER_").append(dofTemp.sFilterID).append("_OP").toString()); - if ((sTempFilterOperator != null) && (!sTempFilterOperator.equals(""))) - dofTemp.sOperator = sTempFilterOperator; - for (int j = 0; j < dofTemp.sFilterInputs.length; j++) - { - String sTempFilterValue = page.getParameter(dofTemp.sFilterInputs[j][0]); - if ((sTempFilterValue != null) && (!sTempFilterValue.equals(""))) { - dofTemp.sFilterInputs[j][1] = DataConvert.toString(sTempFilterValue); + public void removeHtmlEvents(String colName, String eventType) { + ArrayList result = new ArrayList(); + for (int i = 0; i < this.mapHtmlEvents.size(); i++) { + ASHtmlEvent event = (ASHtmlEvent) this.mapHtmlEvents.get(i); + if ((event.getColName().equalsIgnoreCase(colName)) && (eventType.equalsIgnoreCase(event.getEventType()))) + result.add(event); } - if ((dofTemp.sFilterInputs[j][1] != null) && (!dofTemp.sFilterInputs[j][1].equals(""))) - this.receivedFilterData = true; - } + this.mapHtmlEvents.removeAll(result); } - } - private String getFilterWhereClause() - { - String sReturn = ""; - String sCurWhereClause = ""; - - int j = 0; - try { - for (int i = 0; i < this.Filters.size(); i++) { - ASDataObjectFilter dofTemp = (ASDataObjectFilter)this.Filters.get(i); - sCurWhereClause = dofTemp.getFilterWhereClause(); - if ((sCurWhereClause != null) && (!sCurWhereClause.equals(""))) - { - j++; - sReturn = new StringBuilder().append(sReturn).append(j == 1 ? "" : " and ").append("(").append(dofTemp.getFilterWhereClause()).append(")").toString(); + public ArrayList getHtmlEvents(String colName) { + ArrayList result = new ArrayList(); + for (int i = 0; i < this.mapHtmlEvents.size(); i++) { + ASHtmlEvent event = (ASHtmlEvent) this.mapHtmlEvents.get(i); + if (event.getColName().equalsIgnoreCase(colName)) + result.add(event); } - } - } catch (Exception e) { e = - e; - - e.printStackTrace(); - } finally { + return result; } - return sReturn; - } - public boolean haveReceivedFilterCriteria() - { - return this.receivedFilterData; - } - - public String[] getExtendAttributes() - { - if (this.Columns == null) return null; - ArrayList result = new ArrayList(); - for (int i = 0; i < this.Columns.size(); i++) { - ASColumn column = (ASColumn)this.Columns.get(i); - //if (("1".equals(column.getAttribute("COLVISIBLE"))) && ((column.getAttribute("COLTABLENAME") == null) || ("".equals(column.getAttribute("COLTABLENAME"))))) { - if (((column.getAttribute("COLTABLENAME") == null) || ("".equals(column.getAttribute("COLTABLENAME"))))) { - result.add(column.getAttribute("COLNAME")); - } + public ASColulmnDistplayRule addColumnDisplayRule(String checkField, String validExpress, String applyFields, String applyCss) { + ASColulmnDistplayRule rule = ASColulmnDistplayRule.createDisplayRegular(); + rule.setCheckField(checkField); + rule.setValidExpress(validExpress); + rule.setApplyFields(applyFields); + rule.setApplyCss(applyCss); + this.columnDisplayRules.add(rule); + return rule; } - return (String[])result.toArray(new String[result.size()]); - } - public String toJson() - throws Exception - { - if (this.Columns == null) return "[]"; - JSONObject list = JSONObject.createArray(); - for (Iterator i$ = this.Columns.iterator(); i$.hasNext(); ) { Object obj = i$.next(); - ASColumn asColumn = (ASColumn)obj; - if ("1".equals(asColumn.getAttribute("ISINUSE"))) { - JSONObject jsonColumn = JSONObject.createObject(); - jsonColumn.add(JSONElement.valueOf("DONO", asColumn.getAttribute("DONO"))); - jsonColumn.add(JSONElement.valueOf("COLINDEX", asColumn.getAttribute("COLINDEX"))); - jsonColumn.add(JSONElement.valueOf("SORTNO", asColumn.getAttribute("SORTNO"))); - jsonColumn.add(JSONElement.valueOf("COLNAME", asColumn.getAttribute("COLNAME"))); - jsonColumn.add(JSONElement.valueOf("COLTYPE", asColumn.getAttribute("COLTYPE"))); - jsonColumn.add(JSONElement.valueOf("COLDEFAULTVALUE", asColumn.getAttribute("COLDEFAULTVALUE"))); - jsonColumn.add(JSONElement.valueOf("COLHEADER", asColumn.getAttribute("COLHEADER"))); - jsonColumn.add(JSONElement.valueOf("COLUNIT", asColumn.getAttribute("COLUNIT"))); - jsonColumn.add(JSONElement.valueOf("COLCOLUMNTYPE", asColumn.getAttribute("COLCOLUMNTYPE"))); - jsonColumn.add(JSONElement.valueOf("COLEDITSTYLE", asColumn.getAttribute("COLEDITSTYLE"))); - jsonColumn.add(JSONElement.valueOf("COLCHECKFORMAT", asColumn.getAttribute("COLCHECKFORMAT"))); - jsonColumn.add(JSONElement.valueOf("COLALIGN", asColumn.getAttribute("COLALIGN"))); - if ((asColumn.getAttribute("COLEDITSOURCETYPE") != null) && (asColumn.getAttribute("COLEDITSOURCE") != null)) { - jsonColumn.add(JSONElement.valueOf("COLEDITSOURCETYPE", asColumn.getAttribute("COLEDITSOURCETYPE"))); - String[] codes = Support.getCodes(asColumn.getAttribute("COLEDITSOURCE"), asColumn.getAttribute("COLEDITSOURCETYPE")); - JSONObject jsonCodes = JSONObject.createArray(); - for (int i = 0; i < codes.length; i++) { - jsonCodes.add(JSONElement.valueOf(codes[i])); - } - jsonColumn.add(JSONElement.valueOf("COLEDITSOURCE", jsonCodes)); + public Vector getColumnDisplayRules() { + return this.columnDisplayRules; + } + + public String[][] getColumnDisplayArray() { + int iSize = this.columnDisplayRules.size(); + if (iSize == 0) + return new String[0][4]; + String[][] result = new String[iSize][4]; + for (int i = 0; i < iSize; i++) { + ASColulmnDistplayRule rule = (ASColulmnDistplayRule) this.columnDisplayRules.get(i); + result[i][0] = rule.getCheckField(); + result[i][1] = rule.getValidExpress(); + result[i][2] = rule.getApplyFields(); + result[i][3] = rule.getApplyCss(); + } + return result; + } + + public String[] getHtmlEvent(String colName, String eventType) { + ArrayList result = new ArrayList(); + for (int i = 0; i < this.mapHtmlEvents.size(); i++) { + ASHtmlEvent event = (ASHtmlEvent) this.mapHtmlEvents.get(i); + if ((event.getColName().equalsIgnoreCase(colName)) && (event.getEventType().equalsIgnoreCase(eventType))) + result.add(new String[]{event.getEventFunction(), event.getEventParams()}); + } + return (String[]) result.toArray(new String[result.size()]); + } + + public void setHtmlEvent(String colNames, String event, String functionName) { + setHtmlEvent(colNames, event, functionName, null); + } + + public void setHtmlEvent(String colNames, String event, String functionName, String functionParams) { + if ((colNames.trim().equals("")) || (colNames.trim().equals("*"))) { + for (int i = 0; i < this.Columns.size(); i++) { + ASColumn column = (ASColumn) this.Columns.get(i); + if ("1".equals(column.getAttribute("COLVISIBLE"))) { + if (i == 0) + colNames = column.getAttribute("colname"); + else + colNames = new StringBuilder().append(colNames).append(",").append(column.getAttribute("colname")).toString(); + } + } + } + String[] sColNameArray = colNames.split("\\,"); + if (sColNameArray == null) + return; + for (int i = 0; i < sColNameArray.length; i++) { + ASHtmlEvent asevent = new ASHtmlEvent(); + asevent.setColName(sColNameArray[i]); + asevent.setEventType(event); + asevent.setEventFunction(functionName); + asevent.setEventParams(functionParams); + this.mapHtmlEvents.add(asevent); + } + } + + public Page getCurPage() { + return this.curPage; + } + + public void setCurPage(Page curPage) { + setLanguage(curPage.getUser().getLanguage()); + this.curPage = curPage; + } + + public void setColCount(int colCount) { + this.colCount = colCount; + } + + public void setBusinessProcess(String businessProcess) { + this.businessProcess = businessProcess; + } + + public String getBusinessProcess() { + return this.businessProcess; + } + + public int getPageSize() { + return this.pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getJboGroup() { + return this.jboGroup; + } + + public String getJboOrder() { + return this.jboOrder; + } + + public int getColCount() { + return this.colCount; + } + + public String getStyleId() { + return this.styleId; + } + + public String[] getJboAttributes() { + return this.jboAttributes; + } + + public String[] getVirtualFields() { + return this.virtualFields; + } + + public void clearVirtualFields() { + this.virtualFields = null; + this.alVirtualFields.clear(); + } + + public String getJboFrom() { + return this.jboFrom; + } + + public void setJboFrom(String jboFrom) { + this.jboFrom = jboFrom.trim(); + } + + public void setJboOrder(String jboOrder) { + if ((jboOrder == null) || (jboOrder.equals(""))) { + return; + } + if (jboOrder.indexOf(".") == -1) { + String[] arr = jboOrder.trim().split("\\s"); + String sColName = arr[0]; + if ((getColumnAttribute(sColName, "COLFILTERREFID") != null) && (getColumnAttribute(sColName, "COLFILTERREFID").trim().length() > 0)) { + sColName = getColumnAttribute(sColName, "COLFILTERREFID"); + } + String sTableName = getColumnAttribute(sColName, "COLTABLENAME"); + sTableName = sTableName.replaceAll(this.jboClass, "o"); + Iterator it = this.repacedTableList.keySet().iterator(); + while (it.hasNext()) { + String sKey = it.next().toString(); + sTableName = sTableName.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); + } + jboOrder = new StringBuilder().append(sTableName).append(".").append(getColumnAttribute(sColName, "COLACTUALNAME")).append(" ").append(arr[1]).toString(); } - jsonColumn.add(JSONElement.valueOf("COLHTMLSTYLE", asColumn.getAttribute("COLHTMLSTYLE"))); - jsonColumn.add(JSONElement.valueOf("COLLIMIT", asColumn.getAttribute("COLLIMIT"))); - jsonColumn.add(JSONElement.valueOf("COLVISIBLE", asColumn.getAttribute("COLVISIBLE"))); - jsonColumn.add(JSONElement.valueOf("COLREADONLY", asColumn.getAttribute("COLREADONLY"))); - jsonColumn.add(JSONElement.valueOf("COLREQUIRED", asColumn.getAttribute("COLREQUIRED"))); - jsonColumn.add(JSONElement.valueOf("COLSORTABLE", asColumn.getAttribute("COLSORTABLE"))); - jsonColumn.add(JSONElement.valueOf("ISFILTER", asColumn.getAttribute("ISFILTER"))); - jsonColumn.add(JSONElement.valueOf("COLSPAN", asColumn.getAttribute("COLSPAN"))); - jsonColumn.add(JSONElement.valueOf("GROUPID", asColumn.getAttribute("GROUPID"))); - jsonColumn.add(JSONElement.valueOf("COLFILTERREFID", asColumn.getAttribute("COLFILTERREFID"))); - jsonColumn.add(JSONElement.valueOf("COLFILTERATTRS", asColumn.getAttribute("COLFILTERATTRS"))); - jsonColumn.add(JSONElement.valueOf("ISAUDIT", asColumn.getAttribute("ISAUDIT"))); - jsonColumn.add(JSONElement.valueOf("COLTIPS", asColumn.getAttribute("COLTIPS"))); - jsonColumn.add(JSONElement.valueOf("COLINNERBTEVENT", asColumn.getAttribute("COLINNERBTEVENT"))); - jsonColumn.add(JSONElement.valueOf("COLFILTEROPTIONS", asColumn.getAttribute("COLFILTEROPTIONS"))); - list.add(JSONElement.valueOf(jsonColumn)); - } } - return JSONEncoder.encode(list); - } + this.jboOrder = jboOrder; + Collections.sort(this.repacedTableKeyList, new SortByKey()); + for (int i = 0; i < this.repacedTableKeyList.size(); i++) { + String sKey = this.repacedTableKeyList.get(i).toString(); + this.jboOrder = this.jboOrder.replaceAll(sKey, this.repacedTableList.get(sKey).toString()); + } + } + + public String getJboSql() { + return this.jboSql; + } + + public String getParamstr() { + return this.paramstr; + } + + public void setParamstr(String paramstr) { + this.paramstr = paramstr; + } + + public int getLockCount() { + return this.lockCount; + } + + public void setLockCount(int iLockCount) { + this.lockCount = iLockCount; + } + + public Vector getValidateRules() { + return this.validateRules; + } + + public void appendValidateRule(ValidateRule validrule) { + this.validateRules.add(validrule); + } + + public void removeValidateRule(String colName, String validateName) { + ValidateRule.removeRule(this.validateRules, colName, validateName); + } + + public void removeValidateRule(String colName) { + ValidateRule.removeRule(this.validateRules, colName, null); + } + + public String getJboClass() { + return this.jboClass; + } + + public void setJboClass(String jBOClass) { + this.jboClass = jBOClass.trim(); + } + + public String getJboWhere() { + return this.jboWhere; + } + + public void setJboWhere(String jBOWhere) { + this.jboWhere = jBOWhere; + } + + public void appendJboWhere(String jboWhere) { + if (StringX.isSpace(jboWhere)) return; + jboWhere = jboWhere.trim(); + if (StringX.isSpace(this.jboWhere)) { + if (jboWhere.toLowerCase().startsWith("and ")) jboWhere = new StringBuilder().append("1 = 1 ").append(jboWhere).toString(); + } else { + if (!jboWhere.toLowerCase().startsWith("and ")) jboWhere = new StringBuilder().append("and ").append(jboWhere).toString(); + jboWhere = new StringBuilder().append(this.jboWhere).append(" ").append(jboWhere).toString(); + } + setJboWhere(jboWhere); + } + + public String getDONO() { + return this.DONO; + } + + public void setDONO(String dONO) { + this.DONO = dONO; + } + + public ASDataObject() throws Exception { + } + + public ASDataObject(String[] headers) throws Exception { + this.DONO = ""; + init(headers); + } + + public ASDataObject(BizObjectManager manager) throws Exception { + this.DONO = manager.getManagedClass().getAbsoluteName(); + init(manager); + } + + public ASDataObject(String sDONo) throws Exception { + if (sDONo.trim().toUpperCase().startsWith("SELECT ")) { + throw new Exception("不再支持Sql Select语句构造DataObject!"); + } + this.DONO = sDONo; + init(sDONo, ""); + } + + public ASDataObject(String sDONo, String sWhere) throws Exception { + this.DONO = sDONo; + init(sDONo, sWhere); + } + + public ASDataObject(String sDONo, String sWhere, String sDatabase) throws Exception { + this.DONO = sDONo; + init(sDONo, sWhere); + } + + public ASColumn createVirtualColumn(String colName, String colHeader, String colActualName) + throws Exception { + ASColumn column = new ASColumn(colName); + String sColIndx = new StringBuilder().append("Z").append(this.appendVirtualColumnSortIndex++).toString(); + column.setAttribute("DONO", this.DONO); + column.setAttribute("COLINDEX", sColIndx); + column.setAttribute("SORTNO", sColIndx); + column.setAttribute("ISINUSE", "1"); + column.setAttribute("COLACTUALNAME", colActualName); + column.setAttribute("COLNAME", colName); + column.setAttribute("COLTYPE", "String"); + column.setAttribute("COLCOLUMNTYPE", "1"); + column.setAttribute("COLCHECKFORMAT", "1"); + column.setAttribute("COLALIGN", "1"); + column.setAttribute("COLDEFAULTVALUE", ""); + column.setAttribute("COLHEADER", colHeader); + column.setAttribute("COLUNIT", ""); + column.setAttribute("COLEDITSTYLE", "Text"); + column.setAttribute("COLEDITSOURCETYPE", ""); + column.setAttribute("COLEDITSOURCE", ""); + column.setAttribute("COLHTMLSTYLE", ""); + column.setAttribute("COLLIMIT", "0"); + column.setAttribute("COLVISIBLE", "1"); + column.setAttribute("COLREADONLY", "1"); + column.setAttribute("COLREQUIRED", "0"); + column.setAttribute("COLSORTABLE", "1"); + column.setAttribute("ISFILTER", "0"); + column.setAttribute("COLSPAN", ""); + column.setAttribute("ISAUTOCOMPLETE", "0"); + column.setAttribute("GROUPID", ""); + column.setAttribute("COLFILTERREFID", ""); + column.setAttribute("COLFILTERATTRS", ""); + return column; + } + + private void init(String[] headers) + throws Exception { + this.colCount = 0; + this.styleId = ""; + this.jboClass = ""; + this.jboWhere = ""; + this.jboFrom = ""; + this.jboGroup = ""; + this.jboOrder = ""; + for (int i = 0; i < headers.length; i++) { + ASColumn column = createVirtualColumn(new StringBuilder().append("VCOLUMN_").append(i).toString(), headers[i], ""); + column.setAttribute("COLSORTABLE", "0"); + this.Columns.add(column); + } + } + + public void initQuery(String jboclazz, String queryStatement) + throws Exception { + queryStatement = StringX.isSpace(queryStatement) ? "SELECT \"*\" FROM O" : StringX.trimAll(queryStatement); + this.DONO = jboclazz; + this.jboClass = jboclazz; + this.colCount = 0; + this.styleId = ""; + + String statement = queryStatement; + String statementUpper = queryStatement.toUpperCase(); + if (statementUpper.indexOf("ORDER") >= 0) { + this.jboOrder = statement.substring(statementUpper.indexOf("ORDER") + 5).trim(); + if (this.jboOrder.toUpperCase().matches("^BY\\s+[\\w\\W]+?$")) { + this.jboOrder = this.jboOrder.substring(2).trim(); + } + statement = statement.substring(0, statementUpper.indexOf("ORDER") - 1); + } else { + this.jboOrder = ""; + } + if (statementUpper.indexOf("GROUP") >= 0) { + this.jboGroup = statement.substring(statementUpper.indexOf("GROUP") + 5).trim(); + if (this.jboGroup.toUpperCase().matches("^BY\\s+[\\w\\W]+?$")) { + this.jboGroup = this.jboGroup.substring(2).trim(); + } + statement = statement.substring(0, statementUpper.indexOf("GROUP") - 1); + } else { + this.jboGroup = ""; + } + if (statementUpper.indexOf("WHERE") >= 0) { + this.jboWhere = statement.substring(statementUpper.indexOf("WHERE") + 5).trim(); + statement = statement.substring(0, statementUpper.indexOf("WHERE") - 1); + } else { + this.jboWhere = ""; + } + if (statementUpper.indexOf("FROM") >= 0) { + this.jboFrom = statement.substring(statementUpper.indexOf("FROM") + 4).trim(); + statement = statement.substring(0, statementUpper.indexOf("FROM") - 1); + } else { + this.jboFrom = "O"; + } + + Parser p = Parser.parseQuery(JBOFactory.getBizObjectClass(jboclazz), queryStatement); + Element[] elementSequence = p.getElementSequence(); + for (int i = 0; i < elementSequence.length; i++) { + Element qe = elementSequence[i]; + if (qe.getType() == 5) { + JBOAttribute attr = (JBOAttribute) qe; + if (attr.getUsedIn() != 0) break; + String attrClazz = attr.getJboClass().getName(); + String classAlias = attr.getClassAlias(); + + BizObjectClass bizObjectClass = JBOFactory.getBizObjectClass(attrClazz); + DataElement element = bizObjectClass.getAttribute(attr.getName()); + addColumnByDataElement(bizObjectClass, classAlias, element); + } + } + } + + private void init(BizObjectManager manager) + throws Exception { + this.colCount = 0; + this.styleId = ""; + this.jboWhere = ""; + this.jboFrom = "O"; + this.jboGroup = ""; + this.jboOrder = ""; + BizObjectClass bizObjectClass = manager.getManagedClass(); + this.jboClass = bizObjectClass.getAbsoluteName(); + for (int i = 0; i < bizObjectClass.getAttributeNumber(); i++) { + DataElement element = bizObjectClass.getAttributes()[i]; + addColumnByDataElement(bizObjectClass, "O", element); + } + } + + private void addColumnByDataElement(BizObjectClass bizObjectClass, String classAlias, DataElement element) throws Exception { + int iIndex = addColumn(element.getName()); + setColumnAttribute(iIndex, "DONO", this.jboClass); + setColumnAttribute(iIndex, "COLINDEX", new StringBuilder().append(iIndex).append("").toString()); + setColumnAttribute(iIndex, "SORTNO", new StringBuilder().append(iIndex).append("").toString()); + setColumnAttribute(iIndex, "ISINUSE", "1"); + setColumnAttribute(iIndex, "COLTABLENAME", classAlias); + setColumnAttribute(iIndex, "COLACTUALNAME", element.getName()); + setColumnAttribute(iIndex, "COLNAME", element.getName()); + if ((element.getType() == 1) || (element.getType() == 2) || (element.getType() == 4)) { + setColumnAttribute(iIndex, "COLTYPE", "Number"); + setColumnAttribute(iIndex, "COLCOLUMNTYPE", "3"); + setColumnAttribute(iIndex, "COLLIMIT", "0"); + if ((element.getType() == 1) || (element.getType() == 2)) { + setColumnAttribute(iIndex, "COLCHECKFORMAT", "5"); + } else setColumnAttribute(iIndex, "COLCHECKFORMAT", "2"); + + setColumnAttribute(iIndex, "COLALIGN", "3"); + } else { + setColumnAttribute(iIndex, "COLTYPE", "String"); + setColumnAttribute(iIndex, "COLCOLUMNTYPE", "1"); + setColumnAttribute(iIndex, "COLLIMIT", String.valueOf(element.getLength())); + setColumnAttribute(iIndex, "COLCHECKFORMAT", "1"); + setColumnAttribute(iIndex, "COLALIGN", "1"); + } + setColumnAttribute(iIndex, "COLDEFAULTVALUE", ""); + setColumnAttribute(iIndex, "COLHEADER", element.getLabel()); + setColumnAttribute(iIndex, "COLUNIT", ""); + setColumnAttribute(iIndex, "COLHTMLSTYLE", ""); + setColumnAttribute(iIndex, "COLVISIBLE", "1"); + setColumnAttribute(iIndex, "COLSPAN", ""); + setColumnAttribute(iIndex, "ISAUTOCOMPLETE", "0"); + setColumnAttribute(iIndex, "GROUPID", ""); + setColumnAttribute(iIndex, "COLFILTERREFID", ""); + setColumnAttribute(iIndex, "COLFILTERATTRS", ""); + + AttributeUIHints h = bizObjectClass.getAttributeUIHint(element.getName()); + String sColEditstyle = "Text"; + String sColEditSourceType = ""; + String sColEditSource = ""; + String sColAlign = "1"; + String sColReadOnly = "0"; + String sColRequired = "0"; + String sColSortable = "0"; + String sIsFilter = "0"; + if (h != null) { + if (h.isDisplayOnly()) sColReadOnly = "1"; + if (h.isRequired()) sColRequired = "1"; + if (h.isSortingSuitable()) sColSortable = "1"; + if (h.isSortingSuitable()) sIsFilter = "1"; + + if ((h.getValueCharacter() == 1) && (!StringX.isEmpty(h.getCodeTable()))) { + String[] sCodeTableArray = StringX.parseArray(h.getCodeTable()); + String codeTableType = sCodeTableArray[0]; + String codeTableSource = sCodeTableArray[1]; + + String[] sCodeArray = null; + if ("datasource".equals(codeTableType)) + sCodeArray = Support.getCodes(codeTableSource, "JBO"); + else { + sCodeArray = Support.getCodes(codeTableSource, "CodeTable"); + } + ARE.getLog().trace(new StringBuilder().append("[").append(element.getLabel()).append("][codeTableSource]").append(codeTableSource).append(" [CodeArray length]").append(sCodeArray.length).toString()); + if (sCodeArray.length > 6) { + sColEditstyle = "Select"; + sColAlign = "2"; + } else { + sColEditstyle = "Radiobox"; + } + sColEditSourceType = "CodeTable"; + sColEditSource = StringFunction.toArrayString(sCodeArray, ","); + } + } + if (element.getType() == 16) { + sColEditstyle = "Date"; + sColEditSourceType = ""; + sColEditSource = ""; + sColAlign = "2"; + } + setColumnAttribute(iIndex, "COLEDITSTYLE", sColEditstyle); + setColumnAttribute(iIndex, "COLEDITSOURCETYPE", sColEditSourceType); + setColumnAttribute(iIndex, "COLEDITSOURCE", sColEditSource); + setColumnAttribute(iIndex, "COLALIGN", sColAlign); + setColumnAttribute(iIndex, "COLREADONLY", sColReadOnly); + setColumnAttribute(iIndex, "COLREQUIRED", sColRequired); + setColumnAttribute(iIndex, "COLSORTABLE", sColSortable); + setColumnAttribute(iIndex, "ISFILTER", sIsFilter); + } + + private String generateJboSelect(String colName) { + String sFieldName0 = ""; + String sColTableName = getColumnAttribute(colName, "ColTableName"); + String sColActualName = getColumnAttribute(colName, "ColActualName"); + String sColName = getColumnAttribute(colName, "ColName"); + if ((sColTableName == null) || (sColTableName.equals(""))) { + if (sColActualName == null) + sColActualName = ""; + int iDot0 = sColActualName.indexOf("("); + int iDot1 = sColActualName.indexOf("."); + if ((iDot1 > -1) && (iDot0 > -1) && (iDot1 < iDot0)) { + sFieldName0 = ""; + this.alVirtualFields.add(colName); + } else { + sFieldName0 = new StringBuilder().append(sColActualName).append(" as v.").append(sColName).toString(); + } + } else { + if (this.repacedTableList.containsKey(sColTableName)) + sFieldName0 = new StringBuilder().append(this.repacedTableList.get(sColTableName).toString()).append(".").append(sColActualName).toString(); + else + sFieldName0 = new StringBuilder().append(sColTableName).append(".").append(sColActualName).toString(); + if ((!StringX.isSpace(sColName)) && (!sColName.equalsIgnoreCase(sColActualName))) + sFieldName0 = new StringBuilder().append(sFieldName0).append(" as ").append(sColName).toString(); + } + return sFieldName0; + } + + public void init() throws Exception { + this.jboSelect = ""; + if (StringX.isEmpty(this.jboFrom)) + this.jboFrom = ""; + if (StringX.isEmpty(this.jboWhereWhenNoFilter)) + this.jboWhereWhenNoFilter = ""; + if (StringX.isEmpty(this.jboGroup)) + this.jboGroup = ""; + if (StringX.isEmpty(this.jboOrder)) { + this.jboOrder = ""; + } + + if (this.replaceClassName) { + String sJboFromTmp = this.jboFrom; + sJboFromTmp = sJboFromTmp.replaceAll("\\s+(left|right|all|inner)\\s+join", ","); + int iDot = sJboFromTmp.toLowerCase().indexOf(" on "); + if (iDot > -1) + sJboFromTmp = sJboFromTmp.substring(0, iDot); + String[] tmp = sJboFromTmp.split("\\,"); + for (int i = 0; i < tmp.length; i++) { + String[] tmp2 = tmp[i].trim().split(" "); + if (tmp2.length == 1) { + if (!tmp2[0].equalsIgnoreCase("o")) { + if (tmp2[0].equalsIgnoreCase(this.jboClass)) { + this.repacedTableList.put(tmp2[0], "o"); + this.repacedTableKeyList.add(tmp2[0]); + this.jboFrom = this.jboFrom.replaceAll(tmp2[0], "o"); + } else if (tmp2[0].indexOf(".") > -1) { + String sTmpR = tmp2[0].substring(tmp2[0].lastIndexOf(".") + 1); + this.repacedTableList.put(tmp2[0], sTmpR); + this.repacedTableKeyList.add(tmp2[0]); + this.jboFrom = this.jboFrom.replaceAll(tmp2[0], new StringBuilder().append(tmp2[0]).append(" ").append(sTmpR).toString()); + this.jboWhere = this.jboWhere.replaceAll(tmp2[0], sTmpR); + this.jboGroup = this.jboGroup.replaceAll(tmp2[0], sTmpR); + this.jboOrder = this.jboOrder.replaceAll(tmp2[0], sTmpR); + } + } + } else if (tmp2.length == 2) { + this.repacedTableList.put(tmp2[0], tmp2[1]); + this.repacedTableKeyList.add(tmp2[0]); + } + } + } + this.alVirtualFields.clear(); + for (int i = 0; i < this.Columns.size(); i++) { + ASColumn column = getColumn(i); + if (!column.getAttribute("ISINUSE").equals("0")) { + String sFieldName0 = generateJboSelect(column.getAttribute("COLNAME")); + if (sFieldName0.length() > 0) + this.jboSelect = new StringBuilder().append(this.jboSelect).append(",").append(sFieldName0).toString(); + this.alSelectFields.add(column.getAttribute("COLNAME")); + } + } + if (!this.jboSelect.equals("")) { + this.jboSelect = this.jboSelect.substring(1); + } + this.virtualFields = ((String[]) this.alVirtualFields.toArray(new String[0])); + + this.jboAttributes = ((String[]) this.alSelectFields.toArray(new String[0])); + composeJboSql(); + + IValidateRulesFactory factory = new DefaultValidateRulesFactory(this); + this.validateRules = factory.getValidateRules(); + } + + private void init(String sDONo, String sWhere) throws Exception { + this.objCatalogModel = AWEDataWindowCache.getInstance().getCatalogModel(sDONo); + if (this.objCatalogModel == null) { + throw new Exception(new StringBuilder().append("显示模板[").append(sDONo).append("]未定义!").toString()); + } + if (StringX.isSpace(this.objCatalogModel.getColCount())) + this.colCount = 0; + else + this.colCount = Integer.parseInt(this.objCatalogModel.getColCount()); + this.styleId = this.objCatalogModel.getModeId(); + this.jboClass = this.objCatalogModel.getJboClass().trim(); + this.jboWhere = this.objCatalogModel.getJboWhere(); + this.jboFrom = this.objCatalogModel.getJboFrom(); + this.DONAME = this.objCatalogModel.getDoName().trim(); + if ((this.jboFrom == null) || (this.jboFrom.equals(""))) + this.jboFrom = "o"; + this.jboGroup = this.objCatalogModel.getJboGroup(); + if (StringX.isEmpty(this.jboGroup)) + this.jboGroup = ""; + this.jboOrder = this.objCatalogModel.getJboOrder(); + if (StringX.isEmpty(this.jboOrder)) + this.jboOrder = ""; + this.businessProcess = this.objCatalogModel.getBusinessProcess(); + + if ((sWhere == null) || (sWhere.equals(""))) { + if (this.objCatalogModel != null) { + List list = this.objCatalogModel.getLibraryList(); + if (list != null) + for (LibraryModel lm : list) { + int iIndex = addColumn(lm.getColName()); + setColumnAttribute(iIndex, "COLINDEX", lm.getColIndex()); + setColumnAttribute(iIndex, "SORTNO", lm.getSortNo()); + setColumnAttribute(iIndex, "ISINUSE", lm.getIsInuse()); + setColumnAttribute(iIndex, "COLTABLENAME", lm.getColTableName()); + setColumnAttribute(iIndex, "COLACTUALNAME", lm.getColActualName()); + setColumnAttribute(iIndex, "COLNAME", lm.getColName()); + setColumnAttribute(iIndex, "COLTYPE", lm.getColType()); + setColumnAttribute(iIndex, "COLDEFAULTVALUE", lm.getColDefaultValue()); + setColumnAttribute(iIndex, "COLHEADER", lm.getColHeader()); + setColumnAttribute(iIndex, "COLUNIT", lm.getColUnit()); + setColumnAttribute(iIndex, "COLCOLUMNTYPE", lm.getColColumnType()); + setColumnAttribute(iIndex, "COLEDITSTYLE", lm.getColEditsTyle()); + setColumnAttribute(iIndex, "COLCHECKFORMAT", lm.getColCheckFormat()); + setColumnAttribute(iIndex, "COLALIGN", lm.getColAlign()); + setColumnAttribute(iIndex, "COLEDITSOURCETYPE", lm.getColEditSourceType()); + setColumnAttribute(iIndex, "COLEDITSOURCE", lm.getColEditSource()); + setColumnAttribute(iIndex, "COLHTMLSTYLE", lm.getColHtmlStyle()); + setColumnAttribute(iIndex, "COLLIMIT", lm.getColLimit()); + setColumnAttribute(iIndex, "COLVISIBLE", lm.getColVisible()); + setColumnAttribute(iIndex, "COLREADONLY", lm.getColReadonly()); + setColumnAttribute(iIndex, "COLREQUIRED", lm.getColRequired()); + setColumnAttribute(iIndex, "COLSORTABLE", lm.getColSortable()); + setColumnAttribute(iIndex, "ISFILTER", lm.getIsFilter()); + setColumnAttribute(iIndex, "COLSPAN", new StringBuilder().append(lm.getColSpan()).append("").toString()); + setColumnAttribute(iIndex, "ISAUTOCOMPLETE", lm.getIsAutoComplete()); + setColumnAttribute(iIndex, "GROUPID", lm.getGroupId()); + setColumnAttribute(iIndex, "COLFILTERREFID", lm.getColFilterrefId()); + setColumnAttribute(iIndex, "ISAUDIT", lm.getIsAudit()); + setColumnAttribute(iIndex, "COLFILTERATTRS", lm.getColFilterAttrs()); + setColumnAttribute(iIndex, "COLTIPS", lm.getColTips()); + setColumnAttribute(iIndex, "COLINNERBTEVENT", lm.getColInnerBtEvent()); + setColumnAttribute(iIndex, "COLFILTEROPTIONS", lm.getColFilterOptions()); + } + } + } else { + BizObjectManager managerDL = JBOFactory.getFactory().getManager("jbo.ui.system.DATAOBJECT_LIBRARY"); + String sQuery = "dono=:dono and isinuse='1'"; + if ((sWhere != null) && (!sWhere.equals(""))) + sQuery = new StringBuilder().append(sQuery).append(" and ").append(sWhere).toString(); + sQuery = new StringBuilder().append(sQuery).append(" order by sortno").toString(); + BizObjectQuery queryDL = managerDL.createQuery(sQuery).setParameter("dono", sDONo); + List list = queryDL.getResultList(false); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + BizObject obj = (BizObject) list.get(i); + int iIndex = addColumn(obj.getAttribute("COLNAME").getString()); + for (int j = 0; j < MDataBuilder.ColumnsEN.length; j++) { + String sJboAttrName = MDataBuilder.ColumnsEN[j]; + if (sJboAttrName.equalsIgnoreCase("COLTIPS")) + sJboAttrName = "TIPS"; + setColumnAttribute(iIndex, MDataBuilder.ColumnsEN[j], obj.getAttribute(sJboAttrName).getString()); + } + } + } + } + if (this.objCatalogModel != null) { + ArrayList listEvents = this.objCatalogModel.getColEventList(); + if (listEvents != null) { + for (int ii = 0; ii < listEvents.size(); ii++) { + ColEventModel boe = (ColEventModel) listEvents.get(ii); + ASHtmlEvent event = new ASHtmlEvent(); + event.setColName(boe.getColName()); + event.setEventType(boe.getEvent()); + event.setEventFunction(boe.getScript()); + if (boe.getEventParams() != null) { + event.setEventParams(boe.getEventParams()); + } + this.mapHtmlEvents.add(event); + } + } + } + + this.dwcontext = new DWContext(AWEDataWindowCache.getInstance().getDWContextString("OW", getDONO()), "OW", getDONO()); + } + + public void composeJboSql() { + this.jboSelect = this.jboSelect.replaceAll(getJboClass(), "o"); + this.jboSql = new StringBuilder().append("select ").append(this.jboSelect.trim()).append(" from ").append(this.jboFrom.trim()).toString(); + if ((this.jboWhere == null) || (this.jboWhere.trim().equals(""))) { + this.jboWhere = " 1=1 "; + } + String sFilterWhereClause = getFilterWhereClause(); + String[] tmp = getJboFrom().split("\\,"); + for (int i = 0; i < tmp.length; i++) { + String[] tmp2 = tmp[i].split(" "); + if (tmp2.length == 1) { + if (!tmp2[0].equalsIgnoreCase("O")) { + if (tmp2[0].equalsIgnoreCase(getJboClass())) { + sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], "O"); + } else if (tmp2[0].indexOf(".") > -1) { + String sTmpR = tmp2[0].substring(tmp2[0].lastIndexOf(".") + 1); + sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], sTmpR); + } + } + } else if (tmp2.length == 2) { + sFilterWhereClause = sFilterWhereClause.replaceAll(tmp2[0], tmp2[1]); + } + } + if ((sFilterWhereClause != null) && (!sFilterWhereClause.equals(""))) { + sFilterWhereClause = sFilterWhereClause.replaceAll(getJboClass(), "O"); + this.jboWhere = new StringBuilder().append(this.jboWhere.trim()).append(" and ").append("(").append(sFilterWhereClause.trim()).append(")").toString(); + } + + if ((StringX.isSpace(sFilterWhereClause)) && (this.jboWhereWhenNoFilter.trim().length() > 0)) { + if (this.jboWhereWhenNoFilter.toLowerCase().trim().startsWith("and")) + this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).append(" ").append(this.jboWhereWhenNoFilter.trim()).toString(); + else + this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).append(" and ").append(this.jboWhereWhenNoFilter.trim()).toString(); + } else this.jboSql = new StringBuilder().append(this.jboSql).append(" where ").append(this.jboWhere.trim()).toString(); + + if ((this.jboGroup != null) && (!this.jboGroup.equals(""))) { + this.jboSql = new StringBuilder().append(this.jboSql).append(" group by ").append(this.jboGroup.trim()).toString(); + } + if ((this.jboOrder != null) && (!this.jboOrder.equals(""))) + this.jboSql = new StringBuilder().append(this.jboSql).append(" order by ").append(this.jboOrder.trim()).toString(); + } + + public int addColumn(String sColumnName) { + int iIndex = getColumnIndex(sColumnName); + if (iIndex == -1) { + this.Columns.addElement(new ASColumn(sColumnName)); + return this.Columns.size() - 1; + } + return iIndex; + } + + public int addColumn(int iPos, String sColumnName) { + int iIndex = getColumnIndex(sColumnName); + if (iIndex == -1) { + this.Columns.add(iPos, new ASColumn(sColumnName)); + return iPos; + } + return iIndex; + } + + public int getColumnIndex(String sColumnName) { + int iSize = this.Columns.size(); + + for (int i = 0; i < iSize; i++) + if (((ASColumn) this.Columns.get(i)).getAttribute("COLNAME").equalsIgnoreCase(sColumnName)) + return i; + return -1; + } + + public ASColumn getColumn(String sColumnName) { + int iIndex = getColumnIndex(sColumnName); + if (iIndex >= 0) { + return (ASColumn) this.Columns.get(iIndex); + } + return null; + } + + public ASColumn getColumn(int iIndex) { + if (iIndex >= 0) { + return (ASColumn) this.Columns.get(iIndex); + } + return null; + } + + public boolean setColumnFilter(String sColumnList, boolean isFilter) { + if (isFilter) { + return setColumnAttribute(sColumnList, "ISFILTER", "1"); + } + return setColumnAttribute(sColumnList, "ISFILTER", "0"); + } + + public boolean setColumnAttribute(String sColumnList, String sAttributeName, String sAttributeValue) { + int i = 0; + int iSize = 0; + int iIndex = 0; + if (sColumnList.equals("") || sColumnList.equals("*")) { + iSize = Columns.size(); + for (i = 0; i < iSize; i++) + setColumnAttribute(i, sAttributeName, sAttributeValue); + + } else { + iSize = StringFunction.getSeparateSum(sColumnList, ","); + for (i = 1; i <= iSize; i++) { + String sColumnName = StringFunction.getSeparate(sColumnList, ",", i); + iIndex = getColumnIndex(sColumnName); + if (iIndex >= 0) + setColumnAttribute(iIndex, sAttributeName, sAttributeValue); + } + + } + return true; + } + + public boolean appendColumnAttribute(String sColumnList, String sAttributeName, String sAttributeValue) { + if (sColumnList.equals("") || sColumnList.equals("*")) { + int iSize = Columns.size(); + for (int i = 0; i < iSize; i++) + appendColumnAttribute(i, sAttributeName, sAttributeValue); + + } else { + int iSize = StringFunction.getSeparateSum(sColumnList, ","); + for (int i = 1; i <= iSize; i++) { + String sColumnName = StringFunction.getSeparate(sColumnList, ",", i); + int iIndex = getColumnIndex(sColumnName); + if (iIndex >= 0) + appendColumnAttribute(iIndex, sAttributeName, sAttributeValue); + } + + } + return true; + } + + public boolean setColumnAttribute(int iIndex, String sAttributeName, String sAttributeValue) { + if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { + ASColumn ascTemp = (ASColumn) this.Columns.get(iIndex); + ascTemp.setAttribute(sAttributeName, sAttributeValue); + return true; + } + return false; + } + + public boolean appendColumnAttribute(int iIndex, String sAttributeName, String sAttributeValue) { + if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { + ASColumn ascTemp = (ASColumn) this.Columns.get(iIndex); + ascTemp.setAttribute(sAttributeName, new StringBuilder().append(ascTemp.getAttribute(sAttributeName)).append(sAttributeValue).toString()); + return true; + } + return false; + } + + public String getColumnAttribute(String sColumnName, String sAttributeName) { + int iSize = this.Columns.size(); + for (int i = 0; i < iSize; i++) { + int iIndex = getColumnIndex(sColumnName); + if (iIndex >= 0) + return getColumnAttribute(iIndex, sAttributeName); + } + return null; + } + + public String getColumnAttribute(int iIndex, String sAttributeName) { + if ((iIndex >= 0) && (iIndex < this.Columns.size())) { + String sValue = ((ASColumn) this.Columns.get(iIndex)).getAttribute(sAttributeName); + if (sValue == null) + sValue = ""; + return sValue; + } + return null; + } + + public String getName(int iIndex) { + if ((iIndex >= 0) && (iIndex <= this.Columns.size())) { + return ((ASColumn) this.Columns.get(iIndex)).getAttribute("Name"); + } + return null; + } + + public void setType(int iIndex, String sType) { + setType(getName(iIndex), sType); + } + + public void setType(String sColumnList, String sType) { + setColumnAttribute(sColumnList, "COLTYPE", sType); + } + + public void setColTips(String sColumnList, String tips) { + setColumnAttribute(sColumnList, "COLTIPS", tips); + } + + public void setColInnerBtEvent(String sColumnList, String sInnerBtEvent) { + setColumnAttribute(sColumnList, "COLINNERBTEVENT", sInnerBtEvent); + } + + public void setColFilterOptions(String sColumnList, String sColFilterOptions) { + setColumnAttribute(sColumnList, "COLFILTEROPTIONS", sColFilterOptions); + } + + public void setColumnType(String sColumnList, String sColumnType) { + setColumnAttribute(sColumnList, "COLCOLUMNTYPE", sColumnType); + } + + public void setVisible(String sColumnList, boolean bValue) { + setColumnAttribute(sColumnList, "COLVISIBLE", bValue ? "1" : "0"); + } + + public void setReadOnly(String sColumnList, boolean bValue) { + setColumnAttribute(sColumnList, "COLREADONLY", bValue ? "1" : "0"); + } + + public void setRequired(String sColumnList, boolean bValue) { + setColumnAttribute(sColumnList, "COLREQUIRED", bValue ? "1" : "0"); + } + + public void setCheckFormat(String sColumnList, String sFormat) { + setColumnAttribute(sColumnList, "COLCHECKFORMAT", sFormat); + } + + public void setDefaultValue(String sColumnList, String sValue) { + setColumnAttribute(sColumnList, "COLDEFAULTVALUE", sValue); + } + + public void setAlign(String sColumnList, String sFormat) { + setColumnAttribute(sColumnList, "COLALIGN", sFormat); + } + + public void setLimit(String sColumnList, int iLimit) { + setColumnAttribute(sColumnList, "COLLIMIT", String.valueOf(iLimit)); + } + + public void setEditStyle(String sColumnList, String sStyle) { + setColumnAttribute(sColumnList, "COLEDITSTYLE", sStyle); + } + + public void setHTMLStyle(String sColumnList, String sStyle) { + setColumnAttribute(sColumnList, "COLHTMLSTYLE", sStyle); + } + + public void appendHTMLStyle(String sColumnList, String sStyle) { + appendColumnAttribute(sColumnList, "COLHTMLSTYLE", sStyle); + } + + public void setDDDWCode(String sColumnList, String sCodeName) { + setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "Code"); + setColumnAttribute(sColumnList, "COLEDITSOURCE", sCodeName); + } + + public void setDDDWJbo(String sColumnList, String sJbo) { + setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "Jbo"); + setColumnAttribute(sColumnList, "COLEDITSOURCE", sJbo); + } + + public void setDDDWCodeTable(String sColumnList, String sCodeTable) { + setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "CodeTable"); + setColumnAttribute(sColumnList, "COLEDITSOURCE", sCodeTable); + } + + public void setDDDWCodeTable(String sColumnList, String[] sCodeArray) { + setColumnAttribute(sColumnList, "COLEDITSOURCETYPE", "CodeTable"); + setColumnAttribute(sColumnList, "COLEDITSOURCE", StringFunction.toArrayString(sCodeArray, ",")); + } + + public void setHeader(String sColumnList, String sValue) { + setColumnAttribute(sColumnList, "COLHEADER", sValue); + } + + public void setHeader(String sValueList) { + int iCount = StringFunction.getSeparateSum(sValueList, ","); + for (int i = 1; i <= iCount; i++) + setColumnAttribute(i - 1, "COLHEADER", StringFunction.getSeparate(sValueList, ",", i)); + } + + public void setHeader(String[][] sValueArray) { + int iCount = sValueArray.length; + for (int i = 0; i < iCount; i++) { + int iIndex = getColumnIndex(sValueArray[i][0]); + if (iIndex >= 0) + setColumnAttribute(iIndex, "COLHEADER", sValueArray[i][1]); + } + } + + public void setUnit(String sColumnList, String sValue) { + setColumnAttribute(sColumnList, "COLUNIT", sValue); + } + + public void setGroup(String sColumnList, String sValue) { + setColumnAttribute(sColumnList, "GROUPID", sValue); + } + + public void appendFilter(ASDataObjectFilter dfFilter) + throws Exception { + this.Filters.addElement(dfFilter); + setColumnAttribute(dfFilter.sFilterColumnID, "ISFILTER", "1"); + } + + public void generateFilters() + throws Exception { + int iFilterID = 0; + for (int i = 0; i < this.Columns.size(); i++) { + ASColumn acTempColumn = (ASColumn) this.Columns.get(i); + if ("1".equals(acTempColumn.getAttribute("ISFILTER"))) { + iFilterID++; + setFilter(new StringBuilder().append("DF").append(iFilterID).toString(), acTempColumn.getAttribute("COLNAME"), null); + } + } + } + + public void setFilter(String sFilterID, String sColumnID, String sOptions) throws Exception { + ASColumn acTempColumn = getColumn(sColumnID); + if (acTempColumn == null) { + throw new Exception(new StringBuilder().append("获得ASColumn失败。ColumnID:").append(sColumnID).toString()); + } + ASColumn refColumn = null; + if ((acTempColumn.getAttribute("COLFILTERREFID") != null) && (acTempColumn.getAttribute("COLFILTERREFID").length() > 0)) { + refColumn = getColumn(acTempColumn.getAttribute("COLFILTERREFID")); + } + ASDataObjectFilter dfFilter = new ASDataObjectFilter(sFilterID, acTempColumn, refColumn, sOptions); + appendFilter(dfFilter); + } + + public ASDataObjectFilter getFilter(String sFilterID) throws Exception { + for (int i = 0; i < this.Filters.size(); i++) { + ASDataObjectFilter tmpFilter = (ASDataObjectFilter) this.Filters.get(i); + if (tmpFilter.sFilterID.equals(sFilterID)) + return tmpFilter; + } + return null; + } + + public ASDataObjectFilter getFilter(int i) throws Exception { + return (ASDataObjectFilter) this.Filters.get(i); + } + + private String getFilterHtml() + throws Exception { + String sReturn = ""; + + for (int i = 0; i < this.Filters.size(); i++) { + ASDataObjectFilter dofTemp = (ASDataObjectFilter) this.Filters.get(i); + sReturn = new StringBuilder().append(sReturn).append(dofTemp.getFilterHtml()).toString(); + } + return sReturn; + } + + public String getFilterHtml(Page page) + throws Exception { + parseFilterData(page); + return getFilterHtml(); + } + + private void parseFilterData(Page page) + throws Exception { + for (int i = 0; i < this.Filters.size(); i++) { + ASDataObjectFilter dofTemp = (ASDataObjectFilter) this.Filters.get(i); + + String sTempFilterOperator = page.getParameter(new StringBuilder().append("DOFILTER_").append(dofTemp.sFilterID).append("_OP").toString()); + if ((sTempFilterOperator != null) && (!sTempFilterOperator.equals(""))) + dofTemp.sOperator = sTempFilterOperator; + for (int j = 0; j < dofTemp.sFilterInputs.length; j++) { + String sTempFilterValue = page.getParameter(dofTemp.sFilterInputs[j][0]); + if ((sTempFilterValue != null) && (!sTempFilterValue.equals(""))) { + dofTemp.sFilterInputs[j][1] = DataConvert.toString(sTempFilterValue); + } + if ((dofTemp.sFilterInputs[j][1] != null) && (!dofTemp.sFilterInputs[j][1].equals(""))) + this.receivedFilterData = true; + } + } + } + + private String getFilterWhereClause() { + String sReturn = ""; + String sCurWhereClause = ""; + + int j = 0; + try { + for (int i = 0; i < this.Filters.size(); i++) { + ASDataObjectFilter dofTemp = (ASDataObjectFilter) this.Filters.get(i); + sCurWhereClause = dofTemp.getFilterWhereClause(); + if ((sCurWhereClause != null) && (!sCurWhereClause.equals(""))) { + j++; + sReturn = new StringBuilder().append(sReturn).append(j == 1 ? "" : " and ").append("(").append(dofTemp.getFilterWhereClause()).append(")").toString(); + } + } + } catch (Exception e) { + e = + e; + + e.printStackTrace(); + } finally { + } + return sReturn; + } + + public boolean haveReceivedFilterCriteria() { + return this.receivedFilterData; + } + + public String[] getExtendAttributes() { + if (this.Columns == null) return null; + ArrayList result = new ArrayList(); + for (int i = 0; i < this.Columns.size(); i++) { + ASColumn column = (ASColumn) this.Columns.get(i); + //if (("1".equals(column.getAttribute("COLVISIBLE"))) && ((column.getAttribute("COLTABLENAME") == null) || ("".equals(column.getAttribute("COLTABLENAME"))))) { + if (((column.getAttribute("COLTABLENAME") == null) || ("".equals(column.getAttribute("COLTABLENAME"))))) { + result.add(column.getAttribute("COLNAME")); + } + } + return (String[]) result.toArray(new String[result.size()]); + } + + public String toJson() + throws Exception { + if (this.Columns == null) return "[]"; + JSONObject list = JSONObject.createArray(); + for (Iterator i$ = this.Columns.iterator(); i$.hasNext(); ) { + Object obj = i$.next(); + ASColumn asColumn = (ASColumn) obj; + if ("1".equals(asColumn.getAttribute("ISINUSE"))) { + JSONObject jsonColumn = JSONObject.createObject(); + jsonColumn.add(JSONElement.valueOf("DONO", asColumn.getAttribute("DONO"))); + jsonColumn.add(JSONElement.valueOf("COLINDEX", asColumn.getAttribute("COLINDEX"))); + jsonColumn.add(JSONElement.valueOf("SORTNO", asColumn.getAttribute("SORTNO"))); + jsonColumn.add(JSONElement.valueOf("COLNAME", asColumn.getAttribute("COLNAME"))); + jsonColumn.add(JSONElement.valueOf("COLTYPE", asColumn.getAttribute("COLTYPE"))); + jsonColumn.add(JSONElement.valueOf("COLDEFAULTVALUE", asColumn.getAttribute("COLDEFAULTVALUE"))); + jsonColumn.add(JSONElement.valueOf("COLHEADER", asColumn.getAttribute("COLHEADER"))); + jsonColumn.add(JSONElement.valueOf("COLUNIT", asColumn.getAttribute("COLUNIT"))); + jsonColumn.add(JSONElement.valueOf("COLCOLUMNTYPE", asColumn.getAttribute("COLCOLUMNTYPE"))); + jsonColumn.add(JSONElement.valueOf("COLEDITSTYLE", asColumn.getAttribute("COLEDITSTYLE"))); + jsonColumn.add(JSONElement.valueOf("COLCHECKFORMAT", asColumn.getAttribute("COLCHECKFORMAT"))); + jsonColumn.add(JSONElement.valueOf("COLALIGN", asColumn.getAttribute("COLALIGN"))); + if ((asColumn.getAttribute("COLEDITSOURCETYPE") != null) && (asColumn.getAttribute("COLEDITSOURCE") != null)) { + jsonColumn.add(JSONElement.valueOf("COLEDITSOURCETYPE", asColumn.getAttribute("COLEDITSOURCETYPE"))); + String[] codes = Support.getCodes(asColumn.getAttribute("COLEDITSOURCE"), asColumn.getAttribute("COLEDITSOURCETYPE")); + JSONObject jsonCodes = JSONObject.createArray(); + for (int i = 0; i < codes.length; i++) { + jsonCodes.add(JSONElement.valueOf(codes[i])); + } + jsonColumn.add(JSONElement.valueOf("COLEDITSOURCE", jsonCodes)); + } + + jsonColumn.add(JSONElement.valueOf("COLHTMLSTYLE", asColumn.getAttribute("COLHTMLSTYLE"))); + jsonColumn.add(JSONElement.valueOf("COLLIMIT", asColumn.getAttribute("COLLIMIT"))); + jsonColumn.add(JSONElement.valueOf("COLVISIBLE", asColumn.getAttribute("COLVISIBLE"))); + jsonColumn.add(JSONElement.valueOf("COLREADONLY", asColumn.getAttribute("COLREADONLY"))); + jsonColumn.add(JSONElement.valueOf("COLREQUIRED", asColumn.getAttribute("COLREQUIRED"))); + jsonColumn.add(JSONElement.valueOf("COLSORTABLE", asColumn.getAttribute("COLSORTABLE"))); + jsonColumn.add(JSONElement.valueOf("ISFILTER", asColumn.getAttribute("ISFILTER"))); + jsonColumn.add(JSONElement.valueOf("COLSPAN", asColumn.getAttribute("COLSPAN"))); + jsonColumn.add(JSONElement.valueOf("GROUPID", asColumn.getAttribute("GROUPID"))); + jsonColumn.add(JSONElement.valueOf("COLFILTERREFID", asColumn.getAttribute("COLFILTERREFID"))); + jsonColumn.add(JSONElement.valueOf("COLFILTERATTRS", asColumn.getAttribute("COLFILTERATTRS"))); + jsonColumn.add(JSONElement.valueOf("ISAUDIT", asColumn.getAttribute("ISAUDIT"))); + jsonColumn.add(JSONElement.valueOf("COLTIPS", asColumn.getAttribute("COLTIPS"))); + jsonColumn.add(JSONElement.valueOf("COLINNERBTEVENT", asColumn.getAttribute("COLINNERBTEVENT"))); + jsonColumn.add(JSONElement.valueOf("COLFILTEROPTIONS", asColumn.getAttribute("COLFILTEROPTIONS"))); + list.add(JSONElement.valueOf(jsonColumn)); + } + } + return JSONEncoder.encode(list); + } } \ No newline at end of file diff --git a/src/com/amarsoft/awe/dw/CustomASObjectModel.java b/src/com/amarsoft/awe/dw/CustomASObjectModel.java new file mode 100644 index 000000000..c2fd89065 --- /dev/null +++ b/src/com/amarsoft/awe/dw/CustomASObjectModel.java @@ -0,0 +1,42 @@ +package com.amarsoft.awe.dw; + +import com.amarsoft.are.jbo.BizObjectManager; + +/** + * @program: apzl_leasing + * @description: + * @author: 李超杰 + * @create: 2024-12-16 17:00 + */ +public class CustomASObjectModel extends ASObjectModel { + public CustomASObjectModel() throws Exception { + } + + public CustomASObjectModel(String[] headers) throws Exception { + super(headers); + } + + public CustomASObjectModel(BizObjectManager manager) throws Exception { + super(manager); + } + + public CustomASObjectModel(String sDONo) throws Exception { + super(sDONo); + } + + public CustomASObjectModel(String sDONo, String sWhere) throws Exception { + super(sDONo, sWhere); + } + + public CustomASObjectModel(String sDONo, String sWhere, String sDatabase) throws Exception { + super(sDONo, sWhere, sDatabase); + } + + public CustomASObjectModel(String sDONo, String fullFenixId, Boolean lazyLoad) throws Exception { + super(sDONo); + this.setFullFenixId(fullFenixId); + this.setLazyLoad(lazyLoad); + this.setDataQueryClass("com.tenwa.flow.comm.list_html_generator.FenixListHtmlGenerator"); + this.setPageSize(20); + } +} diff --git a/src_tenwa/com/tenwa/flow/comm/list_html_generator/FenixListHtmlGenerator.java b/src_tenwa/com/tenwa/flow/comm/list_html_generator/FenixListHtmlGenerator.java new file mode 100644 index 000000000..48eaf2cf0 --- /dev/null +++ b/src_tenwa/com/tenwa/flow/comm/list_html_generator/FenixListHtmlGenerator.java @@ -0,0 +1,100 @@ +package com.tenwa.flow.comm.list_html_generator; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.db.Entity; +import cn.hutool.db.Page; +import cn.hutool.db.PageResult; +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.awe.dw.handler.BusinessProcessData; +import com.amarsoft.awe.dw.ui.htmlfactory.ListHtmlWithASDataObjectGenerator; +import com.amarsoft.awe.dw.ui.htmlfactory.QueryParamObject; +import com.amarsoft.awe.util.Transaction; +import com.tenwa.util.SqlRunnerUtil; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @program: apzl_leasing + * @description: + * @author: 李超杰 + * @create: 2024-12-16 17:09 + */ +public class FenixListHtmlGenerator extends ListHtmlWithASDataObjectGenerator { + + @Override + public void run(BusinessProcessData arg0) throws Exception { + if (StrUtil.isEmpty(this.asObj.getFullFenixId())) { + throw new RuntimeException("参数【fullFenixId】不能为空!"); + } + this.asObj.setParamstr(this.paramstr); + System.out.println("SQL参数:" + this.paramstr); + System.out.println("分页参数:pageSize=" + this.pageSize + ",curPage=" + this.curPage + ",pageCount=" + this.pageCount + ",rowCount=" + + this.rowCount + ""); + //获得查询条件 + List queryParams = this.getQeuryParmObjects(); + if (this.asObj.getLazyLoad() && queryParams.size() == 0) { + this.searchedDataList = new ArrayList(); + return; + } + Map paramMap = new HashMap<>(); + if (StrUtil.isNotBlank(this.paramstr)) { + paramMap.put("paramstr", this.paramstr); + } + for (QueryParamObject queryParam : queryParams) { + System.out.println("查询条件:[colname=" + queryParam.getColName() + ",option=" + queryParam.getOption() + ",value0=" + queryParam.getValue0() + + ",value1=" + queryParam.getValue1() + "]"); + if ("Area".equals(queryParam.getOption())) { + if (StrUtil.isNotBlank(queryParam.getValue0())) { + paramMap.put(queryParam.getColName() + "Start", queryParam.getValue0()); + } + if (StrUtil.isNotBlank(queryParam.getValue1())) { + paramMap.put(queryParam.getColName() + "End", queryParam.getValue1()); + } + } else { + paramMap.put(queryParam.getColName(), queryParam.getValue0()); + } + } + + Transaction transaction = Transaction.createTransaction(JBOFactory.createJBOTransaction()); + try { + PageResult pageResult = SqlRunnerUtil.page(transaction, this.asObj.getFullFenixId(), paramMap, + Page.of(this.curPage, this.getPageSize())); + this.rowCount = pageResult.getTotal(); + this.pageCount = pageResult.getTotalPage(); + + BizObjectManager manager = getBizObjectManager(); + this.searchedDataList = new ArrayList(); + for (Entity entity : pageResult) { + this.searchedDataList.add(createBizObject(manager, entity)); + } + transaction.commit(); + } catch (Exception e) { + e.printStackTrace(); + try { + if (transaction != null) transaction.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + } finally { + try { + if (transaction != null) { + transaction.disConnect(); + } + } catch (JBOException e) { + e.printStackTrace(); + } + } + } + + @Override + public void calPageCount(BusinessProcessData businessProcessData) throws Exception { + pageCount = (rowCount + this.pageSize - 1) / this.pageSize; + } +} diff --git a/src_tenwa/com/tenwa/flow/rent/rentincome/RentIncomeMethod.java b/src_tenwa/com/tenwa/flow/rent/rentincome/RentIncomeMethod.java index 2449013c2..261c504ab 100644 --- a/src_tenwa/com/tenwa/flow/rent/rentincome/RentIncomeMethod.java +++ b/src_tenwa/com/tenwa/flow/rent/rentincome/RentIncomeMethod.java @@ -8,9 +8,12 @@ import java.sql.ResultSet; import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityHandler; import cn.hutool.db.handler.NumberHandler; import com.google.common.collect.ImmutableMap; import com.tenwa.util.SqlRunnerUtil; @@ -202,19 +205,19 @@ public class RentIncomeMethod { /** * 租金核销 */ - public String setRentDataToRentIncome(JBOTransaction tx) throws JBOException{ - try{ + public String setRentDataToRentIncome(JBOTransaction tx) throws JBOException { + try { boolean flag = false; - if("Y".equals(isChanged)){ + if ("Y".equals(isChanged)) { flag = true; } - BigDecimal bel = new BigDecimal(balance == null?"0":balance); //可核销金额 + BigDecimal bel = new BigDecimal(balance == null ? "0" : balance); //可核销金额 BigDecimal allFactMoney = bel; BizObjectManager bomEb = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME); tx.join(bomEb); BizObject boEb = bomEb.createQuery("FLOWUNID=:FLOWUNID") .setParameter("FLOWUNID", flowunid).getSingleResult(true); - if(flag){ + if (flag) { bel = new BigDecimal(boEb.getAttribute("MAYOPE_MONEY").getString()); allFactMoney = bel; } @@ -222,36 +225,39 @@ public class RentIncomeMethod { String[] corpuss = new String[ids.length]; String[] interests = new String[ids.length]; String[] Penaltys = new String[ids.length]; - if(overCorpuss != null){ + if (overCorpuss != null) { corpuss = overCorpuss.split("@"); interests = overInterests.split("@"); Penaltys = overPenaltys.split("@"); } String factDate = boEb.getAttribute("FACT_DATE").getString(); Date f = new SimpleDateFormat("yyyy/MM/dd").parse(factDate); - for(int i=0;i>> paymentOrders = ProductParamUtil.getProductComponentDecisionTable(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307", "rmoname", "rmosortno"); - String penaltyRule = ProductParamUtil.getProductParameterValue(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307","PenaltyRule", "PenaltyRule"); + Map>> paymentOrders = ProductParamUtil + .getProductComponentDecisionTable(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307", "rmoname", "rmosortno"); + String penaltyRule = ProductParamUtil + .getProductParameterValue(boLCI.getAttribute("PRODUCT_ID").getString(), "PRD0307", "PenaltyRule", "PenaltyRule"); String[] paymentOrder = new String[3]; String planDate = boVLRP.getAttribute("PLAN_DATE").getString(); - if(f.compareTo(new SimpleDateFormat("yyyy/MM/dd").parse(planDate)) > 0){ - for(int j=0;j 0) { + for (int j = 0; j < paymentOrders.get("RMO-02").size(); j++) { + paymentOrder[Integer.parseInt(paymentOrders.get("RMO-02").get(j).get("rmosortno")) - 1] = paymentOrders.get("RMO-02").get(j).get("rmoname"); } - }else{ - for(int j=0;j boLCRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0").setParameter("PLAN_ID", ids[i]) .getResultList(false); - boLRIT.setAttributeValue("HIRE_LIST", boLCRI.size()+boLCRIT.size()+1); + boLRIT.setAttributeValue("HIRE_LIST", boLCRI.size() + boLCRIT.size() + 1); //安鹏要求改为网银到账日期 boLRIT.setAttributeValue("HIRE_DATE", factDate); boLRIT.setAttributeValue("CHARGE_WAY", "Collection"); boLRIT.setAttributeValue("HIRE_OBJECT", boEb.getAttribute("CLIENT_NAME").getString()); BigDecimal money; - if(!flag){ + if (!flag) { money = new BigDecimal(corpuss[i]).add(new BigDecimal(interests[i])).add(new BigDecimal(Penaltys[i])); - if(!ids[i].equals(portionCollectionID)){ + if (!ids[i].equals(portionCollectionID)) { bel = bel.subtract(money); boLRIT.setAttributeValue("RENT", new BigDecimal(corpuss[i]).add(new BigDecimal(interests[i]))); boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpuss[i])); boLRIT.setAttributeValue("INTEREST", new BigDecimal(interests[i])); boLRIT.setAttributeValue("PENALTY", new BigDecimal(Penaltys[i])); - }else{ + } else { BigDecimal portionMoneys = new BigDecimal(portionMoney); BigDecimal rentMoney = new BigDecimal(0); - for(int j=0;j= 0){ //如果能正常减去,则为对应的回笼对象赋值对应值 - if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){ + } else { + if (portionMoneys.compareTo(subtractMoney) >= 0) { //如果能正常减去,则为对应的回笼对象赋值对应值 + if ("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)) { rentMoney = rentMoney.add(subtractMoney); } portionMoneys = portionMoneys.subtract(subtractMoney); boLRIT.setAttributeValue(subtractMoneyName, subtractMoney); - }else{ //如果不够减,则把剩余的值赋值给对应的回笼对象 - if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){ + } else { //如果不够减,则把剩余的值赋值给对应的回笼对象 + if ("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)) { rentMoney = rentMoney.add(portionMoneys); } boLRIT.setAttributeValue(subtractMoneyName, portionMoneys); @@ -336,59 +343,62 @@ public class RentIncomeMethod { boLRIT.setAttributeValue("RENT", rentMoney); bel = bel.subtract(new BigDecimal(portionMoney)); } - }else{ - BizObject bo = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("id=:planID").setParameter("planID", ids[i]).getSingleResult(false); - String corpusOver = bo.getAttribute("corpus_over").getString(); - String interestOver = bo.getAttribute("interest_over").getString(); - // String penaltyOver = bo.getAttribute("penalty_over").getString(); - String factPenalty = bo.getAttribute("fact_penalty").getString(); - String penaltyAdjust = bo.getAttribute("penalty_adjust").getString(); + } else { +// BizObject bo = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("id=:planID").setParameter("planID", ids[i]).getSingleResult(false); + Map sqlParamMap = new HashMap<>(); + sqlParamMap.put("planId", ids[i]); + Entity entity = SqlRunnerUtil.query("flow.FundCollectionFlow.queryRentPlanList", sqlParamMap, new EntityHandler()); + String paymentNumber = entity.getStr("payment_number"); + String planList = entity.getStr("plan_list"); + BigDecimal corpusOver = entity.getBigDecimal("corpus_over"); + BigDecimal interestOver = entity.getBigDecimal("interest_over"); + BigDecimal penaltySum = entity.getBigDecimal("penalty_sum");// 包含罚息实收和罚息调整 String penalty = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME) - .createQuery("select v.round(v.getRentPenalty('"+bo.getAttribute("payment_number").getString()+"','"+bo.getAttribute("plan_list").getString()+"','"+factDate+"'),2) as v.penalty from O").getSingleResult(false).getAttribute("penalty").getString(); - String penaltyOver = new BigDecimal(penalty).subtract(new BigDecimal(factPenalty)).subtract(new BigDecimal(penaltyAdjust)).toString(); - - if("penalty_income".equals(penaltyRule)){ - penaltyOver = "0.00"; - }else{ - // penaltyOver = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("select v.getRentPenalty('"+boVLRP.getAttribute("PAYMENT_NUMBER").getString()+"','"+boVLRP.getAttribute("PLAN_LIST").getString()+"','"+factDate+"') v.penalty from O").getSingleResult(false).getAttribute("penalty").getString(); + .createQuery("select v.round(v.getRentPenalty('" + paymentNumber + "','" + planList + "','" + factDate + "'),2) as v.penalty from O").getSingleResult(false).getAttribute("penalty").getString(); + BigDecimal penaltyOver = new BigDecimal(penalty).subtract(penaltySum); + + if ("penalty_income".equals(penaltyRule)) { + penaltyOver = BigDecimal.ZERO; + } else { + // penaltyOver = JBOFactory.getBizObjectManager(VI_LC_RENT_PLAN.CLASS_NAME).createQuery("select v.getRentPenalty('"+boVLRP.getAttribute("PAYMENT_NUMBER").getString()+"','"+boVLRP.getAttribute("PLAN_LIST").getString()+"','"+factDate+"') v.penalty from O").getSingleResult(false).getAttribute("penalty").getString(); } - money = new BigDecimal(corpusOver).add(new BigDecimal(interestOver)).add(new BigDecimal(penaltyOver)); - if(money.compareTo(bel) <= 0){ + money = corpusOver.add(interestOver).add(penaltyOver); + if (money.compareTo(bel) <= 0) { bel = bel.subtract(money); - boLRIT.setAttributeValue("RENT", new BigDecimal(corpusOver).add(new BigDecimal(interestOver))); - boLRIT.setAttributeValue("CORPUS", new BigDecimal(corpusOver)); - boLRIT.setAttributeValue("INTEREST", new BigDecimal(interestOver)); - boLRIT.setAttributeValue("PENALTY", new BigDecimal(penaltyOver)); - }else{ + boLRIT.setAttributeValue("RENT", corpusOver.add(interestOver)); + boLRIT.setAttributeValue("CORPUS", corpusOver); + boLRIT.setAttributeValue("INTEREST", interestOver); + boLRIT.setAttributeValue("PENALTY", penaltyOver); + } else { BigDecimal portionMoneys = bel; BigDecimal rentMoney = new BigDecimal(0); - for(int j=0;j= 0){ //如果能正常减去,则为对应的回笼对象赋值对应值 - if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){ + } else { + if (portionMoneys.compareTo(subtractMoney) >= 0) { //如果能正常减去,则为对应的回笼对象赋值对应值 + if ("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)) { rentMoney = rentMoney.add(subtractMoney); } portionMoneys = portionMoneys.subtract(subtractMoney); boLRIT.setAttributeValue(subtractMoneyName, subtractMoney); - }else{ //如果不够减,则把剩余的值赋值给对应的回笼对象 - if("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)){ + } else { //如果不够减,则把剩余的值赋值给对应的回笼对象 + if ("CORPUS".equals(subtractMoneyName) || "INTEREST".equals(subtractMoneyName)) { rentMoney = rentMoney.add(portionMoneys); } boLRIT.setAttributeValue(subtractMoneyName, portionMoneys); @@ -417,7 +427,7 @@ public class RentIncomeMethod { boLRIT.setAttributeValue("FLOWUNID", flowunid); boLRI.saveObject(boLRIT); } - if(bel.compareTo(new BigDecimal(0)) > 0){ + if (bel.compareTo(new BigDecimal(0)) > 0) { allFactMoney = allFactMoney.subtract(bel); } BizObjectManager bomLEP = JBOFactory.getBizObjectManager(LC_EBANK_PROCESS.CLASS_NAME); @@ -430,11 +440,11 @@ public class RentIncomeMethod { //已核销金额 = 到账总金额 - 剩余可核销金额 BigDecimal mayMoney = new BigDecimal(boEb.getAttribute("MAYOPE_MONEY").getDouble()); BigDecimal factMoney = new BigDecimal(boEb.getAttribute("FACT_MONEY").getDouble()); - BigDecimal mayMoneyNew = mayMoney.subtract(allFactMoney); - boEb.setAttributeValue("MAYOPE_MONEY",mayMoneyNew.toString()); + BigDecimal mayMoneyNew = mayMoney.subtract(allFactMoney); + boEb.setAttributeValue("MAYOPE_MONEY", mayMoneyNew.toString()); boEb.setAttributeValue("HAD_MONEY", factMoney.subtract(mayMoneyNew).toString()); bomEb.saveObject(boEb); - }catch(Exception e){ + } catch (Exception e) { e.printStackTrace(); return "ERROR"; }