fix before contest submission rejudge bug

This commit is contained in:
Himit_ZH 2022-01-22 18:58:45 +08:00
parent 1beab3d386
commit 69b7dbdbf7
2 changed files with 20 additions and 17 deletions

View File

@ -130,24 +130,25 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
// 将新提交数据插入数据库
judgeMapper.insert(judge);
// 管理员比赛前的提交不纳入记录
if (contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode()) {
// 同时初始化写入contest_record表
ContestRecord contestRecord = new ContestRecord();
contestRecord.setDisplayId(judgeDto.getPid())
.setCpid(contestProblem.getId())
.setSubmitId(judge.getSubmitId())
.setPid(judge.getPid())
.setUsername(userRolesVo.getUsername())
.setRealname(userRolesVo.getRealname())
.setUid(userRolesVo.getUid())
.setCid(judge.getCid())
.setSubmitTime(judge.getSubmitTime())
// 设置比赛开始时间到提交时间之间的秒数
.setTime(DateUtil.between(contest.getStartTime(), judge.getSubmitTime(), DateUnit.SECOND));
contestRecordMapper.insert(contestRecord);
// 同时初始化写入contest_record表
ContestRecord contestRecord = new ContestRecord();
contestRecord.setDisplayId(judgeDto.getPid())
.setCpid(contestProblem.getId())
.setSubmitId(judge.getSubmitId())
.setPid(judge.getPid())
.setUsername(userRolesVo.getUsername())
.setRealname(userRolesVo.getRealname())
.setUid(userRolesVo.getUid())
.setCid(judge.getCid())
.setSubmitTime(judge.getSubmitTime());
if (contest.getStatus().intValue() == Constants.Contest.STATUS_SCHEDULED.getCode()) {
contestRecord.setTime(0L);
} else {
// 设置比赛开始时间到提交时间之间的秒数
contestRecord.setTime(DateUtil.between(contest.getStartTime(), judge.getSubmitTime(), DateUnit.SECOND));
}
contestRecordMapper.insert(contestRecord);
return null;
}

View File

@ -2,10 +2,10 @@ package top.hcode.hoj.service.judge.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.judge.remote.RemoteJudgeDispatcher;
import top.hcode.hoj.judge.self.JudgeDispatcher;
@ -59,6 +59,7 @@ public class RejudgeServiceImpl implements RejudgeService {
private RemoteJudgeDispatcher remoteJudgeDispatcher;
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult rejudge(Long submitId) {
Judge judge = judgeService.getById(submitId);
@ -117,6 +118,7 @@ public class RejudgeServiceImpl implements RejudgeService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult rejudgeContestProblem(Long cid, Long pid) {
QueryWrapper<Judge> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("cid", cid).eq("pid", pid);