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
a28ed26e
Commit
a28ed26e
authored
Sep 26, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 优化海信灯态
parent
629c69ce
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
103 deletions
+151
-103
HisenseApplication.java
...c/main/java/net/wanji/utc/hisense/HisenseApplication.java
+2
-1
SignalStatusController.java
.../wanji/utc/hisense/controller/SignalStatusController.java
+3
-3
NettyServerHandler.java
...t/wanji/utc/hisense/netty/handler/NettyServerHandler.java
+5
-32
SignalStatusService.java
...va/net/wanji/utc/hisense/service/SignalStatusService.java
+1
-1
SignalStatusServiceImpl.java
...nji/utc/hisense/service/impl/SignalStatusServiceImpl.java
+137
-64
HisensePhaseCountDownTask.java
...net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
+3
-2
No files found.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/HisenseApplication.java
View file @
a28ed26e
package
net
.
wanji
.
utc
.
hisense
;
import
net.wanji.utc.hisense.netty.NettyClient
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
...
...
@@ -29,6 +30,6 @@ public class HisenseApplication implements CommandLineRunner {
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
//
NettyClient.connection(localPort, remoteProt);
NettyClient
.
connection
(
localPort
,
remoteProt
);
}
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/controller/SignalStatusController.java
View file @
a28ed26e
...
...
@@ -63,11 +63,11 @@ public class SignalStatusController {
return
jsonViewObject
.
success
(
lightsStatusVOList
);
}
@AspectLog
(
description
=
"
从滴滴数据大脑
接收海信灯态"
,
operationType
=
BaseEnum
.
OperationTypeEnum
.
QUERY
)
@AspectLog
(
description
=
"接收海信灯态"
,
operationType
=
BaseEnum
.
OperationTypeEnum
.
QUERY
)
@PostMapping
(
value
=
"/receiveLightStatus"
,
produces
=
MediaType
.
APPLICATION_JSON
)
@ApiOperation
(
value
=
"接收海信灯态"
,
notes
=
"接收海信灯态"
,
response
=
LightsStatusVO
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
)
public
JsonViewObject
receiveLightStatus
(
@RequestBody
HisenseLightStatusPojo
hisenseLightStatusPojo
)
throws
Exception
{
signalStatusService
.
receiveLightStatus
(
hisenseLightStatusPojo
);
public
JsonViewObject
receiveLightStatus
(
@RequestBody
List
<
HisenseLightStatusPojo
>
hisenseLightStatusPojos
)
throws
Exception
{
signalStatusService
.
receiveLightStatus
(
hisenseLightStatusPojo
s
);
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
return
jsonViewObject
.
success
(
"海信灯态接收成功"
);
}
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/netty/handler/NettyServerHandler.java
View file @
a28ed26e
...
...
@@ -6,7 +6,6 @@ import io.netty.channel.SimpleChannelInboundHandler;
import
io.netty.channel.socket.DatagramPacket
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.framework.spring.ServiceBeanContext
;
import
net.wanji.databus.dao.mapper.CrossInfoMapper
;
import
net.wanji.databus.po.CrossInfoPO
;
import
net.wanji.utc.hisense.cache.CrossInfoCache
;
import
net.wanji.utc.hisense.cache.SignalDataCache
;
...
...
@@ -18,38 +17,16 @@ import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import
net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo
;
import
net.wanji.utc.hisense.pojo.netty.MessageResultPojo
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.net.InetSocketAddress
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
@Slf4j
@Component
public
class
NettyServerHandler
extends
SimpleChannelInboundHandler
<
DatagramPacket
>
{
// 信号机ID和路口ID映射
private
static
final
Map
<
String
,
String
>
signalMap
=
new
HashMap
<>();
@Autowired
private
CrossInfoMapper
crossInfoMapper
;
@PostConstruct
public
void
init
()
{
List
<
CrossInfoPO
>
crossInfoPOList
=
crossInfoMapper
.
selectAll
();
for
(
CrossInfoPO
crossInfoPO
:
crossInfoPOList
)
{
String
crossId
=
crossInfoPO
.
getId
();
String
signalCode
=
crossInfoPO
.
getCode
();
signalMap
.
put
(
signalCode
,
crossId
);
}
}
@Resource
private
CrossInfoCache
crossInfoCache
;
/**
* 读取消息
...
...
@@ -74,20 +51,16 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack
// 直接set灯态缓存
RunningLightsStatusPojo
pojo
=
(
RunningLightsStatusPojo
)
resultPojo
;
String
signalCode
=
pojo
.
getCID
();
String
crossId
=
signalMap
.
get
(
signalCode
);
Map
<
String
,
RunningLightsStatusPojo
>
cache
=
SignalDataCache
.
runningStateInfoCacheUdp
;
if
(
crossId
!=
null
)
{
cache
.
put
(
crossI
d
,
pojo
);
CrossInfoPO
crossInfoPO
=
CrossInfoCache
.
getCrossInfoBySignalCode
(
signalCode
);
if
(
Objects
.
nonNull
(
crossInfoPO
))
{
Map
<
String
,
RunningLightsStatusPojo
>
cache
=
SignalDataCache
.
runningStateInfoCacheUdp
;
cache
.
put
(
crossI
nfoPO
.
getId
()
,
pojo
);
}
return
;
}
Object
bean
=
ServiceBeanContext
.
getBean
(
className
);
CommandResponseFactory
commandResponseFactory
=
ServiceBeanContext
.
getBean
(
className
);
String
key
=
StringUtils
.
join
(
"/"
,
remote
.
getHostString
(),
":"
,
remote
.
getPort
(),
"/"
,
resultPojo
.
getClass
().
getSimpleName
());
String
key
=
StringUtils
.
join
(
"/"
,
remote
.
getHostString
(),
":"
,
remote
.
getPort
(),
"/"
,
resultPojo
.
getClass
().
getSimpleName
());
CommandPojo
commandPojo
=
getCommandPojo
(
key
,
resultPojo
);
Object
hexResult
=
commandResponseFactory
.
getCommandResponse
(
commandPojo
);
if
(
Objects
.
nonNull
(
hexResult
))
{
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/SignalStatusService.java
View file @
a28ed26e
...
...
@@ -21,5 +21,5 @@ public interface SignalStatusService {
List
<
SignalStatusLogPO
>
runningStatusAlarm
(
String
crossId
);
List
<
LightsStatusVO
>
lightStatus
(
String
crossId
);
void
receiveLightStatus
(
HisenseLightStatusPojo
hisenseLightStatusPojo
)
throws
Exception
;
void
receiveLightStatus
(
List
<
HisenseLightStatusPojo
>
hisenseLightStatusPojos
)
throws
Exception
;
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/impl/SignalStatusServiceImpl.java
View file @
a28ed26e
This diff is collapsed.
Click to expand it.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
View file @
a28ed26e
...
...
@@ -47,11 +47,12 @@ public class HisensePhaseCountDownTask {
Long
lastPhaseTimeStamp
=
runningStatusStampMap
.
get
(
crossId
);
String
phaseId
=
lightsStatusVO
.
getPhaseId
();
String
schemeId
=
lightsStatusVO
.
getSchemeId
();
if
(
Objects
.
nonNull
(
lastPhaseTimeStamp
)
&&
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
String
.
valueOf
(
lastPhaseTimeStamp
)))
{
if
(
Objects
.
nonNull
(
lastPhaseTimeStamp
)
&&
!
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
String
.
valueOf
(
lastPhaseTimeStamp
)))
{
CrossSchemePO
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
schemeId
));
// 通过时段表,切换方案 凌晨00:00 如果切换下一个日期方案,可能RefreshCacheTask还没执行
String
nextSectionSchemeNo
=
CrossRunSchemeCache
.
currentRunSchemeNoCache
.
get
(
crossId
);
if
(!
StringUtils
.
equalsIgnoreCase
(
nextSectionSchemeNo
,
schemeId
))
{
String
currentTime
=
String
.
valueOf
(
new
Date
().
getTime
());
if
(
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
currentTime
))
{
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
nextSectionSchemeNo
));
executeNextSectionScheme
(
crossId
,
lightsStatusVO
,
"1"
,
crossSchemePO
);
lightsStatusVO
.
setCycleLen
(
crossSchemePO
.
getCycle
());
...
...
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