Forráskód Böngészése

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/main/java/com/ywt/biz/common/util/DateUtil.java
liyang 1 éve
szülő
commit
e7d62a1a65

+ 8 - 1
src/main/java/com/ywt/biz/common/enums/OrderTypeEnum.java

@@ -15,7 +15,14 @@ public enum OrderTypeEnum {
     MARKETING("健康教育", 9),           //医生推广费
     TREATMENT_REPORT("远程会诊报告", 10),
     PRESCRIPTION("处方单", 11),
-    MED_FIELD_ARTICLE("医学界文章", 12);
+    MED_FIELD_ARTICLE("医学界文章", 12),
+    OFFLINE_CONSULT("线下就诊", 13),
+    Deposit("住院押金充值", 14),
+    CheckUp("体检缴费", 15),
+    NAT("核酸检测", 16),
+    MED_EQUIP("医疗设备检查订单", 17),
+    GLASSES("眼镜店", 18),
+    MedicalRecordMailing("病例邮寄订单", 19);
 
     private final String displayName;
 

+ 134 - 0
src/main/java/com/ywt/biz/common/enums/TerminalEnum.java

@@ -0,0 +1,134 @@
+package com.ywt.biz.common.enums;
+
+/**
+ * 终端类型
+ * @author
+ */
+public enum TerminalEnum {
+    /**
+     * 未知
+     */
+    UNKNOWN("未知", 0),
+    PatientWxApp("微信小程序患者版", 1), // 支付助手
+    PatientWxOfficial("微信公众号患者版", 2),
+    DoctorAndroid("安卓医生版", 3),
+    DoctorIOS("苹果医生版", 4),
+    PatientAndroid("安卓患者版", 5),
+    PatientIOS("苹果患者版", 6),
+    DoctorWxOfficial("微信公众号医生版", 7),
+    TaiheWxOfficial("太和医院公众号", 8),
+    NfHealth("南方大健康", 9),
+    TAI_HE_OFFICIAL("太和医院官网", 10),
+    TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM("太和互联网医院患者端小程序版", 11),
+    TAI_HE_INTERNET_HOSPITAL_PATIENT_WX_OFFICIAL("太和互联网医院患者端公众号版", 12),
+    TAI_HE_INTERNET_HOSPITAL_DOCTOR_WX_OFFICIAL("太和互联网医院医生端公众号版", 13),
+    GD_YWT_WX_OFFICIAL("广东医务通公众号", 14),
+    PRESCRIPTION_SYSTEM_PC("处方系统PC端", 15),
+    DOCTOR_MINI_PROGRAM("医生端小程序", 16),
+    /**
+     * 医生端小程序内嵌H5页面,
+     * 接口路径前缀为:thnetdocexapi
+     * 接口地址如:https://m-qa.ywtinfo.com/thnetdocexapi/account/doctor
+     */
+    DOCTOR_H5("医生端H5", 17),
+    YWT_CLOUD_PLATFORM_PATIENT_MINI_PROGRAM("医务通云平台患者端小程序版", 18),
+    NFYYBYFY_WXAPP("南方医院白云分院小程序", 20),
+    NFYYBYFY_WX_OFFICIAL("南方医院白云分院公众号", 21),
+    NFYYBYFY_DOC_WX_OFFICIAL("南方医院白云分院医生版公众号", 22),
+    NFYYBYFY_ALIPAY_MP("南方医院白云分院支付宝小程序", 24),
+    TH_ALIPAY_MP("南方医院太和分院支付宝小程序", 25),
+    EXPERTS_STUDIO_WX_MP("专家工作室微信小程序", 26),
+
+    ;
+
+    private final String displayName;
+
+    private final int value;
+
+    TerminalEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+
+    public static TerminalEnum valueOf(int value) {
+        for (TerminalEnum terminalEnum : TerminalEnum.values()) {
+            if (terminalEnum.getValue() == value) {
+                return terminalEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+
+    public static boolean isDoctorTerminal(int terminal) {
+        for (TerminalEnum terminalEnum : getDoctorTerminal()) {
+            if (terminalEnum.getValue() == terminal) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断终端是否是患者版
+     *
+     * @param terminal 终端
+     * @return ture or fasle
+     */
+    public static boolean isPatientTerminal(int terminal) {
+        for (TerminalEnum terminalEnum : getPatientTerminals()) {
+            if (terminalEnum.getValue() == terminal) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 患者版终端
+     */
+    public static TerminalEnum[] getPatientTerminals() {
+        return new TerminalEnum[]{
+                PatientAndroid,
+                PatientIOS,
+                PatientWxApp,
+                PatientWxOfficial,
+                TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM,
+                TAI_HE_INTERNET_HOSPITAL_PATIENT_WX_OFFICIAL
+        };
+    }
+
+    /**
+     * 医生终端
+     *
+     * @return
+     */
+    public static TerminalEnum[] getDoctorTerminal() {
+        return new TerminalEnum[]{
+                DoctorAndroid,
+                DoctorIOS,
+                DoctorWxOfficial,
+                TAI_HE_INTERNET_HOSPITAL_DOCTOR_WX_OFFICIAL,
+                PRESCRIPTION_SYSTEM_PC,
+                DOCTOR_MINI_PROGRAM,
+                NFYYBYFY_DOC_WX_OFFICIAL,
+        };
+    }
+
+    public static TerminalEnum getTerminalEnum(int type) {
+        for (TerminalEnum terminalEnum : TerminalEnum.values()) {
+            if (terminalEnum.value == type) {
+                return terminalEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 11 - 4
src/main/java/com/ywt/biz/common/util/DateUtil.java

@@ -15,6 +15,16 @@ public class DateUtil {
 
     private static final String[] WEEK_DAYS_MIDDLE = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
 
+    public static final String DADE_FROMAT_YMD = "yyyy-MM-dd";
+
+    public static final String DADE_FROMAT_YMDHMS = "yyyy-MM-dd HH:mm:ss";
+
+    public static final String DADE_FROMAT_CYMD = "yyyy年M月d日";
+
+    public static final String DADE_FROMAT_CYMDHM = "yyyy年M月d日 HH:mm";
+
+
+
     /**
      * 将时间戳转换成日期字符串格式
      * @param timestamp 时间戳
@@ -223,11 +233,8 @@ public class DateUtil {
      */
     public static String convertTimestampToDateString(long timestamp) {
         Date date = new Date(timestamp);
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat sdf = new SimpleDateFormat(DADE_FROMAT_YMDHMS);
         return sdf.format(date);
     }
 
-
-
-
 }

+ 99 - 23
src/main/java/com/ywt/biz/common/util/StringHelper.java

@@ -1,5 +1,7 @@
 package com.ywt.biz.common.util;
 
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -11,11 +13,6 @@ public class StringHelper {
     public static final String scriptReg = "<script[\\s\\S]+?</script>";
     public static final String iframeReg = "<iframe[\\s\\S]+?</iframe>";
 
-    /**
-     * 非负整数正则表达式
-     */
-    private static final String NON_NEGATIVE_INTEGER_REGEX = "^\\d+$";
-
     public static String clearHtmlTag(String content) {
         if (!isNullOrEmpty(content)) {
             content = clearSpecialContent(content, scriptReg);
@@ -48,7 +45,7 @@ public class StringHelper {
         return sourceStr;
     }
 
-    public static String substringContent(String sourceStr, String regexExp, int flags){
+    public static String substringContent(String sourceStr, String regexExp, int flags) {
         Pattern pattern = Pattern.compile(regexExp, flags);
         Matcher matcher = pattern.matcher(sourceStr);
         return matcher.find() ? matcher.group() : "";
@@ -60,26 +57,25 @@ public class StringHelper {
 
     /**
      * 判断传入的value是null还是空白的字符串
+     *
      * @param value
      * @return
      */
-    public static boolean isNullOrWhiteSpace(String value){
-        return value == null || "".equals(value)||"".equals(value.trim());
+    public static boolean isNullOrWhiteSpace(String value) {
+        return value == null || "".equals(value) || "".equals(value.trim());
     }
 
 
     /**
      * 转半角的函数
+     *
      * @param value 任意字符串
      * @return 半角字符串
      */
-    public static String toDBC(String value)
-    {
+    public static String toDBC(String value) {
         char[] c = value.toCharArray();
-        for (int i = 0; i < c.length; i++)
-        {
-            if (c[i] == 12288)
-            {
+        for (int i = 0; i < c.length; i++) {
+            if (c[i] == 12288) {
                 c[i] = (char) 32;
                 continue;
             }
@@ -91,17 +87,18 @@ public class StringHelper {
 
     /**
      * 获取没有连字号的UUID
+     *
      * @return
      */
-    public static String getUUIDWithoutHyphen(){
+    public static String getUUIDWithoutHyphen() {
         return UUID.randomUUID().toString().replaceAll("-", "");
     }
 
-    public static String trimStart(String source, char element){
+    public static String trimStart(String source, char element) {
 //        source.replaceFirst()
         boolean beginIndexFlag = true;
         boolean endIndexFlag = true;
-        do{
+        do {
             int beginIndex = source.indexOf(element) == 0 ? 1 : 0;
             int endIndex = source.lastIndexOf(element) + 1 == source.length() ? source.lastIndexOf(element) : source.length();
             source = source.substring(beginIndex, endIndex);
@@ -111,6 +108,20 @@ public class StringHelper {
         return source;
     }
 
+    /**
+     * 过滤emoji表情
+     *
+     * @param source
+     * @return 过滤后的字符串
+     */
+    public static String filterEmoji(String source) {
+        if (isNullOrWhiteSpace(source)) {
+            return source;
+        }
+
+        return source.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "");
+    }
+
     public static String toString(Object obj, String defaultValue) {
         return obj != null ? obj.toString() : defaultValue;
     }
@@ -120,14 +131,79 @@ public class StringHelper {
     }
 
     /**
-     * 判断字符串是否为非负整数
+     * 生成32位md5码
      *
-     * @param str
+     * @param text
      * @return
      */
-    public static boolean isNonNegativeInteger(String str) {
-        Pattern pattern = Pattern.compile(NON_NEGATIVE_INTEGER_REGEX);
-        Matcher matcher = pattern.matcher(str);
-        return matcher.matches();
+    public static String md5(String text) {
+        StringBuilder builder = new StringBuilder();
+
+        try {
+            MessageDigest digest = MessageDigest.getInstance("md5");
+            byte[] result = digest.digest(text.getBytes());
+
+            for (byte b : result) {
+                int number = b & 0xff;
+                String str = Integer.toHexString(number);
+                if (str.length() == 1) {
+                    builder.append("0");
+                }
+                builder.append(str);
+            }
+
+        } catch (NoSuchAlgorithmException e) {
+
+        }
+
+        return builder.toString();
     }
+
+    public static String padLeft(String str, int totalWidth, char paddingChar) {
+        if (str == null || str.length() >= totalWidth) {
+            return str;
+        }
+
+        StringBuilder result = new StringBuilder(totalWidth);
+        int len = totalWidth - str.length();
+        for (; len > 0; len--) {
+            result.append(paddingChar);
+        }
+        result.append(str);
+//        } else {
+//            result.append(source);
+//            for (; len > 0; len--) {
+//                result.append(fillChar);
+//            }
+//        }
+        return result.toString();
+    }
+
+    /**
+     * 超出的字符用省略号处理
+     *
+     * @param str 字符串
+     * @param num 处理长度(超过这个长度之后才进行处理,并且最后三个长度用 '...' 来替代)
+     * @return 处理后的字符串
+     */
+    public static String dealStringWithEllipsis(String str, int num) {
+        if (Checker.isNone(str) || str.trim().length() == 0) {
+            return "";
+        }
+        if (str.length() > num) {
+            str = str.substring(0, num-3).concat("...");
+        }
+        return str;
+    }
+
+    /**
+     * 超出的字符用省略号处理(长度超过20后进行处理,并且最后三个长度用 '...' 来替代)
+     *
+     * @param str 字符串
+     * @return 处理后的字符串
+     */
+    public static String dealStringWithEllipsis(String str) {
+        return dealStringWithEllipsis(str,20);
+    }
+
 }