diff --git a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java index eac0e7d..f649617 100644 --- a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java +++ b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java @@ -352,4 +352,15 @@ public class RedisKeys { public static String getAllDeptCodeOptionKey() { return rootPrefix.concat("options:dept:code:kc"); } + + /** + * @param fileName + * @Author: makunhua + * @Note: 获取导入人员信息文件名key + * @Date: 16:32 2022/3/1 + * @Modified by: + */ + public static String getFileName4Import(String fileName) { + return rootPrefix.concat("user:info:import").concat(fileName); + } } diff --git a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/CoordinatesUtils.java b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/CoordinatesUtils.java new file mode 100644 index 0000000..2b4467d --- /dev/null +++ b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/CoordinatesUtils.java @@ -0,0 +1,71 @@ +package com.elink.esua.epdc.commons.tools.utils; + +/** + * @program: pingyin-personal + * @description: 坐标转换工具 + * @author: wangtong + * @create: 2022-04-26 11:48 + **/ +public class CoordinatesUtils { + + public static double pi = 3.1415926535897932384626; + public static double a = 6378245.0; + public static double ee = 0.00669342162296594323; + + /** + * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return + * lat:纬度 + * lon:经度 + * */ + public static double[] gcj02_To_Gps84(double lat, double lon) { + double[] gps = transform(lat, lon); + double lontitude = lon * 2 - gps[1]; + double latitude = lat * 2 - gps[0]; + return new double[] { latitude, lontitude }; + } + + public static double transformLat(double x, double y) { + double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + + 0.2 * Math.sqrt(Math.abs(x)); + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; + ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; + return ret; + } + + public static double transformLon(double x, double y) { + double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 + * Math.sqrt(Math.abs(x)); + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; + ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 + * pi)) * 2.0 / 3.0; + return ret; + } + + public static double[] transform(double lat, double lon) { + if (outOfChina(lat, lon)) { + return new double[] { lat, lon }; + } + double dLat = transformLat(lon - 105.0, lat - 35.0); + double dLon = transformLon(lon - 105.0, lat - 35.0); + double radLat = lat / 180.0 * pi; + double magic = Math.sin(radLat); + magic = 1 - ee * magic * magic; + double sqrtMagic = Math.sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); + double mgLat = lat + dLat; + double mgLon = lon + dLon; + return new double[] { mgLat, mgLon }; + } + + public static boolean outOfChina(double lat, double lon) { + if (lon < 72.004 || lon > 137.8347) + return true; + if (lat < 0.8293 || lat > 55.8271) + return true; + return false; + } + +} diff --git a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java index 1841987..21671b3 100644 --- a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java +++ b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java @@ -30,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; @@ -364,4 +365,32 @@ public class ExcelUtils { sheet.addValidationData(dataValidation); } + + /** + * 删除文件夹(强制删除) + * + * @param path + */ + public static void deleteAllFilesOfDir(File path) { + if (null != path) { + if (!path.exists()) { + return; + } + if (path.isFile()) { + boolean result = path.delete(); + int tryCount = 0; + while (!result && tryCount++ < 10) { + System.gc(); // 回收资源 + result = path.delete(); + } + } + File[] files = path.listFiles(); + if (null != files) { + for (int i = 0; i < files.length; i++) { + deleteAllFilesOfDir(files[i]); + } + } + path.delete(); + } + } } diff --git a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/IdentityNoUtils.java b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/IdentityNoUtils.java index 0d48190..cbfff1a 100644 --- a/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/IdentityNoUtils.java +++ b/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/IdentityNoUtils.java @@ -45,6 +45,20 @@ public class IdentityNoUtils implements Serializable { */ private final static int[] VERIFY_CODE_WEIGHT = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; + /** + * 手机格式校验 + */ + private static final Pattern PHONE_PATTERN = Pattern.compile("^[1]\\d{10}$"); + + /** + * 手机格式校验,验证带区号的:3-4位区号,5-8位号码 + */ + private static final Pattern PHONE_PATTERN_A = Pattern.compile("^[0][0-9]{2,3}-[0-9]{5,8}$"); + /** + * 手机格式校验,验证没有区号的:,5-8位号码 + */ + private static final Pattern PHONE_PATTERN_B = Pattern.compile("^[1-9]{1}[0-9]{4,7}$"); + /** * 根据身份证号获取性别 0女;1男 * @@ -352,4 +366,34 @@ public class IdentityNoUtils implements Serializable { } } + /** + * 正则:手机号(简单), 1字头+10位数字即可.(批量插入专用) + * + * @param in + * @return + */ + public static boolean validateMobilePhone(String in) { + if (StringUtils.isBlank(in)) { + return false; + } + boolean isPhone = false; + isPhone = PHONE_PATTERN.matcher(in).matches(); + if (!isPhone) {//座机号码校验 + Matcher m = null; + + if (in.length() > 9) { + // 验证带区号的:3-4位区号,5-8位号码 + m = PHONE_PATTERN_A.matcher(in); + isPhone = m.matches(); + } else { + // 验证没有区号的:,5-8位号码 + m = PHONE_PATTERN_B.matcher(in); + isPhone = m.matches(); + } + return isPhone; + } else { + return isPhone; + } + } + }