From af0e0279867da4f6bf0bb783483ad2c3320c5d42 Mon Sep 17 00:00:00 2001 From: tuyp Date: Wed, 14 Jun 2023 16:24:18 +0800 Subject: [PATCH] 定时任务:删除上线做了人脸识别但是没有看视频或者考试的人,这些人的人脸识别记录 --- src/main/java/com/subsidy/jobs/RenSheJuJob.java | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------- src/main/java/com/subsidy/jobs/WarningJob.java | 4 ++-- src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java | 13 ++++++++++++- src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java | 2 +- src/main/resources/mapper/ImageCheckRecordMapper.xml | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/subsidy/jobs/RenSheJuJob.java b/src/main/java/com/subsidy/jobs/RenSheJuJob.java index 9fc059d..5227221 100644 --- a/src/main/java/com/subsidy/jobs/RenSheJuJob.java +++ b/src/main/java/com/subsidy/jobs/RenSheJuJob.java @@ -1,8 +1,13 @@ package com.subsidy.jobs; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.subsidy.common.ResponseData; +import com.subsidy.mapper.ActivityDetectionMapper; +import com.subsidy.mapper.ImageCheckRecordMapper; import com.subsidy.mapper.OprMemDictMapper; +import com.subsidy.model.ActivityDetectionDO; +import com.subsidy.model.ImageCheckRecordDO; import com.subsidy.model.OprMemDictDO; import com.subsidy.service.RenSheJuService; import com.subsidy.util.IpAddressUtil; @@ -36,6 +41,12 @@ public class RenSheJuJob { @Autowired private OprMemDictMapper oprMemDictMapper; + @Autowired + private ImageCheckRecordMapper imageCheckRecordMapper; + + @Autowired + private ActivityDetectionMapper activityDetectionMapper; + @Value("${spring.profiles.active}") private String env; @@ -45,7 +56,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 0 1 * * ?") public void classBaseInfo() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.classBaseInfo(); } } @@ -55,7 +66,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 5 1 * * ?") public void classHourBehavior() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.classHourBehavior(); } } @@ -65,7 +76,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 10 1 * * ?") public void uploadChapterBehavior() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.uploadChapterBehavior(); } } @@ -75,7 +86,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 15 1 * * ?") public void uploadClassAnswerQuestionBehavior() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.uploadClassAnswerQuestionBehavior(); } } @@ -85,7 +96,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 20 1 * * ?") public void uploadImage() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.uploadImage(); } } @@ -95,7 +106,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 25 1 * * ?") public void getClassCodeByPrivateKey() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.getClassCodeByPrivateKey(); } } @@ -105,7 +116,7 @@ public class RenSheJuJob { */ @Scheduled(cron = "0 30 1 * * ?") public void uploadClassCode() throws IOException { - if ("prod".equals(env)){ + if ("prod".equals(env)) { renSheJuService.uploadClassCode(); } } @@ -118,9 +129,13 @@ public class RenSheJuJob { // renSheJuService.getErrorClass(); // } + + /** + * 强制用户用户下线(websocket强制下线) + */ @Scheduled(cron = "0 30 23 * * ?") @Transactional(rollbackFor = Exception.class) - public void logout(){ + public void logout() { //让当前用户下线 ConcurrentHashMap webSocketMap = WebSocketUtil.webSocketMap; @@ -139,51 +154,64 @@ public class RenSheJuJob { } } + /** + * 删掉有登录数据 做过人脸 没有学习数据(视频+考试+答疑) + */ + @Scheduled(cron = "0 01 16 * * ?") + @Transactional(rollbackFor = Exception.class) + public void deleteNoStudyMembers() { + + //查看登陆过做过人脸,但是没视频记录的人 + List vodHistoryMembers = imageCheckRecordMapper.noVodHistoryMembers(); + vodHistoryMembers.stream().forEach(x -> { + imageCheckRecordMapper.deleteById(x.getId()); + + ActivityDetectionDO activityDetectionDO = activityDetectionMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ActivityDetectionDO::getFaceCheckId, x.getId())); + if (null != activityDetectionDO) { + activityDetectionMapper.deleteById(activityDetectionDO.getId()); + } + }); + + //查看登陆过做过人脸,但是没考试记录的人 + List examHistoryMembers = imageCheckRecordMapper.noExamHistoryMembers(); + examHistoryMembers.stream().forEach(x -> { + imageCheckRecordMapper.deleteById(x.getId()); + + ActivityDetectionDO activityDetectionDO = activityDetectionMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ActivityDetectionDO::getFaceCheckId, x.getId())); + if (null != activityDetectionDO) { + activityDetectionMapper.deleteById(activityDetectionDO.getId()); + } + }); + + } + + /** + * 补登录登出数据 + */ @Scheduled(cron = "0 40 23 * * ?") @Transactional(rollbackFor = Exception.class) public void cancelLogin() { - //让当前用户下线 // ConcurrentHashMap webSocketMap = WebSocketUtil.webSocketMap; //查看当天登录过的人最后一次活跃数据 List insertLastStudyRecordVOS = oprMemDictMapper.insertLastStudyRecord(); for (InsertLastStudyRecordVO ilsr : insertLastStudyRecordVOS) { - - oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(),"登录",1, ilsr.getIpAddress(),ilsr.getSignInDate()); + oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(), "登录", 1, ilsr.getIpAddress(), ilsr.getSignInDate()); if (null == ilsr.getMt()) { //补23:58的数据 - oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(),"登出",1,null,new Date()); + oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(), "登出", 1, null, new Date()); } else { //最后一次学习的数据 oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(), "登出", 1, null, ilsr.getMt()); } } - - -// List shutdownUsers = oprMemDictMapper.shutdownUser(); -// for (Long key : shutdownUsers) { -// try { -// if (!onLineUsers.contains(key)) { -// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(key); -// if (null != oprMemDictDO) { -// if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) { -// oprMemDictMapper.deleteById(oprMemDictDO.getId()); -// } -// } -// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); -// LocalDateTime time = LocalDateTime.now(); -// String localDateTime = df.format(time); -// LocalDateTime ldt = LocalDateTime.parse(localDateTime, df); -// oprMemDictDO.setCreateDate(ldt); -// oprMemDictMapper.insertOrUpdate(key, "登出", 1, null, ldt); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } } } diff --git a/src/main/java/com/subsidy/jobs/WarningJob.java b/src/main/java/com/subsidy/jobs/WarningJob.java index 22604d7..d0ec309 100644 --- a/src/main/java/com/subsidy/jobs/WarningJob.java +++ b/src/main/java/com/subsidy/jobs/WarningJob.java @@ -39,10 +39,10 @@ public class WarningJob { private String env; /** - * POST-2:班级基本信息信息采集接口 + * 11点钟有错误数据 发短信 */ @Scheduled(cron = "0 0 23 * * ?") - public void classBaseInfo() throws IOException { + public void classBaseInfo(){ if ("prod".equals(env)) { List result = new ArrayList<>(); diff --git a/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java b/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java index 2572608..489e2de 100644 --- a/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java +++ b/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java @@ -27,6 +27,17 @@ public interface ImageCheckRecordMapper extends BaseMapper { /** * 查看某个人某个课程当天做了几次人脸识别 */ - int checkDailyCount(Long memberId,Long classId,Integer checkPlace,Long paperId); + int checkDailyCount(Long memberId, Long classId, Integer checkPlace, Long paperId); + + /** + * 查看登陆过做过人脸,但是没视频记录的人 + */ + List noVodHistoryMembers(); + + /** + * 查看登陆过做过人脸,但是没考试记录的人 + */ + List noExamHistoryMembers(); + } diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index 9ae202f..c0e5b28 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -189,8 +189,8 @@ public class RenSheJuServiceImpl implements RenSheJuService { List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getDownCode(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); if (chapterList3s.size() > 0) { loginList.setChapterList(chapterList3s); + loginLists.add(loginList); } - loginLists.add(loginList); } classHourBasic.setLoginList(loginLists); diff --git a/src/main/resources/mapper/ImageCheckRecordMapper.xml b/src/main/resources/mapper/ImageCheckRecordMapper.xml index c06a704..e0f1a9b 100644 --- a/src/main/resources/mapper/ImageCheckRecordMapper.xml +++ b/src/main/resources/mapper/ImageCheckRecordMapper.xml @@ -55,4 +55,44 @@ + + + + -- libgit2 0.25.0