From eefbce7c36a7a18b5264279786d6159ba9fb6608 Mon Sep 17 00:00:00 2001 From: tuyp Date: Wed, 9 Mar 2022 13:56:00 +0800 Subject: [PATCH] 签到数据删除了历史数据 --- pom.xml | 10 +++++----- src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java | 13 +++++-------- src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 69 ++++++++++++++++++++++++++++++++++++++------------------------------- src/main/resources/application.properties | 4 ++-- 4 files changed, 50 insertions(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index faa6f00..bbd39da 100644 --- a/pom.xml +++ b/pom.xml @@ -133,11 +133,11 @@ ${swagger2.version} - - com.amdelamar - jhash - ${jhash.version} - + + + + + org.apache.poi diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index 10bfbaa..af1c3f8 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -56,9 +56,6 @@ public class SignInRecordServiceImpl extends ServiceImpl() - .lambda() - .eq(SignInRecordDO::getMemberId,signInRecordDO.getMemberId()) - .eq(SignInRecordDO::getClassId,classDictDO.getId())); + this.baseMapper.delete(new QueryWrapper() + .lambda() + .eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId()) + .gt(SignInRecordDO::getSignInDate, LocalDate.now())); // 存储到缓存到同时保存到数据库 SignInRecordDO sign = this.baseMapper.selectOne(new QueryWrapper() @@ -138,7 +135,7 @@ public class SignInRecordServiceImpl extends ServiceImpl() + Integer signCount = this.baseMapper.selectCount(new QueryWrapper() .lambda() .eq(SignInRecordDO::getMemberId, classMemberMappingDO.getMemberId()) .eq(SignInRecordDO::getClassId, dataViewVO.getClassId())); diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index a810e57..8fcb78a 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -366,12 +366,16 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl= 0; k--) { //查看当天这人已经看的视频时长 List vodPlayHistoryDOS = vodPlayHistoryMapper.exPlayInfo(classMemberMappingDO.getMemberId(), String.valueOf(classId), signInRecordDOS.get(k).getSignInDate()); - //查看学生一看视频时长 + //查看学生已看视频时长 int totalLength = 0; System.out.println("111111111111111"); List vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper() @@ -398,39 +402,42 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 0) { - //随机看几个视频 - int playCounts = new Random().nextInt(4) + 2; - System.out.println("4444444444444444"); - for (int i = 0; i < playCounts; i++) { - VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - Random random1 = new Random(); - System.out.println("55555555555555555555"); - int j = random1.nextInt(vodDictDOS.size()); - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryDO.setClassId(classId); - vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); - int h = new Random().nextInt(vodDictDOS.get(j).getVodLength() - 10) + 1; - System.out.println("666666666666666666"); - vodPlayHistoryDO.setPlayRecord(new Random().nextInt(h)); - if (leftLength - h > 0) { - vodPlayHistoryDO.setPlayLength(h); - playLength += h; - vodPlayHistoryDO.setVodId(vodDictDOS.get(j).getId()); - vodPlayHistoryDO.setPlayDate(signInRecordDOS.get(k).getSignInDate().plusSeconds(playLength)); - leftLength = leftLength - h; - vodPlayHistoryMapper.insert(vodPlayHistoryDO); - } else { - vodPlayHistoryDO.setPlayLength(leftLength); - playLength += leftLength; - vodPlayHistoryDO.setVodId(vodDictDOS.get(j).getId()); - vodPlayHistoryDO.setPlayDate(signInRecordDOS.get(k).getSignInDate().plusSeconds(playLength)); - vodPlayHistoryMapper.insert(vodPlayHistoryDO); - break; + if (maxLength>playLength){ + if (leftLength > 0) { + //随机看几个视频 + int playCounts = new Random().nextInt(4) + 2; + System.out.println("4444444444444444"); + for (int i = 0; i < playCounts; i++) { + + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + Random random1 = new Random(); + System.out.println("55555555555555555555"); + int j = random1.nextInt(vodDictDOS.size()); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(classId); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + int h = new Random().nextInt(vodDictDOS.get(j).getVodLength() - 10) + 1; + System.out.println("666666666666666666"); + vodPlayHistoryDO.setPlayRecord(new Random().nextInt(h)); + if (leftLength - h > 0) { + vodPlayHistoryDO.setPlayLength(h); + playLength += h; + vodPlayHistoryDO.setVodId(vodDictDOS.get(j).getId()); + vodPlayHistoryDO.setPlayDate(signInRecordDOS.get(k).getSignInDate().plusSeconds(playLength)); + leftLength = leftLength - h; + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + } else { + vodPlayHistoryDO.setPlayLength(leftLength); + playLength += leftLength; + vodPlayHistoryDO.setVodId(vodDictDOS.get(j).getId()); + vodPlayHistoryDO.setPlayDate(signInRecordDOS.get(k).getSignInDate().plusSeconds(playLength)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + break; + } } } } + System.out.println("33333333333333333333"); } } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a62a220..37ce64a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ # 环境配置 -spring.profiles.active=dev +spring.profiles.active=prod # 端口号 -spring.server.port=23457 +spring.server.port=23459 #嵌入tomcat配置 #和CPU数 spring.server.acceptorThreadCount=600 -- libgit2 0.25.0