修复比赛后管理员重判题目导致排行榜失效的问题
This commit is contained in:
parent
26c16b2b64
commit
60b249f901
|
@ -14,6 +14,7 @@
|
|||
| 2021-04-16 | 重构解耦JudgeServer判题逻辑,添加部署文档 | Himit_ZH |
|
||||
| 2021-04-19 | 加入rsync实现评测数据同步,修复一些已知的BUG | Himit_ZH |
|
||||
| 2021-04-24 | 加入题目模板,修改页面页脚 | Himit_ZH |
|
||||
| 2021-05-02 | 修复比赛后管理员重判题目导致排行榜失效的问题 | Himit_ZH |
|
||||
|
||||
# 二、部署
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ public class FileController {
|
|||
.sheet("rank")
|
||||
.doWrite(fileService.changeACMContestRankToExcelRowList(acmContestRankVoList, contestProblemDisplayIDList));
|
||||
} else {
|
||||
List<ContestRecord> oiContestRecord = contestRecordService.getOIContestRecord(cid, isOpenSealRank, contest.getSealRankTime(), contest.getEndTime());
|
||||
List<ContestRecord> oiContestRecord = contestRecordService.getOIContestRecord(cid, isOpenSealRank, contest.getSealRankTime(),contest.getStartTime(), contest.getEndTime());
|
||||
Assert.notEmpty(oiContestRecord, "比赛暂无排行榜记录!");
|
||||
List<OIContestRankVo> oiContestRankVoList = contestRecordService.calcOIRank(oiContestRecord);
|
||||
EasyExcel.write(response.getOutputStream())
|
||||
|
|
|
@ -304,7 +304,7 @@ public class ContestController {
|
|||
}
|
||||
|
||||
// 将数据统一写入到一个Vo返回数据实体类中
|
||||
ProblemInfoVo problemInfoVo = new ProblemInfoVo(problem, tagsStr, languagesStr, problemCount,LangNameAndCode);
|
||||
ProblemInfoVo problemInfoVo = new ProblemInfoVo(problem, tagsStr, languagesStr, problemCount, LangNameAndCode);
|
||||
return CommonResult.successResponse(problemInfoVo, "获取成功");
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,8 @@ public class ContestController {
|
|||
QueryWrapper<ContestRecord> wrapper = new QueryWrapper<ContestRecord>().eq("cid", cid)
|
||||
.isNotNull("status")
|
||||
// 如果已经开启了封榜模式
|
||||
.notBetween(isOpenSealRank, "submit_time", contest.getSealRankTime(), contest.getEndTime())
|
||||
.between(isOpenSealRank, "submit_time", contest.getStartTime(), contest.getSealRankTime())
|
||||
.between(!isOpenSealRank, "submit_time", contest.getStartTime(), contest.getEndTime())
|
||||
.orderByAsc("time");
|
||||
|
||||
List<ContestRecord> contestRecordList = contestRecordService.list(wrapper);
|
||||
|
@ -413,7 +414,7 @@ public class ContestController {
|
|||
|
||||
} else { //OI比赛:以最后一次提交得分作为该题得分
|
||||
|
||||
resultList = contestRecordService.getContestOIRank(cid, isOpenSealRank, contest.getSealRankTime(),
|
||||
resultList = contestRecordService.getContestOIRank(cid, isOpenSealRank, contest.getSealRankTime(),contest.getStartTime(),
|
||||
contest.getEndTime(), currentPage, limit);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,5 +24,6 @@ public interface ContestRecordMapper extends BaseMapper<ContestRecord> {
|
|||
List<ContestRecord> getACInfo(IPage iPage, @Param("status") Integer status, @Param("cid") Long cid);
|
||||
|
||||
List<ContestRecord> getOIContestRecord(@Param("cid") Long cid, @Param("isOpenSealRank") Boolean isOpenSealRank,
|
||||
@Param("sealTime") Date sealTime, @Param("endTime") Date endTime);
|
||||
@Param("sealTime") Date sealTime, @Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,14 @@
|
|||
(SELECT uid,pid,cpid,MAX(time) AS time FROM contest_record
|
||||
<where>
|
||||
cid=#{cid} AND status IS NOT NULL
|
||||
<if test="isOpenSealRank">
|
||||
AND submit_time NOT BETWEEN #{sealTime} AND #{endTime}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="isOpenSealRank">
|
||||
AND submit_time BETWEEN #{startTime} AND #{sealTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND submit_time BETWEEN #{startTime} AND #{endTime}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
GROUP BY uid,pid,cpid) t
|
||||
LEFT JOIN contest_record cr ON t.uid = cr.uid AND t.pid =cr.pid
|
||||
|
|
|
@ -21,7 +21,6 @@ import top.hcode.hoj.utils.RedisUtils;
|
|||
* 3. 再次接受到信息,再次查询是否有空闲判题服务器,若有则进行判题,否则回到2
|
||||
*/
|
||||
@Component
|
||||
@Async
|
||||
@Slf4j
|
||||
public class JudgeReceiver {
|
||||
|
||||
|
@ -34,7 +33,7 @@ public class JudgeReceiver {
|
|||
@Autowired
|
||||
private JudgeServiceImpl judgeService;
|
||||
|
||||
|
||||
@Async
|
||||
public void processWaitingTask() {
|
||||
// 如果队列中还有任务,则继续处理
|
||||
if (redisUtils.lGetListSize(Constants.Judge.STATUS_JUDGE_WAITING.getName()) > 0) {
|
||||
|
|
|
@ -23,8 +23,8 @@ public interface ContestRecordService extends IService<ContestRecord> {
|
|||
|
||||
IPage<ACMContestRankVo> getContestACMRank(List<ContestRecord> contestRecordList, int currentPage, int limit);
|
||||
|
||||
IPage<OIContestRankVo> getContestOIRank(Long cid, Boolean isOpenSealRank, Date sealTime, Date endTime, int currentPage, int limit);
|
||||
IPage<OIContestRankVo> getContestOIRank(Long cid, Boolean isOpenSealRank, Date sealTime, Date startTime, Date endTime, int currentPage, int limit);
|
||||
|
||||
List<ContestRecord> getOIContestRecord(Long cid, Boolean isOpenSealRank, Date sealTime, Date endTime);
|
||||
List<ContestRecord> getOIContestRecord(Long cid, Boolean isOpenSealRank, Date sealTime, Date startTime, Date endTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
|
|||
|
||||
|
||||
@Override
|
||||
public IPage<OIContestRankVo> getContestOIRank(Long cid, Boolean isOpenSealRank, Date sealTime, Date endTime, int currentPage, int limit) {
|
||||
public IPage<OIContestRankVo> getContestOIRank(Long cid, Boolean isOpenSealRank, Date sealTime, Date startTime, Date endTime, int currentPage, int limit) {
|
||||
|
||||
// 获取每个用户每道题最近一次提交
|
||||
List<ContestRecord> oiContestRecord = contestRecordMapper.getOIContestRecord(cid, isOpenSealRank, sealTime, endTime);
|
||||
List<ContestRecord> oiContestRecord = contestRecordMapper.getOIContestRecord(cid, isOpenSealRank, sealTime, startTime, endTime);
|
||||
|
||||
// 计算排名
|
||||
List<OIContestRankVo> orderResultList = calcOIRank(oiContestRecord);
|
||||
|
@ -92,8 +92,8 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ContestRecord> getOIContestRecord(Long cid, Boolean isOpenSealRank, Date sealTime, Date endTime) {
|
||||
return contestRecordMapper.getOIContestRecord(cid, isOpenSealRank, sealTime, endTime);
|
||||
public List<ContestRecord> getOIContestRecord(Long cid, Boolean isOpenSealRank, Date sealTime, Date startTime, Date endTime) {
|
||||
return contestRecordMapper.getOIContestRecord(cid, isOpenSealRank, sealTime, startTime, endTime);
|
||||
}
|
||||
|
||||
public List<ACMContestRankVo> calcACMRank(List<ContestRecord> contestRecordList) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class JudgeController {
|
|||
public CommonResult getVersion() {
|
||||
|
||||
return CommonResult.successResponse(MapUtil.builder()
|
||||
.put("version", "1.1.0")
|
||||
.put("version", "1.2.0")
|
||||
.put("currentTime", new Date())
|
||||
.put("judgeServerName", name)
|
||||
.put("cpu", Runtime.getRuntime().availableProcessors())
|
||||
|
|
|
@ -16,7 +16,6 @@ import top.hcode.hoj.pojo.entity.Problem;
|
|||
* @since 2020-10-23
|
||||
*/
|
||||
public interface JudgeService extends IService<Judge> {
|
||||
String test();
|
||||
|
||||
Judge Judge(Problem problem, Judge judge);
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@ import java.util.HashMap;
|
|||
@Slf4j
|
||||
public class JudgeServiceImpl extends ServiceImpl<JudgeMapper, Judge> implements JudgeService {
|
||||
|
||||
public String test() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private JudgeStrategy judgeStrategy;
|
||||
|
@ -53,8 +50,6 @@ public class JudgeServiceImpl extends ServiceImpl<JudgeMapper, Judge> implements
|
|||
@Autowired
|
||||
private ContestRecordServiceImpl contestRecordService;
|
||||
|
||||
@Autowired
|
||||
private ContestServiceImpl contestService;
|
||||
|
||||
@Override
|
||||
public Judge Judge(Problem problem, Judge judge) {
|
||||
|
@ -116,16 +111,7 @@ public class JudgeServiceImpl extends ServiceImpl<JudgeMapper, Judge> implements
|
|||
}
|
||||
|
||||
} else { //如果是比赛提交
|
||||
|
||||
Contest contest = contestService.getById(cid);
|
||||
if (contest == null) {
|
||||
log.error("判题机出错----------->{}", "该比赛不存在");
|
||||
|
||||
} else if (contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode()) {
|
||||
// 比赛期间的提交才进行记录
|
||||
contestRecordService.UpdateContestRecord(uid, score, status, submitId, cid);
|
||||
}
|
||||
|
||||
contestRecordService.UpdateContestRecord(uid, score, status, submitId, cid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ if (process.env.NODE_ENV == 'development') {
|
|||
} else if (process.env.NODE_ENV == 'debug') {
|
||||
axios.defaults.baseURL = "http://localhost:6688";
|
||||
} else if (process.env.NODE_ENV == 'production') {
|
||||
axios.defaults.baseURL = '你网站的域名';
|
||||
axios.defaults.baseURL = '你的域名或者ip:端口号';
|
||||
}
|
||||
|
||||
// 请求超时时间
|
||||
|
|
Loading…
Reference in New Issue