|
|
@@ -93,6 +93,9 @@ public class DevicePermissVerifyService {
|
|
|
return ResultContent.buildFail("用户不可用");
|
|
|
}
|
|
|
|
|
|
+ stopWatch.stop();
|
|
|
+
|
|
|
+ stopWatch.start("查询设备信息");
|
|
|
// 验证设备
|
|
|
DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
@@ -106,14 +109,23 @@ public class DevicePermissVerifyService {
|
|
|
String projectOid = deviceInfo.getProjectOid();
|
|
|
|
|
|
// 验证手动管理的设备权限
|
|
|
+ stopWatch.stop();
|
|
|
+
|
|
|
+ stopWatch.start("设备权限");
|
|
|
DevicePermiss devicePermiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOidAndDataState(userId, deviceId, projectOid, DataState.Enable);
|
|
|
if (ObjectUtils.isNotEmpty(devicePermiss)) {
|
|
|
hasPermission = true;
|
|
|
}
|
|
|
+ stopWatch.stop();
|
|
|
|
|
|
if (!hasPermission) {
|
|
|
+
|
|
|
+ stopWatch.start("查询当前时间段");
|
|
|
// 查找当前时间对应的时段信息
|
|
|
List<PermissTimeSlot> permissTimeSlots = getCurrentTimeSlot(projectOid);
|
|
|
+
|
|
|
+ stopWatch.stop();
|
|
|
+ stopWatch.start("查询用户所属机构");
|
|
|
List<OrganizationUser> organizationUsers = organizationUserService.getUserOrgList(userId, projectOid);
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(permissTimeSlots) && ObjectUtils.isNotEmpty(organizationUsers)) {
|
|
|
@@ -128,6 +140,9 @@ public class DevicePermissVerifyService {
|
|
|
// 用户id
|
|
|
dataIds.add(userId);
|
|
|
|
|
|
+ stopWatch.stop();
|
|
|
+
|
|
|
+ stopWatch.start("机构用户信息处理");
|
|
|
// 用户所属角色、机构
|
|
|
organizationUsers.parallelStream().forEach(organizationUser -> {
|
|
|
dataIds.add(organizationUser.getOrganization().getOid());
|
|
|
@@ -137,6 +152,8 @@ public class DevicePermissVerifyService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ stopWatch.stop();
|
|
|
+ stopWatch.start("用户分组处理");
|
|
|
// 用户分组
|
|
|
List<UserGroupToUser> userGroupToUsers = userGroupToUserDao.findByUserIdAndProjectOid(userId, projectOid);
|
|
|
if (ObjectUtils.isNotEmpty(userGroupToUsers)) {
|
|
|
@@ -157,6 +174,8 @@ public class DevicePermissVerifyService {
|
|
|
deviceIds.add(deviceInfo.getArea().getId());
|
|
|
}
|
|
|
|
|
|
+ stopWatch.stop();
|
|
|
+ stopWatch.start("设备分组");
|
|
|
// 设备分组信息
|
|
|
List<DeviceGroupToDevice> deviceAbouts = deviceGroupToDeviceDao.findByProjectOidAndDeviceId(projectOid, deviceId);
|
|
|
if (ObjectUtils.isNotEmpty(deviceAbouts)) {
|
|
|
@@ -171,14 +190,17 @@ public class DevicePermissVerifyService {
|
|
|
deviceIds.addAll(groupIds);
|
|
|
}
|
|
|
}
|
|
|
+ stopWatch.stop();
|
|
|
// 设备所在的分组
|
|
|
search.setDeviceIds(deviceIds);
|
|
|
|
|
|
+ stopWatch.start("规则数据查询");
|
|
|
Pageable pageable = PageRequest.of(0, 1);
|
|
|
Page<PermissSettingList> page = permissSettingListDao.page(pageable, search);
|
|
|
if (ObjectUtils.isNotEmpty(page.getContent())) {
|
|
|
hasPermission = true;
|
|
|
}
|
|
|
+ stopWatch.stop();
|
|
|
}
|
|
|
}
|
|
|
|