MemberServiceImpl.java 23.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
package com.subsidy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.member.*;
import com.subsidy.mapper.*;
import com.subsidy.model.*;
import com.subsidy.service.MemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.MathUtil;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.course.QueryCoursesVO;
import com.subsidy.vo.member.*;
import com.subsidy.vo.paper.QueryPapersVO;
import com.subsidy.vo.vod.StudyHistoryVO;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Member;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 学生表 服务实现类
 * </p>
 *
 * @author DengMin
 * @since 2021-10-11
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> implements MemberService {

    @Autowired
    private SmsVerifyCodeMapper smsVerifyCodeMapper;

    @Autowired
    private CourseContentMapper courseContentMapper;

    @Autowired
    private VodPlayHistoryMapper vodPlayHistoryMapper;

    @Autowired
    private VodDictMapper vodDictMapper;

    @Autowired
    private FileDictMapper fileDictMapper;

    @Autowired
    private ExerciseDoneResultMapper exerciseDoneResultMapper;

    @Autowired
    private ClassMemberMappingMapper classMemberMappingMapper;

    @Autowired
    private PaperDictMapper paperDictMapper;

    @Autowired
    private ClassDictMapper classDictMapper;

    @Autowired
    private CompanyDictMapper companyDictMapper;

    @Autowired
    private MemberDepartmentMappingMapper memberDepartmentMappingMapper;

    @Autowired
    private ClassHourDictMapper classHourDictMapper;

    public IPage<GetAllVO> getAll(GetAllDTO getAllDTO) {
        Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize());
        IPage iPage = this.baseMapper.getMembers(pager, getAllDTO.getDepartmentId(), getAllDTO.getUserName(), getAllDTO.getStatus());

        List<GetAllVO> getAllVOS = iPage.getRecords();
        for (GetAllVO getAllVO : getAllVOS) {
            List<DepartmentDictDO> departmentDictDOS = this.baseMapper.getDepartments(getAllVO.getId());
            getAllVO.setDepartmentDictDOS(departmentDictDOS);
        }
        return iPage;
    }

    public String deleteMember(MemberDO memberDO) {
        this.baseMapper.deleteById(memberDO.getId());

        classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
                .lambda()
                .eq(ClassMemberMappingDO::getMemberId, memberDO.getId()));

        memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
                .lambda()
                .eq(MemberDepartmentMappingDO::getMemberId, memberDO.getId()));

        return ConstantUtils.DELETE_SUCCESS;
    }

    public String addMember(AddMemberDTO addMemberDTO) {

        Integer count = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
                .lambda()
                .eq(MemberDO::getTelephone, addMemberDTO.getTelephone()));

        if (count > 0) {
            throw new HttpException(20002);
        }

        //部门
        List<Long> longs = addMemberDTO.getDepartmentIds();

        Integer count1 = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
                .lambda()
                .eq(MemberDO::getAccountName, addMemberDTO.getAccountName())
                .eq(MemberDO::getCompanyId, addMemberDTO.getCompanyId()));

        if (count1 > 0) {
            throw new HttpException(20002);
        }


        MemberDO memberDO = new MemberDO();
        BeanUtils.copyProperties(addMemberDTO, memberDO);
        memberDO.setPassword("123456");
        memberDO.setStatus("启用");
        memberDO.setFirstLogin(0);
        //公司赋值
        memberDO.setCompanyId(addMemberDTO.getCompanyId());
        this.baseMapper.insert(memberDO);


        for (Long lg : longs) {
            MemberDepartmentMappingDO memberDepartmentMappingDO = new MemberDepartmentMappingDO();
            memberDepartmentMappingDO.setMemberId(memberDO.getId());
            memberDepartmentMappingDO.setDepartmentId(lg);
            memberDepartmentMappingMapper.insert(memberDepartmentMappingDO);
        }

        return ConstantUtils.ADD_SUCCESS;
    }

    public String updateMember(AddMemberDTO addMemberDTO) {

        if (null != addMemberDTO.getDepartmentIds()) {
            Integer count = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
                    .lambda()
                    .eq(MemberDO::getTelephone, addMemberDTO.getTelephone())
                    .ne(MemberDO::getId, addMemberDTO.getId()));

            if (count > 0) {
                throw new HttpException(20002);
            }
            Integer count1 = this.baseMapper.selectCount(new QueryWrapper<MemberDO>()
                    .lambda()
                    .eq(MemberDO::getAccountName, addMemberDTO.getAccountName())
                    .eq(MemberDO::getCompanyId, addMemberDTO.getCompanyId())
                    .ne(MemberDO::getId, addMemberDTO.getId()));

            if (count1 > 0) {
                throw new HttpException(20002);
            }
        }

        MemberDO memberDO = new MemberDO();
        BeanUtils.copyProperties(addMemberDTO, memberDO);
        this.baseMapper.updateById(memberDO);

        if (null != addMemberDTO.getDepartmentIds()) {
            memberDepartmentMappingMapper.delete(new QueryWrapper<MemberDepartmentMappingDO>()
                    .lambda()
                    .eq(MemberDepartmentMappingDO::getMemberId, addMemberDTO.getId()));

            //部门
            List<Long> longs = addMemberDTO.getDepartmentIds();
            for (Long lg : longs) {
                MemberDepartmentMappingDO memberDepartmentMappingDO = new MemberDepartmentMappingDO();
                memberDepartmentMappingDO.setMemberId(memberDO.getId());
                memberDepartmentMappingDO.setDepartmentId(lg);
                memberDepartmentMappingMapper.insert(memberDepartmentMappingDO);
            }
        }

        return ConstantUtils.SET_SUCCESS;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public UserRoleVO login(VerifyCodeDTO verifyCodeDTO) {
        UserRoleVO userRoleVO = new UserRoleVO();
        MemberDO memberDO = this.baseMapper.selectOne(new QueryWrapper<MemberDO>()
                .lambda()
                .eq(MemberDO::getTelephone, verifyCodeDTO.getTelephone()));
        if (memberDO == null) {
            throw new HttpException(10010);
        }

        if ("冻结".equals(memberDO.getStatus())) {
            throw new HttpException(10013);
        }

        //是否登陆过   1:是 0:否
        if (0 == memberDO.getFirstLogin()) {
            memberDO.setFirstLogin(1);
            this.baseMapper.updateById(memberDO);
        }
        BeanUtils.copyProperties(memberDO, userRoleVO);

        SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
                .lambda()
                .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
                .eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
                .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
        if (smsCodeDO == null) {
            throw new HttpException(70010);
        }
        return userRoleVO;
    }

    public UserRoleVO passwordLogin(PasswordLoginDTO passwordLoginDTO) {
        UserRoleVO userRoleVO = this.baseMapper.passwordLogin(passwordLoginDTO);
        if (userRoleVO == null) {
            throw new HttpException(10004);
        }
        if ("冻结".equals(userRoleVO.getStatus())) {
            throw new HttpException(10014);
        }
        if (0 == userRoleVO.getFirstLogin()) {
            throw new HttpException(10015);
        }
        return userRoleVO;
    }

    public String updatePassword(MemberDO memberDO) {
        this.baseMapper.updateById(memberDO);
        return ConstantUtils.SET_SUCCESS;
    }

    public MemberStudyPageVO studyPage(MemberDO memberDO) {

        MemberStudyPageVO memberStudyPageVO = new MemberStudyPageVO();

        List<StudyPageVO> studyPageVOS = this.baseMapper.studyPage(memberDO);

        for (StudyPageVO studyPageVO : studyPageVOS) {

            //查看课程下有几节课
            List<VodDictDO> vodDictDOS = courseContentMapper.getCourseVods(studyPageVO.getId());
            studyPageVO.setTotalVods(vodDictDOS.size());

            int i = 0;

            //该成员完成了几个视频
            for (VodDictDO vodDictDO : vodDictDOS) {
                List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                        .lambda()
                        .eq(VodPlayHistoryDO::getMemberId, memberDO.getId())
                        .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
                        .orderByDesc(VodPlayHistoryDO::getPlayRecord));

                if (vodPlayHistoryDOS.size() > 0) {
                    if (vodPlayHistoryDOS.get(0).getPlayRecord() > vodDictDO.getVodLength() * 0.8) {
                        i++;
                    }
                }
            }
            studyPageVO.setDoneVods(i);

            //该班级课程下有多少人
            List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
                    .lambda()
                    .eq(ClassMemberMappingDO::getClassId, studyPageVO.getClassId()));
            studyPageVO.setTotalMember(classMemberMappingDOS.size());

            //多少人完成
            //int completedCnt = 0;
            //for (ClassMemberMappingDO cmmd : classMemberMappingDOS) {
            //
            //    Boolean flag = true;
            //
            //    for (VodDictDO vodDictDO : vodDictDOS) {
            //        List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
            //                .lambda()
            //                .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
            //                .eq(VodPlayHistoryDO::getMemberId, cmmd.getMemberId())
            //                .orderByDesc(VodPlayHistoryDO::getPlayRecord));
            //        if (vodPlayHistoryDOS.size() > 0) {
            //            if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength()) {
            //                flag = false;
            //                //break;
            //            }
            //        } else {
            //            flag = false;
            //        }
            //    }
            //    if (flag) {
            //        completedCnt++;
            //    }
            //}
            //studyPageVO.setDoneMember(completedCnt);
        }

        memberStudyPageVO.setStudyPageVOS(studyPageVOS);

        List<DepartmentDictDO> departmentDictDOS = this.baseMapper.getDepartments(memberDO.getId());

        if (departmentDictDOS.size() > 0) {
            CompanyDictDO companyDictDO = companyDictMapper.selectById(departmentDictDOS.get(0).getId());
            if (null != companyDictDO) {
                BeanUtils.copyProperties(companyDictDO, memberStudyPageVO);
            }
        }
        return memberStudyPageVO;
    }

    public ContentVodNewVO contentVod(ContentMemberDTO contentVodDTO) {

        ContentVodNewVO contentVodNewVO = new ContentVodNewVO();

        List<ContentVodVO> contentVodVOS = new ArrayList<>();
        List<CourseContentDO> courseContentDOS = courseContentMapper.selectList(new QueryWrapper<CourseContentDO>()
                .lambda()
                .eq(CourseContentDO::getCourseId, contentVodDTO.getCourseId())
                .orderByAsc(CourseContentDO::getOrderNo));

        for (CourseContentDO courseContentDO : courseContentDOS) {
            ContentVodVO contentVodVO = new ContentVodVO();
            contentVodVO.setContent(courseContentDO.getContent());

            List<MemberVodVO> memberVodVOS = new ArrayList<>();

            //目录下的视频
            List<VodDictDO> vodDictDOS = vodDictMapper.selectList(new QueryWrapper<VodDictDO>()
                    .lambda()
                    .eq(VodDictDO::getContentId, courseContentDO.getId()));
            for (VodDictDO vodDictDO : vodDictDOS) {
                MemberVodVO memberVodVO = new MemberVodVO();
                List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                        .lambda()
                        .eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId())
                        .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
                        .orderByDesc(VodPlayHistoryDO::getPlayRecord));

                memberVodVO.setStatus(false);
                if (vodPlayHistoryDOS.size() > 0) {
                    int length = MathUtil.intDivCeil(100 * vodPlayHistoryDOS.get(0).getPlayRecord(), vodDictDO.getVodLength());
                    if (length >= 100) {
                        memberVodVO.setPercent(100);
                    } else {
                        memberVodVO.setPercent(length);
                    }
                    if (memberVodVO.getPercent() >= 80) {
                        memberVodVO.setStatus(true);
                    }
                } else {
                    memberVodVO.setPercent(0);
                }
                List<VodPlayHistoryDO> vodPlayHistoryDOS1 = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                        .lambda()
                        .eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId())
                        .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
                        .orderByDesc(VodPlayHistoryDO::getCreateDate));
                if (vodPlayHistoryDOS1.size() > 0) {
                    memberVodVO.setPlayRecord(vodPlayHistoryDOS1.get(0).getPlayRecord());
                }
                memberVodVO.setId(vodDictDO.getId());
                memberVodVO.setVodUrl(vodDictDO.getVodUrl());
                memberVodVO.setTeacherName(vodDictDO.getTeacherName());
                memberVodVO.setVodLength(vodDictDO.getVodLength());
                memberVodVO.setVodName(vodDictDO.getVodName());
                memberVodVOS.add(memberVodVO);
            }
            contentVodVO.setMemberVodVOS(memberVodVOS);
            contentVodVOS.add(contentVodVO);
        }

        contentVodNewVO.setContentVodVOS(contentVodVOS);

        List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                .lambda()
                .eq(VodPlayHistoryDO::getClassId, contentVodDTO.getClassId())
                .eq(VodPlayHistoryDO::getMemberId, contentVodDTO.getMemberId())
                .orderByDesc(VodPlayHistoryDO::getCreateDate));
        if (vodPlayHistoryDOS.size() > 0) {
            VodPlayHistoryDO vodPlayHistoryDO = vodPlayHistoryDOS.get(0);
            VodDictDO vodDictDO = vodDictMapper.selectById(vodPlayHistoryDO.getVodId());
            if (null != vodDictDO) {
                BeanUtils.copyProperties(vodDictDO, contentVodNewVO);
                contentVodNewVO.setPlayRecord(vodPlayHistoryDO.getPlayRecord());
            }
        }
        return contentVodNewVO;
    }

    public List<ContentFilesVO> contentFiles(ContentMemberDTO contentMemberDTO) {

        List<ContentFilesVO> contentFilesVOS = new ArrayList<>();

        List<CourseContentDO> courseContentDOS = courseContentMapper.selectList(new QueryWrapper<CourseContentDO>()
                .lambda()
                .eq(CourseContentDO::getCourseId, contentMemberDTO.getCourseId())
                .orderByAsc(CourseContentDO::getOrderNo));

        for (CourseContentDO courseContentDO : courseContentDOS) {

            ContentFilesVO contentFilesVO = new ContentFilesVO();
            contentFilesVO.setContent(courseContentDO.getContent());

            List<FileDictDO> fileDictDOS = fileDictMapper.selectList(new QueryWrapper<FileDictDO>()
                    .lambda()
                    .eq(FileDictDO::getContentId, courseContentDO.getId()));
            contentFilesVO.setFileDictDOS(fileDictDOS);

            contentFilesVOS.add(contentFilesVO);
        }

        return contentFilesVOS;
    }

    public IPage studyHistory(StudyHistoryDTO studyHistoryDTO) {
        Page pager = new Page(studyHistoryDTO.getPageNum(), studyHistoryDTO.getPageSize());

        IPage iPage = vodPlayHistoryMapper.studyHistory(pager, studyHistoryDTO.getMemberId());

        List<StudyHistoryVO> studyHistoryVOS = iPage.getRecords();

        for (StudyHistoryVO studyHistoryVO : studyHistoryVOS) {
            if (studyHistoryVO.getPercent() >= 80) {
                studyHistoryVO.setStatus(true);
            } else {
                studyHistoryVO.setStatus(false);
            }
        }
        iPage.setRecords(studyHistoryVOS);

        return iPage;
    }

    public List<QueryPapersVO> getCourseTest(ContentMemberDTO contentMemberDTO) {

        //查看该班级下的测试卷子(有效卷子)
        ClassDictDO classDictDO = classDictMapper.selectById(contentMemberDTO.getClassId());
        List<QueryPapersVO> queryPapersVOS = paperDictMapper.queryPapers(contentMemberDTO.getCourseId(), null, 1);
        for (QueryPapersVO queryPapersVO : queryPapersVOS) {
            //多少人已完成
            Integer cnt = paperDictMapper.completeCount(queryPapersVO.getId());
            queryPapersVO.setCompleteCnt(cnt);
            //自己成绩
            List<ExerciseDoneResultDO> exerciseDoneResultDOS = exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
                    .lambda()
                    .eq(ExerciseDoneResultDO::getMemberId, contentMemberDTO.getMemberId())
                    .eq(ExerciseDoneResultDO::getPaperId, queryPapersVO.getId())
                    .orderByDesc(ExerciseDoneResultDO::getScore));

            if (exerciseDoneResultDOS.size() > 0) {
                queryPapersVO.setRightCounts(exerciseDoneResultDOS.get(0).getRightCounts());
                queryPapersVO.setTotalCount(exerciseDoneResultDOS.get(0).getTotalCounts());
                queryPapersVO.setResult(exerciseDoneResultDOS.get(0).getResult());
            } else {
                queryPapersVO.setResult("待完成");
            }

            //截止时间
            queryPapersVO.setEndDate(classDictDO.getEndDate());
        }
        return queryPapersVOS;
    }

    public List<ExerciseDoneResultDO> getPaperDoneDetail(ExerciseDoneResultDO exerciseDoneResultDO) {
        return exerciseDoneResultMapper.selectList(new QueryWrapper<ExerciseDoneResultDO>()
                .lambda()
                .eq(ExerciseDoneResultDO::getMemberId, exerciseDoneResultDO.getMemberId())
                .eq(ExerciseDoneResultDO::getPaperId, exerciseDoneResultDO.getPaperId()));
    }

    public GetStudyInfoVO getStudyInfo(MemberDO memberDO) {

        GetStudyInfoVO getStudyInfoVO = new GetStudyInfoVO();

        MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId());

        //第几天
        long diff = Duration.between(memberDO1.getCreateDate(), LocalDateTime.now()).toDays();
        getStudyInfoVO.setDiff(diff);

        //已学课程
        List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
                .lambda()
                .eq(ClassMemberMappingDO::getMemberId, memberDO.getId()));
        /**
         * 遍历课程,里面的视频都看过80% 则表示已学完
         */
        int i = 0; //已学课程
        for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
            List<VodDictDO> vodDictDOS = classDictMapper.getClassVods(classMemberMappingDO.getClassId());
            for (VodDictDO vodDictDO : vodDictDOS) {
                List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                        .lambda()
                        .eq(VodPlayHistoryDO::getMemberId, memberDO.getId())
                        .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
                        .orderByDesc(VodPlayHistoryDO::getPlayRecord));
                if (vodPlayHistoryDOS.size() > 0) {
                    if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength() * 0.8) {
                        break;
                    }
                }
            }
            i++;
        }
        getStudyInfoVO.setStudyCourse(i);

        //累计学习时长
        int studyLength = 0;
        List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
                .lambda()
                .eq(VodPlayHistoryDO::getMemberId, memberDO.getId()));

        for (VodPlayHistoryDO vodPlayHistoryDO : vodPlayHistoryDOS) {
            studyLength += vodPlayHistoryDO.getPlayLength();
        }
        getStudyInfoVO.setStudyLength(studyLength);

        return getStudyInfoVO;
    }

    public ExerciseDoneResultDO getDoneResult(ExerciseDoneResultDO exerciseDoneResultDO) {
        return exerciseDoneResultMapper.selectById(exerciseDoneResultDO.getId());
    }

    public String checkTimes(ExerciseDoneResultDO exerciseDoneResultDO) {


        ClassHourDictDO classHourDictDO = classHourDictMapper.getClassHourDictInfo(exerciseDoneResultDO.getClassId());

        if (null != classHourDictDO) {
            Integer status = classHourDictDO.getRepeatStatus();
            if (1 == status) {
                int cnt = classHourDictDO.getRepeatTime();

                //查看这个人这个卷子做了几次
                Integer count = exerciseDoneResultMapper.selectCount(new QueryWrapper<ExerciseDoneResultDO>()
                        .lambda()
                        .eq(ExerciseDoneResultDO::getMemberId, exerciseDoneResultDO.getMemberId())
                        .eq(ExerciseDoneResultDO::getPaperId, exerciseDoneResultDO.getPaperId()));

                if (cnt <= count) {
                    throw new HttpException(60001);
                }
            }
        }
        return ConstantUtils.CHECK_STATUS;
    }

    public void replace(){

        List<MemberDO> memberDOS = this.baseMapper.selectList(null);

        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
        //拼音小写
        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        //不带声调
        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);

        try {
            for (MemberDO memberDO : memberDOS) {

                String accountName = PinyinHelper.toHanYuPinyinString(memberDO.getUserName(), format, "", true);
                memberDO.setAccountName(accountName);
                this.baseMapper.updateById(memberDO);
            }
        }catch (Exception e){

        }
    }


}