doum
2025-09-08 fa7ac16021db8d9a6a5bc214f50600420876325e
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
package com.doumee.core.constants;
 
import ch.qos.logback.core.util.COWArrayList;
import com.doumee.dao.business.web.request.LocaltionDTO;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
 
import javax.servlet.http.HttpServletRequest;
import java.awt.*;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class Constants {
 
  public static final String DEFAULT_PWD = "DEFAULT_PWD";
  public static final String TRUE = "t";
  public static final String FALSE = "f";
  public static final String TOKEN ="TOKEN" ;
    public static final String SYSTEM ="SYSTEM" ;
    public static final String DINGDING ="DINGDING" ;
    public static final String DINGDING_APPKEY ="DINGDING_APPKEY" ;
    public static final String DINGDING_CHATTOKEN ="DINGDING_CHATTOKEN" ;
    public static final String DINGDING_ROBOTCODE ="DINGDING_ROBOTCODE" ;
    public static final String DINGDING_SECRET ="DINGDING_SECRET" ;
    public static final String DINGDING_TOKEN ="DINGDING_TOKEN" ;
 
    public static final String MINI_PROGRAMME ="MINI_PROGRAMME" ;
    public static final String FREE_RENT_TIME ="FREE_RENT_TIME" ;
    public static final String LOW_VOLTAGE ="LOW_VOLTAGE" ;
    public static final String ACCESS_TOKEN ="ACCESS_TOKEN" ;
    public static final String IMG_DIR = "IMG_DIR";
    public static final String FILE_DIR ="FILE_DIR" ;
    public static final String PRIVATE_KEY = "PRIVATE_KEY";
    public static final String PROJECT_FILE = "PROJECT_FILE";
    public static final String PROJECTS = "PROJECTS";
    public static final String DISCOUNT = "DISCOUNT";
    public static final String ELEC_BIKE_CONTRIL_API_URL = "ELEC_BIKE_CONTRIL_API_URL";
    public static final String FORCE_BACK_LOCK = "FORCE_BACK_LOCK";
    public static final String FORCE_BACK_SITE = "FORCE_BACK_SITE";
    //车辆类型数据
    public static final String  BIKE_TYPE ="0,1,2,3,4,5,6,7,8" ;
    public static final String MINI_PROGRAMME_REALEASE ="MINI_PROGRAMME_REALEASE" ;
    public static final String TIME_OUT_TEMPID ="TIME_OUT_TEMPID" ;
 
    public static final int FOUR =4 ;
    public static final String PAUSE_BIKE_TYPE ="PAUSE_BIKE_TYPE" ;
    public static final String HEART_TIME_EXPIRE_TIME ="HEART_TIME_EXPIRE_TIME" ;
    public static final String PARK_LAT_LNG_LIST = "PARK_LAT_LNG_LIST";
    public static final String LOW_BIKE_VOLTAGE ="LOW_BIKE_VOLTAGE" ;
    public static final String OBLINE_HEART_TIME_LIMIT ="OBLINE_HEART_TIME_LIMIT" ;
    public static final String EBIKE_PREFIX ="ebike-" ;
    public static String REDIS_DEBUG_STR="test_";
    public static final String AD = "AD";
    public static String REPAIR = "REPAIR";
    public static final String NOTICE_SITE_LINK_LIMIT="NOTICE_SITE_LINK_LIMIT";
 
    public static boolean equalsInteger(Integer a, Integer b) {
        if (formatIntegerNum(a) == formatIntegerNum(b)) {
            return true;
        }
        return false;
    }
 
    public  interface MqttTopic{
 
        String topic_index = "device/lock/";
        //开锁(发布)
        String pub_openLock = "device/lock/{siteId}/{lockId}/unlock";
        //站点全量锁头数量信息
        String sub_siteInfo = "device/lock/+/siteInfo";
        //管理员刷卡记录上报
        String sub_adminCard = "device/lock/+/+/adminCard";
        //锁信息,在初始化、状态变更时会推送锁的完整状态(订阅)
        String sub_lockInfo = "device/lock/+/+/info";
        //还车锁头(订阅)
        String sub_closeLock = "device/lock/+/+/bike";
        String sub_health= "device/lock/+/health";
 
        String sub_brokers = "$SYS/brokers/+/clients/#";
        //实时获取锁信息(发布)
        String pub_getLockInfo = "device/lock/{siteId}/{lockId}/getInfo";
    }
 
    /**
   * 数据权限范围:0只看自己;1只看自己所在校区;2看全部校区;3看指定校区(多选)
   */
  public interface PermissionType{
        int self =0;
        int self_campus =1;
        int all =2;
        int partful = 3;
  }
    public interface LockStatus{
      //  //状态,0闭合, 1打开,2运行中, 3异常 -1自检
        int closed =0;
        int open =1;
        int running =2;
        int error= 3;
        int checking= -1;
    }
    public interface goodsorderStatus{
        int waitPay =0;
        int pay =1;
        int cancel =2;
        int fail = 3;
        int over = 4;
    }
    public interface goodsorderPayStatus{
        int waitPay =0;
        int pay =1;
    }
    public enum TRANSACTIONS_TYPE{
      //交易类型 0租车押金 1结算实际消费 2结算退款 3平台退款"
        DEPOSIT(0,"租车押金", "租车押金"),
 
        CONSUMPTION(1,"订单消费结算", "订单消费结算"),
 
        REFUND(2,"结算退押金", "结算退押金"),
 
        PLATFORM_REFUND(3,"平台退款", "平台退款"),
 
        DISCOUNT(4,"套餐购买", "套餐购买")
 
        ;
        String name;
 
        Integer key;
 
        String info;
 
        TRANSACTIONS_TYPE(Integer key, String name, String info) {
            this.name = name;
            this.key = key;
            this.info = info;
        }
        public static TRANSACTIONS_TYPE get(int key) {
            TRANSACTIONS_TYPE[] values = TRANSACTIONS_TYPE.values();
            for (TRANSACTIONS_TYPE object : values) {
                if (object.key == key) {
                    return object;
                }
            }
            return null;
        }
 
        public String getName() {
            return name;
        }
 
        public void setName(String name) {
            this.name = name;
        }
 
        public Integer getKey() {
            return key;
        }
 
        public void setKey(Integer key) {
            this.key = key;
        }
 
        public String getInfo() {
            return info;
        }
 
        public void setInfo(String info) {
            this.info = info;
        }
    }
 
 
public static  String getUUID(){
      return UUID.randomUUID().toString().replace("-","");
}
        public interface RedisKeys {
            public static final String submission_period_key = "sp_";
            public static final String import_bikes = "import_bikes";
        }
 
        public static final String ACCESS_ID = "ACCESS_ID";
        public static final String BUCKETNAME = "BUCKETNAME";
        public static final String OSS = "OSS";
        public static final String ACCESS_KEY = "ACCESS_KEY";
        public static final String ENDPOINT = "ENDPOINT";
        public static final String RESOURCE_PATH = "RESOURCE_PATH";
        public static final String AVATAR_FILE = "AVATAR_FILE";
        //用户协议
        public static final String AGREEMENT = "AGREEMENT";
        //计价规则
        public static final String PRICING_RULE = "PRICING_RULE";
        //小程序主题名称
        public static final String PROJECT_NAME = "PROJECT_NAME";
        //小程序服务端电话
        public static final String SERVER_PHONE = "SERVER_PHONE";
        //小程序租赁流程视频
        public static final String RENT_TIPS_VIDEO = "RENT_TIPS_VIDEO";
        //租赁须知
        public static final String LEASE_NOTICE = "LEASE_NOTICE";
        //租赁须知图片
        public static final String LEASE_NOTICE_URL = "LEASE_NOTICE_URL";
        //押金
        public static final String RENT_DEPOSIT = "RENT_DEPOSIT";
        //电车临停自动关锁时长(分钟)
        public static final String PAUSE_AUTO_CLOSE_TIME = "PAUSE_AUTO_CLOSE_TIME";
 
        //温馨提示
        public static final String TIPS = "TIPS";
        //温馨提示
        public static final String RENT_NOTICE = "RENT_NOTICE";
        //小程序停止服务提示
        public static final String STOP_SERVE_TIPS = "STOP_SERVE_TIPS";
        //小程序是否停止服务 0否 1是
        public static final String IS_STOP_SERVE = "IS_STOP_SERVE";
        //小程序停止开始时间
        public static final String STOP_SERVE_STARTTIME = "STOP_SERVE_STARTTIME";
        //小程序停止结束时间
        public static final String STOP_SERVE_ENDTIME = "STOP_SERVE_ENDTIME";
        //小程序每日服务开始时间
        public static final String BUSINESS_STARTTIME = "BUSINESS_STARTTIME";
        //小程序每日服务结束时间
        public static final String BUSINESS_ENDTIME = "BUSINESS_ENDTIME";
        //电车二维码前缀
        public static final String ELECTRICITY_PREFIX = "ELECTRICITY_PREFIX";
 
        //钉钉通知地址
        public static final String DINGDING_URL = "DINGDING_URL";
        //钉钉签名
 
        //小程序满载预警(%)最大值
        public static final String WARN_MAX = "WARN_MAX";
        //小程序满载预警(%)最小值
        public static final String WARN_MIN = "WARN_MIN";
 
 
        public static final String FILES_DIR = "FILES_DIR";
        public static final String SCRATCH_REDIRECT_URL = "SCRATCH_REDIRECT_URL";
        public static final Integer ZERO = 0;
        public static final Integer ONE = 1;
        public static final Integer TWO = 2;
        public static final Integer THREE = 3;
 
        public static int formatIntegerNum(Integer num) {
            if (num == null) {
                return 0;
            }
            return num;
        }
        public static Integer formatIntegerFromStr(String num) {
            try {
                return  Integer.parseInt(num);
            }catch (Exception e){
 
            }
            return null;
        }
 
        public interface UserActionsType {
            String cancelPrePay = "CANCEL_PRE_PAY";
 
            //订单结算订单
            String close = "CLOSE";
            String forceRefund = "FORCE_REFUND";
            String login = "LOGIN";
            String pay = "PAY";
            String preForceRefund = "PRE_FORCE_REFUND";
            String prePay = "PRE_PAY";
            String preRefund = "PRE_REFUND";
            String refund = "REFUND";
            String register = "REGISTER";
            String rent = "RENT";
        }
 
        public interface ActionLogObjType {
            int memberrides =0;//骑行记录
 
        }
 
        public enum ACTIONLOG_TYPE{
            //  0骑行记录
            FORCE_BACK(0,"强制还车","后台强制还车"),
            UPDATE_DURATION(1,"修改骑行时长","后台修改骑行时长")
            ;
            String name;
 
            Integer key;
 
            String info;
 
            ACTIONLOG_TYPE(Integer key,String name,  String info) {
                this.name = name;
                this.key = key;
                this.info = info;
            }
 
            public String getName() {
                return name;
            }
 
            public void setName(String name) {
                this.name = name;
            }
 
            public Integer getKey() {
                return key;
            }
 
            public void setKey(Integer key) {
                this.key = key;
            }
 
            public String getInfo() {
                return info;
            }
 
            public void setInfo(String info) {
                this.info = info;
            }
        }
        public enum GOODSORDER_STATUS{
            //            0待支付 1已支付 2已取消 3支付失败 4已结算
            UN_PAY("待支付", 0,"待支付"),
 
            HAVING_PAY("已支付", 1,"已支付"),
 
            CANCEL("已取消", 2,"已取消"),
 
            PAY_FAILURE("支付失败", 3,"支付失败"),
 
            CLOSE("已结算", 4,"已结算"),
            ;
            String name;
 
            Integer key;
 
            String info;
 
            GOODSORDER_STATUS(String name, Integer key, String info) {
                this.name = name;
                this.key = key;
                this.info = info;
            }
 
            public String getName() {
                return name;
            }
 
            public void setName(String name) {
                this.name = name;
            }
 
            public Integer getKey() {
                return key;
            }
 
            public void setKey(Integer key) {
                this.key = key;
            }
 
            public String getInfo() {
                return info;
            }
 
            public void setInfo(String info) {
                this.info = info;
            }
        }
 
    public enum REFUND_TYPE{
        // '退款类型 0用户结算退款 1平台自动结算退款 2强制结算退款 3结算后退款'
        NORMAL(  0,"用户结算退款","结算退押金"),
 
        PLAT_AUTO( 1,"平台自动结算退款","平台退押金"),
 
        PLAT_FORCE( 2,"强制结算退款","平台退押金"),
 
        BACK( 3,"结算后退款","平台退款"),
 
        ;
        String name;
 
        Integer key;
 
        String info;
 
 
        REFUND_TYPE(Integer key,String name, String info) {
            this.name = name;
            this.key = key;
            this.info = info;
        }
 
        public static REFUND_TYPE get(int key) {
            REFUND_TYPE[] values = REFUND_TYPE.values();
            for (REFUND_TYPE object : values) {
                if (object.key == key) {
                    return object;
                }
            }
            return null;
        }
        public String getName() {
            return name;
        }
 
        public void setName(String name) {
            this.name = name;
        }
 
        public Integer getKey() {
            return key;
        }
 
        public void setKey(Integer key) {
            this.key = key;
        }
 
        public String getInfo() {
            return info;
        }
 
        public void setInfo(String info) {
            this.info = info;
        }
    }
        public enum MEMBER_RIDES_STATUS{
//            0请求开锁中 1骑行中 2已还车  3开锁失败
            LOCKING("请求开锁中", 0,"请求开锁中"),
 
            RIDES_RUNNING("骑行中", 1,"骑行中"),
 
            BACK_CYCLING("已还车", 2,"已还车"),
 
            LOCKING_DEFEAT("开锁失败", 3,"开锁失败"),
            RIDES_PAUSING("临停中", 4,"临停中")
            ;
            String name;
 
            Integer key;
 
            String info;
 
            MEMBER_RIDES_STATUS(String name, Integer key, String info) {
                this.name = name;
                this.key = key;
                this.info = info;
            }
 
            public String getName() {
                return name;
            }
 
            public void setName(String name) {
                this.name = name;
            }
 
            public Integer getKey() {
                return key;
            }
 
            public void setKey(Integer key) {
                this.key = key;
            }
 
            public String getInfo() {
                return info;
            }
 
            public void setInfo(String info) {
                this.info = info;
            }
        }
        public static BigDecimal formatDecimalNum(BigDecimal num) {
            if (num == null) {
                return new BigDecimal(0);
            }
            return num;
        }
 
        public static int compareBigdecimal(BigDecimal num, BigDecimal num2) {
            if (num == null) {
                num = new BigDecimal(0);
            }
            if (num2 == null) {
                num2 = new BigDecimal(0);
            }
            if (num.compareTo(num2) == 1) {
                return 1;
            } else if (num.compareTo(num2) == -1) {
                return -1;
            }
            return 0;
        }
        public static long formatLongNum(Long num) {
            if (num == null) {
                return 0;
            }
            return num;
        }
        public static String formatImgPath(String avatar, String imgPath) {
            if (StringUtils.isBlank(avatar)) {
                return null;
            }
            return imgPath + avatar;
        }
        public static String getIpAddr(HttpServletRequest request) {
            String ipAddress = request.getHeader("x-forwarded-for");
            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
                ipAddress = request.getHeader("Proxy-Client-IP");
            }
            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
                ipAddress = request.getHeader("WL-Proxy-Client-IP");
            }
            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
                ipAddress = request.getRemoteAddr();
                String localIp = "127.0.0.1";
                String localIpv6 = "0:0:0:0:0:0:0:1";
                if (ipAddress.equals(localIp) || ipAddress.equals(localIpv6)) {
                    // 根据网卡取本机配置的IP
                    InetAddress inet = null;
                    try {
                        inet = InetAddress.getLocalHost();
                        ipAddress = inet.getHostAddress();
                    } catch (UnknownHostException e) {
                        e.printStackTrace();
                    }
                }
            }
            // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
            String ipSeparate = ",";
            int ipLength = 15;
            if (ipAddress != null && ipAddress.length() > ipLength) {
                if (ipAddress.indexOf(ipSeparate) > 0) {
                    ipAddress = ipAddress.substring(0, ipAddress.indexOf(ipSeparate));
                }
            }
            return ipAddress;
        }
 
        public static String getSHA256Str(String str) {
            MessageDigest messageDigest;
            String encdeStr = "";
            try {
                messageDigest = MessageDigest.getInstance("SHA-256");
                byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
                encdeStr = Hex.encodeHexString(hash);
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            return encdeStr;
        }
 
        public static String trimEndSpaceStr(String outPut) {
            String newOutPut = "";
            if (StringUtils.isNotBlank(outPut)) {
                String[] ostrs = outPut.split("\n");
                for (String str : ostrs) {
                    String text = str.replace("\n", "").replaceAll("\\s+$", "");
                    newOutPut += text + "\n";
 
                }
                if (newOutPut.endsWith("\n")) {
                    newOutPut = newOutPut.substring(0, newOutPut.length() - 1);
                }
            }
            return newOutPut;
        }
 
        public static String delHTMLTag(String htmlStr) {
            if (StringUtils.isBlank(htmlStr)) {
                return "";
            }
            String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
            String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
            String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
 
            Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
            Matcher m_script = p_script.matcher(htmlStr);
            htmlStr = m_script.replaceAll(""); // 过滤script标签
 
            Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
            Matcher m_style = p_style.matcher(htmlStr);
            htmlStr = m_style.replaceAll(""); // 过滤style标签
 
            Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
            Matcher m_html = p_html.matcher(htmlStr);
            htmlStr = m_html.replaceAll(""); // 过滤html标签
 
            htmlStr = htmlStr.replace("&nbsp;&nbsp;", "&nbsp;"); // 过滤空格标签
            htmlStr = htmlStr.replace("&nbsp;", " "); // 过滤空格标签
 
            return htmlStr.trim(); // 返回文本字符串
        }
 
 
        public static List<String> checkUUID(String checkValue) {
            String[] str = checkValue.split(",");
            List<String> strList = new ArrayList<>();
            for (String s : str) {
                try {
                    String uuid = UUID.fromString(s).toString();
                    strList.add(uuid);
                    //do something
                } catch (IllegalArgumentException exception) {
                    continue;
                }
            }
            return strList;
        }
 
 
        public static BigDecimal translateMoney(BigDecimal money){
            return  Constants.formatDecimalNum(money).divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP);
 
        }
 
 
}