|
@@ -8,10 +8,10 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
import com.google.zxing.common.BitMatrix;
|
|
import com.google.zxing.common.BitMatrix;
|
|
|
import com.google.zxing.qrcode.QRCodeWriter;
|
|
import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
|
|
import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
|
|
|
-import com.zhongshu.card.client.utils.DateUtils;
|
|
|
|
|
-import com.zhongshu.card.client.utils.ITree;
|
|
|
|
|
import com.zhongshu.card.client.type.Sex;
|
|
import com.zhongshu.card.client.type.Sex;
|
|
|
import com.zhongshu.card.client.type.school.CardType;
|
|
import com.zhongshu.card.client.type.school.CardType;
|
|
|
|
|
+import com.zhongshu.card.client.utils.DateUtils;
|
|
|
|
|
+import com.zhongshu.card.client.utils.ITree;
|
|
|
import com.zhongshu.card.server.core.domain.base.SuperMain;
|
|
import com.zhongshu.card.server.core.domain.base.SuperMain;
|
|
|
import com.zhongshu.card.server.core.util.exception.BusinessException;
|
|
import com.zhongshu.card.server.core.util.exception.BusinessException;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
@@ -566,6 +566,12 @@ public class CommonUtil {
|
|
|
return param;
|
|
return param;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 取电话号码后4位 ,如:18723497100 -> 7100
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param phone
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
public static String getPhoneLast4(String phone) {
|
|
public static String getPhoneLast4(String phone) {
|
|
|
if (StringUtils.isNotEmpty(phone) && phone.length() >= 4) {
|
|
if (StringUtils.isNotEmpty(phone) && phone.length() >= 4) {
|
|
|
int len = phone.length();
|
|
int len = phone.length();
|
|
@@ -574,4 +580,88 @@ public class CommonUtil {
|
|
|
return phone;
|
|
return phone;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手机号码脱敏,如:18723497100 -> 187****7100
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param phone
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String turnPhoneDesen(String phone) {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(phone) && phone.length() == 11) {
|
|
|
|
|
+ return phone.substring(0, 3) + "****" + phone.substring(7, 11);
|
|
|
|
|
+ }
|
|
|
|
|
+ return phone;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 名字脱敏,如:张三 -> 张*
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param name
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String turnNameDesen(String name) {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(name) && name.length() > 1) {
|
|
|
|
|
+ if (name.length() == 2) {
|
|
|
|
|
+ return name.substring(0, 1) + "*";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return String.format("%s*%s", name.substring(0, 1), name.substring((name.length() - 1), name.length()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 身份证脱敏显示
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param idCardNo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String idCardDesen(String idCardNo) {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(idCardNo) && idCardNo.length() == 18) {
|
|
|
|
|
+ return idCardNo.substring(0, 6) + "****" + idCardNo.substring(12, 18);
|
|
|
|
|
+ }
|
|
|
|
|
+ return idCardNo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计算环比,如:83.2 (最多保留2未小数)
|
|
|
|
|
+ * `
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param currentNumber 当期的值
|
|
|
|
|
+ * @param preNumber 上期的值
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public BigDecimal chainScale(Long currentNumber, Long preNumber) {
|
|
|
|
|
+ BigDecimal number = BigDecimal.ZERO;
|
|
|
|
|
+ if (currentNumber != null) {
|
|
|
|
|
+ if (preNumber == null || preNumber == 0) {
|
|
|
|
|
+ number = BigDecimal.valueOf(100);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ number = BigDecimal.valueOf(((currentNumber - preNumber) * 100)).divide(new BigDecimal(preNumber), 2, RoundingMode.HALF_UP).stripTrailingZeros();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return number;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计算比例 (最多保留2位小数)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param number
|
|
|
|
|
+ * @param totalNumber
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static BigDecimal countScale(Long number, Long totalNumber) {
|
|
|
|
|
+ if (number != null && totalNumber != null && totalNumber > 0) {
|
|
|
|
|
+ return countScale(BigDecimal.valueOf(number), BigDecimal.valueOf(totalNumber));
|
|
|
|
|
+ }
|
|
|
|
|
+ return BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static BigDecimal countScale(BigDecimal number, BigDecimal totalNumber) {
|
|
|
|
|
+ if (number != null && totalNumber.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ return number.multiply(BigDecimal.valueOf(100)).divide(totalNumber, 2, RoundingMode.HALF_UP).stripTrailingZeros();
|
|
|
|
|
+ }
|
|
|
|
|
+ return BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|