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
edb7744a
Commit
edb7744a
authored
Feb 07, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 优化次数时间优化
parent
77272f20
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
205 additions
and
30 deletions
+205
-30
pom.xml
pom.xml
+5
-0
pom.xml
signal-optimize-service/pom.xml
+5
-0
StrategyOptCountDTO.java
.../src/main/java/net/wanji/opt/dto/StrategyOptCountDTO.java
+29
-0
StrategyOptTimesDTO.java
.../src/main/java/net/wanji/opt/dto/StrategyOptTimesDTO.java
+26
-0
StrategyCrossResultEntity.java
...t/wanji/opt/synthesis/pojo/StrategyCrossResultEntity.java
+2
-0
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+33
-29
pom.xml
signal-utc-hisense-service/pom.xml
+0
-1
pom.xml
wj-common/pom.xml
+4
-0
OkHttpClientUtil.java
...rc/main/java/net/wanji/common/utils/OkHttpClientUtil.java
+101
-0
No files found.
pom.xml
View file @
edb7744a
...
...
@@ -104,6 +104,11 @@
<!-- 依赖声明 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
4.9.3
</version>
</dependency>
<!-- knife4j依赖 -->
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
...
...
signal-optimize-service/pom.xml
View file @
edb7744a
...
...
@@ -18,6 +18,11 @@
</properties>
<dependencies>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
4.9.3
</version>
</dependency>
<!--客户端负载均衡loadbalancer-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
signal-optimize-service/src/main/java/net/wanji/opt/dto/StrategyOptCountDTO.java
0 → 100644
View file @
edb7744a
package
net
.
wanji
.
opt
.
dto
;
import
lombok.Data
;
/**
* @author duanruiming
* @date 2025/02/07 15:14
*/
@Data
public
class
StrategyOptCountDTO
{
private
String
message
;
private
String
status
;
private
Integer
code
;
private
Long
timestamp
;
private
Detail
content
;
@Data
public
static
class
Detail
{
private
Integer
congestionNum
;
private
Integer
congestionRoadNum
;
private
Integer
emptyPassNum
;
private
Integer
emptyPassNumUp
;
private
Integer
slowlyRoadNum
;
private
Integer
spilloverNum
;
private
Integer
spilloverNumUp
;
private
Integer
unbalanceNum
;
private
Integer
unbalanceNumUp
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/dto/StrategyOptTimesDTO.java
0 → 100644
View file @
edb7744a
package
net
.
wanji
.
opt
.
dto
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author duanruiming
* @date 2025/02/07 14:42
*/
@Data
public
class
StrategyOptTimesDTO
{
private
String
message
;
private
String
status
;
private
Integer
code
;
private
Long
timestamp
;
private
List
<
Detail
>
content
;
@Data
public
static
class
Detail
{
private
Integer
executeNum
;
private
Integer
executeNumUp
;
private
Double
optimizeTime
;
private
Integer
optimizeTimeUp
;
private
String
strategyType
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/pojo/StrategyCrossResultEntity.java
View file @
edb7744a
...
...
@@ -64,4 +64,6 @@ public class StrategyCrossResultEntity {
private
Integer
emptyTurn
;
@TableField
(
"empty_dir"
)
private
String
empty_dir
;
@TableField
(
"dt"
)
private
Integer
dt
;
}
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
edb7744a
...
...
@@ -9,12 +9,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.framework.Constants
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.utils.OkHttpClientUtil
;
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
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveInfoMapper
;
import
net.wanji.databus.entity.basedata.ResultView
;
import
net.wanji.databus.po.BaseCrossInfoPO
;
import
net.wanji.databus.vo.AbnormalCrossListVO
;
import
net.wanji.opt.cache.BaseCrossInfoCache
;
...
...
@@ -22,6 +24,8 @@ import net.wanji.opt.cache.GreenWaveInfoCache;
import
net.wanji.opt.common.enums.EventStatusEnum
;
import
net.wanji.opt.common.enums.StrategyControlEnum
;
import
net.wanji.opt.dao.mapper.*
;
import
net.wanji.opt.dto.StrategyOptCountDTO
;
import
net.wanji.opt.dto.StrategyOptTimesDTO
;
import
net.wanji.opt.po.StrategyGreenOptHistEntity
;
import
net.wanji.opt.po.trend.HoloEventInfoPO
;
import
net.wanji.opt.synthesis.enums.StrategyCrossAlgoEnum
;
...
...
@@ -30,6 +34,7 @@ import net.wanji.opt.synthesis.pojo.vo.*;
import
net.wanji.opt.synthesis.service.PushStrategyControlService
;
import
net.wanji.opt.synthesis.service.StrategyControlService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.geotools.feature.visitor.CountVisitor
;
import
org.jetbrains.annotations.NotNull
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -133,8 +138,13 @@ public class StrategyControlServiceImpl implements StrategyControlService {
detailData
.
setBiz_id
(
dataVO
.
getBizId
());
detailData
.
setBiz_type
(
dataVO
.
getBizType
());
detailData
.
setStrategy
(
dataVO
.
getStrategy
());
if
(
Objects
.
nonNull
(
dataVO
.
getScheduleStart
())
&&
Objects
.
nonNull
(
dataVO
.
getScheduleStart
()))
{
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
));
}
else
{
detailData
.
setSchedule_start
(
DateUtil
.
format
(
new
Date
(),
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_SECOND
));
detailData
.
setSchedule_end
(
DateUtil
.
format
(
new
Date
(),
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
->
{
...
...
@@ -380,36 +390,30 @@ public class StrategyControlServiceImpl implements StrategyControlService {
@Override
public
JsonViewObject
strategyOptTimes
()
throws
Exception
{
LocalDate
currentDate
=
LocalDate
.
now
();
LocalTime
startTime
=
LocalTime
.
MIDNIGHT
;
LocalDateTime
startOfDay
=
LocalDateTime
.
of
(
currentDate
,
startTime
);
LambdaQueryWrapper
<
StrategyGreenOptHistEntity
>
greenQuery
=
new
LambdaQueryWrapper
<>();
greenQuery
.
ge
(
StrategyGreenOptHistEntity:
:
getControlTime
,
startOfDay
);
List
<
StrategyGreenOptHistEntity
>
greenOptList
=
strategyGreenOptHistMapper
.
selectList
(
greenQuery
);
int
totalTime
=
0
;
int
totalCount
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
greenOptList
))
{
for
(
StrategyGreenOptHistEntity
entity
:
greenOptList
)
{
Integer
controlDuration
=
entity
.
getControlDuration
();
totalTime
+=
controlDuration
;
totalCount
+=
1
;
}
}
LambdaQueryWrapper
<
StrategyCrossResultEntity
>
crossQuery
=
new
LambdaQueryWrapper
<>();
crossQuery
.
ge
(
StrategyCrossResultEntity:
:
getIssueTime
,
startOfDay
);
List
<
StrategyCrossResultEntity
>
crossList
=
strategyCrossResultMapper
.
selectList
(
crossQuery
);
if
(!
CollectionUtils
.
isEmpty
(
crossList
))
{
for
(
StrategyCrossResultEntity
entity
:
crossList
)
{
Integer
countDown
=
entity
.
getCountDown
();
if
(
Math
.
abs
(
countDown
)
>
1
)
{
totalTime
+=
countDown
;
totalCount
+=
1
;
}
}
}
String
timeUrl
=
"http://37.12.182.29:15020/decisionPage/MonitorStrategyOptimizationInfo/getData"
;
String
timeResult
=
OkHttpClientUtil
.
get
(
timeUrl
);
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
StrategyOptTimesVO
strategyOptTimesVO
=
new
StrategyOptTimesVO
();
strategyOptTimesVO
.
setCount
(
totalCount
);
strategyOptTimesVO
.
setTimes
(
totalTime
/
3600
);
if
(
StringUtils
.
isNotBlank
(
timeResult
))
{
StrategyOptTimesDTO
dto
=
mapper
.
readValue
(
timeResult
,
StrategyOptTimesDTO
.
class
);
List
<
StrategyOptTimesDTO
.
Detail
>
content
=
dto
.
getContent
();
if
(!
CollectionUtils
.
isEmpty
(
content
))
{
Double
totalTime
=
0.0
;
for
(
StrategyOptTimesDTO
.
Detail
item
:
content
)
{
totalTime
+=
item
.
getOptimizeTime
();
}
Double
temp
=
Math
.
floor
(
totalTime
/
3600
);
strategyOptTimesVO
.
setTimes
(
temp
.
intValue
());
}
}
String
countUrl
=
"http://37.12.182.29:15020/decisionPage/MonitorRadarIndicatorsInfo/getRadarCountData"
;
String
countResult
=
OkHttpClientUtil
.
get
(
countUrl
);
if
(
StringUtils
.
isNotBlank
(
countResult
))
{
StrategyOptCountDTO
strategyOptCountDTO
=
mapper
.
readValue
(
countResult
,
StrategyOptCountDTO
.
class
);
StrategyOptCountDTO
.
Detail
content
=
strategyOptCountDTO
.
getContent
();
int
count
=
content
.
getCongestionNum
()
+
content
.
getEmptyPassNum
()
+
content
.
getSpilloverNum
()
+
content
.
getUnbalanceNum
();
strategyOptTimesVO
.
setCount
(
count
);
}
return
JsonViewObject
.
newInstance
().
success
(
strategyOptTimesVO
);
}
...
...
signal-utc-hisense-service/pom.xml
View file @
edb7744a
...
...
@@ -27,7 +27,6 @@
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
4.9.3
</version>
</dependency>
<dependency>
<groupId>
dom4j
</groupId>
...
...
wj-common/pom.xml
View file @
edb7744a
...
...
@@ -27,6 +27,10 @@
</properties>
<dependencies>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
</dependency>
<!--rest参数校验 start -->
<dependency>
<groupId>
org.hibernate
</groupId>
...
...
wj-common/src/main/java/net/wanji/common/utils/OkHttpClientUtil.java
0 → 100644
View file @
edb7744a
package
net
.
wanji
.
common
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.utils.tool.StringUtils
;
import
okhttp3.*
;
import
java.io.IOException
;
/**
* @ClassName OkHttpClient
* @Description OkHttpClient
* @Author zhouleilei
* @Date 2024/11/3 18:11
*/
@Slf4j
public
class
OkHttpClientUtil
{
public
static
String
xmlPost
(
String
url
,
String
xmlContent
)
{
if
(
StringUtils
.
isBlank
(
url
)
||
StringUtils
.
isBlank
(
xmlContent
))
{
return
null
;
}
// 创建 OkHttpClient 实例
OkHttpClient
client
=
new
OkHttpClient
();
// 创建请求体
RequestBody
body
=
RequestBody
.
create
(
xmlContent
,
MediaType
.
get
(
"application/xml; charset=utf-8"
));
// 创建请求
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
post
(
body
)
.
build
();
// 执行请求
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
// 获取响应体
if
(
response
.
code
()
==
200
&&
response
.
body
()
!=
null
)
{
String
responseString
=
response
.
body
().
string
();
return
responseString
;
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
jsonPost
(
String
url
,
String
json
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
url
)
||
StringUtils
.
isBlank
(
json
))
{
return
null
;
}
// 创建 OkHttpClient 实例
OkHttpClient
client
=
new
OkHttpClient
();
// 创建请求体
RequestBody
body
=
RequestBody
.
create
(
json
,
MediaType
.
get
(
"application/json; charset=utf-8"
));
// 创建请求
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
post
(
body
)
.
build
();
// 执行请求
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
// 获取响应体
if
(
response
.
code
()
==
200
&&
response
.
body
()
!=
null
)
{
String
responseString
=
response
.
body
().
string
();
log
.
info
(
"远程服务调用成功,url:{}"
,
url
);
return
responseString
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"OkHttpClientUtil远程服务url:{}, 调用异常:{}"
,
url
,
e
.
getMessage
());
throw
new
Exception
();
}
return
null
;
}
public
static
String
get
(
String
url
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
url
))
{
return
null
;
}
// 创建 OkHttpClient 客户端
OkHttpClient
client
=
new
OkHttpClient
();
// 构建请求
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
get
()
.
build
();
// 执行请求
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
// 获取响应体
if
(
response
.
isSuccessful
())
{
String
responseString
=
response
.
body
().
string
();
log
.
info
(
"远程服务调用成功,url:{}"
,
url
);
return
responseString
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"OkHttpClientUtil远程服务url:{}, 调用异常:{}"
,
url
,
e
.
getMessage
());
throw
new
Exception
();
}
return
null
;
}
}
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