app 修改bug
This commit is contained in:
@ -108,6 +108,9 @@ public class Device extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "绑定状态")
|
||||
private Integer bindingStatus;
|
||||
|
||||
@ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private Integer communicationMode;
|
||||
|
||||
|
||||
public void copy(Device source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.base.BaseEntity;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -100,6 +101,8 @@ public class APPDevice extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "绑定类型")
|
||||
private Integer bindingType;
|
||||
|
||||
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private String communicationMode;
|
||||
|
||||
public void copy(Device source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
@ -86,6 +86,7 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
|
||||
List<Device> devices = new ArrayList<>();
|
||||
|
||||
|
||||
if (criteria.getCommunicationMode().equals(CommunicationModeEnum.BLUETOOTH.getValue())) {
|
||||
devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_mac", criteria.getDeviceMac()));
|
||||
if (CollectionUtil.isEmpty(devices)) {
|
||||
@ -109,8 +110,9 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
throw new BadRequestException("该设备已绑定!!!");
|
||||
}
|
||||
}
|
||||
|
||||
Device device = devices.get(0);
|
||||
device.setCommunicationMode(criteria.getCommunicationMode());
|
||||
|
||||
device.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||
deviceMapper.updateById(device);
|
||||
|
||||
@ -171,6 +173,9 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
}
|
||||
queryWrapper.eq("binding_type", UserType.APP.getValue());
|
||||
APPDevice appDevice = appDeviceMapper.selectOne(queryWrapper);
|
||||
if (appDevice == null) {
|
||||
throw new BadRequestException("设备不存在!!!");
|
||||
}
|
||||
appDeviceMapper.delete(queryWrapper);
|
||||
|
||||
List<Device> devices = deviceMapper.selectList(qw);
|
||||
@ -186,5 +191,4 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
deviceMapper.updateById(device);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -149,11 +149,12 @@ file:
|
||||
logging:
|
||||
level:
|
||||
com.fuyuanshen: debug
|
||||
|
||||
# MQTT配置
|
||||
mqtt:
|
||||
username: admin
|
||||
password: fys123456
|
||||
url: tcp://127.0.0.1:1883
|
||||
url: tcp://47.107.152.87:1883
|
||||
subClientId: wuLang_subClient_01
|
||||
subTopic: worker/alert/#,worker/location/#
|
||||
pubTopic: worker/location
|
||||
|
@ -155,3 +155,14 @@ file:
|
||||
pic: /home/eladmin/app_avatar/ #设备图片存储路径
|
||||
#ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
ip: https://fuyuanshen.com/ #服务器地址
|
||||
|
||||
|
||||
# MQTT配置
|
||||
mqtt:
|
||||
username: admin
|
||||
password: fys123456
|
||||
url: tcp://47.107.152.87:1883
|
||||
subClientId: wuLang_subClient_01
|
||||
subTopic: worker/alert/#,worker/location/#
|
||||
pubTopic: worker/location
|
||||
pubClientId: wuLang_pubClient_01
|
@ -34,7 +34,7 @@ spring:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
# 激活的环境,如果需要 quartz 分布式支持,需要修改 active: dev,quartz
|
||||
active: dev
|
||||
active: prod
|
||||
data:
|
||||
redis:
|
||||
repositories:
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<!-- APP用户设备列表 -->
|
||||
<select id="appDeviceList" resultType="com.fuyuanshen.modules.system.domain.app.APPDevice">
|
||||
select d.* from app_device as d
|
||||
select d.* ,d.app_device_id AS id from app_device as d
|
||||
<where>
|
||||
<!-- 时间范围等其他条件保持原样 -->
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
@ -87,5 +87,4 @@
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,90 @@
|
||||
package com.fuyuanshen.utils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ImageToCArrayConverter {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
convertImageToCArray("C:\\work\\6170_强光_160_80_2.jpg", "output.c", 160, 80);
|
||||
System.out.println("转换成功!");
|
||||
} catch (IOException e) {
|
||||
System.err.println("转换失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void convertImageToCArray(String inputPath, String outputPath,
|
||||
int width, int height) throws IOException {
|
||||
// 读取原始图片
|
||||
BufferedImage originalImage = ImageIO.read(new File(inputPath));
|
||||
|
||||
// 调整图片尺寸
|
||||
BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
resizedImage.getGraphics().drawImage(
|
||||
originalImage, 0, 0, width, height, null);
|
||||
|
||||
// 转换像素数据为RGB565格式(高位在前)
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int rgb = resizedImage.getRGB(x, y);
|
||||
|
||||
// 提取RGB分量
|
||||
int r = (rgb >> 16) & 0xFF;
|
||||
int g = (rgb >> 8) & 0xFF;
|
||||
int b = rgb & 0xFF;
|
||||
|
||||
// 转换为RGB565(5位红,6位绿,5位蓝)
|
||||
int r5 = (r >> 3) & 0x1F;
|
||||
int g6 = (g >> 2) & 0x3F;
|
||||
int b5 = (b >> 3) & 0x1F;
|
||||
|
||||
// 组合为16位值
|
||||
int rgb565 = (r5 << 11) | (g6 << 5) | b5;
|
||||
|
||||
// 高位在前(大端序)写入字节
|
||||
byteStream.write((rgb565 >> 8) & 0xFF); // 高字节
|
||||
byteStream.write(rgb565 & 0xFF); // 低字节
|
||||
}
|
||||
}
|
||||
|
||||
byte[] imageData = byteStream.toByteArray();
|
||||
|
||||
// 生成C语言数组文件
|
||||
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
|
||||
// 写入注释行(包含尺寸信息)
|
||||
String header = String.format("/* 0X10,0X10,0X00,0X%02X,0X00,0X%02X,0X01,0X1B, */\n",
|
||||
width, height);
|
||||
fos.write(header.getBytes());
|
||||
|
||||
// 写入数组声明
|
||||
fos.write("const unsigned char gImage_data[] = {\n".getBytes());
|
||||
|
||||
// 写入数据(每行16个字节)
|
||||
for (int i = 0; i < imageData.length; i++) {
|
||||
// 写入0X前缀
|
||||
fos.write(("0X" + String.format("%02X", imageData[i] & 0xFF)).getBytes());
|
||||
|
||||
// 添加逗号(最后一个除外)
|
||||
if (i < imageData.length - 1) {
|
||||
fos.write(',');
|
||||
}
|
||||
|
||||
// 换行和缩进
|
||||
if ((i + 1) % 16 == 0) {
|
||||
fos.write('\n');
|
||||
} else {
|
||||
fos.write(' ');
|
||||
}
|
||||
}
|
||||
|
||||
// 写入数组结尾
|
||||
fos.write("\n};\n".getBytes());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user