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
1065f08c
Commit
1065f08c
authored
May 06, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 济南测试平台-态势检测-重点路口检测
parent
76baa26e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
28 deletions
+103
-28
TrendController.java
...c/main/java/net/wanji/opt/controller/TrendController.java
+12
-8
TrendService.java
...ice/src/main/java/net/wanji/opt/service/TrendService.java
+2
-0
TrendServiceImpl.java
...ain/java/net/wanji/opt/service/impl/TrendServiceImpl.java
+63
-19
HotspotCrossVO.java
...ervice/src/main/java/net/wanji/opt/vo/HotspotCrossVO.java
+25
-0
CrossDataRealtimeMapper.xml
...bus/src/main/resources/mapper/CrossDataRealtimeMapper.xml
+1
-1
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/controller/TrendController.java
View file @
1065f08c
...
...
@@ -13,10 +13,7 @@ import net.wanji.opt.dto.trend.EventAlarmDTO;
import
net.wanji.opt.dto.trend.GreenwaveListDTO
;
import
net.wanji.opt.service.impl.TrendServiceImpl
;
import
net.wanji.opt.vo.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.ws.rs.core.MediaType
;
import
java.text.ParseException
;
...
...
@@ -173,7 +170,7 @@ public class TrendController {
return
jsonViewObject
.
success
(
eventAlarmVOList
);
}
@ApiOperation
(
value
=
"数量实时推送"
,
notes
=
"数量实时推送"
,
response
=
JsonViewObject
.
class
,
@ApiOperation
(
value
=
"数量实时推送"
,
notes
=
"数量实时推送"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/countRealTime"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
...
...
@@ -186,7 +183,7 @@ public class TrendController {
return
JsonViewObject
.
newInstance
().
success
(
countRealTimeVO
);
}
@ApiOperation
(
value
=
"表格分时段查询"
,
notes
=
"表格分时段查询"
,
response
=
JsonViewObject
.
class
,
@ApiOperation
(
value
=
"表格分时段查询"
,
notes
=
"表格分时段查询"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/tableQuery"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
...
...
@@ -198,7 +195,7 @@ public class TrendController {
return
JsonViewObject
.
newInstance
().
success
(
tableQueryVO
);
}
@ApiOperation
(
value
=
"表格实时推送"
,
notes
=
"表格实时推送"
,
response
=
JsonViewObject
.
class
,
@ApiOperation
(
value
=
"表格实时推送"
,
notes
=
"表格实时推送"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/tableRealTime"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
...
...
@@ -210,7 +207,7 @@ public class TrendController {
return
JsonViewObject
.
newInstance
().
success
(
tableRealTimeVO
);
}
@ApiOperation
(
value
=
"优化类型"
,
notes
=
"优化类型"
,
response
=
JsonViewObject
.
class
,
@ApiOperation
(
value
=
"优化类型"
,
notes
=
"优化类型"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/optType"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
...
...
@@ -221,4 +218,11 @@ public class TrendController {
OptTypeVO
optTypeVO
=
trendService
.
optType
(
crossIdBO
);
return
JsonViewObject
.
newInstance
().
success
(
optTypeVO
);
}
@ApiOperation
(
value
=
"重点路口监测"
,
notes
=
"重点路口监测"
,
response
=
JsonViewObject
.
class
)
@GetMapping
(
value
=
"/hotspotCross"
)
public
JsonViewObject
hotspotCross
()
throws
Exception
{
List
<
HotspotCrossVO
>
hotspotCrossVOS
=
trendService
.
hotspotCross
();
return
JsonViewObject
.
newInstance
().
success
(
hotspotCrossVOS
);
}
}
\ No newline at end of file
signal-optimize-service/src/main/java/net/wanji/opt/service/TrendService.java
View file @
1065f08c
...
...
@@ -46,4 +46,6 @@ public interface TrendService {
TableQueryVO
tableRealTime
(
CrossIdAndIsFirstBO
crossIdAndIsFirstBO
)
throws
Exception
;
OptTypeVO
optType
(
CrossIdBO
crossIdBO
);
List
<
HotspotCrossVO
>
hotspotCross
()
throws
Exception
;
}
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/TrendServiceImpl.java
View file @
1065f08c
...
...
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
...
...
@@ -238,7 +239,7 @@ public class TrendServiceImpl implements TrendService {
spilloverDirList
.
add
(
Integer
.
parseInt
(
s
));
}
buildRidData
(
abnormalCrossListVO
,
endCrossId
,
spilloverDirList
);
}
else
if
(
Objects
.
equals
(
realtimeStatus
,
CrossStatusEnum
.
CONGESTION
.
getCode
())){
}
else
if
(
Objects
.
equals
(
realtimeStatus
,
CrossStatusEnum
.
CONGESTION
.
getCode
()))
{
// 拥堵返回所有方向关联路口
List
<
Integer
>
inDirs
=
baseCrossDirInfoMapper
.
selectInDirsByCrossId
(
endCrossId
);
buildRidData
(
abnormalCrossListVO
,
endCrossId
,
inDirs
);
...
...
@@ -268,7 +269,6 @@ public class TrendServiceImpl implements TrendService {
}
abnormalCrossVO
.
setAbnormalCrossList
(
abnormalCrossListVOList
);
// 构造统计信息
List
<
AbnormalCrossListVO
>
listForStats
=
...
...
@@ -281,7 +281,7 @@ public class TrendServiceImpl implements TrendService {
private
int
getFrequent
(
String
crossId
,
Integer
batchTime
)
{
LambdaQueryWrapper
<
CrossDataHistPO
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
CrossDataHistPO:
:
getCrossId
,
crossId
);
queryWrapper
.
between
(
CrossDataHistPO:
:
getBatchTime
,
batchTime
-
30
*
86400
,
batchTime
);
queryWrapper
.
between
(
CrossDataHistPO:
:
getBatchTime
,
batchTime
-
30
*
86400
,
batchTime
);
queryWrapper
.
eq
(
CrossDataHistPO:
:
getIsCongestion
,
1
);
List
<
CrossDataHistPO
>
crossDataHistPOS
=
crossDataHistMapper
.
selectList
(
queryWrapper
);
List
<
CrossDataHistPO
>
result
=
new
ArrayList
<>();
...
...
@@ -310,7 +310,7 @@ public class TrendServiceImpl implements TrendService {
return
0.0
;
}
Double
lastCongestionIndex
=
lastHistPO
.
getCongestionIndex
();
return
(
congestionIndex
-
lastCongestionIndex
)/
lastCongestionIndex
*
100
;
return
(
congestionIndex
-
lastCongestionIndex
)
/
lastCongestionIndex
*
100
;
}
private
static
class
CrossComparator
implements
Comparator
<
AbnormalCrossListVO
>
{
...
...
@@ -367,7 +367,7 @@ public class TrendServiceImpl implements TrendService {
CrossDataRealtimePO
crossDataRealtimePO
=
crossDataRealtimeMapper
.
selectByCrossId
(
crossId
);
abnormalCrossDetailVO
.
setCrossStatus
(
crossDataRealtimePO
.
getStatus
());
abnormalCrossDetailVO
.
setCrossQueueLength
(
crossDataRealtimePO
.
getQueueLength
());
abnormalCrossDetailVO
.
setCrossFlowRate
((
double
)
crossDataRealtimePO
.
getFlow
());
abnormalCrossDetailVO
.
setCrossFlowRate
((
double
)
crossDataRealtimePO
.
getFlow
());
abnormalCrossDetailVO
.
setCrossStopTimes
(
crossDataRealtimePO
.
getStopTimes
());
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
crossDataRealtimePO
.
getCongestionIndex
()).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
abnormalCrossDetailVO
.
setCongestionIndex
(
bigDecimal
);
...
...
@@ -491,7 +491,7 @@ public class TrendServiceImpl implements TrendService {
double
width
=
foundItem
.
getWidth
();
double
designSpeed
=
foundItem
.
getDesignSpeed
()
/
3.6
;
// 换算成米/秒
int
widthSeconds
=
(
int
)(
width
/
designSpeed
);
int
widthSeconds
=
(
int
)
(
width
/
designSpeed
);
Integer
dir
=
greenwaveInfoPO
.
getDir
();
if
(
dir
==
0
)
{
// 正向
res
.
setForwardWidth
(
widthSeconds
);
...
...
@@ -503,7 +503,7 @@ public class TrendServiceImpl implements TrendService {
}
double
uncoordinatePhaseQueue
=
greenwaveRealtimePO
.
getUncoordinatePhaseQueue
();
res
.
setUncoordinatePhaseQueue
((
int
)
uncoordinatePhaseQueue
);
res
.
setUncoordinatePhaseQueue
((
int
)
uncoordinatePhaseQueue
);
double
noparkPassRate
=
greenwaveRealtimePO
.
getNoparkPassRate
();
res
.
setNoparkPassRate
((
int
)
(
noparkPassRate
*
100
));
res
.
setTrvalTime
(
greenwaveRealtimePO
.
getTrvalTime
());
...
...
@@ -603,7 +603,7 @@ public class TrendServiceImpl implements TrendService {
LocalTime
startTimeObj
=
LocalTime
.
parse
(
startTime
);
Duration
duration
=
Duration
.
between
(
startTimeObj
,
now
);
long
seconds
=
duration
.
getSeconds
();
return
(
int
)
seconds
;
return
(
int
)
seconds
;
}
private
List
<
GreenwaveDetailVO
.
GreenwavePoint
>
buildReverseGreenwaveList
(
...
...
@@ -632,7 +632,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int
distanceToNextCross
=
greenwaveCross
.
getDistanceToNextCross
();
double
designSpeed
=
greenwaveInfoPO
.
getDesignSpeed
()
/
3.6
;
// 换算成米/秒
int
travalTime
=
(
int
)(
distanceToNextCross
/
designSpeed
);
int
travalTime
=
(
int
)
(
distanceToNextCross
/
designSpeed
);
// 计算协调相位绿灯开始的绝对时间
int
absoluteSecondsBegin
=
calcCoordBeginSeconds
(
greenwaveCross
);
// 计算绿波点位的绝对时间
...
...
@@ -651,7 +651,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int
distanceToNextCross
=
greenwaveCrossAbove
.
getDistanceToNextCross
();
double
designSpeed
=
greenwaveInfoPO
.
getDesignSpeed
()
/
3.6
;
// 换算成米/秒
int
travalTime
=
(
int
)(
distanceToNextCross
/
designSpeed
);
int
travalTime
=
(
int
)
(
distanceToNextCross
/
designSpeed
);
// 计算协调相位绿灯开始的绝对时间
int
absoluteSecondsBegin
=
calcCoordBeginSeconds
(
greenwaveCross
);
// 计算绿波点位的绝对时间
...
...
@@ -692,7 +692,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int
distanceToNextCross
=
greenwaveCross
.
getDistanceToNextCross
();
double
designSpeed
=
greenwaveInfoPO
.
getDesignSpeed
()
/
3.6
;
// 换算成米/秒
int
travalTime
=
(
int
)(
distanceToNextCross
/
designSpeed
);
int
travalTime
=
(
int
)
(
distanceToNextCross
/
designSpeed
);
// 计算协调相位绿灯开始的绝对时间
int
absoluteSecondsBegin
=
calcCoordBeginSeconds
(
greenwaveCross
);
// 计算绿波点位的绝对时间
...
...
@@ -711,7 +711,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int
distanceToNextCross
=
greenwaveCrossAbove
.
getDistanceToNextCross
();
double
designSpeed
=
greenwaveInfoPO
.
getDesignSpeed
()
/
3.6
;
// 换算成米/秒
int
travalTime
=
(
int
)(
distanceToNextCross
/
designSpeed
);
int
travalTime
=
(
int
)
(
distanceToNextCross
/
designSpeed
);
// 计算协调相位绿灯开始的绝对时间
int
absoluteSecondsBegin
=
calcCoordBeginSeconds
(
greenwaveCross
);
// 计算绿波点位的绝对时间
...
...
@@ -816,7 +816,7 @@ public class TrendServiceImpl implements TrendService {
Double
speed
=
null
;
if
(
i
<
size
-
1
)
{
// 不是最后一个路口
double
nextCrossLen
=
greenwaveCrossPO
.
getNextCrossLen
();
distanceToNextCross
=
(
int
)
nextCrossLen
;
distanceToNextCross
=
(
int
)
nextCrossLen
;
GreenwaveCrossPO
nextCrossPO
=
filteredList
.
get
(
i
+
1
);
String
nextCrossId
=
nextCrossPO
.
getCrossId
();
...
...
@@ -904,7 +904,7 @@ public class TrendServiceImpl implements TrendService {
greenwavePhase
.
setSort
(
i
+
2
);
greenwavePhase
.
setPhaseNo
(
crossPhasePO
.
getPhaseNo
());
if
(
i
==
size
-
1
){
if
(
i
==
size
-
1
)
{
greenwavePhase
.
setSeconds
(
crossPhasePO
.
getPhaseTime
()
-
absoluteOffset
);
}
else
{
greenwavePhase
.
setSeconds
(
crossPhasePO
.
getPhaseTime
());
...
...
@@ -1411,7 +1411,7 @@ public class TrendServiceImpl implements TrendService {
Double
length
=
greenwaveCrossPO
.
getNextCrossLen
();
Double
speed
=
getSpeed
(
listForNoPark
);
double
travelTime
=
length
/
speed
;
greenwaveCrossMetricsVO
.
setTrvalTime
((
int
)
travelTime
);
greenwaveCrossMetricsVO
.
setTrvalTime
((
int
)
travelTime
);
}
}
...
...
@@ -1433,7 +1433,7 @@ public class TrendServiceImpl implements TrendService {
maxQueue
=
queueLength
;
}
}
return
(
int
)
maxQueue
;
return
(
int
)
maxQueue
;
}
private
Integer
getAveRate
(
List
<
CrossTurnDataHistPO
>
crossDirDataHistPOList
)
{
...
...
@@ -1444,7 +1444,7 @@ public class TrendServiceImpl implements TrendService {
}
int
size
=
crossDirDataHistPOList
.
size
();
double
avg
=
total
/
size
;
return
(
int
)(
avg
*
100
);
return
(
int
)
(
avg
*
100
);
}
private
List
<
GreenWaveCrossMonitorVO
>
buildRes
(
List
<
GreenwaveCrossPO
>
greenwaveCrossPOList
)
{
...
...
@@ -1538,7 +1538,7 @@ public class TrendServiceImpl implements TrendService {
long
batchTime
=
crossDirDataHistPO
.
getBatchTime
();
long
preSecond
=
preMinute
.
getTime
()
/
1000
;
long
currentSecond
=
currentMinute
.
getTime
()
/
1000
;
if
(
dirType
==
dir
&&
batchTime
<=
currentSecond
&&
batchTime
>=
preSecond
)
{
if
(
dirType
==
dir
&&
batchTime
<=
currentSecond
&&
batchTime
>=
preSecond
)
{
Integer
status
=
crossDirDataHistPO
.
getStatus
();
// 转换状态,3、4都算拥堵
if
(
status
==
4
)
{
...
...
@@ -1563,7 +1563,7 @@ public class TrendServiceImpl implements TrendService {
List
<
CrossTurnDataRealtimePO
>
subList
=
entry
.
getValue
();
List
<
AbnormalCrossDetailVO
.
TurnDataElement
.
TurnListElement
>
turnList
=
buildTurnList
(
subList
);
turnDataElement
.
setTurnList
(
turnList
);
turnData
.
add
(
turnDataElement
);
}
return
turnData
;
...
...
@@ -1661,4 +1661,48 @@ public class TrendServiceImpl implements TrendService {
}
greenwaveListVO
.
setDuration
(
duration
);
}
@Override
public
List
<
HotspotCrossVO
>
hotspotCross
()
throws
Exception
{
List
<
HotspotCrossVO
>
hotspotCrossVOS
=
new
ArrayList
<>();
LambdaQueryWrapper
<
CrossDataRealtimePO
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
select
(
CrossDataRealtimePO:
:
getCrossId
,
CrossDataRealtimePO:
:
getStartTime
,
CrossDataRealtimePO:
:
getBatchTime
)
.
orderByDesc
(
CrossDataRealtimePO:
:
getCongestionIndex
)
.
last
(
"limit 1"
);
List
<
CrossDataRealtimePO
>
crossRealtimePOS
=
crossDataRealtimeMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
crossRealtimePOS
)
&&
crossRealtimePOS
.
size
()
==
1
)
{
CrossDataRealtimePO
crossDataRealtimePO
=
crossRealtimePOS
.
get
(
0
);
// 查询当前拥堵指数最大,历史表中一个小时以内数据
LambdaQueryWrapper
<
CrossDirDataHistPO
>
histQuery
=
new
LambdaQueryWrapper
<>();
histQuery
.
eq
(
CrossDirDataHistPO:
:
getCrossId
,
crossDataRealtimePO
.
getCrossId
())
.
between
(
CrossDirDataHistPO:
:
getBatchTime
,
crossDataRealtimePO
.
getBatchTime
()
-
3600
,
crossDataRealtimePO
.
getBatchTime
());
List
<
CrossDirDataHistPO
>
histPOS
=
crossDirDataHistMapper
.
selectList
(
histQuery
);
if
(!
CollectionUtils
.
isEmpty
(
histPOS
))
{
Map
<
Date
,
List
<
CrossDirDataHistPO
>>
map
=
histPOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrossDirDataHistPO:
:
getStartTime
));
if
(!
map
.
isEmpty
())
{
for
(
Map
.
Entry
<
Date
,
List
<
CrossDirDataHistPO
>>
entry
:
map
.
entrySet
())
{
HotspotCrossVO
hotspotCrossVO
=
new
HotspotCrossVO
();
List
<
CrossDirDataHistPO
>
value
=
entry
.
getValue
();
if
(!
CollectionUtils
.
isEmpty
(
value
))
{
List
<
HotspotCrossVO
.
DetailVO
>
detailVOS
=
new
ArrayList
<>(
value
.
size
());
for
(
CrossDirDataHistPO
crossDirDataHistPO
:
value
)
{
HotspotCrossVO
.
DetailVO
detailVO
=
new
HotspotCrossVO
.
DetailVO
();
detailVO
.
setDir
(
crossDirDataHistPO
.
getDirType
());
detailVO
.
setQueueLength
(
crossDirDataHistPO
.
getQueueLength
());
detailVOS
.
add
(
detailVO
);
}
hotspotCrossVO
.
setDetailList
(
detailVOS
);
hotspotCrossVO
.
setTimeStamp
(
entry
.
getKey
());
hotspotCrossVOS
.
add
(
hotspotCrossVO
);
}
}
}
}
}
return
hotspotCrossVOS
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/vo/HotspotCrossVO.java
0 → 100644
View file @
1065f08c
package
net
.
wanji
.
opt
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author duanruiming
* @date 2024/05/06 10:58
*/
@NoArgsConstructor
@Data
@ApiModel
(
value
=
"重点路口监测实体"
,
description
=
"重点路口监测实体"
)
public
class
HotspotCrossVO
{
private
Date
timeStamp
;
private
List
<
DetailVO
>
detailList
;
@Data
public
static
class
DetailVO
{
private
Integer
dir
;
private
Double
queueLength
;
}
}
wj-databus/src/main/resources/mapper/CrossDataRealtimeMapper.xml
View file @
1065f08c
...
...
@@ -88,7 +88,7 @@
and t1.type = #{type}
</if>
<if
test=
"status == null"
>
and t1.status in (0, 1, 2, 3)
and t1.status in (0, 1, 2, 3
, 5
)
</if>
and t2.is_signal = 1
</where>
...
...
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