宣城导入错误问题和redis切换主从监听失效问题处理

ds-xuancheng
luyya 2025-07-17 17:07:45 +08:00
parent 3fd5bc2f17
commit fe00bd7311
8 changed files with 34 additions and 18 deletions

View File

@ -169,7 +169,7 @@ public class GpsServiceImpl implements IGpsService {
@Override @Override
public R updateOnlineStatusBatch(List<EsGpsInfoVO2> list) { public R updateOnlineStatusBatch(List<EsGpsInfoVO2> list) {
logger.error("下线设备数量={}",list.size()); logger.error("记录仪状态修改设备数量={}",list.size());
int num = 0; int num = 0;
for (EsGpsInfo originEsGpsInfo : list) { for (EsGpsInfo originEsGpsInfo : list) {
String deviceCode = originEsGpsInfo.getDeviceCode(); String deviceCode = originEsGpsInfo.getDeviceCode();
@ -177,9 +177,15 @@ public class GpsServiceImpl implements IGpsService {
// DeviceEntityV2 de = deviceService.checkDeviceExists(info); // DeviceEntityV2 de = deviceService.checkDeviceExists(info);
JSONObject o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType+":" + deviceCode); JSONObject o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType+":" + deviceCode);
if (Objects.isNull(o)) { if (Objects.isNull(o)) {
if ("5".equals(deviceType) || "7".equals(deviceType) || "8".equals(deviceType)){
logger.error("记录仪设备不在online_users中deviceCode={},deviceType={}",deviceCode,deviceType);
o = JSONUtil.parseObj(originEsGpsInfo);
}else {
logger.error("redis中的Object=nulldeviceType={},deviceCode={}",deviceType,deviceCode); logger.error("redis中的Object=nulldeviceType={},deviceCode={}",deviceType,deviceCode);
continue; continue;
} }
}
EsGpsInfoVO2 esGpsInfoVO2 = JSONUtil.toBean(o, EsGpsInfoVO2.class); EsGpsInfoVO2 esGpsInfoVO2 = JSONUtil.toBean(o, EsGpsInfoVO2.class);
//更新在线状态和时间,经纬度不变 //更新在线状态和时间,经纬度不变
esGpsInfoVO2.setOnline(originEsGpsInfo.getOnline()); esGpsInfoVO2.setOnline(originEsGpsInfo.getOnline());
@ -204,6 +210,7 @@ public class GpsServiceImpl implements IGpsService {
num++; num++;
// storeDataService.saveDataByPersonType(esGpsInfo); // storeDataService.saveDataByPersonType(esGpsInfo);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
num--; num--;
logger.error(e.getMessage()); logger.error(e.getMessage());
// return response.error(500,e.getMessage()); // return response.error(500,e.getMessage());

View File

@ -22,7 +22,7 @@ public class TDeviceExportVo implements Serializable {
/** /**
* *
*/ */
@ExcelProperty(value = "设备类型") @ExcelProperty(value = "设备类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "zd_device_type") @ExcelDictFormat(dictType = "zd_device_type")
private String deviceType; private String deviceType;
@ -41,28 +41,28 @@ public class TDeviceExportVo implements Serializable {
/** /**
* *
*/ */
@ExcelProperty(value = "警号", converter = ExcelDictConvert.class) @ExcelProperty(value = "警号")
private String policeNo; private String policeNo;
/** /**
* *
*/ */
@ExcelProperty(value = "警员姓名", converter = ExcelDictConvert.class) @ExcelProperty(value = "警员姓名")
private String policeName; private String policeName;
/** /**
* *
*/ */
@ExcelProperty(value = "电话号码", converter = ExcelDictConvert.class) @ExcelProperty(value = "电话号码")
private String phoneNum; private String phoneNum;
/** /**
* *
*/ */
@ExcelProperty(value = "车牌号", converter = ExcelDictConvert.class) @ExcelProperty(value = "车牌号")
private String carNum; private String carNum;
@ExcelProperty(value = "证件号码", converter = ExcelDictConvert.class) @ExcelProperty(value = "证件号码")
private String cardNum; private String cardNum;
@ExcelProperty(value = "设备名称") @ExcelProperty(value = "设备名称")

View File

@ -1,6 +1,7 @@
package org.dromara.system.listener; package org.dromara.system.listener;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
@ -15,6 +16,7 @@ import org.dromara.common.core.utils.ValidatorUtils;
import org.dromara.common.excel.core.ExcelListener; import org.dromara.common.excel.core.ExcelListener;
import org.dromara.common.excel.core.ExcelResult; import org.dromara.common.excel.core.ExcelResult;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.TDevice;
import org.dromara.system.domain.bo.TDeviceBo; import org.dromara.system.domain.bo.TDeviceBo;
import org.dromara.system.domain.vo.SysDeptVo; import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.domain.vo.TDeviceImportVo; import org.dromara.system.domain.vo.TDeviceImportVo;
@ -22,6 +24,7 @@ import org.dromara.system.domain.vo.TDeviceVo;
import org.dromara.system.service.ISysDeptService; import org.dromara.system.service.ISysDeptService;
import org.dromara.system.service.ITDeviceService; import org.dromara.system.service.ITDeviceService;
import java.util.Date;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@ -53,7 +56,7 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
failureMsg.append("请删除Excel中提示必须删除的行后重新导入"); failureMsg.append("请删除Excel中提示必须删除的行后重新导入");
}else { }else {
String deviceCode = deviceImportVo.getDeviceCode().replaceAll("[\\p{Zs}\\s]", ""); String deviceCode = deviceImportVo.getDeviceCode().replaceAll("[\\p{Zs}\\s]", "");
TDeviceVo deviceVo = this.deviceService.queryByDeviceCode(deviceCode); TDevice deviceVo = this.deviceService.queryByDeviceCode(deviceCode);
try { try {
// 验证是否存在这个设备 // 验证是否存在这个设备
if (ObjectUtil.isNull(deviceVo)) { if (ObjectUtil.isNull(deviceVo)) {
@ -64,6 +67,8 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
} }
TDeviceBo deviceBo = BeanUtil.toBean(deviceImportVo, TDeviceBo.class); TDeviceBo deviceBo = BeanUtil.toBean(deviceImportVo, TDeviceBo.class);
ValidatorUtils.validate(deviceBo); ValidatorUtils.validate(deviceBo);
deviceBo.setCreateTime(new Date());
deviceBo.setUpdateTime(new Date());
deviceService.insertByBo(deviceBo); deviceService.insertByBo(deviceBo);
successNum++; successNum++;
successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceBo.getDeviceCode()).append(" 导入成功"); successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceBo.getDeviceCode()).append(" 导入成功");
@ -71,11 +76,12 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
Long id = deviceVo.getId(); Long id = deviceVo.getId();
SysDeptVo deptVo = deptService.selectDeptById(deviceVo.getZzjgdm()); SysDeptVo deptVo = deptService.selectDeptById(deviceVo.getZzjgdm());
if(null != deptVo){ if(null != deptVo){
deviceVo.setZzjgmc(deptVo.getShortName()); deviceImportVo.setZzjgmc(deptVo.getShortName());
} }
TDeviceBo deviceBo = BeanUtil.toBean(deviceVo, TDeviceBo.class); TDeviceBo deviceBo = BeanUtil.toBean(deviceImportVo, TDeviceBo.class);
deviceBo.setId(id); deviceBo.setId(id);
ValidatorUtils.validate(deviceBo); ValidatorUtils.validate(deviceBo);
deviceBo.setUpdateTime(new Date());
deviceService.updateByBo(deviceBo); deviceService.updateByBo(deviceBo);
successNum++; successNum++;
successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceImportVo.getDeviceCode()).append(" 更新成功"); successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceImportVo.getDeviceCode()).append(" 更新成功");

View File

@ -82,7 +82,7 @@ public interface ITDeviceService {
R saveDeviceToSt(String infoSource,List<TDevice> list); R saveDeviceToSt(String infoSource,List<TDevice> list);
TDeviceVo queryByDeviceCode(String deviceCode); TDevice queryByDeviceCode(String deviceCode);
List<TDeviceExportVo> selectDeviceExportList(TDeviceBo bo); List<TDeviceExportVo> selectDeviceExportList(TDeviceBo bo);

View File

@ -84,7 +84,7 @@ public class TDeviceServiceImpl implements ITDeviceService {
// bo.setValid(1); // bo.setValid(1);
LambdaQueryWrapper<TDevice> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TDevice> lqw = buildQueryWrapper(bo);
Page<TDeviceVo> result = baseMapper.selectPageDevicetList(pageQuery.build(), lqw); Page<TDeviceVo> result = baseMapper.selectPageDevicetList(pageQuery.build(), lqw);
List<TDeviceVo> list = result.getRecords(); // List<TDeviceVo> list = result.getRecords();
/*for (TDeviceVo vo : list) { /*for (TDeviceVo vo : list) {
if ("".equals(vo.getPoliceName()) || null == vo.getPoliceName()){ if ("".equals(vo.getPoliceName()) || null == vo.getPoliceName()){
vo.setDeviceName(vo.getCarNum()); vo.setDeviceName(vo.getCarNum());
@ -410,10 +410,11 @@ public class TDeviceServiceImpl implements ITDeviceService {
} }
@Override @Override
public TDeviceVo queryByDeviceCode(String deviceCode) { public TDevice queryByDeviceCode(String deviceCode) {
QueryWrapper<TDevice> queryWrapper = new QueryWrapper<>(); QueryWrapper<TDevice> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("device_code", deviceCode); queryWrapper.eq("device_code", deviceCode);
TDeviceVo vo = baseMapper.selectVoOne(queryWrapper); queryWrapper.last("order by update_time desc limit 1");
TDevice vo = baseMapper.selectOne(queryWrapper);
return vo; return vo;
} }
} }

View File

@ -17,7 +17,6 @@
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
device_type = VALUES(device_type),
online = VALUES(online), online = VALUES(online),
zzjgdm = VALUES(zzjgdm) zzjgdm = VALUES(zzjgdm)
</insert> </insert>

View File

@ -28,7 +28,7 @@
</select> </select>
<select id="selectPageDevicetList" resultMap="DevicetResult"> <select id="selectPageDevicetList" resultMap="DevicetResult">
select u.id,u.device_code, u.device_type, u.zzjgdm, u.zzjgmc, u.police_no, u.police_name, u.phone_num, u.car_num, u.valid, select u.id,u.device_code, u.device_type, u.zzjgdm, u.zzjgmc, u.police_no, u.police_name, u.phone_num, u.car_num,u.device_name, u.valid,
u.remark1, u.remark2, u.card_num, u.create_time, u.update_time u.remark1, u.remark2, u.card_num, u.create_time, u.update_time
from t_device u from t_device u
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}

View File

@ -73,6 +73,9 @@ public class DeviceStatusSchedule {
}else { }else {
info.setDeviceType("5"); info.setDeviceType("5");
} }
info.setLat(originDevice.getLatitude()+""); //解决记录仪设备在线 但对接的时候已经没有坐标回传问题
info.setLng(originDevice.getLongitude()+""); //
info.setGpsTime(originDevice.getUpdateTime());
info.setOnline(originDevice.getAlive()); info.setOnline(originDevice.getAlive());
Timestamp updateTime = originDevice.getUpdateTime(); Timestamp updateTime = originDevice.getUpdateTime();
list.add(info); list.add(info);