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
9f3641bc
Commit
9f3641bc
authored
Sep 07, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 优化海信程序
parent
f53a45fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
8 deletions
+47
-8
HisenseApplication.java
...c/main/java/net/wanji/utc/hisense/HisenseApplication.java
+1
-2
SignalDataCache.java
...ain/java/net/wanji/utc/hisense/cache/SignalDataCache.java
+2
-0
SignalStatusServiceImpl.java
...nji/utc/hisense/service/impl/SignalStatusServiceImpl.java
+44
-6
No files found.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/HisenseApplication.java
View file @
9f3641bc
package
net
.
wanji
.
utc
.
hisense
;
package
net
.
wanji
.
utc
.
hisense
;
import
net.wanji.utc.hisense.netty.NettyClient
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
...
@@ -30,6 +29,6 @@ public class HisenseApplication implements CommandLineRunner {
...
@@ -30,6 +29,6 @@ public class HisenseApplication implements CommandLineRunner {
@Override
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
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/cache/SignalDataCache.java
View file @
9f3641bc
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.PriorityQueue
;
/**
/**
* @author duanruiming
* @author duanruiming
...
@@ -23,4 +24,5 @@ public class SignalDataCache {
...
@@ -23,4 +24,5 @@ public class SignalDataCache {
// 海信推送灯态数据
// 海信推送灯态数据
public
static
final
Map
<
String
,
RunningLightsStatusPojo
>
runningStateInfoCache
=
new
HashMap
<>();
public
static
final
Map
<
String
,
RunningLightsStatusPojo
>
runningStateInfoCache
=
new
HashMap
<>();
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCache4DataBrain
=
new
HashMap
<>();
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCache4DataBrain
=
new
HashMap
<>();
public
static
final
Map
<
String
,
PriorityQueue
<
LightsStatusVO
>>
crossPriority
=
new
HashMap
<>();
}
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/impl/SignalStatusServiceImpl.java
View file @
9f3641bc
...
@@ -47,7 +47,8 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -47,7 +47,8 @@ public class SignalStatusServiceImpl implements SignalStatusService {
public
void
receiveLightStatus
(
HisenseLightStatusPojo
hisenseLightStatusPojo
)
throws
Exception
{
public
void
receiveLightStatus
(
HisenseLightStatusPojo
hisenseLightStatusPojo
)
throws
Exception
{
ObjectMapper
jackson
=
JacksonUtils
.
getInstance
();
ObjectMapper
jackson
=
JacksonUtils
.
getInstance
();
String
bodyStr
=
hisenseLightStatusPojo
.
getBody
();
String
bodyStr
=
hisenseLightStatusPojo
.
getBody
();
List
<
HisenseLightStatusPojo
.
Body
>
bodies
=
jackson
.
readValue
(
bodyStr
,
new
TypeReference
<
List
<
HisenseLightStatusPojo
.
Body
>>()
{});
List
<
HisenseLightStatusPojo
.
Body
>
bodies
=
jackson
.
readValue
(
bodyStr
,
new
TypeReference
<
List
<
HisenseLightStatusPojo
.
Body
>>()
{
});
if
(!
CollectionUtils
.
isEmpty
(
bodies
))
{
if
(!
CollectionUtils
.
isEmpty
(
bodies
))
{
for
(
HisenseLightStatusPojo
.
Body
body
:
bodies
)
{
for
(
HisenseLightStatusPojo
.
Body
body
:
bodies
)
{
HisenseLightStatusPojo
.
ContentBody
content
=
body
.
getContent
();
HisenseLightStatusPojo
.
ContentBody
content
=
body
.
getContent
();
...
@@ -55,19 +56,49 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -55,19 +56,49 @@ public class SignalStatusServiceImpl implements SignalStatusService {
String
hiCrossId
=
content
.
getCrossId
();
String
hiCrossId
=
content
.
getCrossId
();
CrossInfoPO
crossInfo
=
CrossInfoCache
.
getCrossInfoBySignalCode
(
hiCrossId
);
CrossInfoPO
crossInfo
=
CrossInfoCache
.
getCrossInfoBySignalCode
(
hiCrossId
);
if
(
Objects
.
isNull
(
crossInfo
))
{
if
(
Objects
.
isNull
(
crossInfo
))
{
log
.
error
(
"接收滴滴数据大脑海信灯态数据,当前路口编码不存在:{}"
,
hiCrossId
);
continue
;
continue
;
}
}
String
crossId
=
crossInfo
.
getId
();
String
crossId
=
crossInfo
.
getId
();
int
cycleCountDown
=
content
.
getCycleCountDown
();
PriorityQueue
<
LightsStatusVO
>
crossPriority
=
SignalDataCache
.
crossPriority
.
get
(
crossId
);
if
(
Objects
.
isNull
(
crossPriority
))
{
crossPriority
=
new
PriorityQueue
<>((
o1
,
o2
)
->
{
long
l
=
Long
.
parseLong
(
o1
.
getSchemeStartTime
())
-
Long
.
parseLong
(
o2
.
getSchemeStartTime
());
return
(
int
)
l
;
});
}
else
{
if
(
crossPriority
.
size
()
>
0
)
{
LightsStatusVO
lightsStatusVOCache
=
crossPriority
.
peek
();
if
(
Objects
.
nonNull
(
lightsStatusVOCache
))
{
if
(
lightsStatusVOCache
.
getCycleCountDown
()
<=
cycleCountDown
)
{
continue
;
}
}
}
}
int
hiControlMode
=
content
.
getControlMode
();
int
hiControlMode
=
content
.
getControlMode
();
int
period
=
content
.
getPeriod
();
int
period
=
content
.
getPeriod
();
int
planId
=
content
.
getPlanId
();
int
planId
=
content
.
getPlanId
();
int
cycleCountDown
=
content
.
getCycleCountDown
();
Long
signalMachineStamp
=
content
.
getSignalMachineStamp
();
lightsStatusVO
.
setCrossId
(
hiCrossId
);
if
(
StringUtils
.
equals
(
crossId
,
"13NF80B5QN0"
))
{
log
.
error
(
"当前路口编号:{}, 周期倒计时:{},周期时间:{}"
,
crossId
,
cycleCountDown
,
period
);
}
lightsStatusVO
.
setCrossId
(
crossId
);
lightsStatusVO
.
setSchemeId
(
String
.
valueOf
(
planId
));
lightsStatusVO
.
setSchemeId
(
String
.
valueOf
(
planId
));
lightsStatusVO
.
setRunMode
(
String
.
valueOf
(
DataBrainControlModeEnum
.
getWjControlMode
(
hiControlMode
)));
String
runMode
=
String
.
valueOf
(
DataBrainControlModeEnum
.
getWjControlMode
(
hiControlMode
));
lightsStatusVO
.
setRunMode
(
runMode
);
lightsStatusVO
.
setCycleCountDown
(
cycleCountDown
);
lightsStatusVO
.
setCycleCountDown
(
cycleCountDown
);
lightsStatusVO
.
setCycleLen
(
period
);
lightsStatusVO
.
setCycleLen
(
period
);
lightsStatusVO
.
setSchemeStartTime
(
String
.
valueOf
(
signalMachineStamp
));
// 保证不为空值
lightsStatusVO
.
setPhaseMap
(
Collections
.
emptyMap
());
lightsStatusVO
.
setControlMode
(
runMode
);
lightsStatusVO
.
setCode
(
hiCrossId
);
lightsStatusVO
.
setManufacturerCode
(
"hisense"
);
lightsStatusVO
.
setPhasePlanId
(
String
.
valueOf
(
planId
));
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>
lampRealInfos
=
content
.
getLampRealInfos
();
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>
lampRealInfos
=
content
.
getLampRealInfos
();
if
(!
CollectionUtils
.
isEmpty
(
lampRealInfos
))
{
if
(!
CollectionUtils
.
isEmpty
(
lampRealInfos
))
{
...
@@ -87,16 +118,23 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -87,16 +118,23 @@ public class SignalStatusServiceImpl implements SignalStatusService {
if
(
StringUtils
.
endsWithIgnoreCase
(
lampStatus
,
"23"
))
{
if
(
StringUtils
.
endsWithIgnoreCase
(
lampStatus
,
"23"
))
{
lightsStatusVO
.
setPhaseId
(
"0"
);
lightsStatusVO
.
setPhaseId
(
"0"
);
lightsStatusVO
.
setCyclePhaseCountDown
(
countDown
);
lightsStatusVO
.
setCyclePhaseCountDown
(
countDown
);
break
;
}
}
turnMap
.
put
(
String
.
valueOf
(
DataBrainTurnEnum
.
getWjTurn
(
roadFlowDirection
)),
DataBrainLampStatusEnum
.
getWjLampStatus
(
lampStatus
));
turnMap
.
put
(
String
.
valueOf
(
DataBrainTurnEnum
.
getWjTurn
(
roadFlowDirection
)),
DataBrainLampStatusEnum
.
getWjLampStatus
(
lampStatus
));
}
}
dirMap
.
put
(
String
.
valueOf
(
DataBrainDirEnum
.
getWjLightsDir
(
roadDirection
)),
turnMap
);
dirMap
.
put
(
String
.
valueOf
(
DataBrainDirEnum
.
getWjLightsDir
(
roadDirection
)),
turnMap
);
}
}
lightsStatusVO
.
setDirLampGroupMap
(
dirMap
);
lightsStatusVO
.
setDirLampGroupMap
(
dirMap
);
crossPriority
.
offer
(
lightsStatusVO
);
if
(
crossPriority
.
size
()
>
100
)
{
crossPriority
.
clear
();
}
SignalDataCache
.
runningStateInfoCache4DataBrain
.
put
(
crossId
,
lightsStatusVO
);
SignalDataCache
.
runningStateInfoCache4DataBrain
.
put
(
crossId
,
lightsStatusVO
);
log
.
error
(
"接收滴滴数据大脑后缓存路口灯态:{}"
,
SignalDataCache
.
runningStateInfoCache4DataBrain
);
SignalDataCache
.
crossPriority
.
put
(
crossId
,
crossPriority
);
}
}
}
}
}
}
}
}
}
}
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