24 changed files with 634 additions and 1121 deletions
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package com.cloud.kicc.commonbiz.api.bigscreen.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
*<p> |
||||
* 动态SQL |
||||
*</p> |
||||
* |
||||
* @Author: wangxiang4 |
||||
* @since: 2023/7/3 |
||||
*/ |
||||
@Data |
||||
public class DynamicModelDto { |
||||
|
||||
/** |
||||
* 数据源ID |
||||
*/ |
||||
private String id; |
||||
|
||||
/** |
||||
* sql脚本 |
||||
*/ |
||||
private String sql; |
||||
|
||||
} |
@ -1,53 +1,35 @@
@@ -1,53 +1,35 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*//*
|
||||
|
||||
package com.cloud.kicc.commonbiz.bigscreen.service.impl; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.visual.entity.VisualCategory; |
||||
import org.springblade.modules.visual.mapper.VisualCategoryMapper; |
||||
import org.springblade.modules.visual.service.IVisualCategoryService; |
||||
import com.cloud.kicc.common.core.exception.CheckedException; |
||||
import com.cloud.kicc.commonbiz.api.bigscreen.entity.VisualCategory; |
||||
import com.cloud.kicc.commonbiz.bigscreen.mapper.VisualCategoryMapper; |
||||
import com.cloud.kicc.commonbiz.bigscreen.service.IVisualCategoryService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
*/ |
||||
/** |
||||
*<p> |
||||
* 可视化分类表 服务实现类 |
||||
*</p> |
||||
* |
||||
* @author BladeX |
||||
*//*
|
||||
|
||||
* @Author: wangxiang4 |
||||
* @since: 2023/7/3 |
||||
*/ |
||||
@Service |
||||
public class VisualCategoryServiceImpl extends ServiceImpl<VisualCategoryMapper, VisualCategory> implements IVisualCategoryService { |
||||
|
||||
@Override |
||||
public boolean submit(VisualCategory visualCategory) { |
||||
LambdaQueryWrapper<VisualCategory> lqw = Wrappers.<VisualCategory>query().lambda().eq(VisualCategory::getCategoryValue, visualCategory.getCategoryValue()); |
||||
Long cnt = baseMapper.selectCount((Func.isEmpty(visualCategory.getId())) ? lqw : lqw.notIn(VisualCategory::getId, visualCategory.getId())); |
||||
Long cnt = baseMapper.selectCount((StrUtil.isBlank(visualCategory.getId())) ? lqw : lqw.notIn(VisualCategory::getId, visualCategory.getId())); |
||||
if (cnt > 0L) { |
||||
throw new ServiceException("当前模块键值已存在!"); |
||||
throw new CheckedException("当前模块键值已存在!"); |
||||
} |
||||
visualCategory.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
||||
return saveOrUpdate(visualCategory); |
||||
} |
||||
|
||||
} |
||||
*/ |
||||
|
||||
|
@ -1,37 +1,21 @@
@@ -1,37 +1,21 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*//*
|
||||
|
||||
package com.cloud.kicc.commonbiz.bigscreen.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springblade.modules.visual.entity.VisualConfig; |
||||
import org.springblade.modules.visual.mapper.VisualConfigMapper; |
||||
import org.springblade.modules.visual.service.IVisualConfigService; |
||||
import com.cloud.kicc.commonbiz.api.bigscreen.entity.VisualConfig; |
||||
import com.cloud.kicc.commonbiz.bigscreen.mapper.VisualConfigMapper; |
||||
import com.cloud.kicc.commonbiz.bigscreen.service.IVisualConfigService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
*/ |
||||
/** |
||||
*<p> |
||||
* 可视化配置表 服务实现类 |
||||
*</p> |
||||
* |
||||
* @author Chill |
||||
*//*
|
||||
|
||||
* @Author: wangxiang4 |
||||
* @since: 2023/7/3 |
||||
*/ |
||||
@Service |
||||
public class VisualConfigServiceImpl extends ServiceImpl<VisualConfigMapper, VisualConfig> implements IVisualConfigService { |
||||
|
||||
} |
||||
*/ |
||||
|
||||
|
@ -0,0 +1,155 @@
@@ -0,0 +1,155 @@
|
||||
package com.cloud.kicc.commonbiz.bigscreen.util; |
||||
|
||||
import java.util.Map; |
||||
import java.util.Properties; |
||||
import java.util.function.Function; |
||||
import java.util.stream.Stream; |
||||
|
||||
/** |
||||
*<p> |
||||
* 占位符解析器 |
||||
*</p> |
||||
* |
||||
* @Author: wangxiang4 |
||||
* @since: 2023/7/3 |
||||
*/ |
||||
public class PlaceholderUtil { |
||||
/** |
||||
* 默认前缀占位符 |
||||
*/ |
||||
public static final String DEFAULT_PLACEHOLDER_PREFIX = "${"; |
||||
|
||||
/** |
||||
* 默认后缀占位符 |
||||
*/ |
||||
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}"; |
||||
|
||||
/** |
||||
* 默认单例解析器 |
||||
*/ |
||||
private static final PlaceholderUtil DEFAULT_RESOLVER = new PlaceholderUtil(); |
||||
|
||||
/** |
||||
* 占位符前缀 |
||||
*/ |
||||
private String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX; |
||||
|
||||
/** |
||||
* 占位符后缀 |
||||
*/ |
||||
private String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX; |
||||
|
||||
|
||||
private PlaceholderUtil() { |
||||
} |
||||
|
||||
private PlaceholderUtil(String placeholderPrefix, String placeholderSuffix) { |
||||
this.placeholderPrefix = placeholderPrefix; |
||||
this.placeholderSuffix = placeholderSuffix; |
||||
} |
||||
|
||||
/** |
||||
* 获取默认的占位符解析器,即占位符前缀为"${", 后缀为"}" |
||||
* |
||||
* @return PlaceholderUtil |
||||
*/ |
||||
public static PlaceholderUtil getDefaultResolver() { |
||||
return DEFAULT_RESOLVER; |
||||
} |
||||
|
||||
public static PlaceholderUtil getResolver(String placeholderPrefix, String placeholderSuffix) { |
||||
return new PlaceholderUtil(placeholderPrefix, placeholderSuffix); |
||||
} |
||||
|
||||
/** |
||||
* 解析带有指定占位符的模板字符串,默认占位符为前缀:${ 后缀:}<br/><br/> |
||||
* 如:template = category:${}:product:${}<br/> |
||||
* values = {"1", "2"}<br/> |
||||
* 返回 category:1:product:2<br/> |
||||
* |
||||
* @param content 要解析的带有占位符的模板字符串 |
||||
* @param values 按照模板占位符索引位置设置对应的值 |
||||
* @return {String} |
||||
*/ |
||||
public String resolve(String content, String... values) { |
||||
int start = content.indexOf(this.placeholderPrefix); |
||||
if (start == -1) { |
||||
return content; |
||||
} |
||||
//值索引
|
||||
int valueIndex = 0; |
||||
StringBuilder result = new StringBuilder(content); |
||||
while (start != -1) { |
||||
int end = result.indexOf(this.placeholderSuffix); |
||||
String replaceContent = values[valueIndex++]; |
||||
result.replace(start, end + this.placeholderSuffix.length(), replaceContent); |
||||
start = result.indexOf(this.placeholderPrefix, start + replaceContent.length()); |
||||
} |
||||
return result.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 解析带有指定占位符的模板字符串,默认占位符为前缀:${ 后缀:}<br/><br/> |
||||
* 如:template = category:${}:product:${}<br/> |
||||
* values = {"1", "2"}<br/> |
||||
* 返回 category:1:product:2<br/> |
||||
* |
||||
* @param content 要解析的带有占位符的模板字符串 |
||||
* @param values 按照模板占位符索引位置设置对应的值 |
||||
* @return {String} |
||||
*/ |
||||
public String resolve(String content, Object[] values) { |
||||
return resolve(content, Stream.of(values).map(String::valueOf).toArray(String[]::new)); |
||||
} |
||||
|
||||
/** |
||||
* 根据替换规则来替换指定模板中的占位符值 |
||||
* |
||||
* @param content 要解析的字符串 |
||||
* @param rule 解析规则回调 |
||||
* @return {String} |
||||
*/ |
||||
public String resolveByRule(String content, Function<String, String> rule) { |
||||
int start = content.indexOf(this.placeholderPrefix); |
||||
if (start == -1) { |
||||
return content; |
||||
} |
||||
StringBuilder result = new StringBuilder(content); |
||||
while (start != -1) { |
||||
int end = result.indexOf(this.placeholderSuffix, start + 1); |
||||
//获取占位符属性值,如${id}, 即获取id
|
||||
String placeholder = result.substring(start + this.placeholderPrefix.length(), end); |
||||
//替换整个占位符内容,即将${id}值替换为替换规则回调中的内容
|
||||
String replaceContent = placeholder.trim().isEmpty() ? "" : rule.apply(placeholder); |
||||
result.replace(start, end + this.placeholderSuffix.length(), replaceContent); |
||||
start = result.indexOf(this.placeholderPrefix, start + replaceContent.length()); |
||||
} |
||||
return result.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 替换模板中占位符内容,占位符的内容即为map key对应的值,key为占位符中的内容。<br/><br/> |
||||
* 如:content = product:${id}:detail:${did}<br/> |
||||
* valueMap = id -> 1; pid -> 2<br/> |
||||
* 经过解析返回 product:1:detail:2<br/> |
||||
* |
||||
* @param content 模板内容 |
||||
* @param valueMap 值映射 |
||||
* @return 替换完成后的字符串 |
||||
*/ |
||||
public String resolveByMap(String content, final Map<String, Object> valueMap) { |
||||
return resolveByRule(content, placeholderValue -> String.valueOf(valueMap.get(placeholderValue))); |
||||
} |
||||
|
||||
/** |
||||
* 根据properties文件替换占位符内容 |
||||
* |
||||
* @param content 模板内容 |
||||
* @param properties 配置 |
||||
* @return {String} |
||||
*/ |
||||
public String resolveByProperties(String content, final Properties properties) { |
||||
return resolveByRule(content, properties::getProperty); |
||||
} |
||||
|
||||
} |
@ -1,103 +0,0 @@
@@ -1,103 +0,0 @@
|
||||
package com.cloud.kicc.commonbiz.util; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.hutool.http.HttpResponse; |
||||
import cn.hutool.http.HttpUtil; |
||||
import cn.hutool.json.JSONObject; |
||||
import cn.hutool.json.JSONUtil; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class BaiduMapUtils { |
||||
|
||||
|
||||
/** |
||||
* 文档地址:http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding
|
||||
* GET请求 |
||||
* callback 将json格式的返回值通过callback函数返回以实现jsonp功能 |
||||
* 示例:http://api.map.baidu.com/geocoding/v3/?address=北京市海淀区上地十街10号&output=json&ak=您的ak&callback=showLocation
|
||||
*/ |
||||
public static Map<String, Object> getLngAndLat(String address, String ak) { |
||||
HttpResponse res = null; |
||||
try { |
||||
res = HttpUtil |
||||
.createGet("http://api.map.baidu.com/geocoding/v3/?address=" + address + "&output=json&ak=" + ak) |
||||
.header("Content-Type", "application/json") |
||||
.execute().charset("UTF-8"); |
||||
|
||||
int code = res.getStatus(); |
||||
if (code == 200) { |
||||
String body = res.body(); |
||||
if (StrUtil.isNotBlank(body)) { |
||||
JSONObject jsonObject = JSONUtil.parseObj(body); |
||||
Map<String, Object> resultMap = new HashMap(); |
||||
resultMap.put("longitude", jsonObject.get("lng")); |
||||
resultMap.put("latitude", jsonObject.get("lat")); |
||||
return resultMap; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("==BaiduMap-Api-getLngAndLat,error==" + e.getMessage()); |
||||
} finally { |
||||
if (res != null) { |
||||
res.close(); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据GPS坐标获取定位位置 |
||||
* 文档地址:http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding-abroad
|
||||
* GET请求 |
||||
* coordtype坐标的类型,目前支持的坐标类型包括:bd09ll(百度经纬度坐标)、bd09mc(百度米制坐标)、gcj02ll(国测局经纬度坐标,仅限中国)、wgs84ll( GPS经纬度) 坐标系说明 |
||||
* 示例:http://api.map.baidu.com/reverse_geocoding/v3/?ak=您的ak&output=json&coordtype=wgs84ll&location=31.225696563611,121.49884033194
|
||||
*/ |
||||
public static String getAddress(String lng, String lat, String ak) { |
||||
HttpResponse res = null; |
||||
try { |
||||
String location = lat + "," + lng; |
||||
res = HttpUtil |
||||
.createGet("http://api.map.baidu.com/reverse_geocoding/v3/?location=" + location + "&output=json&coordtype=wgs84ll&ak=" + ak) |
||||
.header("Content-Type", "application/json") |
||||
.execute().charset("UTF-8"); |
||||
|
||||
int code = res.getStatus(); |
||||
if (code == 200) { |
||||
String body = res.body(); |
||||
if (StrUtil.isNotBlank(body)) { |
||||
JSONObject jsonObject = JSONUtil.parseObj(body); |
||||
if (jsonObject.getInt("status") == 0) { |
||||
String addr = jsonObject.getJSONObject("result").getStr("formatted_address"); |
||||
return addr; |
||||
} |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("==BaiduMap-Api-getAddress,error==" + e.getMessage()); |
||||
} finally { |
||||
if (res != null) { |
||||
res.close(); |
||||
} |
||||
} |
||||
return null; |
||||
|
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
//String addr = getAddress("112.917007","28.280622","WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d");
|
||||
//String addr = getAddress("108.379051", "30.808975", "gIZFKgVkaqGOFTDSSrbklWjesguyrM8H");
|
||||
|
||||
//String addr = getAddress("112.92457569595736", "28.29473945087382", "WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d");
|
||||
//String addr = getAddress("112.91276433", "28.29194017", "WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d");
|
||||
String addr = getAddress("112.88416317", "28.22842167", "WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d"); |
||||
|
||||
//String addr = getAddress("11254.76586", "28.21360333", "WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d");
|
||||
System.out.println(addr); |
||||
/*Map<String, Object> address = getLngAndLat("湖南省长沙市望城区梅园路","WpNIUTCTrECQQyrGDv4x3Gx1CdNRCm5d"); |
||||
System.out.println(address.toString());*/ |
||||
} |
||||
} |
||||
|
@ -1,200 +0,0 @@
@@ -1,200 +0,0 @@
|
||||
package com.cloud.kicc.commonbiz.util; |
||||
|
||||
///
|
||||
|
||||
/// 百度 高德 GPS地图坐标转换类
|
||||
|
||||
/// 地球坐标系(GPS坐标):WGS-84
|
||||
|
||||
//中国的火星坐标系:GCJ-02 使用者:高德、谷歌、腾讯搜搜、阿里云地图、灵图51ditu地图
|
||||
|
||||
//百度坐标系:BD-09 使用者:百度
|
||||
|
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
|
||||
public class GpsGaoAndBaidu { |
||||
|
||||
private static final double x_pi = 3.14159265358979324 * 3000.0 / 180.0; |
||||
|
||||
private static final double pi = 3.14159265358979324; |
||||
private static final double a = 6378245.0; |
||||
private static final double ee = 0.00669342162296594323; |
||||
|
||||
/** |
||||
* gg_lat 纬度 |
||||
* gg_lon 经度 |
||||
* GCJ-02转换BD-09 |
||||
* Google地图经纬度转百度地图经纬度 |
||||
* */ |
||||
public static Point google_bd_encrypt(double gg_lat, double gg_lon){ |
||||
Point point=new Point(); |
||||
double x = gg_lon, y = gg_lat; |
||||
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); |
||||
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); |
||||
double bd_lon = z * Math.cos(theta) + 0.0065; |
||||
double bd_lat = z * Math.sin(theta) + 0.006; |
||||
point.setLat(bd_lat); |
||||
point.setLng(bd_lon); |
||||
return point; |
||||
} |
||||
|
||||
/** |
||||
* wgLat 纬度 |
||||
* wgLon 经度 |
||||
* BD-09转换GCJ-02 |
||||
* 百度转google |
||||
* */ |
||||
public static Point bd_google_encrypt(double bd_lat, double bd_lon){ |
||||
Point point=new Point(); |
||||
double x = bd_lon - 0.0065, y = bd_lat - 0.006; |
||||
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); |
||||
double theta =Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); |
||||
double gg_lon = z * Math.cos(theta); |
||||
double gg_lat = z * Math.sin(theta); |
||||
point.setLat(gg_lat); |
||||
point.setLng(gg_lon); |
||||
return point; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* wgLat 纬度 |
||||
* wgLon 经度 |
||||
* WGS-84 到 GCJ-02 的转换(即 GPS 加偏) |
||||
* */ |
||||
public static Point wgs_gcj_encrypts(double wgLat, double wgLon) { |
||||
Point point=new Point(); |
||||
if (outOfChina(wgLat, wgLon)) { |
||||
point.setLat(wgLat); |
||||
point.setLng(wgLon); |
||||
return point; |
||||
} |
||||
double dLat = transformLat(wgLon - 105.0, wgLat - 35.0); |
||||
double dLon = transformLon(wgLon - 105.0, wgLat - 35.0); |
||||
double radLat = wgLat / 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 lat = wgLat + dLat; |
||||
double lon = wgLon + dLon; |
||||
point.setLat(lat); |
||||
point.setLng(lon); |
||||
return point; |
||||
} |
||||
|
||||
|
||||
public static void transform(double wgLat, double wgLon, double[] latlng) { |
||||
if (outOfChina(wgLat, wgLon)) { |
||||
latlng[0] = wgLat; |
||||
latlng[1] = wgLon; |
||||
return; |
||||
} |
||||
double dLat = transformLat(wgLon - 105.0, wgLat - 35.0); |
||||
double dLon = transformLon(wgLon - 105.0, wgLat - 35.0); |
||||
double radLat = wgLat / 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); |
||||
latlng[0] = wgLat + dLat; |
||||
latlng[1] = wgLon + dLon; |
||||
} |
||||
|
||||
private 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; |
||||
} |
||||
|
||||
private 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; |
||||
} |
||||
|
||||
private 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 Point gpsAddPrecision(String lng, String lat) { |
||||
//进行坐标偏移
|
||||
lng = lng.replace(",E",""); |
||||
lat = lat.replace(",N",""); |
||||
Point p = new Point(); |
||||
p.setLng(gpsCalculate(Double.parseDouble(lng))); |
||||
p.setLat(gpsCalculate(Double.parseDouble(lat))); |
||||
return p; |
||||
} |
||||
|
||||
/** |
||||
* gps转百度坐标 |
||||
* |
||||
* @param gg_lat |
||||
* @param gg_lon |
||||
* @return |
||||
*/ |
||||
public static Point gpsTransformBaidu(double gg_lat, double gg_lon) { |
||||
//进行坐标偏移
|
||||
Point p = wgs_gcj_encrypts(gpsCalculate(gg_lat),gpsCalculate(gg_lon)); |
||||
p = google_bd_encrypt(p.getLat(),p.getLng()); |
||||
System.out.println(p); |
||||
return p; |
||||
} |
||||
|
||||
/** |
||||
* 将经纬度计算得到度分秒格式再转成度格式 |
||||
* |
||||
* @return |
||||
*/ |
||||
public static double gpsCalculate(double num) { |
||||
int a = (int) num / 100; |
||||
double b = (num - a * 100); |
||||
int c = (int) (b); |
||||
double d = (b - c) * 60; |
||||
String e = a + "°" + c + "′" + d + "″"; |
||||
return Dms2D(e); |
||||
} |
||||
|
||||
public static double Dms2D(String dms_data) { |
||||
if (!dms_data.contains("°") || !dms_data.contains("′") || !dms_data.contains("″")) |
||||
return 0; |
||||
double d = Double.parseDouble(dms_data.split("°")[0]); |
||||
double m = Double.parseDouble(dms_data.split("°")[1].split("′")[0]); |
||||
double s = Double.parseDouble(dms_data.split("°")[1].split("′")[1].replace("″", "")); |
||||
return keep8Decimal(d + m / 60 + s / 60 / 60); |
||||
} |
||||
|
||||
//保留8位小数
|
||||
public static double keep8Decimal(double d) { |
||||
BigDecimal bd = new BigDecimal(d); |
||||
double d1 = bd.setScale(8, BigDecimal.ROUND_HALF_UP).doubleValue(); |
||||
System.out.println(d1); |
||||
return d1; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
//"lg": "11253.92844,E",
|
||||
// "lt": "2813.70530,N",
|
||||
//lg":"11253.04979,E","lt":"2812.81620,N"
|
||||
|
||||
System.out.println(gpsCalculate(11253.04979)); |
||||
System.out.println(gpsCalculate(2812.81620)); |
||||
//GpsGaoAndBaidu.gpsTransformBaidu( 2817.51641,11254.76586);
|
||||
} |
||||
} |
||||
|
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
package com.cloud.kicc.commonbiz.util; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 用于构造地图中的坐标点 |
||||
* |
||||
* @author lw |
||||
**/ |
||||
@Data |
||||
public class Point { |
||||
|
||||
private double lat;// 纬度
|
||||
private double lng;// 经度
|
||||
|
||||
public Point() { |
||||
} |
||||
|
||||
public Point(double lng, double lat) { |
||||
this.lng = lng; |
||||
this.lat = lat; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
if (obj instanceof Point) { |
||||
Point bmapPoint = (Point) obj; |
||||
return (bmapPoint.getLng() == lng && bmapPoint.getLat() == lat) ? true : false; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return lng + "," + lat; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,162 @@
@@ -0,0 +1,162 @@
|
||||
package com.cloud.kicc.commonbiz.util; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.cloud.kicc.common.core.constant.StringPool; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import okhttp3.*; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
*<p> |
||||
* Http请求工具类 |
||||
*</p> |
||||
* |
||||
* @Author: wangxiang4 |
||||
* @since: 2023/7/3 |
||||
*/ |
||||
@Slf4j |
||||
public class RequestUtil { |
||||
|
||||
public static MediaType JSON = MediaType.parse("application/json; charset=utf-8"); |
||||
public static String GET = "GET"; |
||||
public static String POST = "POST"; |
||||
public static String PUT = "PUT"; |
||||
public static String DELETE = "DELETE"; |
||||
|
||||
|
||||
/** |
||||
* request |
||||
* |
||||
* @param url 请求url |
||||
* @param header 请求头 |
||||
* @param queries 请求的参数,在浏览器?后面的数据,没有可以传null |
||||
* @param method 请求方法(get delete) |
||||
* @return String |
||||
*/ |
||||
public static String request(String url, Map<String, Object> header, Map<String, Object> queries, String method) { |
||||
|
||||
Request.Builder builder = new Request.Builder().url(requestUrl(url, queries)); |
||||
|
||||
if (header != null && header.keySet().size() > 0) { |
||||
header.forEach((k, v) -> builder.addHeader(k, String.valueOf(v))); |
||||
} |
||||
|
||||
if (StrUtil.equalsIgnoreCase(method, GET)) { |
||||
builder.get(); |
||||
} else if (StrUtil.equalsIgnoreCase(method, DELETE)) { |
||||
builder.delete(); |
||||
} |
||||
|
||||
return getBody(builder.build()); |
||||
} |
||||
|
||||
/** |
||||
* requestUrl |
||||
* |
||||
* @param url 请求url |
||||
* @param queries 请求的参数,在浏览器?后面的数据,没有可以传null |
||||
* @return String |
||||
*/ |
||||
public static String requestUrl(String url, Map<String, Object> queries) { |
||||
StringBuffer sb = new StringBuffer(url).append(StringPool.QUESTION_MARK); |
||||
if (queries != null && queries.keySet().size() > 0) { |
||||
queries.forEach((k, v) -> sb.append("&").append(k).append("=").append(v)); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
/** |
||||
* requestForm |
||||
* |
||||
* @param url 请求url |
||||
* @param header 请求头 |
||||
* @param params post put form 提交的参数 |
||||
* @param method 请求方法(post put) |
||||
* @return String |
||||
*/ |
||||
public static String requestForm(String url, Map<String, Object> header, Map<String, Object> params, String method) { |
||||
FormBody.Builder formBuilder = new FormBody.Builder(); |
||||
//添加参数
|
||||
if (params != null && params.keySet().size() > 0) { |
||||
params.forEach((k, v) -> formBuilder.add(k, String.valueOf(v))); |
||||
} |
||||
|
||||
Request.Builder builder = new Request.Builder().url(url); |
||||
|
||||
if (header != null && header.keySet().size() > 0) { |
||||
header.forEach((k, v) -> builder.addHeader(k, String.valueOf(v))); |
||||
} |
||||
|
||||
if (StrUtil.equalsIgnoreCase(method, POST)) { |
||||
builder.post(formBuilder.build()); |
||||
} else if (StrUtil.equalsIgnoreCase(method, PUT)) { |
||||
builder.put(formBuilder.build()); |
||||
} |
||||
|
||||
return getBody(builder.build()); |
||||
} |
||||
|
||||
/** |
||||
* 请求发送JSON数据 |
||||
* |
||||
* @param url 请求url |
||||
* @param header 请求头 |
||||
* @param json 请求json串 |
||||
* @param method 请求方法(post put) |
||||
* @return String |
||||
*/ |
||||
public static String requestJson(String url, Map<String, Object> header, String json, String method) { |
||||
return requestContent(url, header, json, JSON, method); |
||||
} |
||||
|
||||
/** |
||||
* 发送请求 |
||||
* |
||||
* @param url 请求的url |
||||
* @param header 请求头 |
||||
* @param content 请求内容 |
||||
* @param mediaType 请求类型 |
||||
* @param method 请求方法(post put) |
||||
* @return String |
||||
*/ |
||||
public static String requestContent(String url, Map<String, Object> header, String content, MediaType mediaType, String method) { |
||||
RequestBody requestBody = RequestBody.create(mediaType, content); |
||||
Request.Builder builder = new Request.Builder().url(url); |
||||
if (header != null && header.keySet().size() > 0) { |
||||
header.forEach((k, v) -> builder.addHeader(k, String.valueOf(v))); |
||||
} |
||||
if (StrUtil.equalsIgnoreCase(method, POST)) { |
||||
builder.post(requestBody); |
||||
} else if (StrUtil.equalsIgnoreCase(method, PUT)) { |
||||
builder.put(requestBody); |
||||
} |
||||
return getBody(builder.build()); |
||||
} |
||||
|
||||
/** |
||||
* 获取body |
||||
* |
||||
* @param request request |
||||
* @return String |
||||
*/ |
||||
private static String getBody(Request request) { |
||||
String responseBody = ""; |
||||
Response response = null; |
||||
try { |
||||
OkHttpClient okHttpClient = new OkHttpClient(); |
||||
response = okHttpClient.newCall(request).execute(); |
||||
if (response.isSuccessful()) { |
||||
return response.body().string(); |
||||
} |
||||
} catch (Exception e) { |
||||
log.error("okhttp3 post error >> ex = {}", e.getMessage()); |
||||
} finally { |
||||
if (response != null) { |
||||
response.close(); |
||||
} |
||||
} |
||||
return responseBody; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue