From ad0681174768f84d97510156db3c5526ea0c2c8d Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Fri, 18 Jul 2025 15:06:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=A4=E5=9B=9E=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/domain/DeviceAssignments.java | 2 +- .../service/impl/DeviceServiceImpl.java | 55 ++----------------- 2 files changed, 5 insertions(+), 52 deletions(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAssignments.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAssignments.java index 071cb5a..e3ea3ce 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAssignments.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAssignments.java @@ -34,7 +34,7 @@ public class DeviceAssignments extends TenantEntity { private Long fromCustomerId; /** - * 接收方 + * 接收方(当前设备所处位置) */ private Long toCustomerId; diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java index f0d1072..f9baab1 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java @@ -44,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; @@ -319,9 +320,9 @@ public class DeviceServiceImpl extends ServiceImpl impleme List deviceTypeGrants = new ArrayList<>(); for (DeviceAssignments assignment : assignments) { - if (assignment.getToCustomerId() != null) { + if (assignment.getToCustomerId() != null && assignment.getToCustomerId() != 0L) { log.info("设备已经分配客户!!!"); - continue; + throw new RuntimeException("设备已经分配客户!!!"); } Device device = deviceMapper.selectById(assignment.getDeviceId()); @@ -412,54 +413,6 @@ public class DeviceServiceImpl extends ServiceImpl impleme } - /** - * 撤回设备 - * - * @param ids - */ - // @Override - // public void withdrawDevice(List ids) { - // ids.forEach((id) -> { - // List 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 getDeviceChain(Long originalDeviceId) { - // List chain = new ArrayList<>(); - // Set visited = new HashSet<>(); // 防止循环引用 - // findNext(chain, visited, originalDeviceId); - // return chain; - // } - // - // private void findNext(List chain, Set visited, Long currentOriginalDeviceId) { - // if (visited.contains(currentOriginalDeviceId)) { - // log.info("检测到循环引用,终止递归"); - // return; - // } - // visited.add(currentOriginalDeviceId); - // - // List 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 impleme Device device = deviceMapper.selectById(assignment.getDeviceId()); // 接收者 assignment.setAssigneeName(""); - assignment.setToCustomerId(null); + assignment.setToCustomerId(0L); deviceAssignmentsMapper.updateById(assignment); // 获取所有已分配的设备