From e31f612f09b734274d085b7486887dbd2203720e Mon Sep 17 00:00:00 2001 From: qinjie <463333974@qq.com> Date: Mon, 25 Nov 2024 16:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gaswellwatch/service/impl/DeviceServiceImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java index 029f789..60ab8d4 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java @@ -14,6 +14,7 @@ import com.isu.gaswellwatch.dto.DeviceEditDTO; import com.isu.gaswellwatch.entity.BlockDepartment; import com.isu.gaswellwatch.entity.Department; import com.isu.gaswellwatch.entity.Device; +import com.isu.gaswellwatch.entity.GasWell; import com.isu.gaswellwatch.exception.BusinessException; import com.isu.gaswellwatch.service.BlockDepartmentService; import com.isu.gaswellwatch.service.DepartmentService; @@ -56,6 +57,15 @@ public class DeviceServiceImpl extends ServiceImpl implements if(CollectionUtil.isNotEmpty(list)) { throw new BusinessException("已有相同设备编码,请重新输入"); } + + GasWell gasWell = gasWellService.getOne(new LambdaQueryWrapper().eq(GasWell::getId, deviceCreateDTO.getGasWell())); + if(gasWell==null) { + throw new BusinessException("该气井不存在"); + } + if(gasWell.getDeviceId()!=null) { + throw new BusinessException("该气井已存在绑定设备,无法添加新设备"); + } + Device device = ConverterUtil.convert(deviceCreateDTO, Device.class); //code必须为整形,用于在缓存中查询设备的上报数据 device.setId(Long.valueOf(deviceCreateDTO.getCode()));