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
11b321ea
Commit
11b321ea
authored
Apr 28, 2025
by
zhoushiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路口缓行事件计算
parent
f67f4c22
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
43 deletions
+121
-43
EventInfoMapper.java
.../net/wanji/opt/dao/mapper/evaluation/EventInfoMapper.java
+5
-0
EventInfoService.java
.../net/wanji/opt/servicev2/evaluation/EventInfoService.java
+6
-0
EventInfoServiceImpl.java
...i/opt/servicev2/evaluation/impl/EventInfoServiceImpl.java
+17
-6
AnalysisGreenCongestionPeriodWeekTask.java
...wanji/opt/task/AnalysisGreenCongestionPeriodWeekTask.java
+43
-4
AnalysisProblemDayTaskTest.java
...ata-compute/src/test/java/AnalysisProblemDayTaskTest.java
+50
-33
No files found.
signal-optimize-data-compute/src/main/java/net/wanji/opt/dao/mapper/evaluation/EventInfoMapper.java
View file @
11b321ea
...
...
@@ -18,5 +18,10 @@ import net.wanji.common.framework.mapper.BaseInterfaceMapper;
public
interface
EventInfoMapper
extends
BaseInterfaceMapper
<
EventInfo
>
{
List
<
Map
<
String
,
Object
>>
getListByStartAndEnd
(
Map
<
String
,
Object
>
map
);
/**
* 路口缓行事件计算
*/
void
insertCrossSlowRunEventData
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"endTime"
)
String
endTime
);
}
signal-optimize-data-compute/src/main/java/net/wanji/opt/servicev2/evaluation/EventInfoService.java
View file @
11b321ea
...
...
@@ -19,4 +19,10 @@ public interface EventInfoService extends BaseDubboInterface<EventInfo> {
List
<
Map
<
String
,
Object
>>
getListByStartAndEnd
(
Map
<
String
,
Object
>
map
);
/**
* 路口缓行事件计算
* @param startTime
* @param endTime
*/
void
insertCrossSlowRunEventData
(
String
startTime
,
String
endTime
);
}
signal-optimize-data-compute/src/main/java/net/wanji/opt/servicev2/evaluation/impl/EventInfoServiceImpl.java
View file @
11b321ea
...
...
@@ -41,16 +41,27 @@ public class EventInfoServiceImpl extends BaseDubboInterfaceImpl<EventInfo> impl
return
this
.
eventInfoMapper
;
}
public
List
<
Map
<
String
,
Object
>>
getListByStartAndEnd
(
Map
<
String
,
Object
>
map
)
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
eventInfoMapper
.
getListByStartAndEnd
(
map
);
for
(
Map
<
String
,
Object
>
data
:
list
)
{
String
dir
=
Tools
.
getMapValue
(
"dir"
,
data
);
if
(
Objects
.
nonNull
(
dir
)
&&
dir
.
length
()
>
2
)
{
public
List
<
Map
<
String
,
Object
>>
getListByStartAndEnd
(
Map
<
String
,
Object
>
map
)
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
eventInfoMapper
.
getListByStartAndEnd
(
map
);
for
(
Map
<
String
,
Object
>
data
:
list
)
{
String
dir
=
Tools
.
getMapValue
(
"dir"
,
data
);
if
(
Objects
.
nonNull
(
dir
)
&&
dir
.
length
()
>
2
)
{
String
dirName
=
CommonUtils
.
getEventHappenDirName
(
dir
);
data
.
put
(
"dirName"
,
dirName
);
data
.
put
(
"dirName"
,
dirName
);
}
}
return
list
;
}
@Override
public
void
insertCrossSlowRunEventData
(
String
startTime
,
String
endTime
)
{
long
st
=
System
.
currentTimeMillis
();
eventInfoMapper
.
insertCrossSlowRunEventData
(
startTime
,
endTime
);
long
et
=
System
.
currentTimeMillis
();
log
.
info
(
"路口缓行事件计算耗时:{}ms,时间:{} {}"
,
et
-
st
,
startTime
,
endTime
);
}
}
signal-optimize-data-compute/src/main/java/net/wanji/opt/task/AnalysisGreenCongestionPeriodWeekTask.java
View file @
11b321ea
package
net
.
wanji
.
opt
.
task
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.opt.servicev2.evaluation.EventInfoService
;
import
net.wanji.opt.servicev2.judgeanalysis.AnalysisGreenCongestionPeriodService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Configurable
;
...
...
@@ -9,6 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.text.ParseException
;
@Component
...
...
@@ -20,17 +25,51 @@ public class AnalysisGreenCongestionPeriodWeekTask {
@Autowired
private
AnalysisGreenCongestionPeriodService
analysisGreenCongestionPeriodService
;
@Resource
EventInfoService
eventInfoService
;
@Scheduled
(
cron
=
"0 30 2 ? * 1"
)
public
void
task
()
throws
ParseException
{
analysisGreenCongestionPeriodService
.
selectCountByCongestionPeriod
();
analysisGreenCongestionPeriodService
.
selectCountByLandData
();
try
{
analysisGreenCongestionPeriodService
.
selectCountByCongestionPeriod
();
analysisGreenCongestionPeriodService
.
selectCountByLandData
();
//analysisGreenCongestionPeriodService.selectCountByCrossData();
//analysisGreenCongestionPeriodService.selectCountByCrossData();
}
catch
(
Exception
e
){
log
.
error
(
""
,
e
);
}
}
@Scheduled
(
cron
=
"0 0 2 ? * ? "
)
public
void
taskDay
()
throws
ParseException
{
analysisGreenCongestionPeriodService
.
selectCountByCrossDataOneDay
();
try
{
analysisGreenCongestionPeriodService
.
selectCountByCrossDataOneDay
();
}
catch
(
Exception
e
){
log
.
error
(
""
,
e
);
}
}
@Scheduled
(
cron
=
"0 0 2 ? * ? "
)
public
void
insertCrossSlowRunEventData
()
throws
ParseException
{
try
{
DateTime
endTDateTime
=
DateUtil
.
date
();
//开始时间
DateTime
startTDateTime
=
DateUtil
.
offsetDay
(
endTDateTime
,
-
1
);
startTDateTime
=
DateUtil
.
beginOfDay
(
startTDateTime
);
String
sdt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:00:00"
);
//窗口截止时间
endTDateTime
=
DateUtil
.
parseDateTime
(
sdt
).
offset
(
DateField
.
HOUR
,
24
).
offset
(
DateField
.
SECOND
,-
1
);
String
edt
=
endTDateTime
.
toString
(
"yyyy-MM-dd HH:mm:ss"
);
eventInfoService
.
insertCrossSlowRunEventData
(
sdt
,
edt
);
}
catch
(
Exception
e
){
log
.
error
(
""
,
e
);
}
}
}
signal-optimize-data-compute/src/test/java/AnalysisProblemDayTaskTest.java
View file @
11b321ea
...
...
@@ -2,11 +2,13 @@
*
*/
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.opt.SignalOptimizeApplication
;
import
net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDayMapper
;
import
net.wanji.opt.servicev2.evaluation.EventInfoService
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -15,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.annotation.Resource
;
import
java.text.ParseException
;
import
java.util.Date
;
/**
...
...
@@ -29,44 +33,57 @@ public class AnalysisProblemDayTaskTest {
@Autowired
private
AnalysisProblemCrossDayMapper
analysisProblemCrossDayMapper
;
@Resource
EventInfoService
eventInfoService
;
@Test
public
void
testProducerTrack
()
{
DateTime
endTDateTime
=
DateUtil
.
date
();
//开始时间
DateTime
startTDateTime
=
DateUtil
.
offsetHour
(
endTDateTime
,
-
1
);
String
sdt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:00:00"
);
//窗口截止时间
startTDateTime
=
DateUtil
.
offsetSecond
(
startTDateTime
,
59
);
String
edt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:mm:ss"
);
System
.
out
.
println
();
// long st = System.currentTimeMillis();
// DateTime startTDateTime = DateUtil.beginOfDay(new Date());
// DateTime endTDateTime = DateUtil.date(); //DateUtil.offsetHour(startTDateTime,1);
//
// while (startTDateTime.isBefore(endTDateTime)) {
//
// String sdt = startTDateTime.toString("yyyy-MM-dd HH:00:00");
//
// startTDateTime = DateUtil.offsetHour(startTDateTime, 1);
// startTDateTime = DateUtil.offsetSecond(startTDateTime,-1);
//
// String edt = startTDateTime.toString("yyyy-MM-dd HH:mm:ss");
//
// analysisProblemCrossDayMapper.insertGreenCrossHourData(sdt, edt);
//
// startTDateTime = DateUtil.offsetSecond(startTDateTime,1);
// log.info("小时粒度数据入库,小时开始时间:{},小时截止时间:{},截止时间:{}",sdt,edt,endTDateTime.toString("yyyy-MM-dd HH:mm:ss"));
//
// }
//
// long et = System.currentTimeMillis();
// System.out.println((et - st) + "ms");
long
st
=
System
.
currentTimeMillis
();
DateTime
startTDateTime
=
DateUtil
.
beginOfDay
(
new
Date
());
DateTime
endTDateTime
=
DateUtil
.
date
();
//DateUtil.offsetHour(startTDateTime,1);
while
(
startTDateTime
.
isBefore
(
endTDateTime
))
{
String
sdt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:00:00"
);
startTDateTime
=
DateUtil
.
offsetHour
(
startTDateTime
,
1
);
startTDateTime
=
DateUtil
.
offsetSecond
(
startTDateTime
,
-
1
);
String
edt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:mm:ss"
);
analysisProblemCrossDayMapper
.
insertGreenCrossHourData
(
sdt
,
edt
);
startTDateTime
=
DateUtil
.
offsetSecond
(
startTDateTime
,
1
);
log
.
info
(
"小时粒度数据入库,小时开始时间:{},小时截止时间:{},截止时间:{}"
,
sdt
,
edt
,
endTDateTime
.
toString
(
"yyyy-MM-dd HH:mm:ss"
));
}
long
et
=
System
.
currentTimeMillis
();
System
.
out
.
println
((
et
-
st
)
+
"ms"
);
}
@Test
public
void
insertCrossSlowRunEventData
()
throws
ParseException
{
try
{
for
(
int
i
=
28
;
i
>
0
;
i
--)
{
DateTime
endTDateTime
=
DateUtil
.
date
();
//开始时间
DateTime
startTDateTime
=
DateUtil
.
offsetDay
(
endTDateTime
,
-
i
);
startTDateTime
=
DateUtil
.
beginOfDay
(
startTDateTime
);
String
sdt
=
startTDateTime
.
toString
(
"yyyy-MM-dd HH:00:00"
);
//窗口截止时间
endTDateTime
=
DateUtil
.
parseDateTime
(
sdt
).
offset
(
DateField
.
HOUR
,
24
).
offset
(
DateField
.
SECOND
,
-
1
);
String
edt
=
endTDateTime
.
toString
(
"yyyy-MM-dd HH:mm:ss"
);
eventInfoService
.
insertCrossSlowRunEventData
(
sdt
,
edt
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
}
}
...
...
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