|
@@ -119,6 +119,23 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
queryWrapper.eq("org_id", envDeviceAddParam.getOrgId())
|
|
|
.eq("device_code", envDeviceAddParam.getDeviceCode())
|
|
|
.or().eq("install_position", envDeviceAddParam.getInstallPosition());
|
|
|
+
|
|
|
+ if (basePigpenMapper.selectById(envDeviceAddParam.getInstallPosition()).getType() != 2) {
|
|
|
+ throw new CommonException("只能在单元添加设备");
|
|
|
+ }
|
|
|
+ if (this.count(new QueryWrapper<EnvDevice>().lambda()
|
|
|
+ .eq(EnvDevice::getOrgId,envDeviceAddParam.getOrgId())
|
|
|
+ .eq(EnvDevice::getDeviceCode,envDevice.getDeviceCode())
|
|
|
+ .ne(EnvDevice::getId,envDevice.getId())) > 0) {
|
|
|
+ throw new CommonException("存在相同设备编号,编号为:{}",envDevice.getDeviceCode());
|
|
|
+ }
|
|
|
+ if (this.count(new QueryWrapper<EnvDevice>().lambda()
|
|
|
+ .eq(EnvDevice::getOrgId,envDeviceAddParam.getOrgId())
|
|
|
+ .eq(EnvDevice::getDeviceName,envDevice.getDeviceName())
|
|
|
+ .ne(EnvDevice::getId,envDevice.getId())) > 0) {
|
|
|
+ throw new CommonException("存在相同设备名称,名称为:{}",envDevice.getDeviceName());
|
|
|
+ }
|
|
|
+
|
|
|
if (ObjectUtil.isEmpty(envDeviceMapper.selectOne(queryWrapper))) {
|
|
|
for (int i = 1; i <= envDeviceAddParam.getFanNum(); i++) {
|
|
|
EnvDeviceEquipment equipment = new EnvDeviceEquipment();
|
|
@@ -149,7 +166,7 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
this.save(envDevice);
|
|
|
return CommonResult.ok();
|
|
|
} else {
|
|
|
- return new CommonResult(500, "设备编号重复或者安装位置已存在设备", false);
|
|
|
+ throw new CommonException("设备编号重复或者安装位置已存在设备");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -178,6 +195,10 @@ public class EnvDeviceServiceImpl extends ServiceImpl<EnvDeviceMapper, EnvDevice
|
|
|
.ne(EnvDevice::getId,envDevice.getId())) > 0) {
|
|
|
throw new CommonException("该位置已存在设备!");
|
|
|
}
|
|
|
+ if (basePigpenMapper.selectById(envDeviceEditParam.getInstallPosition()).getType() != 2) {
|
|
|
+ throw new CommonException("只能在单元添加设备");
|
|
|
+ }
|
|
|
+
|
|
|
equipmentMapper.delete(new QueryWrapper<EnvDeviceEquipment>().lambda()
|
|
|
.eq(EnvDeviceEquipment::getDeviceCode,envDeviceEditParam.getDeviceCode())
|
|
|
.eq(EnvDeviceEquipment::getOrgId,envDeviceEditParam.getOrgId()));
|