P15GEN2\59518
2025-10-10 9f6890646993d16260d4201d613c092132856127
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
99
package biz.target;
 
import java.math.BigDecimal;
 
import foundation.data.entity.Entity;
 
public class TargetModelDetail {
 
    private String id;
    private TargetModel targetModel;
    private BigDecimal base;
    private BigDecimal top;
    private String unit;
    private String remark;
    private int valueIndex;
    
    public TargetModelDetail(TargetModel targetModel) {
        this.targetModel = targetModel;
    }
 
    public void load(Entity entity) throws Exception {
        id = entity.getId();
        BigDecimal exRate = targetModel.getExRate();
        base = entity.getBigDecimal("left_step_level") ;
        base = base == null ? null : exRate.multiply(base);
        top = entity.getBigDecimal("right_step_level");
        top = top == null ? null : exRate.multiply(top);
        unit = entity.getString("unit");
        remark = entity.getString("step_param_value");
        
        parseValueIndex();
    }
    
    public void parseValueIndex() {
        String parentId = targetModel.getId();
        
        if ("s_increase".equals(parentId)) {
            valueIndex = 0;
        }
        else if ("s_increase_amt".equals(parentId)) {
            valueIndex = 1;
        }
        else if ("s_sale".equals(parentId)) {
            valueIndex = 2;
        }
        else {
            valueIndex = 2;
        }
    }
 
    public boolean isValid(BigDecimal value) {
        return overBase(value) && underTop(value);
    }
 
    public boolean overBase(BigDecimal value) {
        if (base == null || base.compareTo(value) <= 0) {
            return true;
        }
        
        return false;
    }
 
    public boolean underTop(BigDecimal value) {
        if (top == null || top.compareTo(value) > 0) {
            return true;
        }
        
        return false;
    }
 
    public String getId() {
        return id;
    }
    
    public String getParentId() {
        return targetModel.getId();
    }
 
    public BigDecimal getBase() {
        return base;
    }
 
    public BigDecimal getTop() {
        return top;
    }
 
    public String getUnit() {
        return unit;
    }
 
    public String getRemark() {
        return remark;
    }
 
    public int getValueIndex() {
        return valueIndex;
    }
 
}