晶全日志配置
This commit is contained in:
@ -94,6 +94,30 @@ public class DeviceReceiverMessageHandler implements MessageHandler {
|
||||
record.setDataSource("客户端操作");
|
||||
}
|
||||
}
|
||||
// 确保在插入前设置tenantId和deviceId
|
||||
record.setTenantId(device.getTenantId());
|
||||
record.setDeviceId(device.getId());
|
||||
deviceLogMapper.insert(record);
|
||||
}
|
||||
|
||||
// 2. 处理 state 消息
|
||||
if (root.has("state")) {
|
||||
JsonNode instructNode = root.get("state");
|
||||
if (instructNode.isArray()) {
|
||||
boolean b = receivedTopicName.startsWith("B/");
|
||||
record = parseState(device, instructNode, b);
|
||||
// 根据不同主题进行不同处理
|
||||
if (receivedTopicName.startsWith("A/")) {
|
||||
// 处理A主题的消息(设备上传)
|
||||
record.setDataSource("设备上报");
|
||||
} else if (receivedTopicName.startsWith("B/")) {
|
||||
// 处理B主题的消息 (手动上传)
|
||||
record.setDataSource("客户端操作");
|
||||
}
|
||||
}
|
||||
// 确保在插入前设置tenantId和deviceId
|
||||
record.setTenantId(device.getTenantId());
|
||||
record.setDeviceId(device.getId());
|
||||
deviceLogMapper.insert(record);
|
||||
}
|
||||
|
||||
@ -102,6 +126,9 @@ public class DeviceReceiverMessageHandler implements MessageHandler {
|
||||
record.setDeviceAction(InstructType6170.fromCode(0).getDescription());
|
||||
record.setDataSource("设备上报");
|
||||
record.setContent("设备启动");
|
||||
// 确保在插入前设置tenantId和deviceId
|
||||
record.setTenantId(device.getTenantId());
|
||||
record.setDeviceId(device.getId());
|
||||
deviceLogMapper.insert(record);
|
||||
}
|
||||
|
||||
@ -217,54 +244,75 @@ public class DeviceReceiverMessageHandler implements MessageHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 解析state消息
|
||||
* 解析 state 消息
|
||||
*
|
||||
* @param device
|
||||
* @param array
|
||||
* @return
|
||||
*/
|
||||
// private StateRecord parseState(Device device, JsonNode array) {
|
||||
// StateRecord record = new StateRecord();
|
||||
// record.setDevice(device);
|
||||
// record.setStateType(array.get(0).asInt());
|
||||
//
|
||||
// switch (record.getStateType()) {
|
||||
// case 1: // 灯光状态
|
||||
// record.setLightMode(array.get(1).asInt());
|
||||
// record.setBrightness(array.get(2).asInt());
|
||||
// break;
|
||||
//
|
||||
// case 2: // 设置结果
|
||||
// record.setSetResult(array.get(1).asInt() == 1);
|
||||
// break;
|
||||
//
|
||||
// case 3: // 图片更新状态
|
||||
// record.setImagePage(array.get(1).asInt());
|
||||
// break;
|
||||
//
|
||||
// case 4: // 激光灯状态
|
||||
// record.setLaserStatus(array.get(1).asInt() == 1);
|
||||
// break;
|
||||
//
|
||||
// case 5: // 亮度状态
|
||||
// record.setBrightness(array.get(1).asInt());
|
||||
// break;
|
||||
//
|
||||
// case 11: // 定位上报
|
||||
// record.setLatitude(array.get(1).asDouble());
|
||||
// record.setLongitude(array.get(2).asDouble());
|
||||
// break;
|
||||
//
|
||||
// case 12: // 设备状态
|
||||
// record.setMainLightGear(array.get(1).asInt());
|
||||
// record.setLaserLightGear(array.get(2).asInt());
|
||||
// record.setBattery(array.get(3).asInt());
|
||||
// record.setChargeStatus(array.get(4).asInt());
|
||||
// record.setDuration(array.get(5).asInt());
|
||||
// break;
|
||||
// }
|
||||
// return record;
|
||||
// }
|
||||
private DeviceLog parseState(Device device, JsonNode array, boolean b) {
|
||||
DeviceLog record = new DeviceLog();
|
||||
record.setDeviceName(device.getDeviceName());
|
||||
// 设备行为
|
||||
record.setDeviceAction(InstructType6170.fromCode(array.get(0).asInt()).getDescription());
|
||||
|
||||
switch (array.get(0).asInt()) {
|
||||
case 1: // 灯光模式
|
||||
LightModeEnum6170 lightModeEnum6170 = LightModeEnum6170.fromCode(array.get(1).asInt());
|
||||
record.setContent(lightModeEnum6170.getDescription());
|
||||
break;
|
||||
|
||||
case 2: // 单位/姓名/职位
|
||||
byte[] unitBytes = new byte[480];
|
||||
for (int i = 1; i <= 480; i++) {
|
||||
unitBytes[i - 1] = (byte) array.get(i).asInt();
|
||||
}
|
||||
// record.setUnitData(unitBytes);
|
||||
break;
|
||||
|
||||
case 3: // 开机图片
|
||||
// record.setImagePage(array.get(1).asInt());
|
||||
byte[] imageBytes = new byte[512];
|
||||
for (int i = 2; i <= 513; i++) {
|
||||
imageBytes[i - 2] = (byte) array.get(i).asInt();
|
||||
}
|
||||
// record.setImageData(imageBytes);
|
||||
break;
|
||||
|
||||
case 4: // 激光灯
|
||||
int anInt = array.get(1).asInt();
|
||||
if (anInt == 0) {
|
||||
record.setContent("关闭激光灯");
|
||||
} else if (anInt == 1) {
|
||||
record.setContent("开启激光灯");
|
||||
} else {
|
||||
record.setContent("未知操作");
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: // 亮度调节
|
||||
record.setContent(+array.get(1).asInt() + "%");
|
||||
break;
|
||||
|
||||
case 11: // 定位数据
|
||||
if (b) {
|
||||
break;
|
||||
}
|
||||
int i1 = array.get(1).asInt();
|
||||
int i2 = array.get(2).asInt();
|
||||
int i3 = array.get(3).asInt();
|
||||
int i4 = array.get(4).asInt();
|
||||
|
||||
// 优雅的转换方式 Longitude and latitude
|
||||
double latitude = i1 + i2 / 10.0;
|
||||
double Longitude = i3 + i4 / 10.0;
|
||||
// 84 ==》 高德
|
||||
double[] doubles = LngLonUtil.gps84_To_Gcj02(latitude, Longitude);
|
||||
String address = GetAddressFromLatUtil.getAdd(String.valueOf(doubles[1]), String.valueOf(doubles[0]));
|
||||
record.setContent(address);
|
||||
break;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
|
@ -64,7 +64,7 @@ spring:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: @profiles.active@
|
||||
active: ${profiles.active}
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
|
Reference in New Issue
Block a user