Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bbf4dbe9
authored
Aug 01, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加区块中心点配置
1 parent
bd18c64a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
2 deletions
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoMPDao.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/utils/RegionUtils.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoMPDao.java
View file @
bbf4dbe
...
@@ -10,4 +10,8 @@ public interface MapBlockInfoMPDao extends BaseMapper<MapBlockInfo> {
...
@@ -10,4 +10,8 @@ public interface MapBlockInfoMPDao extends BaseMapper<MapBlockInfo> {
@Select
(
"select * from map_block_info where block_id=#{blockId}"
)
@Select
(
"select * from map_block_info where block_id=#{blockId}"
)
MapBlockInfo
getByBlockId
(
String
blockId
);
MapBlockInfo
getByBlockId
(
String
blockId
);
@Select
(
"select * from map_block_info where team_id=#{teamId} and layer_id=#{layerId}"
)
MapBlockInfo
getByTeamIdAndLayerId
(
String
teamId
,
String
layerId
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessBlockServiceImpl.java
View file @
bbf4dbe
...
@@ -12,6 +12,7 @@ import com.dituhui.pea.order.dto.BusinessServerBlocksRespDTO;
...
@@ -12,6 +12,7 @@ import com.dituhui.pea.order.dto.BusinessServerBlocksRespDTO;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.order.feign.ISaaSRemoteService
;
import
com.dituhui.pea.order.service.BusinessBlockService
;
import
com.dituhui.pea.order.service.BusinessBlockService
;
import
com.dituhui.pea.order.utils.RegionUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
com.dituhui.pea.order.utils.TypeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -45,6 +46,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -45,6 +46,9 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
@Autowired
@Autowired
private
ISaaSRemoteService
saasRemoteService
;
private
ISaaSRemoteService
saasRemoteService
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Value
(
"${SaaS.ak}"
)
@Value
(
"${SaaS.ak}"
)
String
ak
;
String
ak
;
...
@@ -147,9 +151,16 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
...
@@ -147,9 +151,16 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
throw
new
BusinessException
(
"关联小队不存在"
);
throw
new
BusinessException
(
"关联小队不存在"
);
}
}
// 重复检查layerId+teamId
MapBlockInfo
existBlock
=
mapBlockInfoMPDao
.
getByTeamIdAndLayerId
(
teamId
,
layerId
);
if
(
null
!=
existBlock
)
{
return
Result
.
failure
(
"区块已存在"
);
}
// 同步到saas,返回blockId
// 同步到saas,返回blockId
// 获取小队出发点,初始化区块 TODO
// 获取小队出发点,初始化区块
String
region
=
"{points:[{\"x\":1.3720127240270969E7,\"y\":3692634.103416302},{\"x\":1.37245800199027E7,\"y\":3692634.103416302},{\"x\":1.3720127240270969E7,\"y\":3744947.448648849},{\"x\":1.3720127240270969E7,\"y\":3692634.103416302}]}"
;
OrgGroupEntity
group
=
orgGroupDao
.
getByGroupId
(
team
.
getGroupId
());
String
region
=
RegionUtils
.
constructRegion
(
group
.
getX
(),
group
.
getY
());
String
result
=
saasRemoteService
.
addArea
(
ak
,
team
.
getTeamName
(),
layerId
,
region
,
"gcj02mc"
);
String
result
=
saasRemoteService
.
addArea
(
ak
,
team
.
getTeamName
(),
layerId
,
region
,
"gcj02mc"
);
log
.
info
(
"params:{} {} {} result:{}"
,
team
.
getTeamName
(),
layerId
,
region
,
result
);
log
.
info
(
"params:{} {} {} result:{}"
,
team
.
getTeamName
(),
layerId
,
region
,
result
);
Result
<
String
>
saasResult
=
TypeUtils
.<
String
>
convertResult
(
result
);
Result
<
String
>
saasResult
=
TypeUtils
.<
String
>
convertResult
(
result
);
...
...
project-order/src/main/java/com/dituhui/pea/order/utils/RegionUtils.java
0 → 100644
View file @
bbf4dbe
package
com
.
dituhui
.
pea
.
order
.
utils
;
import
com.dituhui.pea.pojo.PointBase
;
import
com.dituhui.pea.pojo.RegionDTO
;
import
com.google.gson.Gson
;
public
class
RegionUtils
{
private
final
static
Gson
gson
=
new
Gson
();
public
static
String
constructRegion
(
String
x
,
String
y
)
{
double
xx
=
Double
.
parseDouble
(
x
);
double
yy
=
Double
.
parseDouble
(
y
);
RegionDTO
region
=
convertXyToRegion
(
xx
,
yy
);
return
gson
.
toJson
(
region
);
}
public
static
RegionDTO
convertXyToRegion
(
double
x
,
double
y
)
{
// 经纬度转墨卡托坐标
double
xx
=
gcj02LngToMercator
(
x
);
double
yy
=
gcj02LatToMercator
(
y
);
// 构造正方形
PointBase
point1
=
new
PointBase
();
point1
.
setX
(
xx
);
point1
.
setY
(
yy
);
PointBase
point2
=
new
PointBase
();
point2
.
setX
(
xx
+
100
);
point2
.
setY
(
yy
);
PointBase
point3
=
new
PointBase
();
point3
.
setX
(
xx
+
100
);
point3
.
setY
(
yy
+
100
);
PointBase
point4
=
new
PointBase
();
point4
.
setX
(
xx
);
point4
.
setY
(
yy
+
100
);
PointBase
[]
points
=
new
PointBase
[]
{
point1
,
point2
,
point3
,
point4
,
point1
};
RegionDTO
region
=
new
RegionDTO
();
region
.
setPoints
(
points
);
return
region
;
}
private
static
double
gcj02LngToMercator
(
double
x
)
{
double
mx
=
x
/
180.0
D
*
2.0037508342789244E7
D
;
return
mx
;
}
private
static
double
gcj02LatToMercator
(
double
y
)
{
double
my
=
Math
.
log
(
Math
.
tan
((
90.0
D
+
y
)
*
3.141592653589793
D
/
360.0
D
))
/
0.017453292519943295
D
;
my
=
my
/
180.0
D
*
2.0037508342789244E7
D
;
return
my
;
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment