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
jinan
traffic-signal-platform
Commits
9a6547ca
Commit
9a6547ca
authored
Apr 25, 2025
by
zhoushiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
干线周报-运行状态bug修改
parent
828e5f1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
19 deletions
+68
-19
CommonUtils.java
...rvice/src/main/java/net/wanji/opt/common/CommonUtils.java
+26
-3
AnalysisGreenWavePeakDetailServiceImpl.java
...2/report/impl/AnalysisGreenWavePeakDetailServiceImpl.java
+42
-16
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/common/CommonUtils.java
View file @
9a6547ca
...
...
@@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSONArray;
import
net.wanji.opt.constant.DirEnum
;
import
org.apache.commons.lang3.StringUtils
;
import
java.time.LocalTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
/**
* @author duanruiming
* @date 2025/04/02 15:44
...
...
@@ -15,17 +19,18 @@ public class CommonUtils {
**/
public
static
final
String
SEPARATOR_UNDER_LINE
=
"_"
;
public
static
String
getStrJoin
(
String
...
str
)
{
public
static
String
getStrJoin
(
String
...
str
)
{
String
join
=
String
.
join
(
SEPARATOR_UNDER_LINE
,
str
);
return
join
;
}
/**
* 事件发生方向转换为描述
*
* @param dir
* @return
*/
public
static
String
getEventHappenDirName
(
String
dir
)
{
public
static
String
getEventHappenDirName
(
String
dir
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
if
(
StringUtils
.
isNotEmpty
(
dir
))
{
JSONArray
dirArr
=
JSONArray
.
parseArray
(
dir
);
...
...
@@ -35,10 +40,28 @@ public class CommonUtils {
stringBuilder
.
append
(
dirName
);
}
}
if
(
stringBuilder
.
length
()
>
1
)
{
if
(
stringBuilder
.
length
()
>
1
)
{
return
stringBuilder
.
substring
(
1
);
}
return
null
;
}
/**
* 获取两个时间之间相差多少分钟
* @param startTime
* @param endTime
* @param format
* @return
*/
public
static
int
getTimeBetweenMinutes
(
String
startTime
,
String
endTime
,
String
format
)
{
// 定义时间格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
format
);
// 解析时间字符串为LocalTime对象
LocalTime
time1
=
LocalTime
.
parse
(
startTime
,
formatter
);
LocalTime
time2
=
LocalTime
.
parse
(
endTime
,
formatter
);
// 计算时间差(以分钟为单位)
int
minutes
=
(
int
)
ChronoUnit
.
MINUTES
.
between
(
time1
,
time2
);
return
minutes
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/servicev2/report/impl/AnalysisGreenWavePeakDetailServiceImpl.java
View file @
9a6547ca
...
...
@@ -10,6 +10,7 @@ import net.wanji.common.utils.tool.DateUtil;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.opt.common.ArithOfBigDecmial
;
import
net.wanji.opt.common.CommonUtils
;
import
net.wanji.opt.common.enums.PeakNameEnum
;
import
net.wanji.opt.constant.PeakEnum
;
import
net.wanji.opt.constant.WeekDayEnum
;
...
...
@@ -29,6 +30,9 @@ import org.springframework.stereotype.Component;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
...
...
@@ -121,7 +125,7 @@ public class AnalysisGreenWavePeakDetailServiceImpl extends BaseDubboInterfaceIm
if
(
vo1
.
getCongestStartTime
()
!=
null
&&
vo2
.
getCongestEndTime
()
!=
null
)
{
weekData
.
setThisWeekCongestSpan
(
DateUtil
.
formatDate
(
vo1
.
getCongestStartTime
(),
"HH:mm"
)
+
"~"
+
DateUtil
.
formatDate
(
vo2
.
getCongestEndTime
(),
"HH:mm"
));
}
if
(
Objects
.
nonNull
(
lastWeekDataList
)){
if
(
Objects
.
nonNull
(
lastWeekDataList
))
{
//上周高峰指标数据
Optional
<
AnalysisGreenWavePeakDetail
>
optional
=
lastWeekDataList
.
stream
().
filter
(
o
->
Objects
.
equals
(
o
.
getWeekDay
(),
detail
.
getWeekDay
())
&&
Objects
.
equals
(
o
.
getPeakType
(),
detail
.
getPeakType
())).
findFirst
();
if
(
optional
.
isPresent
())
{
...
...
@@ -209,48 +213,62 @@ public class AnalysisGreenWavePeakDetailServiceImpl extends BaseDubboInterfaceIm
Double
lastAvgCongestIndex
=
0
D
;
//====================================================================================================================================================//
if
(
Objects
.
nonNull
(
earliestStartTimePo
)
&&
Objects
.
nonNull
(
lastWeekEarliestStartTimePo
))
{
minutesStart
=
Minutes
.
minutesBetween
(
new
DateTime
(
earliestStartTimePo
.
getPeakStartTime
().
getTime
()),
new
DateTime
(
lastWeekEarliestStartTimePo
.
getPeakStartTime
().
getTime
())).
getMinutes
();
minutesEnd
=
Minutes
.
minutesBetween
(
new
DateTime
(
earliestStartTimePo
.
getPeakEndTime
().
getTime
()),
new
DateTime
(
lastWeekEarliestStartTimePo
.
getPeakEndTime
().
getTime
())).
getMinutes
();
String
thisHM
=
DateUtil
.
formatDate
(
earliestStartTimePo
.
getPeakStartTime
(),
"HH:mm"
);
String
lastHM
=
DateUtil
.
formatDate
(
lastWeekEarliestStartTimePo
.
getPeakStartTime
(),
"HH:mm"
);
// 计算时间差(以分钟为单位)
minutesStart
=
CommonUtils
.
getTimeBetweenMinutes
(
thisHM
,
lastHM
,
"HH:mm"
);
thisHM
=
DateUtil
.
formatDate
(
earliestStartTimePo
.
getPeakEndTime
(),
"HH:mm"
);
lastHM
=
DateUtil
.
formatDate
(
lastWeekEarliestStartTimePo
.
getPeakEndTime
(),
"HH:mm"
);
// 计算时间差(以分钟为单位)
minutesEnd
=
CommonUtils
.
getTimeBetweenMinutes
(
thisHM
,
lastHM
,
"HH:mm"
);
}
//====================================================================================================================================================//
//早高峰集中时段
if
(
Objects
.
nonNull
(
earliestStartTimePo
)
&&
Objects
.
nonNull
(
lastEndTimePo
))
{
amPeakScope
=
DateUtil
.
formatDate
(
earliestStartTimePo
.
getPeakStartTime
(),
"HH:mm"
)
+
"~"
+
DateUtil
.
formatDate
(
lastEndTimePo
.
getPeakEndTime
(),
"HH:mm"
);
//持续时长
amDuration1
=
Minutes
.
minutesBetween
(
new
DateTime
(
earliestStartTimePo
.
getPeakStartTime
().
getTime
()),
new
DateTime
(
lastEndTimePo
.
getPeakEndTime
().
getTime
())).
getMinutes
();
String
amPeakStart
=
DateUtil
.
formatDate
(
earliestStartTimePo
.
getPeakStartTime
(),
"HH:mm"
);
String
amPeakEnd
=
DateUtil
.
formatDate
(
lastEndTimePo
.
getPeakEndTime
(),
"HH:mm"
);
amPeakScope
=
amPeakStart
+
"~"
+
amPeakEnd
;
// 计算时间差(以分钟为单位)
amDuration1
=
CommonUtils
.
getTimeBetweenMinutes
(
amPeakStart
,
amPeakEnd
,
"HH:mm"
);
}
//====================================================================================================================================================//
//开始时间比上周
String
amPeakStartSituation
=
""
;
if
(
minutesStart
>
0
)
{
amPeakStartSituation
=
"提前"
+
minutesStart
+
"分钟"
;
amPeakStartSituation
=
"提前"
+
Math
.
abs
(
minutesStart
)
+
"分钟"
;
}
else
{
amPeakStartSituation
=
"延后"
+
minutesStart
+
"分钟"
;
amPeakStartSituation
=
"延后"
+
Math
.
abs
(
minutesStart
)
+
"分钟"
;
}
//====================================================================================================================================================//
//结束时间比上周
String
amPeakEndSituation
=
""
;
if
(
minutesEnd
>
0
)
{
amPeakEndSituation
=
"提前"
+
minutesEnd
+
"分钟"
;
amPeakEndSituation
=
"提前"
+
Math
.
abs
(
minutesEnd
)
+
"分钟"
;
}
else
{
amPeakEndSituation
=
"延后"
+
minutesEnd
+
"分钟"
;
amPeakEndSituation
=
"延后"
+
Math
.
abs
(
minutesEnd
)
+
"分钟"
;
}
//====================================================================================================================================================//
//持续时长
if
(
Objects
.
nonNull
(
lastWeekEarliestStartTimePo
)
&&
Objects
.
nonNull
(
lastWeekLastEndTimePo
))
{
amDuration2
=
Minutes
.
minutesBetween
(
new
DateTime
(
lastWeekEarliestStartTimePo
.
getPeakStartTime
().
getTime
()),
new
DateTime
(
lastWeekLastEndTimePo
.
getPeakEndTime
().
getTime
())).
getMinutes
();
String
amPeakStart
=
DateUtil
.
formatDate
(
lastWeekEarliestStartTimePo
.
getPeakStartTime
(),
"HH:mm"
);
String
amPeakEnd
=
DateUtil
.
formatDate
(
lastWeekLastEndTimePo
.
getPeakEndTime
(),
"HH:mm"
);
amDuration2
=
CommonUtils
.
getTimeBetweenMinutes
(
amPeakStart
,
amPeakEnd
,
"HH:mm"
);
}
//本周高峰持续时长
String
amPeakDuration
=
amDuration1
+
"分钟"
;
String
amDurationSameRatioSituation
=
""
;
if
(
amDuration1
>
amDuration2
)
{
amDurationSameRatioSituation
=
"增加"
+
(
amDuration1
-
amDuration2
)
+
"分钟"
;
amDurationSameRatioSituation
=
"增加"
+
Math
.
abs
((
amDuration1
-
amDuration2
)
)
+
"分钟"
;
}
else
{
amDurationSameRatioSituation
=
"减少"
+
(
amDuration2
-
amDuration1
)
+
"分钟"
;
amDurationSameRatioSituation
=
"减少"
+
Math
.
abs
((
amDuration2
-
amDuration1
)
)
+
"分钟"
;
}
//====================================================================================================================================================//
thisMaxTravelTime
=
thisWeekList
.
stream
().
map
(
AnalysisGreenWavePeakDetail:
:
getTravelTime
).
max
(
Comparator
.
comparing
(
Integer:
:
intValue
)).
orElse
(
0
);
thisMaxTravelTime
=
(
int
)
ArithOfBigDecmial
.
div
(
thisMaxTravelTime
,
60
);
//转为分钟
lastMaxTravelTime
=
lastWeekDataList
.
stream
().
map
(
AnalysisGreenWavePeakDetail:
:
getTravelTime
).
max
(
Comparator
.
comparing
(
Integer:
:
intValue
)).
orElse
(
0
);
lastMaxTravelTime
=
(
int
)
ArithOfBigDecmial
.
div
(
lastMaxTravelTime
,
60
);
//转为分钟
//最大行程时间状况
String
maxTravelTimeSituation
=
""
;
if
(
thisMaxTravelTime
>
lastMaxTravelTime
)
{
...
...
@@ -266,9 +284,9 @@ public class AnalysisGreenWavePeakDetailServiceImpl extends BaseDubboInterfaceIm
//平均拥堵指数状况
String
amAvgCongestIndex
=
""
;
if
(
thisAvgCongestIndex
>
lastAvgCongestIndex
)
{
amAvgCongestIndex
=
"增加"
+
(
Math
.
abs
(
thisAvgCongestIndex
-
lastAvgCongestIndex
)
)
+
""
;
amAvgCongestIndex
=
"增加"
+
ArithOfBigDecmial
.
round
(
Math
.
abs
(
thisAvgCongestIndex
-
lastAvgCongestIndex
),
2
)
+
""
;
}
else
{
amAvgCongestIndex
=
"减少"
+
(
Math
.
abs
(
thisAvgCongestIndex
-
lastAvgCongestIndex
))
+
""
;
amAvgCongestIndex
=
"减少"
+
ArithOfBigDecmial
.
round
(
Math
.
abs
(
thisAvgCongestIndex
-
lastAvgCongestIndex
),
2
)
+
""
;
}
//====================================================================================================================================================//
if
(
Objects
.
equals
(
peakType
,
1
))
{
...
...
@@ -304,6 +322,14 @@ public class AnalysisGreenWavePeakDetailServiceImpl extends BaseDubboInterfaceIm
return
vo
;
}
public
static
void
main
(
String
[]
args
)
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"HH:mm"
);
LocalTime
time1
=
LocalTime
.
parse
(
"0800"
,
formatter
);
LocalTime
time2
=
LocalTime
.
parse
(
"0745"
,
formatter
);
// 计算时间差(以分钟为单位)
int
minutesStart
=
(
int
)
ChronoUnit
.
MINUTES
.
between
(
time1
,
time2
);
System
.
out
.
println
(
minutesStart
);
}
/**
* 获取峰值时间边界
...
...
@@ -315,7 +341,7 @@ public class AnalysisGreenWavePeakDetailServiceImpl extends BaseDubboInterfaceIm
*/
private
AnalysisGreenWavePeakDetail
getPeakTimeBoundary
(
List
<
AnalysisGreenWavePeakDetail
>
list
,
Integer
type
,
Integer
peakType
)
{
if
(
Objects
.
isNull
(
list
))
{
return
null
;
return
null
;
}
AnalysisGreenWavePeakDetail
ret
=
null
;
//修改为取交通指数最大的一条记录
...
...
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