From 25054ef36dee3ec67a098729442510b88b50bb43 Mon Sep 17 00:00:00 2001 From: xins Date: Sun, 28 Apr 2024 10:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D=E5=8A=A12.?= =?UTF-8?q?0.4=20=E4=BF=AE=E6=94=B9=E9=87=91=E7=91=9E=E9=93=AD=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E9=97=AE=E9=A2=98=EF=BC=9A=20=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=8D=E8=83=BD=E9=87=8D=E5=A4=8D=EF=BC=8C?= =?UTF-8?q?=E5=8C=85=E6=8B=AC=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HwDeviceController.java | 3 ++ .../controller/HwDeviceModeController.java | 3 ++ .../business/mapper/HwDeviceModeMapper.java | 28 ++++++++--------- .../service/impl/HwDeviceModeServiceImpl.java | 31 +++++++++++++++++-- .../service/impl/HwDeviceServiceImpl.java | 2 +- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java index 35bf56e..273a192 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceController.java @@ -230,6 +230,9 @@ public class HwDeviceController extends BaseController { } + /** + * 重新创建所有设备子表,对于已经创建的不再创建,只是创建没有在TDengine创建子表的设备进行重新创建 + */ @RequiresPermissions("business:device:rebuild") @Log(title = "设备信息", businessType = BusinessType.REBUILD) @GetMapping("/rebuildTdTables") diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java index d3477fc..4a7360c 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwDeviceModeController.java @@ -138,6 +138,9 @@ public class HwDeviceModeController extends BaseController { return success(hwSceneService.selectHwSceneList4Select(scene)); } + /** + * 创建超级表,将所有设备模型中没有创建超级表的创建一下,已经创建过的不需要再创建 + */ @RequiresPermissions("business:deviceMode:rebuild") @Log(title = "设备模型", businessType = BusinessType.REBUILD) @GetMapping("/rebuildTdSuperTables") diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java index bd3f146..d4297c2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/mapper/HwDeviceModeMapper.java @@ -7,15 +7,15 @@ import com.ruoyi.business.domain.HwDeviceModeParameter; /** * 设备模型Mapper接口 - * + * * @author xins * @date 2023-09-04 */ -public interface HwDeviceModeMapper +public interface HwDeviceModeMapper { /** * 查询设备模型 - * + * * @param deviceModeId 设备模型主键 * @return 设备模型 */ @@ -23,7 +23,7 @@ public interface HwDeviceModeMapper /** * 查询设备模型列表 - * + * * @param hwDeviceMode 设备模型 * @return 设备模型集合 */ @@ -31,7 +31,7 @@ public interface HwDeviceModeMapper /** * 新增设备模型 - * + * * @param hwDeviceMode 设备模型 * @return 结果 */ @@ -39,7 +39,7 @@ public interface HwDeviceModeMapper /** * 修改设备模型 - * + * * @param hwDeviceMode 设备模型 * @return 结果 */ @@ -47,7 +47,7 @@ public interface HwDeviceModeMapper /** * 删除设备模型 - * + * * @param deviceModeId 设备模型主键 * @return 结果 */ @@ -55,7 +55,7 @@ public interface HwDeviceModeMapper /** * 批量删除设备模型 - * + * * @param deviceModeIds 需要删除的数据主键集合 * @return 结果 */ @@ -63,24 +63,24 @@ public interface HwDeviceModeMapper /** * 批量删除设备模型功能 - * + * * @param deviceModeIds 需要删除的数据主键集合 * @return 结果 */ public int deleteHwDeviceModeFunctionByDeviceModeIds(Long[] deviceModeIds); - + /** * 批量新增设备模型功能 - * + * * @param hwDeviceModeFunctionList 设备模型功能列表 * @return 结果 */ public int batchHwDeviceModeFunction(List hwDeviceModeFunctionList); - + /** * 通过设备模型主键删除设备模型功能信息 - * + * * @param deviceModeId 设备模型ID * @return 结果 */ @@ -121,7 +121,7 @@ public interface HwDeviceModeMapper /** * 通过设备模型功能主键删除设备模型功能参数信息 * - * @param deviceModeId 设备模型功能ID + * @param modeFunctionId 设备模型功能ID * @return 结果 */ public int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index 13a6ca6..61187a2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -88,6 +88,17 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { @Transactional @Override public int insertHwDeviceMode(HwDeviceMode hwDeviceMode) { + //判断同一场景下模型名称是否重复 + String deviceModeName = hwDeviceMode.getDeviceModeName(); + Long sceneId = hwDeviceMode.getSceneId(); + HwDeviceMode queryDeviceMode = new HwDeviceMode(); + queryDeviceMode.setDeviceModeName(deviceModeName); + queryDeviceMode.setSceneId(sceneId); + List deviceModes = hwDeviceModeMapper.selectHwDeviceModeList(queryDeviceMode); + if (deviceModes != null && !deviceModes.isEmpty()) { + throw new ServiceException("此场景下设备模型名称重复"); + } + //先判断是否有重复的标识符 List hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList(); @@ -135,6 +146,22 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { @Transactional @Override public int updateHwDeviceMode(HwDeviceMode hwDeviceMode) { + String deviceModeName = hwDeviceMode.getDeviceModeName(); + Long sceneId = hwDeviceMode.getSceneId(); + HwDeviceMode queryDeviceMode = new HwDeviceMode(); + queryDeviceMode.setDeviceModeName(deviceModeName); + queryDeviceMode.setSceneId(sceneId); + List deviceModes = hwDeviceModeMapper.selectHwDeviceModeList(queryDeviceMode); + + if (deviceModes != null && !deviceModes.isEmpty()) { + List filterDeviceModes = deviceModes.stream().filter(hwDm -> !hwDm.getDeviceModeId().equals(hwDeviceMode.getDeviceModeId()) + && hwDm.getDeviceModeName().equals(hwDeviceMode.getDeviceModeName())).collect(Collectors.toList()); + if (filterDeviceModes != null && !filterDeviceModes.isEmpty()) { + throw new ServiceException("此场景下设备模型名称重复"); + } + } + + hwDeviceMode.setUpdateBy(SecurityUtils.getUsername()); hwDeviceMode.setUpdateTime(DateUtils.getNowDate()); // hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(hwDeviceMode.getDeviceModeId()); @@ -364,7 +391,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { } /** - * 重建所有设备模型的超级表 + * 重建所有设备模型的超级表(创建超级表,将所有设备模型中没有创建超级表的创建一下,已经创建过的不需要再创建) * * @description * @author xins @@ -397,7 +424,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { //过滤只有数值的属性才可以定义报警规则.或过滤出服务可以添加关联设备 List filterDeviceModeFunctions = deviceModeFunctions.stream() .filter(deviceModeFunction -> (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && - deviceModeFunction.getDataType()!=null && (String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.INT.getDataCode())) + deviceModeFunction.getDataType() != null && (String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.INT.getDataCode())) || String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.FLOAT.getDataCode())) || String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.DOUBLE.getDataCode())))) || (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE))) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index 35bea9f..7fed586 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -830,7 +830,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { } /** - * @description 重建tdengine所有设备表 + * @description 重建tdengine所有设备表(重新创建所有设备子表,对于已经创建的不再创建,只是创建没有在TDengine创建子表的设备进行重新创建) * @author xins * @date 2023-10-10 20:05 */