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
728f850f
Commit
728f850f
authored
Jun 20, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 微观大数据平台-Excel导出优化
parent
bdf0aae0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
44 deletions
+83
-44
BaseCrossInfoCache.java
...src/main/java/net/wanji/opt/cache/BaseCrossInfoCache.java
+9
-0
TrendServiceImpl.java
...ain/java/net/wanji/opt/service/impl/TrendServiceImpl.java
+46
-25
TableQueryVO.java
...-service/src/main/java/net/wanji/opt/vo/TableQueryVO.java
+24
-15
TurnDataIndexExcelVO.java
.../src/main/java/net/wanji/opt/vo/TurnDataIndexExcelVO.java
+3
-3
CrossLaneDataHistMapper.xml
...bus/src/main/resources/mapper/CrossLaneDataHistMapper.xml
+1
-1
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/cache/BaseCrossInfoCache.java
View file @
728f850f
...
...
@@ -58,6 +58,15 @@ public class BaseCrossInfoCache implements CommandLineRunner {
return
isSignalCrossIdList
;
}
public
String
getCrossName
(
String
crossId
)
{
for
(
BaseCrossInfoPO
baseCrossInfoPO
:
crossInfoList
)
{
if
(
StringUtils
.
equals
(
crossId
,
baseCrossInfoPO
.
getId
()))
{
return
baseCrossInfoPO
.
getName
();
}
}
return
""
;
}
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
init
();
...
...
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/TrendServiceImpl.java
View file @
728f850f
...
...
@@ -22,6 +22,7 @@ import net.wanji.databus.po.*;
import
net.wanji.databus.vo.AbnormalCrossListVO
;
import
net.wanji.databus.vo.GreenwaveListVO
;
import
net.wanji.opt.bo.*
;
import
net.wanji.opt.cache.BaseCrossInfoCache
;
import
net.wanji.opt.common.ExcelExportUtils
;
import
net.wanji.opt.common.RedisUtils
;
import
net.wanji.opt.config.DirectionMappingsConfig
;
...
...
@@ -111,6 +112,7 @@ public class TrendServiceImpl implements TrendService {
private
final
RunningEvaluateServiceImpl
runningEvaluateService
;
private
final
AnalysisRidTurnIndicatorsMapper
ridTurnIndicatorsMapper
;
private
final
HoloEventMapper
holoEventMapper
;
private
final
BaseCrossInfoCache
crossInfoCache
;
// 用于计算路口状态,key为方向,value为状态
private
Map
<
Integer
,
Integer
>
preStatus
=
new
HashMap
<
Integer
,
Integer
>()
{{
...
...
@@ -141,7 +143,8 @@ public class TrendServiceImpl implements TrendService {
RidInfoMapper
ridInfoMapper
,
BaseCrossDirInfoMapper
baseCrossDirInfoMapper
,
CrossSchemeOptLogMapper
crossSchemeOptLogMapper
,
GreenwaveCrossMapper
greenwaveCrossMapper
,
CrossDirDataRealtimeMapper
crossDirDataRealtimeMapper
,
GreenwaveHistMapper
greenwaveHistMapper
,
GreenwaveRealtimeMapper
greenwaveRealtimeMapper
,
SceneStrategyIdeaMapper
strategyIdeaMapper
,
StrategyMapper
strategyMapper
,
BaseCrossSchedulesMapper
baseCrossSchedulesMapper
,
BaseCrossSchedulesPlanMapper
baseCrossSchedulesPlanMapper
,
BaseCrossSectionMapper
baseCrossSectionMapper
,
BaseCrossSchemeMapper
crossSchemeMapper
,
BaseCrossSchemeMapper
baseCrossSchemeMapper
,
BaseCrossPhaseMapper
baseCrossPhaseMapper
,
BaseCrossPhaseLightsMapper
crossPhaseLightsMapper
,
BaseCrossLaneLightsMapper
baseCrossLaneLightsMapper
,
CrossBaseLaneInfoMapper
crossBaseLaneInfoMapper
,
CrossTurnDataHistMapper
crossTurnDataHistMapper
,
@Qualifier
(
"greenwaveSceneMapper"
)
GreenwaveSceneMapper
greenwaveSceneMapper
,
@Qualifier
(
"sceneStrategyMapper"
)
SceneStrategyMapper
sceneStrategyMapper
,
@Qualifier
(
"sceneMapper"
)
SceneMapper
sceneMapper
,
@Qualifier
(
"baseCrossPlanMapper"
)
BaseCrossPlanMapper
baseCrossPlanMapper
,
MainlineEvaluateServiceImpl
mainlineEvaluateServiceImpl
,
CrossLaneDataHistMapper
crossLaneDataHistMapper
,
LaneSnapshotDataQueryService
laneSnapshotDataQueryService
,
DirectionMappingsConfig
directionMappingsConfig
,
CrossDataHistMapper
crossDataHistMapper
,
RunningEvaluateServiceImpl
runningEvaluateService
,
AnalysisRidTurnIndicatorsMapper
ridTurnIndicatorsMapper
,
HoloEventMapper
holoEventMapper
)
{
AnalysisRidTurnIndicatorsMapper
ridTurnIndicatorsMapper
,
HoloEventMapper
holoEventMapper
,
BaseCrossInfoCache
crossInfoCache
)
{
this
.
greenwaveInfoMapper
=
greenwaveInfoMapper
;
this
.
baseCrossInfoMapper
=
baseCrossInfoMapper
;
this
.
crossDataRealtimeMapper
=
crossDataRealtimeMapper
;
...
...
@@ -177,6 +180,7 @@ public class TrendServiceImpl implements TrendService {
this
.
runningEvaluateService
=
runningEvaluateService
;
this
.
ridTurnIndicatorsMapper
=
ridTurnIndicatorsMapper
;
this
.
holoEventMapper
=
holoEventMapper
;
this
.
crossInfoCache
=
crossInfoCache
;
}
@Override
...
...
@@ -1252,6 +1256,7 @@ public class TrendServiceImpl implements TrendService {
element
.
setTime
(
date
);
element
.
setDir
(
dto
.
getDir
());
element
.
setDirName
(
BaseEnum
.
SignalDirectionEnum
.
getNameByCode
(
dto
.
getDir
()));
String
laneId
=
dto
.
getLaneId
();
String
laneSort
=
laneId
.
substring
(
laneId
.
length
()
-
2
);
...
...
@@ -1362,7 +1367,6 @@ public class TrendServiceImpl implements TrendService {
if
(
po
.
getId
().
contains
(
crossId
.
concat
(
Constants
.
SystemParam
.
SEPARATOR_MINUS
)))
{
pedFlow
+=
po
.
getFlow
();
}
String
laneId
=
po
.
getId
();
Integer
batchTime
=
po
.
getBatchTime
();
// 将10位时间戳转换为毫秒
long
millis
=
batchTime
*
1000L
;
...
...
@@ -1371,6 +1375,7 @@ public class TrendServiceImpl implements TrendService {
vo
.
setTime
(
dateFromTimestamp
);
vo
.
setDir
(
po
.
getDir
());
vo
.
setDirName
(
BaseEnum
.
SignalDirectionEnum
.
getNameByCode
(
po
.
getDir
()));
vo
.
setFlow
(
po
.
getFlow
());
Double
speed
=
po
.
getSpeed
();
...
...
@@ -2051,14 +2056,15 @@ public class TrendServiceImpl implements TrendService {
List
<
CrossLaneDataHistPOExt
>
poExtList
=
crossLaneDataHistMapper
.
selectByCrossIdAndTimeSpan
(
crossId
,
start
,
end
);
List
<
TableQueryVO
.
CycleDataElement
>
dataList
=
buildCycleData
(
crossId
,
poExtList
);
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
dataList
,
"车道周期数据"
,
TableQueryVO
.
CycleDataElement
.
class
);
String
crossName
=
crossInfoCache
.
getCrossName
(
crossId
);
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
dataList
,
crossName
.
concat
(
"车道周期数据"
),
TableQueryVO
.
CycleDataElement
.
class
);
}
@Override
public
void
periodTurnExcel
(
LanePeriodTurnVO
lanePeriodTurnVO
,
HttpServletResponse
response
)
throws
Exception
{
String
startStr
=
null
;
String
endStr
=
null
;
List
<
TurnDataIndexExcelVO
>
result
=
n
ull
;
List
<
TurnDataIndexExcelVO
>
result
=
n
ew
ArrayList
<>()
;
try
{
String
crossId
=
lanePeriodTurnVO
.
getCrossId
();
Date
startDate
=
lanePeriodTurnVO
.
getStart
();
...
...
@@ -2119,19 +2125,28 @@ public class TrendServiceImpl implements TrendService {
turnDataIndexExcelVO
.
setDir
(
BaseEnum
.
SignalDirectionEnum
.
getNameByCode
(
dir
));
turnDataIndexExcelVO
.
setFlow
(
allFlow
);
turnDataIndexExcelVO
.
setLeftFlow
(
leftFlow
);
BigDecimal
leftAverage
=
leftSpeed
.
divide
(
new
BigDecimal
(
left
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
leftAverage
=
new
BigDecimal
(
0
);
if
(
left
>
0
)
{
leftAverage
=
leftSpeed
.
divide
(
new
BigDecimal
(
left
),
2
,
RoundingMode
.
HALF_UP
);
}
turnDataIndexExcelVO
.
setLeftSpeed
(
leftAverage
);
if
(
leftFlow
==
0
)
{
turnDataIndexExcelVO
.
setLeftSpeed
(
new
BigDecimal
(
0
));
}
turnDataIndexExcelVO
.
setStraightFlow
(
straightFlow
);
BigDecimal
straightAverage
=
straightSpeed
.
divide
(
new
BigDecimal
(
straight
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
straightAverage
=
new
BigDecimal
(
0
);
if
(
straight
>
0
)
{
straightAverage
=
straightSpeed
.
divide
(
new
BigDecimal
(
straight
),
2
,
RoundingMode
.
HALF_UP
);
}
turnDataIndexExcelVO
.
setStraightSpeed
(
straightAverage
);
if
(
straightFlow
==
0
)
{
turnDataIndexExcelVO
.
setStraightSpeed
(
new
BigDecimal
(
0
));
}
turnDataIndexExcelVO
.
setRightFlow
(
rightFlow
);
BigDecimal
rightAverage
=
rightSpeed
.
divide
(
new
BigDecimal
(
right
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
rightAverage
=
new
BigDecimal
(
0
);
if
(
right
>
0
)
{
rightAverage
=
rightSpeed
.
divide
(
new
BigDecimal
(
right
),
2
,
RoundingMode
.
HALF_UP
);
}
turnDataIndexExcelVO
.
setRightSpeed
(
rightAverage
);
if
(
rightFlow
==
0
)
{
turnDataIndexExcelVO
.
setRightSpeed
(
new
BigDecimal
(
0
));
...
...
@@ -2142,34 +2157,40 @@ public class TrendServiceImpl implements TrendService {
}
}
}
String
crossName
=
crossInfoCache
.
getCrossName
(
crossId
);
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
result
,
crossName
.
concat
(
"转向周期数据"
),
TurnDataIndexExcelVO
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"导出转向数据异常:"
,
e
);
throw
new
RuntimeException
(
e
);
}
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
result
,
"周期转向数据"
,
TurnDataIndexExcelVO
.
class
);
}
@Override
public
void
laneSnapshotExcel
(
LaneSnapshotIndexVO
laneSnapshotIndexVO
,
HttpServletResponse
response
)
throws
Exception
{
String
crossId
=
laneSnapshotIndexVO
.
getCrossId
();
Date
startDate
=
laneSnapshotIndexVO
.
getStart
();
Date
endDate
=
laneSnapshotIndexVO
.
getEnd
();
String
startStr
=
DateUtil
.
format
(
startDate
,
DateStyle
.
YYYY_MM_DD_HH_MM
.
getValue
());
String
endStr
=
DateUtil
.
format
(
endDate
,
DateStyle
.
MM_DD_HH_MM
.
getValue
());
try
{
String
crossId
=
laneSnapshotIndexVO
.
getCrossId
();
Date
startDate
=
laneSnapshotIndexVO
.
getStart
();
Date
endDate
=
laneSnapshotIndexVO
.
getEnd
();
String
startStr
=
DateUtil
.
format
(
startDate
,
DateStyle
.
YYYY_MM_DD_HH_MM
.
getValue
());
String
endStr
=
DateUtil
.
format
(
endDate
,
DateStyle
.
MM_DD_HH_MM
.
getValue
());
int
start
=
(
int
)
(
startDate
.
getTime
()
/
1000
);
int
end
=
(
int
)
(
endDate
.
getTime
()
/
1000
);
String
laneId
=
laneSnapshotIndexVO
.
getLaneId
();
// 查询秒级数据
List
<
CrossLaneSnapshotDataDTO
>
dtoList
=
laneSnapshotDataQueryService
.
queryByCrossIdAndTimeSpan
(
crossId
,
start
,
end
,
-
1
,
laneId
);
List
<
TableQueryVO
.
RealTimeDataElement
>
result
=
buildRealTimeList
(
dtoList
);
List
<
TableQueryVO
.
RealTimeDataElement
>
dataList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
dataList
=
result
.
stream
().
sorted
(
Comparator
.
comparing
(
TableQueryVO
.
RealTimeDataElement
::
getTime
).
reversed
()).
collect
(
Collectors
.
toList
());
int
start
=
(
int
)
(
startDate
.
getTime
()
/
1000
);
int
end
=
(
int
)
(
endDate
.
getTime
()
/
1000
);
String
laneId
=
laneSnapshotIndexVO
.
getLaneId
();
// 查询秒级数据
List
<
CrossLaneSnapshotDataDTO
>
dtoList
=
laneSnapshotDataQueryService
.
queryByCrossIdAndTimeSpan
(
crossId
,
start
,
end
,
-
1
,
laneId
);
List
<
TableQueryVO
.
RealTimeDataElement
>
result
=
buildRealTimeList
(
dtoList
);
List
<
TableQueryVO
.
RealTimeDataElement
>
dataList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
dataList
=
result
.
stream
().
sorted
(
Comparator
.
comparing
(
TableQueryVO
.
RealTimeDataElement
::
getTime
).
reversed
()).
collect
(
Collectors
.
toList
());
}
String
crossName
=
crossInfoCache
.
getCrossName
(
crossId
);
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
dataList
,
crossName
.
concat
(
"车道快照数据"
),
TableQueryVO
.
RealTimeDataElement
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"快照数据导出失败:"
,
e
);
throw
new
RuntimeException
(
e
);
}
ExcelExportUtils
.
exportExcel
(
response
,
startStr
,
endStr
,
dataList
,
"车道快照数据"
,
TableQueryVO
.
RealTimeDataElement
.
class
);
}
}
signal-optimize-service/src/main/java/net/wanji/opt/vo/TableQueryVO.java
View file @
728f850f
package
net
.
wanji
.
opt
.
vo
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -34,14 +35,17 @@ public class TableQueryVO {
private
Date
time
;
@ApiModelProperty
(
value
=
"方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北"
)
@Excel
Property
(
"方向"
)
@Excel
Ignore
private
Integer
dir
;
@ExcelProperty
(
"方向"
)
private
String
dirName
;
@ApiModelProperty
(
value
=
"车道,从左车道开始编号11、12、13..."
)
@ExcelProperty
(
"车道号"
)
private
String
laneSort
;
@ApiModelProperty
(
value
=
"车道编号"
)
@ExcelIgnore
private
String
laneId
;
@ApiModelProperty
(
value
=
"排队长度"
)
...
...
@@ -65,6 +69,7 @@ public class TableQueryVO {
private
int
carNums
;
@ApiModelProperty
(
value
=
"空间密度车辆负荷比"
)
@ExcelIgnore
private
double
vehicleNumsRatio
;
@ApiModelProperty
(
value
=
"空间密度(长度占比)"
)
...
...
@@ -79,8 +84,8 @@ public class TableQueryVO {
@ExcelProperty
(
"头车速度"
)
private
double
headSpeed
;
@ApiModelProperty
(
value
=
"
尾
车速度"
)
@ExcelProperty
(
"
尾
车速度"
)
@ApiModelProperty
(
value
=
"
末
车速度"
)
@ExcelProperty
(
"
末
车速度"
)
private
double
mailSpeed
;
@ApiModelProperty
(
value
=
"队首距离(米)"
)
...
...
@@ -105,10 +110,14 @@ public class TableQueryVO {
private
Date
time
;
@ApiModelProperty
(
value
=
"方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北"
)
@Excel
Property
(
"方向"
)
@Excel
Ignore
private
Integer
dir
;
@ExcelProperty
(
"方向"
)
private
String
dirName
;
@ApiModelProperty
(
value
=
"车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n"
)
@ExcelIgnore
private
Integer
turn
;
@ApiModelProperty
(
value
=
"车道,从左车道开始编号11、12、13..."
)
...
...
@@ -116,13 +125,9 @@ public class TableQueryVO {
private
String
laneSort
;
@ApiModelProperty
(
value
=
"流量"
)
@Excel
Property
(
"流量"
)
@Excel
Ignore
private
Integer
flow
;
@ApiModelProperty
(
value
=
"速度"
)
@ExcelProperty
(
"速度"
)
private
Integer
speed
;
@ApiModelProperty
(
value
=
"最大排队"
)
@ExcelProperty
(
"最大排队"
)
private
Integer
queueLength
;
...
...
@@ -144,31 +149,35 @@ public class TableQueryVO {
private
Double
vehheadDist
;
@ApiModelProperty
(
value
=
"时间占有率"
)
@ExcelProperty
(
"平均时间占有率"
)
private
Integer
timeOccupancy
;
@ApiModelProperty
(
value
=
"空间占有率"
)
// 空间占有率即车辆负荷比
@ExcelProperty
(
"空间占有率"
)
@ExcelProperty
(
"
平均
空间占有率"
)
private
Integer
vehicleNumsRatioMean
;
@ExcelProperty
(
"85位速度"
)
private
double
v85
;
@ApiModelProperty
(
value
=
"速度"
)
@ExcelProperty
(
"平均速度"
)
private
Integer
speed
;
@ExcelProperty
(
"大车流量"
)
private
Integer
trafficFlowA
;
@ExcelProperty
(
"中车流量"
)
private
Integer
trafficFlowB
;
@ExcelProperty
(
"小车流量"
)
private
Integer
trafficFlowC
;
@ExcelProperty
(
"85速度"
)
private
double
v85
;
@ApiModelProperty
(
value
=
"非机动车流量"
)
@ExcelProperty
(
"非机动车流量"
)
private
int
nonMotorFlow
;
@ApiModelProperty
(
value
=
"行人流量"
)
@ExcelProperty
(
"行人流量"
)
private
int
pedFlow
;
@ApiModelProperty
(
value
=
"总流量"
)
@ExcelProperty
(
"总流量"
)
private
int
allFlow
;
@ApiModelProperty
(
value
=
"车辆总和"
)
@ExcelProperty
(
"车辆总和"
)
private
int
allVehiceleFlow
;
@ApiModelProperty
(
value
=
"总流量"
)
@ExcelProperty
(
"总流量"
)
private
int
allFlow
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/vo/TurnDataIndexExcelVO.java
View file @
728f850f
...
...
@@ -51,12 +51,12 @@ public class TurnDataIndexExcelVO {
@ExcelProperty
(
"直行平均速度"
)
private
BigDecimal
straightSpeed
;
@ApiModelProperty
(
value
=
"右转
平均
流量"
)
@ExcelProperty
(
"右转
平均
流量"
)
@ApiModelProperty
(
value
=
"右转流量"
)
@ExcelProperty
(
"右转流量"
)
private
Integer
rightFlow
;
@ApiModelProperty
(
value
=
"右转速度"
)
@ExcelProperty
(
"右转速度"
)
@ExcelProperty
(
"右转
平均
速度"
)
private
BigDecimal
rightSpeed
;
}
wj-databus/src/main/resources/mapper/CrossLaneDataHistMapper.xml
View file @
728f850f
...
...
@@ -104,7 +104,7 @@
<select
id=
"selectByCrossIdAndTimeSpan"
resultType=
"net.wanji.databus.po.CrossLaneDataHistPOExt"
>
SELECT t1.id, t2.dir,t2.turn, t2.sort, t1.flow, t1.speed, t1.queue_length, t1.delay_time, t1.stop_times,
t1.vehhead_time, t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean, t1.start_time,
t1.vehhead_time,
t1.vehhead_dist,
t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean, t1.start_time,
t1.traffic_flow_A, t1.traffic_flow_B, t1.traffic_flow_C,t1.v_85, t1.non_motor_flow, t1.time_occupancy
FROM t_lane_data_hist t1 JOIN t_base_lane_info t2 ON t1.id = t2.id
where t1.cross_id = #{crossId}
...
...
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