若依微服务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")
@Log(title = "设备信息", businessType = BusinessType.REBUILD)
@GetMapping("/rebuildTdTables")

@ -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")

@ -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<HwDeviceModeFunction> hwDeviceModeFunctionList);
/**
*
*
*
* @param deviceModeId ID
* @return
*/
@ -121,7 +121,7 @@ public interface HwDeviceModeMapper
/**
*
*
* @param deviceModeId ID
* @param modeFunctionId ID
* @return
*/
public int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId);

@ -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<HwDeviceMode> deviceModes = hwDeviceModeMapper.selectHwDeviceModeList(queryDeviceMode);
if (deviceModes != null && !deviceModes.isEmpty()) {
throw new ServiceException("此场景下设备模型名称重复");
}
//先判断是否有重复的标识符
List<HwDeviceModeFunction> 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<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.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<HwDeviceModeFunction> 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)))

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

Loading…
Cancel
Save