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
275e5985
Commit
275e5985
authored
Dec 14, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
ce009c3b
53fd44f1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
41 deletions
+111
-41
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
+3
-6
GreenwaveHistMapper.xml
...service/src/main/resources/mapper/GreenwaveHistMapper.xml
+3
-0
HisenseTurnEnum.java
...in/java/net/wanji/utc/hisense/common/HisenseTurnEnum.java
+3
-3
ControlCommandServiceImpl.java
...i/utc/hisense/service/impl/ControlCommandServiceImpl.java
+27
-4
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/entity/InduceTemplate.java
View file @
275e5985
...
@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
...
@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
org.apache.ibatis.type.BlobTypeHandler
;
import
org.apache.ibatis.type.BlobTypeHandler
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
/**
* <p>
* <p>
* 诱导屏-发布模板
* 诱导屏-发布模板
...
@@ -97,5 +97,21 @@ public class InduceTemplate implements Serializable {
...
@@ -97,5 +97,21 @@ public class InduceTemplate implements Serializable {
@TableField
(
"gmt_modified"
)
@TableField
(
"gmt_modified"
)
private
Date
gmtModified
;
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 @
275e5985
...
@@ -115,8 +115,8 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -115,8 +115,8 @@ public class InduceSendServiceImpl implements InduceSendService {
int
bottomRightX
=
Integer
.
parseInt
(
bottomRight
[
0
]);
int
bottomRightX
=
Integer
.
parseInt
(
bottomRight
[
0
]);
int
bottomRightY
=
Integer
.
parseInt
(
bottomRight
[
1
]);
int
bottomRightY
=
Integer
.
parseInt
(
bottomRight
[
1
]);
// 图片生成操作
// 图片生成操作
boolean
upDown
=
param
.
getContents
()[
0
].
contains
(
"▲"
)
||
param
.
getContents
()[
0
].
contains
(
"▼"
);
//
boolean upDown = param.getContents()[0].contains("▲") || param.getContents()[0].contains("▼");
createImageWithText
(
induceTemplate
,
image
,
param
.
getContents
(),
upDown
,
topLeftX
,
topLeftY
,
bottomRightX
,
bottomRightY
);
createImageWithText
(
induceTemplate
,
image
,
param
.
getContents
(),
true
,
topLeftX
,
topLeftY
,
bottomRightX
,
bottomRightY
);
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
log
.
error
(
ex
.
getMessage
());
...
@@ -136,6 +136,8 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -136,6 +136,8 @@ public class InduceSendServiceImpl implements InduceSendService {
greenwaveinduces
.
setSourceId
(
PATH
+
dirName
+
"/"
+
fileName
);
greenwaveinduces
.
setSourceId
(
PATH
+
dirName
+
"/"
+
fileName
);
}
}
log
.
info
(
"上传文件至ftp-filePath:{}"
,
param
.
getFtpPath
());
log
.
info
(
"上传文件至ftp-filePath:{}"
,
param
.
getFtpPath
());
induceTemplateService
.
updateById
(
induceTemplate
);
}
}
// //如果已发布,则调用下屏服务
// //如果已发布,则调用下屏服务
// if(greenwaveinduces.getStatus()==1){
// if(greenwaveinduces.getStatus()==1){
...
@@ -287,15 +289,6 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -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 {
...
@@ -304,7 +297,7 @@ public class InduceSendServiceImpl implements InduceSendService {
* @param width 绘制区域宽度
* @param width 绘制区域宽度
* @param height 绘制区域高度
* @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
);
Font
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
1
);
g2d
.
setFont
(
font
);
g2d
.
setFont
(
font
);
...
@@ -317,26 +310,29 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -317,26 +310,29 @@ public class InduceSendServiceImpl implements InduceSendService {
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
fontSize
);
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
fontSize
);
g2d
.
setFont
(
font
);
g2d
.
setFont
(
font
);
metrics
=
g2d
.
getFontMetrics
();
metrics
=
g2d
.
getFontMetrics
();
drawParam
.
setTextSize
(
fontSize
);
// 确保绘制区域能够容纳文本,考虑字体长度和高度
// 确保绘制区域能够容纳文本,考虑字体长度和高度
// if (drawParam.getTextDirection()) {
if
(
true
)
{
// // 高度考虑上下边距
// 高度只考虑上边距
// if (metrics.stringWidth(contents[0]) > width || (metrics.getHeight() - 4) > height) {
if
(
metrics
.
stringWidth
(
contents
[
0
])
>
width
||
(
metrics
.
getHeight
()
-
4
)
>
height
)
{
// // 设置字体大小
// 设置字体大小
// font = new Font(drawParam.getTextFont(), Font.BOLD, --fontSize);
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
--
fontSize
);
// g2d.setFont(font);
g2d
.
setFont
(
font
);
// metrics = g2d.getFontMetrics();
metrics
=
g2d
.
getFontMetrics
();
// return metrics;
drawParam
.
setTextSize
(
fontSize
);
// }
return
metrics
;
// } else {
}
}
else
{
// 高度只考虑上边距
// 高度只考虑上边距
if
(
metrics
.
stringWidth
(
contents
[
0
])
>
width
||
(
metrics
.
getHeight
()
-
1
)
*
contents
.
length
>
height
)
{
if
(
metrics
.
stringWidth
(
contents
[
0
])
>
width
||
(
metrics
.
getHeight
()
-
1
)
*
contents
.
length
>
height
)
{
// 设置字体大小
// 设置字体大小
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
--
fontSize
);
font
=
new
Font
(
drawParam
.
getTextFont
(),
Font
.
BOLD
,
--
fontSize
);
g2d
.
setFont
(
font
);
g2d
.
setFont
(
font
);
metrics
=
g2d
.
getFontMetrics
();
metrics
=
g2d
.
getFontMetrics
();
drawParam
.
setTextSize
(
fontSize
);
return
metrics
;
return
metrics
;
}
}
//
}
}
}
}
// 若字体大小超出限制,则返回最小字体
// 若字体大小超出限制,则返回最小字体
return
metrics
;
return
metrics
;
...
@@ -347,7 +343,6 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -347,7 +343,6 @@ public class InduceSendServiceImpl implements InduceSendService {
*
*
* @param image 图片
* @param image 图片
* @param text 内容数组
* @param text 内容数组
* @param sign 绘制方向
* @param topLeftX 区域左上角x坐标
* @param topLeftX 区域左上角x坐标
* @param topLeftY 区域左上角y坐标
* @param topLeftY 区域左上角y坐标
* @param bottomRightX 区域右下角x坐标
* @param bottomRightX 区域右下角x坐标
...
@@ -364,7 +359,7 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -364,7 +359,7 @@ public class InduceSendServiceImpl implements InduceSendService {
int
width
=
bottomRightX
-
topLeftX
;
int
width
=
bottomRightX
-
topLeftX
;
int
height
=
bottomRightY
-
topLeftY
;
int
height
=
bottomRightY
-
topLeftY
;
// 动态调整字体大小,以适应文本区域
// 动态调整字体大小,以适应文本区域
FontMetrics
metrics
=
autoFont
(
g2d
,
pictureFile
,
text
,
width
,
height
);
FontMetrics
metrics
=
autoFont
(
g2d
,
pictureFile
,
text
,
width
,
height
);
// 绘制坐标点
// 绘制坐标点
int
textWidth
;
int
textWidth
;
// 考虑文字绘制方向、文字居中。垂直居中要根据文字高度,水平居中要根据文字宽度。
// 考虑文字绘制方向、文字居中。垂直居中要根据文字高度,水平居中要根据文字宽度。
...
@@ -385,6 +380,7 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -385,6 +380,7 @@ public class InduceSendServiceImpl implements InduceSendService {
currentX
=
topLeftX
+
(
width
-
textWidth
)
/
2
;
currentX
=
topLeftX
+
(
width
-
textWidth
)
/
2
;
// 计算居中的y坐标
// 计算居中的y坐标
currentY
=
currentY
+
(
height
-
metrics
.
getHeight
())
/
2
;
currentY
=
currentY
+
(
height
-
metrics
.
getHeight
())
/
2
;
textSend
(
pictureFile
,
text
,
g2d
,
2
,
currentY
);
g2d
.
drawString
(
text
[
0
],
currentX
,
currentY
);
g2d
.
drawString
(
text
[
0
],
currentX
,
currentY
);
}
else
{
}
else
{
// 计算每个文本内容的竖向绘制坐标
// 计算每个文本内容的竖向绘制坐标
...
@@ -404,6 +400,41 @@ public class InduceSendServiceImpl implements InduceSendService {
...
@@ -404,6 +400,41 @@ public class InduceSendServiceImpl implements InduceSendService {
g2d
.
dispose
();
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 @
275e5985
package
net
.
wanji
.
opt
.
task
;
package
net
.
wanji
.
opt
.
task
;
import
com.alibaba.druid.support.json.JSONUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
@@ -12,7 +11,6 @@ import net.wanji.common.utils.tool.DateUtil;
...
@@ -12,7 +11,6 @@ import net.wanji.common.utils.tool.DateUtil;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.common.utils.tool.JacksonUtils
;
import
net.wanji.common.utils.tool.StringUtils
;
import
net.wanji.common.utils.tool.StringUtils
;
import
net.wanji.databus.dao.entity.GreenwaveCrossPO
;
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.entity.GreenwaveInfoPO
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
import
net.wanji.databus.dao.mapper.CrossDataRealtimeMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveCrossMapper
;
import
net.wanji.databus.dao.mapper.GreenwaveCrossMapper
;
...
@@ -32,7 +30,6 @@ import net.wanji.opt.service.induce.InduceTemplateService;
...
@@ -32,7 +30,6 @@ import net.wanji.opt.service.induce.InduceTemplateService;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyControlDetailList
;
import
net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyDailyPlanInfoEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity
;
import
net.wanji.opt.synthesis.pojo.StrategyPlanInfoEntity
;
import
net.wanji.opt.vo.GreenBeltInfoVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -196,10 +193,10 @@ public class InducesMonitorTask {
...
@@ -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
(
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
())
{
if
(
greenwaveInducesHist
.
getMinSpeed
()
>
greenOptHistEntity
.
getMinSpeed
()
||
greenwaveInducesHist
.
getMaxSpeed
()
>
greenOptHistEntity
.
getMaxSpeed
())
{
upDown
=
"
▼
"
;
upDown
=
""
;
}
}
if
(
greenwaveInducesHist
.
getMinSpeed
()
<
greenOptHistEntity
.
getMinSpeed
()
||
greenwaveInducesHist
.
getMaxSpeed
()
<
greenOptHistEntity
.
getMaxSpeed
())
{
if
(
greenwaveInducesHist
.
getMinSpeed
()
<
greenOptHistEntity
.
getMinSpeed
()
||
greenwaveInducesHist
.
getMaxSpeed
()
<
greenOptHistEntity
.
getMaxSpeed
())
{
upDown
=
"
▲
"
;
upDown
=
""
;
}
}
}
}
greenwaveInducesHist
.
setMinSpeed
(
greenOptHistEntity
.
getMinSpeed
());
greenwaveInducesHist
.
setMinSpeed
(
greenOptHistEntity
.
getMinSpeed
());
...
@@ -219,7 +216,7 @@ public class InducesMonitorTask {
...
@@ -219,7 +216,7 @@ public class InducesMonitorTask {
messageParam
.
setFlg
(
1
);
messageParam
.
setFlg
(
1
);
messageParam
.
setGreenId
(
greenwaveInfoPO
.
getId
());
messageParam
.
setGreenId
(
greenwaveInfoPO
.
getId
());
messageParam
.
setContents
(
new
String
[]{(
upDown
+
(
Objects
.
nonNull
(
greenOptHistEntity
.
getMinSpeed
())
?
greenOptHistEntity
.
getMinSpeed
().
intValue
()
+
"-"
:
""
)
+
(
Objects
.
nonNull
(
greenOptHistEntity
.
getMaxSpeed
())
?
greenOptHistEntity
.
getMaxSpeed
().
intValue
()
:
""
))
+
"km/h"
});
messageParam
.
setContents
(
new
String
[]{(
upDown
+
(
Objects
.
nonNull
(
greenOptHistEntity
.
getMinSpeed
())
?
greenOptHistEntity
.
getMinSpeed
().
intValue
()
+
"-"
:
""
)
+
(
Objects
.
nonNull
(
greenOptHistEntity
.
getMaxSpeed
())
?
greenOptHistEntity
.
getMaxSpeed
().
intValue
()
:
""
))
+
"
km/h"
});
messageParam
.
setType
(
"TFMH"
);
messageParam
.
setType
(
"TFMH"
);
try
{
try
{
if
(
greenwaveInducesHist
.
getStatus
()
==
0
||
greenwaveInducesHist
.
getModifyTime
().
before
(
greenOptHistEntity
.
getCreateTime
()))
{
if
(
greenwaveInducesHist
.
getStatus
()
==
0
||
greenwaveInducesHist
.
getModifyTime
().
before
(
greenOptHistEntity
.
getCreateTime
()))
{
...
...
signal-optimize-service/src/main/resources/mapper/GreenwaveHistMapper.xml
View file @
275e5985
...
@@ -191,6 +191,9 @@
...
@@ -191,6 +191,9 @@
#{item}
#{item}
</foreach>
</foreach>
</if>
</if>
<if
test=
"crossId !=null and crossId !=''"
>
and cross_id = #{crossId}
</if>
GROUP BY type
GROUP BY type
</select>
</select>
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/common/HisenseTurnEnum.java
View file @
275e5985
...
@@ -24,9 +24,9 @@ public enum HisenseTurnEnum {
...
@@ -24,9 +24,9 @@ public enum HisenseTurnEnum {
TURN_8
(
8
,
6
,
"直右"
),
TURN_8
(
8
,
6
,
"直右"
),
TURN_9
(
9
,
7
,
"左直右"
),
TURN_9
(
9
,
7
,
"左直右"
),
TURN_10
(
10
,
10
,
"直调头"
),
TURN_10
(
10
,
10
,
"直调头"
),
TURN_11
(
11
,
0
,
"入口行人"
),
TURN_11
(
11
,
21
,
"入口行人"
),
TURN_12
(
12
,
0
,
"出口行人"
),
TURN_12
(
12
,
22
,
"出口行人"
),
TURN_13
(
13
,
0
,
"出入口行人"
),
TURN_13
(
13
,
2
0
,
"出入口行人"
),
TURN_14
(
14
,
12
,
"左直调头"
),
TURN_14
(
14
,
12
,
"左直调头"
),
TURN_15
(
15
,
11
,
"右调头"
),
TURN_15
(
15
,
11
,
"右调头"
),
TURN_16
(
16
,
15
,
"左右调头"
),
TURN_16
(
16
,
15
,
"左右调头"
),
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/impl/ControlCommandServiceImpl.java
View file @
275e5985
...
@@ -93,7 +93,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -93,7 +93,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
}
//相位驻留
//相位驻留
String
xmlPost
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
String
xmlPost
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
/*
String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
/*
String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
" <messageType>12</messageType>\n" +
...
@@ -117,7 +117,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -117,7 +117,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
if
(
commandVO
.
getCommand
()
==
1
){
if
(
commandVO
.
getCommand
()
==
1
){
Integer
duration
=
commandVO
.
getDuration
();
Integer
duration
=
commandVO
.
getDuration
();
Thread
.
sleep
(
duration
*
1000
);
Thread
.
sleep
(
duration
*
1000
);
messageContent
.
addElement
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
}
}
return
jsonViewObject
.
success
(
"相位锁定/解锁 - 控制成功"
);
return
jsonViewObject
.
success
(
"相位锁定/解锁 - 控制成功"
);
...
@@ -147,7 +147,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -147,7 +147,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
if
(
command
==
0
)
{
if
(
command
==
0
)
{
//取消步进
//取消步进
long
start
=
System
.
currentTimeMillis
();
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
long
end
=
System
.
currentTimeMillis
();
log
.
info
(
"取消步进 耗时: {} ms"
,
end
-
start
);
// boolean isOk = true;
// boolean isOk = true;
if
(
isOk
)
{
if
(
isOk
)
{
return
jsonViewObject
.
success
(
"取消步进 - 控制成功"
);
return
jsonViewObject
.
success
(
"取消步进 - 控制成功"
);
...
@@ -157,7 +160,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -157,7 +160,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
else
if
(
command
==
1
)
{
}
else
if
(
command
==
1
)
{
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//相位驻留
//相位驻留
long
start
=
System
.
currentTimeMillis
();
String
xmlPost
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
String
xmlPost
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
long
end
=
System
.
currentTimeMillis
();
log
.
info
(
"相位驻留 耗时: {} ms"
,
end
-
start
);
/*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
/*String xmlPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <subSystem>Hisense</subSystem>\n" +
...
@@ -183,7 +189,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -183,7 +189,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
//开始步进
//开始步进
//给海信发送http请求
//给海信发送http请求
for
(
int
i
=
0
;
i
<
stepNum
;
i
++)
{
for
(
int
i
=
0
;
i
<
stepNum
;
i
++)
{
long
s
=
System
.
currentTimeMillis
();
String
post
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
String
post
=
OkHttpClientUtil
.
xmlPost
(
hisenseUrl
,
document
.
asXML
());
long
e
=
System
.
currentTimeMillis
();
log
.
info
(
"相位步进 耗时: {} ms"
,
e
-
s
);
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
/*String post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
" <subSystem>Hisense</subSystem>\n" +
...
@@ -210,7 +219,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -210,7 +219,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log
.
error
(
"路口号 :{},第 {} 次步进失败,result:{}"
,
code
,
i
+
1
,
result
);
log
.
error
(
"路口号 :{},第 {} 次步进失败,result:{}"
,
code
,
i
+
1
,
result
);
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
//取消步进
//取消步进
long
s1
=
System
.
currentTimeMillis
();
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
long
e1
=
System
.
currentTimeMillis
();
log
.
info
(
"取消 相位步进 耗时: {} ms"
,
e1
-
s1
);
// boolean isOk = true;
// boolean isOk = true;
if
(
isOk
)
{
if
(
isOk
)
{
return
jsonViewObject
.
fail
(
"相位步进失败,取消步进成功,路口号: "
+
code
);
return
jsonViewObject
.
fail
(
"相位步进失败,取消步进成功,路口号: "
+
code
);
...
@@ -223,7 +237,11 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -223,7 +237,11 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
else
{
}
else
{
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
//取消步进
//取消步进
long
s1
=
System
.
currentTimeMillis
();
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
long
e1
=
System
.
currentTimeMillis
();
log
.
info
(
"取消 相位步进 耗时: {} ms"
,
e1
-
s1
);
// boolean isOk = true;
// boolean isOk = true;
if
(
isOk
)
{
if
(
isOk
)
{
return
jsonViewObject
.
fail
(
"相位步进失败,取消步进成功,路口号: "
+
code
);
return
jsonViewObject
.
fail
(
"相位步进失败,取消步进成功,路口号: "
+
code
);
...
@@ -234,9 +252,14 @@ public class ControlCommandServiceImpl implements ControlCommandService {
...
@@ -234,9 +252,14 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
}
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
messageContent
.
selectSingleNode
(
HttpConstants
.
COMMAND
).
setText
(
"0"
);
System
.
out
.
println
(
document
.
asXML
());
//取消步进
//取消步进
boolean
isOk
=
sendMesIsOk
(
document
.
asXML
());
long
s1
=
System
.
currentTimeMillis
();
// boolean isOk = true;
// boolean isOk = sendMesIsOk(document.asXML());
long
e1
=
System
.
currentTimeMillis
();
log
.
info
(
"取消 相位步进 耗时: {} ms"
,
e1
-
s1
);
boolean
isOk
=
true
;
if
(
isOk
)
{
if
(
isOk
)
{
return
jsonViewObject
.
success
(
"相位步进成功,,路口号: "
+
code
);
return
jsonViewObject
.
success
(
"相位步进成功,,路口号: "
+
code
);
}
else
{
}
else
{
...
...
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