Commit 53fd44f1 authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

parents b5784924 4f707812
......@@ -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;
}
......@@ -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]);
}
}
}
/**
* 在指定位置添加文字到图像
*
......
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());
......
......@@ -24,9 +24,9 @@ public enum HisenseTurnEnum {
TURN_8(8, 6, "直右"),
TURN_9(9, 7, "左直右"),
TURN_10(10, 10, "直调头"),
TURN_11(11, 0, "入口行人"),
TURN_12(12, 0, "出口行人"),
TURN_13(13, 0, "出入口行人"),
TURN_11(11, 21, "入口行人"),
TURN_12(12, 22, "出口行人"),
TURN_13(13, 20, "出入口行人"),
TURN_14(14, 12, "左直调头"),
TURN_15(15, 11, "右调头"),
TURN_16(16, 15, "左右调头"),
......
......@@ -93,7 +93,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
//相位驻留
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" +
" <subSystem>Hisense</subSystem>\n" +
" <messageType>12</messageType>\n" +
......@@ -117,7 +117,7 @@ public class ControlCommandServiceImpl implements ControlCommandService {
if (commandVO.getCommand() == 1){
Integer duration = commandVO.getDuration();
Thread.sleep(duration * 1000);
messageContent.addElement(HttpConstants.COMMAND).setText("0");
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
OkHttpClientUtil.xmlPost(hisenseUrl, document.asXML());
}
return jsonViewObject.success("相位锁定/解锁 - 控制成功");
......@@ -147,7 +147,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
if (command == 0) {
//取消步进
long start = System.currentTimeMillis();
boolean isOk = sendMesIsOk(document.asXML());
long end = System.currentTimeMillis();
log.info("取消步进 耗时: {} ms", end - start);
// boolean isOk = true;
if (isOk) {
return jsonViewObject.success("取消步进 - 控制成功");
......@@ -157,7 +160,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
} else if (command == 1) {
//逻辑:第一次发送步进指令是相位驻留,以后发送才是相位步进,步进成功则取消步进。步进失败,也立即下发取消步进控制
//相位驻留
long start = System.currentTimeMillis();
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" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
......@@ -183,7 +189,10 @@ public class ControlCommandServiceImpl implements ControlCommandService {
//开始步进
//给海信发送http请求
for (int i = 0; i < stepNum; i++) {
long s = System.currentTimeMillis();
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" +
"<systemScription System=\"TCIP\" Version=\"1.0\">\n" +
" <subSystem>Hisense</subSystem>\n" +
......@@ -210,7 +219,12 @@ public class ControlCommandServiceImpl implements ControlCommandService {
log.error("路口号 :{},第 {} 次步进失败,result:{}", code, i + 1, result);
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
long s1 = System.currentTimeMillis();
boolean isOk = sendMesIsOk(document.asXML());
long e1 = System.currentTimeMillis();
log.info("取消 相位步进 耗时: {} ms", e1 - s1);
// boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + code);
......@@ -223,7 +237,11 @@ public class ControlCommandServiceImpl implements ControlCommandService {
} else {
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
//取消步进
long s1 = System.currentTimeMillis();
boolean isOk = sendMesIsOk(document.asXML());
long e1 = System.currentTimeMillis();
log.info("取消 相位步进 耗时: {} ms", e1 - s1);
// boolean isOk = true;
if (isOk) {
return jsonViewObject.fail("相位步进失败,取消步进成功,路口号: " + code);
......@@ -234,9 +252,14 @@ public class ControlCommandServiceImpl implements ControlCommandService {
}
messageContent.selectSingleNode(HttpConstants.COMMAND).setText("0");
System.out.println(document.asXML());
//取消步进
boolean isOk = sendMesIsOk(document.asXML());
// boolean isOk = true;
long s1 = System.currentTimeMillis();
// boolean isOk = sendMesIsOk(document.asXML());
long e1 = System.currentTimeMillis();
log.info("取消 相位步进 耗时: {} ms", e1 - s1);
boolean isOk = true;
if (isOk) {
return jsonViewObject.success("相位步进成功,,路口号: " + code);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment