From c9c5035f757991bd2b3d71915c05a2582235e906 Mon Sep 17 00:00:00 2001 From: ck-chenkang Date: Mon, 6 Jul 2026 09:23:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A4=84=E7=90=86device=20id=E4=B8=BAnull?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=BB=99=E5=88=A0=E9=99=A4=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/OrganizationServiceImpl.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java index 7332b70a6..458d76e36 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java @@ -140,11 +140,16 @@ public class OrganizationServiceImpl implements OrganizationService { if (organizationMapper.selectCountByParentId(id) > 0) { throw exception(ORGANIZATION_EXITS_CHILDREN); } - DeviceLedgerDO deviceLedgerDO = deviceLedgerService.getDeviceLedger(organizationMapper.selectById(id).getMachineId()); - if (deviceLedgerDO != null) { - deviceLedgerDO.setWorkshop(null); - deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedgerDO, DeviceLedgerSaveReqVO.class)); + + Long deviceId = organizationMapper.selectById(id).getMachineId(); + if(deviceId != null){ // 处理device id为null,不给删除的情况 + DeviceLedgerDO deviceLedgerDO = deviceLedgerService.getDeviceLedger(deviceId); + if (deviceLedgerDO != null) { + deviceLedgerDO.setWorkshop(null); + deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedgerDO, DeviceLedgerSaveReqVO.class)); + } } + // 删除 organizationMapper.deleteById(id); // 设备台账关联产线