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
f6fed476
Commit
f6fed476
authored
Dec 04, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 路网优化检测AI优化历史优化
parent
074627fc
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
105 additions
and
28 deletions
+105
-28
GreenBeltController.java
...t/wanji/opt/controller/signalopt/GreenBeltController.java
+1
-1
GreenBeltServiceImpl.java
...anji/opt/service/signalopt/impl/GreenBeltServiceImpl.java
+6
-9
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+12
-1
StrategyGreenBeltController.java
...opt/synthesis/controller/StrategyGreenBeltController.java
+1
-1
StrategyOptTimesVO.java
...a/net/wanji/opt/synthesis/pojo/vo/StrategyOptTimesVO.java
+18
-0
StrategyControlService.java
...t/wanji/opt/synthesis/service/StrategyControlService.java
+1
-0
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+61
-16
StrategyGreenBeltServiceImpl.java
.../synthesis/service/impl/StrategyGreenBeltServiceImpl.java
+1
-0
GreenBeltFlowStopTimeVO.java
...c/main/java/net/wanji/opt/vo/GreenBeltFlowStopTimeVO.java
+2
-0
GreenBeltStopTimesQueueLengthVO.java
...ava/net/wanji/opt/vo/GreenBeltStopTimesQueueLengthVO.java
+2
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/controller/signalopt/GreenBeltController.java
View file @
f6fed476
...
...
@@ -28,7 +28,7 @@ public class GreenBeltController {
@Resource
private
GreenBeltInfoService
greenBeltInfoService
;
@ApiOperation
(
value
=
"绿波协调方向
流量停车次数"
,
notes
=
"绿波协调方向
流量停车次数"
,
response
=
JsonViewObject
.
class
,
@ApiOperation
(
value
=
"绿波协调方向
路口流量停车次数"
,
notes
=
"绿波协调方向路口
流量停车次数"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/greenBeltCrossDetailHist"
)
@ApiResponses
({
...
...
signal-optimize-service/src/main/java/net/wanji/opt/service/signalopt/impl/GreenBeltServiceImpl.java
View file @
f6fed476
...
...
@@ -31,15 +31,10 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
@Override
public
List
<
GreenBeltFlowStopTimeVO
>
greenBeltCrossDetailHist
(
Integer
greenId
)
{
List
<
String
>
crossIds
=
greenwaveInfoMapper
.
selectCrossIdsById
(
greenId
);
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
// 00:00
LocalDateTime
startOfDay
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
LocalDate
nextDate
=
currentDate
.
plusDays
(
1
);
LocalTime
endTime
=
LocalTime
.
MIDNIGHT
;
// 00:00 of the next day
LocalDateTime
endOfDay
=
LocalDateTime
.
of
(
nextDate
,
endTime
);
long
startSecond
=
startOfDay
.
toEpochSecond
(
ZoneOffset
.
of
(
"+8"
))
+
5
*
600
;
long
endSecond
=
endOfDay
.
toEpochSecond
(
ZoneOffset
.
of
(
"+8"
));
List
<
CrossDataHistPO
>
crossDataHistPOS
=
crossDataHistMapper
.
selectByCrossIdsAndTimestamp
(
crossIds
,
(
int
)
startSecond
,
(
int
)
endSecond
);
long
currentTimeMillis
=
System
.
currentTimeMillis
();
int
startSecond
=
(
int
)
(
currentTimeMillis
/
1000
-
3600
);
int
endSecond
=
(
int
)
(
currentTimeMillis
/
1000
);
List
<
CrossDataHistPO
>
crossDataHistPOS
=
crossDataHistMapper
.
selectByCrossIdsAndTimestamp
(
crossIds
,
startSecond
,
endSecond
);
if
(!
CollectionUtils
.
isEmpty
(
crossDataHistPOS
))
{
List
<
GreenBeltFlowStopTimeVO
>
results
=
new
ArrayList
<>();
Map
<
Date
,
List
<
CrossDataHistPO
>>
startTimeMap
=
crossDataHistPOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrossDataHistPO:
:
getStartTime
));
...
...
@@ -55,6 +50,8 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
flowStopTimeDetail
.
setFlow
(
crossDataHistPO
.
getFlow
());
flowStopTimeDetail
.
setStopTimes
(
crossDataHistPO
.
getStopTimes
());
flowStopTimeDetail
.
setCrossId
(
crossDataHistPO
.
getCrossId
());
// todo 先删除,后续通过路口距离/速度计算 距离通过卫博发送数据
flowStopTimeDetail
.
setTravelTime
(
0.0
);
crossList
.
add
(
flowStopTimeDetail
);
}
}
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
f6fed476
...
...
@@ -77,7 +77,18 @@ public class StrategyControlController {
}
@ApiOperation
(
value
=
"路网优化监测"
,
notes
=
"路网优化监测"
,
@ApiOperation
(
value
=
"AI优化次数优化时长"
,
notes
=
"路网优化检测-AI优化次数优化时长"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/strategyOptTimes"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
StrategyControlDataEntity
.
class
),
})
public
JsonViewObject
strategyOptTimes
()
throws
Exception
{
return
strategyControlService
.
strategyOptTimes
();
}
@ApiOperation
(
value
=
"路网优化监测-接口干线列表"
,
notes
=
"路网优化监测-AI路口-AI干线"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/crossOptInfoList"
)
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyGreenBeltController.java
View file @
f6fed476
...
...
@@ -24,7 +24,7 @@ import java.util.List;
* @date 2024/11/19 20:10
* @description 神思推送绿波时序图
*/
@Api
(
value
=
"StrategyGreenBeltController"
,
description
=
"策略绿波带"
)
@Api
(
value
=
"StrategyGreenBeltController"
,
description
=
"策略绿波带
弹窗
"
)
@RequestMapping
(
"/strategyBelt"
)
@RestController
public
class
StrategyGreenBeltController
{
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/vo/StrategyOptTimesVO.java
0 → 100644
View file @
f6fed476
package
net
.
wanji
.
opt
.
synthesis
.
pojo
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author duanruiming
* @date 2024/12/04 13:58
*/
@Data
@ApiModel
(
"AI优化次数优化时长返回实体"
)
public
class
StrategyOptTimesVO
{
@ApiModelProperty
(
"优化次数"
)
private
Integer
count
;
@ApiModelProperty
(
"优化时长"
)
private
Integer
times
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/StrategyControlService.java
View file @
f6fed476
...
...
@@ -15,6 +15,7 @@ public interface StrategyControlService {
JsonViewObject
strategyInfoPageList
(
StrategyControlDataEntity
entity
)
throws
Exception
;
JsonViewObject
crossStrategyInfoList
(
Integer
type
)
throws
Exception
;
JsonViewObject
strategyOptTimes
()
throws
Exception
;
JsonViewObject
crossStrategyHistList
()
throws
Exception
;
JsonViewObject
crossOptInfoList
(
Integer
type
)
throws
Exception
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
f6fed476
...
...
@@ -16,6 +16,7 @@ import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.databus.po.BaseCrossInfoPO
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.opt.cache.BaseCrossInfoCache
;
import
net.wanji.opt.cache.GreenWaveInfoCache
;
import
net.wanji.opt.dao.mapper.*
;
...
...
@@ -25,6 +26,7 @@ import net.wanji.opt.synthesis.pojo.*;
import
net.wanji.opt.synthesis.pojo.vo.StrategyControlDataVO
;
import
net.wanji.opt.synthesis.pojo.vo.StrategyControlHistVO
;
import
net.wanji.opt.synthesis.pojo.vo.StrategyControlVO
;
import
net.wanji.opt.synthesis.pojo.vo.StrategyOptTimesVO
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -38,6 +40,7 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -245,12 +248,15 @@ public class StrategyControlServiceImpl implements StrategyControlService {
try
{
List
<
StrategyControlDataEntity
>
results
=
new
ArrayList
<>();
List
<
StrategyControlDataEntity
>
entities
=
getCurrentStrateInfoList
(
type
);
Map
<
String
,
StrategyControlDataEntity
>
map
=
entities
.
stream
().
collect
(
Collectors
.
toMap
(
StrategyControlDataEntity:
:
getBizId
,
entity
->
entity
));
List
<
StrategyControlDataEntity
>
runList
=
entities
.
stream
().
filter
(
entity
->
Objects
.
equals
(
1
,
entity
.
getStatus
())).
collect
(
Collectors
.
toList
());
Map
<
String
,
StrategyControlDataEntity
>
map
=
runList
.
stream
().
collect
(
Collectors
.
toMap
(
StrategyControlDataEntity:
:
getBizId
,
entity
->
entity
));
// 路口
if
(
Objects
.
equals
(
0
,
type
))
{
List
<
BaseCrossInfoPO
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectAll
();
LambdaQueryWrapper
<
TBaseCrossInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
TBaseCrossInfo:
:
getIsSignal
,
1
);
List
<
TBaseCrossInfo
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
baseCrossInfoPOS
))
{
for
(
BaseCrossInfoPO
baseCrossInfoPO
:
baseCrossInfoPOS
)
{
for
(
TBaseCrossInfo
baseCrossInfoPO
:
baseCrossInfoPOS
)
{
StrategyControlDataEntity
strategyControlDataEntity
=
new
StrategyControlDataEntity
();
String
crossId
=
baseCrossInfoPO
.
getId
();
strategyControlDataEntity
.
setBizType
(
0
);
...
...
@@ -258,13 +264,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
strategyControlDataEntity
.
setStrategy
(
null
);
strategyControlDataEntity
.
setTime
(
null
);
strategyControlDataEntity
.
setStatus
(
0
);
if
(
map
.
containsKey
(
crossId
))
{
strategyControlDataEntity
=
map
.
get
(
crossId
);
}
strategyControlDataEntity
.
setCrossName
(
baseCrossInfoPO
.
getName
());
String
location
=
baseCrossInfoPO
.
getLocation
();
location
=
location
.
replace
(
"POINT("
,
""
).
replace
(
" "
,
","
).
replace
(
")"
,
""
);
strategyControlDataEntity
.
setWkt
(
location
);
if
(
map
.
containsKey
(
crossId
))
{
strategyControlDataEntity
=
map
.
get
(
crossId
);
}
results
.
add
(
strategyControlDataEntity
);
}
}
...
...
@@ -274,17 +280,17 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if
(!
CollectionUtils
.
isEmpty
(
greenwaveInfoPOS
))
{
for
(
GreenwaveInfoPO
greenwaveInfoPO
:
greenwaveInfoPOS
)
{
StrategyControlDataEntity
strategyControlDataEntity
=
new
StrategyControlDataEntity
();
Integer
greenId
=
greenwaveInfoPO
.
getId
(
);
String
greenId
=
String
.
valueOf
(
greenwaveInfoPO
.
getId
()
);
strategyControlDataEntity
.
setBizType
(
1
);
strategyControlDataEntity
.
setBizId
(
String
.
valueOf
(
greenId
));
strategyControlDataEntity
.
setStrategy
(
null
);
strategyControlDataEntity
.
setTime
(
null
);
strategyControlDataEntity
.
setStatus
(
0
);
strategyControlDataEntity
.
setCrossName
(
greenwaveInfoPO
.
getName
());
strategyControlDataEntity
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
if
(
map
.
containsKey
(
greenId
))
{
strategyControlDataEntity
=
map
.
get
(
greenId
);
}
strategyControlDataEntity
.
setCrossName
(
greenwaveInfoPO
.
getName
());
strategyControlDataEntity
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
results
.
add
(
strategyControlDataEntity
);
}
}
...
...
@@ -296,15 +302,50 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
@Override
public
JsonViewObject
strategyOptTimes
()
throws
Exception
{
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
LocalDateTime
startOfDay
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
LambdaQueryWrapper
<
StrategyGreenOptHistEntity
>
greenQuery
=
new
LambdaQueryWrapper
<>();
greenQuery
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
startOfDay
);
List
<
StrategyGreenOptHistEntity
>
greenOptList
=
strategyGreenOptHistMapper
.
selectList
(
greenQuery
);
int
totalTime
=
0
;
int
totalCount
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
greenOptList
))
{
for
(
StrategyGreenOptHistEntity
entity
:
greenOptList
)
{
Integer
controlDuration
=
entity
.
getControlDuration
();
totalTime
+=
controlDuration
;
totalCount
+=
1
;
}
}
LambdaQueryWrapper
<
StrategyCrossResultEntity
>
crossQuery
=
new
LambdaQueryWrapper
<>();
crossQuery
.
ge
(
StrategyCrossResultEntity:
:
getIssueTime
,
startOfDay
);
List
<
StrategyCrossResultEntity
>
crossList
=
strategyCrossResultMapper
.
selectList
(
crossQuery
);
if
(!
CollectionUtils
.
isEmpty
(
crossList
))
{
for
(
StrategyCrossResultEntity
entity
:
crossList
)
{
Integer
countDown
=
entity
.
getCountDown
();
if
(
Math
.
abs
(
countDown
)
>
1
)
{
totalTime
+=
countDown
;
totalCount
+=
1
;
}
}
}
StrategyOptTimesVO
strategyOptTimesVO
=
new
StrategyOptTimesVO
();
strategyOptTimesVO
.
setCount
(
totalCount
);
strategyOptTimesVO
.
setTimes
(
totalTime
/
3600
);
return
JsonViewObject
.
newInstance
().
success
(
strategyOptTimesVO
);
}
private
List
<
StrategyControlDataEntity
>
getCurrentStrateInfoList
(
Integer
type
)
throws
Exception
{
ObjectMapper
instance
=
JacksonUtils
.
getInstance
();
LambdaQueryWrapper
<
StrategyControlDataEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
Date
current
=
new
Date
();
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizType
,
type
);
queryWrapper
.
ge
(
StrategyControlDataEntity:
:
getScheduleStart
,
new
Date
()
);
queryWrapper
.
le
(
StrategyControlDataEntity:
:
getScheduleEnd
,
new
Date
()
);
queryWrapper
.
le
(
StrategyControlDataEntity:
:
getScheduleStart
,
current
);
queryWrapper
.
ge
(
StrategyControlDataEntity:
:
getScheduleEnd
,
current
);
List
<
StrategyControlDataEntity
>
entities
=
strategyControlInfoMapper
.
selectList
(
queryWrapper
);
List
<
StrategyControlDataEntity
>
results
=
new
ArrayList
<>(
entities
.
size
());
Date
current
=
new
Date
();
for
(
StrategyControlDataEntity
entity
:
entities
)
{
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
result
);
...
...
@@ -317,7 +358,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List
<
StrategyControlDataVO
.
TimeTable
>
timeTables
=
instance
.
readValue
(
time
,
new
TypeReference
<
List
<
StrategyControlDataVO
.
TimeTable
>>()
{
});
for
(
StrategyControlDataVO
.
TimeTable
timeTable
:
timeTables
)
{
int
currentWeek
=
DateUtil
.
thisDayOfWeek
();
int
currentWeek
=
DateUtil
.
thisDayOfWeek
()
-
1
;
if
(
currentWeek
!=
timeTable
.
getWeek
())
{
result
.
setTime
(
""
);
}
else
{
...
...
@@ -328,14 +369,17 @@ public class StrategyControlServiceImpl implements StrategyControlService {
String
[]
currentHour
=
hour
.
split
(
"-"
);
String
startHour
=
currentHour
[
0
];
String
entHour
=
currentHour
[
1
];
if
(
StringUtils
.
equals
(
"24:00"
,
entHour
))
{
entHour
=
"23:59"
;
}
String
format
=
DateUtil
.
format
(
current
,
"HH:mm"
);
DateTime
currentTime
=
DateUtil
.
parse
(
format
,
"HH:mm"
);
DateTime
startHourDate
=
DateUtil
.
parse
(
startHour
,
"HH:mm"
);
DateTime
endHourDate
=
DateUtil
.
parse
(
entHour
,
"HH:mm"
);
if
(
currentTime
.
before
(
startHourDate
)
||
currentTime
.
after
(
endHourDate
))
{
if
(
currentTime
.
after
(
startHourDate
)
&&
currentTime
.
before
(
endHourDate
))
{
result
.
setTime
(
hour
);
result
.
setStatus
(
1
);
}
}
else
{
// 如果有调度策略在执行,设置为开启,否则关闭,提供前端过滤配置和未配置
result
.
setStatus
(
0
);
}
...
...
@@ -343,6 +387,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
}
}
if
(
type
==
0
)
{
BaseCrossInfoPO
baseCrossInfoPO
=
baseCrossInfoMapper
.
selectById
(
entity
.
getBizId
());
result
.
setCrossName
(
baseCrossInfoPO
.
getName
());
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyGreenBeltServiceImpl.java
View file @
f6fed476
...
...
@@ -86,6 +86,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
vo
.
setHourMinute
(
DateUtils
.
format
(
greenwaveHistPO
.
getStartTime
(),
"HH:mm"
));
vo
.
setStopTimes
(
greenwaveHistPO
.
getStopTimes
());
vo
.
setCordQueueRatio
(
greenwaveHistPO
.
getCordQueueRatio
()
*
100
);
vo
.
setTravelTime
(
greenwaveHistPO
.
getTrvalTime
());
results
.
add
(
vo
);
}
}
...
...
signal-optimize-service/src/main/java/net/wanji/opt/vo/GreenBeltFlowStopTimeVO.java
View file @
f6fed476
...
...
@@ -29,5 +29,7 @@ public class GreenBeltFlowStopTimeVO {
private
Integer
flow
;
@ApiModelProperty
(
"停车次数"
)
private
Double
stopTimes
;
@ApiModelProperty
(
"行程时间"
)
private
Double
travelTime
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/vo/GreenBeltStopTimesQueueLengthVO.java
View file @
f6fed476
...
...
@@ -27,4 +27,6 @@ public class GreenBeltStopTimesQueueLengthVO {
private
Double
stopTimes
;
@ApiModelProperty
(
"空间占比"
)
private
Double
cordQueueRatio
;
@ApiModelProperty
(
"行程时间"
)
private
Integer
travelTime
;
}
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