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
38f53bd4
Commit
38f53bd4
authored
Dec 05, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 路口优化检测接口
parent
704eacde
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
147 additions
and
39 deletions
+147
-39
CrossOptStrategyEnum.java
...java/net/wanji/opt/common/enums/CrossOptStrategyEnum.java
+29
-0
CrossIndexController.java
.../wanji/opt/controller/signalopt/CrossIndexController.java
+18
-0
CrossIndexService.java
...rc/main/java/net/wanji/opt/service/CrossIndexService.java
+3
-0
CrossIndexServiceImpl.java
...ava/net/wanji/opt/service/impl/CrossIndexServiceImpl.java
+44
-3
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+25
-35
StrategyGreenBeltServiceImpl.java
.../synthesis/service/impl/StrategyGreenBeltServiceImpl.java
+1
-1
CrossOptResult.java
...ervice/src/main/java/net/wanji/opt/vo/CrossOptResult.java
+27
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/common/enums/CrossOptStrategyEnum.java
0 → 100644
View file @
38f53bd4
package
net
.
wanji
.
opt
.
common
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @author duanruiming
* @date 2024/12/05 15:20
*/
@Getter
@AllArgsConstructor
public
enum
CrossOptStrategyEnum
{
ZERO
(
0
,
"无策略"
),
ONE
(
1
,
"绿灯空放"
),
TWO
(
2
,
"失衡"
),
THREE
(
3
,
"溢出"
);
private
int
code
;
private
String
desc
;
public
static
String
getDesc
(
int
code
)
{
for
(
CrossOptStrategyEnum
value
:
CrossOptStrategyEnum
.
values
())
{
if
(
code
==
value
.
code
)
{
return
value
.
getDesc
();
}
}
return
"无策略"
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/controller/signalopt/CrossIndexController.java
View file @
38f53bd4
...
@@ -11,6 +11,7 @@ import net.wanji.databus.po.CrossDirDataRealtimePO;
...
@@ -11,6 +11,7 @@ import net.wanji.databus.po.CrossDirDataRealtimePO;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO
;
import
net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO
;
import
net.wanji.opt.service.CrossIndexService
;
import
net.wanji.opt.service.CrossIndexService
;
import
net.wanji.opt.vo.CrossOptResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -65,4 +66,21 @@ public class CrossIndexController {
...
@@ -65,4 +66,21 @@ public class CrossIndexController {
return
JsonViewObject
.
newInstance
().
success
(
crossDataRealtimePO
);
return
JsonViewObject
.
newInstance
().
success
(
crossDataRealtimePO
);
}
}
@ApiOperation
(
value
=
"方案优化曲线"
,
notes
=
"优化监测-方案优化曲线"
,
response
=
JsonViewObject
.
class
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@PostMapping
(
value
=
"/crossOptResultList"
,
produces
=
MediaType
.
APPLICATION_JSON
,
consumes
=
MediaType
.
APPLICATION_JSON
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AddOrUpdateSceneDTO
.
class
),
})
public
JsonViewObject
crossOptResultList
(
@RequestBody
CrossIdBO
crossIdBO
)
{
List
<
CrossOptResult
>
results
=
null
;
try
{
results
=
crossIndexService
.
crossOptResultList
(
crossIdBO
);
}
catch
(
Exception
e
)
{
JsonViewObject
.
newInstance
().
fail
(
"方案优化曲线查询异常"
);
}
return
JsonViewObject
.
newInstance
().
success
(
results
);
}
}
}
signal-optimize-service/src/main/java/net/wanji/opt/service/CrossIndexService.java
View file @
38f53bd4
...
@@ -4,6 +4,7 @@ import net.wanji.databus.bo.CrossIdBO;
...
@@ -4,6 +4,7 @@ import net.wanji.databus.bo.CrossIdBO;
import
net.wanji.databus.po.CrossDataRealtimePO
;
import
net.wanji.databus.po.CrossDataRealtimePO
;
import
net.wanji.databus.po.CrossDirDataRealtimePO
;
import
net.wanji.databus.po.CrossDirDataRealtimePO
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.opt.vo.CrossOptResult
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -18,4 +19,6 @@ public interface CrossIndexService {
...
@@ -18,4 +19,6 @@ public interface CrossIndexService {
CrossDataRealtimePO
crossIndex
(
CrossIdBO
crossIdBO
);
CrossDataRealtimePO
crossIndex
(
CrossIdBO
crossIdBO
);
List
<
TBaseCrossInfo
>
crossInfoList
();
List
<
TBaseCrossInfo
>
crossInfoList
();
List
<
CrossOptResult
>
crossOptResultList
(
CrossIdBO
crossIdBO
)
throws
Exception
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/CrossIndexServiceImpl.java
View file @
38f53bd4
...
@@ -2,6 +2,7 @@ package net.wanji.opt.service.impl;
...
@@ -2,6 +2,7 @@ package net.wanji.opt.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.utils.tool.DateUtil
;
import
net.wanji.databus.bo.CrossIdBO
;
import
net.wanji.databus.bo.CrossIdBO
;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
import
net.wanji.databus.dao.mapper.BaseCrossInfoMapper
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
...
@@ -9,14 +10,21 @@ import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
...
@@ -9,14 +10,21 @@ import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import
net.wanji.databus.po.CrossDataRealtimePO
;
import
net.wanji.databus.po.CrossDataRealtimePO
;
import
net.wanji.databus.po.CrossDirDataRealtimePO
;
import
net.wanji.databus.po.CrossDirDataRealtimePO
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.opt.common.enums.CrossOptStrategyEnum
;
import
net.wanji.opt.dao.mapper.StrategyCrossResultMapper
;
import
net.wanji.opt.service.CrossIndexService
;
import
net.wanji.opt.service.CrossIndexService
;
import
net.wanji.opt.synthesis.pojo.StrategyCrossResultEntity
;
import
net.wanji.opt.vo.CrossOptResult
;
import
org.drools.core.util.DateUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.time.LocalDate
;
import
java.util.List
;
import
java.time.LocalDateTime
;
import
java.util.Map
;
import
java.time.LocalTime
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* @author duanruiming
* @author duanruiming
...
@@ -32,6 +40,8 @@ public class CrossIndexServiceImpl implements CrossIndexService {
...
@@ -32,6 +40,8 @@ public class CrossIndexServiceImpl implements CrossIndexService {
private
CrossDataRealtimeMapper
crossDataRealtimeMapper
;
private
CrossDataRealtimeMapper
crossDataRealtimeMapper
;
@Resource
@Resource
private
BaseCrossInfoMapper
baseCrossInfoMapper
;
private
BaseCrossInfoMapper
baseCrossInfoMapper
;
@Resource
private
StrategyCrossResultMapper
strategyCrossResultMapper
;
@Override
@Override
public
Map
<
Integer
,
CrossDirDataRealtimePO
>
crossDirIndex
(
CrossIdBO
crossIdBO
)
{
public
Map
<
Integer
,
CrossDirDataRealtimePO
>
crossDirIndex
(
CrossIdBO
crossIdBO
)
{
...
@@ -60,4 +70,35 @@ public class CrossIndexServiceImpl implements CrossIndexService {
...
@@ -60,4 +70,35 @@ public class CrossIndexServiceImpl implements CrossIndexService {
List
<
TBaseCrossInfo
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectList
(
queryWrapper
);
List
<
TBaseCrossInfo
>
baseCrossInfoPOS
=
baseCrossInfoMapper
.
selectList
(
queryWrapper
);
return
baseCrossInfoPOS
;
return
baseCrossInfoPOS
;
}
}
@Override
public
List
<
CrossOptResult
>
crossOptResultList
(
CrossIdBO
crossIdBO
)
throws
Exception
{
LambdaQueryWrapper
<
StrategyCrossResultEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
StrategyCrossResultEntity:
:
getCrossId
,
crossIdBO
.
getCrossId
());
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
LocalDateTime
startOfDay
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
queryWrapper
.
eq
(
StrategyCrossResultEntity:
:
getCrossId
,
crossIdBO
.
getCrossId
());
queryWrapper
.
ge
(
StrategyCrossResultEntity:
:
getIssueTime
,
startOfDay
);
List
<
StrategyCrossResultEntity
>
list
=
strategyCrossResultMapper
.
selectList
(
queryWrapper
);
List
<
CrossOptResult
>
crossOptResults
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
for
(
StrategyCrossResultEntity
entity
:
list
)
{
CrossOptResult
crossOptResult
=
new
CrossOptResult
();
Date
date
=
DateUtil
.
parse
(
entity
.
getIssueTime
(),
"yyyy-MM-dd HH:mm:ss"
);
crossOptResult
.
setTimeStamp
(
date
);
String
timingPlan
=
entity
.
getTimingPlan
();
Integer
countDown
=
entity
.
getCountDown
();
if
(
entity
.
getCurrentAlgo
()
==
2
)
{
countDown
=
5
;
}
crossOptResult
.
setCountDown
(
countDown
);
Integer
currentAlgo
=
entity
.
getCurrentAlgo
();
crossOptResult
.
setStrategy
(
currentAlgo
);
crossOptResult
.
setStrategyName
(
CrossOptStrategyEnum
.
getDesc
(
currentAlgo
));
crossOptResults
.
add
(
crossOptResult
);
}
}
return
crossOptResults
;
}
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
38f53bd4
...
@@ -349,19 +349,11 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -349,19 +349,11 @@ public class StrategyControlServiceImpl implements StrategyControlService {
for
(
StrategyControlDataEntity
entity
:
entities
)
{
for
(
StrategyControlDataEntity
entity
:
entities
)
{
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
result
);
BeanUtils
.
copyProperties
(
entity
,
result
);
Date
start
=
entity
.
getScheduleStart
();
Date
end
=
entity
.
getScheduleEnd
();
if
(
current
.
before
(
start
)
||
current
.
after
(
end
))
{
result
.
setTime
(
""
);
}
else
{
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
;
int
currentWeek
=
DateUtil
.
thisDayOfWeek
()
-
1
;
if
(
currentWeek
!=
timeTable
.
getWeek
())
{
result
.
setTime
(
""
);
}
else
{
String
[]
timeList
=
timeTable
.
getTimeList
();
String
[]
timeList
=
timeTable
.
getTimeList
();
for
(
String
s
:
timeList
)
{
for
(
String
s
:
timeList
)
{
String
[]
hours
=
s
.
split
(
","
);
String
[]
hours
=
s
.
split
(
","
);
...
@@ -386,8 +378,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -386,8 +378,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
}
}
}
}
}
}
if
(
type
==
0
)
{
if
(
type
==
0
)
{
BaseCrossInfoPO
baseCrossInfoPO
=
baseCrossInfoMapper
.
selectById
(
entity
.
getBizId
());
BaseCrossInfoPO
baseCrossInfoPO
=
baseCrossInfoMapper
.
selectById
(
entity
.
getBizId
());
result
.
setCrossName
(
baseCrossInfoPO
.
getName
());
result
.
setCrossName
(
baseCrossInfoPO
.
getName
());
...
...
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyGreenBeltServiceImpl.java
View file @
38f53bd4
...
@@ -55,7 +55,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
...
@@ -55,7 +55,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
GreenBeltAreaIndexVO
.
DirDetail
dirDetail
=
new
GreenBeltAreaIndexVO
.
DirDetail
();
GreenBeltAreaIndexVO
.
DirDetail
dirDetail
=
new
GreenBeltAreaIndexVO
.
DirDetail
();
String
roadDirection
=
realtimePO
.
getRoadDirection
();
String
roadDirection
=
realtimePO
.
getRoadDirection
();
dirDetail
.
setDirName
(
GreenBeltDirEnum
.
getDesc
(
roadDirection
));
dirDetail
.
setDirName
(
GreenBeltDirEnum
.
getDesc
(
roadDirection
));
dirDetail
.
setTravelTime
(
realtimePO
.
getTrvalTime
());
dirDetail
.
setTravelTime
(
realtimePO
.
getTrvalTime
()
/
60
);
dirDetail
.
setStopTimes
(
realtimePO
.
getStopTimes
());
dirDetail
.
setStopTimes
(
realtimePO
.
getStopTimes
());
status
=
status
>=
realtimePO
.
getStatus
()
?
status
:
realtimePO
.
getStatus
();
status
=
status
>=
realtimePO
.
getStatus
()
?
status
:
realtimePO
.
getStatus
();
dirDetails
.
add
(
dirDetail
);
dirDetails
.
add
(
dirDetail
);
...
...
signal-optimize-service/src/main/java/net/wanji/opt/vo/CrossOptResult.java
0 → 100644
View file @
38f53bd4
package
net
.
wanji
.
opt
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author duanruiming
* @date 2024/12/05 11:29
* @description 路口优化结果当前时间优化场景节约时间
*/
@Data
@ApiModel
(
"路口优化曲线实体"
)
public
class
CrossOptResult
{
@ApiModelProperty
(
"策略"
)
private
Integer
strategy
;
@ApiModelProperty
(
"策略名称"
)
private
String
strategyName
;
@ApiModelProperty
(
"节约时间"
)
private
Integer
countDown
;
@ApiModelProperty
(
"时间戳"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
private
Date
timeStamp
;
}
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