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
52fe6646
Commit
52fe6646
authored
Feb 06, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 交通体检-交通状态接口优化
parent
8122b65e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
25 deletions
+45
-25
HoloEventMapper.java
...c/main/java/net/wanji/opt/dao/mapper/HoloEventMapper.java
+8
-0
EventTypeTimeRateDTO.java
...src/main/java/net/wanji/opt/dto/EventTypeTimeRateDTO.java
+14
-0
TrendServiceImpl.java
...ain/java/net/wanji/opt/service/impl/TrendServiceImpl.java
+13
-25
HoloEventMapper.xml
...ize-service/src/main/resources/mapper/HoloEventMapper.xml
+10
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/dao/mapper/HoloEventMapper.java
View file @
52fe6646
...
...
@@ -3,6 +3,7 @@ package net.wanji.opt.dao.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
net.wanji.databus.dto.EventInfoTrafficStatusDTO
;
import
net.wanji.databus.po.EventInfoTrafficStatusPO
;
import
net.wanji.opt.dto.EventTypeTimeRateDTO
;
import
net.wanji.opt.entity.EventAlarmInfo
;
import
net.wanji.opt.po.base.EventStatisticPo
;
import
net.wanji.opt.po.trend.EventInfoSimplePo
;
...
...
@@ -50,4 +51,11 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
*/
List
<
EventAlarmInfo
>
findNotFinishAlarmInfo
();
/**
* 查询事件表,事件类型持续时间与当前时间的时间比例,对应交通体检-交通状态
* @param crossId
* @return
*/
List
<
EventTypeTimeRateDTO
>
selectEventTypeTimeRate
(
String
crossId
);
}
signal-optimize-service/src/main/java/net/wanji/opt/dto/EventTypeTimeRateDTO.java
0 → 100644
View file @
52fe6646
package
net
.
wanji
.
opt
.
dto
;
import
lombok.Data
;
/**
* @author duanruiming
* @date 2025/02/06 17:02
* @description 事件表事件类型与当前事件比例
*/
@Data
public
class
EventTypeTimeRateDTO
{
private
String
type
;
private
Double
timeRate
;
}
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/TrendServiceImpl.java
View file @
52fe6646
...
...
@@ -25,6 +25,7 @@ import net.wanji.opt.cache.BaseCrossInfoCache;
import
net.wanji.opt.common.ExcelExportUtils
;
import
net.wanji.opt.common.KafkaConsumerUtil
;
import
net.wanji.opt.common.RedisUtils
;
import
net.wanji.opt.common.enums.EventInfoTypeEnum
;
import
net.wanji.opt.common.exception.OptServiceException
;
import
net.wanji.opt.config.DirectionMappingsConfig
;
import
net.wanji.opt.dao.mapper.CrossSchemeOptLogMapper
;
...
...
@@ -35,10 +36,7 @@ import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper;
import
net.wanji.opt.dao.mapper.strategy.StrategyMapper
;
import
net.wanji.opt.dao.mapper.trend.AnalysisRidTurnIndicatorsMapper
;
import
net.wanji.opt.dao.mapper.trend.EventAlarmMapper
;
import
net.wanji.opt.dto.CrossEventDTO
;
import
net.wanji.opt.dto.CrossLaneSnapshotDataDTO
;
import
net.wanji.opt.dto.LineCongestion
;
import
net.wanji.opt.dto.LineSchemeDTO
;
import
net.wanji.opt.dto.*
;
import
net.wanji.opt.dto.trend.AbnormalCrossListDTO
;
import
net.wanji.opt.dto.trend.GreenwaveListDTO
;
import
net.wanji.opt.po.base.CrossSchemeOptLogPO
;
...
...
@@ -2020,30 +2018,20 @@ public class TrendServiceImpl implements TrendService {
CrossStatusTimeRateVO
crossStatusTimeRateVO
=
new
CrossStatusTimeRateVO
();
try
{
String
crossId
=
commonCrossIdVO
.
getCrossId
();
//Instant instant = Instant.ofEpochSecond(1705456500L);
Date
date
=
new
Date
();
long
time
=
date
.
getTime
()
/
1000
;
Instant
instant
=
Instant
.
ofEpochSecond
(
time
);
LocalDateTime
localDateTime
=
LocalDateTime
.
ofInstant
(
instant
,
ZoneId
.
of
(
"+8"
));
// 00:00
LocalDateTime
startOfDay
=
localDateTime
.
withHour
(
0
).
withMinute
(
0
).
withSecond
(
0
);
int
startBatchTime
=
Long
.
valueOf
(
Date
.
from
(
startOfDay
.
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
()).
getTime
()
/
1000
).
intValue
();
// 23:59
LocalDateTime
endOfDay
=
startOfDay
.
plus
(
1
,
ChronoUnit
.
DAYS
).
minus
(
1
,
ChronoUnit
.
SECONDS
);
int
endBatchTime
=
Long
.
valueOf
(
Date
.
from
(
endOfDay
.
atZone
(
ZoneId
.
of
(
"+8"
)).
toInstant
()).
getTime
()
/
1000
).
intValue
();
List
<
CrossDataHistPO
>
crossDataHistPOS
=
crossDataHistMapper
.
selectByCrossIdAndStartEnd
(
crossId
,
startBatchTime
,
endBatchTime
);
if
(!
CollectionUtils
.
isEmpty
(
crossDataHistPOS
))
{
Map
<
Integer
,
List
<
CrossDataHistPO
>>
statusMap
=
crossDataHistPOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
CrossDataHistPO:
:
getStatus
));
crossStatusTimeRateVO
.
setCrossId
(
crossId
);
for
(
Map
.
Entry
<
Integer
,
List
<
CrossDataHistPO
>>
entry
:
statusMap
.
entrySet
())
{
Integer
status
=
entry
.
getKey
();
List
<
CrossDataHistPO
>
value
=
entry
.
getValue
();
float
temp
=
value
.
size
()
/
(
float
)
crossDataHistPOS
.
size
()
*
100
;
List
<
EventTypeTimeRateDTO
>
eventTypeTimeRateDTOS
=
holoEventMapper
.
selectEventTypeTimeRate
(
crossId
);
if
(!
CollectionUtils
.
isEmpty
(
eventTypeTimeRateDTOS
))
{
int
unblockedTimeRate
=
0
;
for
(
EventTypeTimeRateDTO
eventTypeTimeRateDTO
:
eventTypeTimeRateDTOS
)
{
String
type
=
eventTypeTimeRateDTO
.
getType
();
Double
timeRate
=
eventTypeTimeRateDTO
.
getTimeRate
();
Double
temp
=
timeRate
*
100
;
temp
=
temp
<
1
?
0
:
temp
;
int
rate
=
Math
.
round
(
temp
);
int
rate
=
(
int
)
Math
.
round
(
temp
);
int
status
=
EventInfoTypeEnum
.
getOptType
(
type
);
setStatusTimeRate
(
crossStatusTimeRateVO
,
status
,
rate
);
unblockedTimeRate
+=
rate
;
}
crossStatusTimeRateVO
.
setUnblockedTimeRate
(
100
-
unblockedTimeRate
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"交通状态时间比例异常:"
,
e
);
...
...
signal-optimize-service/src/main/resources/mapper/HoloEventMapper.xml
View file @
52fe6646
...
...
@@ -228,6 +228,16 @@
start_time
</select>
<select
id=
"selectEventTypeTimeRate"
parameterType=
"String"
resultType=
"net.wanji.opt.dto.EventTypeTimeRateDTO"
>
select type, sum(duration) / totalTime as timeRate from (
select cross_id, type,
TIMESTAMPDIFF(SECOND, start_time, ifnull(end_time,now())) duration,
TIMESTAMPDIFF(SECOND, DATE_FORMAT(start_time, '%Y-%m-%d 00:00:00'), now()) as totalTime
from t_event_info
where type in ('701', '702', '703', '704', '707') and start_time >= curdate() and cross_id = '13N0C0B5P30'
) t1 group by t1.type;
</select>
</mapper>
\ No newline at end of file
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