撤回设备

This commit is contained in:
2025-07-18 15:06:39 +08:00
parent 34188f20dd
commit ad06811747
2 changed files with 5 additions and 52 deletions

View File

@ -34,7 +34,7 @@ public class DeviceAssignments extends TenantEntity {
private Long fromCustomerId; private Long fromCustomerId;
/** /**
* 接收方 * 接收方(当前设备所处位置)
*/ */
private Long toCustomerId; private Long toCustomerId;

View File

@ -44,6 +44,7 @@ import com.fuyuanshen.system.domain.vo.SysOssVo;
import com.fuyuanshen.system.service.ISysOssService; import com.fuyuanshen.system.service.ISysOssService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -319,9 +320,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>(); List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
for (DeviceAssignments assignment : assignments) { for (DeviceAssignments assignment : assignments) {
if (assignment.getToCustomerId() != null) { if (assignment.getToCustomerId() != null && assignment.getToCustomerId() != 0L) {
log.info("设备已经分配客户!!!"); log.info("设备已经分配客户!!!");
continue; throw new RuntimeException("设备已经分配客户!!!");
} }
Device device = deviceMapper.selectById(assignment.getDeviceId()); Device device = deviceMapper.selectById(assignment.getDeviceId());
@ -412,54 +413,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
/**
* 撤回设备
*
* @param ids
*/
// @Override
// public void withdrawDevice(List<Long> ids) {
// ids.forEach((id) -> {
// List<Device> deviceChain = getDeviceChain(id);
// deviceChain.forEach((device) -> {
// device.setDeviceStatus(DeviceStatusEnum.INVALID.getCode());
// deviceMapper.updateById(device);
// });
// });
//
// ids.forEach((id) -> {
// Device device = new Device();
// device.setId(id);
// device.setCustomerId(null);
// device.setCustomerName("");
// deviceMapper.updateById(device);
// });
//
// }
//
//
// public List<Device> getDeviceChain(Long originalDeviceId) {
// List<Device> chain = new ArrayList<>();
// Set<Long> visited = new HashSet<>(); // 防止循环引用
// findNext(chain, visited, originalDeviceId);
// return chain;
// }
//
// private void findNext(List<Device> chain, Set<Long> visited, Long currentOriginalDeviceId) {
// if (visited.contains(currentOriginalDeviceId)) {
// log.info("检测到循环引用,终止递归");
// return;
// }
// visited.add(currentOriginalDeviceId);
//
// List<Device> devices = deviceMapper.findByOriginalDeviceId(currentOriginalDeviceId);
// for (Device device : devices) {
// chain.add(device);
// findNext(chain, visited, device.getId());
// }
// }
/** /**
* 撤回设备 * 撤回设备
* *
@ -474,7 +427,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
Device device = deviceMapper.selectById(assignment.getDeviceId()); Device device = deviceMapper.selectById(assignment.getDeviceId());
// 接收者 // 接收者
assignment.setAssigneeName(""); assignment.setAssigneeName("");
assignment.setToCustomerId(null); assignment.setToCustomerId(0L);
deviceAssignmentsMapper.updateById(assignment); deviceAssignmentsMapper.updateById(assignment);
// 获取所有已分配的设备 // 获取所有已分配的设备