Blame view

CollegesDictServiceImpl.java 25.6 KB
涂亚平 committed
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 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
package com.zhongzhi.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongzhi.common.constant.Platform;
import com.zhongzhi.common.constant.ProjectSchedule;
import com.zhongzhi.common.constant.ProjectStatus;
import com.zhongzhi.common.exception.HttpException;
import com.zhongzhi.common.utils.*;
import com.zhongzhi.dao.*;
import com.zhongzhi.dto.college.*;
import com.zhongzhi.dto.projectJudge.ImportJudge;
import com.zhongzhi.model.*;
import com.zhongzhi.service.CollegesDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongzhi.service.ProjectScheduleRecordService;
import com.zhongzhi.service.ProjectService;
import com.zhongzhi.vo.ExcelFieldVO;
import com.zhongzhi.vo.college.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;

/**
 * <p>
 * 院校字典表 服务实现类
 * </p>
 *
 * @author DengMin
 * @since 2021-04-28
 */
@Service
public class CollegesDictServiceImpl extends ServiceImpl<CollegesDictDAO, CollegesDictDO> implements CollegesDictService {

    @Autowired
    private ProjectService projectService;

    @Autowired
    private MatchCollegePdfMapper matchCollegePdfMapper;

    @Autowired
    private MatchDictDAO matchDictDAO;

    @Autowired
    private FinalMatchMemberDAO finalMatchMemberDAO;

    @Autowired
    private StudentDAO studentDAO;

    @Autowired
    private ProjectDAO projectDAO;

    @Autowired
    private ProjectMemberDAO projectMemberDAO;

    @Autowired
    private CollegesDictDAO collegesDictDAO;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public CollegesVO login(LoginDTO loginDTO) {
        CollegesVO collegesVO = new CollegesVO();
        CollegesDictDO collegesDict = this.baseMapper.selectOne(new QueryWrapper<CollegesDictDO>().lambda()
                .eq(CollegesDictDO::getAccount, loginDTO.getAccount()));
        if (collegesDict == null) {
            throw new HttpException(10060);
        }

        if (!collegesDict.getPassword().equals(loginDTO.getPassword())) {
            throw new HttpException(10061);
        }

        if (collegesDict.getLoginStatus() == 0) {
            throw new HttpException(10067);
        }

        BeanUtils.copyProperties(collegesDict, collegesVO);
        if (collegesDict.getLoginTime() != null) {
            collegesVO.setIsLogin(1);
        } else {
            collegesVO.setIsLogin(0);
        }

        String token = JwtUtil.generateToken(collegesDict.getId(), Platform.school);
        collegesVO.setToken(token);
        return collegesVO;
    }

    @Override
    public IPage getCollegesPage(CollegesPageDTO collegesPageDTO) {
        Page page = new Page(collegesPageDTO.getPageNo(), collegesPageDTO.getPageSize());
        IPage<CollegePageVO> iPage = this.baseMapper.listPage(page, collegesPageDTO.getName());
        return iPage;
    }

    @Override
    public void createColleges(CollegesDictDO collegesDictDO) {
        CollegesDictDO collegesDict = this.baseMapper.selectOne(new QueryWrapper<CollegesDictDO>().lambda()
                .eq(CollegesDictDO::getAccount, collegesDictDO.getAccount()));
        if (collegesDict != null) {
            throw new HttpException(10062);
        }

        if (collegesDictDO.getName().equals(collegesDict.getName())) {
            throw new HttpException(10063);
        }

        if (collegesDictDO.getCode().equals(collegesDict.getCode())) {
            throw new HttpException(10064);
        }

        collegesDictDO.setAccount("shzc" + collegesDictDO.getCode());
        collegesDictDO.setPassword(RandomUtil.randomPass(8));
        this.baseMapper.insert(collegesDictDO);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Map<String, Object> importColleges(MultipartFile file) {
        Map<String, Object> map = new HashMap<>();
        if (file == null) {
            throw new HttpException(10066);
        }

        List<CollegesDOT> list = ExcelUtil.readExcel(CollegesDOT.class, file);
        int success = 0;
        int fail = 0;
        List<CollegesDOT> error = new ArrayList<>();
        if (list.size() > 0) {
            for (CollegesDOT collegesDOT : list) {
                CollegesDictDO collegesDictDO = new CollegesDictDO();
                BeanUtils.copyProperties(collegesDOT, collegesDictDO);

                CollegesDictDO collegesDict = this.baseMapper.selectOne(new QueryWrapper<CollegesDictDO>()
                        .lambda()
                        .eq(CollegesDictDO::getAccount, collegesDictDO.getAccount()));
                if (collegesDict != null) {
                    fail++;
                    collegesDOT.setFailReason("院校账户已存在");
                    continue;

                }

                if (collegesDictDO.getName().equals(collegesDict.getName())) {
                    fail++;
                    collegesDOT.setFailReason("院校名称重复");
                    continue;
                }

                if (collegesDictDO.getCode().equals(collegesDict.getCode())) {
                    fail++;
                    collegesDOT.setFailReason("院校代码重复");
                    continue;
                }

                if (fail > 0) {
                    error.add(collegesDOT);
                }

                collegesDictDO.setAccount("shzc" + collegesDictDO.getCode());
                collegesDictDO.setPassword(RandomUtil.randomPass(8));
                this.baseMapper.insert(collegesDictDO);
                success++;
            }
        }
        map.put("success", success);
        map.put("fail", fail);
        map.put("errorData", error);
        return map;
    }

    @Override
    public void downloadErrorData(DownloadErrorDataDTO downloadErrorDataDTO) {
        List<ExcelFieldVO> list = ExcelUtil.getField(CollegesDOT.class);
        List<Map> data = new ArrayList<>();
        if (downloadErrorDataDTO.getErrorData().size() > 0) {
            for (CollegesDOT errorDatum : downloadErrorDataDTO.getErrorData()) {
                if (errorDatum != null) {
                    data.add(JSON.parseObject(JSON.toJSONString(errorDatum), Map.class));
                }
            }
        }
        ExcelUtil.writeExcel(list, data);
    }

    @Override
    public IPage getAwardedList(AwardedListDTO awardedListDTO) {
        IPage<AwardedListVO> iPage = this.baseMapper.getAwardedList(new Page<>(awardedListDTO.getPageNo(), awardedListDTO.getPageSize()),
                awardedListDTO.getName());
        for (AwardedListVO record : iPage.getRecords()) {
            List<ProjectDO> list = projectService.getList(awardedListDTO.getMatchId(), record.getName(), awardedListDTO.getProjectGroup());
            if (list != null && list.size() > 0) {
                Integer schoolCompetitionNum = 0;
                Integer rematchNum = 0;
                Integer finalNum = 0;
                Integer winningPrizeNum = 0;
                Integer bronzeAwardNum = 0;
                Integer silverAwardNum = 0;
                Integer goldAwardNum = 0;
                for (ProjectDO projectDO : list) {
                    /**
                     * 奖项
                     */
                    if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_BRONZE_AWARD)) {
                        bronzeAwardNum++;
                    } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_SILVER_AWARD)) {
                        silverAwardNum++;
                    } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_FINALS_GOLD_AWARD)) {
                        goldAwardNum++;
                    } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_WINNING_AWARD)) {
                        winningPrizeNum++;
                    }

                    /**
                     * 项目进度
                     */
                    if (projectDO.getProjectSchedule().equals(ProjectSchedule.SCHOOL_REVIEW)) {
                        schoolCompetitionNum++;
                    } else if (projectDO.getProjectSchedule().equals(ProjectSchedule.SEMI_FINAL_REVIEW)) {
                        rematchNum++;
                    } else if (projectDO.getProjectSchedule().equals(ProjectSchedule.FINAL_REVIEW)) {
                        finalNum++;
                    }
                }
                record.setSchoolCompetitionNum(schoolCompetitionNum + rematchNum + finalNum);
                record.setRematchNum(rematchNum);
                record.setFinalNum(finalNum);
                record.setBronzeAwardNum(bronzeAwardNum);
                record.setSilverAwardNum(silverAwardNum);
                record.setGoldAwardNum(goldAwardNum);
                record.setWinningPrizeNum(winningPrizeNum);

                //盖章pdf
                MatchCollegePdfDO matchCollegePdfDO = matchCollegePdfMapper.selectOne(new QueryWrapper<MatchCollegePdfDO>()
                        .lambda()
                        .eq(MatchCollegePdfDO::getMatchId, awardedListDTO.getMatchId())
                        .eq(MatchCollegePdfDO::getCollegeId, record.getId()));
                if (null != matchCollegePdfDO) {
                    record.setAttachment(matchCollegePdfDO.getAttachment());
                    record.setFileName(matchCollegePdfDO.getFileName());
                }
            }
        }
        return iPage;
    }

    @Override
    public void exportAwardedList(AwardedListDTO awardedListDTO) {
        List<Map> data = new ArrayList<>();
        List<AwardedListVO> listAll = this.baseMapper.getAwardedListAll();
        for (AwardedListVO awardedListVO : listAll) {

            List<ProjectDO> list = projectService.getList(awardedListDTO.getMatchId(), awardedListVO.getName(), awardedListDTO.getProjectGroup());
            Integer schoolCompetitionNum = 0;
            Integer rematchNum = 0;
            Integer finalNum = 0;
            Integer winningPrizeNum = 0;
            Integer bronzeAwardNum = 0;
            Integer silverAwardNum = 0;
            Integer goldAwardNum = 0;
            for (ProjectDO projectDO : list) {
                /**
                 * 奖项
                 */
                if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_BRONZE_AWARD)) {
                    bronzeAwardNum++;
                } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_SILVER_AWARD)) {
                    silverAwardNum++;
                } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_FINALS_GOLD_AWARD)) {
                    goldAwardNum++;
                } else if (projectDO.getProjectStatus().equals(ProjectStatus.REMATCH_WINNING_AWARD)) {
                    winningPrizeNum++;
                }

                /**
                 * 项目进度
                 */
                if (projectDO.getProjectSchedule().equals(ProjectSchedule.SCHOOL_REVIEW)) {
                    schoolCompetitionNum++;
                } else if (projectDO.getProjectSchedule().equals(ProjectSchedule.SEMI_FINAL_REVIEW)) {
                    rematchNum++;
                } else if (projectDO.getProjectSchedule().equals(ProjectSchedule.FINAL_REVIEW)) {
                    finalNum++;
                }
            }
            awardedListVO.setSchoolCompetitionNum(schoolCompetitionNum + rematchNum + finalNum);
            awardedListVO.setRematchNum(rematchNum);
            awardedListVO.setFinalNum(finalNum);
            awardedListVO.setBronzeAwardNum(bronzeAwardNum);
            awardedListVO.setSilverAwardNum(silverAwardNum);
            awardedListVO.setGoldAwardNum(goldAwardNum);
            awardedListVO.setWinningPrizeNum(winningPrizeNum);
            data.add(JSON.parseObject(JSON.toJSONString(awardedListVO), Map.class));
        }
        ExcelUtil.writeExcel(ExcelUtil.getField(AwardedListVO.class), data);
    }

    @Override
    public void exportCollege() {
        List<ExcelFieldVO> field = ExcelUtil.getField(ExportCollegeDTO.class);
        List<Map> data = new ArrayList<>();
        List<CollegesDictDO> list = this.baseMapper.selectList(new QueryWrapper<>());
        if (list != null && list.size() > 0) {
            for (CollegesDictDO collegesDictDO : list) {
                data.add(JSON.parseObject(JSON.toJSONString(collegesDictDO), Map.class));
            }
        }
        ExcelUtil.writeExcel(field, data);
    }

    @Override
    public void updatePwd(UpdatePwdDTO updatePwdDTO) {
        CollegesDictDO collegesDict = (CollegesDictDO) Localstorage.getUser();
        if (collegesDict == null) {
            throw new HttpException(10060);
        }

        CollegesDictDO collegesDictDO = new CollegesDictDO();
        collegesDictDO.setLoginTime(DateFormatUtil.dateToLocalDateTime(new Date()));
        collegesDictDO.setId(collegesDict.getId());
        collegesDictDO.setPassword(updatePwdDTO.getPassword());
        this.baseMapper.updateById(collegesDictDO);
    }

    public List<ProjectDO> projects(ProjectDO projectDO) {
        CollegesDictDO collegesDict = (CollegesDictDO) Localstorage.getUser();

        //除去已经报名了的项目
        List<ProjectDO> list = projectDAO.projects(projectDO.getMatchId(), collegesDict.getId(), collegesDict.getName());
        return list;
    }

    public ProjectMemberDO projectLeader(ProjectMemberDO projectMemberDO) {
        ProjectMemberDO projectMemberDO1 = projectMemberDAO.selectOne(new QueryWrapper<ProjectMemberDO>()
                .lambda()
                .eq(ProjectMemberDO::getType, "团队负责人")
                .eq(ProjectMemberDO::getProjectId, projectMemberDO.getProjectId()));

        ProjectDO projectDO = projectDAO.selectById(projectMemberDO.getProjectId());
        StudentDO studentDO = studentDAO.selectById(projectDO.getProposerId());
        projectMemberDO1.setIdCard(studentDO.getIdCard());
        return projectMemberDO1;
    }

    public List<ProjectMemberDO> projectMembers(ProjectMemberDO projectMemberDO) {
        List<ProjectMemberDO> projectMemberDOS = projectMemberDAO.projectMembers(projectMemberDO.getProjectId());
        return projectMemberDOS;
    }

    public void addProjectMember(AddProjectMemberDTO addProjectMemberDTO) throws Exception {

        CollegesDictDO collegesDict = (CollegesDictDO) Localstorage.getUser();

        ProjectDO projectDO = projectDAO.selectById(addProjectMemberDTO.getProjectId());

        MatchDictDO matchDictDO = matchDictDAO.selectById(addProjectMemberDTO.getMatchId());

        if (StringUtils.isEmpty(matchDictDO.getRegistrationDeadline()) || StringUtils.isEmpty(matchDictDO.getRegistrationStart())){
            throw new HttpException(10031);
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (new Date().before(simpleDateFormat.parse(matchDictDO.getRegistrationStart())) || new Date().after(simpleDateFormat.parse(matchDictDO.getRegistrationDeadline()))) {
            throw new HttpException(10031);
        }

        List<Long> studentIds = addProjectMemberDTO.getStudentIds();
        for (Long studentId : studentIds) {
            FinalMatchMemberDO finalMatchMemberDO = new FinalMatchMemberDO();
            finalMatchMemberDO.setCollegeId(collegesDict.getId());
            finalMatchMemberDO.setMemberId(studentId);
            finalMatchMemberDO.setProjectId(addProjectMemberDTO.getProjectId());
            StudentDO studentDO = studentDAO.selectById(projectDO.getProposerId());
            finalMatchMemberDO.setIdCard(studentDO.getIdCard());
            ProjectMemberDO projectMemberDO = projectMemberDAO.selectById(studentId);
            finalMatchMemberDO.setIdCard(projectMemberDO.getIdCard());
            finalMatchMemberDO.setMatchId(addProjectMemberDTO.getMatchId());
            finalMatchMemberDO.setTelephone(projectMemberDO.getTelephone());
            finalMatchMemberDO.setUserName(projectMemberDO.getName());
            if ("团队负责人".equals(projectMemberDO.getType())) {
                finalMatchMemberDO.setMemberType("参赛人员(负责人)");
                finalMatchMemberDO.setIdCard(studentDO.getIdCard());
                finalMatchMemberDO.setOrderNo(0);
            } else {
                finalMatchMemberDO.setMemberType("参赛人员");
                finalMatchMemberDO.setOrderNo(1);
            }
            finalMatchMemberDO.setUpdateTime(LocalDateTime.now());
            finalMatchMemberDAO.insert(finalMatchMemberDO);
        }
    }

    public void removeProject(AddProjectMemberDTO addProjectMemberDTO) throws Exception {

        MatchDictDO matchDictDO = matchDictDAO.selectById(addProjectMemberDTO.getMatchId());

        if (StringUtils.isEmpty(matchDictDO.getRegistrationDeadline()) || StringUtils.isEmpty(matchDictDO.getRegistrationStart())){
            throw new HttpException(10031);
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (new Date().before(simpleDateFormat.parse(matchDictDO.getRegistrationStart())) || new Date().after(simpleDateFormat.parse(matchDictDO.getRegistrationDeadline()))) {
            throw new HttpException(10031);
        }

        finalMatchMemberDAO.delete(new QueryWrapper<FinalMatchMemberDO>()
                .lambda()
                .eq(FinalMatchMemberDO::getProjectId, addProjectMemberDTO.getProjectId()));
    }

    public void addObservations(FinalMatchMemberDO finalMatchMemberDO) throws Exception {

        CollegesDictDO collegesDict = (CollegesDictDO) Localstorage.getUser();

        MatchDictDO matchDictDO = matchDictDAO.selectById(finalMatchMemberDO.getMatchId());

        if (null == matchDictDO.getRegistrationDeadline() || null == matchDictDO.getRegistrationStart()){
            throw new HttpException(10031);
        }

        if (null != matchDictDO.getRegistrationDeadline()) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            if (new Date().before(simpleDateFormat.parse(matchDictDO.getRegistrationStart())) || new Date().after(simpleDateFormat.parse(matchDictDO.getRegistrationDeadline()))) {
                throw new HttpException(10031);
            }
        }

        if ("观摩人员".equals(finalMatchMemberDO.getMemberType())) {

            //当前有几个观摩人员
            int count = finalMatchMemberDAO.selectCount(new QueryWrapper<FinalMatchMemberDO>()
                    .lambda()
                    .eq(FinalMatchMemberDO::getCollegeId, collegesDict.getId())
                    .eq(FinalMatchMemberDO::getMemberType, "观摩人员"));

            if (count >=2) {
                throw new HttpException(10029);
            }
            finalMatchMemberDO.setOrderNo(4);
            finalMatchMemberDO.setCollegeId(collegesDict.getId());
            finalMatchMemberDO.setUpdateTime(LocalDateTime.now());
            finalMatchMemberDAO.insert(finalMatchMemberDO);
        }
        if ("学校领队".equals(finalMatchMemberDO.getMemberType())) {
            //当前有几个学校领队
            int count = finalMatchMemberDAO.selectCount(new QueryWrapper<FinalMatchMemberDO>()
                    .lambda()
                    .eq(FinalMatchMemberDO::getCollegeId, collegesDict.getId())
                    .eq(FinalMatchMemberDO::getMemberType, "学校领队"));

            if (count > 0) {
                throw new HttpException(10019);
            }
            finalMatchMemberDO.setCollegeId(collegesDict.getId());
            finalMatchMemberDO.setOrderNo(3);
            finalMatchMemberDO.setUpdateTime(LocalDateTime.now());
            finalMatchMemberDAO.insert(finalMatchMemberDO);
        }

        if ("车".equals(finalMatchMemberDO.getMemberType())){
            finalMatchMemberDO.setCollegeId(collegesDict.getId());
            finalMatchMemberDO.setOrderNo(5);
            finalMatchMemberDO.setUpdateTime(LocalDateTime.now());
            finalMatchMemberDAO.insert(finalMatchMemberDO);
        }
    }

    public void updateObservations(FinalMatchMemberDO finalMatchMemberDO) throws Exception {

        MatchDictDO matchDictDO = matchDictDAO.selectById(finalMatchMemberDO.getMatchId());
        if (StringUtils.isEmpty(matchDictDO.getRegistrationDeadline()) || StringUtils.isEmpty(matchDictDO.getRegistrationStart())){
            throw new HttpException(10031);
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (new Date().before(simpleDateFormat.parse(matchDictDO.getRegistrationStart())) || new Date().after(simpleDateFormat.parse(matchDictDO.getRegistrationDeadline()))) {
            throw new HttpException(10031);
        }

        finalMatchMemberDAO.updateById(finalMatchMemberDO);
    }

    public void deleteObservations(FinalMatchMemberDO finalMatchMemberDO) throws Exception {

        MatchDictDO matchDictDO = matchDictDAO.selectById(finalMatchMemberDO.getMatchId());

        if (StringUtils.isEmpty(matchDictDO.getRegistrationDeadline()) || StringUtils.isEmpty(matchDictDO.getRegistrationStart())){
            throw new HttpException(10031);
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (new Date().before(simpleDateFormat.parse(matchDictDO.getRegistrationStart()))||new Date().after(simpleDateFormat.parse(matchDictDO.getRegistrationDeadline()))) {
            throw new HttpException(10031);
        }

        finalMatchMemberDAO.deleteById(finalMatchMemberDO.getId());
    }

    public List<RegisterMembersVO> registerMembers(RegisterMembersDTO registerMembersDTO) {
        CollegesDictDO collegesDict = collegesDictDAO.selectById(registerMembersDTO.getCollegeId());
        return finalMatchMemberDAO.registerMembers(collegesDict.getId(),registerMembersDTO.getMatchId());
    }

    public List<RegisterMembersVO> otherMembers(RegisterMembersDTO registerMembersDTO) {
        CollegesDictDO collegesDict = collegesDictDAO.selectById(registerMembersDTO.getCollegeId());
        return finalMatchMemberDAO.otherMembers(collegesDict.getId(),registerMembersDTO.getMatchId());
    }

    public List<RegisterMembersVO> cars(RegisterMembersDTO registerMembersDTO){
        CollegesDictDO collegesDict = collegesDictDAO.selectById(registerMembersDTO.getCollegeId());
        return finalMatchMemberDAO.cars(collegesDict.getId(),registerMembersDTO.getMatchId());
    }

    public DetailVO detail(RegisterMembersDTO registerMembersDTO) {
        CollegesDictDO collegesDict = collegesDictDAO.selectById(registerMembersDTO.getId());
        DetailVO detailVO = new DetailVO();

        MatchDictDO matchDictDO = matchDictDAO.selectById(registerMembersDTO.getMatchId());
        detailVO.setRegistrationDeadline(matchDictDO.getRegistrationDeadline());

        //最近一次更新时间
        String latestUpdateTime = finalMatchMemberDAO.latestUpdateTime(collegesDict.getId());
        detailVO.setLatestUpdateTime(latestUpdateTime);

        return detailVO;
    }

    public List<SchoolsVO> schools(RegisterMembersDTO registerMembersDTO) {
        return finalMatchMemberDAO.schools(registerMembersDTO.getMatchId(), registerMembersDTO.getName());
    }

    public  void exportList(FinalMatchMemberDO finalMatchMemberDO){

        MatchDictDO matchDictDO1 = matchDictDAO.selectById(finalMatchMemberDO.getId());

        //导出所有名单
        List<ExportListVO> exportListVOS = finalMatchMemberDAO.exportList(matchDictDO1.getId(),finalMatchMemberDO.getCollegeId());

        List<ExcelFieldVO> field = ExcelUtil.getField(ExportListVO.class);
        List<Map> data = new ArrayList<>();
        if (exportListVOS != null && exportListVOS.size() > 0) {
            for (ExportListVO exportListVO : exportListVOS) {
                data.add(JSON.parseObject(JSON.toJSONString(exportListVO), Map.class));
            }
        }
        ExcelUtil.writeExcel(field, data);
    }

    @Override
    public void addContact(CollegesDictDO collegesDictDO) {
        CollegesDictDO collegesDict = (CollegesDictDO) Localstorage.getUser();
        if (collegesDict == null) {
            throw new HttpException(10060);
        }

        collegesDictDO.setId(collegesDict.getId());
        this.baseMapper.updateById(collegesDictDO);
    }

    @Override
    public void updateAllLoginStatus(LoginStatusDTO loginStatusDTO) {
        List<CollegesDictDO> list = this.baseMapper.selectList(new QueryWrapper());
        if (list != null && list.size() > 0) {
            for (CollegesDictDO collegesDictDO : list) {
                CollegesDictDO collegesDict = new CollegesDictDO();
                collegesDict.setId(collegesDictDO.getId());
                collegesDict.setLoginStatus(loginStatusDTO.getLoginStatus());
                this.baseMapper.updateById(collegesDict);
            }
        }
    }

    @Override
    public void batchUpdateLoginStatus(LoginStatusDTO loginStatusDTO) {
        if (loginStatusDTO.getIds().length > 0) {
            for (Long id : loginStatusDTO.getIds()) {
                CollegesDictDO collegesDict = new CollegesDictDO();
                collegesDict.setId(id);
                collegesDict.setLoginStatus(loginStatusDTO.getLoginStatus());
                this.baseMapper.updateById(collegesDict);
            }
        }
    }

    @Override
    public void updateLoginStatus(LoginStatusDTO loginStatusDTO) {
        CollegesDictDO collegesDict = new CollegesDictDO();
        collegesDict.setId(loginStatusDTO.getId());
        collegesDict.setLoginStatus(loginStatusDTO.getLoginStatus());
        this.baseMapper.updateById(collegesDict);
    }
}