feat(后端): 联调修改12
parent
f17de4dc33
commit
2dd8de87de
|
@ -3,7 +3,7 @@ package com.unisinsight.project.controller;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.unisinsight.project.entity.dao.DeviceImageMapping;
|
||||
import com.unisinsight.project.entity.req.DeviceImageMappingReq;
|
||||
import com.unisinsight.project.entity.res.DeviceImageMappingRes;
|
||||
|
@ -48,9 +48,9 @@ public class DeviceImageMappingController {
|
|||
}
|
||||
log.info("终端镜像映射新增请求参数为:{}", JSONUtil.toJsonStr(deviceImageMappingReq));
|
||||
|
||||
QueryWrapper<DeviceImageMapping> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<DeviceImageMapping> wrapper = new LambdaQueryWrapper<>();
|
||||
if (CollectionUtil.isEmpty(deviceImageMappingReq.getData()) && ObjectUtils.isNotEmpty(deviceImageMappingReq.getDeviceId())) {
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceId, deviceImageMappingReq.getDeviceId());
|
||||
wrapper.eq(DeviceImageMapping::getDeviceId, deviceImageMappingReq.getDeviceId());
|
||||
List<DeviceImageMapping> list = deviceImageMappingService.list(wrapper);
|
||||
List<Long> collect = list.stream().map(DeviceImageMapping::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
|
@ -62,7 +62,7 @@ public class DeviceImageMappingController {
|
|||
List<DeviceImageMappingReq> reqData = deviceImageMappingReq.getData();
|
||||
List<DeviceImageMappingReq> addList = reqData.stream().distinct().filter(e -> Objects.isNull(e.getId())).collect(Collectors.toList());
|
||||
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceId, reqData.get(0).getDeviceId());
|
||||
wrapper.eq(DeviceImageMapping::getDeviceId, reqData.get(0).getDeviceId());
|
||||
List<DeviceImageMapping> list = deviceImageMappingService.list(wrapper);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
|
@ -87,6 +87,7 @@ public class DeviceImageMappingController {
|
|||
List<DeviceImageMapping> deviceImageMappings = BeanUtil.copyToList(addList, DeviceImageMapping.class);
|
||||
List<DeviceImageMapping> deviceImageMappingList = deviceImageMappings.stream().peek(e -> {
|
||||
e.setCreateUser("admin");
|
||||
e.setUpdateUser("admin");
|
||||
}).collect(Collectors.toList());
|
||||
boolean insert = deviceImageMappingService.saveBatch(deviceImageMappingList);
|
||||
log.info("终端镜像映射新增insert:{}", insert);
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.unisinsight.project.controller;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.unisinsight.project.entity.dao.DeviceUserMapping;
|
||||
import com.unisinsight.project.entity.req.DeviceUserMappingReq;
|
||||
import com.unisinsight.project.entity.res.DeviceUserMappingRes;
|
||||
|
@ -47,9 +47,9 @@ public class DeviceUserMappingController {
|
|||
return Result.errorResult(BaseErrorCode.PARAMETERS_INVALID);
|
||||
}
|
||||
log.info("终端用户映射新增请求参数为:{}", JSONUtil.toJsonStr(deviceUserMappingReq));
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<DeviceUserMapping> wrapper = new LambdaQueryWrapper<>();
|
||||
if (CollectionUtil.isEmpty(deviceUserMappingReq.getData()) && ObjectUtils.isNotEmpty(deviceUserMappingReq.getDeviceId())) {
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, deviceUserMappingReq.getDeviceId());
|
||||
wrapper.eq(DeviceUserMapping::getDeviceId, deviceUserMappingReq.getDeviceId());
|
||||
List<DeviceUserMapping> list = deviceUserMappingService.list(wrapper);
|
||||
List<Long> collect = list.stream().map(DeviceUserMapping::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
|
@ -61,7 +61,7 @@ public class DeviceUserMappingController {
|
|||
List<DeviceUserMappingReq> userMappingReqData = deviceUserMappingReq.getData();
|
||||
List<DeviceUserMappingReq> addList = userMappingReqData.stream().distinct().filter(e -> Objects.isNull(e.getId())).collect(Collectors.toList());
|
||||
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, userMappingReqData.get(0).getDeviceId());
|
||||
wrapper.eq(DeviceUserMapping::getDeviceId, userMappingReqData.get(0).getDeviceId());
|
||||
List<DeviceUserMapping> list = deviceUserMappingService.list(wrapper);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
|
@ -87,6 +87,7 @@ public class DeviceUserMappingController {
|
|||
List<DeviceUserMapping> deviceUserMappings = BeanUtil.copyToList(addList, DeviceUserMapping.class);
|
||||
List<DeviceUserMapping> deviceUserMapping = deviceUserMappings.stream().distinct().peek(e -> {
|
||||
e.setCreateUser("admin");
|
||||
e.setUpdateUser("admin");
|
||||
}).collect(Collectors.toList());
|
||||
boolean insert = deviceUserMappingService.saveBatch(deviceUserMapping);
|
||||
log.info("终端用户映射新增insert:{}", insert);
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.unisinsight.project.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.unisinsight.project.entity.dao.DeviceImageMapping;
|
||||
import com.unisinsight.project.entity.dao.Image;
|
||||
import com.unisinsight.project.entity.res.ImageRes;
|
||||
|
@ -45,18 +45,14 @@ public class ClientServiceImpl implements ClientService {
|
|||
@Override
|
||||
public Result<?> getImageList(String deviceId, String token) {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
QueryWrapper<DeviceImageMapping> deviceImageMappingQueryWrapper = new QueryWrapper<>();
|
||||
deviceImageMappingQueryWrapper.lambda().eq(DeviceImageMapping::getDeviceId, deviceId);
|
||||
List<DeviceImageMapping> deviceImageMappings = deviceImageMappingMapper.selectList(deviceImageMappingQueryWrapper);
|
||||
List<DeviceImageMapping> deviceImageMappings = deviceImageMappingMapper.selectList(new LambdaQueryWrapper<DeviceImageMapping>().eq(DeviceImageMapping::getDeviceId, deviceId));
|
||||
if (CollectionUtil.isEmpty(deviceImageMappings)) {
|
||||
hashMap.put("list", new ArrayList<>());
|
||||
return Result.successResult(hashMap);
|
||||
}
|
||||
List<Long> imageIdList = deviceImageMappings.stream().map(DeviceImageMapping::getImageId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(imageIdList)) {
|
||||
QueryWrapper<Image> imageQueryWrapper = new QueryWrapper<>();
|
||||
imageQueryWrapper.lambda().in(Image::getId, imageIdList);
|
||||
List<Image> images = imageMapper.selectList(imageQueryWrapper);
|
||||
List<Image> images = imageMapper.selectList(new LambdaQueryWrapper<Image>().in(Image::getId, imageIdList));
|
||||
log.info("用户登录查询镜像结果:{}", JSONUtil.toJsonStr(images));
|
||||
List<ImageRes> imageRes = BeanUtil.copyToList(images, ImageRes.class);
|
||||
List<HashMap<String, Object>> collect = imageRes.stream().distinct().map(e -> {
|
||||
|
|
|
@ -47,13 +47,11 @@ public class DeviceImageMappingServiceImpl extends ServiceImpl<DeviceImageMappin
|
|||
@Override
|
||||
public Result<?> select(DeviceImageMappingReq deviceImageMappingReq) {
|
||||
DeviceImageMapping deviceImageMapping = BeanUtil.copyProperties(deviceImageMappingReq, DeviceImageMapping.class);
|
||||
QueryWrapper<DeviceImageMapping> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<DeviceImageMapping> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceId, deviceImageMapping.getDeviceId());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(deviceImageMapping.getDeviceGroupId())) {
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceGroupId, deviceImageMapping.getDeviceGroupId());
|
||||
}
|
||||
wrapper.eq(DeviceImageMapping::getDeviceId, deviceImageMapping.getDeviceId());
|
||||
wrapper.eq(ObjectUtil.isNotEmpty(deviceImageMapping.getDeviceGroupId()), DeviceImageMapping::getDeviceGroupId, deviceImageMapping.getDeviceGroupId());
|
||||
wrapper.orderByAsc(DeviceImageMapping::getId);
|
||||
List<DeviceImageMapping> deviceUserMappings = deviceImageMappingMapper.selectList(wrapper);
|
||||
log.info("终端镜像映射查询结果:{}", JSONUtil.toJsonStr(deviceUserMappings));
|
||||
if (CollectionUtil.isEmpty(deviceUserMappings)) {
|
||||
|
@ -62,7 +60,7 @@ public class DeviceImageMappingServiceImpl extends ServiceImpl<DeviceImageMappin
|
|||
List<DeviceImageMappingRes> deviceImageMappingRes = BeanUtil.copyToList(deviceUserMappings, DeviceImageMappingRes.class);
|
||||
List<Long> imageIds = deviceImageMappingRes.stream().map(DeviceImageMappingRes::getImageId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(imageIds)) {
|
||||
LambdaQueryWrapper<Image> imageLambdaQueryWrapper = new QueryWrapper<Image>().lambda().in(Image::getId, imageIds);
|
||||
LambdaQueryWrapper<Image> imageLambdaQueryWrapper = new LambdaQueryWrapper<Image>().in(Image::getId, imageIds);
|
||||
List<Image> images = imageMapper.selectList(imageLambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(images)) {
|
||||
deviceImageMappingRes.forEach(deviceImage -> images.forEach(image -> {
|
||||
|
@ -85,13 +83,6 @@ public class DeviceImageMappingServiceImpl extends ServiceImpl<DeviceImageMappin
|
|||
}));
|
||||
}
|
||||
}
|
||||
deviceImageMappingRes = deviceImageMappingRes.stream().sorted((u1, u2) -> {
|
||||
// 对结果按主键排序
|
||||
if (u1.getId() != null && u2.getId() != null) {
|
||||
return u1.getId().compareTo(u2.getId());
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
return Result.successResult(deviceImageMappingRes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.unisinsight.project.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -55,6 +56,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device>
|
|||
return new Result<>("200", "终端已存在");
|
||||
}
|
||||
device.setCreateUser("admin");
|
||||
device.setUpdateUser("admin");
|
||||
int insert = deviceMapper.insert(device);
|
||||
log.info("终端新增insert:{}", insert);
|
||||
if (insert == 1) {
|
||||
|
@ -91,23 +93,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device>
|
|||
@Override
|
||||
public Result<?> selectPageUser(DeviceReq deviceReq) {
|
||||
Page<Device> page = new Page<>(deviceReq.getPageNum(), deviceReq.getPageSize());
|
||||
QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (StringUtils.isNotBlank(deviceReq.getDeviceName())) {
|
||||
queryWrapper.lambda().like(Device::getDeviceName, deviceReq.getDeviceName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(deviceReq.getDeviceGroupName())) {
|
||||
queryWrapper.lambda().eq(Device::getDeviceGroupName, deviceReq.getDeviceGroupName());
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(deviceReq.getDeviceGroupId())) {
|
||||
queryWrapper.lambda().eq(Device::getDeviceGroupId, deviceReq.getDeviceGroupId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(deviceReq.getIpAddr())) {
|
||||
queryWrapper.lambda().eq(Device::getIpAddr, deviceReq.getIpAddr());
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(deviceReq.getDeviceType())) {
|
||||
queryWrapper.lambda().eq(Device::getDeviceType, deviceReq.getDeviceType());
|
||||
}
|
||||
LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotBlank(deviceReq.getDeviceName()), Device::getDeviceName, deviceReq.getDeviceName());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(deviceReq.getDeviceGroupName()), Device::getDeviceGroupName, deviceReq.getDeviceGroupName());
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(deviceReq.getDeviceGroupId()), Device::getDeviceGroupId, deviceReq.getDeviceGroupId());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(deviceReq.getIpAddr()), Device::getIpAddr, deviceReq.getIpAddr());
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(deviceReq.getDeviceType()), Device::getDeviceType, deviceReq.getDeviceType());
|
||||
queryWrapper.orderByAsc(Device::getId);
|
||||
|
||||
IPage<Device> userPage = deviceMapper.selectPage(page, queryWrapper);
|
||||
log.info("分页查询终端返回:{}", JSONUtil.toJsonStr(userPage));
|
||||
|
@ -127,12 +119,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device>
|
|||
device.setDeviceGroupName(userDeviceGroup.getName());
|
||||
}
|
||||
}
|
||||
}).sorted((u1, u2) -> {
|
||||
// 对结果按主键排序
|
||||
if (u1.getId() != null && u2.getId() != null) {
|
||||
return u1.getId().compareTo(u2.getId());
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
convert.setData(resList);
|
||||
return Result.successResult(convert);
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.unisinsight.project.entity.dao.DeviceUserMapping;
|
||||
|
@ -53,16 +54,12 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
@Override
|
||||
public Result<?> select(DeviceUserMappingReq deviceUserMappingReq) {
|
||||
DeviceUserMapping deviceUserMapping = BeanUtil.copyProperties(deviceUserMappingReq, DeviceUserMapping.class);
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<DeviceUserMapping> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, deviceUserMapping.getDeviceId());
|
||||
wrapper.eq(DeviceUserMapping::getDeviceId, deviceUserMapping.getDeviceId());
|
||||
wrapper.eq(ObjectUtil.isNotEmpty(deviceUserMapping.getType()), DeviceUserMapping::getType, deviceUserMapping.getType());
|
||||
wrapper.eq(ObjectUtil.isNotEmpty(deviceUserMapping.getDeviceGroupId()), DeviceUserMapping::getDeviceGroupId, deviceUserMapping.getDeviceGroupId());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(deviceUserMapping.getType())) {
|
||||
wrapper.lambda().eq(DeviceUserMapping::getType, deviceUserMapping.getType());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(deviceUserMapping.getDeviceGroupId())) {
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceGroupId, deviceUserMapping.getDeviceGroupId());
|
||||
}
|
||||
List<DeviceUserMapping> deviceUserMappings = deviceUserMappingMapper.selectList(wrapper);
|
||||
log.info("终端用户映射查询结果:{}", JSONUtil.toJsonStr(deviceUserMappings));
|
||||
if (CollectionUtil.isEmpty(deviceUserMappings)) {
|
||||
|
@ -86,9 +83,7 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
|
||||
List<Long> deviceList = deviceUserMappingRes.stream().map(DeviceUserMappingRes::getDeviceGroupId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(deviceList)) {
|
||||
QueryWrapper<UserDeviceGroup> groupQueryWrapper = new QueryWrapper<>();
|
||||
groupQueryWrapper.lambda().in(UserDeviceGroup::getId, deviceList);
|
||||
List<UserDeviceGroup> userDeviceGroups = groupMapper.selectList(groupQueryWrapper);
|
||||
List<UserDeviceGroup> userDeviceGroups = groupMapper.selectList(new LambdaQueryWrapper<UserDeviceGroup>().in(UserDeviceGroup::getId, deviceList));
|
||||
deviceUserMappingRes = deviceUserMappingRes.stream().distinct().peek(device -> {
|
||||
for (UserDeviceGroup userDeviceGroup : userDeviceGroups) {
|
||||
if (!ObjectUtils.isEmpty(device.getDeviceGroupId()) && device.getDeviceGroupId().equals(userDeviceGroup.getId())) {
|
||||
|
@ -99,9 +94,7 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
}
|
||||
List<Long> userGroupId = deviceUserMappingRes.stream().map(DeviceUserMappingRes::getUserGroupId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(userGroupId)) {
|
||||
QueryWrapper<UserDeviceGroup> groupQueryWrapper = new QueryWrapper<>();
|
||||
groupQueryWrapper.lambda().in(UserDeviceGroup::getId, userGroupId);
|
||||
List<UserDeviceGroup> userDeviceGroups = groupMapper.selectList(groupQueryWrapper);
|
||||
List<UserDeviceGroup> userDeviceGroups = groupMapper.selectList(new LambdaQueryWrapper<UserDeviceGroup>().in(UserDeviceGroup::getId, userGroupId));
|
||||
deviceUserMappingRes = deviceUserMappingRes.stream().distinct().peek(group -> {
|
||||
for (UserDeviceGroup userDeviceGroup : userDeviceGroups) {
|
||||
if (!ObjectUtils.isEmpty(group.getUserGroupId()) && group.getUserGroupId().equals(userDeviceGroup.getId())) {
|
||||
|
@ -110,13 +103,6 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
deviceUserMappingRes = deviceUserMappingRes.stream().sorted((u1, u2) -> {
|
||||
// 对结果按主键排序
|
||||
if (u1.getId() != null && u2.getId() != null) {
|
||||
return u1.getId().compareTo(u2.getId());
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
return Result.successResult(deviceUserMappingRes);
|
||||
}
|
||||
|
||||
|
@ -126,25 +112,20 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
@Override
|
||||
public Result<?> loginUser(DeviceUserReq deviceUserReq) {
|
||||
|
||||
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
||||
userQueryWrapper.lambda().in(User::getUserName, deviceUserReq.getUserName());
|
||||
List<User> userList1 = userMapper.selectList(userQueryWrapper);
|
||||
List<User> userList1 = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getUserName, deviceUserReq.getUserName()));
|
||||
log.info("登录查询用户结果:{}", JSONUtil.toJsonStr(userList1));
|
||||
if (CollectionUtil.isEmpty(userList1)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "用户不存在");
|
||||
}
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, deviceUserReq.getDeviceId());
|
||||
List<DeviceUserMapping> deviceUserMappings = deviceUserMappingMapper.selectList(wrapper);
|
||||
|
||||
List<DeviceUserMapping> deviceUserMappings = deviceUserMappingMapper.selectList(new LambdaQueryWrapper<DeviceUserMapping>().eq(DeviceUserMapping::getDeviceId, deviceUserReq.getDeviceId()));
|
||||
log.info("用户登录查询映射结果:{}", JSONUtil.toJsonStr(deviceUserMappings));
|
||||
|
||||
List<User> users = new ArrayList<>();
|
||||
List<Long> userIdList = deviceUserMappings.stream().map(DeviceUserMapping::getUserId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
log.info("用户登录查询用户id结果:{}", JSONUtil.toJsonStr(userIdList));
|
||||
if (CollectionUtil.isNotEmpty(userIdList)) {
|
||||
QueryWrapper<User> groupWrapper = new QueryWrapper<>();
|
||||
groupWrapper.lambda().in(User::getId, userIdList);
|
||||
List<User> userList = userMapper.selectList(groupWrapper);
|
||||
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getId, userIdList));
|
||||
log.info("用户id查询结果:{}", JSONUtil.toJsonStr(userList));
|
||||
if (CollectionUtil.isNotEmpty(userList)) {
|
||||
User user = userList.stream().distinct().filter(e -> e.getUserName().equals(deviceUserReq.getUserName())).findAny().orElse(null);
|
||||
|
@ -155,9 +136,7 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
List<Long> groupList = deviceUserMappings.stream().map(DeviceUserMapping::getUserGroupId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
log.info("用户登录查询用户组id结果:{}", JSONUtil.toJsonStr(groupList));
|
||||
if (CollectionUtil.isNotEmpty(groupList)) {
|
||||
QueryWrapper<User> groupWrapper = new QueryWrapper<>();
|
||||
groupWrapper.lambda().in(User::getUserGroupId, groupList);
|
||||
List<User> userDeviceGroups = userMapper.selectList(groupWrapper);
|
||||
List<User> userDeviceGroups = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getUserGroupId, groupList));
|
||||
log.info("用户组id查询结果:{}", JSONUtil.toJsonStr(userDeviceGroups));
|
||||
if (CollectionUtil.isNotEmpty(userDeviceGroups)) {
|
||||
User user = userDeviceGroups.stream().distinct().filter(e -> e.getUserName().equals(deviceUserReq.getUserName())).findAny().orElse(null);
|
||||
|
@ -165,9 +144,6 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
}
|
||||
}
|
||||
log.info("用户登录查询结果:{}", JSONUtil.toJsonStr(users));
|
||||
if (CollectionUtil.isEmpty(users)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "当前用户无权限登录终端,请联系管理员");
|
||||
}
|
||||
users = users.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(users)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "当前用户无权限登录终端,请联系管理员");
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.unisinsight.project.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -57,15 +57,10 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image>
|
|||
@Override
|
||||
public Result<?> selectPage(ImageReq imageReq) {
|
||||
Page<Image> page = new Page<>(imageReq.getPageNum(), imageReq.getPageSize());
|
||||
QueryWrapper<Image> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (StringUtils.isNotBlank(imageReq.getImageName())) {
|
||||
queryWrapper.lambda().like(Image::getImageName, imageReq.getImageName());
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(imageReq.getImageType())) {
|
||||
queryWrapper.lambda().eq(Image::getImageType, imageReq.getImageType());
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Image> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotBlank(imageReq.getImageName()), Image::getImageName, imageReq.getImageName());
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(imageReq.getImageType()), Image::getImageType, imageReq.getImageType());
|
||||
queryWrapper.orderByAsc(Image::getId);
|
||||
IPage<Image> imageIPage = imageMapper.selectPage(page, queryWrapper);
|
||||
log.info("分页查询镜像返回:{}", JSONUtil.toJsonStr(imageIPage));
|
||||
if (CollectionUtil.isEmpty(imageIPage.getRecords())) {
|
||||
|
@ -81,12 +76,6 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image>
|
|||
e.setBtPath(btUrl + "/api/vdi/file/down/" + fileName);
|
||||
}
|
||||
}
|
||||
}).sorted((u1, u2) -> {
|
||||
// 对结果按主键排序
|
||||
if (u1.getId() != null && u2.getId() != null) {
|
||||
return u1.getId().compareTo(u2.getId());
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
convert.setData(collect);
|
||||
return Result.successResult(convert);
|
||||
|
@ -106,7 +95,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image>
|
|||
log.info("请求bt停止接口返回: {}", JSONUtil.toJsonStr(responseEntity));
|
||||
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||
if (statusCode != HttpStatus.OK) {
|
||||
boolean result = responseEntity.getBody();
|
||||
boolean result = Boolean.TRUE.equals(responseEntity.getBody());
|
||||
if (result) {
|
||||
log.info("请求bt停止接口成功");
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.unisinsight.project.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.unisinsight.project.entity.dao.UserDeviceGroup;
|
||||
import com.unisinsight.project.entity.req.DeleteIdReq;
|
||||
|
@ -40,21 +40,20 @@ public class UserDeviceGroupServiceImpl extends ServiceImpl<UserDeviceGroupMappe
|
|||
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||
}
|
||||
UserDeviceGroup group = BeanUtil.copyProperties(groupReq, UserDeviceGroup.class);
|
||||
QueryWrapper<UserDeviceGroup> wrapper = new QueryWrapper<>();
|
||||
LambdaQueryWrapper<UserDeviceGroup> wrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtils.isEmpty(group.getParentId())) {
|
||||
if (group.getType() == 1) {
|
||||
wrapper.lambda().eq(UserDeviceGroup::getType, 1);
|
||||
wrapper.lambda().eq(UserDeviceGroup::getName, "用户顶级组织a");
|
||||
wrapper.eq(UserDeviceGroup::getType, 1);
|
||||
wrapper.eq(UserDeviceGroup::getName, "用户顶级组织a");
|
||||
} else {
|
||||
wrapper.lambda().eq(UserDeviceGroup::getType, 2);
|
||||
wrapper.lambda().eq(UserDeviceGroup::getName, "终端顶级组织b");
|
||||
wrapper.eq(UserDeviceGroup::getType, 2);
|
||||
wrapper.eq(UserDeviceGroup::getName, "终端顶级组织b");
|
||||
}
|
||||
UserDeviceGroup userDeviceGroup = groupMapper.selectOne(wrapper);
|
||||
if (ObjectUtils.isNotEmpty(userDeviceGroup)) {
|
||||
group.setParentId(userDeviceGroup.getId());
|
||||
group.setParentName(userDeviceGroup.getName());
|
||||
group.setPath(userDeviceGroup.getId().toString());
|
||||
// group.setIndex(userDeviceGroup.getId().toString());
|
||||
}
|
||||
} else {
|
||||
UserDeviceGroup groupParent = groupMapper.selectById(group.getParentId());
|
||||
|
@ -94,18 +93,15 @@ public class UserDeviceGroupServiceImpl extends ServiceImpl<UserDeviceGroupMappe
|
|||
@Override
|
||||
public Result<?> query(UserDeviceGroupReq groupReq) {
|
||||
UserDeviceGroup userDeviceGroup = BeanUtil.copyProperties(groupReq, UserDeviceGroup.class);
|
||||
QueryWrapper<UserDeviceGroup> wrapper = new QueryWrapper<>();
|
||||
if (ObjectUtils.isEmpty(userDeviceGroup.getType())) {
|
||||
log.error("分组类型为空:{}", JSONUtil.toJsonStr(groupReq));
|
||||
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||||
}
|
||||
wrapper.lambda().eq(UserDeviceGroup::getType, userDeviceGroup.getType());
|
||||
if (ObjectUtils.isNotEmpty(userDeviceGroup.getId())) {
|
||||
wrapper.lambda().eq(UserDeviceGroup::getId, userDeviceGroup.getId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(userDeviceGroup.getName())) {
|
||||
wrapper.lambda().eq(UserDeviceGroup::getName, userDeviceGroup.getName());
|
||||
}
|
||||
LambdaQueryWrapper<UserDeviceGroup> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserDeviceGroup::getType, userDeviceGroup.getType());
|
||||
wrapper.eq(ObjectUtils.isNotEmpty(userDeviceGroup.getId()), UserDeviceGroup::getId, userDeviceGroup.getId());
|
||||
wrapper.eq(StringUtils.isNotBlank(userDeviceGroup.getName()), UserDeviceGroup::getName, userDeviceGroup.getName());
|
||||
|
||||
List<UserDeviceGroup> userDeviceGroups = groupMapper.selectList(wrapper);
|
||||
if (CollectionUtil.isEmpty(userDeviceGroups)) {
|
||||
log.error("查询数据为空:{}", JSONUtil.toJsonStr(userDeviceGroups));
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.unisinsight.project.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -49,6 +50,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||
public Result<?> insert(UserReq userReq) {
|
||||
User user = BeanUtil.copyProperties(userReq, User.class);
|
||||
user.setCreateUser("admin");
|
||||
user.setUpdateUser("admin");
|
||||
int insert = userMapper.insert(user);
|
||||
log.info("用户新增insert:{}", insert);
|
||||
if (insert == 1) {
|
||||
|
@ -86,20 +88,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||
public Result<?> selectPageUser(UserReq userReq) {
|
||||
|
||||
Page<User> page = new Page<>(userReq.getPageNum(), userReq.getPageSize());
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (ObjectUtils.isNotEmpty(userReq.getUserGroupId())) {
|
||||
queryWrapper.lambda().eq(User::getUserGroupId, userReq.getUserGroupId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(userReq.getUserName())) {
|
||||
queryWrapper.lambda().like(User::getUserName, userReq.getUserName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(userReq.getIdentityNo())) {
|
||||
queryWrapper.lambda().eq(User::getIdentityNo, userReq.getIdentityNo());
|
||||
}
|
||||
if (StringUtils.isNotBlank(userReq.getCellPhone())) {
|
||||
queryWrapper.lambda().eq(User::getCellPhone, userReq.getCellPhone());
|
||||
}
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(userReq.getUserGroupId()), User::getUserGroupId, userReq.getUserGroupId());
|
||||
queryWrapper.like(StringUtils.isNotBlank(userReq.getUserName()), User::getUserName, userReq.getUserName());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(userReq.getIdentityNo()), User::getIdentityNo, userReq.getIdentityNo());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(userReq.getCellPhone()), User::getCellPhone, userReq.getCellPhone());
|
||||
queryWrapper.orderByAsc(User::getId);
|
||||
|
||||
IPage<User> userPage = userMapper.selectPage(page, queryWrapper);
|
||||
log.info("分页查询用户返回:{}", JSONUtil.toJsonStr(userPage));
|
||||
|
@ -119,12 +113,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||
user.setUserGroupName(userDeviceGroup.getName());
|
||||
}
|
||||
}
|
||||
}).sorted((u1, u2) -> {
|
||||
// 对结果按主键排序
|
||||
if (u1.getId() != null && u2.getId() != null) {
|
||||
return u1.getId().compareTo(u2.getId());
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
convert.setData(resList);
|
||||
return Result.successResult(convert);
|
||||
|
|
Loading…
Reference in New Issue