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 c341ad31
authored
Jul 28, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 调整同步接口参数
1 parent
7acc816f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
project-interface/src/main/java/com/dituhui/pea/pojo/BlockSyncRequest.java
project-order/src/main/java/com/dituhui/pea/order/controller/BlockController.java
project-interface/src/main/java/com/dituhui/pea/pojo/BlockSyncRequest.java
View file @
c341ad3
...
...
@@ -7,6 +7,8 @@ public class BlockSyncRequest {
String
blockId
;
Long
area
;
String
points
;
String
parts
;
RegionDTO
region
;
}
project-order/src/main/java/com/dituhui/pea/order/controller/BlockController.java
View file @
c341ad3
package
com
.
dituhui
.
pea
.
order
.
controller
;
import
java.util.Arrays
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -11,6 +13,8 @@ import com.dituhui.pea.common.BusinessException;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.service.IBlockService
;
import
com.dituhui.pea.pojo.BlockSyncRequest
;
import
com.dituhui.pea.pojo.PointBase
;
import
com.dituhui.pea.pojo.RegionDTO
;
/**
* 服务范围相关接口
...
...
@@ -36,12 +40,41 @@ public class BlockController {
if
(
request
==
null
||
StringUtils
.
isBlank
(
request
.
getBlockId
()))
{
return
Result
.
failure
(
"缺少参数blockId"
);
}
if
(
null
==
request
.
getRegion
(
))
{
return
Result
.
failure
(
"缺少参数
region
"
);
if
(
StringUtils
.
isBlank
(
request
.
getPoints
()
))
{
return
Result
.
failure
(
"缺少参数
points
"
);
}
Result
<
Boolean
>
res
=
null
;
try
{
RegionDTO
region
=
new
RegionDTO
();
String
[]
xys
=
request
.
getPoints
().
split
(
";"
);
Arrays
.
asList
(
xys
).
stream
().
map
(
xy
->
{
String
[]
temp
=
xy
.
split
(
","
);
PointBase
p
=
new
PointBase
();
p
.
setX
(
Double
.
parseDouble
(
temp
[
0
]));
p
.
setY
(
Double
.
parseDouble
(
temp
[
1
]));
return
p
;
});
PointBase
[]
points
=
new
PointBase
[
xys
.
length
];
for
(
int
i
=
0
;
i
<
points
.
length
;
i
++)
{
String
xy
=
xys
[
i
];
String
[]
temp
=
xy
.
split
(
","
);
PointBase
p
=
new
PointBase
();
p
.
setX
(
Double
.
parseDouble
(
temp
[
0
]));
p
.
setY
(
Double
.
parseDouble
(
temp
[
1
]));
points
[
i
]
=
p
;
}
region
.
setPoints
(
points
);
if
(
StringUtils
.
isBlank
(
request
.
getParts
()))
{
String
[]
temp
=
request
.
getParts
().
split
(
","
);
Integer
[]
parts
=
new
Integer
[
temp
.
length
];
for
(
int
i
=
0
;
i
<
parts
.
length
;
i
++)
{
parts
[
i
]
=
Integer
.
parseInt
(
temp
[
i
]);
}
region
.
setParts
(
parts
);
}
res
=
blockService
.
synchronizeBlock
(
request
.
getBlockId
(),
request
.
getArea
(),
request
.
getRegion
());
}
catch
(
BusinessException
e
)
{
return
Result
.
failure
(
e
.
getMessage
());
...
...
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