|
|
@@ -13,6 +13,7 @@ import com.template.model.pojo.SmartRelation;
|
|
|
import com.template.mapper.SmartRelationMapper;
|
|
|
import com.template.model.pojo.SmartUser;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
+import com.template.model.vo.SmartRelationVo;
|
|
|
import com.template.model.vo.UserVo;
|
|
|
import com.template.services.SmartAccessService;
|
|
|
import com.template.services.SmartFaceDiscernService;
|
|
|
@@ -56,7 +57,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
SmartRelationMapper smartRelationMapper;
|
|
|
|
|
|
@Async
|
|
|
- @Scheduled(cron = "0 0 1 * * ? ")//每天凌晨一点
|
|
|
+ @Scheduled(cron = "0 20 0 * * ? ")//每天凌晨一点
|
|
|
+// @Scheduled(cron = "0 10 14 * * ? ")//每天凌晨一点
|
|
|
public void getAccessSmartRelation() {
|
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -70,8 +72,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
for (SmartAccess smartAccess : accessList) {
|
|
|
String dateTime = smartAccess.getDateTime();
|
|
|
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();
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
List<SmartAccess> accesses = smartAccessService.toDatelist(startTime, endTime);
|
|
|
@@ -79,33 +81,35 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
for (SmartAccess access : accesses) {
|
|
|
Integer userId1 = access.getUserId();
|
|
|
- SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
+ if (!userId.equals(userId1) && userId != 0 && userId1 != 0) {
|
|
|
+ SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
// 判断是否已添加,有的话则加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,7 +120,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
- @Scheduled(cron = "0 0 2 * * ? ")//每天凌晨一点
|
|
|
+ @Scheduled(cron = "0 40 2 * * ? ")//每天凌晨两点
|
|
|
+// @Scheduled(cron = "0 25` * * * ? ")//每天凌晨两点
|
|
|
public void getFaceDiscernListSmartRelation() {
|
|
|
if (scheduleConfig.getIsOpen().equals("1")) {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -132,8 +137,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
for (SmartFaceDiscern faceDiscern : faceDiscernList) {
|
|
|
String dateTime = faceDiscern.getDateTime();
|
|
|
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();
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
List<SmartFaceDiscern> faceDiscerns = smartFaceDiscernService.toDateList(startTime, endTime);
|
|
|
@@ -141,35 +146,36 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
for (SmartFaceDiscern faceDiscern1 : faceDiscerns) {
|
|
|
Integer userId1 = faceDiscern1.getUserId();
|
|
|
- SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
+ if (!userId.equals(userId1) && userId != 0 && userId1 != 0) {
|
|
|
+ SmartUser smartById = smartUserService.getSmartById(userId1);
|
|
|
// 判断是否已添加,有的话则加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);
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -179,12 +185,12 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public PageUtils<SmartRelation> getPage(int currentPage, int pageCount, Integer userId) {
|
|
|
-// Page<UserVo> page = new Page<>();
|
|
|
-// page.setCurrent(currentPage);
|
|
|
-// page.setSize(pageCount);
|
|
|
-// IPage<WarningUserDto> result = smartUserMapper.warningUserList(page, name);
|
|
|
-// return new PageUtils(result);
|
|
|
- return null;
|
|
|
+ public PageUtils<SmartRelationVo> getList(int currentPage,int pageCount,Integer userId, String startTime, String endTime) {
|
|
|
+ Page<SmartRelationVo> page = new Page<>();
|
|
|
+ page.setCurrent(currentPage);
|
|
|
+ page.setSize(pageCount);
|
|
|
+ IPage<SmartRelationVo> result =smartRelationMapper.getList(page,userId,startTime,endTime);
|
|
|
+
|
|
|
+ return new PageUtils(result);
|
|
|
}
|
|
|
}
|