设备接口修改1

This commit is contained in:
qinjie 2024-11-25 16:29:26 +08:00
parent a93f20772b
commit e31f612f09
1 changed files with 10 additions and 0 deletions

View File

@ -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<DeviceDao, Device> implements
if(CollectionUtil.isNotEmpty(list)) {
throw new BusinessException("已有相同设备编码,请重新输入");
}
GasWell gasWell = gasWellService.getOne(new LambdaQueryWrapper<GasWell>().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()));