Compare commits

2 Commits

7 changed files with 7 additions and 21 deletions

View File

@ -166,13 +166,10 @@ public class AppDeviceBizService {
} }
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX + item.getDeviceImei()); String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX + item.getDeviceImei());
// 获取电量
if(StringUtils.isNotBlank(location)){ if(StringUtils.isNotBlank(location)){
JSONObject jsonObject = JSONObject.parseObject(location); JSONObject jsonObject = JSONObject.parseObject(location);
item.setLatitude(jsonObject.getString("latitude")); item.setLatitude(jsonObject.getString("latitude"));
item.setLongitude(jsonObject.getString("longitude")); item.setLongitude(jsonObject.getString("longitude"));
}else{
item.setBattery("0");
} }
} }
}); });

View File

@ -4,12 +4,6 @@ import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders; import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Header;
/**
* @Author: HarryLin
* @Date: 2025/3/20 17:06
* @Company: 北京红山信息科技研究院有限公司
* @Email: linyun@***.com.cn
**/
@MessagingGateway(defaultRequestChannel = "mqttOutboundChannel") @MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
public interface MqttGateway { public interface MqttGateway {
public abstract void sendMsgToMqtt(@Header(value = MqttHeaders.TOPIC) String topic, String payload); public abstract void sendMsgToMqtt(@Header(value = MqttHeaders.TOPIC) String topic, String payload);

View File

@ -6,12 +6,7 @@ import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/**
* @Author: HarryLin
* @Date: 2025/3/20 16:16
* @Company: 北京红山信息科技研究院有限公司
* @Email: linyun@***.com.cn
**/
@Service @Service
public class MqttMessageSender { public class MqttMessageSender {
@Autowired @Autowired

View File

@ -51,7 +51,7 @@ public class DeviceBootLogoRule implements MqttMessageRule {
byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data); byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data);
byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512); byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512);
System.out.println("" + val2 + "块数据大小: " + specificChunk.length + " 字节"); log.info("第{}块数据大小: {} 字节", val2, specificChunk.length);
// System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk)); // System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk));
ArrayList<Integer> intData = new ArrayList<>(); ArrayList<Integer> intData = new ArrayList<>();

View File

@ -50,7 +50,7 @@ public class DeviceSendMessageRule implements MqttMessageRule {
byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data); byte[] arr = ImageToCArrayConverter.convertStringToByteArray(data);
byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512); byte[] specificChunk = ImageToCArrayConverter.getChunk(arr, (val2 - 1), 512);
System.out.println("" + val2 + "块数据大小: " + specificChunk.length + " 字节"); log.info("第{}块数据大小: {} 字节", val2, specificChunk.length);
// System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk)); // System.out.println("第" + val2 + "块数据: " + Arrays.toString(specificChunk));
ArrayList<Integer> intData = new ArrayList<>(); ArrayList<Integer> intData = new ArrayList<>();

View File

@ -181,7 +181,7 @@ public class LocationDataRule implements MqttMessageRule {
// RedisUtils.expire(trajectoryKey, Duration.ofDays(30)); // RedisUtils.expire(trajectoryKey, Duration.ofDays(30));
// 清理30天前的数据冗余保护 // 清理30天前的数据冗余保护
long thirtyDaysAgo = System.currentTimeMillis() - (90L * 24 * 60 * 60 * 1000); long thirtyDaysAgo = System.currentTimeMillis() - (7L * 24 * 60 * 60 * 1000);
RedisUtils.zRemoveRangeByScore(trajectoryKey, 0, thirtyDaysAgo); RedisUtils.zRemoveRangeByScore(trajectoryKey, 0, thirtyDaysAgo);
} catch (Exception e) { } catch (Exception e) {
log.error("存储设备轨迹到Redis(ZSet)失败: device={}, error={}", deviceImei, e.getMessage(), e); log.error("存储设备轨迹到Redis(ZSet)失败: device={}, error={}", deviceImei, e.getMessage(), e);

View File

@ -107,7 +107,7 @@ spring.data:
# 数据库索引 # 数据库索引
database: 1 database: 1
# redis 密码必须配置 # redis 密码必须配置
password: re_fs_11520631 password: xhYc_djkl382^#780!
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
# 是否开启ssl # 是否开启ssl
@ -280,8 +280,8 @@ mqtt:
password: #YtvpSfCNG password: #YtvpSfCNG
url: tcp://47.120.79.150:2883 url: tcp://47.120.79.150:2883
subClientId: fys_subClient subClientId: fys_subClient
subTopic: worker/alert/#,worker/location/# subTopic: A/#,B/#,worker/location/#
pubTopic: worker/location pubTopic: B/#
pubClientId: fys_pubClient pubClientId: fys_pubClient