zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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;
    }
}