调整
This commit is contained in:
parent
91bc6aa572
commit
d9c7e6ff66
@ -15,7 +15,7 @@
|
||||
*/
|
||||
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.modules.front.domain.dto.DeviceLogCriteria;
|
||||
import me.zhengjie.modules.front.service.WeChatService;
|
||||
@ -64,7 +64,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -74,7 +74,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -93,7 +93,7 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
|
||||
device = entity;
|
||||
}
|
||||
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()) {
|
||||
List<Long> dIds = oldList.stream().map(BusDeviceCommand::getId).collect(Collectors.toList());
|
||||
busCommandMapper.deleteBatchIds(dIds);
|
||||
@ -175,15 +175,15 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
|
||||
|
||||
@Override
|
||||
public void bindingDevice(String deviceCode) {
|
||||
BusDevice device = busDeviceMapper.selectOne(new LambdaQueryWrapper<BusDevice>().eq(BusDevice::getDeviceCode, deviceCode));
|
||||
BusDevice device = getByDeviceCode(deviceCode);
|
||||
if (null == device) {
|
||||
throw new BadRequestException("二维码有误,未查询到设备信息");
|
||||
}
|
||||
JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser();
|
||||
User user = jwtUser.getUser();
|
||||
BusUserDevice udEntity = userDeviceMapper.selectOne(new LambdaQueryWrapper<BusUserDevice>()
|
||||
.eq(BusUserDevice::getDeviceId, device.getId())
|
||||
.eq(BusUserDevice::getUserId, user.getId())
|
||||
BusUserDevice udEntity = userDeviceMapper.selectOne(new QueryWrapper<BusUserDevice>()
|
||||
.eq("device_id", device.getId())
|
||||
.eq("user_id", user.getId())
|
||||
);
|
||||
if (null != udEntity) {
|
||||
throw new BadRequestException("您已绑定过该设备,请勿重复绑定");
|
||||
@ -192,10 +192,10 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
|
||||
addUserDevice.setUserId(user.getId());
|
||||
addUserDevice.setDeviceId(device.getId());
|
||||
userDeviceMapper.insert(addUserDevice);
|
||||
List<BusDeviceCommand> commands = busCommandMapper.selectList(new LambdaQueryWrapper<BusDeviceCommand>().eq(BusDeviceCommand::getDeviceId, device.getId()));
|
||||
if (commands.isEmpty()) { return; }
|
||||
List<Long> commandIds = commands.stream().map(BusDeviceCommand::getId).collect(Collectors.toList());
|
||||
busUserCommandMapper.bindingCommand(user.getId(), commandIds);
|
||||
// List<BusDeviceCommand> commands = busCommandMapper.selectList(new LambdaQueryWrapper<BusDeviceCommand>().eq(BusDeviceCommand::getDeviceId, device.getId()));
|
||||
// if (commands.isEmpty()) { return; }
|
||||
// List<Long> commandIds = commands.stream().map(BusDeviceCommand::getId).collect(Collectors.toList());
|
||||
// busUserCommandMapper.bindingCommand(user.getId(), commandIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
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.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.BusUserCommand;
|
||||
@ -51,8 +50,8 @@ public class BusUserDeviceServiceImpl extends ServiceImpl<BusUserDeviceMapper, B
|
||||
if (null == commands || commands.isEmpty()) { return; }
|
||||
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<BusUserDevice> oldUserDevices = busUserDeviceMapper.selectList(new LambdaQueryWrapper<BusUserDevice>().eq(BusUserDevice::getUserId, busUser.getId()));
|
||||
List<BusUserCommand> oldUserCommands = busUserCommandMapper.selectList(new LambdaQueryWrapper<BusUserCommand>().eq(BusUserCommand::getUserId, busUser.getId()));
|
||||
List<BusUserDevice> oldUserDevices = busUserDeviceMapper.selectList(new QueryWrapper<BusUserDevice>().eq("user_id", busUser.getId()));
|
||||
List<BusUserCommand> oldUserCommands = busUserCommandMapper.selectList(new QueryWrapper<BusUserCommand>().eq("user_id", busUser.getId()));
|
||||
if (!oldUserDevices.isEmpty()) {
|
||||
List<Long> delIds = oldUserDevices.stream().map(i -> i.getId()).collect(Collectors.toList());
|
||||
busUserDeviceMapper.deleteBatchIds(delIds);
|
||||
|
Loading…
Reference in New Issue
Block a user