田源
2025-03-05 be30e17e3c7685a54f761bf3a03487308c939270
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.vci.ubcs.code.algorithm;
import com.vci.ubcs.starter.annotation.VciEnum;
import com.vci.ubcs.starter.web.enumpck.BaseEnum;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
 
/***
 * 自定义流水枚举
 */
@VciEnum(name ="customSerialEnum",text = "自定义流水类型",description = "")
public enum CustomSerialEnum implements BaseEnum {
 
    /**
     * 编辑中
     */
    ROMAN("custom_serial_roman","罗马流水");
 
    /**
     * 枚举的值
     */
    private String value;
 
    /**
     * 枚举显示文本
     */
    private String text;
 
    /**
     * 构造函数
     *
     * @param value 值
     * @param text  显示文本
     */
    private CustomSerialEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }
 
    /**
     * 获取枚举值
     *
     * @return 枚举值
     */
    @Override
    public String getValue() {
        return value;
    }
 
    /**
     * 设置枚举值
     *
     * @param value 枚举值
     */
    public void setValue(String value) {
        this.value = value;
    }
 
    /**
     * 获取枚举显示文本
     *
     * @return 显示文本
     */
    @Override
    public String getText() {
        return text;
    }
 
    /**
     * 设置显示文本
     *
     * @param text 显示文本
     */
    public void setText(String text) {
        this.text = text;
    }
 
 
 
    /**
     * 根据枚举类型判断应该返回什么样类型的流水
     * 暂时加了罗马类型,如果后续有其他流水类型则需要在此处理
     * @return 枚举值
     */
    public static Double getDoubleCustomSerialValue(String value,String customCodeSerialType) {
        Double serialValue=null;
        for (CustomSerialEnum wenum : CustomSerialEnum.values()) {
            if (wenum.getValue().equalsIgnoreCase(customCodeSerialType)) {//如果为罗马
                int newValue = VciBaseUtil.convertRomanToArabic(value);
                serialValue = new Double(newValue);
                break;
            } else {
                serialValue=Double.parseDouble(value);
                break;
            }
        }
        return serialValue;
    }
    /**
     * 根据枚举类型判断应该返回什么样类型的流水
     * 暂时加了罗马类型,如果后续有其他流水类型则需要在此处理
     * @return 枚举值
     */
    public static String getStringCustomSerialValue(Double value,String customCodeSerialType) {
        String serialValue=String.valueOf(value);
        for (CustomSerialEnum wenum : CustomSerialEnum.values()) {
            if (wenum.getValue().equalsIgnoreCase(customCodeSerialType)) {//如果为罗马
                String newValue=VciBaseUtil.convertArabicToRoman(value.intValue());
                serialValue=newValue;
                break;
            }else{
                break;
            }
        }
        return serialValue;
    }
 
 
    /**
     * 根据名称获取对应的枚举值
     *
     * @param text 名称
     * @return 枚举值
     */
    public static String getValueByText(String text) {
        for (CustomSerialEnum wenum : CustomSerialEnum.values()) {
            if (wenum.getText().equalsIgnoreCase(text)) {
                return wenum.getValue();
            }
        }
        return "";
    }
 
    /**
     * 根据枚举值获取名称
     *
     * @param value 枚举值
     * @return 名称
     */
    public static String getTextByValue(String value) {
        for (CustomSerialEnum wenum : CustomSerialEnum.values()) {
            if (wenum.getValue().equalsIgnoreCase(value)) {
                return wenum.getText();
            }
        }
        return "";
    }
 
    /**
     * 根据枚举值获取枚举对象
     *
     * @param value 枚举值
     * @return 枚举对象,不存在时候返回null
     */
    public static CustomSerialEnum forValue(String value) {
        for (CustomSerialEnum wenum : CustomSerialEnum.values()) {
            if (wenum.getValue().equalsIgnoreCase(value)) {
                return wenum;
            }
        }
        return null;
    }
 
}