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
e6ff3bb0
Commit
e6ff3bb0
authored
Dec 05, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 干线运行监测优化
parent
8f1ed8b5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
41 deletions
+160
-41
StrategyControlEnum.java
.../java/net/wanji/opt/common/enums/StrategyControlEnum.java
+29
-0
GreenBeltController.java
...t/wanji/opt/controller/signalopt/GreenBeltController.java
+25
-2
GreenBeltInfoService.java
...net/wanji/opt/service/signalopt/GreenBeltInfoService.java
+3
-1
GreenBeltServiceImpl.java
...anji/opt/service/signalopt/impl/GreenBeltServiceImpl.java
+74
-29
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+4
-9
GreenBeltSpeedWidthVO.java
...src/main/java/net/wanji/opt/vo/GreenBeltSpeedWidthVO.java
+25
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/common/enums/StrategyControlEnum.java
0 → 100644
View file @
e6ff3bb0
package
net
.
wanji
.
opt
.
common
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @author duanruiming
* @date 2024/12/05 19:29
*/
@Getter
@AllArgsConstructor
public
enum
StrategyControlEnum
{
ZERO
(
0
,
"绿波带"
),
ONE
(
1
,
"失衡"
),
TWO
(
2
,
"溢出"
),
THREE
(
3
,
"空放"
);
private
int
code
;
private
String
desc
;
public
static
String
getDesc
(
int
code
)
{
for
(
StrategyControlEnum
value
:
StrategyControlEnum
.
values
())
{
if
(
code
==
value
.
getCode
())
{
return
value
.
getDesc
();
}
}
return
""
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/controller/signalopt/GreenBeltController.java
View file @
e6ff3bb0
...
...
@@ -8,19 +8,21 @@ import net.wanji.common.framework.rest.JsonViewObject;
import
net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO
;
import
net.wanji.opt.service.signalopt.GreenBeltInfoService
;
import
net.wanji.opt.vo.GreenBeltFlowStopTimeVO
;
import
net.wanji.opt.vo.GreenBeltSpeedWidthVO
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.ws.rs.core.MediaType
;
import
java.util.Collections
;
import
java.util.List
;
/**
* @author duanruiming
* @date 2024/11/28 16:03
*/
@Api
(
value
=
"
CrossIndexController"
,
description
=
"路口指标控制器
"
)
@Api
(
value
=
"
GreenBeltController"
,
description
=
"绿波干线
"
)
@RequestMapping
(
"/greenBelt"
)
@RestController
public
class
GreenBeltController
{
...
...
@@ -35,7 +37,28 @@ public class GreenBeltController {
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AddOrUpdateSceneDTO
.
class
),
})
public
JsonViewObject
greenBeltCrossDetailHist
(
Integer
greenId
)
{
List
<
GreenBeltFlowStopTimeVO
>
greenBeltFlowStopTimeVOS
=
greenBeltInfoService
.
greenBeltCrossDetailHist
(
greenId
);
List
<
GreenBeltFlowStopTimeVO
>
greenBeltFlowStopTimeVOS
=
Collections
.
EMPTY_LIST
;
try
{
greenBeltFlowStopTimeVOS
=
greenBeltInfoService
.
greenBeltCrossDetailHist
(
greenId
);
}
catch
(
Exception
e
)
{
JsonViewObject
.
newInstance
().
fail
(
"绿波协调方向路口流量停车次数异常"
);
}
return
JsonViewObject
.
newInstance
().
success
(
greenBeltFlowStopTimeVOS
);
}
@ApiOperation
(
value
=
"绿波带宽曲线"
,
notes
=
"优化监测-绿波带宽曲线"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/greenBeltSpeedWidth"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AddOrUpdateSceneDTO
.
class
),
})
public
JsonViewObject
greenBeltSpeedWidth
(
Integer
greenId
)
{
List
<
GreenBeltSpeedWidthVO
>
greenBeltFlowStopTimeVOS
=
Collections
.
EMPTY_LIST
;
try
{
greenBeltFlowStopTimeVOS
=
greenBeltInfoService
.
greenBeltSpeedWidth
(
greenId
);
}
catch
(
Exception
e
)
{
JsonViewObject
.
newInstance
().
fail
(
"绿波带宽曲线异常"
);
}
return
JsonViewObject
.
newInstance
().
success
(
greenBeltFlowStopTimeVOS
);
}
}
signal-optimize-service/src/main/java/net/wanji/opt/service/signalopt/GreenBeltInfoService.java
View file @
e6ff3bb0
package
net
.
wanji
.
opt
.
service
.
signalopt
;
import
net.wanji.opt.vo.GreenBeltFlowStopTimeVO
;
import
net.wanji.opt.vo.GreenBeltSpeedWidthVO
;
import
java.util.List
;
...
...
@@ -9,5 +10,6 @@ import java.util.List;
* @date 2024/11/19 18:07
*/
public
interface
GreenBeltInfoService
{
List
<
GreenBeltFlowStopTimeVO
>
greenBeltCrossDetailHist
(
Integer
greenId
);
List
<
GreenBeltFlowStopTimeVO
>
greenBeltCrossDetailHist
(
Integer
greenId
)
throws
Exception
;
List
<
GreenBeltSpeedWidthVO
>
greenBeltSpeedWidth
(
Integer
greenId
)
throws
Exception
;
}
signal-optimize-service/src/main/java/net/wanji/opt/service/signalopt/impl/GreenBeltServiceImpl.java
View file @
e6ff3bb0
package
net
.
wanji
.
opt
.
service
.
signalopt
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.utils.tool.DateUtil
;
import
net.wanji.databus.dao.mapper.CrossDataHistMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.databus.po.CrossDataHistPO
;
import
net.wanji.opt.dao.mapper.StrategyControlInfoMapper
;
import
net.wanji.opt.dao.mapper.StrategyGreenOptHistMapper
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
import
net.wanji.opt.service.signalopt.GreenBeltInfoService
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDataEntity
;
import
net.wanji.opt.vo.GreenBeltFlowStopTimeVO
;
import
net.wanji.opt.vo.GreenBeltSpeedWidthVO
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.text.ParseException
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
...
...
@@ -21,46 +30,82 @@ import java.util.stream.Collectors;
* @date 2024/12/02 13:42
*/
@Service
@Slf4j
public
class
GreenBeltServiceImpl
implements
GreenBeltInfoService
{
@Resource
private
GreenwaveInfoMapper
greenwaveInfoMapper
;
@Resource
private
CrossDataHistMapper
crossDataHistMapper
;
@Resource
private
StrategyGreenOptHistMapper
strategyGreenOptHistMapper
;
@Override
public
List
<
GreenBeltFlowStopTimeVO
>
greenBeltCrossDetailHist
(
Integer
greenId
)
{
List
<
String
>
crossIds
=
greenwaveInfoMapper
.
selectCrossIdsById
(
greenId
);
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
));
for
(
Map
.
Entry
<
Date
,
List
<
CrossDataHistPO
>>
entry
:
startTimeMap
.
entrySet
())
{
GreenBeltFlowStopTimeVO
greenBeltFlowStopTimeVO
=
new
GreenBeltFlowStopTimeVO
();
Date
startDate
=
entry
.
getKey
();
List
<
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
>
crossList
=
new
ArrayList
<>();
greenBeltFlowStopTimeVO
.
setStartTime
(
startDate
);
List
<
CrossDataHistPO
>
value
=
entry
.
getValue
();
if
(!
CollectionUtils
.
isEmpty
(
value
))
{
for
(
CrossDataHistPO
crossDataHistPO
:
value
)
{
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
flowStopTimeDetail
=
new
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
();
flowStopTimeDetail
.
setFlow
(
crossDataHistPO
.
getFlow
());
flowStopTimeDetail
.
setStopTimes
(
crossDataHistPO
.
getStopTimes
());
flowStopTimeDetail
.
setCrossId
(
crossDataHistPO
.
getCrossId
());
// todo 先删除,后续通过路口距离/速度计算 距离通过卫博发送数据
flowStopTimeDetail
.
setTravelTime
(
0.0
);
crossList
.
add
(
flowStopTimeDetail
);
}
public
List
<
GreenBeltSpeedWidthVO
>
greenBeltSpeedWidth
(
Integer
greenId
)
throws
Exception
{
try
{
LambdaQueryWrapper
<
StrategyGreenOptHistEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
StrategyGreenOptHistEntity:
:
getGreenId
,
greenId
);
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
LocalDateTime
startOfDay
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
queryWrapper
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
startOfDay
);
List
<
StrategyGreenOptHistEntity
>
entities
=
strategyGreenOptHistMapper
.
selectList
(
queryWrapper
);
List
<
GreenBeltSpeedWidthVO
>
results
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
entities
))
{
for
(
StrategyGreenOptHistEntity
entity
:
entities
)
{
GreenBeltSpeedWidthVO
greenBeltSpeedWidthVO
=
new
GreenBeltSpeedWidthVO
();
Date
date
=
DateUtil
.
parse
(
entity
.
getControlTime
(),
"yyyy-MM-dd HH:mm:ss"
);
greenBeltSpeedWidthVO
.
setStartTime
(
date
);
greenBeltSpeedWidthVO
.
setSpeed
(
entity
.
getMaxSpeed
());
greenBeltSpeedWidthVO
.
setWidth
(
entity
.
getGreenWidthTime
());
results
.
add
(
greenBeltSpeedWidthVO
);
}
greenBeltFlowStopTimeVO
.
setDetailList
(
crossList
);
results
.
add
(
greenBeltFlowStopTimeVO
);
}
Collections
.
sort
(
results
,
Comparator
.
comparing
(
GreenBeltFlowStopTimeVO:
:
getStartTime
));
return
results
;
}
catch
(
Exception
e
)
{
log
.
error
(
"绿波带宽曲线异常:"
,
e
);
throw
new
RuntimeException
(
e
);
}
}
@Override
public
List
<
GreenBeltFlowStopTimeVO
>
greenBeltCrossDetailHist
(
Integer
greenId
)
throws
Exception
{
try
{
List
<
String
>
crossIds
=
greenwaveInfoMapper
.
selectCrossIdsById
(
greenId
);
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
));
for
(
Map
.
Entry
<
Date
,
List
<
CrossDataHistPO
>>
entry
:
startTimeMap
.
entrySet
())
{
GreenBeltFlowStopTimeVO
greenBeltFlowStopTimeVO
=
new
GreenBeltFlowStopTimeVO
();
Date
startDate
=
entry
.
getKey
();
List
<
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
>
crossList
=
new
ArrayList
<>();
greenBeltFlowStopTimeVO
.
setStartTime
(
startDate
);
List
<
CrossDataHistPO
>
value
=
entry
.
getValue
();
if
(!
CollectionUtils
.
isEmpty
(
value
))
{
for
(
CrossDataHistPO
crossDataHistPO
:
value
)
{
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
flowStopTimeDetail
=
new
GreenBeltFlowStopTimeVO
.
FlowStopTimeDetail
();
flowStopTimeDetail
.
setFlow
(
crossDataHistPO
.
getFlow
());
flowStopTimeDetail
.
setStopTimes
(
crossDataHistPO
.
getStopTimes
());
flowStopTimeDetail
.
setCrossId
(
crossDataHistPO
.
getCrossId
());
// todo 先删除,后续通过路口距离/速度计算 距离通过卫博发送数据
flowStopTimeDetail
.
setTravelTime
(
0.0
);
crossList
.
add
(
flowStopTimeDetail
);
}
}
greenBeltFlowStopTimeVO
.
setDetailList
(
crossList
);
results
.
add
(
greenBeltFlowStopTimeVO
);
}
Collections
.
sort
(
results
,
Comparator
.
comparing
(
GreenBeltFlowStopTimeVO:
:
getStartTime
));
return
results
;
}
return
Collections
.
EMPTY_LIST
;
}
catch
(
Exception
e
)
{
log
.
error
(
"绿波协调方向路口流量停车次数查询异常:"
,
e
);
throw
new
RuntimeException
(
e
);
}
return
Collections
.
EMPTY_LIST
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
e6ff3bb0
...
...
@@ -19,6 +19,8 @@ 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.common.enums.CrossOptStrategyEnum
;
import
net.wanji.opt.common.enums.StrategyControlEnum
;
import
net.wanji.opt.dao.mapper.*
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
import
net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum
;
...
...
@@ -400,19 +402,12 @@ public class StrategyControlServiceImpl implements StrategyControlService {
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
try
{
List
<
StrategyControlDataEntity
>
currentStrateInfoList
=
getCurrentStrateInfoList
(
type
);
List
<
StrategyFactoryEntity
>
strategyFactoryEntities
=
strategyFactoryMapper
.
selectList
(
null
);
List
<
StrategyControlDataExt
>
strategyControlDataExts
=
new
ArrayList
<>();
for
(
StrategyControlDataEntity
strategyControlDataEntity
:
currentStrateInfoList
)
{
Integer
strategy
=
strategyControlDataEntity
.
getStrategy
();
StrategyControlDataExt
strategyControlDataExt
=
new
StrategyControlDataExt
();
BeanUtils
.
copyProperties
(
strategyControlDataEntity
,
strategyControlDataExt
);
String
strategyName
=
""
;
for
(
StrategyFactoryEntity
strategyFactoryEntity
:
strategyFactoryEntities
)
{
if
(
Objects
.
equals
(
strategy
,
strategyFactoryEntity
.
getScene
()))
{
strategyName
=
strategyFactoryEntity
.
getStrategyName
();
}
}
strategyControlDataExt
.
setStrategyName
(
strategyName
);
strategyControlDataExt
.
setStrategyName
(
StrategyControlEnum
.
getDesc
(
strategy
));
strategyControlDataExt
.
setOptStatus
(
"未执行"
);
if
(
StringUtils
.
isNotBlank
(
strategyControlDataEntity
.
getTime
()))
{
strategyControlDataExt
.
setOptStatus
(
"优化中"
);
...
...
@@ -635,7 +630,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for
(
StrategyPlanDTO
strategyPlanDTO
:
strategyPlanDTOS
)
{
Integer
dailyPlanId
=
planDetail
.
getDailyPlanId
();
List
<
Integer
>
weeks
=
planDetail
.
getWeeks
();
if
(
dailyPlanId
==
strategyPlanDTO
.
getDailyPlanId
(
))
{
if
(
Objects
.
equals
(
dailyPlanId
,
strategyPlanDTO
.
getDailyPlanId
()
))
{
strategyPlanDTO
.
setPlanId
(
planId
);
strategyPlanDTO
.
setStartTime
(
startTime
);
strategyPlanDTO
.
setEndTime
(
endTime
);
...
...
signal-optimize-service/src/main/java/net/wanji/opt/vo/GreenBeltSpeedWidthVO.java
0 → 100644
View file @
e6ff3bb0
package
net
.
wanji
.
opt
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author duanruiming
* @date 2024/12/05 19:48
*/
@Data
@ApiModel
(
value
=
"优化监测-绿波带宽曲线实体"
)
public
class
GreenBeltSpeedWidthVO
{
@ApiModelProperty
(
"时间"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startTime
;
@ApiModelProperty
(
"流量"
)
private
Double
speed
;
@ApiModelProperty
(
"带宽"
)
private
Double
width
;
}
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