考试 优化
正在显示
2 个修改的文件
包含
47 行增加
和
14 行删除
1 | package com.skua.modules.edu.controller; | 1 | package com.skua.modules.edu.controller; |
2 | 2 | ||
3 | 3 | ||
4 | import cn.hutool.core.bean.BeanUtil; | ||
5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
4 | import com.baomidou.mybatisplus.core.metadata.IPage; | 6 | import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
8 | import com.skua.common.constant.BusinessConstant; | ||
6 | import com.skua.core.api.vo.Result; | 9 | import com.skua.core.api.vo.Result; |
7 | import com.skua.core.aspect.annotation.AutoLog; | 10 | import com.skua.core.aspect.annotation.AutoLog; |
8 | import com.skua.core.context.BaseContextHandler; | 11 | import com.skua.core.context.BaseContextHandler; |
9 | import com.skua.core.util.DateUtils; | 12 | import com.skua.core.util.DateUtils; |
13 | import com.skua.modules.base.service.IBaseService; | ||
14 | import com.skua.modules.biz.IBusinessService; | ||
10 | import com.skua.modules.edu.entity.*; | 15 | import com.skua.modules.edu.entity.*; |
11 | import com.skua.modules.edu.service.IPaperService; | 16 | import com.skua.modules.edu.service.IPaperService; |
12 | import com.skua.modules.edu.service.IUserPaperService; | 17 | import com.skua.modules.edu.service.IUserPaperService; |
... | @@ -30,6 +35,11 @@ import javax.servlet.http.HttpServletResponse; | ... | @@ -30,6 +35,11 @@ import javax.servlet.http.HttpServletResponse; |
30 | import java.io.IOException; | 35 | import java.io.IOException; |
31 | import java.math.BigInteger; | 36 | import java.math.BigInteger; |
32 | import java.net.URLEncoder; | 37 | import java.net.URLEncoder; |
38 | import java.util.ArrayList; | ||
39 | import java.util.Arrays; | ||
40 | import java.util.List; | ||
41 | import java.util.Map; | ||
42 | import java.util.stream.Collectors; | ||
33 | 43 | ||
34 | @Slf4j | 44 | @Slf4j |
35 | @Api(tags="在线考试-用户考试") | 45 | @Api(tags="在线考试-用户考试") |
... | @@ -41,6 +51,10 @@ public class UserPaperController { | ... | @@ -41,6 +51,10 @@ public class UserPaperController { |
41 | 51 | ||
42 | @Autowired | 52 | @Autowired |
43 | private IUserPaperService userPaperService; | 53 | private IUserPaperService userPaperService; |
54 | @Autowired | ||
55 | private IBaseService baseService; | ||
56 | @Autowired | ||
57 | private IBusinessService businessService; | ||
44 | 58 | ||
45 | // 我的 考试 | 59 | // 我的 考试 |
46 | @AutoLog(value = "在线考试--试卷列表") | 60 | @AutoLog(value = "在线考试--试卷列表") |
... | @@ -58,10 +72,11 @@ public class UserPaperController { | ... | @@ -58,10 +72,11 @@ public class UserPaperController { |
58 | queryWrapper.le("start_time",currentDate);// 当前时间 > 开始结束时间 | 72 | queryWrapper.le("start_time",currentDate);// 当前时间 > 开始结束时间 |
59 | queryWrapper.ge("end_time",currentDate); | 73 | queryWrapper.ge("end_time",currentDate); |
60 | IPage<Paper> pageList = paperService.page(page, queryWrapper);*/ | 74 | IPage<Paper> pageList = paperService.page(page, queryWrapper);*/ |
61 | paper.setUserId(BaseContextHandler.getUserId()); | 75 | String userId = BaseContextHandler.getUserId(); |
76 | // paper.setUserId(userId); | ||
62 | paper.setStartTime(DateUtils.now()); | 77 | paper.setStartTime(DateUtils.now()); |
63 | paper.setEndTime( DateUtils.now() ); | 78 | paper.setEndTime( DateUtils.now() ); |
64 | paper.setExamStatus(0);//考试状态是未考试的 | 79 | // paper.setExamStatus(0);//考试状态是未考试的 |
65 | IPage<Paper> pageList = paperService.queryMyPaperByList(page ,paper); | 80 | IPage<Paper> pageList = paperService.queryMyPaperByList(page ,paper); |
66 | result.setSuccess(true); | 81 | result.setSuccess(true); |
67 | result.setResult(pageList); | 82 | result.setResult(pageList); |
... | @@ -148,12 +163,11 @@ public class UserPaperController { | ... | @@ -148,12 +163,11 @@ public class UserPaperController { |
148 | @AutoLog(value = "在线考试--历史试卷列表") | 163 | @AutoLog(value = "在线考试--历史试卷列表") |
149 | @ApiOperation(value="在线考试--历史试卷列表", notes="在线考试--历史试卷列表") | 164 | @ApiOperation(value="在线考试--历史试卷列表", notes="在线考试--历史试卷列表") |
150 | @GetMapping(value = "/historyList") | 165 | @GetMapping(value = "/historyList") |
151 | public Result<IPage<Paper>> historyList( | 166 | public Result<Object> historyList( |
152 | Paper paper, | 167 | Paper paper, |
153 | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, | 168 | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
154 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, | 169 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
155 | HttpServletRequest req) throws Exception { | 170 | HttpServletRequest req) throws Exception { |
156 | Result<IPage<Paper>> result = new Result<IPage<Paper>>(); | ||
157 | /* StringBuffer sql = new StringBuffer(); | 171 | /* StringBuffer sql = new StringBuffer(); |
158 | sql.append("select up.score, p.* from edu_user_paper up "); | 172 | sql.append("select up.score, p.* from edu_user_paper up "); |
159 | sql.append(" left join edu_paper p on p.id = up.paper_id "); | 173 | sql.append(" left join edu_paper p on p.id = up.paper_id "); |
... | @@ -164,16 +178,34 @@ public class UserPaperController { | ... | @@ -164,16 +178,34 @@ public class UserPaperController { |
164 | Page<Map<String, Object>> pageList = iCommonSqlService.queryForPage(page, sql.toString()); | 178 | Page<Map<String, Object>> pageList = iCommonSqlService.queryForPage(page, sql.toString()); |
165 | List<Paper> paperList = JoinSqlUtils.multiMaps2Beans(pageList.getRecords(), Paper.class); | 179 | List<Paper> paperList = JoinSqlUtils.multiMaps2Beans(pageList.getRecords(), Paper.class); |
166 | */ | 180 | */ |
167 | 181 | String departIds = BaseContextHandler.getDeparts(); | |
168 | Page<Paper> page = new Page<Paper>(pageNo, pageSize); | 182 | QueryWrapper<?> queryWrapper0 = new QueryWrapper<>(); |
169 | if(StringUtils.isEmpty(paper.getUserId())){ | 183 | queryWrapper0.eq(StringUtils.isNotEmpty(paper.getUserId()),"edu_user_paper.user_id", paper.getUserId()) |
170 | paper.setUserId(BaseContextHandler.getUserId());//获取当前用户编号 | 184 | .like(StringUtils.isNotEmpty(paper.getPaperTitle()), "edu_paper.paper_title", paper.getPaperTitle()) |
171 | } | 185 | .in("edu_user_paper.depart_id", Arrays.asList(departIds.split(","))) |
172 | IPage<Paper> paperList = paperService.queryMyPaperRecoredByList(page,paper); | 186 | .orderByDesc("edu_user_paper.start_time", "edu_user_paper.score"); |
173 | 187 | List<String> columnList = new ArrayList<String>(){{ | |
174 | result.setResult(paperList); | 188 | add("edu_user_paper.score"); |
175 | result.setSuccess(true); | 189 | add("edu_user_paper.user_id"); |
176 | return result; | 190 | add("edu_user_paper.rank"); |
191 | add("edu_user_paper.depart_id"); | ||
192 | add("edu_user_paper.id as 'user_paper_id'"); | ||
193 | add("edu_paper.*"); | ||
194 | }}; | ||
195 | IPage<Map<String, Object>> mapIPage = baseService.queryForPage(new Page<>(pageNo, pageSize), "select " + String.join(",", columnList) + " from edu_user_paper left join edu_paper on edu_user_paper.paper_id = edu_paper.id", queryWrapper0); | ||
196 | // 翻译 | ||
197 | Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null); | ||
198 | Map<String, String> sysUserDictMap = businessService.dictMap("sys_user", null); | ||
199 | // 封装结果集 | ||
200 | IPage<Map<String, Object>> paperIPage = new Page<>(pageNo, pageSize); | ||
201 | paperIPage.setTotal(mapIPage.getTotal()); | ||
202 | paperIPage.setRecords(mapIPage.getRecords().stream().map(item -> { | ||
203 | Map<String, Object> tmpMap = BeanUtil.beanToMap(BeanUtil.toBean(item, Paper.class)); | ||
204 | tmpMap.put("userId" + BusinessConstant.dictText, sysUserDictMap.get(tmpMap.get("userId"))); | ||
205 | tmpMap.put("departId" + BusinessConstant.dictText, sysDepartDictMap.get(tmpMap.get("departId"))); | ||
206 | return tmpMap; | ||
207 | }).collect(Collectors.toList())); | ||
208 | return Result.ok(paperIPage); | ||
177 | } | 209 | } |
178 | //历史试卷详情 history_detail | 210 | //历史试卷详情 history_detail |
179 | @AutoLog(value = "在线考试--历史试卷详情(复习)") | 211 | @AutoLog(value = "在线考试--历史试卷详情(复习)") | ... | ... |
... | @@ -87,6 +87,7 @@ public class MybatisInterceptor implements Interceptor { | ... | @@ -87,6 +87,7 @@ public class MybatisInterceptor implements Interceptor { |
87 | add("inspection_point_trigger_config"); | 87 | add("inspection_point_trigger_config"); |
88 | 88 | ||
89 | //在线考试 | 89 | //在线考试 |
90 | add("edu_paper");//用户的试卷 | ||
90 | add("edu_user_paper");//用户的试卷 | 91 | add("edu_user_paper");//用户的试卷 |
91 | add("edu_question");//试题 | 92 | add("edu_question");//试题 |
92 | add("edu_question_db");//题库 | 93 | add("edu_question_db");//题库 | ... | ... |
-
请 注册 或 登录 后发表评论