Browse Source

手持表bug 修改

hand_device
wangwei_123 1 week ago
parent
commit
4988ac9d78
  1. 18
      cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/DeviceMessageProcessor.java
  2. 3
      cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/HandDetectorServiceImpl.java
  3. 3
      cc-admin-master/yudao-module-hand/src/main/resources/mapper/TdengineMapper.xml
  4. 2
      cc-admin-master/yudao-server/src/main/resources/application.yaml

18
cc-admin-master/yudao-module-hand-mqtt/src/main/java/cn/iocoder/yudao/module/mqtt/processor/DeviceMessageProcessor.java

@ -577,18 +577,28 @@ public class DeviceMessageProcessor {
detector.setOnlineStatus(OnlineStatusType.ONLINE.getType()); detector.setOnlineStatus(OnlineStatusType.ONLINE.getType());
String[] split = numbersString.split(","); String[] split = numbersString.split(",");
if (split.length != 3) {
log.error("数据格式错误:{}", payload);
if (split.length < 3) {
log.error("数据格式错误:输入字符串格式不正确:{}", payload);
return detector; return detector;
} }
int finalGpsType = 0; // 默认值设为 0 (GPS)
if (split.length >= 4) {
finalGpsType = Integer.parseInt(split[3].trim());
} else {
int oldTypeValue = Integer.parseInt(split[2].trim());
finalGpsType = (oldTypeValue == 0) ? 0 : 2;
}
Map<String, Double> wgs84ToGcj02 = CoordinateTransferUtils.wgs84ToGcj02(Double.parseDouble(split[0]), Double.parseDouble(split[1])); Map<String, Double> wgs84ToGcj02 = CoordinateTransferUtils.wgs84ToGcj02(Double.parseDouble(split[0]), Double.parseDouble(split[1]));
Double lon = wgs84ToGcj02.get("lon"); Double lon = wgs84ToGcj02.get("lon");
Double lat = wgs84ToGcj02.get("lat"); Double lat = wgs84ToGcj02.get("lat");
detector.setLongitude(lon); detector.setLongitude(lon);
detector.setLatitude(lat); detector.setLatitude(lat);
String type = split[2];
detector.setGpsType(Integer.parseInt(type));
detector.setGpsType(finalGpsType);
return detector; return detector;

3
cc-admin-master/yudao-module-hand/src/main/java/cn/iocoder/yudao/module/hand/service/impl/HandDetectorServiceImpl.java

@ -307,8 +307,6 @@ public class HandDetectorServiceImpl implements HandDetectorService {
// 批量更新数据库 // 批量更新数据库
handDetectorMapper.updateBatch(devicesToMigrate); handDetectorMapper.updateBatch(devicesToMigrate);
// 4. --- Redis缓存处理 ---
// 4.1. 清理旧租户的设备信息缓存 // 4.1. 清理旧租户的设备信息缓存
String oldTenantDeviceKey = RedisKeyUtil.getTenantDeviceHashKey(Long.valueOf(oldTenantId)); String oldTenantDeviceKey = RedisKeyUtil.getTenantDeviceHashKey(Long.valueOf(oldTenantId));
// 从旧租户的Hash中批量删除这些设备 // 从旧租户的Hash中批量删除这些设备
@ -344,7 +342,6 @@ public class HandDetectorServiceImpl implements HandDetectorService {
} }
queryWrapper.eq("tenant_id", tenantId); queryWrapper.eq("tenant_id", tenantId);
// 【核心优化2】使用 selectObjs
// selectObjs 直接返回第一列的值(List<Object>),性能最高 // selectObjs 直接返回第一列的值(List<Object>),性能最高
List<Object> result = handDetectorMapper.selectObjs(queryWrapper); List<Object> result = handDetectorMapper.selectObjs(queryWrapper);

3
cc-admin-master/yudao-module-hand/src/main/resources/mapper/TdengineMapper.xml

@ -177,8 +177,7 @@
AND dept_id = #{vo.deptId} AND dept_id = #{vo.deptId}
</if> </if>
<if test="vo.holderName != null and vo.holderName != ''"> <if test="vo.holderName != null and vo.holderName != ''">
<bind name="holderNamePattern" value="'%' + vo.holderName + '%'" />
AND holder_name LIKE #{vo.holderNamePattern}
AND holder_name = #{vo.holderName}
</if> </if>
<if test="vo.pushSnList != null and vo.pushSnList != ''"> <if test="vo.pushSnList != null and vo.pushSnList != ''">
<!-- 使用 INSTR 函数:查找子串位置,大于0表示存在 --> <!-- 使用 INSTR 函数:查找子串位置,大于0表示存在 -->

2
cc-admin-master/yudao-server/src/main/resources/application.yaml

@ -2,7 +2,7 @@ spring:
application: application:
name: gas_mobile name: gas_mobile
profiles: profiles:
active: dev
active: prod
main: main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。

Loading…
Cancel
Save