|
@@ -57,12 +57,13 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
|
|
@Async
|
|
@Async
|
|
|
@Scheduled(cron = "0 0 1 * * ? ")//每天凌晨一点
|
|
@Scheduled(cron = "0 0 1 * * ? ")//每天凌晨一点
|
|
|
|
|
+// @Scheduled(cron = "0 41 10 * * ? ")//每天凌晨一点
|
|
|
public void getAccessSmartRelation() {
|
|
public void getAccessSmartRelation() {
|
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
|
|
|
|
|
- LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
|
|
|
|
|
|
|
+ LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(8);
|
|
|
|
|
+ LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(8);
|
|
|
String format = start.format(pattern);
|
|
String format = start.format(pattern);
|
|
|
// 找到昨天的所有数据
|
|
// 找到昨天的所有数据
|
|
|
List<SmartAccess> accessList = smartAccessService.toDatelist(start, end);
|
|
List<SmartAccess> accessList = smartAccessService.toDatelist(start, end);
|
|
@@ -70,8 +71,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
for (SmartAccess smartAccess : accessList) {
|
|
for (SmartAccess smartAccess : accessList) {
|
|
|
String dateTime = smartAccess.getDateTime();
|
|
String dateTime = smartAccess.getDateTime();
|
|
|
LocalDateTime date = LocalDateTime.parse(dateTime, pattern);
|
|
LocalDateTime date = LocalDateTime.parse(dateTime, pattern);
|
|
|
- LocalDateTime startTime = date.minusSeconds(10);
|
|
|
|
|
- LocalDateTime endTime = date.plusSeconds(10);
|
|
|
|
|
|
|
+ LocalDateTime startTime = date.minusSeconds(5);
|
|
|
|
|
+ LocalDateTime endTime = date.plusSeconds(5);
|
|
|
Integer userId = smartAccess.getUserId();
|
|
Integer userId = smartAccess.getUserId();
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
List<SmartAccess> accesses = smartAccessService.toDatelist(startTime, endTime);
|
|
List<SmartAccess> accesses = smartAccessService.toDatelist(startTime, endTime);
|
|
@@ -79,33 +80,35 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
|
|
for (SmartAccess access : accesses) {
|
|
for (SmartAccess access : accesses) {
|
|
|
Integer userId1 = access.getUserId();
|
|
Integer userId1 = access.getUserId();
|
|
|
- SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
|
|
|
|
+ if (!userId.equals(userId1) && userId != 0 && userId1 != 0) {
|
|
|
|
|
+ SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
// 判断是否已添加,有的话则加1
|
|
// 判断是否已添加,有的话则加1
|
|
|
- LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(SmartRelation::getUserId, userId)
|
|
|
|
|
- .eq(SmartRelation::getRelationId, userId1)
|
|
|
|
|
- .eq(SmartRelation::getDateTime,format);
|
|
|
|
|
- SmartRelation one = this.getOne(wrapper);
|
|
|
|
|
- if (ObjectUtils.isEmpty(one)) {
|
|
|
|
|
- SmartRelation smartRelation = new SmartRelation();
|
|
|
|
|
- smartRelation.setUserId(userId);
|
|
|
|
|
- smartRelation.setRelationId(userId1);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
- smartRelation.setName(smartUser.getName());
|
|
|
|
|
|
|
+ LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(SmartRelation::getUserId, userId)
|
|
|
|
|
+ .eq(SmartRelation::getRelationId, userId1)
|
|
|
|
|
+ .eq(SmartRelation::getDateTime, format);
|
|
|
|
|
+ SmartRelation one = this.getOne(wrapper);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(one)) {
|
|
|
|
|
+ SmartRelation smartRelation = new SmartRelation();
|
|
|
|
|
+ smartRelation.setUserId(userId);
|
|
|
|
|
+ smartRelation.setRelationId(userId1);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
+ smartRelation.setName(smartUser.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartById)) {
|
|
|
|
|
+ smartRelation.setRelationName(smartById.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ smartRelation.setCount(1);
|
|
|
|
|
+ smartRelation.setDateTime(format);
|
|
|
|
|
+ this.save(smartRelation);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Integer count = one.getCount();
|
|
|
|
|
+ count = count + 1;
|
|
|
|
|
+ one.setCount(count);
|
|
|
|
|
+ this.updateById(one);
|
|
|
}
|
|
}
|
|
|
- if (ObjectUtils.isNotEmpty(smartById)) {
|
|
|
|
|
- smartRelation.setRelationName(smartById.getName());
|
|
|
|
|
- }
|
|
|
|
|
- smartRelation.setCount(0);
|
|
|
|
|
- smartRelation.setDateTime(format);
|
|
|
|
|
- this.save(smartRelation);
|
|
|
|
|
- } else {
|
|
|
|
|
- Integer count = one.getCount();
|
|
|
|
|
- count = count + 1;
|
|
|
|
|
- one.setCount(count);
|
|
|
|
|
- this.updateById(one);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -116,13 +119,14 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Async
|
|
@Async
|
|
|
- @Scheduled(cron = "0 0 2 * * ? ")//每天凌晨一点
|
|
|
|
|
|
|
+ @Scheduled(cron = "0 0 3 * * ? ")//每天凌晨两点
|
|
|
|
|
+// @Scheduled(cron = "0 25` * * * ? ")//每天凌晨两点
|
|
|
public void getFaceDiscernListSmartRelation() {
|
|
public void getFaceDiscernListSmartRelation() {
|
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
|
|
|
|
|
- LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
|
|
|
|
|
|
|
+ LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(8);
|
|
|
|
|
+ LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(8);
|
|
|
|
|
|
|
|
String format = start.format(pattern);
|
|
String format = start.format(pattern);
|
|
|
|
|
|
|
@@ -132,8 +136,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
for (SmartFaceDiscern faceDiscern : faceDiscernList) {
|
|
for (SmartFaceDiscern faceDiscern : faceDiscernList) {
|
|
|
String dateTime = faceDiscern.getDateTime();
|
|
String dateTime = faceDiscern.getDateTime();
|
|
|
LocalDateTime date = LocalDateTime.parse(dateTime, pattern);
|
|
LocalDateTime date = LocalDateTime.parse(dateTime, pattern);
|
|
|
- LocalDateTime startTime = date.minusSeconds(10);
|
|
|
|
|
- LocalDateTime endTime = date.plusSeconds(10);
|
|
|
|
|
|
|
+ LocalDateTime startTime = date.minusSeconds(5);
|
|
|
|
|
+ LocalDateTime endTime = date.plusSeconds(5);
|
|
|
Integer userId = faceDiscern.getUserId();
|
|
Integer userId = faceDiscern.getUserId();
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
List<SmartFaceDiscern> faceDiscerns = smartFaceDiscernService.toDateList(startTime, endTime);
|
|
List<SmartFaceDiscern> faceDiscerns = smartFaceDiscernService.toDateList(startTime, endTime);
|
|
@@ -141,35 +145,36 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
|
|
for (SmartFaceDiscern faceDiscern1 : faceDiscerns) {
|
|
for (SmartFaceDiscern faceDiscern1 : faceDiscerns) {
|
|
|
Integer userId1 = faceDiscern1.getUserId();
|
|
Integer userId1 = faceDiscern1.getUserId();
|
|
|
- SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
|
|
|
|
+ if (!userId.equals(userId1) && userId != 0 && userId1 != 0) {
|
|
|
|
|
+ SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
// 判断是否已添加,有的话则加1
|
|
// 判断是否已添加,有的话则加1
|
|
|
- LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(SmartRelation::getUserId, userId)
|
|
|
|
|
- .eq(SmartRelation::getRelationId, userId1)
|
|
|
|
|
- .eq(SmartRelation::getDateTime,format);
|
|
|
|
|
- SmartRelation one = this.getOne(wrapper);
|
|
|
|
|
- if (ObjectUtils.isEmpty(one)) {
|
|
|
|
|
- SmartRelation smartRelation = new SmartRelation();
|
|
|
|
|
- smartRelation.setUserId(userId);
|
|
|
|
|
- smartRelation.setRelationId(userId1);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
- smartRelation.setName(smartUser.getName());
|
|
|
|
|
- }
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(smartById)) {
|
|
|
|
|
- smartRelation.setRelationName(smartById.getName());
|
|
|
|
|
|
|
+ LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(SmartRelation::getUserId, userId)
|
|
|
|
|
+ .eq(SmartRelation::getRelationId, userId1)
|
|
|
|
|
+ .eq(SmartRelation::getDateTime, format);
|
|
|
|
|
+ SmartRelation one = this.getOne(wrapper);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(one)) {
|
|
|
|
|
+ SmartRelation smartRelation = new SmartRelation();
|
|
|
|
|
+ smartRelation.setUserId(userId);
|
|
|
|
|
+ smartRelation.setRelationId(userId1);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
+ smartRelation.setName(smartUser.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartById)) {
|
|
|
|
|
+ smartRelation.setRelationName(smartById.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ smartRelation.setDateTime(format);
|
|
|
|
|
+ smartRelation.setCount(1);
|
|
|
|
|
+ this.save(smartRelation);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Integer count = one.getCount();
|
|
|
|
|
+ count = count + 1;
|
|
|
|
|
+ one.setCount(count);
|
|
|
|
|
+ this.updateById(one);
|
|
|
}
|
|
}
|
|
|
- smartRelation.setDateTime(format);
|
|
|
|
|
- smartRelation.setCount(0);
|
|
|
|
|
- this.save(smartRelation);
|
|
|
|
|
- } else {
|
|
|
|
|
- Integer count = one.getCount();
|
|
|
|
|
- count = count + 1;
|
|
|
|
|
- one.setCount(count);
|
|
|
|
|
- this.updateById(one);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|