若依微服务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")

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

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