杆塔管理
This commit is contained in:
parent
27a1a971ef
commit
f2f452bb5c
|
|
@ -52,4 +52,17 @@ public class TbTowerController {
|
||||||
public ServerResponse getTbTowerById(EncryptedReq<TbTowerVo> dto) {
|
public ServerResponse getTbTowerById(EncryptedReq<TbTowerVo> dto) {
|
||||||
return tbTowerService.getTbTowerById(dto.getData());
|
return tbTowerService.getTbTowerById(dto.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理-新增
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "addTbTower")
|
||||||
|
@DecryptAndVerify(decryptedClass = TbTowerVo.class)//加解密统一管理
|
||||||
|
@LogAnnotation(operModul = "杆塔管理-新增", operation = "新增", operDesc = "系统级事件",operType="查询")
|
||||||
|
public ServerResponse addTbTower(EncryptedReq<TbTowerVo> dto) {
|
||||||
|
return tbTowerService.addTbTower(dto.getData());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,8 @@ public interface TbTowerMapper {
|
||||||
List<TbTowerVo> getTbProjectList(TbTowerVo data);
|
List<TbTowerVo> getTbProjectList(TbTowerVo data);
|
||||||
|
|
||||||
TbTowerVo getTbTowerById(TbTowerVo data);
|
TbTowerVo getTbTowerById(TbTowerVo data);
|
||||||
|
|
||||||
|
void addTbTower(TbTowerVo data);
|
||||||
|
|
||||||
|
TbTowerVo getTbTowerBySort(TbTowerVo data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,11 @@ public interface TbTowerService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ServerResponse getTbTowerById(TbTowerVo data);
|
ServerResponse getTbTowerById(TbTowerVo data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理-新增
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ServerResponse addTbTower(TbTowerVo data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,17 @@ import com.bonus.digitalSignage.basic.dao.TbTowerMapper;
|
||||||
import com.bonus.digitalSignage.basic.service.TbTowerService;
|
import com.bonus.digitalSignage.basic.service.TbTowerService;
|
||||||
import com.bonus.digitalSignage.basic.vo.TbProjectVo;
|
import com.bonus.digitalSignage.basic.vo.TbProjectVo;
|
||||||
import com.bonus.digitalSignage.basic.vo.TbTowerVo;
|
import com.bonus.digitalSignage.basic.vo.TbTowerVo;
|
||||||
|
import com.bonus.digitalSignage.utils.CoordinateConverter;
|
||||||
import com.bonus.digitalSignage.utils.ServerResponse;
|
import com.bonus.digitalSignage.utils.ServerResponse;
|
||||||
|
import com.bonus.digitalSignage.utils.StrUtil;
|
||||||
|
import com.bonus.digitalSignage.utils.UserUtil;
|
||||||
|
import com.bonus.digitalSignage.webResult.StringUtils;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,4 +60,41 @@ public class TbTowerServiceImpl implements TbTowerService {
|
||||||
return ServerResponse.createErroe("杆塔管理-查询详情失败");
|
return ServerResponse.createErroe("杆塔管理-查询详情失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杆塔管理-新增
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServerResponse addTbTower(TbTowerVo data) {
|
||||||
|
try {
|
||||||
|
//判断经纬度是否合法
|
||||||
|
if(!StrUtil.isValidLongitude(Double.parseDouble(data.getLon())) || !StrUtil.isValidLatitude(Double.parseDouble(data.getLat()))){
|
||||||
|
return ServerResponse.createErroe("请输入正确经纬度");
|
||||||
|
}
|
||||||
|
TbTowerVo tbTower = tbTowerMapper.getTbTowerBySort(data);
|
||||||
|
if (StringUtils.isNotNull(tbTower)){
|
||||||
|
return ServerResponse.createErroe("排序已存在");
|
||||||
|
}
|
||||||
|
//判断新增塔杆的坐标系 1.WGS-84地心坐标系 2.2000国家大地坐标系
|
||||||
|
if ("1".equals(data.getUploadType())){
|
||||||
|
double[] bd09 =CoordinateConverter.wgs84ToBd09(Double.parseDouble(data.getLat()),Double.parseDouble(data.getLon()));
|
||||||
|
data.setBaiduLat(String.valueOf(bd09[0]));
|
||||||
|
data.setBaiduLon(String.valueOf(bd09[1]));
|
||||||
|
}else {
|
||||||
|
double[] bd09 =CoordinateConverter.cgcs2000ToBd09(Double.parseDouble(data.getLat()),Double.parseDouble(data.getLon()));
|
||||||
|
data.setBaiduLat(String.valueOf(bd09[0]));
|
||||||
|
data.setBaiduLon(String.valueOf(bd09[1]));
|
||||||
|
}
|
||||||
|
Long userId = UserUtil.getLoginUser().getId();
|
||||||
|
data.setCreateUserId(userId);
|
||||||
|
data.setCreateTime(new Date());
|
||||||
|
tbTowerMapper.addTbTower(data);
|
||||||
|
return ServerResponse.createSuccess("杆塔管理-新增成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
return ServerResponse.createErroe("杆塔管理-新增失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
package com.bonus.digitalSignage.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2025/4/25
|
||||||
|
*/
|
||||||
|
public class CoordinateConverter {
|
||||||
|
private static final double PI = 3.14159265358979324;
|
||||||
|
private static final double X_PI = PI * 3000.0 / 180.0;
|
||||||
|
private static final double A = 6378245.0;
|
||||||
|
private static final double EE = 0.00669342162296594323;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否在中国范围内
|
||||||
|
* @param lat 纬度
|
||||||
|
* @param lon 经度
|
||||||
|
* @return 如果在中国范围内返回 true,否则返回 false
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换纬度
|
||||||
|
* @param x 经度
|
||||||
|
* @param y 纬度
|
||||||
|
* @return 转换后的纬度
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换经度
|
||||||
|
* @param x 经度
|
||||||
|
* @param y 纬度
|
||||||
|
* @return 转换后的经度
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WGS - 84 转换为 GCJ - 02
|
||||||
|
* @param wgLat WGS - 84 纬度
|
||||||
|
* @param wgLon WGS - 84 经度
|
||||||
|
* @return 包含 GCJ - 02 纬度和经度的数组
|
||||||
|
*/
|
||||||
|
public static double[] wgs84ToGcj02(double wgLat, double wgLon) {
|
||||||
|
/* if (outOfChina(wgLat, wgLon)) {
|
||||||
|
return new double[]{wgLat, wgLon};
|
||||||
|
}*/
|
||||||
|
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 mgLat = wgLat + dLat;
|
||||||
|
double mgLon = wgLon + dLon;
|
||||||
|
return new double[]{mgLat, mgLon};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GCJ - 02 转换为 BD - 09
|
||||||
|
* @param ggLat GCJ - 02 纬度
|
||||||
|
* @param ggLon GCJ - 02 经度
|
||||||
|
* @return 包含 BD - 09 纬度和经度的数组
|
||||||
|
*/
|
||||||
|
public static double[] gcj02ToBd09(double ggLat, double ggLon) {
|
||||||
|
double x = ggLon;
|
||||||
|
double y = ggLat;
|
||||||
|
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 bdLon = z * Math.cos(theta) + 0.0065;
|
||||||
|
double bdLat = z * Math.sin(theta) + 0.006;
|
||||||
|
return new double[]{bdLat, bdLon};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WGS - 84 转换为 BD - 09
|
||||||
|
* @param wgLat WGS - 84 纬度
|
||||||
|
* @param wgLon WGS - 84 经度
|
||||||
|
* @return 包含 BD - 09 纬度和经度的数组
|
||||||
|
*/
|
||||||
|
public static double[] wgs84ToBd09(double wgLat, double wgLon) {
|
||||||
|
double[] gcj02 = wgs84ToGcj02(wgLat, wgLon);
|
||||||
|
return gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CGCS2000 转换为 GCJ - 02
|
||||||
|
* @param cgLat CGCS2000 纬度
|
||||||
|
* @param cgLon CGCS2000 经度
|
||||||
|
* @return 包含 GCJ - 02 纬度和经度的数组
|
||||||
|
*/
|
||||||
|
public static double[] cgcs2000ToGcj02(double cgLat, double cgLon) {
|
||||||
|
if (outOfChina(cgLat, cgLon)) {
|
||||||
|
return new double[]{cgLat, cgLon};
|
||||||
|
}
|
||||||
|
double dLat = transformLat(cgLon - 105.0, cgLat - 35.0);
|
||||||
|
double dLon = transformLon(cgLon - 105.0, cgLat - 35.0);
|
||||||
|
double radLat = cgLat / 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 = cgLat + dLat;
|
||||||
|
double mgLon = cgLon + dLon;
|
||||||
|
return new double[]{mgLat, mgLon};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CGCS2000 转换为 BD - 09
|
||||||
|
* @param cgLat CGCS2000 纬度
|
||||||
|
* @param cgLon CGCS2000 经度
|
||||||
|
* @return 包含 BD - 09 纬度和经度的数组
|
||||||
|
*/
|
||||||
|
public static double[] cgcs2000ToBd09(double cgLat, double cgLon) {
|
||||||
|
double[] gcj02 = cgcs2000ToGcj02(cgLat, cgLon);
|
||||||
|
return gcj02ToBd09(gcj02[0], gcj02[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
double wgLat = 31.230416;
|
||||||
|
double wgLon = 121.473701;
|
||||||
|
double[] bd09 = wgs84ToBd09(wgLat, wgLon);
|
||||||
|
System.out.println("BD - 09 Latitude: " + bd09[0]);
|
||||||
|
System.out.println("BD - 09 Longitude: " + bd09[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,4 +50,21 @@ public class StrUtil {
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验经度是否合法
|
||||||
|
* @param longitude 经度值
|
||||||
|
* @return 如果经度在合法范围内返回 true,否则返回 false
|
||||||
|
*/
|
||||||
|
public static boolean isValidLongitude(double longitude) {
|
||||||
|
return longitude >= -180 && longitude <= 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验纬度是否合法
|
||||||
|
* @param latitude 纬度值
|
||||||
|
* @return 如果纬度在合法范围内返回 true,否则返回 false
|
||||||
|
*/
|
||||||
|
public static boolean isValidLatitude(double latitude) {
|
||||||
|
return latitude >= -90 && latitude <= 90;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,37 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bonus.digitalSignage.basic.dao.TbTowerMapper">
|
<mapper namespace="com.bonus.digitalSignage.basic.dao.TbTowerMapper">
|
||||||
|
<insert id="addTbTower">
|
||||||
|
insert into tb_tower
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="proId != null ">pro_id,</if>
|
||||||
|
<if test="towerName != null ">tower_name,</if>
|
||||||
|
<if test="lon != null ">lon,</if>
|
||||||
|
<if test="lat != null ">lat,</if>
|
||||||
|
<if test="baiduLon != null">baidu_lon,</if>
|
||||||
|
<if test="baiduLat != null ">baidu_lat,</if>
|
||||||
|
<if test="sort != null ">sort,</if>
|
||||||
|
<if test="centralMeridian != null ">central_meridian,</if>
|
||||||
|
<if test="uploadType != null ">upload_type,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="createUser != null ">create_user,</if>
|
||||||
|
is_actvice
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="proId != null ">#{proId},</if>
|
||||||
|
<if test="towerName != null ">#{towerName},</if>
|
||||||
|
<if test="lon != null ">#{lon},</if>
|
||||||
|
<if test="lat != null ">#{lat},</if>
|
||||||
|
<if test="baiduLon != null ">#{baiduLon},</if>
|
||||||
|
<if test="baiduLat != null ">#{baiduLat},</if>
|
||||||
|
<if test="sort != null ">#{sort},</if>
|
||||||
|
<if test="centralMeridian != null ">#{centralMeridian},</if>
|
||||||
|
<if test="uploadType != null ">#{uploadType},</if>
|
||||||
|
<if test="createTime != null ">#{createTime},</if>
|
||||||
|
<if test="createUser != null ">#{createUser},</if>
|
||||||
|
1
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="getTbProjectList" resultType="com.bonus.digitalSignage.basic.vo.TbTowerVo">
|
<select id="getTbProjectList" resultType="com.bonus.digitalSignage.basic.vo.TbTowerVo">
|
||||||
select id as id,pro_id as proId,tower_name as towerName,lon as lon,lat as lat,
|
select id as id,pro_id as proId,tower_name as towerName,lon as lon,lat as lat,
|
||||||
|
|
@ -14,4 +45,10 @@
|
||||||
upload_type as uploadType
|
upload_type as uploadType
|
||||||
from tb_tower where id = #{id}
|
from tb_tower where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getTbTowerBySort" resultType="com.bonus.digitalSignage.basic.vo.TbTowerVo">
|
||||||
|
select id as id,pro_id as proId,tower_name as towerName,lon as lon,lat as lat,
|
||||||
|
baidu_lon as baiduLon,baidu_lat as baiduLat,sort as sort,central_meridian as centralMeridian,
|
||||||
|
upload_type as uploadType
|
||||||
|
from tb_tower where id = #{id} and sort = #{sort}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue