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
709ddb7f
Commit
709ddb7f
authored
Dec 13, 2024
by
zhouleilei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
诱导屏更新
parent
280cba58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
33 deletions
+77
-33
InduceTemplate.java
...ce/src/main/java/net/wanji/opt/entity/InduceTemplate.java
+19
-3
InduceSendServiceImpl.java
.../wanji/opt/service/induce/impl/InduceSendServiceImpl.java
+56
-25
InducesMonitorTask.java
.../src/main/java/net/wanji/opt/task/InducesMonitorTask.java
+2
-5
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/entity/InduceTemplate.java
View file @
709ddb7f
...
...
@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.apache.ibatis.type.BlobTypeHandler
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* <p>
* 诱导屏-发布模板
...
...
@@ -97,5 +97,21 @@ public class InduceTemplate implements Serializable {
@TableField
(
"gmt_modified"
)
private
Date
gmtModified
;
/**
* 图片宽度
*/
@TableField
(
"file_width"
)
private
Integer
fileWidth
;
/**
* 图片高度
*/
@TableField
(
"file_height"
)
private
Integer
fileHeight
;
/**
* 速度值
*/
@TableField
(
"text_send"
)
private
String
textSend
;
}
signal-optimize-service/src/main/java/net/wanji/opt/service/induce/impl/InduceSendServiceImpl.java
View file @
709ddb7f
...
...
@@ -115,8 +115,8 @@ public class InduceSendServiceImpl implements InduceSendService {
int
bottomRightX
=
Integer
.
parseInt
(
bottomRight
[
0
]);
int
bottomRightY
=
Integer
.
parseInt
(
bottomRight
[
1
]);
// 图片生成操作
boolean
upDown
=
param
.
getContents
()[
0
].
contains
(
"▲"
)
||
param
.
getContents
()[
0
].
contains
(
"▼"
);
createImageWithText
(
induceTemplate
,
image
,
param
.
getContents
(),
upDown
,
topLeftX
,
topLeftY
,
bottomRightX
,
bottomRightY
);
//
boolean upDown = param.getContents()[0].contains("▲") || param.getContents()[0].contains("▼");
createImageWithText
(
induceTemplate
,
image
,
param
.
getContents
(),
true
,
topLeftX
,
topLeftY
,
bottomRightX
,
bottomRightY
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
...
...
@@ -136,6 +136,8 @@ public class InduceSendServiceImpl implements InduceSendService {
greenwaveinduces
.
setSourceId
(
PATH
+
dirName
+
"/"
+
fileName
);
}
log
.
info
(
"上传文件至ftp-filePath:{}"
,
param
.
getFtpPath
());
induceTemplateService
.
updateById
(
induceTemplate
);
}
// //如果已发布,则调用下屏服务
// if(greenwaveinduces.getStatus()==1){
...
...
@@ -287,15 +289,6 @@ public class InduceSendServiceImpl implements InduceSendService {
}
/**
* 根据绘制的区域,动态调整字体大小,以适应文本区域
*
* @param g2d graphics2d对象
* @param sign 绘制方向标识
* @param text 绘制内容
* @param width 绘制区域宽度
* @param height 绘制区域高度
*/
/**
* 根据绘制的区域,动态调整字体大小,以适应文本区域
*
...
...
@@ -304,7 +297,7 @@ public class InduceSendServiceImpl implements InduceSendService {
* @param width 绘制区域宽度
* @param height 绘制区域高度
*/
private
static
FontMetrics
autoFont
(
Graphics2D
g2d
,
InduceTemplate
drawParam
,
String
[]
contents
,
int
width
,
int
height
)
{
private
static
FontMetrics
autoFont
(
Graphics2D
g2d
,
InduceTemplate
drawParam
,
String
[]
contents
,
int
width
,
int
height
)
{
// 初始化字体
Font
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
1
);
g2d
.
setFont
(
font
);
...
...
@@ -317,26 +310,29 @@ public class InduceSendServiceImpl implements InduceSendService {
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
fontSize
);
g2d
.
setFont
(
font
);
metrics
=
g2d
.
getFontMetrics
();
drawParam
.
setTextSize
(
fontSize
);
// 确保绘制区域能够容纳文本,考虑字体长度和高度
// if (drawParam.getTextDirection()) {
// // 高度考虑上下边距
// if (metrics.stringWidth(contents[0]) > width || (metrics.getHeight() - 4) > height) {
// // 设置字体大小
// font = new Font(drawParam.getTextFont(), Font.BOLD, --fontSize);
// g2d.setFont(font);
// metrics = g2d.getFontMetrics();
// return metrics;
// }
// } else {
if
(
true
)
{
// 高度只考虑上边距
if
(
metrics
.
stringWidth
(
contents
[
0
])
>
width
||
(
metrics
.
getHeight
()
-
4
)
>
height
)
{
// 设置字体大小
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
--
fontSize
);
g2d
.
setFont
(
font
);
metrics
=
g2d
.
getFontMetrics
();
drawParam
.
setTextSize
(
fontSize
);
return
metrics
;
}
}
else
{
// 高度只考虑上边距
if
(
metrics
.
stringWidth
(
contents
[
0
])
>
width
||
(
metrics
.
getHeight
()
-
1
)
*
contents
.
length
>
height
)
{
// 设置字体大小
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
--
fontSize
);
g2d
.
setFont
(
font
);
metrics
=
g2d
.
getFontMetrics
();
drawParam
.
setTextSize
(
fontSize
);
return
metrics
;
}
//
}
}
}
// 若字体大小超出限制,则返回最小字体
return
metrics
;
...
...
@@ -347,7 +343,6 @@ public class InduceSendServiceImpl implements InduceSendService {
*
* @param image 图片
* @param text 内容数组
* @param sign 绘制方向
* @param topLeftX 区域左上角x坐标
* @param topLeftY 区域左上角y坐标
* @param bottomRightX 区域右下角x坐标
...
...
@@ -364,7 +359,7 @@ public class InduceSendServiceImpl implements InduceSendService {
int
width
=
bottomRightX
-
topLeftX
;
int
height
=
bottomRightY
-
topLeftY
;
// 动态调整字体大小,以适应文本区域
FontMetrics
metrics
=
autoFont
(
g2d
,
pictureFile
,
text
,
width
,
height
);
FontMetrics
metrics
=
autoFont
(
g2d
,
pictureFile
,
text
,
width
,
height
);
// 绘制坐标点
int
textWidth
;
// 考虑文字绘制方向、文字居中。垂直居中要根据文字高度,水平居中要根据文字宽度。
...
...
@@ -385,6 +380,7 @@ public class InduceSendServiceImpl implements InduceSendService {
currentX
=
topLeftX
+
(
width
-
textWidth
)
/
2
;
// 计算居中的y坐标
currentY
=
currentY
+
(
height
-
metrics
.
getHeight
())
/
2
;
textSend
(
pictureFile
,
text
,
g2d
,
2
,
currentY
);
g2d
.
drawString
(
text
[
0
],
currentX
,
currentY
);
}
else
{
// 计算每个文本内容的竖向绘制坐标
...
...
@@ -404,6 +400,41 @@ public class InduceSendServiceImpl implements InduceSendService {
g2d
.
dispose
();
}
/**
* 判断是否包含“km/h”,若包含,对比上次绘制的速度值,追加上升或下降符号
*
* @param pictureFile
* @param text
* @param g2d
* @param currentX
* @param currentY
* @return
*/
public
static
void
textSend
(
InduceTemplate
pictureFile
,
String
[]
text
,
Graphics2D
g2d
,
int
currentX
,
int
currentY
)
{
// 获取速度值
if
(
text
.
length
>
0
&&
text
[
0
].
contains
(
"km/h"
)
&&
pictureFile
.
getFileWidth
()
>
128
&&
pictureFile
.
getFileHeight
()
>
64
)
{
String
[]
split
=
text
[
0
].
split
(
"km/h"
);
if
(
split
.
length
>
0
)
{
// 若存在上次的速度值,则对比
if
(
pictureFile
.
getTextSend
()
!=
null
)
{
String
[]
newSend
=
split
[
0
].
split
(
"-"
);
String
[]
oldSend
=
pictureFile
.
getTextSend
().
split
(
"-"
);
// 对比两组速度值,判断是否需要追加符号
if
(
newSend
.
length
>
1
&&
oldSend
.
length
>
1
)
{
int
newSpeed
=
Integer
.
parseInt
(
newSend
[
0
].
trim
())
+
Integer
.
parseInt
(
newSend
[
1
].
trim
());
int
oldSpeed
=
Integer
.
parseInt
(
oldSend
[
0
].
trim
())
+
Integer
.
parseInt
(
oldSend
[
1
].
trim
());
if
(
newSpeed
>
oldSpeed
)
{
g2d
.
drawString
(
"▲ "
,
currentX
,
currentY
);
}
else
if
(
newSpeed
<
oldSpeed
)
{
g2d
.
drawString
(
"▼ "
,
currentX
,
currentY
);
}
}
}
pictureFile
.
setTextSend
(
split
[
0
]);
}
}
}
/**
* 在指定位置添加文字到图像
*
...
...
signal-optimize-service/src/main/java/net/wanji/opt/task/InducesMonitorTask.java
View file @
709ddb7f
package
net
.
wanji
.
opt
.
task
;
import
com.alibaba.druid.support.json.JSONUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
...
@@ -12,7 +11,6 @@ import net.wanji.common.utils.tool.DateUtil;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.common.utils.tool.StringUtils
;
import
net.wanji.databus.dao.entity.GreenwaveCrossPO
;
import
net.wanji.databus.dao.entity.GreenwaveCrossPOExt
;
import
net.wanji.databus.dao.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveCrossMapper
;
...
...
@@ -32,7 +30,6 @@ import net.wanji.opt.service.induce.InduceTemplateService;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity
;
import
net.wanji.opt.vo.GreenBeltInfoVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -196,10 +193,10 @@ public class InducesMonitorTask {
// 计算绿波速度变化趋势
if
(
Objects
.
nonNull
(
greenwaveInducesHist
.
getMinSpeed
())
&&
Objects
.
nonNull
(
greenwaveInducesHist
.
getMaxSpeed
())
&&
Objects
.
nonNull
(
greenOptHistEntity
.
getMinSpeed
())
&&
Objects
.
nonNull
(
greenOptHistEntity
.
getMaxSpeed
()))
{
if
(
greenwaveInducesHist
.
getMinSpeed
()
>
greenOptHistEntity
.
getMinSpeed
()
||
greenwaveInducesHist
.
getMaxSpeed
()
>
greenOptHistEntity
.
getMaxSpeed
())
{
upDown
=
"
▼
"
;
upDown
=
""
;
}
if
(
greenwaveInducesHist
.
getMinSpeed
()
<
greenOptHistEntity
.
getMinSpeed
()
||
greenwaveInducesHist
.
getMaxSpeed
()
<
greenOptHistEntity
.
getMaxSpeed
())
{
upDown
=
"
▲
"
;
upDown
=
""
;
}
}
greenwaveInducesHist
.
setMinSpeed
(
greenOptHistEntity
.
getMinSpeed
());
...
...
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