宣城汇聚redis过期监听修改以及新添device_name

ds-xuancheng
luyya 2025-07-04 14:55:45 +08:00
parent 13f517251b
commit 13f78c74b0
5 changed files with 20 additions and 27 deletions

View File

@ -70,6 +70,8 @@ public class RemoteDeviceVo implements Serializable {
private String cardNum;
private String deviceName;
/**
* 01
*/

View File

@ -53,7 +53,7 @@ public class RedisExpireListener extends KeyExpirationEventMessageListener {
public void onMessage(Message message, byte[] pattern) {
String expireKey = message.toString();
if(StringUtils.isNotEmpty(expireKey) &&
expireKey.startsWith(RedisConstants.ORG_CODE_PRE)){
expireKey.startsWith(RedisConstants.ONLINE_USERS_TEN)){
handleExpiredEvent(expireKey);
}
}

View File

@ -7,9 +7,9 @@ package org.dromara.data2es.handler;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson2.util.JSONObject1O;
import jodd.util.StringUtil;
import org.apache.commons.lang.StringUtils;
@ -74,7 +74,8 @@ public class RequestHandler {
//kafkaProducer.send(esGpsInfo, ConfigConstants.KAFKA_TOPIC_SEND_PRE+"."+ infoSource);
//todo 2023年3月30日 cpu过载暂时隐藏
kafkaTemplate.send(ConfigConstants.KAFKA_TOPIC_SEND_PRE+"."+deviceType, JSON.toJSONString(esGpsInfoVO2));
kafkaTemplate.send(ConfigConstants.KAFKA_TOPIC_SEND_PRE+"."+deviceType,
JSON.toJSONString(esGpsInfoVO2, SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty));
//kafkaProducer.send(esGpsInfoVO2, ConfigConstants.KAFKA_TOPIC_SEND_PRE+"."+deviceType);
//地市的kafka数据如接收地市某个设备的数据可以对接此kafka topic
//todo 暂时隐藏
@ -144,7 +145,7 @@ public class RequestHandler {
}
Date gpsTime = esGpsInfoVo2.getGpsTime();
String jsonValue = JSONUtil.toJsonStr(esGpsInfoVo2);
String jsonValue = JSON.toJSONString(esGpsInfoVo2, SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty);
if(!Objects.isNull(gpsTime)){
//设置永不过期,便于前端查询设备的最后位置 ----2022年9月15日
@ -174,23 +175,6 @@ public class RequestHandler {
}
//方便根据组织机构计算数量
String zzjgdm = esGpsInfoVo2.getZzjgdm();
if(esGpsInfoVo2.getOnline() == 1) {
if(StringUtils.isNotBlank(zzjgdm)) {
RedisUtils.set(RedisConstants.ORG_CODE_ONLINE_DEVICES + esGpsInfoVo2.getDeviceType() + ":"
+ zzjgdm + ":" + esGpsInfoVo2.getDeviceCode(), jsonValue, RedisConstants.REDIS_NEVER_EXPIRE);
}
}else{
if(StringUtils.isNotBlank(zzjgdm)) {
//如果是离线的情况,那么就清除这个在线的
RedisUtils.del(RedisConstants.ORG_CODE_ONLINE_DEVICES + esGpsInfoVo2.getDeviceType() + ":"
+ zzjgdm + ":" + esGpsInfoVo2.getDeviceCode());
}
}
}
@ -204,7 +188,7 @@ public class RequestHandler {
@Async
public void redisOnlineUserByPerson(EsGpsInfo esGpsInfo){
EsGpsInfoVO3 esGpsInfoVO3 = (EsGpsInfoVO3) esGpsInfo;
String jsonValue = JSONUtil.toJsonStr(esGpsInfoVO3);
String jsonValue = JSON.toJSONString(esGpsInfoVO3, SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty);
Date gpsTime = esGpsInfoVO3.getGpsTime();
if(!Objects.isNull(gpsTime)){

View File

@ -3,6 +3,8 @@ package org.dromara.data2es.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
@ -197,13 +199,16 @@ public class StoreDataServiceImpl implements StoreDataService {
if (null == qinwu){
return false;
}
Object obj = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + "9:" + qinwu.getImei());
if (null == obj){
JSONObject obj = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + "9:" + qinwu.getImei());
if (null == obj || JSONUtil.isNull(obj)){
return false;
}else {
// 如需按照gps最新时间来判断 可在这添加逻辑
EsGpsInfoVO3 esGpsInfoVO3 = BeanUtil.toBean(obj.toString(),EsGpsInfoVO3.class);
if (null == esGpsInfoVO3.getGpsTime()){
return false;
}
if (DateUtil.between(new Date(),esGpsInfoVO3.getGpsTime(), DateUnit.SECOND)>120){
return false;
}else {

View File

@ -112,7 +112,7 @@ public class TDeviceServiceImpl implements ITDeviceService {
public List<TDeviceVo> queryList(TDeviceBo bo) {
LambdaQueryWrapper<TDevice> lqw = buildQueryWrapper(bo);
List<TDeviceVo> list = baseMapper.selectVoList(lqw);
for (TDeviceVo vo : list) {
/*for (TDeviceVo vo : list) {
if ("".equals(vo.getPoliceName()) || null == vo.getPoliceName()){
vo.setDeviceName(vo.getCarNum());
}
@ -125,7 +125,7 @@ public class TDeviceServiceImpl implements ITDeviceService {
}
}
}*/
return list;
}
@ -210,7 +210,9 @@ public class TDeviceServiceImpl implements ITDeviceService {
lqw.in(null != bo.getZzjgdms() && bo.getZzjgdms().length>0,TDevice::getZzjgdm,bo.getZzjgdms());
lqw.eq(StringUtils.isNotBlank(bo.getZzjgmc()), TDevice::getZzjgmc, bo.getZzjgmc());
lqw.and(StringUtils.isNotBlank(bo.getPoliceName()),wrapper -> wrapper.like(TDevice::getPoliceNo, bo.getPoliceName())
.or().like(TDevice::getPoliceName, bo.getPoliceName()).or().like(TDevice::getCarNum, bo.getPoliceName()));
.or().like(TDevice::getPoliceName, bo.getPoliceName())
.or().like(TDevice::getCarNum, bo.getPoliceName())
.or().like(TDevice::getDeviceName, bo.getPoliceName()));
lqw.eq(StringUtils.isNotBlank(bo.getPhoneNum()), TDevice::getPhoneNum, bo.getPhoneNum());
lqw.eq(bo.getValid() != null, TDevice::getValid, bo.getValid());
lqw.eq(StringUtils.isNotBlank(bo.getRemark1()), TDevice::getRemark1, bo.getRemark1());