|
|
@@ -1,15 +1,22 @@
|
|
|
package com.zhongshu.card.server.core.service.devices.permiss;
|
|
|
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.devices.permiss.TimeSlotModel;
|
|
|
+import com.zhongshu.card.client.model.devices.permiss.TimeSlotWeekModel;
|
|
|
import com.zhongshu.card.client.type.DataState;
|
|
|
import com.zhongshu.card.client.type.UserState;
|
|
|
import com.zhongshu.card.client.type.device.PermissDataType;
|
|
|
+import com.zhongshu.card.client.type.device.TimeSlotType;
|
|
|
+import com.zhongshu.card.client.type.device.WeekDayType;
|
|
|
+import com.zhongshu.card.client.utils.DateUtils;
|
|
|
import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.devices.DevicePermissDao;
|
|
|
+import com.zhongshu.card.server.core.dao.devices.PermissSettingListDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
import com.zhongshu.card.server.core.domain.devices.permiss.DevicePermiss;
|
|
|
+import com.zhongshu.card.server.core.domain.devices.permiss.PermissTimeSlot;
|
|
|
import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
@@ -17,6 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 验证用户是否可以使用设备
|
|
|
*
|
|
|
@@ -39,6 +50,9 @@ public class DevicePermissVerifyService {
|
|
|
@Autowired
|
|
|
private DeviceInfoDao deviceInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PermissSettingListDao permissSettingListDao;
|
|
|
+
|
|
|
/**
|
|
|
* 验证用户是否有设备的使用权限
|
|
|
*
|
|
|
@@ -91,4 +105,42 @@ public class DevicePermissVerifyService {
|
|
|
log.info("用户设备权限验证:{}", stopWatch.prettyPrint());
|
|
|
return ResultContent.buildSuccess(msg);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证当前时间是否在时间段里
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean verifyTimeSlot(List<PermissTimeSlot> list) {
|
|
|
+ boolean b = false;
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ WeekDayType weekDayType = DateUtils.getTimeWeekData(System.currentTimeMillis());
|
|
|
+
|
|
|
+ List<TimeSlotModel> timeSlots = new ArrayList<>();
|
|
|
+ list.parallelStream().forEach(it -> {
|
|
|
+ if (it.getState() == DataState.Enable) {
|
|
|
+ if (it.getType() == TimeSlotType.Week) {
|
|
|
+ List<TimeSlotWeekModel> timeSlotWeekModels = it.getTimeSlotWeekModels();
|
|
|
+ if (ObjectUtils.isNotEmpty(timeSlotWeekModels)) {
|
|
|
+ timeSlotWeekModels.parallelStream().forEach(time -> {
|
|
|
+ if (time.getWeekDayType() == weekDayType && ObjectUtils.isNotEmpty(time.getTimeSlots())) {
|
|
|
+ timeSlots.addAll(time.getTimeSlots());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(timeSlots)) {
|
|
|
+ Long time = System.currentTimeMillis();
|
|
|
+ timeSlots.parallelStream().filter(it -> {
|
|
|
+ return it.getStartTimeNumber() < time && time < it.getEndTimeNumber();
|
|
|
+ }).collect(Collectors.toUnmodifiableList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
}
|