若依微服务2.0.4

修改金瑞铭以下问题:
同一场景下设备模型名称不能重复,包括新增和修改页面
dev 2.0.4
xins 7 months ago
parent 98357fdf5a
commit 25054ef36d

@ -230,6 +230,9 @@ public class HwDeviceController extends BaseController {
} }
/**
* TDengine
*/
@RequiresPermissions("business:device:rebuild") @RequiresPermissions("business:device:rebuild")
@Log(title = "设备信息", businessType = BusinessType.REBUILD) @Log(title = "设备信息", businessType = BusinessType.REBUILD)
@GetMapping("/rebuildTdTables") @GetMapping("/rebuildTdTables")

@ -138,6 +138,9 @@ public class HwDeviceModeController extends BaseController {
return success(hwSceneService.selectHwSceneList4Select(scene)); return success(hwSceneService.selectHwSceneList4Select(scene));
} }
/**
*
*/
@RequiresPermissions("business:deviceMode:rebuild") @RequiresPermissions("business:deviceMode:rebuild")
@Log(title = "设备模型", businessType = BusinessType.REBUILD) @Log(title = "设备模型", businessType = BusinessType.REBUILD)
@GetMapping("/rebuildTdSuperTables") @GetMapping("/rebuildTdSuperTables")

@ -7,15 +7,15 @@ import com.ruoyi.business.domain.HwDeviceModeParameter;
/** /**
* Mapper * Mapper
* *
* @author xins * @author xins
* @date 2023-09-04 * @date 2023-09-04
*/ */
public interface HwDeviceModeMapper public interface HwDeviceModeMapper
{ {
/** /**
* *
* *
* @param deviceModeId * @param deviceModeId
* @return * @return
*/ */
@ -23,7 +23,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@ -31,7 +31,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@ -39,7 +39,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@ -47,7 +47,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param deviceModeId * @param deviceModeId
* @return * @return
*/ */
@ -55,7 +55,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param deviceModeIds * @param deviceModeIds
* @return * @return
*/ */
@ -63,24 +63,24 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param deviceModeIds * @param deviceModeIds
* @return * @return
*/ */
public int deleteHwDeviceModeFunctionByDeviceModeIds(Long[] deviceModeIds); public int deleteHwDeviceModeFunctionByDeviceModeIds(Long[] deviceModeIds);
/** /**
* *
* *
* @param hwDeviceModeFunctionList * @param hwDeviceModeFunctionList
* @return * @return
*/ */
public int batchHwDeviceModeFunction(List<HwDeviceModeFunction> hwDeviceModeFunctionList); public int batchHwDeviceModeFunction(List<HwDeviceModeFunction> hwDeviceModeFunctionList);
/** /**
* *
* *
* @param deviceModeId ID * @param deviceModeId ID
* @return * @return
*/ */
@ -121,7 +121,7 @@ public interface HwDeviceModeMapper
/** /**
* *
* *
* @param deviceModeId ID * @param modeFunctionId ID
* @return * @return
*/ */
public int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId); public int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId);

@ -88,6 +88,17 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Transactional @Transactional
@Override @Override
public int insertHwDeviceMode(HwDeviceMode hwDeviceMode) { public int insertHwDeviceMode(HwDeviceMode hwDeviceMode) {
//判断同一场景下模型名称是否重复
String deviceModeName = hwDeviceMode.getDeviceModeName();
Long sceneId = hwDeviceMode.getSceneId();
HwDeviceMode queryDeviceMode = new HwDeviceMode();
queryDeviceMode.setDeviceModeName(deviceModeName);
queryDeviceMode.setSceneId(sceneId);
List<HwDeviceMode> deviceModes = hwDeviceModeMapper.selectHwDeviceModeList(queryDeviceMode);
if (deviceModes != null && !deviceModes.isEmpty()) {
throw new ServiceException("此场景下设备模型名称重复");
}
//先判断是否有重复的标识符 //先判断是否有重复的标识符
List<HwDeviceModeFunction> hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList(); List<HwDeviceModeFunction> hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList();
@ -135,6 +146,22 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
@Transactional @Transactional
@Override @Override
public int updateHwDeviceMode(HwDeviceMode hwDeviceMode) { public int updateHwDeviceMode(HwDeviceMode hwDeviceMode) {
String deviceModeName = hwDeviceMode.getDeviceModeName();
Long sceneId = hwDeviceMode.getSceneId();
HwDeviceMode queryDeviceMode = new HwDeviceMode();
queryDeviceMode.setDeviceModeName(deviceModeName);
queryDeviceMode.setSceneId(sceneId);
List<HwDeviceMode> deviceModes = hwDeviceModeMapper.selectHwDeviceModeList(queryDeviceMode);
if (deviceModes != null && !deviceModes.isEmpty()) {
List<HwDeviceMode> 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.setUpdateBy(SecurityUtils.getUsername());
hwDeviceMode.setUpdateTime(DateUtils.getNowDate()); hwDeviceMode.setUpdateTime(DateUtils.getNowDate());
// hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(hwDeviceMode.getDeviceModeId()); // hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(hwDeviceMode.getDeviceModeId());
@ -364,7 +391,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
} }
/** /**
* * ()
* *
* @description * @description
* @author xins * @author xins
@ -397,7 +424,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
//过滤只有数值的属性才可以定义报警规则.或过滤出服务可以添加关联设备 //过滤只有数值的属性才可以定义报警规则.或过滤出服务可以添加关联设备
List<HwDeviceModeFunction> filterDeviceModeFunctions = deviceModeFunctions.stream() List<HwDeviceModeFunction> filterDeviceModeFunctions = deviceModeFunctions.stream()
.filter(deviceModeFunction -> (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && .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.FLOAT.getDataCode()))
|| String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.DOUBLE.getDataCode())))) || String.valueOf(deviceModeFunction.getDataType()).equals(String.valueOf(DataTypeEnums.DOUBLE.getDataCode()))))
|| (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE))) || (deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_SERVICE)))

@ -830,7 +830,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
} }
/** /**
* @description tdengine * @description tdengine(TDengine)
* @author xins * @author xins
* @date 2023-10-10 20:05 * @date 2023-10-10 20:05
*/ */

Loading…
Cancel
Save