This commit is contained in:
tangzh 2025-07-14 16:25:43 +08:00
parent 91bc6aa572
commit d9c7e6ff66
2 changed files with 14 additions and 15 deletions

View File

@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.system.service.impl; package me.zhengjie.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.front.domain.dto.DeviceLogCriteria; import me.zhengjie.modules.front.domain.dto.DeviceLogCriteria;
import me.zhengjie.modules.front.service.WeChatService; import me.zhengjie.modules.front.service.WeChatService;
@ -64,7 +64,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
@Override @Override
public BusDevice getByDeviceCode(String deviceCode) { public BusDevice getByDeviceCode(String deviceCode) {
return busDeviceMapper.selectOne(new LambdaQueryWrapper<BusDevice>().in(BusDevice::getDeviceCode, deviceCode)); return busDeviceMapper.selectOne(new QueryWrapper<BusDevice>().eq("device_code", deviceCode));
} }
@Override @Override
@ -74,7 +74,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
@Override @Override
public BusDevice getByDeviceSn(String deviceSn) { public BusDevice getByDeviceSn(String deviceSn) {
return busDeviceMapper.selectOne(new LambdaQueryWrapper<BusDevice>().eq(BusDevice::getDeviceSn, deviceSn)); return busDeviceMapper.selectOne(new QueryWrapper<BusDevice>().eq("device_sn", deviceSn));
} }
@Async @Async
@ -93,7 +93,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
device = entity; device = entity;
} }
List<BusDeviceCommand> newList = entity.getCommandList(); List<BusDeviceCommand> newList = entity.getCommandList();
List<BusDeviceCommand> oldList = busCommandMapper.selectList(new LambdaQueryWrapper<BusDeviceCommand>().eq(BusDeviceCommand::getDeviceId, device.getId())); List<BusDeviceCommand> oldList = busCommandMapper.selectList(new QueryWrapper<BusDeviceCommand>().eq("device_id", device.getId()));
if (newList.isEmpty() && !oldList.isEmpty()) { if (newList.isEmpty() && !oldList.isEmpty()) {
List<Long> dIds = oldList.stream().map(BusDeviceCommand::getId).collect(Collectors.toList()); List<Long> dIds = oldList.stream().map(BusDeviceCommand::getId).collect(Collectors.toList());
busCommandMapper.deleteBatchIds(dIds); busCommandMapper.deleteBatchIds(dIds);
@ -175,15 +175,15 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
@Override @Override
public void bindingDevice(String deviceCode) { public void bindingDevice(String deviceCode) {
BusDevice device = busDeviceMapper.selectOne(new LambdaQueryWrapper<BusDevice>().eq(BusDevice::getDeviceCode, deviceCode)); BusDevice device = getByDeviceCode(deviceCode);
if (null == device) { if (null == device) {
throw new BadRequestException("二维码有误,未查询到设备信息"); throw new BadRequestException("二维码有误,未查询到设备信息");
} }
JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser(); JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser();
User user = jwtUser.getUser(); User user = jwtUser.getUser();
BusUserDevice udEntity = userDeviceMapper.selectOne(new LambdaQueryWrapper<BusUserDevice>() BusUserDevice udEntity = userDeviceMapper.selectOne(new QueryWrapper<BusUserDevice>()
.eq(BusUserDevice::getDeviceId, device.getId()) .eq("device_id", device.getId())
.eq(BusUserDevice::getUserId, user.getId()) .eq("user_id", user.getId())
); );
if (null != udEntity) { if (null != udEntity) {
throw new BadRequestException("您已绑定过该设备,请勿重复绑定"); throw new BadRequestException("您已绑定过该设备,请勿重复绑定");
@ -192,10 +192,10 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
addUserDevice.setUserId(user.getId()); addUserDevice.setUserId(user.getId());
addUserDevice.setDeviceId(device.getId()); addUserDevice.setDeviceId(device.getId());
userDeviceMapper.insert(addUserDevice); userDeviceMapper.insert(addUserDevice);
List<BusDeviceCommand> commands = busCommandMapper.selectList(new LambdaQueryWrapper<BusDeviceCommand>().eq(BusDeviceCommand::getDeviceId, device.getId())); // List<BusDeviceCommand> commands = busCommandMapper.selectList(new LambdaQueryWrapper<BusDeviceCommand>().eq(BusDeviceCommand::getDeviceId, device.getId()));
if (commands.isEmpty()) { return; } // if (commands.isEmpty()) { return; }
List<Long> commandIds = commands.stream().map(BusDeviceCommand::getId).collect(Collectors.toList()); // List<Long> commandIds = commands.stream().map(BusDeviceCommand::getId).collect(Collectors.toList());
busUserCommandMapper.bindingCommand(user.getId(), commandIds); // busUserCommandMapper.bindingCommand(user.getId(), commandIds);
} }
@Override @Override

View File

@ -15,7 +15,6 @@
*/ */
package me.zhengjie.modules.system.service.impl; package me.zhengjie.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhengjie.modules.system.domain.BusUser; import me.zhengjie.modules.system.domain.BusUser;
import me.zhengjie.modules.system.domain.BusUserCommand; import me.zhengjie.modules.system.domain.BusUserCommand;
@ -51,8 +50,8 @@ public class BusUserDeviceServiceImpl extends ServiceImpl<BusUserDeviceMapper, B
if (null == commands || commands.isEmpty()) { return; } if (null == commands || commands.isEmpty()) { return; }
List<BusTreeVo> userDevices = commands.stream().filter(i -> i.getId().contains("d")).collect(Collectors.toList()); List<BusTreeVo> userDevices = commands.stream().filter(i -> i.getId().contains("d")).collect(Collectors.toList());
List<BusTreeVo> userCommands = commands.stream().filter(i -> i.getId().contains("c")).collect(Collectors.toList()); List<BusTreeVo> userCommands = commands.stream().filter(i -> i.getId().contains("c")).collect(Collectors.toList());
List<BusUserDevice> oldUserDevices = busUserDeviceMapper.selectList(new LambdaQueryWrapper<BusUserDevice>().eq(BusUserDevice::getUserId, busUser.getId())); List<BusUserDevice> oldUserDevices = busUserDeviceMapper.selectList(new QueryWrapper<BusUserDevice>().eq("user_id", busUser.getId()));
List<BusUserCommand> oldUserCommands = busUserCommandMapper.selectList(new LambdaQueryWrapper<BusUserCommand>().eq(BusUserCommand::getUserId, busUser.getId())); List<BusUserCommand> oldUserCommands = busUserCommandMapper.selectList(new QueryWrapper<BusUserCommand>().eq("user_id", busUser.getId()));
if (!oldUserDevices.isEmpty()) { if (!oldUserDevices.isEmpty()) {
List<Long> delIds = oldUserDevices.stream().map(i -> i.getId()).collect(Collectors.toList()); List<Long> delIds = oldUserDevices.stream().map(i -> i.getId()).collect(Collectors.toList());
busUserDeviceMapper.deleteBatchIds(delIds); busUserDeviceMapper.deleteBatchIds(delIds);