Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
signal
traffic-signal-platform
Commits
1dfc8641
Commit
1dfc8641
authored
Feb 08, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[udpate] 辖区分组优化代码结构,信号机添加经纬度
parent
2561c1b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
18 deletions
+44
-18
SituationDetectionController.java
...et/wanji/web/controller/SituationDetectionController.java
+1
-1
SituationDetectionService.java
...java/net/wanji/web/service/SituationDetectionService.java
+1
-1
SituationDetectionServiceImpl.java
...wanji/web/service/impl/SituationDetectionServiceImpl.java
+42
-16
No files found.
signal-control-service/src/main/java/net/wanji/web/controller/SituationDetectionController.java
View file @
1dfc8641
...
...
@@ -168,7 +168,7 @@ public class SituationDetectionController extends BaseController {
@ApiOperation
(
value
=
"辖区分组"
,
notes
=
"辖区分组"
)
@GetMapping
(
"/jurisdictionTree"
)
public
JsonViewObject
jurisdictionTree
(
Integer
areaId
)
{
public
JsonViewObject
jurisdictionTree
(
Integer
areaId
)
throws
Exception
{
List
<
JurisdictionAreaTreeVO
>
result
=
situationDetectionService
.
jurisdictionTree
(
areaId
);
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
return
jsonViewObject
.
success
(
result
);
...
...
signal-control-service/src/main/java/net/wanji/web/service/SituationDetectionService.java
View file @
1dfc8641
...
...
@@ -35,7 +35,7 @@ public interface SituationDetectionService {
TBaseCrossInfo
selectCrossInfoById
(
String
signalId
);
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
);
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
)
throws
Exception
;
List
<
AreaListVO
>
selectAreaList
(
Integer
areaId
);
...
...
signal-control-service/src/main/java/net/wanji/web/service/impl/SituationDetectionServiceImpl.java
View file @
1dfc8641
...
...
@@ -404,7 +404,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
}
@Override
public
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
)
{
public
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
)
throws
Exception
{
List
<
JurisdictionAreaTreeVO
>
resultList
=
new
ArrayList
<>();
// 辖区构建
LambdaQueryWrapper
<
TBaseAreaInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
...
...
@@ -420,6 +420,38 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
LambdaQueryWrapper
<
TBaseCrossInfo
>
crossInfoQuery
=
new
LambdaQueryWrapper
<>();
List
<
TBaseCrossInfo
>
tBaseCrossInfos
=
tBaseCrossInfoMapper
.
selectList
(
crossInfoQuery
);
List
<
CrossInfoOutVo
>
crossInfoOutVoList
=
getCrossInfoOutVoList
(
new
CrossInfoVO
());
getJurisdictionAreaTreeVO
(
resultList
,
tBaseAreaInfos
,
tBaseAreaCrosses
,
tBaseCrossInfos
,
crossInfoOutVoList
);
// 构建树结构
Map
<
String
,
List
<
JurisdictionAreaTreeVO
>>
map
=
resultList
.
stream
().
collect
(
Collectors
.
groupingBy
(
JurisdictionAreaTreeVO:
:
getParentCode
));
for
(
JurisdictionAreaTreeVO
jurisdictionAreaTreeVO
:
resultList
)
{
for
(
Map
.
Entry
<
String
,
List
<
JurisdictionAreaTreeVO
>>
entry
:
map
.
entrySet
())
{
if
(
Objects
.
equals
(
jurisdictionAreaTreeVO
.
getId
(),
entry
.
getKey
()))
{
jurisdictionAreaTreeVO
.
setChlidren
(
entry
.
getValue
());
break
;
}
}
}
List
<
JurisdictionAreaTreeVO
>
collect
=
resultList
.
stream
().
filter
(
vo
->
StringUtils
.
equals
(
"0"
,
vo
.
getParentCode
())).
collect
(
Collectors
.
toList
());
return
collect
;
}
/**
* 构建返回所有辖区集合
*
* @param resultList
* @param tBaseAreaInfos
* @param tBaseAreaCrosses
* @param tBaseCrossInfos
*/
private
static
void
getJurisdictionAreaTreeVO
(
List
<
JurisdictionAreaTreeVO
>
resultList
,
List
<
TBaseAreaInfo
>
tBaseAreaInfos
,
List
<
TBaseAreaCross
>
tBaseAreaCrosses
,
List
<
TBaseCrossInfo
>
tBaseCrossInfos
,
List
<
CrossInfoOutVo
>
crossInfoOutVoList
)
{
// 构建辖区实体
for
(
TBaseAreaInfo
parent
:
tBaseAreaInfos
)
{
JurisdictionAreaTreeVO
jurisdictionAreaVO
=
new
JurisdictionAreaTreeVO
();
jurisdictionAreaVO
.
setId
(
String
.
valueOf
(
parent
.
getCode
()));
...
...
@@ -431,6 +463,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
jurisdictionAreaVO
.
setChlidren
(
null
);
resultList
.
add
(
jurisdictionAreaVO
);
}
// 将路口转化为辖区实体
for
(
TBaseAreaInfo
parent
:
tBaseAreaInfos
)
{
Integer
parentCode
=
parent
.
getCode
();
for
(
TBaseAreaCross
tBaseAreaCross
:
tBaseAreaCrosses
)
{
...
...
@@ -438,35 +471,28 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
JurisdictionAreaTreeVO
signalAreaVO
=
new
JurisdictionAreaTreeVO
();
signalAreaVO
.
setId
(
tBaseAreaCross
.
getCrossId
());
String
name
=
null
;
String
location
=
null
;
for
(
TBaseCrossInfo
tBaseCrossInfo
:
tBaseCrossInfos
)
{
if
(
StringUtils
.
equals
(
tBaseCrossInfo
.
getId
(),
tBaseAreaCross
.
getCrossId
()))
{
name
=
tBaseCrossInfo
.
getName
();
break
;
}
}
for
(
CrossInfoOutVo
crossInfoOutVo
:
crossInfoOutVoList
)
{
if
(
StringUtils
.
equals
(
crossInfoOutVo
.
getId
(),
tBaseAreaCross
.
getCrossId
()))
{
location
=
crossInfoOutVo
.
getLocation
();
break
;
}
}
signalAreaVO
.
setName
(
name
);
signalAreaVO
.
setType
(
"2"
);
signalAreaVO
.
setPolylines
(
""
);
signalAreaVO
.
setPolylines
(
location
);
signalAreaVO
.
setParentCode
(
String
.
valueOf
(
parentCode
));
signalAreaVO
.
setChlidren
(
null
);
resultList
.
add
(
signalAreaVO
);
}
}
}
Map
<
String
,
List
<
JurisdictionAreaTreeVO
>>
map
=
resultList
.
stream
().
collect
(
Collectors
.
groupingBy
(
JurisdictionAreaTreeVO:
:
getParentCode
));
for
(
JurisdictionAreaTreeVO
jurisdictionAreaTreeVO
:
resultList
)
{
for
(
Map
.
Entry
<
String
,
List
<
JurisdictionAreaTreeVO
>>
entry
:
map
.
entrySet
())
{
if
(
Objects
.
equals
(
jurisdictionAreaTreeVO
.
getId
(),
entry
.
getKey
()))
{
jurisdictionAreaTreeVO
.
setChlidren
(
entry
.
getValue
());
break
;
}
}
}
List
<
JurisdictionAreaTreeVO
>
collect
=
resultList
.
stream
().
filter
(
vo
->
StringUtils
.
equals
(
"0"
,
vo
.
getParentCode
())).
collect
(
Collectors
.
toList
());
return
collect
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment