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
7652f699
Commit
7652f699
authored
Nov 29, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略历史优化查询
parent
e69d4323
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
160 additions
and
25 deletions
+160
-25
GreenWaveInfoCache.java
...src/main/java/net/wanji/opt/cache/GreenWaveInfoCache.java
+42
-0
StrategyControlController.java
...i/opt/synthesis/controller/StrategyControlController.java
+1
-0
StrategyControlHistVO.java
...a/net/wanji/opt/synthesis/pojo/StrategyControlHistVO.java
+28
-0
StrategyHistReq.java
...net/wanji/opt/synthesis/pojo/request/StrategyHistReq.java
+20
-0
StrategyControlService.java
...t/wanji/opt/synthesis/service/StrategyControlService.java
+1
-0
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+67
-23
CrossRunSchemeCache.java
...java/net/wanji/utc/hisense/cache/CrossRunSchemeCache.java
+1
-2
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/cache/GreenWaveInfoCache.java
0 → 100644
View file @
7652f699
package
net
.
wanji
.
opt
.
cache
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author duanruiming
* @date 2024/11/29 11:19
*/
@Component
@Slf4j
public
class
GreenWaveInfoCache
implements
CommandLineRunner
{
public
static
final
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
new
HashMap
<>();
@Resource
private
GreenwaveInfoMapper
greenwaveInfoMapper
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
try
{
List
<
GreenwaveInfoPO
>
greenWaveInfoPOS
=
greenwaveInfoMapper
.
selectAll
();
if
(!
CollectionUtils
.
isEmpty
(
greenWaveInfoPOS
))
{
for
(
GreenwaveInfoPO
greenWaveInfoPO
:
greenWaveInfoPOS
)
{
greenWaveMap
.
put
(
greenWaveInfoPO
.
getId
(),
greenWaveInfoPO
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"绿波信息初始化失败:"
,
e
);
throw
new
RuntimeException
(
"绿波信息初始化失败!"
);
}
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/controller/StrategyControlController.java
View file @
7652f699
...
@@ -10,6 +10,7 @@ import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
...
@@ -10,6 +10,7 @@ import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.pojo.StrategyFactoryEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyFactoryEntity
;
import
net.wanji.opt.synthesis.pojo.request.StrategyHistReq
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/StrategyControlHistVO.java
0 → 100644
View file @
7652f699
package
net
.
wanji
.
opt
.
synthesis
.
pojo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author duanruiming
* @date 2024/11/29 11:03
*/
@Data
@ApiModel
(
value
=
"StrategyControlHistVO"
,
description
=
"策略控制操作实体"
)
public
class
StrategyControlHistVO
{
@ApiModelProperty
(
"路口编号干线编号"
)
private
String
id
;
@ApiModelProperty
(
"路口名称干线名称"
)
private
String
name
;
@ApiModelProperty
(
"策略号"
)
private
Integer
strategy
;
@ApiModelProperty
(
"策略名称"
)
private
String
strategyName
;
@ApiModelProperty
(
"优化时间"
)
private
String
optTime
;
@ApiModelProperty
(
"优化结果"
)
private
String
result
;
@ApiModelProperty
(
"经纬度"
)
private
String
wkt
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/request/StrategyHistReq.java
0 → 100644
View file @
7652f699
package
net
.
wanji
.
opt
.
synthesis
.
pojo
.
request
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author duanruiming
* @date 2024/11/29 11:10
*/
@Data
@ApiModel
(
value
=
"StrategyHistReq"
,
description
=
"策略控制历史请求实体"
)
public
class
StrategyHistReq
{
@ApiModelProperty
(
"路口编号/干线编号"
)
private
String
id
;
@ApiModelProperty
(
"当前日期,为空查询时间"
)
private
Date
currentDate
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/StrategyControlService.java
View file @
7652f699
...
@@ -5,6 +5,7 @@ import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
...
@@ -5,6 +5,7 @@ import net.wanji.opt.synthesis.pojo.StrategyControlDataEntity;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.pojo.StrategyControlVO
;
import
net.wanji.opt.synthesis.pojo.StrategyFactoryEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyFactoryEntity
;
import
net.wanji.opt.synthesis.pojo.request.StrategyHistReq
;
/**
/**
* @author duanruiming
* @author duanruiming
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
7652f699
...
@@ -11,16 +11,17 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,16 +11,17 @@ import lombok.extern.slf4j.Slf4j;
import
net.wanji.common.enums.DateStyle
;
import
net.wanji.common.enums.DateStyle
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.utils.licenseUtils.DateUtils
;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.databus.po.BaseCrossInfoPO
;
import
net.wanji.databus.po.BaseCrossInfoPO
;
import
net.wanji.opt.dao.mapper.StrategyControlInfoMapper
;
import
net.wanji.opt.cache.GreenWaveInfoCache
;
import
net.wanji.opt.dao.mapper.StrategyDailyPlanInfoMapper
;
import
net.wanji.opt.dao.mapper.*
;
import
net.wanji.opt.dao.mapper.StrategyFactoryMapper
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
import
net.wanji.opt.dao.mapper.StrategyPlanInfoMapper
;
import
net.wanji.opt.synthesis.pojo.*
;
import
net.wanji.opt.synthesis.pojo.*
;
import
net.wanji.opt.synthesis.pojo.request.StrategyHistReq
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -31,6 +32,9 @@ import org.springframework.util.CollectionUtils;
...
@@ -31,6 +32,9 @@ import org.springframework.util.CollectionUtils;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -56,6 +60,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -56,6 +60,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private
StrategyFactoryMapper
strategyFactoryMapper
;
private
StrategyFactoryMapper
strategyFactoryMapper
;
@Resource
@Resource
private
GreenwaveInfoMapper
greenwaveInfoMapper
;
private
GreenwaveInfoMapper
greenwaveInfoMapper
;
@Resource
private
StrategyGreenOptHistMapper
strategyGreenOptHistMapper
;
@Override
@Override
...
@@ -159,30 +165,68 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -159,30 +165,68 @@ public class StrategyControlServiceImpl implements StrategyControlService {
@Override
@Override
public
JsonViewObject
crossStrategyHistList
()
throws
Exception
{
public
JsonViewObject
crossStrategyHistList
()
throws
Exception
{
List
<
StrategyControlDataEntity
>
resulsts
=
new
ArrayList
<>();
List
<
StrategyControlHistVO
>
results
=
new
ArrayList
<>();
LambdaQueryWrapper
<
StrategyControlDataEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LocalDate
currentDate
=
LocalDate
.
now
();
queryWrapper
.
isNotNull
(
StrategyControlDataEntity:
:
getScheduleStart
);
LocalDateTime
midnight
=
currentDate
.
atStartOfDay
();
queryWrapper
.
orderByDesc
(
StrategyControlDataEntity:
:
getScheduleEnd
);
LambdaQueryWrapper
<
StrategyGreenOptHistEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
StrategyControlDataEntity
>
entities
=
strategyControlInfoMapper
.
selectList
(
queryWrapper
);
queryWrapper
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
midnight
);
List
<
StrategyGreenOptHistEntity
>
entities
=
strategyGreenOptHistMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
entities
))
{
if
(!
CollectionUtils
.
isEmpty
(
entities
))
{
for
(
StrategyControlDataEntity
entity
:
entities
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Integer
type
=
entity
.
getBizType
();
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
GreenWaveInfoCache
.
greenWaveMap
;
if
(
type
==
0
)
{
for
(
StrategyGreenOptHistEntity
entity
:
entities
)
{
BaseCrossInfoPO
baseCrossInfoPO
=
baseCrossInfoMapper
.
selectById
(
entity
.
getBizId
());
StrategyControlHistVO
histVO
=
new
StrategyControlHistVO
();
entity
.
setCrossName
(
baseCrossInfoPO
.
getName
());
histVO
.
setId
(
String
.
valueOf
(
entity
.
getGreenId
()));
String
location
=
baseCrossInfoPO
.
getLocation
();
if
(
greenWaveMap
.
isEmpty
())
{
location
=
location
.
replace
(
"POINT("
,
""
).
replace
(
" "
,
","
).
replace
(
")"
,
""
);
continue
;
entity
.
setWkt
(
location
);
}
String
controlTime
=
entity
.
getControlTime
();
Date
parse
=
format
.
parse
(
controlTime
);
GreenwaveInfoPO
greenwaveInfoPO
=
greenWaveMap
.
get
(
entity
.
getGreenId
());
if
(
Objects
.
nonNull
(
greenwaveInfoPO
))
{
histVO
.
setName
(
greenwaveInfoPO
.
getName
());
histVO
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
}
}
if
(
type
==
1
)
{
LambdaQueryWrapper
<
StrategyControlDataEntity
>
strategyQuery
=
new
LambdaQueryWrapper
<>();
GreenwaveInfoPO
greenwaveInfoPO
=
greenwaveInfoMapper
.
selectById
(
Integer
.
valueOf
(
entity
.
getBizId
()));
strategyQuery
.
eq
(
StrategyControlDataEntity:
:
getBizId
,
entity
.
getGreenId
());
entity
.
setCrossName
(
greenwaveInfoPO
.
getName
());
strategyQuery
.
eq
(
StrategyControlDataEntity:
:
getBizType
,
1
);
entity
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
strategyQuery
.
le
(
StrategyControlDataEntity:
:
getScheduleStart
,
parse
);
strategyQuery
.
ge
(
StrategyControlDataEntity:
:
getScheduleEnd
,
parse
);
// 应该是下发时间在调度下发时间内,但是目前神思下发可能没有走策略
List
<
StrategyControlDataEntity
>
strategyList
=
strategyControlInfoMapper
.
selectList
(
strategyQuery
);
if
(!
CollectionUtils
.
isEmpty
(
strategyList
))
{
StrategyControlDataEntity
strategyControlDataEntity
=
strategyList
.
get
(
0
);
histVO
.
setStrategy
(
strategyControlDataEntity
.
getStrategy
());
histVO
.
setStrategyName
(
"绿波带"
);
}
}
resulsts
.
add
(
entity
);
histVO
.
setOptTime
(
entity
.
getControlTime
());
histVO
.
setResult
(
Objects
.
equals
(
1
,
entity
.
getControlMethod
())
?
"失败"
:
"成功"
);
results
.
add
(
histVO
);
}
}
}
}
return
JsonViewObject
.
newInstance
().
success
(
resulsts
);
//LambdaQueryWrapper<StrategyControlDataEntity> queryWrapper = new LambdaQueryWrapper<>();
//queryWrapper.isNotNull(StrategyControlDataEntity::getScheduleStart);
//queryWrapper.orderByDesc(StrategyControlDataEntity::getScheduleEnd);
//List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
//if (!CollectionUtils.isEmpty(entities)) {
// for (StrategyControlDataEntity entity : entities) {
// Integer type = entity.getBizType();
// if (type == 0) {
// BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(entity.getBizId());
// entity.setCrossName(baseCrossInfoPO.getName());
// String location = baseCrossInfoPO.getLocation();
// location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
// entity.setWkt(location);
// }
// if (type == 1) {
// GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectById(Integer.valueOf(entity.getBizId()));
// entity.setCrossName(greenwaveInfoPO.getName());
// entity.setWkt(greenwaveInfoPO.getWkt());
// }
// results.add(entity);
// }
//}
return
JsonViewObject
.
newInstance
().
success
(
results
);
}
}
@Override
@Override
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/cache/CrossRunSchemeCache.java
View file @
7652f699
...
@@ -61,8 +61,7 @@ public class CrossRunSchemeCache implements CommandLineRunner {
...
@@ -61,8 +61,7 @@ public class CrossRunSchemeCache implements CommandLineRunner {
Integer
schemeId
=
getCurrentSchemeId
(
crossSectionPOS
,
currentTime
,
currentPlanId
);
Integer
schemeId
=
getCurrentSchemeId
(
crossSectionPOS
,
currentTime
,
currentPlanId
);
CrossSchemePO
crossSchemePO
=
crossSchemeMapper
.
selectSchemePOById
(
schemeId
);
CrossSchemePO
crossSchemePO
=
crossSchemeMapper
.
selectSchemePOById
(
schemeId
);
if
(
Objects
.
nonNull
(
crossSchemePO
))
{
if
(
Objects
.
nonNull
(
crossSchemePO
))
{
currentRunSchemeNoCache
.
put
(
crossId
,
crossSchemePO
.
getSchemeNo
());
}
}
}
}
}
}
}
}
...
...
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