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
35bb34be
Commit
35bb34be
authored
Mar 27, 2025
by
zhouleilei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决信号机同步时,车道数据重复问题
parent
8ebfab8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
PlanSendServiceImpl.java
.../java/net/wanji/web/service/impl/PlanSendServiceImpl.java
+69
-0
No files found.
signal-control-service/src/main/java/net/wanji/web/service/impl/PlanSendServiceImpl.java
View file @
35bb34be
...
@@ -479,6 +479,8 @@ public class PlanSendServiceImpl implements PlanSendService {
...
@@ -479,6 +479,8 @@ public class PlanSendServiceImpl implements PlanSendService {
}
}
}
}
}
}
//解决车道重复问题
crossLaneLightsPOS
=
distinctLaneLights
(
crossLaneLightsPOS
,
crossLightsPOS
);
baseCrossLaneLightsMapper
.
deleteByCrossId
(
crossId
);
baseCrossLaneLightsMapper
.
deleteByCrossId
(
crossId
);
baseCrossLaneLightsMapper
.
insertBatch
(
crossLaneLightsPOS
);
baseCrossLaneLightsMapper
.
insertBatch
(
crossLaneLightsPOS
);
...
@@ -517,6 +519,73 @@ public class PlanSendServiceImpl implements PlanSendService {
...
@@ -517,6 +519,73 @@ public class PlanSendServiceImpl implements PlanSendService {
return
jsonViewObject
.
success
();
return
jsonViewObject
.
success
();
}
}
/**
* @Description 解决车道重复问题
* @Param [crossLaneLightsPOS, crossLightsPOS]
* @return java.util.List<net.wanji.databus.po.CrossLaneLightsPO>
**/
private
List
<
CrossLaneLightsPO
>
distinctLaneLights
(
List
<
CrossLaneLightsPO
>
crossLaneLightsPOS
,
List
<
BaseCrossLightsPO
>
crossLightsPOS
){
if
(
CollectionUtil
.
isEmpty
(
crossLightsPOS
)
||
CollectionUtil
.
isEmpty
(
crossLaneLightsPOS
)){
return
crossLaneLightsPOS
;
}
//存储灯组id和类型
Map
<
Integer
,
Integer
>
lightMap
=
new
HashMap
<>();
for
(
BaseCrossLightsPO
crossLightsPO
:
crossLightsPOS
)
{
lightMap
.
put
(
crossLightsPO
.
getId
(),
crossLightsPO
.
getType
());
}
List
<
CrossLaneLightsPO
>
resultList
=
new
ArrayList
<>();
//根据车道id分组
Map
<
String
,
List
<
CrossLaneLightsPO
>>
laneMap
=
crossLaneLightsPOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrossLaneLightsPO:
:
getLaneId
));
Set
<
String
>
lineIds
=
laneMap
.
keySet
();
for
(
String
lineId
:
lineIds
)
{
List
<
CrossLaneLightsPO
>
laneList
=
laneMap
.
get
(
lineId
);
//判断是否重复
if
(
laneList
.
size
()
>
1
){
CrossLaneLightsPO
result
=
null
;
CrossLaneLightsPO
type2Candidate
=
null
;
CrossLaneLightsPO
type5Candidate
=
null
;
CrossLaneLightsPO
minTypeCandidate
=
null
;
for
(
CrossLaneLightsPO
po
:
laneList
)
{
int
type
=
lightMap
.
get
(
po
.
getLightsId
());
if
(
type
==
2
)
{
if
(
type2Candidate
==
null
)
{
type2Candidate
=
po
;
}
}
else
if
(
type
==
5
)
{
// 仅当type2不存在时,才考虑type5
if
(
type2Candidate
==
null
&&
type5Candidate
==
null
)
{
type5Candidate
=
po
;
}
}
else
{
// 仅当type2和type5都不存在时,才比较最小type
if
(
type2Candidate
==
null
&&
type5Candidate
==
null
)
{
if
(
minTypeCandidate
==
null
||
type
<
lightMap
.
get
(
minTypeCandidate
.
getLightsId
()))
{
minTypeCandidate
=
po
;
}
}
}
}
// 确定最终结果
if
(
type2Candidate
!=
null
)
{
result
=
type2Candidate
;
}
else
if
(
type5Candidate
!=
null
)
{
result
=
type5Candidate
;
}
else
{
result
=
minTypeCandidate
;
}
resultList
.
add
(
result
);
}
else
{
resultList
.
addAll
(
laneList
);
}
}
resultList
=
resultList
.
stream
().
sorted
(
Comparator
.
comparing
(
CrossLaneLightsPO:
:
getLaneId
)).
collect
(
Collectors
.
toList
());
return
resultList
;
}
public
void
syncSchedules
(
String
crossId
,
SchemePhaseLightsVO
schemePhaseLightsVO
)
throws
Exception
{
public
void
syncSchedules
(
String
crossId
,
SchemePhaseLightsVO
schemePhaseLightsVO
)
throws
Exception
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
// 计划信息
// 计划信息
...
...
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