diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java index a337187a..20b807c6 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java @@ -452,7 +452,6 @@ public class ContestController { // 如果已经开启了封榜模式 .between(isOpenSealRank, "submit_time", contest.getStartTime(), contest.getSealRankTime()) .between(!isOpenSealRank, "submit_time", contest.getStartTime(), contest.getEndTime()) - .ne("uid", "1") .ne("username", contest.getAuthor()) .orderByAsc("time"); diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java index 4d55c9c7..f0b44c9b 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java @@ -313,7 +313,7 @@ public class JudgeController { } } - // 超级管理员与管理员有权限查看代码 + // 超级管理员与题目管理员有权限查看代码 // 如果不是本人或者并未分享代码,则不可查看 // 当此次提交代码不共享 // 比赛提交只有比赛创建者和root账号可看代码 @@ -332,8 +332,7 @@ public class JudgeController { judge.setCode(null); } }else { - boolean admin = SecurityUtils.getSubject().hasRole("admin") - || SecurityUtils.getSubject().hasRole("problem_admin");// 是否为管理员 + boolean admin = SecurityUtils.getSubject().hasRole("problem_admin");// 是否为题目管理员 if (!judge.getShare() && !root && !admin) { if (userRolesVo != null) { // 当前是登陆状态 // 需要判断是否为当前登陆用户自己的提交代码 diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/UserInfoMapper.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/UserInfoMapper.java index 5ab467f7..28129a84 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/UserInfoMapper.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/UserInfoMapper.java @@ -6,6 +6,8 @@ import top.hcode.hoj.pojo.dto.RegisterDto; import top.hcode.hoj.pojo.entity.UserInfo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; + /** *

@@ -19,4 +21,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @Repository public interface UserInfoMapper extends BaseMapper { int addUser(RegisterDto registerDto); + + List getSuperAdminList(); } diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml index e6b95098..3dd149ac 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml @@ -31,7 +31,7 @@ SELECT cr.* FROM (SELECT uid,pid,cpid,MAX(time) AS time FROM contest_record - cid=#{cid} AND status IS NOT NULL AND uid!='1' + cid=#{cid} AND status IS NOT NULL AND username!=#{contestAuthor} diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserInfoMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserInfoMapper.xml index ad00bbde..3daf239e 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserInfoMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserInfoMapper.xml @@ -6,4 +6,7 @@ #{uuid}, #{username},#{password},#{email} ) + diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/OIContestRankVo.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/OIContestRankVo.java index c4e9a68b..ea1f3108 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/OIContestRankVo.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/OIContestRankVo.java @@ -27,6 +27,12 @@ public class OIContestRankVo { @ApiModelProperty(value = "提交总得分") private Integer totalScore; + @ApiModelProperty(value = "提交总耗时,只有满分的提交才会统计") + private Integer totalTime; + @ApiModelProperty(value = "OI的题对应提交得分") private HashMap submissionInfo; + + @ApiModelProperty(value = "OI的题得满分后对应提交最优耗时") + private HashMap timeInfo; } \ No newline at end of file diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/ContestRecordService.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/ContestRecordService.java index 2a402e05..5b29e9b5 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/ContestRecordService.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/ContestRecordService.java @@ -1,6 +1,7 @@ package top.hcode.hoj.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import top.hcode.hoj.pojo.entity.UserInfo; import top.hcode.hoj.pojo.vo.ACMContestRankVo; import top.hcode.hoj.pojo.entity.ContestRecord; import com.baomidou.mybatisplus.extension.service.IService; @@ -27,4 +28,7 @@ public interface ContestRecordService extends IService { List getOIContestRecord(Long cid, String contestAuthor, Boolean isOpenSealRank, Date sealTime, Date startTime, Date endTime); + + List getSuperAdminList(); + } diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java index 586da1f0..fc6f7b54 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java @@ -1,8 +1,11 @@ package top.hcode.hoj.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; +import top.hcode.hoj.dao.UserInfoMapper; +import top.hcode.hoj.pojo.entity.UserInfo; import top.hcode.hoj.pojo.vo.ACMContestRankVo; import top.hcode.hoj.pojo.entity.ContestRecord; import top.hcode.hoj.dao.ContestRecordMapper; @@ -30,6 +33,9 @@ public class ContestRecordServiceImpl extends ServiceImpl getACInfo(Integer currentPage, Integer limit, Integer status, Long cid) { @@ -37,6 +43,11 @@ public class ContestRecordServiceImpl extends ServiceImpl getSuperAdminList() { + return userInfoMapper.getSuperAdminList(); + } + @Override public IPage getContestACMRank(List contestRecordList, int currentPage, int limit) { @@ -96,7 +107,13 @@ public class ContestRecordServiceImpl extends ServiceImpl calcACMRank(List contestRecordList) { + + List superAdminList = getSuperAdminList(); + + List superAdminUidList = superAdminList.stream().map(UserInfo::getUuid).collect(Collectors.toList()); + List result = new ArrayList<>(); HashMap uidMapIndex = new HashMap<>(); @@ -106,6 +123,11 @@ public class ContestRecordServiceImpl extends ServiceImpl firstACMap = new HashMap<>(); for (ContestRecord contestRecord : contestRecordList) { + + if (superAdminUidList.contains(contestRecord.getUid())) { // 超级管理员的提交不入排行榜 + continue; + } + ACMContestRankVo ACMContestRankVo; if (!uidMapIndex.containsKey(contestRecord.getUid())) { // 如果该用户信息没还记录 @@ -182,15 +204,44 @@ public class ContestRecordServiceImpl extends ServiceImpl calcOIRank(List oiContestRecord) { + + List superAdminList = getSuperAdminList(); + + List superAdminUidList = superAdminList.stream().map(UserInfo::getUuid).collect(Collectors.toList()); + List result = new ArrayList<>(); HashMap uidMapIndex = new HashMap<>(); + HashMap> uidMapTime = new HashMap<>(); + int index = 0; for (ContestRecord contestRecord : oiContestRecord) { + + if (superAdminUidList.contains(contestRecord.getUid())) { // 超级管理员的提交不入排行榜 + continue; + } + + if (contestRecord.getStatus() == 1) { // AC + HashMap pidMapTime = uidMapTime.get(contestRecord.getUid()); + if (pidMapTime != null) { + Integer useTime = pidMapTime.get(contestRecord.getDisplayId()); + if (useTime != null) { + if (useTime > contestRecord.getUseTime()) { // 如果时间消耗比原来的少 + pidMapTime.put(contestRecord.getDisplayId(), contestRecord.getUseTime()); + } + } else { + pidMapTime.put(contestRecord.getDisplayId(), contestRecord.getUseTime()); + } + } else { + HashMap tmp = new HashMap<>(); + tmp.put(contestRecord.getDisplayId(), contestRecord.getUseTime()); + uidMapTime.put(contestRecord.getUid(), tmp); + } + } + OIContestRankVo oiContestRankVo; if (!uidMapIndex.containsKey(contestRecord.getUid())) { // 如果该用户信息没还记录 - // 初始化参数 oiContestRankVo = new OIContestRankVo(); oiContestRankVo.setRealname(contestRecord.getRealname()) @@ -218,9 +269,24 @@ public class ContestRecordServiceImpl extends ServiceImpl pidMapTime = uidMapTime.get(oiContestRankVo.getUid()); + int sumTime = 0; + if (pidMapTime != null) { + for (String key : pidMapTime.keySet()) { + Integer time = pidMapTime.get(key); + sumTime += time == null ? 0 : time; + } + } + oiContestRankVo.setTotalTime(sumTime); + oiContestRankVo.setTimeInfo(pidMapTime); + } + + // 根据总得分进行降序,再根据总时耗升序排序 List orderResultList = result.stream() - .sorted(Comparator.comparing(OIContestRankVo::getTotalScore, Comparator.reverseOrder())) + .sorted(Comparator.comparing(OIContestRankVo::getTotalScore, Comparator.reverseOrder()) + .thenComparing(OIContestRankVo::getTotalTime,Comparator.naturalOrder())) .collect(Collectors.toList()); return orderResultList; } diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java index 5f00b7a7..da756212 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java @@ -136,7 +136,8 @@ public class JudgeController { finalJudge.getCid(), finalJudge.getUid(), finalJudge.getPid(), - finalJudge.getScore()); + finalJudge.getScore(), + finalJudge.getTime()); } @@ -165,7 +166,7 @@ public class JudgeController { public CommonResult remoteJudge(@RequestBody ToJudge toJudge) { if (!openRemoteJudge) { - return CommonResult.errorResponse("对不起!该判题服务器未开启远程虚拟判题功能!",CommonResult.STATUS_ACCESS_DENIED); + return CommonResult.errorResponse("对不起!该判题服务器未开启远程虚拟判题功能!", CommonResult.STATUS_ACCESS_DENIED); } if (!toJudge.getToken().equals(judgeToken)) { diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult.java index b0ad0131..726a9873 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult.java @@ -78,13 +78,13 @@ public class RemoteJudgeGetResult { // 写回数据库 judgeService.updateById(judge); // 同步其它表 - judgeService.updateOtherTable(submitId, status, cid, uid, pid, score); + judgeService.updateOtherTable(submitId, status, cid, uid, pid, score, judge.getTime()); } else { judgeService.updateById(judge); // 同步其它表 - judgeService.updateOtherTable(submitId, status, cid, uid, pid, null); + judgeService.updateOtherTable(submitId, status, cid, uid, pid, null, null); } scheduler.shutdown(); diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeToSubmit.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeToSubmit.java index 49ad756f..e55271e6 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeToSubmit.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/RemoteJudgeToSubmit.java @@ -83,6 +83,7 @@ public class RemoteJudgeToSubmit { cid, uid, pid, + null, null); log.error("网络错误---------------->获取不到提交ID"); return; diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java index 0895cf2f..63990888 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java @@ -71,6 +71,7 @@ public class POJJudge implements RemoteJudgeStrategy { TimeUnit.SECONDS.sleep(2); maxRunId = getMaxRunId(request, username, problemId); } + return MapUtil.builder(new HashMap()) .put("cookies", cookies) .put("runId", maxRunId) @@ -85,6 +86,10 @@ public class POJJudge implements RemoteJudgeStrategy { .addHeaders(headers); HttpResponse response = request.execute(); + if (response.getStatus() != 200) { + log.error(submitId + " error:{}", response.body()); + } + String statusStr = ReUtil.get("Result:(.+?)", response.body(), 1) .replaceAll("<.*?>", "") .trim(); diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/ContestRecordService.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/ContestRecordService.java index ce89802c..a4024e0b 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/ContestRecordService.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/ContestRecordService.java @@ -13,5 +13,5 @@ import top.hcode.hoj.pojo.entity.Judge; * @since 2020-10-23 */ public interface ContestRecordService extends IService { - void UpdateContestRecord(String uid, Integer score, Integer status, Long submitId, Long cid); + void UpdateContestRecord(String uid, Integer score, Integer status, Long submitId, Long cid, Integer useTime); } diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/JudgeService.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/JudgeService.java index 53bd2aa3..f0fd8d16 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/JudgeService.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/JudgeService.java @@ -21,5 +21,5 @@ public interface JudgeService extends IService { Boolean compileSpj(String code, Long pid, String spjLanguage) throws CompileError, SystemError; - void updateOtherTable(Long submitId, Integer status, Long cid, String uid, Long pid, Integer score); + void updateOtherTable(Long submitId, Integer status, Long cid, String uid, Long pid, Integer score,Integer useTime); } diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java index 164ead22..d4058dc9 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java @@ -42,7 +42,7 @@ public class ContestRecordServiceImpl extends ServiceImpl updateWrapper = new UpdateWrapper<>(); // 如果是AC if (status.intValue() == Constants.Judge.STATUS_ACCEPTED.getStatus()) { @@ -64,6 +64,8 @@ public class ContestRecordServiceImpl extends ServiceImpl 0; diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java index 892970d6..960331df 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java @@ -48,7 +48,7 @@ public class JudgeServiceImpl extends ServiceImpl implements public Judge Judge(Problem problem, Judge judge) { // c和c++为一倍时间和空间,其它语言为2倍时间和空间 - if (!judge.getLanguage().equals("C++") && !judge.getLanguage().equals("C")&& + if (!judge.getLanguage().equals("C++") && !judge.getLanguage().equals("C") && !judge.getLanguage().equals("C++ With O2") && !judge.getLanguage().equals("C With O2")) { problem.setTimeLimit(problem.getTimeLimit() * 2); problem.setMemoryLimit(problem.getMemoryLimit() * 2); @@ -84,7 +84,7 @@ public class JudgeServiceImpl extends ServiceImpl implements @Override @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED) - public void updateOtherTable(Long submitId, Integer status, Long cid, String uid, Long pid, Integer score) { + public void updateOtherTable(Long submitId, Integer status, Long cid, String uid, Long pid, Integer score, Integer useTime) { if (cid == 0) { // 非比赛提交 // 如果是AC,就更新user_acproblem表, @@ -98,7 +98,7 @@ public class JudgeServiceImpl extends ServiceImpl implements } else { //如果是比赛提交 - contestRecordService.UpdateContestRecord(uid, score, status, submitId, cid); + contestRecordService.UpdateContestRecord(uid, score, status, submitId, cid, useTime); } } diff --git a/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/ContestRecord.java b/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/ContestRecord.java index 23e75031..03298577 100644 --- a/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/ContestRecord.java +++ b/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/ContestRecord.java @@ -68,6 +68,9 @@ public class ContestRecord implements Serializable { @ApiModelProperty(value = "OI比赛的得分") private Integer score; + @ApiModelProperty(value = "提交耗时") + private Integer useTime; + @ApiModelProperty(value = "是否为一血AC") private Boolean firstBlood; diff --git a/hoj-vue/src/App.vue b/hoj-vue/src/App.vue index f6e0d226..d4a8ee50 100644 --- a/hoj-vue/src/App.vue +++ b/hoj-vue/src/App.vue @@ -304,9 +304,6 @@ a:hover { margin-top: 80px; padding: 0 4%; } - .vxe-table--body-wrapper { - overflow-x: hidden !important; - } } .markdown-body img { max-width: 100%; diff --git a/hoj-vue/src/components/admin/ContestAddProblem.vue b/hoj-vue/src/components/admin/ContestAddProblem.vue index f91a7bfa..9a69bc94 100644 --- a/hoj-vue/src/components/admin/ContestAddProblem.vue +++ b/hoj-vue/src/components/admin/ContestAddProblem.vue @@ -85,8 +85,8 @@ export default { .admin_getContestProblemList(params) .then((res) => { this.loading = false; - this.total = res.data.data.total; - this.problems = res.data.data.records; + this.total = res.data.data.problemList.total; + this.problems = res.data.data.problemList.records; }) .catch(() => { this.loading = false; diff --git a/hoj-vue/src/views/oj/contest/children/ACMContestRank.vue b/hoj-vue/src/views/oj/contest/children/ACMContestRank.vue index 7f158715..8684feea 100644 --- a/hoj-vue/src/views/oj/contest/children/ACMContestRank.vue +++ b/hoj-vue/src/views/oj/contest/children/ACMContestRank.vue @@ -61,6 +61,7 @@ > @@ -76,6 +77,7 @@ @@ -99,6 +102,7 @@ diff --git a/hoj-vue/src/views/oj/contest/children/ContestRejudgeAdmin.vue b/hoj-vue/src/views/oj/contest/children/ContestRejudgeAdmin.vue index fb81b8d8..87a1a36f 100644 --- a/hoj-vue/src/views/oj/contest/children/ContestRejudgeAdmin.vue +++ b/hoj-vue/src/views/oj/contest/children/ContestRejudgeAdmin.vue @@ -10,7 +10,7 @@ align="center" :data="contestProblems" > - + diff --git a/hoj-vue/src/views/oj/contest/children/OIContestRank.vue b/hoj-vue/src/views/oj/contest/children/OIContestRank.vue index 533a9334..399bf8e5 100644 --- a/hoj-vue/src/views/oj/contest/children/OIContestRank.vue +++ b/hoj-vue/src/views/oj/contest/children/OIContestRank.vue @@ -50,6 +50,7 @@ auto-resize size="small" align="center" + ref="OIContestRank" :data="dataRank" :cell-class-name="cellClassName" :seq-config="{ startIndex: (this.page - 1) * this.limit }" @@ -63,6 +64,7 @@ @@ -339,4 +351,8 @@ a.emphasis { a.emphasis:hover { color: #2d8cf0; } +.problem-time { + color: rgba(0, 0, 0, 0.45); + font-size: 12px; +} diff --git a/hoj-vue/src/views/oj/problem/ProblemList.vue b/hoj-vue/src/views/oj/problem/ProblemList.vue index 676d68aa..6fc886e4 100644 --- a/hoj-vue/src/views/oj/problem/ProblemList.vue +++ b/hoj-vue/src/views/oj/problem/ProblemList.vue @@ -150,6 +150,7 @@ field="title" :title="$t('m.Problem')" min-width="180" + show-overflow >