医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
package cn.besteam.common.util;
 
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
 
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
 
/**
 * @author jacob
 */
public class StringUtil {
 
    public static String trim(String str) {
 
        if (str == null) {
            return "";
        }
        return str.trim();
    }
 
    /**
     * 判断A字符串不为NULL并且equals字符串B
     *
     * @param valueA
     * @param valueB
     * @return
     * @Date in Apr 14, 2011,5:40:43 PM
     */
    public static boolean strEquals(String valueA, String valueB) {
 
        boolean eq = (!isBlank(valueA) && !isBlank(valueB)) && (valueA.trim().equals(valueB.trim()));
        if (eq) {
            return true;
        }
        return false;
    }
 
    /**
     * <pre>
     * 判断是否为空,为空则返回true
     * 为空的条件:null、""、"null"
     * </pre>
     *
     * @param obj
     * @return
     */
    public static boolean isBlank(Object obj) {
 
        if (obj == null) {
            return true;
        }
        String str = obj.toString().trim();
        if ("".equals(str) || "null".equalsIgnoreCase(str)) {
            return true;
        }
        return false;
    }
 
    /**
     * <pre>
     * 判断是否不为空,不为空则返回true
     * 为空的条件:null、""、"null"
     * </pre>
     *
     * @param obj
     * @return
     */
    public static boolean isNotBlank(Object obj) {
 
        return !isBlank(obj);
    }
 
    /**
     * <pre>
     * 获取换行符
     * </pre>
     *
     * @return
     */
    public static String getNewLine() {
 
        return System.getProperty("line.separator");
    }
 
    /**
     * 获取uuid字符串
     */
    public static String uuid() {
 
        return UUID.randomUUID().toString();
    }
 
    /**
     * 获取uuid字符串,无横杠
     */
    public static String uuidNotLine() {
 
        return UUID.randomUUID().toString().replace("-", "");
    }
 
    /**
     * 去除前后空格,若obj为null返回""空字串
     *
     * @param obj
     * @return
     */
    public static String trim(Object obj) {
 
        if (obj == null) {
            return "";
        }
        return obj.toString().trim();
    }
 
    /**
     * <p>
     * 生成随机码
     *
     * <p>
     * 若指定的长度为0,则返回空白字符串
     *
     * @param codeLength 随机码长度
     * @return
     */
    public static String randomCode(int codeLength) {
 
        return RandomStringUtils.randomNumeric(codeLength);
    }
 
    /**
     * 取uuid去掉-后从后向前截取指定长度随机串 @Date 2016年3月19日,上午12:57:40 @author YYF @param length @return @return
     * String @throws
     */
    public static String getUUID(int length) {
 
        String uuid = UUID.randomUUID().toString();
        uuid = uuid.replace("-", "");
        if (uuid.length() > length) {
            uuid = uuid.substring(uuid.length() - length, uuid.length());
        }
        return uuid;
    }
 
    /**
     * 判断字符串是否为数字
     *
     * @param str
     * @return
     */
    public static boolean isNumeric(String str) {
 
        if (null == str || str.trim().length() == 0) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
 
    /**
     * 检查指定的字符串是否为空。
     * <ul>
     * <li>SysUtils.isEmpty(null) = true</li>
     * <li>SysUtils.isEmpty("") = true</li>
     * <li>SysUtils.isEmpty(" ") = true</li>
     * <li>SysUtils.isEmpty("abc") = false</li>
     * </ul>
     *
     * @param value 待检查的字符串
     * @return true/false
     */
    public static boolean isEmpty(String value) {
 
        int strLen;
        if (value == null || (strLen = value.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if ((Character.isWhitespace(value.charAt(i)) == false)) {
                return false;
            }
        }
        return true;
    }
 
    /**
     * 检查对象是否为数字型字符串,包含负数开头的。
     */
    public static boolean isNumeric(Object obj) {
 
        if (obj == null) {
            return false;
        }
        char[] chars = obj.toString().toCharArray();
        int length = chars.length;
        if (length < 1) {
            return false;
        }
        int i = 0;
        if (length > 1 && chars[0] == '-') {
            i = 1;
        }
        for (; i < length; i++) {
            if (!Character.isDigit(chars[i])) {
                return false;
            }
        }
        return true;
    }
 
    /**
     * 检查指定的字符串列表是否不为空。
     */
    public static boolean areNotEmpty(String... values) {
 
        boolean result = true;
        if (values == null || values.length == 0) {
            result = false;
        } else {
            for (String value : values) {
                result &= !isEmpty(value);
            }
        }
        return result;
    }
 
    /**
     * 把通用字符编码的字符串转化为汉字编码。
     */
    public static String unicodeToChinese(String unicode) {
 
        StringBuilder out = new StringBuilder();
        if (!isEmpty(unicode)) {
            for (int i = 0; i < unicode.length(); i++) {
                out.append(unicode.charAt(i));
            }
        }
        return out.toString();
    }
 
    public static String numFormat(double d, String format) {
 
        return new DecimalFormat(format).format(d);
    }
 
    public static String numFormat(double d) {
 
        return numFormat(d, "#0.00");
    }
 
    /**
     * yyyyMMddHHmmss+param+6位随机数
     *
     * @param param
     * @return
     */
    public static String serialNum(Long param) {
 
        return DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + param + (int) ((Math.random() * 9 + 1) * 100000);
    }
 
    /**
     * 返回对象所有值为null的字段 String空串也是为null
     *
     * @param source
     * @return
     */
    public static String[] getNullPropertyNames(Object source) {
 
        BeanWrapper src = new BeanWrapperImpl(source);
        java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
        Set<String> emptyNames = new HashSet<String>();
        for (java.beans.PropertyDescriptor pd : pds) {
            Object srcValue = src.getPropertyValue(pd.getName());
            boolean empty = srcValue == null || ("".equals(srcValue.toString().trim()));
            if (empty) {
                emptyNames.add(pd.getName());
            }
        }
        String[] result = new String[emptyNames.size()];
        return emptyNames.toArray(result);
    }
 
    /**
     * 隐藏手机中间四位数
     *
     * @param tel
     * @return
     */
    public static String getTelHide(String tel) {
 
        if (!isEmpty(tel)) {
            StringBuilder sb = new StringBuilder(tel);
            sb.replace(3, 7, "****");
            return sb.toString();
        }
        return null;
    }
 
}