Commit af0e0279 by 涂亚平

定时任务:删除上线做了人脸识别但是没有看视频或者考试的人,这些人的人脸识别记录

1 parent 17dd553c
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<Long, WebSocketSession> webSocketMap = WebSocketUtil.webSocketMap;
......@@ -139,51 +154,64 @@ public class RenSheJuJob {
}
}
/**
* 删掉有登录数据 做过人脸 没有学习数据(视频+考试+答疑)
*/
@Scheduled(cron = "0 01 16 * * ?")
@Transactional(rollbackFor = Exception.class)
public void deleteNoStudyMembers() {
//查看登陆过做过人脸,但是没视频记录的人
List<ImageCheckRecordDO> vodHistoryMembers = imageCheckRecordMapper.noVodHistoryMembers();
vodHistoryMembers.stream().forEach(x -> {
imageCheckRecordMapper.deleteById(x.getId());
ActivityDetectionDO activityDetectionDO = activityDetectionMapper.selectOne(new QueryWrapper<ActivityDetectionDO>()
.lambda()
.eq(ActivityDetectionDO::getFaceCheckId, x.getId()));
if (null != activityDetectionDO) {
activityDetectionMapper.deleteById(activityDetectionDO.getId());
}
});
//查看登陆过做过人脸,但是没考试记录的人
List<ImageCheckRecordDO> examHistoryMembers = imageCheckRecordMapper.noExamHistoryMembers();
examHistoryMembers.stream().forEach(x -> {
imageCheckRecordMapper.deleteById(x.getId());
ActivityDetectionDO activityDetectionDO = activityDetectionMapper.selectOne(new QueryWrapper<ActivityDetectionDO>()
.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<Long, WebSocketSession> webSocketMap = WebSocketUtil.webSocketMap;
//查看当天登录过的人最后一次活跃数据
List<InsertLastStudyRecordVO> 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<Long> 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();
// }
// }
}
}
......@@ -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<Long> result = new ArrayList<>();
......
......@@ -27,6 +27,17 @@ public interface ImageCheckRecordMapper extends BaseMapper<ImageCheckRecordDO> {
/**
* 查看某个人某个课程当天做了几次人脸识别
*/
int checkDailyCount(Long memberId,Long classId,Integer checkPlace,Long paperId);
int checkDailyCount(Long memberId, Long classId, Integer checkPlace, Long paperId);
/**
* 查看登陆过做过人脸,但是没视频记录的人
*/
List<ImageCheckRecordDO> noVodHistoryMembers();
/**
* 查看登陆过做过人脸,但是没考试记录的人
*/
List<ImageCheckRecordDO> noExamHistoryMembers();
}
......@@ -189,9 +189,9 @@ public class RenSheJuServiceImpl implements RenSheJuService {
List<ChapterList3> 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);
}
}
classHourBasic.setLoginList(loginLists);
//活跃度列表
......
......@@ -55,4 +55,44 @@
</if>
</select>
<select id="noVodHistoryMembers" resultType="com.subsidy.model.ImageCheckRecordDO">
SELECT
id
FROM
image_check_record t1
WHERE
DATE_FORMAT( t1.create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
AND t1.delete_date IS NULL
AND paper_id IS NULL
AND t1.member_id NOT IN (
SELECT DISTINCT
member_id
FROM
vod_play_history
WHERE
delete_date IS NULL
AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
)
</select>
<select id="noExamHistoryMembers" resultType="com.subsidy.model.ImageCheckRecordDO">
SELECT
id
FROM
image_check_record t1
WHERE
DATE_FORMAT( t1.create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
AND t1.delete_date IS NULL
AND paper_id IS NOT NULL
and t1.member_id not in (
SELECT DISTINCT
member_id
FROM
exercise_done_result
WHERE
delete_date IS NULL
AND DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
)
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!