package com.tenwa.reckon.product; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Vector; import apx.com.amarsoft.als.apzl.apply.business.loan.product.ProductBaseLoanTools; import apx.com.amarsoft.als.base.cache.instance.AppAweDoCache; import com.amarsoft.are.ARE; import com.amarsoft.awe.dw.ASColumn; import com.amarsoft.awe.dw.ASObjectModel; import com.amarsoft.awe.dw.ui.validator.ValidateRule; import com.tenwa.officetempalte.util.FileOperatorUtil; import com.tenwa.quartz.StringUtil; public class ProductConditionService { //获取设备款 产品配置 public String getEquipRule(ASObjectModel doTemp,Map> map,String col,Vector vali) throws Exception{ Map rule=new HashMap(); if(map.containsKey(col)){ String min=StringUtil.nullToString(map.get(col).get("CostType08-MIN"));//最小值 String max=StringUtil.nullToString(map.get(col).get("CostType08-MAX"));//最大值 String defaultValue=StringUtil.nullToString(map.get(col).get("CostType08"));//限定值 rule.put("min", min); rule.put("max", max); rule.put("defaultValue", defaultValue); String para=""; if(min.length()>0){ para=this.getValidat(min,"设备款不能小于"+min, ">="); } if(max.length()>0){ if(para.length()>0){para+=",";} para+=this.getValidat(max,"设备款不能大于"+max, "<="); } if(para.length()>0){ this.setColValidat(vali, col, para); } if(defaultValue.length()>0){ doTemp.setDefaultValue(col, defaultValue); doTemp.setColumnAttribute(col,"colreadonly", "1"); } }else{ this.setColValidat(vali, col,this.getValidat("0","设备款必须大于0", ">")); } return FileOperatorUtil.getMapToJsonStr(rule); } //获取设备款 产品配置 public String getEquipRuleApp(List> appList,Map> map,String col,Vector vali) throws Exception{ Map rule=new HashMap(); if(map.containsKey(col)){ String min=StringUtil.nullToString(map.get(col).get("CostType08-MIN"));//最小值 String max=StringUtil.nullToString(map.get(col).get("CostType08-MAX"));//最大值 String defaultValue=StringUtil.nullToString(map.get(col).get("CostType08"));//限定值 if(min.length()>0){ rule.put("min", "设备款不能小于"+min+"@>="); } if(max.length()>0){ rule.put("max", "设备款不能小于"+max+"@<="); } if(defaultValue.length()>0){ ProductBaseLoanTools.addAppList(appList, col, "coldefaultvalue", defaultValue); ProductBaseLoanTools.addAppList(appList, col, "colreadonly", "1"); } }else{ rule.put("0", "设备款必须大于0@>"); } ProductBaseLoanTools.addAppList(appList, col, "colvalidat", rule); return FileOperatorUtil.getMapToJsonStr(rule); } //获取除设备款外其它费用项 配置 public String getFeeRule(ASObjectModel doTemp,Map> map,String col,String colName,Vector vali)throws Exception{ //CostType05 是否显示比例 CostType06 输入方式 CostType07 比例参照 CostType08 金额限定 CostType09 比例限定 Map rule=new HashMap(); Map ratioRule=new HashMap(); String sJson=""; if(map.containsKey(col)){ String min=StringUtil.nullToString(map.get(col).get("CostType08-MIN"));//最小值 String max=StringUtil.nullToString(map.get(col).get("CostType08-MAX"));//最大值 String defaultValue=StringUtil.nullToString(map.get(col).get("CostType08"));//限定值 String isShowRatio=StringUtil.nullToString(map.get(col).get("CostType05"));//是否显示比例 String inputModel=StringUtil.nullToString(map.get(col).get("CostType06"));//输入方式 String oder=StringUtil.nullToString(map.get(col).get("DISPLAY_ORDER"));//排序号 if(!col.equals("FIRST_PAYMENT")){ doTemp.setColumnAttribute(col,"sortno",oder+doTemp.getColumnAttribute(col, "sortno")); if(col.equals("CAUTION_MONEY")){ doTemp.setColumnAttribute("CAUTION_DEDUCTION_MONEY","sortno",oder+doTemp.getColumnAttribute("CAUTION_DEDUCTION_MONEY", "sortno")); doTemp.setColumnAttribute("CAUTION_MONEY_REMAIN","sortno",oder+doTemp.getColumnAttribute("CAUTION_MONEY_REMAIN", "sortno")); doTemp.setColumnAttribute("CAUTION_MONEY_METHOD","sortno",oder+doTemp.getColumnAttribute("CAUTION_MONEY_METHOD", "sortno")); } } //根据产品,带出手续费分摊方式 if(col.equals("HANDLING_CHARGE_MONEY")) { String oneOrMore = map.get(col).get("oneOrMore"); //System.err.println(oneOrMore); doTemp.setDefaultValue("HANDLING_CHARGE_MONEY_TYPE", oneOrMore == null ? "" : oneOrMore); } String groupId = doTemp.getColumnAttribute(col, "groupid"); if("0070".equals(groupId)) { rule.put("financing", "true"); } String ratioMin=StringUtil.nullToString(map.get(col).get("CostType09-MIN"));//比例最小值 String ratioMax=StringUtil.nullToString(map.get(col).get("CostType09-MAX"));//比例最小值 String ratioDefaultValue=StringUtil.nullToString(map.get(col).get("CostType09"));//比例限定值 rule.put("ratioFee", StringUtil.nullToString(map.get(col).get("CostType07")));//比例参考项 rule.put("ratioType", inputModel);//比例计算方式 rule.put("min", min); rule.put("max", max); rule.put("defaultValue", defaultValue); String para=""; if(min.length()>0){ para=this.getValidat(min, colName+"不能小于"+min, ">="); } if(max.length()>0){ if(para.length()>0){para+=",";} para+=this.getValidat(max, colName+"不能大于"+max, "<="); } if(para.length()>0){ this.setColValidat(vali, col, para); } //比例限定 ratioRule.put("min", ratioMin); ratioRule.put("max", ratioMax); ratioRule.put("defaultValue", ratioDefaultValue); para=""; if(ratioMin.length()>0){ para=this.getValidat(ratioMin, colName+"比例不能小于"+ratioMin+"%", ">="); } if(ratioMax.length()>0){ if(para.length()>0){para+=",";} para+=this.getValidat(ratioMax, colName+"比例不能大于"+ratioMax+"%", "<="); } if(para.length()>0){ this.setColValidat(vali, col+"_RATIO_0", para); } if("InputMode03".equals(inputModel)){//互算 rule.put("isShowRatio","true"); if(defaultValue.length()>0){ doTemp.setDefaultValue(col, defaultValue); } if(ratioDefaultValue.length()>0){ doTemp.setDefaultValue(col+"_RATIO", ratioDefaultValue); } }else if("InputMode02".equals(inputModel)){//比例算金额 rule.put("isShowRatio","true"); doTemp.setColumnAttribute(col,"colreadonly", "1"); if(ratioDefaultValue.length()>0){ doTemp.setColumnAttribute(col+"_RATIO","colreadonly", "1"); doTemp.setDefaultValue(col+"_RATIO", ratioDefaultValue); } }else{ rule.put("isShowRatio","true"); doTemp.setColumnAttribute(col+"_RATIO","colreadonly", "1"); if(defaultValue.length()>0){ doTemp.setDefaultValue(col, defaultValue); doTemp.setColumnAttribute(col,"colreadonly", "1"); doTemp.setColumnAttribute(col+"_FINA","colreadonly", "1"); } if("N".equals(isShowRatio)){ doTemp.setColumnAttribute(col,"colfilterrefid", "");//不显示比例 rule.put("isShowRatio","false"); } } for(Map.Entry entry:rule.entrySet()){ sJson+="'"+entry.getKey()+"':'"+entry.getValue()+"',"; } sJson+="'ratioRule':"+FileOperatorUtil.getMapToJsonStr(ratioRule); } return "{"+sJson+"}"; } @SuppressWarnings("unchecked") public String getFeeRuleApp(List> appList,Map> map,String col,String colName,Vector vali)throws Exception{ //CostType05 是否显示比例 CostType06 输入方式 CostType07 比例参照 CostType08 金额限定 CostType09 比例限定 Map rule=new HashMap(); Map ratioRule=new HashMap(); Map aweDo = AppAweDoCache.getAppAweDoCachePool(); Map doTemplate = null; List> doLibrary = null; try { doTemplate = (Map) aweDo.get("LoanSimulationBasicInfoApp"); doLibrary = (List>) doTemplate.get("library"); } catch (Exception e) { ARE.getLog().error(e); return ""; } String sontno2 = ""; String sontno3 = ""; String sontno4 = ""; String sontno5 = ""; String groupId = ""; for (Map colM2 : doLibrary) { String colName2 = colM2.get("colname") == null ? "" : colM2.get("colname").toString(); if (col.equalsIgnoreCase(colName2)) { sontno2 = colM2.get("sortno") == null ? "" : colM2.get("sortno").toString(); groupId = colM2.get("groupid") == null ? "" : colM2.get("groupid").toString(); } if ("CAUTION_DEDUCTION_MONEY".equalsIgnoreCase(colName2)) sontno3 = colM2.get("sortno") == null ? "" : colM2.get("sortno").toString(); if ("CAUTION_MONEY_REMAIN".equalsIgnoreCase(colName2)) sontno4 = colM2.get("sortno") == null ? "" : colM2.get("sortno").toString(); if ("CAUTION_MONEY_METHOD".equalsIgnoreCase(colName2)) sontno5 = colM2.get("sortno") == null ? "" : colM2.get("sortno").toString(); } String sJson=""; if(map.containsKey(col)){ String min=StringUtil.nullToString(map.get(col).get("CostType08-MIN"));//最小值 String max=StringUtil.nullToString(map.get(col).get("CostType08-MAX"));//最大值 String defaultValue=StringUtil.nullToString(map.get(col).get("CostType08"));//限定值 String isShowRatio=StringUtil.nullToString(map.get(col).get("CostType05"));//是否显示比例 String inputModel=StringUtil.nullToString(map.get(col).get("CostType06"));//输入方式 String oder=StringUtil.nullToString(map.get(col).get("DISPLAY_ORDER"));//排序号 if(!col.equals("FIRST_PAYMENT")){ ProductBaseLoanTools.addAppList(appList, col, "sortno", oder+sontno2); if(col.equals("CAUTION_MONEY")){ Map CAUTION_DEDUCTION_MONEY = new HashMap(); CAUTION_DEDUCTION_MONEY.put("colname", "CAUTION_DEDUCTION_MONEY"); appList.add(CAUTION_DEDUCTION_MONEY); ProductBaseLoanTools.addAppList(appList, CAUTION_DEDUCTION_MONEY.get("colname").toString(), "sortno", oder+sontno3); Map CAUTION_MONEY_REMAIN = new HashMap(); CAUTION_MONEY_REMAIN.put("colname", "CAUTION_MONEY_REMAIN"); appList.add(CAUTION_MONEY_REMAIN); ProductBaseLoanTools.addAppList(appList, CAUTION_MONEY_REMAIN.get("colname").toString(), "sortno", oder+sontno4); Map CAUTION_MONEY_METHOD = new HashMap(); CAUTION_MONEY_METHOD.put("colname", col); appList.add(CAUTION_MONEY_METHOD); ProductBaseLoanTools.addAppList(appList, CAUTION_MONEY_METHOD.get("colname").toString(), "sortno", oder+sontno5); } } // String groupId = doTemp.getColumnAttribute(col, "groupid"); if("0070".equals(groupId)) { rule.put("financing", "true"); } String ratioMin=StringUtil.nullToString(map.get(col).get("CostType09-MIN"));//比例最小值 String ratioMax=StringUtil.nullToString(map.get(col).get("CostType09-MAX"));//比例最小值 String ratioDefaultValue=StringUtil.nullToString(map.get(col).get("CostType09"));//比例限定值 rule.put("ratioFee", StringUtil.nullToString(map.get(col).get("CostType07")));//比例参考项 rule.put("ratioType", inputModel);//比例计算方式 rule.put("min", min); rule.put("max", max); rule.put("defaultValue", defaultValue); String para=""; if(min.length()>0){ rule.put("min", colName+"不能小于"+min+"@>="); } if(max.length()>0){ rule.put("min", colName+"不能大于"+max+"@<="); } //比例限定 ratioRule.put("min", ratioMin); ratioRule.put("max", ratioMax); ratioRule.put("defaultValue", ratioDefaultValue); para=""; if(ratioMin.length()>0){ ratioRule.put("min", colName+"比例不能小于"+ratioMin+"%@>="); } if(ratioMax.length()>0){ ratioRule.put("min", colName+"比例不能大于"+ratioMax+"%@<="); } if("InputMode03".equals(inputModel)){//互算 rule.put("isShowRatio","true"); if(defaultValue.length()>0){ ProductBaseLoanTools.addAppList(appList, col, "defaultValue", defaultValue); } if(ratioDefaultValue.length()>0){ ProductBaseLoanTools.addAppList(appList, col+"_RATIO", "defaultValue", ratioDefaultValue); } }else if("InputMode02".equals(inputModel)){//比例算金额 rule.put("isShowRatio","true"); ProductBaseLoanTools.addAppList(appList, col, "colreadonly", "1"); if(ratioDefaultValue.length()>0){ ProductBaseLoanTools.addAppList(appList, col+"_RATIO", "colreadonly", "1"); ProductBaseLoanTools.addAppList(appList, col+"_RATIO", "defaultValue", ratioDefaultValue); } }else{ rule.put("isShowRatio","true"); ProductBaseLoanTools.addAppList(appList, col+"_RATIO", "colreadonly", "1"); if(defaultValue.length()>0){ ProductBaseLoanTools.addAppList(appList, col, "defaultValue", defaultValue); ProductBaseLoanTools.addAppList(appList, col, "colreadonly", "1"); ProductBaseLoanTools.addAppList(appList, col+"_FINA", "colreadonly", "1"); } if("N".equals(isShowRatio)){ ProductBaseLoanTools.addAppList(appList, col, "colfilterrefid", ""); rule.put("isShowRatio","false"); } } for(Map.Entry entry:rule.entrySet()){ sJson+="'"+entry.getKey()+"':'"+entry.getValue()+"',"; } sJson+="'ratioRule':"+FileOperatorUtil.getMapToJsonStr(ratioRule); } return "{"+sJson+"}"; } /** * 给模板加字段校验 * @param vali 检验规则集合 * @param colName 字段名 * @param param 校验规则 * @throws Exception */ public void setColValidat(Vector vali,String col,String param) throws Exception{ String[] params=new String[10]; params[0]="["+param+"]"; ValidateRule vr=new ValidateRule(); vr.setControlto(col);//字段名 vr.setName("Expression_"+col);//校验名称 vr.setType("Expression");// vr.setUseStatus("all");//状态 vr.setParams(params); vali.add(vr); } /** * 获取字段校验规则 * @param value 值 * @param message 提示 * @param type 操作符 >.<.>=.<= * @return * @throws Exception */ public String getValidat(String value,String message,String type) throws Exception{ String expression="${numberValue}"+type+value; Mapmap=new HashMap(); map.put("expression",expression); map.put("message",message); map.put("name", "规则1"); map.put("scope", "client"); return FileOperatorUtil.getMapToJsonStr(map); } public ASColumn createFeeCol(String colname,Map column){ ASColumn col=new ASColumn(colname.toUpperCase()); col.setAttribute("COLINDEX",column.get("DISPLAY_ORDER"));//显示序号 col.setAttribute("SORTNO",column.get("DISPLAY_ORDER"));//排序号 col.setAttribute("ISINUSE", "1");//是否有效 1 有效 0 无效 col.setAttribute("COLACTUALNAME", "''");//jbo属性名 col.setAttribute("COLTYPE", "Number");//值类型 col.setAttribute("COLDEFAULTVALUE", "0");//默认值 col.setAttribute("COLHEADER",column.get("colheader"));//显示名称 col.setAttribute("COLEDITSTYLE", "Text");//编辑形式 col.setAttribute("COLCHECKFORMAT", "2");//格式检查 col.setAttribute("COLALIGN", "1");//对齐方式 col.setAttribute("COLVISIBLE", "1");//可见 col.setAttribute("COLREADONLY", "0");//只读 col.setAttribute("COLREQUIRED", "1");//必填 col.setAttribute("GROUPID", "fund_info");//分组 col.setAttribute("colfilterrefid",colname.toUpperCase()+ "_RATIO");//比例 return col; } public ASColumn createFeeColRatio(String colname,Map column){ ASColumn col=new ASColumn(colname.toUpperCase()+"_RATIO"); col.setAttribute("COLINDEX",column.get("DISPLAY_ORDER"));//显示序号 col.setAttribute("SORTNO",column.get("DISPLAY_ORDER"));//排序号 col.setAttribute("ISINUSE", "1");//是否有效 1 有效 0 无效 col.setAttribute("COLACTUALNAME", "''");//jbo属性名 col.setAttribute("COLTYPE", "Number");//值类型 col.setAttribute("COLDEFAULTVALUE", "0");//默认值 col.setAttribute("COLHEADER",column.get("colheader"));//显示名称 col.setAttribute("COLEDITSTYLE", "Text");//编辑形式 col.setAttribute("COLCHECKFORMAT", "2");//格式检查 col.setAttribute("COLALIGN", "1");//对齐方式 col.setAttribute("COLVISIBLE", "0");//可见 col.setAttribute("COLREADONLY", "0");//只读 col.setAttribute("COLREQUIRED", "1");//必填 col.setAttribute("GROUPID", "fund_info");//分组 return col; } public void createFeeColApp(List> appList, String colname,Map column){ colname = colname.toUpperCase(); //使用名 ProductBaseLoanTools.addAppList(appList, colname, "COLNAME".toLowerCase(), colname); //显示序号 ProductBaseLoanTools.addAppList(appList, colname, "COLINDEX".toLowerCase(), column.get("DISPLAY_ORDER")); //排序号 ProductBaseLoanTools.addAppList(appList, colname, "SORTNO".toLowerCase(), column.get("DISPLAY_ORDER")); //是否有效 1 有效 0 无效 ProductBaseLoanTools.addAppList(appList, colname, "ISINUSE".toLowerCase(), "1"); // JBO属性名 ProductBaseLoanTools.addAppList(appList, colname, "COLACTUALNAME".toLowerCase(), "''"); //值类型 ProductBaseLoanTools.addAppList(appList, colname, "COLTYPE".toLowerCase(), "Number"); //默认值 ProductBaseLoanTools.addAppList(appList, colname, "COLDEFAULTVALUE".toLowerCase(), "0"); //显示名称 ProductBaseLoanTools.addAppList(appList, colname, "COLHEADER".toLowerCase(), column.get("colheader")); //编辑形式 ProductBaseLoanTools.addAppList(appList, colname, "COLEDITSTYLE".toLowerCase(), column.get("Text")); //格式检查 ProductBaseLoanTools.addAppList(appList, colname, "COLCHECKFORMAT".toLowerCase(), "2"); //对齐方式 ProductBaseLoanTools.addAppList(appList, colname, "COLALIGN".toLowerCase(), "1"); //可见 ProductBaseLoanTools.addAppList(appList, colname, "COLVISIBLE".toLowerCase(), "1"); //只读 ProductBaseLoanTools.addAppList(appList, colname, "COLREADONLY".toLowerCase(), "0"); //必填 ProductBaseLoanTools.addAppList(appList, colname, "COLREQUIRED".toLowerCase(), "1"); //分组 ProductBaseLoanTools.addAppList(appList, colname, "GROUPID".toLowerCase(), "fund_info"); //比例 ProductBaseLoanTools.addAppList(appList, colname, "colfilterrefid".toLowerCase(), colname+"_RATIO"); } public void createFeeColRatioApp(List> appList,String colname,Map column){ colname = colname.toUpperCase(); //使用名 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLNAME".toLowerCase(), colname+"_RATIO"); //显示序号 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLINDEX".toLowerCase(), column.get("DISPLAY_ORDER")); //排序号 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "SORTNO".toLowerCase(), column.get("DISPLAY_ORDER")); //是否有效 1 有效 0 无效 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "ISINUSE".toLowerCase(), "1"); // JBO属性名 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLACTUALNAME".toLowerCase(), "''"); //值类型 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLTYPE".toLowerCase(), "Number"); //默认值 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLDEFAULTVALUE".toLowerCase(), "0"); //显示名称 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLHEADER".toLowerCase(), column.get("colheader")); //编辑形式 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLEDITSTYLE".toLowerCase(), column.get("Text")); //格式检查 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLCHECKFORMAT".toLowerCase(), "2"); //对齐方式 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLALIGN".toLowerCase(), "1"); //可见 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLVISIBLE".toLowerCase(), "0"); //只读 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLREADONLY".toLowerCase(), "0"); //必填 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "COLREQUIRED".toLowerCase(), "1"); //分组 ProductBaseLoanTools.addAppList(appList, colname+"_RATIO", "GROUPID".toLowerCase(), "fund_info"); } }