From 096878ddc0994ec35d879faa52367562776e297e Mon Sep 17 00:00:00 2001 From: tuyp Date: Thu, 12 Oct 2023 17:28:37 +0800 Subject: [PATCH] 解决时间交叉,活跃度检测的问题 --- src/main/java/com/subsidy/controller/ActivityDetectionController.java | 4 ++-- src/main/java/com/subsidy/controller/AdministerController.java | 2 +- src/main/java/com/subsidy/controller/VodPlayHistoryController.java | 9 +++++---- src/main/java/com/subsidy/dto/detection/VerifyDTO.java | 4 ++++ src/main/java/com/subsidy/jobs/RenSheJuJob.java | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------- src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java | 7 ++++++- src/main/java/com/subsidy/model/ActivityDetectionDO.java | 5 +++++ src/main/java/com/subsidy/model/ClassDictDO.java | 5 +++++ src/main/java/com/subsidy/model/VodPlayHistoryDO.java | 3 +-- src/main/java/com/subsidy/service/VodPlayHistoryService.java | 5 +++-- src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java | 59 +++++++++++++++++++++++++++++++++-------------------------- src/main/java/com/subsidy/service/impl/MemberServiceImpl.java | 33 +++++++++++++++------------------ src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java | 3 +-- src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------- src/main/java/com/subsidy/util/ActivityDetectionUtils.java | 59 +++++++++++++++++++++++++++++++---------------------------- src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java | 2 ++ src/main/java/com/subsidy/vo/member/MemberVodVO.java | 1 + src/main/java/com/subsidy/vo/vod/FixLengthVO.java | 12 ++++++++++++ src/main/resources/application-dev.properties | 19 +++++++++++++------ src/main/resources/mapper/AdministerMapper.xml | 2 +- src/main/resources/mapper/ClassMemberMappingMapper.xml | 3 +-- src/main/resources/mapper/MemberMapper.xml | 2 +- src/main/resources/mapper/OprMemDictMapper.xml | 5 +---- src/main/resources/mapper/RenSheJuMapper.xml | 11 +++-------- src/main/resources/mapper/VodDictMapper.xml | 2 +- src/main/resources/mapper/VodPlayHistoryMapper.xml | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------- 26 files changed, 447 insertions(+), 378 deletions(-) create mode 100644 src/main/java/com/subsidy/vo/vod/FixLengthVO.java diff --git a/src/main/java/com/subsidy/controller/ActivityDetectionController.java b/src/main/java/com/subsidy/controller/ActivityDetectionController.java index aaee5c8..6764d0e 100644 --- a/src/main/java/com/subsidy/controller/ActivityDetectionController.java +++ b/src/main/java/com/subsidy/controller/ActivityDetectionController.java @@ -36,7 +36,7 @@ public class ActivityDetectionController { private ActivityDetectionService activityDetectionService; @PostMapping("verify") - @ApiOperation("验证滑块 ticket randStr memberId classId checkType:检测类型:0:滑块 1:人脸 ") + @ApiOperation("验证滑块 ticket randStr vodId memberId classId checkType:检测类型:0:滑块 1:人脸 ") @TimeRequired public ResponseVO verify(@RequestBody VerifyDTO verifyDTO, HttpServletRequest request){ return ResponseData.generateCreatedResponse(0,activityDetectionService.verify(verifyDTO,request)); @@ -49,7 +49,7 @@ public class ActivityDetectionController { } @PostMapping("verifyError") - @ApiOperation("验证失败记录 classId memberId") + @ApiOperation("验证失败记录 vodId classId memberId") public ResponseVO verifyError(@RequestBody ActivityDetectionDO activityDetectionDO){ return ResponseData.generateCreatedResponse(0,activityDetectionService.verifyError(activityDetectionDO)); } diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index 3b2590e..c777f9f 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -181,7 +181,7 @@ public class AdministerController { @PostMapping("classVodDailyInfo") @ApiOperation("学习记录---每日学习时长(视频维度)") - @LoginRequired +// @LoginRequired public ResponseVO classVodDailyInfo(@RequestBody ClassVodDailyInfoDTO classVodDailyInfoDTO) { return ResponseData.generateCreatedResponse(0, administerService.classVodDailyInfo(classVodDailyInfoDTO)); } diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index d714374..d528968 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -39,17 +40,17 @@ public class VodPlayHistoryController { "memberId 成员id playLength 播放时长 playRecord 位点 suspendLength暂停时长 ") @LoginRequired @TimeRequired - public ResponseVO insertHistory(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){ - return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistory(vodPlayHistoryDO)); + public ResponseVO insertHistory(@RequestBody VodPlayHistoryDO vodPlayHistoryDO, HttpServletRequest request){ + return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistory(vodPlayHistoryDO,request)); } @RequestMapping("insertHistoryNew") @ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id " + "playLength 播放时长 playRecord 位点 suspendLength") @TimeRequired - public ResponseVO insertHistoryNew(@RequestBody String param){ + public ResponseVO insertHistoryNew(@RequestBody String param,HttpServletRequest request){ InsertHistoryNewDTO insertHistoryNewDTO = JSON.parseObject(param, InsertHistoryNewDTO.class); - return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(insertHistoryNewDTO)); + return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(insertHistoryNewDTO,request)); } @PostMapping("dataFix") diff --git a/src/main/java/com/subsidy/dto/detection/VerifyDTO.java b/src/main/java/com/subsidy/dto/detection/VerifyDTO.java index b2e963c..cb03c64 100644 --- a/src/main/java/com/subsidy/dto/detection/VerifyDTO.java +++ b/src/main/java/com/subsidy/dto/detection/VerifyDTO.java @@ -13,6 +13,10 @@ public class VerifyDTO { private Long memberId; + private Long vodId; + private Long classId; + private Integer clickStatus; + } diff --git a/src/main/java/com/subsidy/jobs/RenSheJuJob.java b/src/main/java/com/subsidy/jobs/RenSheJuJob.java index 0d99731..4af97da 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:班级基本信息信息采集接口 +// /** +//// * POST-2:班级基本信息信息采集接口 +//// */ +// @Scheduled(cron = "0 0 1 * * ?") +// public void classBaseInfo() throws IOException { +// if ("prod".equals(env)) { +// renSheJuService.classBaseInfo(); +// } +// } +// +// /** +// * POST-3:学时信息采集接口 // */ - @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(); - } +// @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 获取推送失败班级列表 diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index b01f66b..f49b189 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -106,7 +106,7 @@ public interface VodPlayHistoryMapper extends BaseMapper { /** * 插入一条学习数据 */ - void insertPlayRecord(Long classId,Long vodId,Long memberId,Integer playLength,Integer suspendLength,Integer playRecord,Integer playCount,Date createDate); + void insertPlayRecord(Long classId,Long vodId,Long memberId,Integer playLength,Integer suspendLength,Integer playRecord,Date createDate,String ipAddress); /** * 修改一条记录 @@ -132,4 +132,9 @@ public interface VodPlayHistoryMapper extends BaseMapper { */ List vodMembers(Long classId); + /** + * 查看某个学员今天最近的一次学习记录 + */ + Date latestDailyStudyRecord(Long memberId); + } diff --git a/src/main/java/com/subsidy/model/ActivityDetectionDO.java b/src/main/java/com/subsidy/model/ActivityDetectionDO.java index fbfd709..4d9054b 100644 --- a/src/main/java/com/subsidy/model/ActivityDetectionDO.java +++ b/src/main/java/com/subsidy/model/ActivityDetectionDO.java @@ -31,6 +31,11 @@ public class ActivityDetectionDO extends BaseModel { private Long classId; /** + * 视频id + */ + private Long vodId; + + /** * 人员id */ private Long memberId; diff --git a/src/main/java/com/subsidy/model/ClassDictDO.java b/src/main/java/com/subsidy/model/ClassDictDO.java index e8ec544..861e583 100644 --- a/src/main/java/com/subsidy/model/ClassDictDO.java +++ b/src/main/java/com/subsidy/model/ClassDictDO.java @@ -133,4 +133,9 @@ public class ClassDictDO extends BaseModel { */ private String professionRank; + /** + * 弹窗提醒 + */ + private Integer activityFlag; + } diff --git a/src/main/java/com/subsidy/model/VodPlayHistoryDO.java b/src/main/java/com/subsidy/model/VodPlayHistoryDO.java index ec42acd..8aefcd0 100644 --- a/src/main/java/com/subsidy/model/VodPlayHistoryDO.java +++ b/src/main/java/com/subsidy/model/VodPlayHistoryDO.java @@ -60,8 +60,7 @@ public class VodPlayHistoryDO extends BaseModel { /** * 聚合 */ - private Integer playCount; + private String ipAddress; private LocalDateTime playDate; - } diff --git a/src/main/java/com/subsidy/service/VodPlayHistoryService.java b/src/main/java/com/subsidy/service/VodPlayHistoryService.java index b16e683..debe16b 100644 --- a/src/main/java/com/subsidy/service/VodPlayHistoryService.java +++ b/src/main/java/com/subsidy/service/VodPlayHistoryService.java @@ -8,6 +8,7 @@ import com.subsidy.model.VodPlayHistoryDO; import com.baomidou.mybatisplus.extension.service.IService; import com.subsidy.vo.vod.VodPlayStateVO; +import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -22,9 +23,9 @@ import java.util.List; */ public interface VodPlayHistoryService extends IService { - String insertHistory(VodPlayHistoryDO vodPlayHistoryDO); + String insertHistory(VodPlayHistoryDO vodPlayHistoryDO,HttpServletRequest request); - String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO); + String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDT,HttpServletRequest request); void dataFix(SignDatePlaysDTO dataFixDTO); diff --git a/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java b/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java index 42e0f47..cf5c7ac 100644 --- a/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java @@ -30,47 +30,54 @@ import javax.servlet.http.HttpServletRequest; @Service public class ActivityDetectionServiceImpl extends ServiceImpl implements ActivityDetectionService { - @Autowired - private VodPlayHistoryMapper vodPlayHistoryMapper; + public String verify(VerifyDTO verifyDTO, HttpServletRequest request) { - public String verify(VerifyDTO verifyDTO, HttpServletRequest request){ + try { - try{ - DescribeCaptchaResultResponse resp = ActivityDetectionUtils.activityDetection(request,verifyDTO.getTicket(),verifyDTO.getRandStr()); - // 输出json格式的字符串回包 - ActivityDetectionDO activityDetectionDO = new ActivityDetectionDO(); - activityDetectionDO.setClassId(verifyDTO.getClassId()); - activityDetectionDO.setMemberId(verifyDTO.getMemberId()); - activityDetectionDO.setRequestId(resp.getRequestId()); - activityDetectionDO.setCheckType(0); - if (resp.getCaptchaCode()==1){ + if (verifyDTO.getClickStatus() == 1) { + ActivityDetectionDO activityDetectionDO = new ActivityDetectionDO(); + activityDetectionDO.setClassId(verifyDTO.getClassId()); + activityDetectionDO.setMemberId(verifyDTO.getMemberId()); + activityDetectionDO.setCheckType(0); + activityDetectionDO.setVodId(verifyDTO.getVodId()); //成功 activityDetectionDO.setStatus(1); this.baseMapper.insert(activityDetectionDO); - return ConstantUtils.SUCCESS_VERIFY; - }else { - //失败 - activityDetectionDO.setStatus(0); - this.baseMapper.insert(activityDetectionDO); -// -// //失败的话删掉这个人最新的学习数据 -// Long latestRecord = vodPlayHistoryMapper.memberLatestRecord(verifyDTO.getMemberId()); -// vodPlayHistoryMapper.deleteById(latestRecord); + } else { + DescribeCaptchaResultResponse resp = ActivityDetectionUtils.activityDetection(request, verifyDTO.getTicket(), verifyDTO.getRandStr()); + // 输出json格式的字符串回包 + ActivityDetectionDO activityDetectionDO = new ActivityDetectionDO(); + activityDetectionDO.setClassId(verifyDTO.getClassId()); + activityDetectionDO.setMemberId(verifyDTO.getMemberId()); + activityDetectionDO.setRequestId(resp.getRequestId()); + activityDetectionDO.setCheckType(0); + activityDetectionDO.setVodId(verifyDTO.getVodId()); + if (resp.getCaptchaCode() == 1) { + //成功 + activityDetectionDO.setStatus(1); + this.baseMapper.insert(activityDetectionDO); + return ConstantUtils.SUCCESS_VERIFY; + } else { + //失败 + activityDetectionDO.setStatus(0); + this.baseMapper.insert(activityDetectionDO); - throw new HttpException(19001); + throw new HttpException(19001); + } } + } catch (Exception e) { -// System.out.println(e.toString()); + System.out.println(e.toString()); } return ConstantUtils.SUCCESS_VERIFY; } - public IPage getCheckHistory(GetCheckHistoryDTO getCheckHistoryDTO){ + public IPage getCheckHistory(GetCheckHistoryDTO getCheckHistoryDTO) { Page pager = new Page(getCheckHistoryDTO.getPageNum(), getCheckHistoryDTO.getPageSize()); - return this.baseMapper.getCheckHistory(pager,getCheckHistoryDTO.getClassId(),getCheckHistoryDTO.getMemberId()); + return this.baseMapper.getCheckHistory(pager, getCheckHistoryDTO.getClassId(), getCheckHistoryDTO.getMemberId()); } - public String verifyError(ActivityDetectionDO activityDetectionDO){ + public String verifyError(ActivityDetectionDO activityDetectionDO) { activityDetectionDO.setStatus(0); activityDetectionDO.setCheckType(0); this.baseMapper.insert(activityDetectionDO); diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index f229d5a..823e2ab 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -301,12 +301,6 @@ public class MemberServiceImpl extends ServiceImpl imple CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); if ("冻结".equals(memberDO.getStatus())) { -// OprMemDictDO oprMemDictDO = new OprMemDictDO(); -// oprMemDictDO.setUserId(memberDO.getId()); -// oprMemDictDO.setOprType("登录"); -// oprMemDictDO.setResult(0); -// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); -// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(10013); } @@ -332,17 +326,6 @@ public class MemberServiceImpl extends ServiceImpl imple // oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(70010); } - //审计日志 -// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); -// if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { -// oprMemDictDO = new OprMemDictDO(); -// oprMemDictDO.setUserId(memberDO.getId()); -// oprMemDictDO.setOprType("登录"); -// oprMemDictDO.setResult(1); -// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); -// oprMemDictMapper.insert(oprMemDictDO); -// } - //mongoTemplate.insert(oprMemDictDO); userRoleVO.setCompanyId(companyDictDO.getId()); userRoleVO.setSuperviseName(companyDictDO.getSuperviseName()); userRoleVO.setCompanyName(companyDictDO.getCompanyName()); @@ -373,7 +356,6 @@ public class MemberServiceImpl extends ServiceImpl imple throw new HttpException(10017); } - /** * 最近5次都输入失败,5分钟后再验证 */ @@ -790,6 +772,21 @@ public class MemberServiceImpl extends ServiceImpl imple if (1 == classDictDO1.getIsOrder()) { for (MemberVodVO memberVodVO : memberVodVOS) { + //当前视频有没有做过活跃度检测 + + Integer count = activityDetectionMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ActivityDetectionDO::getVodId, memberVodVO.getId()) + .eq(ActivityDetectionDO::getMemberId, contentVodDTO.getMemberId()) + .eq(ActivityDetectionDO::getClassId, contentVodDTO.getClassId()) + .eq(ActivityDetectionDO::getStatus, 1)); + + if (count > 0) { + memberVodVO.setActivityStatus(true); + } else { + memberVodVO.setActivityStatus(false); + } + if (i == 0 && contentStatus) { //第一个视频默认打开 memberVodVO.setStatus(true); diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index b441b71..c63a06f 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -166,8 +166,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { List result = new ArrayList<>(); // List vodClassIds = new ArrayList<>(); -// -// vodClassIds.add(451L); + try { for (Long classId : vodClassIds) { diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index d134123..fc3c204 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -10,13 +10,17 @@ import com.subsidy.mapper.*; import com.subsidy.model.*; import com.subsidy.service.VodPlayHistoryService; import com.subsidy.util.ConstantUtils; +import com.subsidy.util.IpAddressUtil; import com.subsidy.util.SMSUtils; +import com.subsidy.vo.vod.FixLengthVO; import com.subsidy.vo.vod.VodPlayStateVO; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import sun.util.calendar.CalendarDate; +import javax.servlet.http.HttpServletRequest; import java.time.LocalDateTime; import java.util.*; @@ -55,21 +59,15 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() -// .lambda() -// .eq(ExerciseDoneResultDO::getClassId, vodPlayHistoryDO.getClassId()) -// .eq(ExerciseDoneResultDO::getMemberId, vodPlayHistoryDO.getMemberId()) -// .eq(ExerciseDoneResultDO::getResult, "合格")); -// if (count == 0){ Date date = new Date(); if (vodPlayHistoryDO.getPlayLength() > 8 && vodPlayHistoryDO.getSuspendLength() <= 3000) { + + Date latestDailyDate = this.baseMapper.latestDailyStudyRecord(vodPlayHistoryDO.getMemberId()); + //查看系统设定的时长 ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() .lambda() @@ -85,40 +83,35 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 5) { - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); -// this.baseMapper.insert(vodPlayHistoryDO); + 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 { - vodPlayHistoryDO.setPlayCount(1); -// this.baseMapper.insert(vodPlayHistoryDO); - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); + 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) { - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); -// this.baseMapper.insert(vodPlayHistoryDO); + 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; } @Transactional(rollbackFor = Exception.class) - public String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO) { + public String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO, HttpServletRequest request) { -// Integer count = exerciseDoneResultMapper.selectCount(new QueryWrapper() -// .lambda() -// .eq(ExerciseDoneResultDO::getClassId, insertHistoryNewDTO.getClassId()) -// .eq(ExerciseDoneResultDO::getMemberId, insertHistoryNewDTO.getMemberId()) -// .eq(ExerciseDoneResultDO::getResult, "合格")); -// -// if (count == 0){ Date date = new Date(); if (insertHistoryNewDTO.getPlayLength() > 8 && insertHistoryNewDTO.getSuspendLength() <= 3000) { VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); @@ -127,6 +120,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() .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()); @@ -137,29 +131,62 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 6 * 3600) { int playLength = 6 * 3600 - total; vodPlayHistoryDO.setPlayLength(playLength); - vodPlayHistoryDO.setPlayCount(1); - if (playLength > 5) { - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); -// this.baseMapper.insert(vodPlayHistoryDO); + 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 { - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); -// this.baseMapper.insert(vodPlayHistoryDO); + 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) { - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() - , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); -// this.baseMapper.insert(vodPlayHistoryDO); + 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; } + /** + * 修正插入观看时长,使不在有交叉 + * + * @param currentDate 当前插入时间 + * @param latestDate 最近一次学习时间 + * @param playLength 当前观看时长 + * @param suspendLength 暂停时长 + * @return + */ + public FixLengthVO fixPlayLength(Date currentDate, Date latestDate, Integer playLength, Integer suspendLength) { + + FixLengthVO fixLengthVO = new FixLengthVO(); + + if (null != latestDate) { + int diff = (int) (currentDate.getTime() - latestDate.getTime()) / 1000; + if (diff < playLength + suspendLength) { + if (diff > 8) { + fixLengthVO.setSuspendLength(0); + fixLengthVO.setPlayLength(diff); + } + } else { + fixLengthVO.setPlayLength(playLength); + fixLengthVO.setSuspendLength(suspendLength); + } + } else { + fixLengthVO.setPlayLength(playLength); + fixLengthVO.setSuspendLength(suspendLength); + } + return fixLengthVO; + } + public void dataFix(SignDatePlaysDTO dataFixDTO) { //班级ids @@ -254,7 +281,6 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 0) { totalPlay += leftLength; VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - vodPlayHistoryDO.setPlayCount(1); vodPlayHistoryDO.setClassId(Long.valueOf(str)); vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); @@ -282,7 +308,6 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 0) { totalPlay += leftLength; VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - vodPlayHistoryDO.setPlayCount(1); vodPlayHistoryDO.setClassId(classDictDO.getId()); vodPlayHistoryDO.setMemberId(remainSecondsDTO.getMemberId()); vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); @@ -628,7 +648,6 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl totalPlay) { //说明今天还可以学 VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - vodPlayHistoryDO.setPlayCount(1); vodPlayHistoryDO.setClassId(classDictDO.getId()); vodPlayHistoryDO.setMemberId(remainSecondsDTO.getMemberId()); vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); @@ -724,21 +743,21 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodPlayHistoryDOS = this.baseMapper.selectList(new QueryWrapper() - .lambda() - .eq(VodPlayHistoryDO::getClassId,vodPlayHistoryDO.getClassId()) - .eq(VodPlayHistoryDO::getMemberId,memberId) - .eq(VodPlayHistoryDO::getVodId,vodPlayHistoryDO.getVodId()) - .orderByAsc(VodPlayHistoryDO::getCreateDate)); - int i = 0 ; - - for (VodPlayHistoryDO vodPlayHistoryDO1 : vodPlayHistoryDOS){ - i+=vodPlayHistoryDO1.getPlayLength(); - if ( i >= vodDictDO.getVodLength()){ - result.add(vodPlayHistoryDO1.getId()); - break; - } + for (Long memberId : vodMembers) { + List vodPlayHistoryDOS = this.baseMapper.selectList(new QueryWrapper() + .lambda() + .eq(VodPlayHistoryDO::getClassId, vodPlayHistoryDO.getClassId()) + .eq(VodPlayHistoryDO::getMemberId, memberId) + .eq(VodPlayHistoryDO::getVodId, vodPlayHistoryDO.getVodId()) + .orderByAsc(VodPlayHistoryDO::getCreateDate)); + int i = 0; + + for (VodPlayHistoryDO vodPlayHistoryDO1 : vodPlayHistoryDOS) { + i += vodPlayHistoryDO1.getPlayLength(); + if (i >= vodDictDO.getVodLength()) { + result.add(vodPlayHistoryDO1.getId()); + break; + } } } return result; diff --git a/src/main/java/com/subsidy/util/ActivityDetectionUtils.java b/src/main/java/com/subsidy/util/ActivityDetectionUtils.java index 2a2b1f1..0f09334 100644 --- a/src/main/java/com/subsidy/util/ActivityDetectionUtils.java +++ b/src/main/java/com/subsidy/util/ActivityDetectionUtils.java @@ -13,37 +13,40 @@ public class ActivityDetectionUtils { /** * 活跃度检测工具类 - * @param request - * @param randstr - * @return + * * @throws Exception */ - public static DescribeCaptchaResultResponse activityDetection(HttpServletRequest request,String ticket, String randstr) throws Exception { - - // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密 - // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取 - Credential cred = new Credential(ConstantUtils.SECRET_ID, ConstantUtils.SECRET_KEY); - // 实例化一个http选项,可选的,没有特殊需求可以跳过 - HttpProfile httpProfile = new HttpProfile(); - httpProfile.setEndpoint("captcha.tencentcloudapi.com"); - // 实例化一个client选项,可选的,没有特殊需求可以跳过 - ClientProfile clientProfile = new ClientProfile(); - clientProfile.setHttpProfile(httpProfile); - // 实例化要请求产品的client对象,clientProfile是可选的 - CaptchaClient client = new CaptchaClient(cred, "", clientProfile); - // 实例化一个请求对象,每个接口都会对应一个request对象 - DescribeCaptchaResultRequest req = new DescribeCaptchaResultRequest(); - req.setCaptchaType(9L); - String ip = IpAddressUtil.getIpAddress(request); - req.setUserIp(ip); - req.setRandstr(randstr); - req.setCaptchaAppId(ConstantUtils.CAPTCHAAPP_ID); - req.setAppSecretKey(ConstantUtils.APP_SECRET_KEY); - req.setBusinessId(ConstantUtils.BUSINESS_ID); - req.setTicket(ticket); - // 返回的resp是一个DescribeCaptchaResultResponse的实例,与请求对象对应 - return client.DescribeCaptchaResult(req); + public static DescribeCaptchaResultResponse activityDetection(HttpServletRequest request, String ticket, String randstr) { + + try { + // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密 + // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取 + Credential cred = new Credential(ConstantUtils.SECRET_ID, ConstantUtils.SECRET_KEY); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("captcha.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + CaptchaClient client = new CaptchaClient(cred, "", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + DescribeCaptchaResultRequest req = new DescribeCaptchaResultRequest(); + req.setCaptchaType(9L); + String ip = IpAddressUtil.getIpAddress(request); + req.setUserIp(ip); + req.setRandstr(randstr); + req.setCaptchaAppId(ConstantUtils.CAPTCHAAPP_ID); + req.setAppSecretKey(ConstantUtils.APP_SECRET_KEY); + req.setBusinessId(ConstantUtils.BUSINESS_ID); + req.setTicket(ticket); + // 返回的resp是一个DescribeCaptchaResultResponse的实例,与请求对象对应 + return client.DescribeCaptchaResult(req); + } catch (Exception e) { + + } + return null; } } diff --git a/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java b/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java index aa9716f..caf2461 100644 --- a/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java +++ b/src/main/java/com/subsidy/vo/classdict/ClassSettingsVO.java @@ -67,4 +67,6 @@ public class ClassSettingsVO { private Integer deviceNoRecord; private Integer timeLimit; + + private Integer activityFlag; } diff --git a/src/main/java/com/subsidy/vo/member/MemberVodVO.java b/src/main/java/com/subsidy/vo/member/MemberVodVO.java index 090c120..61c9832 100644 --- a/src/main/java/com/subsidy/vo/member/MemberVodVO.java +++ b/src/main/java/com/subsidy/vo/member/MemberVodVO.java @@ -24,4 +24,5 @@ public class MemberVodVO { private String leftLength; + private Boolean activityStatus; } diff --git a/src/main/java/com/subsidy/vo/vod/FixLengthVO.java b/src/main/java/com/subsidy/vo/vod/FixLengthVO.java new file mode 100644 index 0000000..3bf0dcf --- /dev/null +++ b/src/main/java/com/subsidy/vo/vod/FixLengthVO.java @@ -0,0 +1,12 @@ +package com.subsidy.vo.vod; + +import lombok.Data; + +@Data +public class FixLengthVO { + + private Integer suspendLength; + + private Integer playLength; + +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 9df4427..7ab97b0 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -2,14 +2,21 @@ spring.server.port=23457 # 数据源配置 -spring.datasource.url=jdbc:mysql://116.62.57.92:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 -#spring.datasource.url=jdbc:mysql://rm-uf6rab73w0qg843opxo.mysql.rds.aliyuncs.com:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 +#spring.datasource.url=jdbc:mysql://116.62.57.92:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 +##spring.datasource.url=jdbc:mysql://rm-uf6rab73w0qg843opxo.mysql.rds.aliyuncs.com:3306/subsidy_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 +#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +##spring.datasource.username=ykadmin_new +##spring.datasource.password=youkedb608@good +#spring.datasource.username=devloper +#spring.datasource.password=dev@1553$ + +# 数据源配置 8.0数据库 +spring.datasource.url=jdbc:mysql://139.224.253.21:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -#spring.datasource.username=ykadmin_new -#spring.datasource.password=youkedb608@good -spring.datasource.username=devloper -spring.datasource.password=dev@1553$ +spring.datasource.username=root +spring.datasource.password=ykhladmin302 spring.datasource.druid.initialSize=5 spring.datasource.druid.minIdle=5 diff --git a/src/main/resources/mapper/AdministerMapper.xml b/src/main/resources/mapper/AdministerMapper.xml index c08652e..b5ec071 100644 --- a/src/main/resources/mapper/AdministerMapper.xml +++ b/src/main/resources/mapper/AdministerMapper.xml @@ -203,7 +203,7 @@ AND t2.class_id = #{classId} GROUP BY t2.member_id, - t2.class_id + t2.class_id ) t2 ON t1.id = t2.member_id order by t1.account_name ASC diff --git a/src/main/resources/mapper/ClassMemberMappingMapper.xml b/src/main/resources/mapper/ClassMemberMappingMapper.xml index e785fbe..d311b23 100644 --- a/src/main/resources/mapper/ClassMemberMappingMapper.xml +++ b/src/main/resources/mapper/ClassMemberMappingMapper.xml @@ -80,7 +80,7 @@ diff --git a/src/main/resources/mapper/MemberMapper.xml b/src/main/resources/mapper/MemberMapper.xml index abb2194..6645104 100644 --- a/src/main/resources/mapper/MemberMapper.xml +++ b/src/main/resources/mapper/MemberMapper.xml @@ -413,7 +413,7 @@ FROM member m LEFT JOIN class_member_mapping cm ON cm.member_id = m.id - LEFT JOIN ( SELECT member_id, count( 1 ) AS ts, class_id FROM exercise_done_result WHERE score >= 60 GROUP BY class_id ) AS r ON r.member_id = m.id AND r.class_id = cm.class_id + LEFT JOIN ( SELECT member_id, count( 1 ) AS ts, class_id FROM exercise_done_result WHERE score >= 60 GROUP BY class_id,member_id ) AS r ON r.member_id = m.id AND r.class_id = cm.class_id WHERE cm.class_id = #{classId} AND r.ts is NULL diff --git a/src/main/resources/mapper/OprMemDictMapper.xml b/src/main/resources/mapper/OprMemDictMapper.xml index 16301d8..a220420 100644 --- a/src/main/resources/mapper/OprMemDictMapper.xml +++ b/src/main/resources/mapper/OprMemDictMapper.xml @@ -108,7 +108,6 @@ FROM ( SELECT - id, user_id, opr_type, max( create_date ) AS time1 @@ -126,7 +125,6 @@ ) t1 LEFT JOIN ( SELECT - id, user_id, opr_type, max( create_date ) AS time2 @@ -143,8 +141,7 @@ create_date DESC ) t2 ON t1.user_id = t2.user_id WHERE - t2.id IS NULL - OR t2.time2 < t1.time1 + t2.time2 < t1.time1 @@ -490,7 +486,6 @@ and class_id = #{classId} AND t1.paper_id IS not NULL AND t1.result = 1 - GROUP BY t1.class_id,t1.member_id ORDER BY t1.create_date desc diff --git a/src/main/resources/mapper/VodDictMapper.xml b/src/main/resources/mapper/VodDictMapper.xml index caed48e..902a731 100644 --- a/src/main/resources/mapper/VodDictMapper.xml +++ b/src/main/resources/mapper/VodDictMapper.xml @@ -126,7 +126,7 @@ t2.content_id = #{conetntId} AND t1.delete_date IS NULL AND t2.delete_date IS NULL - GROUP BY + order BY t1.order_no DESC diff --git a/src/main/resources/mapper/VodPlayHistoryMapper.xml b/src/main/resources/mapper/VodPlayHistoryMapper.xml index de00ac8..9925333 100644 --- a/src/main/resources/mapper/VodPlayHistoryMapper.xml +++ b/src/main/resources/mapper/VodPlayHistoryMapper.xml @@ -22,9 +22,9 @@ delete_date, id, class_id, vod_id, member_id, play_length, play_record - - - + + + SELECT - t.member_id, - DATE_FORMAT( t.create_date, '%Y-%m-%d' ) as studyDate, - sum( t.play_length ) as playLength, - sum( - IF - ( t.play_length >= t2.vod_length, t2.vod_length, t.play_length )) AS distinctLength + t.member_id, + DATE_FORMAT( t.create_date, '%Y-%m-%d' ) as studyDate, + sum( t.play_length ) as playLength, + sum( + IF + ( t.play_length >= t2.vod_length, t2.vod_length, t.play_length )) AS distinctLength FROM - vod_play_history t + vod_play_history t LEFT JOIN vod_dict t2 ON t.vod_id = t2.id WHERE - t.delete_date IS NULL + t.delete_date IS NULL AND t2.delete_date IS NULL AND t.class_id = #{classId} AND t.member_id IN #{id} - AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) BETWEEN DATE_FORMAT( #{startDate}, '%Y-%m-%d' ) - AND DATE_FORMAT( #{endDate}, '%Y-%m-%d' ) - GROUP BY - t.member_id, - DATE_FORMAT( t.create_date, '%Y-%m-%d' ) + AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) BETWEEN DATE_FORMAT( #{startDate}, '%Y-%m-%d' ) + AND DATE_FORMAT( #{endDate}, '%Y-%m-%d' ) + GROUP BY + t.member_id, + DATE_FORMAT( t.create_date, '%Y-%m-%d' ) - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - SELECT * FROM @@ -469,21 +469,21 @@ t.create_date - - - - - - - - - - - + + + + + + + + + + + - insert into vod_play_history (class_id,vod_id,member_id,play_length,suspend_length,play_record,play_count,create_date) - VALUES (#{classId}, #{vodId}, #{memberId}, #{playLength},#{suspendLength},#{playRecord}, #{playCount},#{createDate}) + insert into vod_play_history (class_id,vod_id,member_id,play_length,suspend_length,play_record,create_date,ip_address) + VALUES (#{classId}, #{vodId}, #{memberId}, #{playLength},#{suspendLength},#{playRecord},#{createDate},#{ipAddress}) @@ -560,4 +560,15 @@ and t.class_id = #{classId} + + -- libgit2 0.25.0