lengfaqiang 2 лет назад
Родитель
Сommit
9c20cae85e

+ 9 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -99,6 +99,15 @@ public class DeviceService {
         if (Objects.isNull(device)) {
         if (Objects.isNull(device)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
         }
         }
+        //验证设备存在与项目关联管理 设备不允许删除
+        List<KwsProjectDevice> projectDevices = projectDeviceMapper.selectList(
+                new LambdaQueryWrapper<KwsProjectDevice>()
+                        .eq(KwsProjectDevice::getDeviceId, ids)
+                        .eq(KwsProjectDevice::getDelFlag, NumberConstant.ZERO)
+        );
+        if (!CollectionUtils.isEmpty(projectDevices) && projectDevices.size()>0){
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE,"设备与项目存在关联,解除关联后,可允许删除");
+        }
         HeaderData headerData = commonService.getHeaderData(response);
         HeaderData headerData = commonService.getHeaderData(response);
         //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         int update = deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
         int update = deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()