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
7ee9a099
Commit
7ee9a099
authored
Dec 07, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] AI路口优化
parent
03350324
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
18 deletions
+41
-18
BaseCrossInfoCache.java
...src/main/java/net/wanji/opt/cache/BaseCrossInfoCache.java
+3
-1
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+38
-17
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/cache/BaseCrossInfoCache.java
View file @
7ee9a099
...
@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils;
...
@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -74,7 +75,8 @@ public class BaseCrossInfoCache implements CommandLineRunner {
...
@@ -74,7 +75,8 @@ public class BaseCrossInfoCache implements CommandLineRunner {
public
void
init
()
{
public
void
init
()
{
List
<
BaseCrossInfoPO
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectAll
(
new
CrossInfoVO
());
List
<
BaseCrossInfoPO
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectAll
(
new
CrossInfoVO
());
if
(!
CollectionUtils
.
isEmpty
(
baseCrossInfoPOS
))
{
if
(!
CollectionUtils
.
isEmpty
(
baseCrossInfoPOS
))
{
crossInfoList
.
addAll
(
baseCrossInfoPOS
);
List
<
BaseCrossInfoPO
>
collect
=
baseCrossInfoPOS
.
stream
().
filter
(
po
->
Objects
.
equals
(
po
.
getIsSignal
(),
1
)).
collect
(
Collectors
.
toList
());
crossInfoList
.
addAll
(
collect
);
}
}
}
}
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
7ee9a099
...
@@ -19,7 +19,6 @@ import net.wanji.databus.po.BaseCrossInfoPO;
...
@@ -19,7 +19,6 @@ import net.wanji.databus.po.BaseCrossInfoPO;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.opt.cache.BaseCrossInfoCache
;
import
net.wanji.opt.cache.BaseCrossInfoCache
;
import
net.wanji.opt.cache.GreenWaveInfoCache
;
import
net.wanji.opt.cache.GreenWaveInfoCache
;
import
net.wanji.opt.common.enums.CrossOptStrategyEnum
;
import
net.wanji.opt.common.enums.StrategyControlEnum
;
import
net.wanji.opt.common.enums.StrategyControlEnum
;
import
net.wanji.opt.dao.mapper.*
;
import
net.wanji.opt.dao.mapper.*
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
...
@@ -72,6 +71,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -72,6 +71,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private
StrategyGreenOptHistMapper
strategyGreenOptHistMapper
;
private
StrategyGreenOptHistMapper
strategyGreenOptHistMapper
;
@Resource
@Resource
private
StrategyCrossResultMapper
strategyCrossResultMapper
;
private
StrategyCrossResultMapper
strategyCrossResultMapper
;
@Resource
private
BaseCrossInfoCache
baseCrossInfoCache
;
@Override
@Override
...
@@ -352,9 +353,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -352,9 +353,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
result
);
BeanUtils
.
copyProperties
(
entity
,
result
);
String
time
=
entity
.
getTime
();
String
time
=
entity
.
getTime
();
List
<
StrategyControlDataVO
.
TimeTable
>
timeTables
=
instance
.
readValue
(
time
,
new
TypeReference
<
List
<
StrategyControlDataVO
.
TimeTable
>>()
{});
List
<
StrategyControlDataVO
.
TimeTable
>
timeTables
=
instance
.
readValue
(
time
,
new
TypeReference
<
List
<
StrategyControlDataVO
.
TimeTable
>>()
{
});
for
(
StrategyControlDataVO
.
TimeTable
timeTable
:
timeTables
)
{
for
(
StrategyControlDataVO
.
TimeTable
timeTable
:
timeTables
)
{
int
currentWeek
=
DateUtil
.
thisDayOfWeek
()
-
1
;
String
[]
timeList
=
timeTable
.
getTimeList
();
String
[]
timeList
=
timeTable
.
getTimeList
();
for
(
String
s
:
timeList
)
{
for
(
String
s
:
timeList
)
{
String
[]
hours
=
s
.
split
(
","
);
String
[]
hours
=
s
.
split
(
","
);
...
@@ -380,17 +381,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -380,17 +381,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
}
}
}
}
if
(
type
==
0
)
{
BaseCrossInfoPO
baseCrossInfoPO
=
baseCrossInfoMapper
.
selectById
(
entity
.
getBizId
());
result
.
setCrossName
(
baseCrossInfoPO
.
getName
());
String
location
=
baseCrossInfoPO
.
getLocation
();
location
=
location
.
replace
(
"POINT("
,
""
).
replace
(
" "
,
","
).
replace
(
")"
,
""
);
result
.
setWkt
(
location
);
}
if
(
type
==
1
)
{
if
(
type
==
1
)
{
GreenwaveInfoPO
greenwaveInfoPO
=
greenwaveInfoMapper
.
selectById
(
Integer
.
valueOf
(
entity
.
getBizId
()));
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
GreenWaveInfoCache
.
greenWaveMap
;
result
.
setCrossName
(
greenwaveInfoPO
.
getName
());
if
(!
greenWaveMap
.
isEmpty
())
{
result
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
GreenwaveInfoPO
greenwaveInfoPO
=
greenWaveMap
.
get
(
Integer
.
valueOf
(
entity
.
getBizId
()));
result
.
setCrossName
(
greenwaveInfoPO
.
getName
());
result
.
setWkt
(
greenwaveInfoPO
.
getWkt
());
}
}
}
results
.
add
(
result
);
results
.
add
(
result
);
}
}
...
@@ -403,19 +400,43 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -403,19 +400,43 @@ public class StrategyControlServiceImpl implements StrategyControlService {
try
{
try
{
List
<
StrategyControlDataEntity
>
currentStrateInfoList
=
getCurrentStrateInfoList
(
type
);
List
<
StrategyControlDataEntity
>
currentStrateInfoList
=
getCurrentStrateInfoList
(
type
);
List
<
StrategyControlDataExt
>
strategyControlDataExts
=
new
ArrayList
<>();
List
<
StrategyControlDataExt
>
strategyControlDataExts
=
new
ArrayList
<>();
List
<
StrategyControlDataExt
>
results
=
new
ArrayList
<>();
for
(
StrategyControlDataEntity
strategyControlDataEntity
:
currentStrateInfoList
)
{
for
(
StrategyControlDataEntity
strategyControlDataEntity
:
currentStrateInfoList
)
{
Integer
strategy
=
strategyControlDataEntity
.
getStrategy
();
Integer
strategy
=
strategyControlDataEntity
.
getStrategy
();
StrategyControlDataExt
strategyControlDataExt
=
new
StrategyControlDataExt
();
StrategyControlDataExt
strategyControlDataExt
=
new
StrategyControlDataExt
();
BeanUtils
.
copyProperties
(
strategyControlDataEntity
,
strategyControlDataExt
);
BeanUtils
.
copyProperties
(
strategyControlDataEntity
,
strategyControlDataExt
);
strategyControlDataExt
.
setStrategyName
(
StrategyControlEnum
.
getDesc
(
strategy
));
strategyControlDataExt
.
setStrategyName
(
StrategyControlEnum
.
getDesc
(
strategy
));
strategyControlDataExt
.
setOptStatus
(
"未执行"
);
if
(
StringUtils
.
isNotBlank
(
strategyControlDataEntity
.
getTime
()))
{
if
(
StringUtils
.
isNotBlank
(
strategyControlDataEntity
.
getTime
()))
{
strategyControlDataExt
.
setOptStatus
(
"优化中"
);
strategyControlDataExt
.
setOptStatus
(
"优化中"
);
strategyControlDataExts
.
add
(
strategyControlDataExt
);
}
}
strategyControlDataExts
.
add
(
strategyControlDataExt
);
}
}
strategyControlDataExts
.
sort
(
Comparator
.
comparing
(
StrategyControlDataExt:
:
getOptStatus
));
if
(
Objects
.
equals
(
0
,
type
))
{
return
jsonViewObject
.
success
(
strategyControlDataExts
,
"路网优化监测查询成功"
);
List
<
BaseCrossInfoPO
>
crossInfoCache
=
baseCrossInfoCache
.
getCrossInfoCache
();
if
(!
CollectionUtils
.
isEmpty
(
crossInfoCache
))
{
for
(
BaseCrossInfoPO
baseCrossInfoPO
:
crossInfoCache
)
{
StrategyControlDataExt
ext
=
new
StrategyControlDataExt
();
ext
.
setBizId
(
baseCrossInfoPO
.
getId
());
ext
.
setStrategyName
(
"无策略"
);
ext
.
setOptStatus
(
"未优化"
);
ext
.
setStatus
(
0
);
for
(
StrategyControlDataExt
strategyControlDataExt
:
strategyControlDataExts
)
{
if
(
StringUtils
.
equals
(
baseCrossInfoPO
.
getId
(),
strategyControlDataExt
.
getBizId
()))
{
ext
=
strategyControlDataExt
;
}
}
String
location
=
baseCrossInfoPO
.
getLocation
();
location
=
location
.
replace
(
"POINT("
,
""
).
replace
(
" "
,
","
).
replace
(
")"
,
""
);
ext
.
setWkt
(
location
);
results
.
add
(
ext
);
}
}
}
if
(
Objects
.
equals
(
1
,
type
))
{
results
.
addAll
(
strategyControlDataExts
);
}
results
.
sort
(
Comparator
.
comparing
(
StrategyControlDataExt:
:
getOptStatus
));
return
jsonViewObject
.
success
(
results
,
"路网优化监测查询成功"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"路网优化监测查询失败: {}"
,
e
);
log
.
error
(
"路网优化监测查询失败: {}"
,
e
);
return
jsonViewObject
.
fail
(
"路网优化监测查询失败"
);
return
jsonViewObject
.
fail
(
"路网优化监测查询失败"
);
...
...
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