优化绘图逻辑,补充接口逻辑等

This commit is contained in:
mi9688 2024-12-11 18:04:18 +08:00
parent 73042e17af
commit f9c7354301
5 changed files with 54 additions and 21 deletions

View File

@ -2,7 +2,6 @@ package com.fastbee.data.controller.printer;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.core.domain.AjaxResultPro;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.data.controller.printer.yilianyun.GenerateQRCodeImage;
import com.fastbee.data.controller.printer.yilianyun.YiLianYunPrintService;

View File

@ -1,5 +1,6 @@
package com.fastbee.data.controller.printer.yilianyun;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
@ -53,25 +54,56 @@ public class GenerateQRCodeImage {
g2d.fillRect(0, 0, imageWidth, imageHeight);
// 绘制二维码
g2d.drawImage(qrCodeImage, 30, 0, qrCodeWidth, qrCodeHeight, null);
g2d.drawImage(qrCodeImage, 40, 0, qrCodeWidth, qrCodeHeight, null);
//绘制虚线矩形
Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{10}, 0);
g2d.setStroke(dashed);
// 设置颜色
g2d.setColor(Color.BLACK);
// 绘制虚线矩形
g2d.drawRect(70, 31, qrCodeImage.getWidth()-62, qrCodeImage.getHeight()-62);
// 绘制文字
g2d.setColor(Color.BLACK);
g2d.setFont(new Font("黑体", Font.BOLD, 18));
String text1 = "设备:"+deviceName;
g2d.setFont(new Font("黑体", Font.BOLD, 20));
String text1 = deviceName;
FontMetrics fontMetrics = g2d.getFontMetrics();
int textX = qrCodeWidth+5; // 间距20像素
int textY1 = (imageHeight - fontMetrics.getHeight()) / 2 + fontMetrics.getAscent()-40;
int textX = qrCodeWidth+15; // 间距20像素
int textY1 = (imageHeight - fontMetrics.getHeight()) / 2 + fontMetrics.getAscent()-65;
g2d.drawString(text1, textX, textY1);
// 绘制第二段文字
String text2 = "编码:"+deviceCode;
int textY2 = textY1 + fontMetrics.getHeight() + 20; // 在第一段文字下方添加一些间距
String text2 = "◉ 系列:"+"RF500780E";
g2d.setFont(new Font("Dialog", Font.BOLD, 18));
int textY2 = textY1 + fontMetrics.getHeight() + 10; // 在第一段文字下方添加一些间距
g2d.drawString(text2, textX, textY2);
// 绘制第三段文字
String text3 = ""+companyName;
int textY3 = textY2 + fontMetrics.getHeight() + 20; // 在第一段文字下方添加一些间距
String text3 = "◉ 型号:" + "RF500 780E";
int textY3 = textY2 + fontMetrics.getHeight() + 10; // 在第一段文字下方添加一些间距
g2d.drawString(text3, textX, textY3);
//绘制第三段文字
String text4 = "◉ 批次:" + "RF500C齐测780";
int textY4 = textY3 + fontMetrics.getHeight() + 10; // 在第一段文字下方添加一些间距
g2d.drawString(text4, textX, textY4);
//绘制第五段文字
// 确保Graphics2D对象的当前颜色是黑色如果不是的话
g2d.setColor(Color.BLACK);
// 计算文本宽度和高度
String text5 =" SN:"+deviceCode+" ";
textWidth = fontMetrics.stringWidth(text5);
int textHeight = fontMetrics.getHeight();
// 计算矩形区域的X和Y坐标留出内边距
int rectX = textX; // 左内边距
int rectY = textY4+10; // 上内边距确保文本顶部与矩形内部有一定的空间
// 为了确保文本完全在矩形内我们可以稍微调整rectHeight
int rectHeight = textHeight + 10; // 文本高度加上上下内边距
// 绘制黑色背景矩形
g2d.fillRect(rectX, rectY, textWidth + 10, rectHeight);
// 设置Graphics2D对象的当前颜色为白色
g2d.setColor(Color.WHITE);
// 绘制第四段文字
int textY5 = textY4 + fontMetrics.getHeight() + 10; // 在前一段文字下方添加间距
g2d.drawString(text5, textX, textY5); // 绘制白色文本
// 释放Graphics2D资源
g2d.dispose();
@ -126,7 +158,7 @@ public class GenerateQRCodeImage {
}
public static void main(String[] args) {
String url = GenerateQRCodeImage.generateQRCodeUrl("测试水电双计设备001","FD7894455454545","山东翰臻物联公司");
String url = GenerateQRCodeImage.generateQRCodeUrl("测试水电双计设备001","FD78944554","山东翰臻物联公司");
System.err.println(url);
}
}

View File

@ -119,7 +119,7 @@ public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<Device
return rest;
}
devicePropertiesList.add(DeviceProperties.builder().name("空气温度").value(meteorology.getAirTemp().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("空气湿度").value(meteorology.getAirHumi().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("空气湿度").value(meteorology.getAirHumi().toString()).unit("%").build());
devicePropertiesList.add(DeviceProperties.builder().name("风速").value(meteorology.getWindSpeed().toString()).unit("m/s").build());
devicePropertiesList.add(DeviceProperties.builder().name("风向").value(meteorology.getWindDir().toString()).unit("°").build());
devicePropertiesList.add(DeviceProperties.builder().name("大气压力").value(meteorology.getAirPre().toString()).unit("hPa").build());
@ -130,11 +130,16 @@ public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<Device
devicePropertiesList.add(DeviceProperties.builder().name("日雨量").value(meteorology.getDayRain().toString()).unit("mm").build());
devicePropertiesList.add(DeviceProperties.builder().name("蒸发量").value(meteorology.getZhengfa().toString()).unit("t/h").build());
devicePropertiesList.add(DeviceProperties.builder().name("土壤温度").value(meteorology.getSoilTemp().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("土壤湿度").value(meteorology.getSoilHumi().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("土壤湿度").value(meteorology.getSoilHumi().toString()).unit("%").build());
Map<String,Object> info=new HashMap<>();
info.put("deviceEncoding", meteorology.getDeviceId());
rest.put("info",info);
return rest;
}
/**
* 风向数据映射
*/
}

View File

@ -124,9 +124,9 @@ public class DeviceRealtimedataMoistureServiceImpl extends ServiceImpl<DeviceRea
devicePropertiesList.add(DeviceProperties.builder().name("四层土壤湿度").value(moisture.getSoilHumi4().toString()).unit("%").build());
devicePropertiesList.add(DeviceProperties.builder().name("环境温度").value(moisture.getAirTemp().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("设备温度").value(moisture.getMppTemp().toString()).unit("%").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池电量").value(moisture.getBatteryCap().toString()).unit("MAh").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池电量").value(moisture.getBatteryCap().toString()).unit("mAh").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池电压").value(moisture.getBatteryVolt().toString()).unit("V").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池电流").value(moisture.getBatteryCur().toString()).unit("I").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池电流").value(moisture.getBatteryCur().toString()).unit("A").build());
devicePropertiesList.add(DeviceProperties.builder().name("电池功率").value(moisture.getBatteryPower().toString()).unit("W").build());
devicePropertiesList.add(DeviceProperties.builder().name("负载电压").value(moisture.getLoadVolt().toString()).unit("V").build());
devicePropertiesList.add(DeviceProperties.builder().name("负载电流").value(moisture.getLoadCur().toString()).unit("I").build());

View File

@ -635,12 +635,12 @@ public class ProjectServiceImpl implements IProjectService
//过滤一下不需要的数据
return Collections.singletonList(sysDistricts.get(0));
}
@Override
public List<Project> getProjectListByArea(Long areaCode) {
//查询全部项目列表
List<Project> projectAllList = new LambdaQueryChainWrapper<>(projectMapper)
.select(Project::getId, Project::getProjectName, Project::getAdministrativeAreaCode)
.select(Project::getId, Project::getProjectName, Project::getAdministrativeAreaCode,
Project::getTenantId,Project::getTenantName)
.list();
//根据行政区划过滤
System.err.println("项目行政区划代码列表:"+projectAllList.size());
@ -658,11 +658,8 @@ public class ProjectServiceImpl implements IProjectService
}
}
}
}
}
return projectFilterList;
}