Browse Source

中航北斗

Zimo 4 days ago
parent
commit
2f842eeac9

+ 13 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -377,4 +377,17 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
         // 第一个参数传null,仅使用wrapper作为更新条件和字段,符合原逻辑
         return update(null, lambdaUpdateWrapper);
     }
+
+    default int updateZhbd(IotDeviceDO iotDeviceDO) {
+        // 非空校验保留
+        Assert.notNull(iotDeviceDO);
+        LambdaUpdateWrapper<IotDeviceDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<IotDeviceDO>()
+                // 逐个设置更新字段,MyBatis-Plus自动处理类型和SQL拼接
+                .set(IotDeviceDO::getVehicleName, iotDeviceDO.getVehicleName())
+                .set(IotDeviceDO::getCarOnline, iotDeviceDO.getCarOnline())
+                // 条件匹配:根据主键ID更新(原CAS逻辑保留)
+                .eq(IotDeviceDO::getId, iotDeviceDO.getId());
+        // 第一个参数传null,仅使用wrapper作为更新条件和字段,符合原逻辑
+        return update(null, lambdaUpdateWrapper);
+    }
 }

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/ZhbdJob.java

@@ -131,7 +131,7 @@ public class ZhbdJob implements JobHandler {
                             IotDeviceDO iotDeviceDO = iotDeviceDOS.get(0);
                             iotDeviceDO.setVehicleName(String.valueOf(location.get("vehicle_name")));
                             iotDeviceDO.setCarOnline(String.valueOf(location.get("online")));
-                            iotDeviceMapper.updateById(iotDeviceDO);
+                            iotDeviceMapper.updateZhbd(iotDeviceDO);
                         }
                     });
                 }