分配设备
This commit is contained in:
@ -0,0 +1,32 @@
|
|||||||
|
package com.fuyuanshen.utils.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-2019:08
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 表示 NanoId 生成时使用的长度配置
|
||||||
|
*/
|
||||||
|
public enum NanoIdLengthEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认设备类型 ID 长度
|
||||||
|
*/
|
||||||
|
DEVICE_TYPE_ID(10),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更长的唯一标识符,用于高并发场景
|
||||||
|
*/
|
||||||
|
HIGH_CONCURRENCY(15);
|
||||||
|
|
||||||
|
private final int length;
|
||||||
|
|
||||||
|
NanoIdLengthEnum(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
|||||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||||
import com.alibaba.excel.converters.bytearray.ByteArrayImageConverter;
|
import com.alibaba.excel.converters.bytearray.ByteArrayImageConverter;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.fuyuanshen.modules.system.converter.IgnoreFailedImageConverter;
|
import com.fuyuanshen.modules.system.converter.IgnoreFailedImageConverter;
|
||||||
|
|
||||||
@ -43,6 +44,11 @@ public class DeviceExcelImportDTO {
|
|||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
|
@ExcelProperty("设备IMEI")
|
||||||
|
@ColumnWidth(20)
|
||||||
|
@ApiModelProperty(value = "设备IMEI")
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
@ExcelProperty("设备SN")
|
@ExcelProperty("设备SN")
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
private String deviceSn;
|
private String deviceSn;
|
||||||
|
@ -31,6 +31,7 @@ import com.fuyuanshen.modules.system.service.DeviceTypeGrantsService;
|
|||||||
import com.fuyuanshen.modules.system.service.UserService;
|
import com.fuyuanshen.modules.system.service.UserService;
|
||||||
import com.fuyuanshen.modules.utils.NanoId;
|
import com.fuyuanshen.modules.utils.NanoId;
|
||||||
import com.fuyuanshen.utils.*;
|
import com.fuyuanshen.utils.*;
|
||||||
|
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -267,7 +268,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 自定义16位id
|
// 自定义16位id
|
||||||
Long generatedId = NanoId.generate(16);
|
Long generatedId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||||
|
|
||||||
// -- 记录分配历史
|
// -- 记录分配历史
|
||||||
DeviceAssignments deviceAssignments = new DeviceAssignments();
|
DeviceAssignments deviceAssignments = new DeviceAssignments();
|
||||||
@ -353,7 +354,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
deviceMapper.update(updateDevice, wrapper);
|
deviceMapper.update(updateDevice, wrapper);
|
||||||
|
|
||||||
// 自定义16位id
|
// 自定义16位id
|
||||||
Long generatedId = NanoId.generate(16);
|
Long generatedId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||||
// -- 授权设备类型给客户
|
// -- 授权设备类型给客户
|
||||||
// QueryWrapper<DeviceTypeGrants> deviceTypeGrantsQueryWrapper = new QueryWrapper<>();
|
// QueryWrapper<DeviceTypeGrants> deviceTypeGrantsQueryWrapper = new QueryWrapper<>();
|
||||||
// Long count = deviceTypeGrantsMapper.selectCount(deviceTypeGrantsQueryWrapper);
|
// Long count = deviceTypeGrantsMapper.selectCount(deviceTypeGrantsQueryWrapper);
|
||||||
@ -384,7 +385,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
// 查询设备类型
|
// 查询设备类型
|
||||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
// SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator();
|
// SnowflakeGenerator snowflakeGenerator = new SnowflakeGenerator();
|
||||||
Long id = NanoId.generate(16);
|
Long id = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||||
deviceType.setId(id);
|
deviceType.setId(id);
|
||||||
deviceType.setCreateTime(timestamp);
|
deviceType.setCreateTime(timestamp);
|
||||||
deviceType.setCreateBy(currentUser.getUsername());
|
deviceType.setCreateBy(currentUser.getUsername());
|
||||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
||||||
import com.fuyuanshen.modules.system.mapper.DeviceTypeGrantsMapper;
|
import com.fuyuanshen.modules.system.mapper.DeviceTypeGrantsMapper;
|
||||||
import com.fuyuanshen.modules.utils.NanoId;
|
import com.fuyuanshen.modules.utils.NanoId;
|
||||||
|
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
||||||
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
||||||
@ -125,7 +126,7 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DeviceType resources) {
|
public void create(DeviceType resources) {
|
||||||
Long deviceTypeId = NanoId.generate(16);
|
Long deviceTypeId = NanoId.generate(NanoIdLengthEnum.HIGH_CONCURRENCY.getLength());
|
||||||
resources.setId(deviceTypeId);
|
resources.setId(deviceTypeId);
|
||||||
resources.setCustomerId(SecurityUtils.getCurrentUserId());
|
resources.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
deviceTypeMapper.insert(resources);
|
deviceTypeMapper.insert(resources);
|
||||||
@ -137,7 +138,6 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
deviceTypeGrants.setGrantorCustomerId(SecurityUtils.getCurrentUserId());
|
deviceTypeGrants.setGrantorCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
deviceTypeGrants.setGrantedAt(new Date());
|
deviceTypeGrants.setGrantedAt(new Date());
|
||||||
deviceTypeGrantsMapper.insert(deviceTypeGrants);
|
deviceTypeGrantsMapper.insert(deviceTypeGrants);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user