221 lines
8.6 KiB
Java
221 lines
8.6 KiB
Java
package com.tenwa.reckon.product;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Vector;
|
|
|
|
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<String,Map<String,String>> map,String col,Vector<ValidateRule> vali) throws Exception{
|
|
Map<String,String> rule=new HashMap<String, String>();
|
|
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 getFeeRule(ASObjectModel doTemp,Map<String,Map<String,String>> map,String col,String colName,Vector<ValidateRule> vali)throws Exception{
|
|
//CostType05 是否显示比例 CostType06 输入方式 CostType07 比例参照 CostType08 金额限定 CostType09 比例限定
|
|
Map<String,String> rule=new HashMap<String, String>();
|
|
Map<String,String> ratioRule=new HashMap<String, String>();
|
|
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"));
|
|
}
|
|
}
|
|
|
|
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<String,String> 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<ValidateRule> 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;
|
|
|
|
Map<String,String>map=new HashMap<String, String>();
|
|
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<String,String> 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<String,String> 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;
|
|
}
|
|
}
|