修改设备类型
This commit is contained in:
@ -137,4 +137,13 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
|||||||
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(@Param("days") int days);
|
List<DeviceUsageFrequencyVo> getDeviceUsageFrequency(@Param("days") int days);
|
||||||
|
|
||||||
List<OnlineStatusVo> queryOnlineStatusList();
|
List<OnlineStatusVo> queryOnlineStatusList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备类型ID查询设备数量
|
||||||
|
*
|
||||||
|
* @param deviceTypeId 设备类型ID
|
||||||
|
* @return 设备数量
|
||||||
|
*/
|
||||||
|
int countByDeviceTypeId(@Param("deviceTypeId") Long deviceTypeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -224,6 +224,16 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
throw new RuntimeException("设备类型不存在");
|
throw new RuntimeException("设备类型不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!deviceType.getTypeName().equals(resources.getTypeName())) {
|
||||||
|
int count = deviceMapper.countByDeviceTypeId(deviceType.getId());
|
||||||
|
if (count > 0) {
|
||||||
|
throw new RuntimeException("该设备类型下已有绑定设备,无法修改设备类型名称!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
||||||
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
|
||||||
// if (CollectionUtil.isNotEmpty(devices)) {
|
// if (CollectionUtil.isNotEmpty(devices)) {
|
||||||
|
|||||||
@ -497,4 +497,11 @@
|
|||||||
FROM device a left join device_type b on a.device_type = b.id where b.communication_mode in (0, 2) and a.online_status in (1,2)
|
FROM device a left join device_type b on a.device_type = b.id where b.communication_mode in (0, 2) and a.online_status in (1,2)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据设备类型ID查询设备数量 -->
|
||||||
|
<select id="countByDeviceTypeId" resultType="int">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM device
|
||||||
|
WHERE device_type = #{deviceTypeId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user