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
078a72df
Commit
078a72df
authored
Jan 13, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略优化历史记录优化参数查询
parent
b7f9f4be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
50 deletions
+79
-50
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+13
-11
StrategyControlService.java
...t/wanji/opt/synthesis/service/StrategyControlService.java
+1
-1
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+44
-25
Constants.java
...n/src/main/java/net/wanji/common/framework/Constants.java
+2
-0
DateUtil.java
...n/src/main/java/net/wanji/common/utils/tool/DateUtil.java
+19
-13
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
078a72df
package
net
.
wanji
.
opt
.
synthesis
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponses
;
import
io.swagger.annotations.*
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.opt.entity.GreenwaveHist
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDataEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyFactoryEntity
;
...
...
@@ -53,15 +51,19 @@ public class StrategyControlController {
return
strategyControlService
.
strategyInfoPageList
(
entity
);
}
@ApiOperation
(
value
=
"策略控制查询列表"
,
notes
=
"策略控制查询列表"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@GetMapping
(
value
=
"/crossStrategyHistList"
)
@GetMapping
(
"/crossStrategyHistList"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"策略执行记录历史->路口/干线,时间粒度, 策略成功失败类型"
,
notes
=
""
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"strategyType"
,
value
=
"策略类型 0-路口 1-干线 空-查所有"
,
required
=
false
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"groupType"
,
value
=
"时间粒度类型 0-1小时 1-1天"
,
required
=
false
,
dataType
=
"Integer"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
name
=
"resultType"
,
value
=
"时间粒度类型 0-失败 1-成功 空-查所有"
,
required
=
false
,
dataType
=
"Integer"
),
})
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
StrategyControlDataEntity
.
class
),
@ApiResponse
(
code
=
200
,
message
=
"成功"
,
response
=
GreenwaveHist
.
class
,
responseHeaders
=
{
@ResponseHeader
(
name
=
"Content-Type"
,
description
=
"application/json"
)})
})
public
JsonViewObject
crossStrategyHistList
()
throws
Exception
{
return
strategyControlService
.
crossStrategyHistList
();
public
JsonViewObject
crossStrategyHistList
(
Integer
strategyType
,
Integer
groupType
,
Integer
resultType
)
throws
Exception
{
return
strategyControlService
.
crossStrategyHistList
(
strategyType
,
groupType
,
resultType
);
}
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/StrategyControlService.java
View file @
078a72df
...
...
@@ -16,7 +16,7 @@ public interface StrategyControlService {
JsonViewObject
strategyInfoPageList
(
StrategyControlDataEntity
entity
)
throws
Exception
;
JsonViewObject
crossStrategyInfoList
(
Integer
type
)
throws
Exception
;
JsonViewObject
strategyOptTimes
()
throws
Exception
;
JsonViewObject
crossStrategyHistList
()
throws
Exception
;
JsonViewObject
crossStrategyHistList
(
Integer
strategyType
,
Integer
groupType
,
Integer
resultType
)
throws
Exception
;
JsonViewObject
crossOptInfoList
(
Integer
type
)
throws
Exception
;
JsonViewObject
strategyPlanDetail
(
String
crossId
)
throws
Exception
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
078a72df
package
net
.
wanji
.
opt
.
synthesis
.
service
.
impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.excel.util.DateUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
...
@@ -12,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
net.wanji.common.enums.DateStyle
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.utils.tool.DateUtil
;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
...
...
@@ -34,7 +32,6 @@ import net.wanji.opt.synthesis.pojo.vo.StrategyControlVO;
import
net.wanji.opt.synthesis.pojo.vo.StrategyOptTimesVO
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
net.wanji.opt.vo.AIOptResultVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -138,8 +135,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
detailData
.
setBiz_id
(
dataVO
.
getBizId
());
detailData
.
setBiz_type
(
dataVO
.
getBizType
());
detailData
.
setStrategy
(
dataVO
.
getStrategy
());
detailData
.
setSchedule_start
(
DateUtil
.
format
(
dataVO
.
getScheduleStart
(),
DateStyle
.
YYYY_MM_DD_HH_MM_SS
.
getValue
()
));
detailData
.
setSchedule_end
(
DateUtil
.
format
(
dataVO
.
getScheduleEnd
(),
DateStyle
.
YYYY_MM_DD_HH_MM_SS
.
getValue
()
));
detailData
.
setSchedule_start
(
DateUtil
.
format
(
dataVO
.
getScheduleStart
(),
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_SECOND
));
detailData
.
setSchedule_end
(
DateUtil
.
format
(
dataVO
.
getScheduleEnd
(),
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_SECOND
));
List
<
StrategyControlDataVO
.
TimeTable
>
timeTableList
=
dataVO
.
getTime
();
List
<
StrategyControlDataReq
.
Time_table
>
timeTables
=
new
ArrayList
<>(
timeTableList
.
size
());
timeTableList
.
forEach
(
item
->
{
...
...
@@ -185,16 +182,26 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
@Override
public
JsonViewObject
crossStrategyHistList
()
throws
Exception
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
public
JsonViewObject
crossStrategyHistList
(
Integer
strategyType
,
Integer
groupType
,
Integer
resultType
)
throws
Exception
{
List
<
StrategyControlHistVO
>
results
=
new
ArrayList
<>();
LocalDate
currentDate
=
LocalDate
.
now
();
LocalDateTime
midnight
=
currentDate
.
atStartOfDay
();
try
{
// 查询当前绿波历史记录
setGreenOptHist
(
results
,
midnight
,
format
);
setCrossOptHist
(
results
,
midnight
);
}
catch
(
ParseException
e
)
{
if
(
Objects
.
isNull
(
groupType
))
{
groupType
=
1
;
}
LocalDateTime
localDateTime
=
Objects
.
equals
(
0
,
groupType
)
?
DateUtil
.
getPlusHour
(-
1
)
:
DateUtil
.
getMidNight
();
// 查询干线和路口
if
(
Objects
.
isNull
(
strategyType
))
{
setGreenOptHist
(
results
,
localDateTime
,
resultType
);
setCrossOptHist
(
results
,
localDateTime
,
resultType
);
}
// 路口
if
(
Objects
.
equals
(
0
,
strategyType
))
{
setCrossOptHist
(
results
,
localDateTime
,
resultType
);
}
// 绿波历史记录
if
(
Objects
.
equals
(
1
,
strategyType
))
{
setGreenOptHist
(
results
,
localDateTime
,
resultType
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"优化策略查询失败:"
,
e
);
JsonViewObject
.
newInstance
().
fail
(
"优化策略查询失败"
);
}
...
...
@@ -202,9 +209,15 @@ public class StrategyControlServiceImpl implements StrategyControlService {
return
JsonViewObject
.
newInstance
().
success
(
sorted
);
}
private
void
setCrossOptHist
(
List
<
StrategyControlHistVO
>
results
,
LocalDateTime
midnight
)
{
private
void
setCrossOptHist
(
List
<
StrategyControlHistVO
>
results
,
LocalDateTime
midnight
,
Integer
resultType
)
{
LambdaQueryWrapper
<
StrategyCrossResultEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
ge
(
StrategyCrossResultEntity:
:
getIssueTime
,
midnight
);
if
(
Objects
.
nonNull
(
midnight
))
{
queryWrapper
.
ge
(
StrategyCrossResultEntity:
:
getIssueTime
,
midnight
);
}
if
(
Objects
.
nonNull
(
resultType
))
{
Integer
resCode
=
Objects
.
equals
(
1
,
resultType
)
?
200
:
500
;
queryWrapper
.
ge
(
StrategyCrossResultEntity:
:
getResponseCode
,
resCode
);
}
List
<
StrategyCrossResultEntity
>
resultEntities
=
strategyCrossResultMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
resultEntities
))
{
for
(
StrategyCrossResultEntity
resultEntity
:
resultEntities
)
{
...
...
@@ -217,7 +230,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
histVO
.
setStrategy
(
resultEntity
.
getCurrentAlgo
());
histVO
.
setStrategyName
(
StrategyCrossAlgoEnum
.
getDescByCode
(
resultEntity
.
getCurrentAlgo
()));
Date
issueTime
=
resultEntity
.
getIssueTime
();
String
format
=
DateUtil
s
.
format
(
issueTime
,
"yyyy-MM-dd HH:mm:ss"
);
String
format
=
DateUtil
.
format
(
issueTime
,
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_SECOND
);
histVO
.
setOptTime
(
format
);
if
(
resultEntity
.
getCurrentAlgo
()
!=
1
)
{
histVO
.
setResult
(
Objects
.
equals
(
200
,
resultEntity
.
getResponseCode
())
?
"成功"
:
"失败"
);
...
...
@@ -229,9 +242,15 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
private
void
setGreenOptHist
(
List
<
StrategyControlHistVO
>
results
,
LocalDateTime
midnight
,
SimpleDateFormat
format
)
throws
ParseException
{
private
void
setGreenOptHist
(
List
<
StrategyControlHistVO
>
results
,
LocalDateTime
midnight
,
Integer
resultType
)
throws
ParseException
{
LambdaQueryWrapper
<
StrategyGreenOptHistEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
midnight
);
if
(
Objects
.
nonNull
(
midnight
))
{
queryWrapper
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
midnight
);
}
if
(
Objects
.
nonNull
(
resultType
))
{
Integer
controlMethod
=
Objects
.
equals
(
1
,
resultType
)
?
1
:
0
;
queryWrapper
.
ge
(
StrategyGreenOptHistEntity:
:
getControlMethod
,
controlMethod
);
}
List
<
StrategyGreenOptHistEntity
>
entities
=
strategyGreenOptHistMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
entities
))
{
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
GreenWaveInfoCache
.
greenWaveMap
;
...
...
@@ -242,7 +261,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
continue
;
}
String
controlTime
=
entity
.
getControlTime
();
Date
parse
=
format
.
parse
(
controlTime
);
Date
parse
=
DateUtil
.
parse
(
controlTime
,
"yyyy-MM-dd HH:mm:ss"
);
GreenwaveInfoPO
greenwaveInfoPO
=
greenWaveMap
.
get
(
entity
.
getGreenId
());
if
(
Objects
.
nonNull
(
greenwaveInfoPO
))
{
histVO
.
setName
(
greenwaveInfoPO
.
getName
());
...
...
@@ -389,11 +408,11 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if
(
StringUtils
.
equals
(
"24:00"
,
entHour
))
{
entHour
=
"23:59"
;
}
String
format
=
DateUtil
.
format
(
current
,
"HH:mm"
);
Date
Time
currentTime
=
DateUtil
.
parse
(
format
,
"HH:mm"
);
Date
Time
startHourDate
=
DateUtil
.
parse
(
startHour
,
"HH:mm"
);
Date
Time
endHourDate
=
DateUtil
.
parse
(
entHour
,
"HH:mm"
);
if
(
currentTime
.
isAfter
(
startHourDate
)
&&
currentTime
.
isB
efore
(
endHourDate
))
{
String
format
=
DateUtil
.
format
(
current
,
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_MINUTE
);
Date
currentTime
=
DateUtil
.
parse
(
format
,
"HH:mm"
);
Date
startHourDate
=
DateUtil
.
parse
(
startHour
,
"HH:mm"
);
Date
endHourDate
=
DateUtil
.
parse
(
entHour
,
"HH:mm"
);
if
(
currentTime
.
after
(
startHourDate
)
&&
currentTime
.
b
efore
(
endHourDate
))
{
result
.
setTime
(
hour
);
result
.
setStatus
(
1
);
}
else
{
...
...
wj-common/src/main/java/net/wanji/common/framework/Constants.java
View file @
078a72df
...
...
@@ -631,6 +631,7 @@ public final class Constants {
private
static
final
String
DATE_FORMAT_SECOND
=
"yyyy-MM-dd HH:mm:ss"
;
private
static
final
String
DATE_FORMAT_MILLIS
=
"yyyy-MM-dd HH:mm:ss.SSS"
;
private
static
final
String
DATE_FORMAT_TIME
=
"HH:mm:ss"
;
private
static
final
String
DATE_FORMAT_HOUR_MINUTE
=
"HH:mm"
;
private
static
final
String
DATE_FORMAT_WEEKDAY
=
"EEEE"
;
public
enum
DATE_FORMAT
{
...
...
@@ -641,6 +642,7 @@ public final class Constants {
E_DATE_FORMAT_SECOND
(
DATE_FORMAT_SECOND
),
E_DATE_FORMAT_MILLIS
(
DATE_FORMAT_MILLIS
),
E_DATE_FORMAT_TIME
(
DATE_FORMAT_TIME
),
E_DATE_FORMAT_HOUR_MINUTE
(
DATE_FORMAT_HOUR_MINUTE
),
E_DATE_FORMAT_WEEKDAY
(
DATE_FORMAT_WEEKDAY
);
private
final
String
strFormat
;
...
...
wj-common/src/main/java/net/wanji/common/utils/tool/DateUtil.java
View file @
078a72df
...
...
@@ -6,10 +6,7 @@ import net.wanji.common.framework.Constants;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.ZoneOffset
;
import
java.time.*
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Random
;
...
...
@@ -41,15 +38,6 @@ public class DateUtil {
return
sdf
.
format
(
date
);
}
public
static
void
main
(
String
[]
args
)
throws
ParseException
{
// DateToString(new Date());
// System.out.println(longToDate(1566144240000L));
Random
r
=
new
Random
();
for
(
int
i
=
0
;
i
<
10
;
i
++){
System
.
out
.
println
(
getId
());
}
}
public
static
String
getRandom
(
int
i
)
{
Random
jjj
=
new
Random
();
...
...
@@ -561,4 +549,22 @@ public class DateUtil {
localDateTime
.
toEpochSecond
(
ZoneOffset
.
of
(
"+8"
));
return
localDateTime
;
}
/**
* 获取当前日期的yyyy-MM-dd 00:00:00
* @return
*/
public
static
LocalDateTime
getMidNight
()
{
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
LocalDateTime
midNight
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
return
midNight
;
}
public
static
LocalDateTime
getPlusHour
(
Integer
offset
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
localDateTime
=
now
.
plusHours
(
offset
);
return
localDateTime
;
}
}
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