package com.changhong.epc.bean.form.budget;
|
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import lombok.Data;
|
import lombok.EqualsAndHashCode;
|
import lombok.NoArgsConstructor;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Objects;
|
|
@Data
|
@EqualsAndHashCode
|
public class BudgetUserDefined {
|
|
private String key;
|
private String val;
|
|
/**
|
* 子表单是否合并
|
*/
|
private boolean mergeSubForm;
|
|
/**
|
* 是否过滤字表单
|
*/
|
private boolean filterSubForm;
|
|
@Data
|
@NoArgsConstructor
|
public static class Dimension{
|
private String name;
|
private String column;
|
private String value;
|
private Boolean isRemove;
|
|
public Dimension(String name, Boolean isRemove){
|
this.name = name;
|
this.column = name;
|
this.isRemove = isRemove;
|
}
|
|
public Dimension(String name, String column){
|
this(name);
|
this.column = column;
|
}
|
|
public Dimension(String name){
|
this.name = name;
|
this.column = name;
|
this.isRemove = false;
|
}
|
|
public void setData(Map<String, Object> data){
|
setValue(getVal(data.get(this.name)));
|
}
|
|
protected String getVal(Object val){
|
if(ObjectUtil.empty(val))
|
return "";
|
if(val instanceof List){
|
return Objects.toString(((List)val).get(0));
|
}else if(val instanceof String){
|
return (String) val;
|
}else{
|
return Objects.toString(val, "");
|
}
|
}
|
|
};
|
|
private List<Dimension> mainDimension;
|
private List<Dimension> subDimension;
|
|
private List<List<Dimension>> subDimensions;
|
|
public void initSubDimensions(int size){
|
subDimensions = new ArrayList<>();
|
for (int i = 0; i < size; i++)
|
subDimensions.add(JSONTool.toList(JSONTool.toJson(subDimension),Dimension.class));
|
}
|
|
public BudgetUserDefined(){
|
}
|
public BudgetUserDefined(String key, String val){
|
this.key = key;
|
this.val = val;
|
}
|
public BudgetUserDefined(String key, String val,
|
List<Dimension> dimension, List<Dimension> subDimension){
|
this.key = key;
|
this.val = val;
|
this.mainDimension = dimension;
|
this.subDimension = subDimension;
|
}
|
}
|