From a079f1efc5940f4fa2b3aaf775effbbccb2ba6c3 Mon Sep 17 00:00:00 2001 From: tuyp Date: Fri, 20 Oct 2023 18:18:16 +0800 Subject: [PATCH] 解决时间交叉,活跃度检测的问题 重新开始推送数据 --- src/main/java/com/subsidy/controller/AdministerController.java | 2 +- src/main/java/com/subsidy/controller/VodPlayHistoryController.java | 3 --- src/main/java/com/subsidy/jobs/RenSheJuJob.java | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------- src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java | 34 +++++++++++++++++----------------- src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- src/main/resources/mapper/RenSheJuMapper.xml | 68 +++++++++++++++++++++++++------------------------------------------- 6 files changed, 182 insertions(+), 187 deletions(-) diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index c777f9f..b2c8d57 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -123,7 +123,7 @@ public class AdministerController { @PostMapping("exportExerciseTest") @ApiOperation("班级管理--测评成绩 id 班级id userName paperId") -// @LoginRequired + @LoginRequired public void exportExerciseTest(@RequestBody ClassDetailDTO classDetailDTO) throws Exception { classDetailDTO.setFlag(true); administerService.exportExerciseTest(classDetailDTO); diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index d528968..cee9a3c 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -105,7 +105,4 @@ public class VodPlayHistoryController { return vodPlayHistoryService.criticalData(vodPlayHistoryDO); } - - - } diff --git a/src/main/java/com/subsidy/jobs/RenSheJuJob.java b/src/main/java/com/subsidy/jobs/RenSheJuJob.java index 4af97da..530cb2b 100644 --- a/src/main/java/com/subsidy/jobs/RenSheJuJob.java +++ b/src/main/java/com/subsidy/jobs/RenSheJuJob.java @@ -64,76 +64,76 @@ public class RenSheJuJob { private String env; -// /** -//// * POST-2:班级基本信息信息采集接口 -//// */ -// @Scheduled(cron = "0 0 1 * * ?") -// public void classBaseInfo() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.classBaseInfo(); -// } -// } -// -// /** -// * POST-3:学时信息采集接口 -// */ -// @Scheduled(cron = "0 5 1 * * ?") -// public void classHourBehavior() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.classHourBehavior(); -// } -// } -// -// /** -// * POST-4:考试信息采集接口 -// */ -// @Scheduled(cron = "0 10 1 * * ?") -// public void uploadChapterBehavior() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.uploadChapterBehavior(); -// } -// } -// -// /** -// * POST-5:答疑辅导采集接口 -// */ -// @Scheduled(cron = "0 15 1 * * ?") -// public void uploadClassAnswerQuestionBehavior() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.uploadClassAnswerQuestionBehavior(); -// } -// } -// -// /** -// * POST-6 班级活跃度/实名认证照片信息采集接口 -// */ -// @Scheduled(cron = "0 20 1 * * ?") -// public void uploadImage() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.uploadImage(); -// } -// } -// -// /** -// * POST-7 获取培训待绑定的(班级编号,项目编号)列表 -// */ -// @Scheduled(cron = "0 25 1 * * ?") -// public void getClassCodeByPrivateKey() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.getClassCodeByPrivateKey(); -// } -// } -// -// /** -// * POST-8 上下游班级数据绑定接口 + /** +// * POST-2:班级基本信息信息采集接口 // */ -// @Scheduled(cron = "0 30 1 * * ?") -// public void uploadClassCode() throws IOException { -// if ("prod".equals(env)) { -// renSheJuService.uploadClassCode(); -// } -// System.gc(); -// } + @Scheduled(cron = "0 0 1 * * ?") + public void classBaseInfo() throws IOException { + if ("prod".equals(env)) { + renSheJuService.classBaseInfo(); + } + } + + /** + * POST-3:学时信息采集接口 + */ + @Scheduled(cron = "0 5 1 * * ?") + public void classHourBehavior() throws IOException { + if ("prod".equals(env)) { + renSheJuService.classHourBehavior(); + } + } + + /** + * POST-4:考试信息采集接口 + */ + @Scheduled(cron = "0 10 1 * * ?") + public void uploadChapterBehavior() throws IOException { + if ("prod".equals(env)) { + renSheJuService.uploadChapterBehavior(); + } + } + + /** + * POST-5:答疑辅导采集接口 + */ + @Scheduled(cron = "0 15 1 * * ?") + public void uploadClassAnswerQuestionBehavior() throws IOException { + if ("prod".equals(env)) { + renSheJuService.uploadClassAnswerQuestionBehavior(); + } + } + + /** + * POST-6 班级活跃度/实名认证照片信息采集接口 + */ + @Scheduled(cron = "0 20 1 * * ?") + public void uploadImage() throws IOException { + if ("prod".equals(env)) { + renSheJuService.uploadImage(); + } + } + + /** + * POST-7 获取培训待绑定的(班级编号,项目编号)列表 + */ + @Scheduled(cron = "0 25 1 * * ?") + public void getClassCodeByPrivateKey() throws IOException { + if ("prod".equals(env)) { + renSheJuService.getClassCodeByPrivateKey(); + } + } + + /** + * POST-8 上下游班级数据绑定接口 + */ + @Scheduled(cron = "0 30 1 * * ?") + public void uploadClassCode() throws IOException { + if ("prod".equals(env)) { + renSheJuService.uploadClassCode(); + } + System.gc(); + } // /** // * POST-9 获取推送失败班级列表 @@ -297,7 +297,6 @@ public class RenSheJuJob { activityDetectionMapper.deleteById(activityDetectionDO.getId()); } }); - } diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index c63a06f..5e4fd45 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -142,10 +142,10 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); - List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); - for (String telephone : telephones) { - smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_2); - } +// List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); +// for (String telephone : telephones) { +// smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_2); +// } } return null; } @@ -165,7 +165,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { List vodClassIds = renSheJuMapper.vodClassIds("0"); List result = new ArrayList<>(); -// List vodClassIds = new ArrayList<>(); try { @@ -251,6 +250,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { } renshejuHistoryMapper.insert(renshejuHistoryDO); return rensheResponseVO; +// return null; } else { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_3); @@ -406,10 +406,11 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); - List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); - for (String telephone : telephones) { - smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_4); - } + +// List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); +// for (String telephone : telephones) { +// smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_4); +// } } return null; } @@ -427,6 +428,9 @@ public class RenSheJuServiceImpl implements RenSheJuService { List dailyAnswerVOS = renSheJuMapper.dailyAnswer("0"); +// List dailyAnswerVOS = new ArrayList<>(); + + try { if (dailyAnswerVOS.size() > 0) { HashMap> hashMap = new HashMap<>(); @@ -498,10 +502,10 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); - List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); - for (String telephone : telephones) { - smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_5); - } +// List telephones = Arrays.asList(new String[]{"15201936167", "18201963812"}); +// for (String telephone : telephones) { +// smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_5); +// } } return null; } @@ -517,10 +521,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { //找到昨天做过人脸识别的班级 List classIds = renSheJuMapper.checkClassIds("0"); -// List classIds = new ArrayList<>(); -// -// classIds.add(451L); - for (Long classId : classIds) { UploadImageDTO uploadImage = new UploadImageDTO(); diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index fc3c204..a34e104 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -59,50 +59,60 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() + .lambda() + .eq(ExerciseDoneResultDO::getClassId, vodPlayHistoryDO.getClassId()) + .eq(ExerciseDoneResultDO::getMemberId, vodPlayHistoryDO.getMemberId())); + + if (count == 0) { - Date date = new Date(); - if (vodPlayHistoryDO.getPlayLength() > 8 && vodPlayHistoryDO.getSuspendLength() <= 3000) { + Date date = new Date(); + if (vodPlayHistoryDO.getPlayLength() > 8 && vodPlayHistoryDO.getSuspendLength() <= 3000) { - Date latestDailyDate = this.baseMapper.latestDailyStudyRecord(vodPlayHistoryDO.getMemberId()); + Date latestDailyDate = this.baseMapper.latestDailyStudyRecord(vodPlayHistoryDO.getMemberId()); - //查看系统设定的时长 - ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() - .lambda() - .eq(ClassDictDO::getId, vodPlayHistoryDO.getClassId())); - if (classDictDO.getLimitHour() == 1) { - //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(vodPlayHistoryDO.getMemberId(), classDictDO.getId()); - if (total >= 6 * 3600) { - throw new HttpException(13001); - } - //是否超过时长 - if (total + vodPlayHistoryDO.getPlayLength() > 6 * 3600) { - //超过时长 - int playLength = 6 * 3600 - total; - vodPlayHistoryDO.setPlayLength(playLength); - if (playLength > 8) { + //查看系统设定的时长 + ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ClassDictDO::getId, vodPlayHistoryDO.getClassId())); + if (classDictDO.getLimitHour() == 1) { + //查看当天这个人看了多少时间 + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(vodPlayHistoryDO.getMemberId(), classDictDO.getId()); + if (total >= 6 * 3600) { + throw new HttpException(13001); + } + //是否超过时长 + if (total + vodPlayHistoryDO.getPlayLength() > 6 * 3600) { + //超过时长 + int playLength = 6 * 3600 - total; + vodPlayHistoryDO.setPlayLength(playLength); + if (playLength > 8) { + FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); + if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() + , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); + } + } + } else { FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); } } - } else { + } else if (classDictDO.getLimitHour() == 0) { FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); } } - } else if (classDictDO.getLimitHour() == 0) { - FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); - if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() - , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); - } } } @@ -112,45 +122,52 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 8 && insertHistoryNewDTO.getSuspendLength() <= 3000) { - VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - BeanUtils.copyProperties(insertHistoryNewDTO, vodPlayHistoryDO); - //查看系统设定的时长 - ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() - .lambda() - .eq(ClassDictDO::getId, insertHistoryNewDTO.getClassId())); - Date latestDailyDate = this.baseMapper.latestDailyStudyRecord(vodPlayHistoryDO.getMemberId()); - if (classDictDO.getLimitHour() == 1) { - //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(insertHistoryNewDTO.getMemberId(), insertHistoryNewDTO.getClassId()); - if (total == 6 * 3600) { - throw new HttpException(13001); - } - //是否超过时长 没超过 false 超过 true - if (total + vodPlayHistoryDO.getPlayLength() > 6 * 3600) { - int playLength = 6 * 3600 - total; - vodPlayHistoryDO.setPlayLength(playLength); - if (playLength > 8) { + Integer count = exerciseDoneResultMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ExerciseDoneResultDO::getClassId, insertHistoryNewDTO.getClassId()) + .eq(ExerciseDoneResultDO::getMemberId, insertHistoryNewDTO.getMemberId())); + + if (count == 0) { + Date date = new Date(); + if (insertHistoryNewDTO.getPlayLength() > 8 && insertHistoryNewDTO.getSuspendLength() <= 3000) { + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + BeanUtils.copyProperties(insertHistoryNewDTO, vodPlayHistoryDO); + //查看系统设定的时长 + ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ClassDictDO::getId, insertHistoryNewDTO.getClassId())); + Date latestDailyDate = this.baseMapper.latestDailyStudyRecord(vodPlayHistoryDO.getMemberId()); + if (classDictDO.getLimitHour() == 1) { + //查看当天这个人看了多少时间 + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(insertHistoryNewDTO.getMemberId(), insertHistoryNewDTO.getClassId()); + if (total == 6 * 3600) { + throw new HttpException(13001); + } + //是否超过时长 没超过 false 超过 true + if (total + vodPlayHistoryDO.getPlayLength() > 6 * 3600) { + int playLength = 6 * 3600 - total; + vodPlayHistoryDO.setPlayLength(playLength); + if (playLength > 8) { + FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); + if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() + , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); + } + } + } else { FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); } } - } else { + } else if (classDictDO.getLimitHour() == 0) { FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); } } - } else if (classDictDO.getLimitHour() == 0) { - FixLengthVO fixLengthVO = fixPlayLength(date, latestDailyDate, vodPlayHistoryDO.getPlayLength(), vodPlayHistoryDO.getSuspendLength()); - if (null != fixLengthVO.getSuspendLength() && null != fixLengthVO.getPlayLength()) { - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), fixLengthVO.getPlayLength() - , fixLengthVO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), date, IpAddressUtil.getIpAddress(request)); - } } } return ConstantUtils.ADD_SUCCESS; diff --git a/src/main/resources/mapper/RenSheJuMapper.xml b/src/main/resources/mapper/RenSheJuMapper.xml index e35e61b..735cdca 100644 --- a/src/main/resources/mapper/RenSheJuMapper.xml +++ b/src/main/resources/mapper/RenSheJuMapper.xml @@ -2,30 +2,12 @@ - - - - - - - - - - - - - create_date, - update_date, - delete_date, - id, company_id, cert_id - - -- libgit2 0.25.0