From 00a4394b430d8cfa4d0d553d024804b914496526 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Thu, 20 Nov 2025 16:15:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DeviceServiceImpl.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java index 6e9551c1..78a83f51 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java @@ -192,10 +192,21 @@ public class DeviceServiceImpl extends ServiceImpl impleme throw new BadRequestException("设备IMEI已存在!!!"); } + DeviceTypeGrants typeGrants = new DeviceTypeGrants(); + + if (deviceForm.getDeviceType() != null) { + DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria(); + queryCriteria.setDeviceTypeId(deviceForm.getDeviceType()); + typeGrants = deviceTypeGrantsMapper.selectById(queryCriteria.getDeviceTypeId()); + if (typeGrants == null) { + throw new Exception("设备类型不存在!!!"); + } + } + // 检查设备类型是否存在,如果不存在则创建 DeviceType deviceType = null; if (deviceForm.getDeviceType() != null) { - deviceType = deviceTypeMapper.selectById(deviceForm.getDeviceType()); + deviceType = deviceTypeMapper.selectById(typeGrants.getDeviceTypeId()); } else if (deviceForm.getTypeName() != null) { deviceType = deviceTypeMapper.selectOne(new QueryWrapper().eq("type_name", deviceForm.getTypeName())); } @@ -278,7 +289,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 保存图片并获取URL if (deviceForm.getFile() != null) { String fileHash = fileHashUtil.hash(deviceForm.getFile()); - SysOssVo upload = ossService.updateHash(deviceForm.getFile(),fileHash); + SysOssVo upload = ossService.updateHash(deviceForm.getFile(), fileHash); // 设置图片路径 deviceForm.setDevicePic(upload.getUrl()); } @@ -353,7 +364,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme // 处理上传的图片 if (deviceForm.getFile() != null) { String fileHash = fileHashUtil.hash(deviceForm.getFile()); - SysOssVo oss = ossService.updateHash(deviceForm.getFile(),fileHash); + SysOssVo oss = ossService.updateHash(deviceForm.getFile(), fileHash); // 强制将HTTP替换为HTTPS if (oss.getUrl() != null && oss.getUrl().startsWith("http://")) { oss.setUrl(oss.getUrl().replaceFirst("^http://", "https://"));