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
77c1b559
Commit
77c1b559
authored
May 30, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 代码优化
parent
af7a9b2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
24 deletions
+19
-24
CommonEventWarnTask.java
...src/main/java/net/wanji/web/task/CommonEventWarnTask.java
+10
-14
RealTimeCarTask.java
...ice/src/main/java/net/wanji/web/task/RealTimeCarTask.java
+1
-2
SignalStatusTask.java
...ce/src/main/java/net/wanji/web/task/SignalStatusTask.java
+4
-4
SystemServiceStatusTask.java
...main/java/net/wanji/web/task/SystemServiceStatusTask.java
+3
-3
WebSocketServer.java
...rc/main/java/net/wanji/web/websocket/WebSocketServer.java
+1
-1
No files found.
signal-control-service/src/main/java/net/wanji/web/task/CommonEventWarnTask.java
View file @
77c1b559
...
...
@@ -2,6 +2,7 @@ package net.wanji.web.task;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.databus.po.BaseCrossInfoPO
;
...
...
@@ -13,7 +14,6 @@ import net.wanji.web.mapper.TDeviceStatusMapper;
import
net.wanji.web.service.SituationDetectionService
;
import
net.wanji.web.vo.situationDetection.CommonEventAlarmOutVo
;
import
net.wanji.web.websocket.WebSocketServer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -30,16 +30,13 @@ import java.util.*;
*/
@Component
@Slf4j
@SuppressWarnings
(
"all"
)
@RequiredArgsConstructor
public
class
CommonEventWarnTask
{
@Autowired
private
UtcFeignClients
utcFeignClients
;
@Autowired
private
SituationDetectionService
situationDetectionService
;
@Autowired
private
TDeviceStatusMapper
tDeviceStatusMapper
;
private
final
UtcFeignClients
utcFeignClients
;
private
final
SituationDetectionService
situationDetectionService
;
private
final
TDeviceStatusMapper
tDeviceStatusMapper
;
@Scheduled
(
fixedRate
=
30
*
1000
)
public
void
pushEvenWarnData
()
{
...
...
@@ -49,7 +46,7 @@ public class CommonEventWarnTask {
log
.
info
(
"告警socket连接数量:{},告警信息:{}"
,
events
.
size
(),
events
);
for
(
WebSocketServer
entry
:
events
)
{
String
userId
=
entry
.
getUserId
();
commonE
n
ventWarnDataSend
(
userId
);
commonEventWarnDataSend
(
userId
);
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -57,7 +54,7 @@ public class CommonEventWarnTask {
}
}
private
void
commonE
n
ventWarnDataSend
(
String
userId
)
throws
IOException
{
private
void
commonEventWarnDataSend
(
String
userId
)
throws
IOException
{
// 信号机故障
JsonViewObject
signalWarnData
=
getSignalWarnData
();
if
(
Objects
.
nonNull
(
signalWarnData
))
{
...
...
@@ -94,8 +91,7 @@ public class CommonEventWarnTask {
LocalDateTime
now
=
LocalDateTime
.
now
();
String
formatNow
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
now
);
List
<
Map
<
String
,
Object
>>
content
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
content
.
forEach
(
map
->
{
Map
<
String
,
Object
>
result
=
map
;
content
.
forEach
(
result
->
{
String
signalId
=
(
String
)
result
.
get
(
"signalId"
);
String
crossId
=
(
String
)
result
.
get
(
"crossId"
);
Integer
currentStatus
=
(
Integer
)
result
.
get
(
"status"
);
...
...
@@ -145,7 +141,7 @@ public class CommonEventWarnTask {
*/
private
static
void
buildSignalWarnData
(
List
<
CommonEventAlarmOutVo
>
results
,
String
formatNow
,
String
signalId
,
Integer
currentStatus
,
Integer
currentFaultType
,
String
coordinate
,
String
crossName
,
TDeviceStatusInfo
tDeviceStatusInfo1
)
{
try
{
if
(
SignalStatusTask
.
isEx
u
cuteUpdate
(
currentStatus
,
currentFaultType
,
tDeviceStatusInfo1
))
{
if
(
SignalStatusTask
.
isEx
e
cuteUpdate
(
currentStatus
,
currentFaultType
,
tDeviceStatusInfo1
))
{
log
.
error
(
"测试日志,执行信号机状态修改成功"
);
CommonEventAlarmOutVo
commonEventAlarmOutVo
=
new
CommonEventAlarmOutVo
();
commonEventAlarmOutVo
.
setEventType
(
3
);
...
...
signal-control-service/src/main/java/net/wanji/web/task/RealTimeCarTask.java
View file @
77c1b559
...
...
@@ -49,7 +49,6 @@ public class RealTimeCarTask {
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
));
tempList
.
add
(
new
TempPojo
(
112.967486
,
28.187118
));
}
...
...
@@ -58,7 +57,7 @@ public class RealTimeCarTask {
// threadPoolExecutor.execute(() -> {
int
i
=
atomicInteger
.
get
();
atomicInteger
.
incrementAndGet
();
if
(
i
==
7
)
{
if
(
i
==
6
)
{
atomicInteger
.
set
(
0
);
}
Set
<
WebSocketServer
>
events
=
WebSocketServer
.
getWebSocketSet
(
Constant
.
WEBSOCKET_TOPIC_CAR_TRAIL_INFO
);
...
...
signal-control-service/src/main/java/net/wanji/web/task/SignalStatusTask.java
View file @
77c1b559
...
...
@@ -38,7 +38,7 @@ public class SignalStatusTask {
private
final
TDeviceStatusLogMapper
tDeviceStatusLogMapper
;
private
final
BaseCrossInfoMapper
baseCrossInfoMapper
;
@Scheduled
(
fixedRate
=
1
*
30
*
1000
)
@Scheduled
(
fixedRate
=
30
*
1000
)
@Transactional
public
void
syncSignalStatus
()
{
try
{
...
...
@@ -102,7 +102,7 @@ public class SignalStatusTask {
lambdaQueryWrapper
.
eq
(
TDeviceStatusInfo:
:
getCode
,
crossId
);
TDeviceStatusInfo
tDeviceStatusInfo
=
tDeviceStatusMapper
.
selectOne
(
lambdaQueryWrapper
);
if
(
Objects
.
nonNull
(
tDeviceStatusInfo
))
{
if
(
isEx
u
cuteUpdate
(
currentSignalStatus
,
currentFaultType
,
tDeviceStatusInfo
))
{
if
(
isEx
e
cuteUpdate
(
currentSignalStatus
,
currentFaultType
,
tDeviceStatusInfo
))
{
tDeviceStatusInfo
.
setStatus
(
currentSignalStatus
);
tDeviceStatusInfo
.
setFaultType
(
currentFaultType
);
tDeviceStatusInfo
.
setGmtCreate
(
new
Date
());
// 实时数据,创建和修改时间一致
...
...
@@ -168,9 +168,9 @@ public class SignalStatusTask {
}
}
public
static
boolean
isEx
u
cuteUpdate
(
Integer
currentSignalStatus
,
Integer
currentFaultType
,
TDeviceStatusInfo
tDeviceStatusInfo
)
{
public
static
boolean
isEx
e
cuteUpdate
(
Integer
currentSignalStatus
,
Integer
currentFaultType
,
TDeviceStatusInfo
tDeviceStatusInfo
)
{
// 故障自定义,当故障时,状态对应海康在线
int
status
=
tDeviceStatusInfo
.
getStatus
()
==
2
?
1
:
tDeviceStatusInfo
.
getStatus
();
return
Objects
.
nonNull
(
tDeviceStatusInfo
)
&&
(
currentSignalStatus
!=
status
||
currentFaultType
!=
tDeviceStatusInfo
.
getFaultType
()
);
return
currentSignalStatus
!=
status
||
currentFaultType
!=
tDeviceStatusInfo
.
getFaultType
(
);
}
}
signal-control-service/src/main/java/net/wanji/web/task/SystemServiceStatusTask.java
View file @
77c1b559
...
...
@@ -29,7 +29,7 @@ public class SystemServiceStatusTask {
private
static
final
String
HIK_LOCAL_IP
=
"10.102.1.183"
;
public
static
final
List
<
SystemServiceStatusDTO
>
sysList
=
new
ArrayList
<
SystemServiceStatusDTO
>();
public
static
final
List
<
SystemServiceStatusDTO
>
sysList
=
new
ArrayList
<>();
static
{
sysList
.
add
(
new
SystemServiceStatusDTO
(
"MYSQL"
,
LOCAL_IP
,
3306
,
30000
,
0
,
null
,
null
));
...
...
@@ -37,7 +37,7 @@ public class SystemServiceStatusTask {
sysList
.
add
(
new
SystemServiceStatusDTO
(
"海康"
,
HIK_LOCAL_IP
,
80
,
30000
,
0
,
null
,
null
));
}
@Scheduled
(
fixedRate
=
1
*
60
*
1000
)
@Scheduled
(
fixedRate
=
60
*
1000
)
public
void
telnetStatus
()
throws
Exception
{
Set
<
WebSocketServer
>
webSocketSet
=
WebSocketServer
.
getWebSocketSet
(
Constant
.
WEBSOCKET_TOPIC_SYS_SERVICE_STATUS
);
if
(!
CollectionUtils
.
isEmpty
(
webSocketSet
))
{
...
...
@@ -46,7 +46,7 @@ public class SystemServiceStatusTask {
int
port
=
dto
.
getPort
();
int
timeout
=
dto
.
getTimeout
();
int
lastStatus
=
dto
.
getStatus
();
int
currentStatus
=
SocketUtil
.
telnet
(
ip
,
port
,
timeout
)
==
true
?
0
:
1
;
int
currentStatus
=
SocketUtil
.
telnet
(
ip
,
port
,
timeout
)
?
0
:
1
;
if
(
currentStatus
!=
lastStatus
)
{
dto
.
setStatus
(
currentStatus
);
}
...
...
signal-control-service/src/main/java/net/wanji/web/websocket/WebSocketServer.java
View file @
77c1b559
...
...
@@ -31,7 +31,7 @@ public class WebSocketServer {
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
*/
private
static
ConcurrentHashMap
<
String
,
Set
<
WebSocketServer
>>
webSocketMap
=
new
ConcurrentHashMap
<>();
private
static
final
ConcurrentHashMap
<
String
,
Set
<
WebSocketServer
>>
webSocketMap
=
new
ConcurrentHashMap
<>();
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
...
...
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