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
bddbe436
Commit
bddbe436
authored
May 18, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 测试轨迹
parent
7439d1d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
RealTimeCarTask.java
...ice/src/main/java/net/wanji/web/task/RealTimeCarTask.java
+40
-6
No files found.
signal-control-service/src/main/java/net/wanji/web/task/RealTimeCarTask.java
View file @
bddbe436
package
net
.
wanji
.
web
.
task
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.web.common.constant.Constant
;
import
net.wanji.web.kafka.ConsumerHandler
;
...
...
@@ -12,9 +14,8 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
* @author duanruiming
...
...
@@ -27,20 +28,46 @@ public class RealTimeCarTask {
@Resource
private
ConsumerHandler
consumerHandler
;
@Scheduled
(
fixedRate
=
1000
)
private
static
final
List
<
TempPojo
>
tempList
=
new
ArrayList
<>(
7
);
private
final
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
static
{
tempList
.
add
(
new
TempPojo
(
112.967134
,
28.182384
));
tempList
.
add
(
new
TempPojo
(
112.966402
,
28.182420
));
tempList
.
add
(
new
TempPojo
(
112.964600
,
28.182618
));
tempList
.
add
(
new
TempPojo
(
112.963046
,
28.182838
));
tempList
.
add
(
new
TempPojo
(
112.963092
,
28.184083
));
tempList
.
add
(
new
TempPojo
(
112.963606
,
28.188246
));
tempList
.
add
(
new
TempPojo
(
112.963711
,
28.189290
));
}
@Scheduled
(
fixedRate
=
2000
)
public
void
pushRealTimeCarInfo
()
{
try
{
Set
<
WebSocketServer
>
events
=
WebSocketServer
.
getWebSocketSet
(
Constant
.
WEBSOCKET_TOPIC_CAR_TRAIL_INFO
);
for
(
WebSocketServer
socketServer
:
events
)
{
String
picLicense
=
socketServer
.
getUserId
();
JNMatchResultMiniData
jnMatchResultMiniData
=
consumerHandler
.
getTopicMessage
(
"CSMatchResultMiniData_0"
);
if
(
Objects
.
nonNull
(
jnMatchResultMiniData
)
)
{
if
(
Objects
.
nonNull
(
jnMatchResultMiniData
))
{
List
<
JNMatchResultMiniData
.
E1FrameParticipant
>
list
=
jnMatchResultMiniData
.
getE1FrameParticipant
();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
for
(
JNMatchResultMiniData
.
E1FrameParticipant
e1FrameParticipant
:
list
)
{
int
id
=
e1FrameParticipant
.
getId
();
String
license
=
e1FrameParticipant
.
getPicLicense
();
if
(
3573
==
e1FrameParticipant
.
getId
()
||
StringUtils
.
equals
(
license
,
picLicense
))
{
if
(
3573
==
e1FrameParticipant
.
getId
()
||
StringUtils
.
equals
(
license
,
picLicense
))
{
for
(
int
i
=
0
;
i
<
tempList
.
size
();
i
++)
{
if
(
i
==
atomicInteger
.
get
())
{
atomicInteger
.
getAndIncrement
();
if
(
i
==
6
)
{
atomicInteger
.
set
(
0
);
}
TempPojo
tempPojo
=
tempList
.
get
(
i
);
e1FrameParticipant
.
setLongitude
(
tempPojo
.
getLongitude
());
e1FrameParticipant
.
setLatitude
(
tempPojo
.
getLatitude
());
break
;
}
}
socketServer
.
sendMessage
(
JSONObject
.
toJSONString
(
e1FrameParticipant
));
}
}
...
...
@@ -52,4 +79,11 @@ public class RealTimeCarTask {
}
}
@Data
@AllArgsConstructor
static
class
TempPojo
{
private
Double
longitude
;
private
Double
latitude
;
}
}
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