kangwei : 在线考试接口:修改计算成绩,我的考试列表,考试记录
正在显示
20 个修改的文件
包含
295 行增加
和
72 行删除
... | @@ -142,7 +142,13 @@ public class QuestionController { | ... | @@ -142,7 +142,13 @@ public class QuestionController { |
142 | @DeleteMapping(value = "/delete") | 142 | @DeleteMapping(value = "/delete") |
143 | public Result<?> delete(@RequestParam(name="id",required=true) String id) { | 143 | public Result<?> delete(@RequestParam(name="id",required=true) String id) { |
144 | try { | 144 | try { |
145 | questionService.removeById(id); | 145 | boolean isUse = questionService.checkByPaper(id); |
146 | if(isUse){//true被使用 | ||
147 | return Result.error("删除失败!试题被试卷使用"); | ||
148 | }else{ | ||
149 | questionService.removeById(id); | ||
150 | } | ||
151 | |||
146 | } catch (Exception e) { | 152 | } catch (Exception e) { |
147 | log.error("删除失败",e.getMessage()); | 153 | log.error("删除失败",e.getMessage()); |
148 | return Result.error("删除失败!"); | 154 | return Result.error("删除失败!"); | ... | ... |
... | @@ -7,15 +7,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ... | @@ -7,15 +7,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
7 | import com.skua.core.api.vo.Result; | 7 | import com.skua.core.api.vo.Result; |
8 | import com.skua.core.aspect.annotation.AutoLog; | 8 | import com.skua.core.aspect.annotation.AutoLog; |
9 | import com.skua.core.context.BaseContextHandler; | 9 | import com.skua.core.context.BaseContextHandler; |
10 | import com.skua.modules.edu.entity.Paper; | 10 | import com.skua.modules.common.service.ICommonSqlService; |
11 | import com.skua.modules.edu.entity.Question; | 11 | import com.skua.modules.edu.entity.*; |
12 | import com.skua.modules.edu.entity.QuestionOption; | ||
13 | import com.skua.modules.edu.entity.UserPaper; | ||
14 | import com.skua.modules.edu.service.IPaperService; | 12 | import com.skua.modules.edu.service.IPaperService; |
15 | import com.skua.modules.edu.service.IUserPaperService; | 13 | import com.skua.modules.edu.service.IUserPaperService; |
16 | import com.skua.modules.edu.vo.PaperVO; | 14 | import com.skua.modules.edu.vo.PaperVO; |
17 | import com.skua.modules.edu.vo.UserPaperVO; | 15 | import com.skua.modules.edu.vo.UserPaperVO; |
16 | import com.skua.modules.equipment.pojo.Equipment; | ||
17 | import com.skua.modules.equipment.util.EquipmentUtils; | ||
18 | import com.skua.modules.equipment.vo.EquipmentVO; | ||
18 | import com.skua.modules.guest.util.DateUtil; | 19 | import com.skua.modules.guest.util.DateUtil; |
20 | import com.skua.tool.util.JoinSqlUtils; | ||
19 | import io.swagger.annotations.Api; | 21 | import io.swagger.annotations.Api; |
20 | import io.swagger.annotations.ApiOperation; | 22 | import io.swagger.annotations.ApiOperation; |
21 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
... | @@ -34,6 +36,8 @@ import java.io.IOException; | ... | @@ -34,6 +36,8 @@ import java.io.IOException; |
34 | import java.math.BigInteger; | 36 | import java.math.BigInteger; |
35 | import java.net.URLEncoder; | 37 | import java.net.URLEncoder; |
36 | import java.util.Date; | 38 | import java.util.Date; |
39 | import java.util.List; | ||
40 | import java.util.Map; | ||
37 | 41 | ||
38 | @Slf4j | 42 | @Slf4j |
39 | @Api(tags="在线考试-用户考试") | 43 | @Api(tags="在线考试-用户考试") |
... | @@ -46,28 +50,53 @@ public class UserPaperController { | ... | @@ -46,28 +50,53 @@ public class UserPaperController { |
46 | @Autowired | 50 | @Autowired |
47 | private IUserPaperService userPaperService; | 51 | private IUserPaperService userPaperService; |
48 | 52 | ||
49 | |||
50 | |||
51 | // 我的 考试 | 53 | // 我的 考试 |
52 | @AutoLog(value = "在线考试--试卷列表") | 54 | @AutoLog(value = "在线考试--试卷列表") |
53 | @ApiOperation(value="在线考试--试卷列表", notes="在线考试--试卷列表") | 55 | @ApiOperation(value="在线考试--试卷列表", notes="在线考试--试卷列表") |
54 | @GetMapping(value = "/paperList") | 56 | @GetMapping(value = "/paperList") |
55 | public Result<IPage<Paper>> queryPageList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, | 57 | public Result<IPage<Paper>> queryPageList(Paper paper, |
58 | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, | ||
56 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, | 59 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
57 | HttpServletRequest req) { | 60 | HttpServletRequest req) throws Exception{ |
58 | Result<IPage<Paper>> result = new Result<IPage<Paper>>(); | 61 | Result<IPage<Paper>> result = new Result<IPage<Paper>>(); |
59 | QueryWrapper<Paper> queryWrapper = new QueryWrapper<>() ;// QueryGenerator.initQueryWrapper(paperAnswer, req.getParameterMap()); | 62 | //QueryWrapper<Paper> queryWrapper = new QueryWrapper<>() ;// QueryGenerator.initQueryWrapper(paperAnswer, req.getParameterMap()); |
60 | Page<Paper> page = new Page<Paper>(pageNo, pageSize); | 63 | Page<Paper> page = new Page<Paper>(pageNo, pageSize); |
61 | queryWrapper.like("exam_user_ids", BaseContextHandler.getUserId()); | 64 | /* queryWrapper.like("exam_user_ids", BaseContextHandler.getUserId()); |
62 | queryWrapper.eq("send_status","1");//已发布的状态 | 65 | queryWrapper.eq("send_status","1");//已发布的状态 |
63 | |||
64 | String currentDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"); | ||
65 | queryWrapper.le("start_time",currentDate);// 当前时间 > 开始结束时间 | 66 | queryWrapper.le("start_time",currentDate);// 当前时间 > 开始结束时间 |
66 | queryWrapper.ge("end_time",currentDate); | 67 | queryWrapper.ge("end_time",currentDate); |
67 | IPage<Paper> pageList = paperService.page(page, queryWrapper); | 68 | IPage<Paper> pageList = paperService.page(page, queryWrapper);*/ |
69 | paper.setUserId(BaseContextHandler.getUserId()); | ||
70 | paper.setStartTime(DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); | ||
71 | paper.setEndTime( DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss") ); | ||
72 | IPage<Paper> pageList = paperService.queryMyPaperByList(page ,paper); | ||
68 | result.setSuccess(true); | 73 | result.setSuccess(true); |
69 | result.setResult(pageList); | 74 | result.setResult(pageList); |
70 | return result; | 75 | return result; |
76 | /* String currentDate = DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"); | ||
77 | StringBuffer sql = new StringBuffer(); | ||
78 | sql.append("select aaa.* from ( "); | ||
79 | sql.append(" select ifnull(up.user_id ,0) 'user_id', ifnull(count(up.id) ,0) as user_count, d.depart_name , p.* from edu_paper p "); | ||
80 | sql.append(" left join edu_user_paper up on p.id = up.paper_id "); | ||
81 | sql.append(" left join sys_depart d on p.depart_id = d.id"); | ||
82 | sql.append(" where p.send_status =1 and p.exam_user_ids like '%"+BaseContextHandler.getUserId()+"%'"); | ||
83 | if( paper.getDepartId() != null && paper.getDepartId().length() > 0){ | ||
84 | sql.append(" and p.depart_id= '"+paper.getDepartId()+"' "); | ||
85 | } | ||
86 | if( paper.getPaperTitle() != null && paper.getPaperTitle().length() > 0){ | ||
87 | sql.append(" and p.paper_title like '%"+paper.getPaperTitle()+"%' "); | ||
88 | } | ||
89 | if( paper.getDepartId() != null && paper.getDepartId().length() > 0){ | ||
90 | sql.append(" and p.depart_id= '"+paper.getDepartId()+"' "); | ||
91 | } | ||
92 | sql.append(" and p.send_time >= '"+currentDate+"' and and p.send_time <= '"+currentDate+"'"); | ||
93 | sql.append(" )aaa where aaa.user_id = 0 "); | ||
94 | // 分页查询 | ||
95 | Page<Map<String, Object>> pageList = iCommonSqlService.queryForPage(page, sql.toString()); | ||
96 | List<Paper> paperList = JoinSqlUtils.multiMaps2Beans(pageList.getRecords(), Paper.class); | ||
97 | //List<Paper> paperList = EquipmentUtils.equipEntities2VOs(dataList); | ||
98 | */ | ||
99 | |||
71 | } | 100 | } |
72 | 101 | ||
73 | // 根据试卷获取试题 | 102 | // 根据试卷获取试题 |
... | @@ -76,20 +105,21 @@ public class UserPaperController { | ... | @@ -76,20 +105,21 @@ public class UserPaperController { |
76 | @GetMapping(value = "/startExam") | 105 | @GetMapping(value = "/startExam") |
77 | public Result<PaperVO> startExam(@RequestParam(name="id",required=true) String id) { | 106 | public Result<PaperVO> startExam(@RequestParam(name="id",required=true) String id) { |
78 | Result<PaperVO> result = new Result<PaperVO>(); | 107 | Result<PaperVO> result = new Result<PaperVO>(); |
79 | Boolean flag = paperService.checkExamCount(id,BaseContextHandler.getUserId()); | 108 | PaperVO paperVO = paperService.queryById(id); |
109 | if(paperVO == null) { | ||
110 | result.error500("未找到对应实体"); | ||
111 | }else if( paperVO!= null && !"1".equals(paperVO.getSendStatus() ) ) { | ||
112 | result.error500("试卷未发布!"); | ||
113 | }else{ | ||
114 | result.setResult(paperVO); | ||
115 | result.setSuccess(true); | ||
116 | } | ||
117 | /* Boolean flag = paperService.checkExamCount(id,BaseContextHandler.getUserId()); | ||
80 | if(flag){ | 118 | if(flag){ |
81 | PaperVO paperVO = paperService.queryById(id); | 119 | |
82 | if(paperVO == null) { | ||
83 | result.error500("未找到对应实体"); | ||
84 | }else if( paperVO!= null && !"1".equals(paperVO.getSendStatus() ) ) { | ||
85 | result.error500("试卷未发布!"); | ||
86 | }else{ | ||
87 | result.setResult(paperVO); | ||
88 | result.setSuccess(true); | ||
89 | } | ||
90 | }else{ | 120 | }else{ |
91 | result.error500("考试次数已用完!不能参加考试"); | 121 | result.error500("考试次数已用完!不能参加考试"); |
92 | } | 122 | }*/ |
93 | return result; | 123 | return result; |
94 | } | 124 | } |
95 | // 在线答题 | 125 | // 在线答题 |
... | @@ -103,10 +133,13 @@ public class UserPaperController { | ... | @@ -103,10 +133,13 @@ public class UserPaperController { |
103 | Result<UserPaperVO> result = new Result<UserPaperVO>(); | 133 | Result<UserPaperVO> result = new Result<UserPaperVO>(); |
104 | String paperScore = "0"; | 134 | String paperScore = "0"; |
105 | try { | 135 | try { |
106 | userPaperVO.setEndTime(DateUtil.getCurrentDate()); | 136 | userPaperVO.setEndTime(DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); |
107 | userPaperVO.setUserId(BaseContextHandler.getUserId());//考试人编号 | 137 | userPaperVO.setUserId(BaseContextHandler.getUserId());//考试人编号 |
108 | paperScore = paperService.submitPaper(userPaperVO); | 138 | paperScore = paperService.submitPaper(userPaperVO); |
109 | userPaperVO.setScore( paperScore ); | 139 | userPaperVO.setScore( paperScore ); |
140 | |||
141 | //计算排名 | ||
142 | userPaperService.changeRankByPaperId(userPaperVO.getPaperId() ) ; | ||
110 | result.setResult( userPaperVO ); | 143 | result.setResult( userPaperVO ); |
111 | result.success("交卷成功!"); | 144 | result.success("交卷成功!"); |
112 | } catch (Exception e) { | 145 | } catch (Exception e) { |
... | @@ -127,24 +160,29 @@ public class UserPaperController { | ... | @@ -127,24 +160,29 @@ public class UserPaperController { |
127 | @AutoLog(value = "在线考试--历史试卷列表") | 160 | @AutoLog(value = "在线考试--历史试卷列表") |
128 | @ApiOperation(value="在线考试--历史试卷列表", notes="在线考试--历史试卷列表") | 161 | @ApiOperation(value="在线考试--历史试卷列表", notes="在线考试--历史试卷列表") |
129 | @GetMapping(value = "/historyList") | 162 | @GetMapping(value = "/historyList") |
130 | public Result<IPage<UserPaper>> historyList( | 163 | public Result<IPage<Paper>> historyList( |
131 | @RequestParam(name="paperId",required=true) String paperId, | 164 | Paper paper, |
132 | @RequestParam(name="userId") String userId, | ||
133 | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, | 165 | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
134 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, | 166 | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
135 | HttpServletRequest req) { | 167 | HttpServletRequest req) throws Exception { |
136 | Result<IPage<UserPaper>> result = new Result<IPage<UserPaper>>(); | 168 | Result<IPage<Paper>> result = new Result<IPage<Paper>>(); |
137 | QueryWrapper<UserPaper> queryWrapper = new QueryWrapper<>() ;// QueryGenerator.initQueryWrapper(paperAnswer, req.getParameterMap()); | 169 | /* StringBuffer sql = new StringBuffer(); |
138 | Page<UserPaper> page = new Page<UserPaper>(pageNo, pageSize); | 170 | sql.append("select up.score, p.* from edu_user_paper up "); |
139 | queryWrapper.eq("paper_id",paperId); | 171 | sql.append(" left join edu_paper p on p.id = up.paper_id "); |
140 | if(userId == null ){ | 172 | sql.append(" where up.user_id = '"+BaseContextHandler.getUserId()+"' "); |
141 | userId = BaseContextHandler.getUserId(); | 173 | |
142 | } | 174 | // 分页查询 |
143 | queryWrapper.eq("user_id",userId);//已发布的状态 | 175 | Page page = new Page(pageNo, pageSize); |
176 | Page<Map<String, Object>> pageList = iCommonSqlService.queryForPage(page, sql.toString()); | ||
177 | List<Paper> paperList = JoinSqlUtils.multiMaps2Beans(pageList.getRecords(), Paper.class); | ||
178 | */ | ||
144 | 179 | ||
145 | IPage<UserPaper> pageList = userPaperService.page(page, queryWrapper); | 180 | Page<Paper> page = new Page<Paper>(pageNo, pageSize); |
181 | paper.setUserId(BaseContextHandler.getUserId());//获取当前用户编号 | ||
182 | IPage<Paper> paperList = paperService.queryMyPaperRecoredByList(page,paper); | ||
183 | |||
184 | result.setResult(paperList); | ||
146 | result.setSuccess(true); | 185 | result.setSuccess(true); |
147 | result.setResult(pageList); | ||
148 | return result; | 186 | return result; |
149 | } | 187 | } |
150 | //历史试卷详情 history_detail | 188 | //历史试卷详情 history_detail |
... | @@ -214,7 +252,7 @@ public class UserPaperController { | ... | @@ -214,7 +252,7 @@ public class UserPaperController { |
214 | paragraphOption = document.createParagraph(); | 252 | paragraphOption = document.createParagraph(); |
215 | setHight( paragraphOption , "500" ); | 253 | setHight( paragraphOption , "500" ); |
216 | optionRun = paragraphOption.createRun(); | 254 | optionRun = paragraphOption.createRun(); |
217 | optionRun.setText(" "+option.getAlias()+"."+ option.getOptionTitle()); | 255 | optionRun.setText(" "+option.getAlias()+". "+ option.getOptionTitle()); |
218 | } | 256 | } |
219 | } | 257 | } |
220 | index++; | 258 | index++; | ... | ... |
... | @@ -127,4 +127,26 @@ public class Paper { | ... | @@ -127,4 +127,26 @@ public class Paper { |
127 | @ApiModelProperty(value = "delFlag") | 127 | @ApiModelProperty(value = "delFlag") |
128 | private Integer delFlag; | 128 | private Integer delFlag; |
129 | 129 | ||
130 | |||
131 | @TableField(exist=false) | ||
132 | @ApiModelProperty(value = "考试人次") | ||
133 | private Integer userCount ; | ||
134 | |||
135 | @TableField(exist=false) | ||
136 | @ApiModelProperty(value = "扩展:考试人员") | ||
137 | private String userId; | ||
138 | |||
139 | @TableField(exist=false) | ||
140 | @ApiModelProperty(value = "扩展:考试分数") | ||
141 | private String score; | ||
142 | @TableField(exist=false) | ||
143 | @ApiModelProperty(value = "扩展:考试名次") | ||
144 | private String rank; | ||
145 | |||
146 | |||
147 | @TableField(exist=false) | ||
148 | @ApiModelProperty(value = "扩展:用户考试试卷编号") | ||
149 | private String userPaperId; | ||
150 | |||
151 | |||
130 | } | 152 | } | ... | ... |
... | @@ -2,6 +2,8 @@ package com.skua.modules.edu.mapper; | ... | @@ -2,6 +2,8 @@ package com.skua.modules.edu.mapper; |
2 | 2 | ||
3 | import java.util.List; | 3 | import java.util.List; |
4 | 4 | ||
5 | import com.baomidou.mybatisplus.core.metadata.IPage; | ||
6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
5 | import org.apache.ibatis.annotations.Param; | 7 | import org.apache.ibatis.annotations.Param; |
6 | import com.skua.modules.edu.entity.Paper; | 8 | import com.skua.modules.edu.entity.Paper; |
7 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 9 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
... | @@ -10,5 +12,20 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ... | @@ -10,5 +12,20 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
10 | * 在线考试-试卷 | 12 | * 在线考试-试卷 |
11 | */ | 13 | */ |
12 | public interface PaperMapper extends BaseMapper<Paper> { | 14 | public interface PaperMapper extends BaseMapper<Paper> { |
15 | /*** | ||
16 | * 我的试卷列表 | ||
17 | * @param page | ||
18 | * @param paper | ||
19 | * @return | ||
20 | */ | ||
21 | IPage<Paper> queryMyPaperByList(Page<Paper> page, @Param("param") Paper paper); | ||
22 | |||
23 | /*** | ||
24 | * 我的试卷记录 | ||
25 | * @param page | ||
26 | * @param paper | ||
27 | * @return | ||
28 | */ | ||
29 | IPage<Paper> queryMyPaperRecoredByList(Page<Paper> page, @Param("param") Paper paper); | ||
13 | 30 | ||
14 | } | 31 | } | ... | ... |
... | @@ -25,4 +25,10 @@ public interface QuestionMapper extends BaseMapper<Question> { | ... | @@ -25,4 +25,10 @@ public interface QuestionMapper extends BaseMapper<Question> { |
25 | */ | 25 | */ |
26 | public List<Question> selectListByPaperIdAndUserId(@Param("paperId") String paperId,@Param("userPaperId") String userPaperId); | 26 | public List<Question> selectListByPaperIdAndUserId(@Param("paperId") String paperId,@Param("userPaperId") String userPaperId); |
27 | 27 | ||
28 | /*** | ||
29 | * 校验试题是否被试卷使用 | ||
30 | * @param questionId | ||
31 | * @return | ||
32 | */ | ||
33 | public int checkByPaper(@Param("questionId")String questionId); | ||
28 | } | 34 | } | ... | ... |
... | @@ -27,4 +27,12 @@ public interface UserPaperMapper extends BaseMapper<UserPaper> { | ... | @@ -27,4 +27,12 @@ public interface UserPaperMapper extends BaseMapper<UserPaper> { |
27 | public UserPaper queryLastOne(String paperId, String userId); | 27 | public UserPaper queryLastOne(String paperId, String userId); |
28 | 28 | ||
29 | public int queryPaperCount(String paperId, String userId); | 29 | public int queryPaperCount(String paperId, String userId); |
30 | |||
31 | /*** | ||
32 | * 设置试卷的考试排名 | ||
33 | * @param paperId | ||
34 | * @return | ||
35 | */ | ||
36 | public int changeRankByPaperId( @Param("paperId") String paperId); | ||
37 | |||
30 | } | 38 | } | ... | ... |
... | @@ -2,4 +2,38 @@ | ... | @@ -2,4 +2,38 @@ |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | <mapper namespace="com.skua.modules.edu.mapper.PaperMapper"> | 3 | <mapper namespace="com.skua.modules.edu.mapper.PaperMapper"> |
4 | 4 | ||
5 | <!-- 我的考试列表 --> | ||
6 | <select id="queryMyPaperByList" resultType="com.skua.modules.edu.entity.Paper"> | ||
7 | select aaa.* from ( | ||
8 | select d.depart_name , IFNULL(up.user_id,0) 'user_id', | ||
9 | p.* ,( select count(1) from edu_user_paper up where up.paper_id = p.id ) 'user_count' | ||
10 | from edu_paper p | ||
11 | left join sys_depart d on p.depart_id = d.id | ||
12 | left join edu_user_paper up on p.id = up.paper_id and up.user_id = #{param.userId} | ||
13 | where | ||
14 | p.send_status =1 | ||
15 | <if test="param.userId != null and param.userId !=''"> | ||
16 | and p.exam_user_ids like CONCAT('%',#{param.userId},'%') | ||
17 | </if> | ||
18 | <if test="param.departId != null and param.departId !=''"> | ||
19 | and p.depart_id = #{param.departId} | ||
20 | </if> | ||
21 | )aaa where aaa.user_id > 0 | ||
22 | <!-- <if test="param.startTime != null and param.startTime !=''"> | ||
23 | and p.start_time <= #{param.startTime} | ||
24 | </if> | ||
25 | <if test="param.endTime != null and param.endTime !=''"> | ||
26 | and p.end_time >= #{param.endTime} | ||
27 | </if>--> | ||
28 | </select> | ||
29 | |||
30 | <!-- 考试记录--> | ||
31 | <select id="queryMyPaperRecoredByList" resultType="com.skua.modules.edu.entity.Paper"> | ||
32 | select up.score, up.rank,up.id as 'user_paper_id', p.* from edu_user_paper up | ||
33 | left join edu_paper p on p.id = up.paper_id | ||
34 | where up.user_id = #{param.userId} | ||
35 | order by up.start_time desc | ||
36 | </select> | ||
37 | |||
38 | |||
5 | </mapper> | 39 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -19,7 +19,9 @@ | ... | @@ -19,7 +19,9 @@ |
19 | where pq.paper_id = #{paperId} | 19 | where pq.paper_id = #{paperId} |
20 | </select> | 20 | </select> |
21 | 21 | ||
22 | 22 | <select id="checkByPaper" resultType="java.lang.Integer"> | |
23 | select count(1) from edu_paper_question where question_id =#{questionId} | ||
24 | </select> | ||
23 | 25 | ||
24 | 26 | ||
25 | </mapper> | 27 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -4,9 +4,10 @@ | ... | @@ -4,9 +4,10 @@ |
4 | 4 | ||
5 | <!-- 校对答案,设置试题分值--> | 5 | <!-- 校对答案,设置试题分值--> |
6 | <update id="checkAnswerByUserPaperId" > | 6 | <update id="checkAnswerByUserPaperId" > |
7 | update edu_user_answer ua , edu_question q ,edu_paper_question pq | 7 | update edu_user_answer ua , edu_question q ,edu_paper_question pq |
8 | set ua.score = pq.score | 8 | set ua.score = pq.score |
9 | where ua.user_paper_id = #{userPaperId} and ua.question_id = q.id and ua.answer = q.question_answer and pq.question_id = ua.question_id ; | 9 | where q.id = ua.question_id and q.id = pq.question_id and ua.paper_id = pq.paper_id |
10 | and ua.user_paper_id =#{userPaperId} | ||
10 | </update> | 11 | </update> |
11 | 12 | ||
12 | </mapper> | 13 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
9 | 9 | ||
10 | 10 | ||
11 | <select id="queryLastOne" resultType="com.skua.modules.edu.entity.UserPaper"> | 11 | <select id="queryLastOne" resultType="com.skua.modules.edu.entity.UserPaper"> |
12 | select t.* from edu_user_answer t where t.paper_id = #{paperId} and t.user_id = #{userId} | 12 | select t.* from edu_user_answer t where t.paper_id = #{paperId} and t.user_id = #{userId} limit 1 |
13 | </select> | 13 | </select> |
14 | 14 | ||
15 | 15 | ||
... | @@ -17,4 +17,18 @@ | ... | @@ -17,4 +17,18 @@ |
17 | select IFNULL(count(1 ),'0') as 'userExamCount' from edu_user_answer where paper_id = #{paperId} and user_id = #{userId} | 17 | select IFNULL(count(1 ),'0') as 'userExamCount' from edu_user_answer where paper_id = #{paperId} and user_id = #{userId} |
18 | </select> | 18 | </select> |
19 | 19 | ||
20 | <!-- 设置试卷的考试排名--> | ||
21 | <update id="changeRankByPaperId" > | ||
22 | update edu_user_paper up ,( | ||
23 | SELECT | ||
24 | a.user_id , | ||
25 | ( SELECT count( DISTINCT b.score ) + 1 FROM edu_user_paper b WHERE b.score > a.score and b.paper_id = #{paperId} ) sort | ||
26 | FROM | ||
27 | edu_user_paper a | ||
28 | where a.paper_id = #{paperId} | ||
29 | )aaa set up.rank = aaa.sort | ||
30 | |||
31 | where up.paper_id =#{paperId} and up.user_id = aaa.user_id | ||
32 | </update> | ||
33 | |||
20 | </mapper> | 34 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | package com.skua.modules.edu.service; | 1 | package com.skua.modules.edu.service; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.metadata.IPage; | ||
4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
3 | import com.skua.modules.edu.entity.Paper; | 5 | import com.skua.modules.edu.entity.Paper; |
4 | import com.baomidou.mybatisplus.extension.service.IService; | 6 | import com.baomidou.mybatisplus.extension.service.IService; |
5 | import com.skua.modules.edu.entity.Question; | 7 | import com.skua.modules.edu.entity.Question; |
... | @@ -56,4 +58,21 @@ public interface IPaperService extends IService<Paper> { | ... | @@ -56,4 +58,21 @@ public interface IPaperService extends IService<Paper> { |
56 | * @return | 58 | * @return |
57 | */ | 59 | */ |
58 | public Boolean checkExamCount(String paperId, String userId); | 60 | public Boolean checkExamCount(String paperId, String userId); |
61 | |||
62 | /*** | ||
63 | * 我的试卷列表 | ||
64 | * @param page | ||
65 | * @param paper | ||
66 | * @return | ||
67 | */ | ||
68 | IPage<Paper> queryMyPaperByList(Page<Paper> page, Paper paper); | ||
69 | |||
70 | /*** | ||
71 | * 我的试卷记录 | ||
72 | * @param page | ||
73 | * @param paper | ||
74 | * @return | ||
75 | */ | ||
76 | IPage<Paper> queryMyPaperRecoredByList(Page<Paper> page, Paper paper); | ||
77 | |||
59 | } | 78 | } | ... | ... |
... | @@ -29,4 +29,12 @@ public interface IQuestionService extends IService<Question> { | ... | @@ -29,4 +29,12 @@ public interface IQuestionService extends IService<Question> { |
29 | * @return | 29 | * @return |
30 | */ | 30 | */ |
31 | public Question queryById(String id); | 31 | public Question queryById(String id); |
32 | |||
33 | |||
34 | /*** | ||
35 | * 校验 试题是否被试卷使用,如果使用返回true,未使用返回false | ||
36 | * @param questionId | ||
37 | * @return | ||
38 | */ | ||
39 | public boolean checkByPaper(String questionId); | ||
32 | } | 40 | } | ... | ... |
... | @@ -2,10 +2,16 @@ package com.skua.modules.edu.service; | ... | @@ -2,10 +2,16 @@ package com.skua.modules.edu.service; |
2 | 2 | ||
3 | import com.skua.modules.edu.entity.UserPaper; | 3 | import com.skua.modules.edu.entity.UserPaper; |
4 | import com.baomidou.mybatisplus.extension.service.IService; | 4 | import com.baomidou.mybatisplus.extension.service.IService; |
5 | import org.apache.ibatis.annotations.Param; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * 在线考试 | 8 | * 在线考试 |
8 | */ | 9 | */ |
9 | public interface IUserPaperService extends IService<UserPaper> { | 10 | public interface IUserPaperService extends IService<UserPaper> { |
10 | 11 | /*** | |
12 | * 设置试卷的考试排名 | ||
13 | * @param paperId | ||
14 | * @return | ||
15 | */ | ||
16 | public int changeRankByPaperId( String paperId); | ||
11 | } | 17 | } | ... | ... |
1 | package com.skua.modules.edu.service.impl; | 1 | package com.skua.modules.edu.service.impl; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.metadata.IPage; | ||
4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
3 | import com.google.gson.Gson; | 5 | import com.google.gson.Gson; |
4 | import com.google.gson.reflect.TypeToken; | 6 | import com.google.gson.reflect.TypeToken; |
5 | import com.skua.core.context.BaseContextHandler; | 7 | import com.skua.core.context.BaseContextHandler; |
... | @@ -96,17 +98,17 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements | ... | @@ -96,17 +98,17 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements |
96 | PaperVO paperVO = new PaperVO();// | 98 | PaperVO paperVO = new PaperVO();// |
97 | if( paper != null ){ | 99 | if( paper != null ){ |
98 | BeanUtils.copyProperties(paper, paperVO); | 100 | BeanUtils.copyProperties(paper, paperVO); |
99 | List<Question> questionList = questionMapper.selectListByPaperId(id); | 101 | List<Question> questionList = questionMapper.selectListByPaperId(id); |
100 | List<QuestionOption> optionList = null; | 102 | List<QuestionOption> optionList = null; |
101 | if(questionList != null && !questionList.isEmpty()){ | 103 | if(questionList != null && !questionList.isEmpty()){ |
102 | // 创建Gson实例 | 104 | // 创建Gson实例 |
103 | Gson gson = new Gson(); | 105 | Gson gson = new Gson(); |
104 | Type questionTypeListType = new TypeToken<List<QuestionOption>>() {}.getType(); | 106 | Type questionTypeListType = new TypeToken<List<QuestionOption>>() {}.getType(); |
105 | for( Question question : questionList){ | 107 | for( Question question : questionList){ |
106 | optionList = gson.fromJson(question.getQuestionData(),questionTypeListType); | 108 | optionList = gson.fromJson(question.getQuestionData(),questionTypeListType); |
107 | question.setOptionList(optionList ); | 109 | question.setOptionList(optionList ); |
108 | } | 110 | } |
109 | } | 111 | } |
110 | paperVO.setQuestionList(questionList); | 112 | paperVO.setQuestionList(questionList); |
111 | } | 113 | } |
112 | return paperVO; | 114 | return paperVO; |
... | @@ -159,6 +161,25 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements | ... | @@ -159,6 +161,25 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements |
159 | } | 161 | } |
160 | 162 | ||
161 | /*** | 163 | /*** |
164 | * 我的试卷列表 | ||
165 | * @param page | ||
166 | * @param paper | ||
167 | * @return | ||
168 | */ | ||
169 | public IPage<Paper> queryMyPaperByList(Page<Paper> page, Paper paper){ | ||
170 | return this.baseMapper.queryMyPaperByList(page,paper) ; | ||
171 | } | ||
172 | /*** | ||
173 | * 我的试卷记录 | ||
174 | * @param page | ||
175 | * @param paper | ||
176 | * @return | ||
177 | */ | ||
178 | public IPage<Paper> queryMyPaperRecoredByList(Page<Paper> page, Paper paper){ | ||
179 | return this.baseMapper.queryMyPaperRecoredByList(page,paper) ; | ||
180 | } | ||
181 | |||
182 | /*** | ||
162 | * 交卷 | 183 | * 交卷 |
163 | * @param paperVO | 184 | * @param paperVO |
164 | */ | 185 | */ |
... | @@ -187,14 +208,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements | ... | @@ -187,14 +208,10 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements |
187 | userPaperMapper.updateById( userPaper); | 208 | userPaperMapper.updateById( userPaper); |
188 | 209 | ||
189 | //计算分数 | 210 | //计算分数 |
190 | // answer.setScore( totalScore ); | 211 | // answer.setScore( totalScore ); |
191 | // answerMapper.updateById( answer ) ; | 212 | // answerMapper.updateById( answer ) ; |
192 | return totalScore; | 213 | return totalScore; |
193 | } | 214 | } |
194 | |||
195 | /* public String queryPaperScore(String paperId,String userId){ | 215 | /* public String queryPaperScore(String paperId,String userId){ |
196 | |||
197 | }*/ | 216 | }*/ |
198 | |||
199 | |||
200 | } | 217 | } | ... | ... |
... | @@ -91,4 +91,14 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i | ... | @@ -91,4 +91,14 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i |
91 | return question; | 91 | return question; |
92 | } | 92 | } |
93 | 93 | ||
94 | /*** | ||
95 | * 校验 试题是否被试卷使用 | ||
96 | * @param questionId | ||
97 | * @return | ||
98 | */ | ||
99 | public boolean checkByPaper(String questionId){ | ||
100 | int count = this.baseMapper.checkByPaper( questionId ); | ||
101 | return count > 0?true:false; | ||
102 | } | ||
103 | |||
94 | } | 104 | } | ... | ... |
... | @@ -12,5 +12,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ... | @@ -12,5 +12,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
12 | */ | 12 | */ |
13 | @Service | 13 | @Service |
14 | public class UserPaperServiceImpl extends ServiceImpl<UserPaperMapper, UserPaper> implements IUserPaperService { | 14 | public class UserPaperServiceImpl extends ServiceImpl<UserPaperMapper, UserPaper> implements IUserPaperService { |
15 | 15 | /*** | |
16 | * 设置试卷的考试排名 | ||
17 | * @param paperId | ||
18 | * @return | ||
19 | */ | ||
20 | public int changeRankByPaperId( String paperId){ | ||
21 | return this.baseMapper.changeRankByPaperId(paperId); | ||
22 | } | ||
16 | } | 23 | } | ... | ... |
... | @@ -28,7 +28,6 @@ public class PaperVO extends Paper { | ... | @@ -28,7 +28,6 @@ public class PaperVO extends Paper { |
28 | @ApiModelProperty(value = "试卷试题集合") | 28 | @ApiModelProperty(value = "试卷试题集合") |
29 | private List<Question> questionList; | 29 | private List<Question> questionList; |
30 | 30 | ||
31 | @ApiModelProperty(value = "参加考试人员") | 31 | |
32 | private String userId; | ||
33 | 32 | ||
34 | } | 33 | } | ... | ... |
... | @@ -73,6 +73,20 @@ public class DistributContractController { | ... | @@ -73,6 +73,20 @@ public class DistributContractController { |
73 | return result; | 73 | return result; |
74 | } | 74 | } |
75 | 75 | ||
76 | |||
77 | @AutoLog(value = "erp分销合同-列表查询") | ||
78 | @ApiOperation(value="erp分销合同-分页列表查询", notes="erp分销合同-分页列表查询") | ||
79 | @GetMapping(value = "/disContractList") | ||
80 | public Result<List<DistributContract>> queryPageList(DistributContract distributContract, | ||
81 | HttpServletRequest req) { | ||
82 | Result<List<DistributContract>> result = new Result<List<DistributContract>>(); | ||
83 | QueryWrapper<DistributContract> queryWrapper = QueryGenerator.initQueryWrapper(distributContract, req.getParameterMap()); | ||
84 | |||
85 | List<DistributContract> dataList = distributContractService.list(queryWrapper); | ||
86 | result.setSuccess(true); | ||
87 | result.setResult(dataList); | ||
88 | return result; | ||
89 | } | ||
76 | @AutoLog(value = "erp分销合同-添加") | 90 | @AutoLog(value = "erp分销合同-添加") |
77 | @ApiOperation(value="erp分销合同-添加", notes="erp分销合同-添加") | 91 | @ApiOperation(value="erp分销合同-添加", notes="erp分销合同-添加") |
78 | @PostMapping(value = "/add") | 92 | @PostMapping(value = "/add") | ... | ... |
... | @@ -10,13 +10,10 @@ import javax.servlet.http.HttpServletRequest; | ... | @@ -10,13 +10,10 @@ import javax.servlet.http.HttpServletRequest; |
10 | import javax.servlet.http.HttpServletResponse; | 10 | import javax.servlet.http.HttpServletResponse; |
11 | import com.skua.core.api.vo.Result; | 11 | import com.skua.core.api.vo.Result; |
12 | import com.skua.core.aspect.annotation.AutoLog; | 12 | import com.skua.core.aspect.annotation.AutoLog; |
13 | import com.skua.core.context.BaseContextHandler; | ||
14 | import com.skua.core.query.QueryGenerator; | 13 | import com.skua.core.query.QueryGenerator; |
15 | import com.skua.core.service.ISequenceService; | ||
16 | import com.skua.core.util.ConvertUtils; | 14 | import com.skua.core.util.ConvertUtils; |
17 | import com.skua.modules.erp.entity.MaterialAcceptanceForm; | 15 | import com.skua.modules.erp.entity.MaterialAcceptanceForm; |
18 | import com.skua.modules.erp.service.IMaterialAcceptanceFormService; | 16 | import com.skua.modules.erp.service.IMaterialAcceptanceFormService; |
19 | import java.util.Date; | ||
20 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 17 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
21 | import com.baomidou.mybatisplus.core.metadata.IPage; | 18 | import com.baomidou.mybatisplus.core.metadata.IPage; |
22 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 19 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ... | ... |
... | @@ -10,9 +10,7 @@ import javax.servlet.http.HttpServletRequest; | ... | @@ -10,9 +10,7 @@ import javax.servlet.http.HttpServletRequest; |
10 | import javax.servlet.http.HttpServletResponse; | 10 | import javax.servlet.http.HttpServletResponse; |
11 | import com.skua.core.api.vo.Result; | 11 | import com.skua.core.api.vo.Result; |
12 | import com.skua.core.aspect.annotation.AutoLog; | 12 | import com.skua.core.aspect.annotation.AutoLog; |
13 | import com.skua.core.context.BaseContextHandler; | ||
14 | import com.skua.core.query.QueryGenerator; | 13 | import com.skua.core.query.QueryGenerator; |
15 | import com.skua.core.service.ISequenceService; | ||
16 | import com.skua.core.util.ConvertUtils; | 14 | import com.skua.core.util.ConvertUtils; |
17 | import com.skua.modules.erp.entity.MaterialIN; | 15 | import com.skua.modules.erp.entity.MaterialIN; |
18 | import com.skua.modules.erp.service.IMaterialINService; | 16 | import com.skua.modules.erp.service.IMaterialINService; | ... | ... |
-
请 注册 或 登录 后发表评论