charIndex = new ArrayList<>();
- while (value > 0) {
- charIndex.add(value % 62);
- value = value / 62;
- }
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = charIndex.size() - 1; i >= 0; i--) {
- stringBuilder.append(chars[charIndex.get(i)]);
- }
- return stringBuilder.toString();
- }
-
- //base62转为正整数
- static int fromBase62(String base62) {
- if (StringUtils.isEmpty(base62)) {
- return 0;
- }
- int value = 0;
- int index;
- for (int i = 0; i < base62.length(); i++) {
- index = Arrays.binarySearch(chars, base62.charAt(i));
- value += (index * (Math.pow(62, base62.length() - i - 1)));
- }
- return value;
- }
-
- //*设置redis,缓存经纬度对应的地址
- // * @param str ingRedis Template s tringRedis Temp7ate
- public static void setRedis(StringRedisTemplate stringRedisTemplate) {
- AddressUtils.stringRedisTemplate = stringRedisTemplate;
- }
-
- //设置redis,缓存经纬度对应的地址
- // @param ip
- // redis
- // @param port
- // redis
- // @param db
- // redis. db index
- //@param password E#
- public static void setRedis(String ip, Integer port, Integer db, String password) {
- RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
- configuration.setHostName(ip);
- configuration.setPort(port);
- configuration.setDatabase(db);
- configuration.setPassword(password);
- GenericObjectPoolConfig config = new GenericObjectPoolConfig();
- LettuceClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder().poolConfig(config).build();
- LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(configuration, clientConfiguration);
- lettuceConnectionFactory.afterPropertiesSet();
- AddressUtils.stringRedisTemplate = new StringRedisTemplate(lettuceConnectionFactory);
- }
-
- //设置精度(米) ,默认5米,可选范围1-50米
- // 注意:多系统共用一个redis库存储地址精度最好相同 ,才能更容易 命中缓存
- //精度值越大,通过经纬度获取的地址越不准磅,但redis缓存数据空间越小
- //
-//0.00001的经纬度对应精度为1米(实际最大1.1米) , 0. 00005精度5米
- // 精度转换公式: ((int)经纬度a *100000)/精度p *精度p
- // @param precision #ß (Ж)
- public static void setPrecision(int precision) {
- if (precision < 1 || precision > 50) {
- throw new IllegalArgumentException("precision 超出值范围1-50");
- }
- AddressUtils.precision = precision;
- }
-
- // 通过经纬度获取地址的请求URL,并包含经纬度占位符{ 7ongi tude}和{7ati tude}
- //有ak要求的URL需带上ak
-//49 : http:l/ip:port/geocoder/api/v1 geocoding inverse?ak XXX& locat ion=l longi tude], [lati tude]&xx=xx
- // @param addressRequestUr 7 tbtt i#*ur7
- public static void setAddressRequestUrl(String addressRequestUrl) {
- AddressUtils.addressRequestUrl = addressRequestUrl;
- }
-
- //调用次数
- public static long getInvokeTimes() {
- return invokeTimes.get();
- }
-
- //命中缓存次数
- public static long getHitTimes() {
- return hitTimes.get();
- }
-
- //新增缓存数
- public static long getCacheItemCount() {
- return cacheItemCount.get();
- }
-
- //获取redis地址缓存数量限制值,默认5千万
- public static int getMaxCacheCount() {
- return maxCacheCount;
- }
-
- public static void setMaxCacheCount(int maxCacheCount) {
- AddressUtils.maxCacheCount = maxCacheCount;
- }
-
- //设置geo服务器每分钟调用限流次数,1标示不限流,默认限流
- public static void setGeoServerRequestLimitPerMin(int geoServerRequestLimitPerMin) {
- AddressUtils.geoServerRequestLimitPerMin = geoServerRequestLimitPerMin;
- }
-}
-
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/ConvertUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/ConvertUtils.java
deleted file mode 100644
index 8de4747..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/ConvertUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import org.springframework.util.StringUtils;
-
-public class ConvertUtils {
-
- public static Integer toInteger(String text, Integer defaultValue) {
- if (!StringUtils.hasText(text)) {
- return defaultValue;
- }
- try {
- return Integer.parseInt(text);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- public static Long toLong(String text, Long defaultValue) {
- if (!StringUtils.hasText(text)) {
- return defaultValue;
- }
- try {
- return Long.parseLong(text);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- public static Double toDouble(String text, Double defaultValue) {
- if (!StringUtils.hasText(text)) {
- return defaultValue;
- }
- try {
- return Double.parseDouble(text);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- //TRUE、 Y. 1转为true (忽略大小写),其他的为false
- public static boolean toBoolean(Object obj) {
- return obj != null && (" true".equalsIgnoreCase(obj.toString()) || "Y".equalsIgnoreCase(obj.toString()) || "1".equalsIgnoreCase(obj.toString()));
- }
-
- //是否可转为int类型
- public static boolean isInt(Object value) {
- try {
- Integer.valueOf(value.toString());
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/DateTimeUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/DateTimeUtils.java
deleted file mode 100644
index 4045883..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/DateTimeUtils.java
+++ /dev/null
@@ -1,224 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import com.docus.api.prototype.web.response.ApiException;
-import com.docus.api.prototype.web.response.ExceptionCode;
-import com.docus.api.prototype.utils.enums.DateTypeEnum;
-import org.springframework.util.StringUtils;
-
-import java.time.*;
-import java.time.format.DateTimeFormatter;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.TimeZone;
-
-//时间工具类
-public class DateTimeUtils {
-
- //时间格式化yyyy-MM-dd
- public static String dateDisplay(LocalDateTime dateTime) {
- if (dateTime == null) {
- return null;
- }
- return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
- }
-
- //时间格式化yyyy-MM-dd HH:mm:ss
- public static String dateTimeDisplay(LocalDateTime dateTime) {
- if (dateTime == null) {
- return null;
- }
- return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
- }
-
- public static String format(LocalDateTime dateTime, String pattern) {
- return dateTime.format(DateTimeFormatter.ofPattern(pattern));
- }
-
- //long毫秒转成localdatetime
- public static LocalDateTime formatTime(long time) {
- return LocalDateTime.ofInstant(Instant.ofEpochMilli(time), TimeZone.getDefault().toZoneId());
- }
-
- //localdatetime转成long毫秒
- public static long toTime(LocalDateTime dateTime) {
- return dateTime.toInstant(OffsetDateTime.now().getOffset()).toEpochMilli();
- }
-
- //字符串转localdatetime
- public static LocalDateTime toLocalDateTime(String str) {
- if (!StringUtils.hasText(str)) {
- return null;
- }
- if (str.contains("T")) {
- if (str.contains("+")) {
- //1 2017-12-22708:09: 15.9467651+08:00
- DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
- return LocalDateTime.parse(str, formatter);
- } else {
- //1/2018- 11-29T07:09:51.775Z
- DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
- return LocalDateTime.parse(str, formatter);
- }
- }
- str = str.replaceAll("[-/\\._: ]", "");
- if (str.length() == 8) {
- LocalDate date = toLocalDate(str);
- return date == null ? null : date.atTime(0, 0);
-
- } else if (str.length() == 14) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern(" yyyyMMddHHmmss");
- return LocalDateTime.parse(str, formatter);
- } else if (str.length() == 17) {
- //带亳秒的没点号会出错,手动加点号
- str = str.substring(0, 14) + "." + str.substring(14);
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss.SSS");
- return LocalDateTime.parse(str, formatter);
- }
- throw new IllegalArgumentException(str + " could : not : parse to LocalDateTime");
- }
-
- public static LocalDate toLocalDate(String str) {
- if (!StringUtils.hasText(str)) {
- return null;
- }
- if (str.length() >= 8) {
- str = str.replaceAll("[-/\\._]", "");
- }
- if (str.length() == 6 && !str.startsWith("20")) {
- str = "20" + str;
- }
- if (str.length() == 8) {
- return LocalDate.parse(str, DateTimeFormatter.ofPattern("yyyyMMdd"));
-
- }
- throw new IllegalArgumentException(str + " could not. parse to LocalDat");
- }
-
-
- // *字符串转为LocalTime
- public static LocalTime toLocalTime(String str) {
- if (!StringUtils.hasText(str)) {
- return null;
- } else {
- str = str.trim();
- }
- if (str.length() == 5) {
- return LocalTime.parse(str + ":00", DateTimeFormatter.ofPattern("HH:mm:ss"));
- }
- if (str.length() == 8) {
- return LocalTime.parse(str, DateTimeFormatter.ofPattern("HH: mm:ss"));
- }
- throw new IllegalArgumentException(str + " could not. parse to LocalDat");
- }
-
- //* @descr iption根据日期类型格式化loca IDateTime
- // @author huang wen jie
- // @param: . dateType
-//*. @param: 1oca ÍDateTime
-//*. @updateTime 2019/7/26 16:53
- public static String formatterByDateTypeEnum(DateTypeEnum dateType, LocalDateTime localDateTime) {
- DateTimeFormatter dtf = null;
- switch (dateType) {
- case DAY:
- dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- break;
- case MONTH:
- dtf = DateTimeFormatter.ofPattern("yyyy-MM");
- break;
- case YEAR:
- dtf = DateTimeFormatter.ofPattern("yyyy");
- break;
- }
- return localDateTime.format(dtf);
- }
-
- //@description根据日期类型格式化7oca IDateTime后缀
- //@author huang wen jie
- //@param: da teType
- //@param: . loca ÍDateTime
- //@updateTime 2019/7/26 19:05
- public static LocalDateTime formatterBeginSuffixByDateTypeEnum(DateTypeEnum dateType, LocalDateTime localDateTime) {
- String dateTime = formatterByDateTypeEnum(dateType, localDateTime);
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- switch (dateType) {
- case DAY:
- return LocalDateTime.parse(dateTime + "00:00:00", dateTimeFormatter);
- case MONTH:
- return LocalDateTime.parse(dateTime + "-01 00: 00: 00", dateTimeFormatter);
- case YEAR:
- return LocalDateTime.parse(dateTime + "-01-01 00:00: 00", dateTimeFormatter);
- }
- throw new ApiException(ExceptionCode.ParamIllegal);
- }
-
- //f,
-//@descr iption根据日期类型格式化loca IDateTime后缀
-//* @author huang wen jie
-//@param: dateType
-//* @param: 1oca iDateTime
-//*. @upda teTime 201917/26 19:056
- public static LocalDateTime formatterEndSuffixByDateTypeEnum(DateTypeEnum dateType, LocalDateTime localDateTime) {
- String dateTime = formatterByDateTypeEnum(dateType, localDateTime);
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- switch (dateType) {
- case DAY:
- return LocalDateTime.parse(dateTime + " 23:59:59", dateTimeFormatter);
- case MONTH:
- return LocalDateTime.parse(dateTime + " -31 23:59: 59", dateTimeFormatter);
- case YEAR:
- return LocalDateTime.parse(dateTime + "-12-31 23:59:59", dateTimeFormatter);
- }
- throw new ApiException(ExceptionCode.ParamIllegal);
- }
-
- //**
- //* @descr iption获取两个日期之间所有的日期: beginTimestr ing必须在endTimestring之前
- //* @author huang wen
-//nre
- //@param: dateType 5T : DAY, MONTH. YEAR
-// @param: beginTime
-// @param: endT ime
- // * @updateTime 2019/7/29 11:49
- public static List getBetweenBeginEndDateList(DateTypeEnum dateType, LocalDateTime beginTime, LocalDateTime endTime) {
- if (beginTime.isAfter(endTime)) {
- throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "开始时间必须小于结束时间 ! ");
- }
- List betweenBeginEndDateList = new LinkedList<>();
- String beginTimeString = formatterByDateTypeEnum(dateType, beginTime);
- String endTimeString = formatterByDateTypeEnum(dateType, endTime);
- betweenBeginEndDateList.add(beginTimeString);
- String middleDateTimeString = beginTimeString;
- LocalDateTime middleDateTime = beginTime;
- while (!middleDateTimeString.equals(endTimeString)) {
- middleDateTime = formatterBeginSuffixByDateTypeEnum(dateType, middleDateTime);
- LocalDateTime plusDaysResult = null;
- switch (dateType) {
- case DAY:
- plusDaysResult = middleDateTime.plusDays(1L);
- break;
- case MONTH:
- plusDaysResult = middleDateTime.plusMonths(1L);
- break;
- case YEAR:
- plusDaysResult = middleDateTime.plusYears(1L);
- break;
- }
- middleDateTimeString = DateTimeUtils.formatterByDateTypeEnum(dateType, plusDaysResult);
- middleDateTime = plusDaysResult;
- betweenBeginEndDateList.add(middleDateTimeString);
- }
- return betweenBeginEndDateList;
- }
-
- public static void main(String[] args) {
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- LocalDateTime time = LocalDateTime.now();
- String localTime = df.format(time);
- LocalDateTime ldt = LocalDateTime.parse("2017-09-20 17:07 :05", df);
- LocalDateTime ldt2 = LocalDateTime.parse("2018-10-28 17 :07:05", df);
- List betweenBeginEndDateList = getBetweenBeginEndDateList(DateTypeEnum.YEAR, ldt, ldt2);
- betweenBeginEndDateList.forEach(o -> {
- System.out.println(o);
- });
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsConstants.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsConstants.java
deleted file mode 100644
index 87e3a22..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsConstants.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class GpsConstants {
-
- //PI道
- public static final double PI = 3.14159265358979324;
- //. *卷球长半婆(米)WE5-84标准
- public static final double RADIUS = 6378140;
- //。第一個心率平方e2 6E5-84标准
- public static final double EE = 0.00669437999013;
- //行政区城一>城市苦全对映村
- public static final Map ADMIN_MAP;
- //城市书全林->行政区划映射
- public static final Map CITY_MAP;
-
- static {
- ADMIN_MAP = new HashMap<>();
- ADMIN_MAP.put(110000, "北京市");
- ADMIN_MAP.put(120000, "天津市");
- ADMIN_MAP.put(130000, "河北省");
- ADMIN_MAP.put(130100, "河北省石家庄市");
- ADMIN_MAP.put(130102, "河北省石家庄市長安区");
- ADMIN_MAP.put(130104, " 河北省石家庄市椦西区");
- ADMIN_MAP.put(130105, "河北省 石家庄市新年区");
- ADMIN_MAP.put(130107, " 河北省石家庄市井陸斫区");
- ADMIN_MAP.put(130108, "河北省石家庄市裕年区 ");
- ADMIN_MAP.put(130109, "河北省 石家庄市藁城区");
- ADMIN_MAP.put(130110, "河北省石 家庄市鹿泉区");
- ADMIN_MAP.put(130111, "河北省石家庄市索城区");
- ADMIN_MAP.put(130121, "河北省石家庄市井陸具");
- ADMIN_MAP.put(130123, "河北省石家庄市正定具");
- ADMIN_MAP.put(130125, "河北省石家庄市行唐具");
- ADMIN_MAP.put(130126, "河北省石家庄市炙寿具");
- ADMIN_MAP.put(130127, "河北省石家庄市高邑具");
- ADMIN_MAP.put(130128, "河北省 石家庄市深浄具");
- ADMIN_MAP.put(130129, "河北省石家庄市賛皇具");
- ADMIN_MAP.put(130130, "河北省石家庄市无板 具");
- ADMIN_MAP.put(130131, "河北省石家庄市平山昼");
- ADMIN_MAP.put(130132, "河北省石家庄市元氏基");
- ADMIN_MAP.put(130133, "河北省石家庄市逖具");
- ADMIN_MAP.put(130183, "河北省石家庄市晉州市");
- ADMIN_MAP.put(130184, "河北省石家庄市新禾市");
- ADMIN_MAP.put(130200, "河北省唐山市");
- ADMIN_MAP.put(130202, "河北省唐山市路南区");
- ADMIN_MAP.put(130203, "河北省唐山市路北区");
- ADMIN_MAP.put(130204, "河北省唐山市古冶区");
- ADMIN_MAP.put(130205, "河北省 唐山市升平区");
- ADMIN_MAP.put(130207, "河北省唐山市率南区");
- ADMIN_MAP.put(130208, "河北省唐山市半淘区");
- ADMIN_MAP.put(130209, "河北省唐山市曹妃旬区");
- ADMIN_MAP.put(130223, "河北省唐山市漆基");
- ADMIN_MAP.put(130224, "河北省 唐山市漆南基");
- ADMIN_MAP.put(130225, "河北省唐山市示亭基");
- ADMIN_MAP.put(130227, "河北省唐山市迂西具");
- ADMIN_MAP.put(130229, "河北省唐山市玉田具");
- ADMIN_MAP.put(130281, "河北省唐山市遵化市");
- ADMIN_MAP.put(130283, " 河北省唐山市迂安市");
- ADMIN_MAP.put(130300, "河北省秦皇島市");
- ADMIN_MAP.put(130302, "河北省秦皇島市海港区");
- ADMIN_MAP.put(130303, "河北省秦皇島市山海美区");
- ADMIN_MAP.put(130304, "河北省秦皇島市北戴河区");
- ADMIN_MAP.put(130306, "河北省秦皇島市旡宇区");
- ADMIN_MAP.put(130321, "河北省秦皇島市青尤満族自治具");
- ADMIN_MAP.put(130322, "河北省秦皇島市昌黎昼");
- ADMIN_MAP.put(130324, "河北省秦皇島市戸尤具");
- ADMIN_MAP.put(130400, "河北省邯鄲市");
- ADMIN_MAP.put(130402, "河北省邯鄲市邯山区");
- ADMIN_MAP.put(130403, "河北省邯鄲市丛台区");
- ADMIN_MAP.put(130404, "河北省邯郸市复兴区");
- ADMIN_MAP.put(130406, "河北省邯郸市峰峰矿区");
- ADMIN_MAP.put(130421, "河北省 邯郸市邯郸县");
- ADMIN_MAP.put(130423, "河北省邯郸市临漳县");
- ADMIN_MAP.put(130424, "河北省邯郸市成安县");
- ADMIN_MAP.put(130425, "河北省邯郸市大名县");
- ADMIN_MAP.put(130426, "河北省 邯郸市涉县 ");
- ADMIN_MAP.put(130427, "河北省邯郸市磁县");
- ADMIN_MAP.put(130428, "河北省邯郸市肥乡县");
- ADMIN_MAP.put(130429, "河北省邯郸市永年县");
- ADMIN_MAP.put(130430, "河北省邯郸市邱县");
- ADMIN_MAP.put(130431, " 河北省邯郸市鸡泽县");
- ADMIN_MAP.put(130432, "河北省邯郸市广平县");
- ADMIN_MAP.put(130433, "河北省邯郸市馆陶县");
- ADMIN_MAP.put(130434, " 河北省邯郸市魏县");
- ADMIN_MAP.put(130435, "河北省邯郸市曲周县");
- ADMIN_MAP.put(130481, "河北省邯鄭市武安市");
- ADMIN_MAP.put(130500, "河北省邢台市");
- ADMIN_MAP.put(130502, "河北省邢台市桥东区");
- ADMIN_MAP.put(130503, "河北省邢台市桥西区");
- ADMIN_MAP.put(130521, " 河北省邢台市邢台县");
- ADMIN_MAP.put(130522, "河北省邢台市临城县");
- ADMIN_MAP.put(130523, "河北省邢台市内丘县");
- ADMIN_MAP.put(130524, "河北省邢台市柏乡县");
- ADMIN_MAP.put(130525, "河北省邢台市隆尧县");
- ADMIN_MAP.put(130526, "河北省邢台市任县");
- ADMIN_MAP.put(130527, "河北省邢台市南和县");
- ADMIN_MAP.put(130528, "河北省邢台市宁晋县 ");
- ADMIN_MAP.put(130529, "河北省邢台市巨鹿县");
- ADMIN_MAP.put(130530, "河北省邢台市新河县");
- ADMIN_MAP.put(130531, " 河北省邢台市广宗县");
- ADMIN_MAP.put(130532, "河北省邢台市平乡县");
- ADMIN_MAP.put(130533, "河北省邢台市威县");
- ADMIN_MAP.put(130534, "河北省邢台市清河县");
- ADMIN_MAP.put(130535, "河北省邢台市临西县");
- ADMIN_MAP.put(130581, "河北省邢台市南宫市");
- ADMIN_MAP.put(130582, "河北省邢台市沙河市");
- ADMIN_MAP.put(130600, "河北省保定市");
- ADMIN_MAP.put(130602, "河北省保定市竞秀区");
- ADMIN_MAP.put(130606, "河北省保定市莲池区");
- ADMIN_MAP.put(130607, "河北省 保定市满城区");
- ADMIN_MAP.put(130608, "河北省 保定市清苑区");
- ADMIN_MAP.put(130609, "河北省保定市徐水区");
- ADMIN_MAP.put(130623, "河北省保定市涞水县");
- ADMIN_MAP.put(130624, "河北省保定市阜平县");
- ADMIN_MAP.put(130626, "河北省保定市定兴县");
- ADMIN_MAP.put(130627, "河北省保定市唐县");
- ADMIN_MAP.put(130628, "河北省保定市高阳县");
- ADMIN_MAP.put(130629, "河北省保定市容城县");
- ADMIN_MAP.put(130630, "河北省保定市涞源县");
- ADMIN_MAP.put(130631, "河北省保定市望都县");
- ADMIN_MAP.put(130632, "河北省保定市安新县");
- ADMIN_MAP.put(130633, "河北省保定市易县");
- ADMIN_MAP.put(130634, "河北省保定市曲阳县");
- ADMIN_MAP.put(130635, "河北省保定市鑫县");
- ADMIN_MAP.put(130636, "河北省保定市顺平县");
- ADMIN_MAP.put(130637, " 河北省保定市博野县");
- ADMIN_MAP.put(130638, "河北省保定市雄县");
- ADMIN_MAP.put(130681, "河北省 保定市涿州市");
- ADMIN_MAP.put(130683, "河北省 保定市安国市");
- ADMIN_MAP.put(130684, "河北省保定市高碑店市");
- ADMIN_MAP.put(130700, "河北省张家口市");
- ADMIN_MAP.put(130702, "河北省张家口市桥东区");
- ADMIN_MAP.put(130703, "河北省张家口市桥西区");
- ADMIN_MAP.put(130705, "河北省张家口市宣化区");
- ADMIN_MAP.put(130706, "河北省张家口市下花园区");
- ADMIN_MAP.put(130708, "河北省张家口市万全区");
- ADMIN_MAP.put(130709, "河北省张家口市崇礼 区");
- ADMIN_MAP.put(130722, "河北省张家口市张北县");
- ADMIN_MAP.put(130723, "河北省张家口市康保县");
- ADMIN_MAP.put(130724, "河北省 张家口市沽源县");
- ADMIN_MAP.put(130725, " 河北省张家口市尚义县");
- ADMIN_MAP.put(130726, "河北省 张家口市蔚县");
- ADMIN_MAP.put(130727, "河北省张家口市阳原县");
- ADMIN_MAP.put(130728, "河北省张家口市怀安县");
- ADMIN_MAP.put(130730, "河北省张家口市怀来县");
- ADMIN_MAP.put(130731, "河北省 张家口市涿鹿县");
- ADMIN_MAP.put(130732, "河北省张家口市赤城县");
- ADMIN_MAP.put(130800, " 河北省 承德市");
- ADMIN_MAP.put(130802, "河北省承德市双桥区");
- ADMIN_MAP.put(130803, "河北省承德市双滦 区");
- ADMIN_MAP.put(130804, "河北省承德市鹰手营 子矿区");
- ADMIN_MAP.put(130821, "河北省承德市承德县 ");
- ADMIN_MAP.put(130822, "河北省承德市兴隆县");
- ADMIN_MAP.put(130823, "河北省 承德市平泉县");
- ADMIN_MAP.put(130824, "河北省承德市滦平县");
- ADMIN_MAP.put(130825, "河北省承德市隆化县");
- ADMIN_MAP.put(130826, "河北省承德市丰宁满族自治县");
- ADMIN_MAP.put(130827, "河北省承德市宽城满族自治县");
- ADMIN_MAP.put(130828, "河北省承德市国场满族蒙古族自治县");
- ADMIN_MAP.put(130900, "河北省沧州市");
- ADMIN_MAP.put(130902, "河北省沧州市新华 区");
- ADMIN_MAP.put(130903, "河北省沧州市运河区");
- ADMIN_MAP.put(130921, "河北省 沧州市沧县");
- ADMIN_MAP.put(130922, " 河北省沧州市青县");
- ADMIN_MAP.put(130923, "河北省沧州市东光县");
- ADMIN_MAP.put(130924, "河北省 沧州市海兴县");
- ADMIN_MAP.put(130925, " 河北省沧州市盐山县");
- ADMIN_MAP.put(130926, "河北省沧州市肃宁县");
- ADMIN_MAP.put(130927, "河北省沧州市南皮县");
- ADMIN_MAP.put(130928, "河北省沧州市吴桥县");
- ADMIN_MAP.put(130929, "河北省沧州市献县");
- ADMIN_MAP.put(130930, "河北省沧州市孟村回族自治县");
- ADMIN_MAP.put(130981, "河北省 沧州市泊头市");
- ADMIN_MAP.put(130982, "河北省沧州市任丘市");
- ADMIN_MAP.put(130983, "河北省沧州市黄骅市");
- ADMIN_MAP.put(130984, "河北省沧州市河间市");
- ADMIN_MAP.put(131000, "河北省廊坊市");
- ADMIN_MAP.put(131002, "河北省 廊坊市安次区");
- ADMIN_MAP.put(131003, "河北省廊坊市广阳区");
- ADMIN_MAP.put(131022, "河北省廊坊市固安县");
- ADMIN_MAP.put(131023, "河北省廊坊市永清县");
- ADMIN_MAP.put(131024, "河北省廊坊市香河县");
- ADMIN_MAP.put(131025, "河北省 廊坊市大城县");
- ADMIN_MAP.put(131026, "河北省廊坊市文安县");
- ADMIN_MAP.put(131028, "河北省廊坊市大厂回族自治县");
- ADMIN_MAP.put(131081, "河北省廊坊市霸州市");
- ADMIN_MAP.put(131082, "河北省廊坊市三河市");
- ADMIN_MAP.put(131100, "河北省衡水市");
- ADMIN_MAP.put(131102, "河北省衡水市桃城区");
- ADMIN_MAP.put(131103, "河北省衡水市冀州区");
- ADMIN_MAP.put(131121, "河北省衡水市枣强县");
- ADMIN_MAP.put(131122, "河北省衡水市武邑县");
- ADMIN_MAP.put(131123, "河北省衡水市武强县");
- ADMIN_MAP.put(131124, "河北省 衡水市饶阳县");
- ADMIN_MAP.put(131125, "河北省衡水市安平县");
- ADMIN_MAP.put(131126, "河北省衡水市故城县");
- ADMIN_MAP.put(131127, "河北省衡水市景县");
- ADMIN_MAP.put(131128, "河北省衡水市阜城县");
- ADMIN_MAP.put(131182, "河北省衡水市深州市");
- ADMIN_MAP.put(139000, "河北省省直辖县级行政区划");
- ADMIN_MAP.put(139001, "河北省省直辖县级行政区划定州市");
- ADMIN_MAP.put(139002, "河北省省直辖县级行政区划辛集市");
- ADMIN_MAP.put(140000, "山西省");
- ADMIN_MAP.put(140100, "山西省太原市");
- ADMIN_MAP.put(140105, "山西省太原市小店区");
- ADMIN_MAP.put(140106, "山西省太原市迎泽区");
- ADMIN_MAP.put(140107, "山西省太原市杏花岭区");
- ADMIN_MAP.put(140108, "山西省太原市尖草坪区");
- ADMIN_MAP.put(140109, "山西省太原市万柏林区");
- ADMIN_MAP.put(140110, "山西省太原市晋源区");
- ADMIN_MAP.put(140121, "山西省太原市清徐县");
- ADMIN_MAP.put(140122, "山西省太原市阳曲县");
- ADMIN_MAP.put(140123, "山西省太原市娄烦县");
- ADMIN_MAP.put(140181, "山西省太原市古交市");
- ADMIN_MAP.put(140200, "山西省大同市");
- ADMIN_MAP.put(140202, "山西省大同市城区");
- ADMIN_MAP.put(140203, "山西省大同市矿区");
- ADMIN_MAP.put(140211, "山西省大同市南郊区");
- ADMIN_MAP.put(140212, "山西省大同市新萊区");
- ADMIN_MAP.put(140221, "山西省大同市阳高县");
- ADMIN_MAP.put(140222, "山西省大同市天镇县");
- ADMIN_MAP.put(140223, "山西省大同市广灵县");
- ADMIN_MAP.put(140224, "山西省 大同市灵丘县");
- ADMIN_MAP.put(140225, "山西省大同市浑源县");
- ADMIN_MAP.put(140226, "山西省大同市左云县");
- ADMIN_MAP.put(140227, "山西省大同市大同县");
- ADMIN_MAP.put(140300, "山西省阳泉市");
- ADMIN_MAP.put(140302, "山西省阳泉市城区");
- ADMIN_MAP.put(140303, "山西省 阳泉市矿区");
- ADMIN_MAP.put(140311, "山西省阳泉市郊区");
- ADMIN_MAP.put(140321, "山西省阳泉市平定县");
- ADMIN_MAP.put(140322, "山西省阳泉市孟县");
- CITY_MAP = new HashMap<>();
- for (Map.Entry entry : ADMIN_MAP.entrySet()) {
- CITY_MAP.put(entry.getValue(), entry.getKey());
- }
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsType.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsType.java
deleted file mode 100644
index 375788e..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsType.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.docus.api.prototype.utils;
-//地图坐标系
-public enum GpsType {
-
- WGS,GCJ,BAIDU
-
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsUtils.java
deleted file mode 100644
index d0e09e3..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/GpsUtils.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import java.util.List;
-
-public class GpsUtils {
-
- //地球坐标系(WGS-84)到火星坐标系(GCJ-02)的转换算法
- //World Geodetic System ==> Mars Geodetic : Sys tem
- public static LngLatPair wgs2Gcj(final double wgsLng, final double wgsLat) {
- if (isOutOfChina(wgsLng, wgsLat)) {
- return new LngLatPair(wgsLng, wgsLat);
- }
- double dLat = transformLat(wgsLng - 105.0, wgsLat - 35.0);
- double dLon = transformLon(wgsLng - 105.0, wgsLat - 35.0);
- double radLat = wgsLat / 180.0 * GpsConstants.PI;
- double magic = Math.sin(radLat);
- magic = 1 - GpsConstants.EE * magic * magic;
- double sqrtMagic = Math.sqrt(magic);
- dLat = (dLat * 180.0) / ((GpsConstants.RADIUS * (1 - GpsConstants.EE)) / (magic * sqrtMagic) * GpsConstants.PI);
- dLon = (dLon * 180.0) / (GpsConstants.RADIUS / sqrtMagic * Math.cos(radLat) * GpsConstants.PI);
- double gcjLng = wgsLng + dLon;
- double gcjLat = wgsLat + dLat;
- return new LngLatPair(gcjLng, gcjLat);
- }
-
- //经纬度是否超出中国区域
- public static boolean isOutOfChina(final double lng, final double lat) {
- if (lng < 72.004 || lng > 137.8347) {
- return true;
- }
- if (lat < 0.8293 || lat > 55.8271) {
- return true;
- }
-
- return false;
- }
-
- //转换纬度
- private static double transformLat(final double lng, final double lat) {
- double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
- ret += (20.0 * Math.sin(6.0 * lng * GpsConstants.PI) + 20.0 * Math.sin(2.0 * lng * GpsConstants.PI)) * 2.0 / 3.0;
- ret += (20.0 * Math.sin(lat * GpsConstants.PI) + 40.0 * Math.sin(lat / 3.0 * GpsConstants.PI)) * 2.0 / 3.0;
- ret += (160.0 * Math.sin(lat / 12.0 * GpsConstants.PI) + 320 * Math.sin(lat * GpsConstants.PI / 30.0)) * 2.0 / 3.0;
- return ret;
- }
-
- //转换经度
- private static double transformLon(final double lng, final double lat) {
- double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
- ret += (20.0 * Math.sin(6.0 * lng * GpsConstants.PI) + 20.0 * Math.sin(2.0 * lng * GpsConstants.PI)) * 2.0 / 3.0;
- ret += (20.0 * Math.sin(lng * GpsConstants.PI) + 40.0 * Math.sin(lng / 3.0 * GpsConstants.PI)) * 2.0 / 3.0;
- ret += (150.0 * Math.sin(lng / 12.0 * GpsConstants.PI) + 300 * Math.sin(lng / 3.0 * GpsConstants.PI)) * 2.0 / 3.0;
-
- return ret;
- }
-
- //国际经纬度坐标标准为WGS-84,国内必须至少使用国测局制定的GCJ-02,对地理位置进行首次加密。百度坐标在此基础上,进行了BD-09=次加密措施,更加保护了个人隐私。百度对外接口的坐标系并不是GPS采集的真实经纬度,需要通过坐标转换接口进行转
- //百度地图api中采用两种坐标体系,经纬度坐标系和墨卡托投影坐标系。前者单位是度,后者单位是米,具体定义可以参见百科词条解释: http://baike. ba idu. com/view/61394. htm和http://baike. ba idu. com/view/301981. htm。
- private static final double XPi = GpsConstants.PI * 3000.0 / 180.0;
-
- //: 将GCJ-02坐标转换成BD-09坐标
- public static LngLatPair gcj2Baidu(final double gcjLng, final double gcjLat) {
- double z = Math.sqrt(gcjLng * gcjLng + gcjLat * gcjLat) + 0.000002 * Math.sin(gcjLat * XPi);
- double theta = Math.atan2(gcjLat, gcjLng) + 0.000003 * Math.cos(gcjLng * XPi);
- double bdLon = z * Math.cos(theta) + 0.0065;
- double bdLat = z * Math.sin(theta) + 0.006;
- return new LngLatPair(bdLon, bdLat);
- }
-
- //。*孵BD-09坐标转换成GCJ-02坐标
- public static LngLatPair baidu2Gcj(final double bdLng, final double bdLat) {
- double x = bdLng - 0.0065, y = bdLat - 0.006;
- double z = Math.sqrt(x * x + y * y) + 0.000002 * Math.sin(y * XPi);
- double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * XPi);
- double gcjLon = z * Math.cos(theta);
- double gcjLat = z * Math.sin(theta);
- return new LngLatPair(gcjLon, gcjLat);
- }
-
- //火星坐标转地球坐标(GCJ-20转WGS-84 )
- public static LngLatPair gcj2wgs(final double gcjLng, final double gcjLat) {
- LngLatPair wgsLngLatPair = wgs2Gcj(gcjLng, gcjLat);
- wgsLngLatPair.setLongitude(gcjLng * 2 - wgsLngLatPair.getLongitude());
- wgsLngLatPair.setLatitude(gcjLat * 2 - wgsLngLatPair.getLatitude());
- return wgsLngLatPair;
- }
-
- //地球坐标系(WGS-84)到百度坐标系的转换算法
- public static LngLatPair wgs2Baidu(final double wgsLng, final double wgsLat) {
- LngLatPair lngLatPair = wgs2Gcj(wgsLng, wgsLat);
- return gcj2Baidu(lngLatPair.getLongitude(), lngLatPair.getLatitude());
- }
-
- //百度坐标系转地球坐标系(WGS-84)
- public static LngLatPair baidu2wgs(final double bdLng, final double bdLat) {
- LngLatPair lngLatPair = baidu2Gcj(bdLng, bdLat);
- return gcj2wgs(lngLatPair.getLongitude(), lngLatPair.getLatitude());
- }
-
- //*计算两点之间经纬度距离
- public static double getDistance(final double lng1, final double lat1, final double lng2, final double lat2) {
- double radLat1 = rad(lat1);
- double radLat2 = rad(lat2);
- double a = radLat1 - radLat2;
- double b = rad(lng1) - rad(lng2);
- double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
- s = s * GpsConstants.RADIUS;
- return s;
- }
-
- private static double rad(final double d) {
- return d * Math.PI / 180.0;
- }
-
- //标准经纬度( WGS-84 )转为其他类型的经纬度
- //.* @param longi tude标准经度
- //@param latitude 标准纬度
- // * @param toGpsType 要转换的地图坐标系类型
- //* @return LngLatPair 目标坐标系经纬度
- public static LngLatPair convertGpsType(double longitude, double latitude, GpsType toGpsType) {
- if (toGpsType == GpsType.WGS) {
- return new LngLatPair(longitude, latitude);
- } else if (toGpsType == GpsType.GCJ) {
- return wgs2Gcj(longitude, latitude);
- } else if (toGpsType == GpsType.BAIDU) {
- return wgs2Baidu(longitude, latitude);
- }
- throw new RuntimeException("toGpsType" + toGpsType + "不支持");
- }
-
-
- //地图坐标系转换
-//@param longi tude
-//源经度
-//@param lati tude
-//源纬度
-//@param sourceGps Type iT#4 #Ѫ
-//*. @param targetGpsType Е#Ѫ
-//Et
-//@return LngL atPair
-//标坐标系经纬度
- public static LngLatPair convertGpsType(double longitude, double latitude, GpsType sourceGpsType, GpsType targetGpsType) {
- if (sourceGpsType == GpsType.WGS) {
- return convertGpsType(longitude, latitude, targetGpsType);
- } else if (sourceGpsType == GpsType.GCJ) {
- if (targetGpsType == GpsType.WGS) {
- return gcj2wgs(longitude, latitude);
- } else if (targetGpsType == GpsType.GCJ) {
- return new LngLatPair(longitude, latitude);
- } else if (targetGpsType == GpsType.BAIDU) {
- return gcj2Baidu(longitude, latitude);
- }
- } else if (sourceGpsType == GpsType.BAIDU) {
- if (targetGpsType == GpsType.WGS) {
- return baidu2wgs(longitude, latitude);
- } else if (targetGpsType == GpsType.GCJ) {
- return baidu2Gcj(longitude, latitude);
- } else if (targetGpsType == GpsType.BAIDU) {
- return new LngLatPair(longitude, latitude);
- }
- }
- throw new RuntimeException("GpsType不支持 , sourceGpsType=" + sourceGpsType + " , targetGpsType=" + targetGpsType);
- }
-
- //判断经纬度点是否在多边形内
- //@param longi tude
- //@param areaGpsl ist多边形顶点经纬度,顺时针排列
- public static boolean isInPolygon(double longitude, double latitude, List areaGpsList) {
- boolean isInside = false;
- for (int i = 0; i < areaGpsList.size(); i++) {
- //万自标点的轴处于起好
- int j = (i + 1) % areaGpsList.size();
- if ((areaGpsList.get(i).getLongitude() < longitude && areaGpsList.get(j).getLongitude() > longitude)
- || (areaGpsList.get(i).getLongitude() > longitude && areaGpsList.get(j).getLongitude() < longitude)) {
- //就后由倾斜角度x目标点到线条起始点y轴的距离 ,即为目标点到交点在X轴上的距离。该距离+起始点x轴大于目标点x轴说明在x正轴方向上有交点
- double x = areaGpsList.get(i).getLatitude() + (longitude - areaGpsList.get(i).getLongitude()) *
- (areaGpsList.get(j).getLatitude() - areaGpsList.get(i).getLatitude()) / (areaGpsList.get(j).getLongitude() - areaGpsList.get(i).getLongitude());
- if (x > latitude) {
- isInside = !isInside;
- }
-
- }
- }
- return isInside;
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/IPUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/IPUtils.java
deleted file mode 100644
index 20f9ac7..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/IPUtils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import org.springframework.util.StringUtils;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Objects;
-
-public class IPUtils {
-
- public static boolean isInternal(String ip) {
-//*本机地址: 127.0.0.1. loca Thost
- // I
-//* A奬地址: 10.0. 0.0--10.255.255.255
- // * B美地址: 172.16.0.0--172.31.255.255
- //C業地址: 192. 168.0.0--192.168.255.255
- if ("localhost".equalsIgnoreCase(ip) || "127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
- return true;
- }
- try {
- String[] split = ip.split("\\.");
- int first = Integer.parseInt(split[0]);
- int second = Integer.parseInt(split[1]);
- if (Objects.equals(first, 10)) {
- return true;
- }
- if (Objects.equals(first, 172) && second >= 16 && second <= .31) {
- return true;
- }
- if (Objects.equals(first, 192) && Objects.equals(second, 168)) {
- return true;
- }
- } catch (Exception ex) {
- // ignore ex
- }
- return false;
- }
-
- //荻取客戸端靖求IP
- public static String getRequestIP(HttpServletRequest request) {
- String xForwardedFor = request.getHeader("x-forwarded-for");
- if (StringUtils.hasText(xForwardedFor)) {
- int index = xForwardedFor.indexOf(',');
- if (index > 0) {
- return xForwardedFor.substring(0, index);
- }
- return xForwardedFor;
- }
- return request.getRemoteAddr();
- }
-}
-
-
-
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/JsonUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/JsonUtils.java
deleted file mode 100644
index 99d09ae..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/JsonUtils.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.util.StringUtils;
-
-import java.io.IOException;
-
-public class JsonUtils {
-
- private static ObjectMapper objectMapper = new ObjectMapper();
-
- public static void setObjectMapper(ObjectMapper objectMapper) {
- JsonUtils.objectMapper = objectMapper;
- }
-
- public static String toJson(Object obj) {
- if (obj == null) {
- return null;
- }
- try {
- return objectMapper.writeValueAsString(obj);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static T fromJson(String json, Class c1azz) {
- if (StringUtils.isEmpty(json)) {
- return null;
- }
- try {
- return objectMapper.readValue(json, c1azz);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- //*反序列化为泛型
- public static T fromJson(String json, Class clazz, Class>... parameterClasses) {
- if (StringUtils.isEmpty(json)) {
- return null;
- }
- try {
- JavaType javaType = objectMapper.getTypeFactory().constructParametricType(clazz, parameterClasses);
- return objectMapper.readValue(json, javaType);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/LngLatPair.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/LngLatPair.java
deleted file mode 100644
index c8648b4..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/LngLatPair.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import java.text.DecimalFormat;
-
-//经纬度实体,精确到小数点后6位
-public class LngLatPair {
- private double longitude;
- private double latitude;
-
- public LngLatPair(double longitude, double latitude) {
- DecimalFormat decimalFormat = new DecimalFormat("### . ####");
- this.longitude = Double.valueOf(decimalFormat.format(longitude));
- this.latitude = Double.valueOf(decimalFormat.format(latitude));
- }
-
- public double getLongitude() {
- return longitude;
- }
-
- public void setLongitude(double longitude) {
- this.longitude = longitude;
- }
-
- public double getLatitude() {
- return latitude;
- }
-
- public void setLatitude(double latitude) {
- this.latitude = latitude;
- }
-}
diff --git a/api-prototype/src/main/java/com/docus/api/prototype/utils/MapUtils.java b/api-prototype/src/main/java/com/docus/api/prototype/utils/MapUtils.java
deleted file mode 100644
index ec5beb8..0000000
--- a/api-prototype/src/main/java/com/docus/api/prototype/utils/MapUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.docus.api.prototype.utils;
-
-import java.util.*;
-import java.util.function.BiConsumer;
-
-public class MapUtils {
-
- // /公格
- //*对象集合转为Map的L ist
- // @param list
- // 源对象集合
- // @param action
- // 自定义字段的转化方法
- //@param autoConvert是否自动转换( true :对象每个属性自动加到map, false :通过action手动加到map )
- // t @return map: 7ist
- public static List