forked from dyf/fys-Multi-tenant
删除设备 逻辑修改
This commit is contained in:
@ -37,7 +37,7 @@ public enum BusinessType {
|
||||
EXPORT,
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*
|
||||
*/
|
||||
IMPORT,
|
||||
|
||||
|
@ -6,17 +6,17 @@ import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.bo.UserAppBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.service.AppUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
|
@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
@ -42,6 +44,7 @@ import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -54,6 +57,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -272,20 +276,23 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
public void deleteAll(List<Long> ids) {
|
||||
List<Long> invalidIds = new ArrayList<>();
|
||||
|
||||
for (Long id : ids) {
|
||||
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
||||
Device deviceType = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
||||
|
||||
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
||||
throw new BadRequestException(deviceType.getDeviceName() + ":设备已分配,请先解绑设备!!!");
|
||||
}
|
||||
|
||||
// 接收者
|
||||
if (Objects.equals(deviceAssignment.getAssigneeId(), deviceType.getOriginalOwnerId())) {
|
||||
invalidIds.add(deviceAssignment.getDeviceId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deviceAssignmentsMapper.deleteByIds(ids);
|
||||
//
|
||||
// for (Long id : ids) {
|
||||
//
|
||||
// Device deviceType = deviceMapper.selectById(id);
|
||||
// if (deviceType == null || !Objects.equals(deviceType.getCurrentOwnerId(), LoginHelper.getUserId())) {
|
||||
// invalidIds.add(id);
|
||||
// }
|
||||
// }
|
||||
// if (!invalidIds.isEmpty()) {
|
||||
// throw new RuntimeException("以下设备无法删除(ID 不存在或无权限): " + invalidIds);
|
||||
// }
|
||||
//
|
||||
// deviceMapper.deleteByIds(ids);
|
||||
deviceMapper.deleteByIds(invalidIds);
|
||||
}
|
||||
|
||||
|
||||
@ -570,7 +577,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备MAC号
|
||||
*
|
||||
|
Reference in New Issue
Block a user