2.4G设备上报技术方案
This commit is contained in:
@ -209,6 +209,20 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
DeviceTypeGrants typeGrants = new DeviceTypeGrants();
|
||||
|
||||
// 修改为:
|
||||
Long userId;
|
||||
LoginUser loginUser;
|
||||
try {
|
||||
loginUser = LoginHelper.getLoginUser();
|
||||
userId = loginUser != null ? loginUser.getUserId() : 1938143703108689922L; // 如果没有登录用户,使用默认系统用户ID
|
||||
} catch (Exception e) {
|
||||
userId = 1938143703108689922L; // 出现异常时使用默认系统用户ID
|
||||
loginUser = new LoginUser();
|
||||
loginUser.setUserId(userId);
|
||||
loginUser.setNickname("admin");
|
||||
loginUser.setTenantId("894078"); // 设置租户ID
|
||||
}
|
||||
|
||||
if (deviceForm.getDeviceType() != null) {
|
||||
DeviceTypeQueryCriteria queryCriteria = new DeviceTypeQueryCriteria();
|
||||
queryCriteria.setDeviceTypeId(deviceForm.getDeviceType());
|
||||
@ -281,8 +295,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
throw new RuntimeException("设备类型名称已存在,无法新增!!!");
|
||||
}
|
||||
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
newDeviceType.setCreateByName(loginUser.getNickname());
|
||||
newDeviceType.setTenantId(loginUser.getTenantId());
|
||||
deviceTypeMapper.insert(newDeviceType);
|
||||
|
||||
// 重新查询确保获取到正确的ID
|
||||
@ -294,6 +308,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
deviceTypeGrants.setCustomerId(loginUser.getUserId());
|
||||
deviceTypeGrants.setGrantorCustomerId(loginUser.getUserId());
|
||||
deviceTypeGrants.setGrantedAt(new Date());
|
||||
deviceTypeGrants.setTenantId(loginUser.getTenantId());
|
||||
deviceTypeGrantsMapper.insert(deviceTypeGrants);
|
||||
}
|
||||
|
||||
@ -318,13 +333,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
BeanUtil.copyProperties(deviceForm, device, true);
|
||||
device.setDeviceNo(createDeviceNo());
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
device.setCurrentOwnerId(loginUser.getUserId());
|
||||
device.setOriginalOwnerId(loginUser.getUserId());
|
||||
device.setCreateByName(loginUser.getNickname());
|
||||
device.setTypeName(deviceType.getTypeName());
|
||||
device.setDeviceType(deviceType.getId());
|
||||
device.setDevicePic(deviceType.getDevicePic());
|
||||
device.setTenantId(loginUser.getTenantId());
|
||||
if (device.getDeviceImei() != null) {
|
||||
device.setPubTopic("A/" + device.getDeviceImei());
|
||||
device.setSubTopic("B/" + device.getDeviceImei());
|
||||
@ -336,7 +351,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
// 查询设备类型的文件列表
|
||||
// 4. 核心优化:同步设备类型的文件列表 (一行代码)
|
||||
appBusinessFileService.cloneFiles(deviceType.getId(), device.getId());
|
||||
//同步设备类型的视频列表
|
||||
// 同步设备类型的视频列表
|
||||
appOperationVideoService.cloneFiles(deviceType.getId(), device.getId());
|
||||
|
||||
// 新增设备类型记录
|
||||
@ -351,10 +366,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
assignments.setActive(DeviceActiveStatusEnum.ACTIVE.getCode());
|
||||
String lever = USER_ID_SEPARATOR + loginUser.getUserId();
|
||||
assignments.setLever(lever);
|
||||
assignments.setTenantId(loginUser.getTenantId());
|
||||
deviceAssignmentsService.save(assignments);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String createDeviceNo() {
|
||||
String uuidStr = UUID.fastUUID().toString(); // 获取带 - 的标准格式字符串
|
||||
return uuidStr.replaceAll("-", "");
|
||||
|
||||
Reference in New Issue
Block a user