From b17282a8dcffc7ca86be01c6d3064737ca13d975 Mon Sep 17 00:00:00 2001 From: tuyp Date: Tue, 8 Mar 2022 17:17:00 +0800 Subject: [PATCH] 脚本调整结束,按照时长分配,(第一个脚本) --- src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java | 2 +- src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java | 2 +- src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- src/main/java/com/subsidy/util/EncryptUtil.java | 70 +++++++++++++++++++++++++++++++++++----------------------------------- src/main/resources/application.properties | 4 ++-- src/main/resources/mapper/CompanyDictMapper.xml | 8 ++++++-- 6 files changed, 98 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index 368e673..e9ca6ec 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -333,7 +333,7 @@ public class AdministerServiceImpl extends ServiceImpl operators(OperatorsDTO operatorsDTO) { Page pager = new Page(operatorsDTO.getPageNum(), operatorsDTO.getPageSize()); - IPage operatorsVOIPage = companyDictMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getFieldId(), null, 0); + IPage operatorsVOIPage = companyDictMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getFieldId(), null, 1); List operatorsVOS = operatorsVOIPage.getRecords(); for (OperatorsVO operatorsVO : operatorsVOS) { diff --git a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java index b67b999..4b870d8 100644 --- a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java @@ -102,7 +102,7 @@ public class CompanyDictServiceImpl extends ServiceImpl 0){ administerDO.setCompanyId(null); } - IPage page = this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getFieldId(),administerDO.getCompanyId(),null); + IPage page = this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getFieldId(),administerDO.getCompanyId(),2); List operatorsVOS = page.getRecords(); for (OperatorsVO operatorsVO : operatorsVOS) { //查看公司所在行业 diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index a58a537..a810e57 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -61,9 +61,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() + ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() .lambda() - .eq(ClassHourDictDO::getCompanyId,memberDO.getCompanyId())); + .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); if (classHourDictDO.getStatus() == 1) { //查看当天这个人看了多少时间 @@ -71,10 +71,10 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl= classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour()*3600-total; + int playLength = classHourDictDO.getClassHour() * 3600 - total; vodPlayHistoryDO.setPlayLength(playLength); this.baseMapper.insert(vodPlayHistoryDO); - throw new HttpException(13001); + throw new HttpException(13001); } } vodPlayHistoryDO.setPlayCount(1); @@ -85,9 +85,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() + ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() .lambda() - .eq(ClassHourDictDO::getCompanyId,memberDO.getCompanyId())); + .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); if (classHourDictDO.getStatus() == 1) { //查看当天这个人看了多少时间 @@ -95,7 +95,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl= classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour()*3600-total; + int playLength = classHourDictDO.getClassHour() * 3600 - total; vodPlayHistoryDO.setPlayLength(playLength); this.baseMapper.insert(vodPlayHistoryDO); throw new HttpException(13001); @@ -366,10 +366,10 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl= 0; k--) { //查看当天这人已经看的视频时长 - List vodPlayHistoryDOS = vodPlayHistoryMapper.exPlayInfo(classMemberMappingDO.getMemberId(), String.valueOf(classId), signInRecordDO.getSignInDate()); + List vodPlayHistoryDOS = vodPlayHistoryMapper.exPlayInfo(classMemberMappingDO.getMemberId(), String.valueOf(classId), signInRecordDOS.get(k).getSignInDate()); //查看学生一看视频时长 int totalLength = 0; @@ -418,14 +418,14 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodDictDOS = courseContentMapper.getCourseVods(classDictDO.getCourseId()); + int vodTotalLength = 0; + for (VodDictDO vodDictDO : vodDictDOS) { + vodTotalLength += vodDictDO.getVodLength(); + } + //查看每个人看视频的时长 for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) { @@ -461,7 +466,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl localDateTimes = new ArrayList<>(); for (SignInRecordDO signInrecord : signInRecordDOS) { - if (signInrecord.getSignInDate().getHour() >= 6 && signInrecord.getSignInDate().getHour() < 15) { + if (signInrecord.getSignInDate().getHour() >= 6 && signInrecord.getSignInDate().getHour() < 17) { localDateTimes.add(signInrecord.getSignInDate()); } } @@ -530,20 +535,27 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 0) { VodPlayHistoryDO vodPlayHistoryDO1 = vodPlayHistoryDOS.get(0); - VodDictDO vodDictDO = vodDictMapper.selectById(vodPlayHistoryDO1.getVodId()); - //剩下的学习时长 - int leftLength = vodDictDO.getVodLength() - vodPlayHistoryDO1.getPlayLength(); - if (leftLength > 0) { - totalPlay += leftLength; - VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryDO.setClassId(classDictDO.getId()); - vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); - vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); - vodPlayHistoryDO.setPlayLength(leftLength); - vodPlayHistoryDO.setVodId(vodDictDO.getId()); - vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(leftLength)); - vodPlayHistoryMapper.insert(vodPlayHistoryDO); + int count = this.baseMapper.selectCount(new QueryWrapper() + .lambda() + .eq(VodPlayHistoryDO::getVodId, vodPlayHistoryDO1.getVodId()) + .eq(VodPlayHistoryDO::getMemberId,classMemberMappingDO.getMemberId())); + + if (count <2) { + VodDictDO vodDictDO = vodDictMapper.selectById(vodPlayHistoryDO1.getVodId()); + //剩下的学习时长 + int leftLength = vodDictDO.getVodLength() - vodPlayHistoryDO1.getPlayLength(); + if (leftLength > 0) { + totalPlay += leftLength; + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(classDictDO.getId()); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); + vodPlayHistoryDO.setPlayLength(leftLength); + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(leftLength)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); + } } } @@ -558,19 +570,21 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl totalPlay) { //说明今天还可以学 - VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - vodPlayHistoryDO.setPlayCount(1); - vodPlayHistoryDO.setClassId(classDictDO.getId()); - vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); - vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); - if (totalPlay+vodDictDO.getVodLength()<=totalPlayLength){ - vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength()); - }else { - vodPlayHistoryDO.setPlayLength(totalPlayLength-totalPlay); - } - vodPlayHistoryDO.setVodId(vodDictDO.getId()); - vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(totalPlay)); - vodPlayHistoryMapper.insert(vodPlayHistoryDO); + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + vodPlayHistoryDO.setPlayCount(1); + vodPlayHistoryDO.setClassId(classDictDO.getId()); + vodPlayHistoryDO.setMemberId(classMemberMappingDO.getMemberId()); + vodPlayHistoryDO.setPlayRecord(vodDictDO.getVodLength()); + if (totalPlay + vodDictDO.getVodLength() <= totalPlayLength) { + vodPlayHistoryDO.setPlayLength(vodDictDO.getVodLength()); + totalPlay += vodDictDO.getVodLength(); + } else { + vodPlayHistoryDO.setPlayLength(totalPlayLength - totalPlay); + totalPlay = totalPlayLength; + } + vodPlayHistoryDO.setVodId(vodDictDO.getId()); + vodPlayHistoryDO.setPlayDate(localDateTime.plusSeconds(totalPlay)); + vodPlayHistoryMapper.insert(vodPlayHistoryDO); } } } diff --git a/src/main/java/com/subsidy/util/EncryptUtil.java b/src/main/java/com/subsidy/util/EncryptUtil.java index 7055849..9db0ff2 100644 --- a/src/main/java/com/subsidy/util/EncryptUtil.java +++ b/src/main/java/com/subsidy/util/EncryptUtil.java @@ -1,35 +1,35 @@ -package com.subsidy.util; - -import com.amdelamar.jhash.Hash; -import com.amdelamar.jhash.algorithms.Type; -import com.amdelamar.jhash.exception.InvalidHashException; - -public class EncryptUtil { - - /** - * 设置密文密码 - * - * @param password 原始密码 - * @return 加密密码 - */ - public static String encrypt(String password) { - char[] chars = password.toCharArray(); - return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).create(); - } - - /** - * 验证加密密码 - * - * @param encryptedPassword 密文密码 - * @param plainPassword 明文密码 - * @return 验证是否成功 - */ - public static boolean verify(String encryptedPassword, String plainPassword) { - char[] chars = plainPassword.toCharArray(); - try { - return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).verify(encryptedPassword); - } catch (InvalidHashException e) { - return false; - } - } -} +//package com.subsidy.util; +// +//import com.amdelamar.jhash.Hash; +//import com.amdelamar.jhash.algorithms.Type; +//import com.amdelamar.jhash.exception.InvalidHashException; +// +//public class EncryptUtil { +// +// /** +// * 设置密文密码 +// * +// * @param password 原始密码 +// * @return 加密密码 +// */ +// public static String encrypt(String password) { +// char[] chars = password.toCharArray(); +// return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).create(); +// } +// +// /** +// * 验证加密密码 +// * +// * @param encryptedPassword 密文密码 +// * @param plainPassword 明文密码 +// * @return 验证是否成功 +// */ +// public static boolean verify(String encryptedPassword, String plainPassword) { +// char[] chars = plainPassword.toCharArray(); +// try { +// return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).verify(encryptedPassword); +// } catch (InvalidHashException e) { +// return false; +// } +// } +//} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 37ce64a..a62a220 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ # 环境配置 -spring.profiles.active=prod +spring.profiles.active=dev # 端口号 -spring.server.port=23459 +spring.server.port=23457 #嵌入tomcat配置 #和CPU数 spring.server.acceptorThreadCount=600 diff --git a/src/main/resources/mapper/CompanyDictMapper.xml b/src/main/resources/mapper/CompanyDictMapper.xml index 1fe08f4..39d4feb 100644 --- a/src/main/resources/mapper/CompanyDictMapper.xml +++ b/src/main/resources/mapper/CompanyDictMapper.xml @@ -34,14 +34,18 @@ t2.address FROM administer t + left join role_administer_mapping t4 on t.id = t4.administer_id left join company_dict t2 on t.company_id = t2.id left join company_field_mapping t3 on t2.id = t3.company_id WHERE t.delete_date IS NULL and t2.delete_date is null and t3.delete_date is null - - and t.role = #{role} + + (and t4.role = 1 or t4.role_id = 3) + + + (and t4.role = 2) and t2.id = #{id} -- libgit2 0.25.0