Commit e9060230a3e07434bd86cc443b851eb0acc5d665
1 parent
039f5e9f
考生成绩查询代码提交
Showing
6 changed files
with
365 additions
and
3 deletions
src/main/java/com/bsth/controller/subject/SubjectUserController.java
| ... | ... | @@ -29,6 +29,16 @@ public class SubjectUserController extends BaseController<SubjectUser, Integer> |
| 29 | 29 | public String determine(@RequestParam("id") Integer id){ |
| 30 | 30 | return subjectUserService.determine(id); |
| 31 | 31 | } |
| 32 | + | |
| 33 | + @RequestMapping("/subjectUserList") | |
| 34 | + public List<Map<String,Object>> subjectUserList(@RequestParam Map<String, Object> map){ | |
| 35 | + return subjectUserService.subjectUserList(map); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @RequestMapping("/subjectUserDetail") | |
| 39 | + public List<Map<String,Object>> subjectUserDetail(@RequestParam Map<String, Object> map){ | |
| 40 | + return subjectUserService.subjectUserDetail(map); | |
| 41 | + } | |
| 32 | 42 | |
| 33 | 43 | |
| 34 | 44 | } | ... | ... |
src/main/java/com/bsth/repository/subject/SubjectUserRepository.java
| ... | ... | @@ -18,4 +18,15 @@ public interface SubjectUserRepository extends BaseRepository<SubjectUser, Integ |
| 18 | 18 | @Modifying |
| 19 | 19 | @Query(value = "update SubjectUser su set su.result =?1 where su.id =?2") |
| 20 | 20 | int updates(String rq, Integer userId); |
| 21 | + | |
| 22 | + @Query(value="select su.user_id,su.rq,su.result,u.name,u.user_name " | |
| 23 | + + " from bsth_subject_user su,bsth_c_sys_user u where su.user_id =u.id and su.rq =?1 and su.user_id in ( ?2 ) " | |
| 24 | + + " order by su.user_id",nativeQuery=true) | |
| 25 | + List<Object[]> searchSubjectUserByUserId(String rq, List<String> userIds); | |
| 26 | + | |
| 27 | + @Query(value="select su.subject_id,su.rq,su.result,s.subject_text,s.operate_test " | |
| 28 | + + " from bsth_subject_user su,bsth_subject s where su.subject_id =s.id and su.rq =?1 and su.user_id = ?2 " | |
| 29 | + + " order by su.user_id",nativeQuery=true) | |
| 30 | + List<Object[]> searchSubjectUserDetail(String rq, String userId); | |
| 31 | + | |
| 21 | 32 | } | ... | ... |
src/main/java/com/bsth/service/subject/SubjectUserService.java
| ... | ... | @@ -4,6 +4,7 @@ import com.bsth.entity.subject.SubjectUser; |
| 4 | 4 | import com.bsth.service.BaseService; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| 7 | +import java.util.Map; | |
| 7 | 8 | |
| 8 | 9 | public interface SubjectUserService extends BaseService<SubjectUser, Integer> { |
| 9 | 10 | |
| ... | ... | @@ -11,4 +12,8 @@ public interface SubjectUserService extends BaseService<SubjectUser, Integer> { |
| 11 | 12 | List<SubjectUser> userAll(); |
| 12 | 13 | |
| 13 | 14 | String determine(Integer id); |
| 15 | + | |
| 16 | + List<Map<String,Object>> subjectUserList(Map<String, Object> map); | |
| 17 | + | |
| 18 | + List<Map<String,Object>> subjectUserDetail(Map<String, Object> map); | |
| 14 | 19 | } | ... | ... |
src/main/java/com/bsth/service/subject/impl/SubjectUserServiceImpl.java
| ... | ... | @@ -7,26 +7,33 @@ import com.bsth.entity.subject.SubjectUser; |
| 7 | 7 | import com.bsth.entity.sys.SysUser; |
| 8 | 8 | import com.bsth.repository.LineRepository; |
| 9 | 9 | import com.bsth.repository.subject.SubjectUserRepository; |
| 10 | +import com.bsth.repository.sys.SysUserRepository; | |
| 10 | 11 | import com.bsth.security.util.SecurityUtils; |
| 11 | -import com.bsth.service.impl.BaseServiceImpl; | |
| 12 | +import com.bsth.service.impl.BaseServiceImpl; | |
| 12 | 13 | import com.bsth.service.subject.SubjectUserService; |
| 13 | 14 | import com.bsth.util.subject.subEnum; |
| 15 | +import org.slf4j.Logger; | |
| 16 | +import org.slf4j.LoggerFactory; | |
| 14 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 18 | import org.springframework.stereotype.Service; |
| 16 | 19 | |
| 17 | 20 | import java.text.SimpleDateFormat; |
| 18 | 21 | import java.util.*; |
| 22 | +import java.util.stream.Collectors; | |
| 19 | 23 | |
| 20 | 24 | @Service |
| 21 | 25 | public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer> implements SubjectUserService { |
| 22 | 26 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 23 | - | |
| 27 | + | |
| 28 | + private static final Logger LOGGER = LoggerFactory.getLogger(SubjectUserServiceImpl.class); | |
| 24 | 29 | @Autowired |
| 25 | 30 | SubjectUserRepository subjectUserRepository; |
| 26 | 31 | @Autowired |
| 27 | 32 | LineRepository lineRepository; |
| 28 | 33 | @Autowired |
| 29 | 34 | DayOfSchedule dayOfSchedule; |
| 35 | + @Autowired | |
| 36 | + SysUserRepository sysUserRepository; | |
| 30 | 37 | |
| 31 | 38 | public List<SubjectUser> userAll(){ |
| 32 | 39 | SysUser user = SecurityUtils.getCurrentUser(); |
| ... | ... | @@ -75,7 +82,110 @@ public class SubjectUserServiceImpl extends BaseServiceImpl<SubjectUser, Integer |
| 75 | 82 | } |
| 76 | 83 | |
| 77 | 84 | |
| 78 | - | |
| 85 | + @Override | |
| 86 | + public List<Map<String, Object>> subjectUserList(Map<String, Object> map) { | |
| 87 | + List<Map<String,Object>> results=new ArrayList<>(); | |
| 88 | + String date=map.get("date").toString(); | |
| 89 | + String userName=map.get("userName").toString(); | |
| 90 | + try { | |
| 91 | + List<String> users=new ArrayList<>(); | |
| 92 | + if(userName.equals("")){ | |
| 93 | + SysUser loginUser = SecurityUtils.getCurrentUser(); | |
| 94 | + List<SysUser> userList=sysUserRepository.findByParentID(String.valueOf(loginUser.getId()));;//根据教师id查询所属学生id | |
| 95 | + for (SysUser user : userList) { | |
| 96 | + users.add(String.valueOf(user.getId())); | |
| 97 | + } | |
| 98 | + }else { | |
| 99 | + SysUser user=sysUserRepository.findByUserName(userName); | |
| 100 | + users.add(String.valueOf(user.getId())); | |
| 101 | + } | |
| 102 | + List<Map<String,Object>> subjectUserList=new ArrayList<>(); | |
| 103 | + List<Object[]> objects = subjectUserRepository.searchSubjectUserByUserId(date,users); | |
| 104 | + int len = objects.size(); | |
| 105 | + if(len>0) { | |
| 106 | + for(int i = 0 ; i < len; i++) { | |
| 107 | + Map<String, Object> tempM = new HashMap<String,Object>(); | |
| 108 | + tempM.put("userId", objects.get(i)[0]); | |
| 109 | + tempM.put("rq", objects.get(i)[1]); | |
| 110 | + tempM.put("result", objects.get(i)[2]); | |
| 111 | + tempM.put("name", objects.get(i)[3]); | |
| 112 | + tempM.put("userName", objects.get(i)[4]); | |
| 113 | + subjectUserList.add(tempM); | |
| 114 | + } | |
| 115 | + } | |
| 116 | + Map<String,List<Map<String,Object>>>m=subjectUserList.stream().collect(Collectors.groupingBy(group->group.get("userId").toString())); | |
| 117 | + m.forEach((k,v)->{ | |
| 118 | + Map<String,Object> result=new HashMap<>(); | |
| 119 | + int sum=0; | |
| 120 | + int t=0; | |
| 121 | + int f=0; | |
| 122 | + int na=0; | |
| 123 | + for (Map<String,Object> su : v) { | |
| 124 | + sum++; | |
| 125 | + if(su.get("result")==null||"".equals(su.get("result"))){ | |
| 126 | + na++; | |
| 127 | + } | |
| 128 | + else if("0".equals(su.get("result").toString())){ | |
| 129 | + t++; | |
| 130 | + }else if("1".equals(su.get("result").toString())){ | |
| 131 | + f++; | |
| 132 | + } | |
| 133 | + } | |
| 134 | + if(v.size()>0){ | |
| 135 | + Map<String,Object> su=v.get(0); | |
| 136 | + result.put("userId",su.get("userId")); | |
| 137 | + result.put("rq",su.get("rq")); | |
| 138 | + result.put("name",su.get("name")); | |
| 139 | + result.put("userName",su.get("name")); | |
| 140 | + result.put("sum",sum); | |
| 141 | + result.put("t",t); | |
| 142 | + result.put("f",f); | |
| 143 | + result.put("na",na); | |
| 144 | + results.add(result); | |
| 145 | + } | |
| 146 | + }); | |
| 147 | + | |
| 148 | + } catch (Exception e) { | |
| 149 | + LOGGER.error("",e); | |
| 150 | + // TODO: handle exception | |
| 151 | + } | |
| 152 | + return results; | |
| 153 | + } | |
| 154 | + | |
| 155 | + | |
| 156 | + @Override | |
| 157 | + public List<Map<String, Object>> subjectUserDetail(Map<String, Object> map) { | |
| 158 | + List<Map<String,Object>> results=new ArrayList<>(); | |
| 159 | + String date=map.get("rq").toString(); | |
| 160 | + String userId=map.get("userId").toString(); | |
| 161 | + try { | |
| 162 | + List<Object[]> objects = subjectUserRepository.searchSubjectUserDetail(date,userId); | |
| 163 | + int len = objects.size(); | |
| 164 | + if(len>0) { | |
| 165 | + for(int i = 0 ; i < len; i++) { | |
| 166 | + Map<String, Object> tempM = new HashMap<String,Object>(); | |
| 167 | + tempM.put("subjectId", objects.get(i)[0]); | |
| 168 | + tempM.put("rq", objects.get(i)[1]); | |
| 169 | + String result = null; | |
| 170 | + if (objects.get(i)[2]==null||"".equals(objects.get(i)[2])){ | |
| 171 | + result="未答"; | |
| 172 | + }else if ("0".equals(objects.get(i)[2])){ | |
| 173 | + result="正确"; | |
| 174 | + }else if ("1".equals(objects.get(i)[2])){ | |
| 175 | + result="错误"; | |
| 176 | + } | |
| 177 | + tempM.put("result",result); | |
| 178 | + tempM.put("subjectText", objects.get(i)[3]); | |
| 179 | + tempM.put("operateTest", objects.get(i)[4]); | |
| 180 | + results.add(tempM); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + } catch (Exception e) { | |
| 184 | + LOGGER.error("",e); | |
| 185 | + // TODO: handle exception | |
| 186 | + } | |
| 187 | + return results; | |
| 188 | + } | |
| 79 | 189 | |
| 80 | 190 | |
| 81 | 191 | } | ... | ... |
src/main/resources/static/pages/subjectUser/subjectUserDetailList.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; } | |
| 11 | + .table-bordered > thead > tr > th, | |
| 12 | + .table-bordered > thead > tr > td { | |
| 13 | + border-bottom-width: 2px; } | |
| 14 | + | |
| 15 | + .table > tbody + tbody { | |
| 16 | + border-top: 1px solid; } | |
| 17 | +</style> | |
| 18 | + | |
| 19 | +<div class="row" id="subjectUserDetailList"> | |
| 20 | + <div class="col-md-12"> | |
| 21 | + <div class="portlet light porttlet-fit bordered"> | |
| 22 | + <div class="portlet-body"> | |
| 23 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 600px"> | |
| 24 | + <table class="table table-bordered table-hover table-checkable" id="forms_2"> | |
| 25 | + <thead> | |
| 26 | + <tr> | |
| 27 | + <td style="min-width: 40px">题号</td> | |
| 28 | + <td style="min-width: 100px">日期</td> | |
| 29 | + <td style="min-width: 150px">题目</td> | |
| 30 | + <td style="min-width: 150px">操作</td> | |
| 31 | + <td style="min-width: 150px">结果</td> | |
| 32 | + <td style="min-width: 50px">成绩</td> | |
| 33 | + </tr> | |
| 34 | + </thead> | |
| 35 | + <tbody> | |
| 36 | + </tbody> | |
| 37 | + </table> | |
| 38 | + </div> | |
| 39 | + </div> | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | +</div> | |
| 43 | +<script> | |
| 44 | + $(function(){ | |
| 45 | + // 关闭左侧栏 | |
| 46 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 47 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 48 | + var userId=""; | |
| 49 | + var rq=""; | |
| 50 | + $("#subjectUserDetailList").on('init', function (e, id) { | |
| 51 | + console.log(id); | |
| 52 | + userId=id.split(",")[0]; | |
| 53 | + rq = id.split(",")[1]; | |
| 54 | + $("#remark").html(id.split(",")[2] + "<br/>" + id.split(",")[3]); | |
| 55 | + var i = layer.load(2); | |
| 56 | + $get('/subjectUser/subjectUserDetail',{userId:userId,rq:rq,status:"detail",type:'query'},function(result){ | |
| 57 | + layer.close(i); | |
| 58 | + var subjectUserDetailList_2 = template('subjectUserDetailList_2',{list:result}); | |
| 59 | + $('#forms_2 tbody').html(subjectUserDetailList_2); | |
| 60 | + }); | |
| 61 | + }) | |
| 62 | + }); | |
| 63 | +</script> | |
| 64 | +<script type="text/html" id="subjectUserDetailList_2"> | |
| 65 | + {{each list as obj i}} | |
| 66 | + <tr > | |
| 67 | + <td>{{obj.subjectId}}</td> | |
| 68 | + <td>{{obj.rq}}</td> | |
| 69 | + <td>{{obj.subjectText}}</td> | |
| 70 | + <td>{{obj.operateTest}}</td> | |
| 71 | + <td>{{obj.operateTest}}</td> | |
| 72 | + <td>{{obj.result}}</td> | |
| 73 | + </tr> | |
| 74 | + {{/each}} | |
| 75 | + {{if list.length == 0}} | |
| 76 | + <tr> | |
| 77 | + <td colspan="10"><h6 class="muted">没有找到相关数据</h6></td> | |
| 78 | + </tr> | |
| 79 | + {{/if}} | |
| 80 | +</script> | |
| 0 | 81 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/subjectUser/subjectUserList.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; } | |
| 11 | + .table-bordered > thead > tr > th, | |
| 12 | + .table-bordered > thead > tr > td { | |
| 13 | + border-bottom-width: 2px; } | |
| 14 | + | |
| 15 | + .table > tbody + tbody { | |
| 16 | + border-top: 1px solid; } | |
| 17 | +</style> | |
| 18 | + | |
| 19 | +<div class="page-head"> | |
| 20 | + <div class="page-title"> | |
| 21 | + <h1>成绩查询</h1> | |
| 22 | + </div> | |
| 23 | +</div> | |
| 24 | + | |
| 25 | +<div class="row"> | |
| 26 | + <div class="col-md-12"> | |
| 27 | + <div class="portlet light porttlet-fit bordered"> | |
| 28 | + <div class="portlet-title"> | |
| 29 | + <form class="form-inline" action=""> | |
| 30 | + <div style="display: inline-block;"> | |
| 31 | + <span class="item-label" style="width: 80px;margin-left: 6px;">开始时间: </span> | |
| 32 | + <input class="form-control" type="text" id="date" style="width: 160px;"/> | |
| 33 | + </div> | |
| 34 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 35 | + <span class="item-label" style="width: 80px;">学号: </span> | |
| 36 | + <input class="form-control" name="userName" id="userName" style="width: 180px;"> | |
| 37 | + </div> | |
| 38 | + <div class="form-group"> | |
| 39 | + <input class="btn btn-default" type="button" id="query" value="查询" style="margin-left: 2px;"/> | |
| 40 | + </div> | |
| 41 | + </form> | |
| 42 | + </div> | |
| 43 | + | |
| 44 | + <div class="portlet-body"> | |
| 45 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | |
| 46 | + <table class="table table-bordered table-hover table-checkable" id="forms"> | |
| 47 | + <thead> | |
| 48 | + <tr> | |
| 49 | + <td>序号</td> | |
| 50 | + <td>学号</td> | |
| 51 | + <td>姓名</td> | |
| 52 | + <td>日期</td> | |
| 53 | + <td>总题数</td> | |
| 54 | + <td>正确</td> | |
| 55 | + <td>错误</td> | |
| 56 | + <td>未答</td> | |
| 57 | + <td>查看</td> | |
| 58 | + </tr> | |
| 59 | + </thead> | |
| 60 | + <tbody> | |
| 61 | + </tbody> | |
| 62 | + </table> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </div> | |
| 66 | + </div> | |
| 67 | +</div> | |
| 68 | +<script src="/pages/mforms/singledatas/jquery.table2excel.min.js"></script> | |
| 69 | +<script> | |
| 70 | + $(function(){ | |
| 71 | + // 关闭左侧栏 | |
| 72 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 73 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 74 | + | |
| 75 | + var d = new Date(); | |
| 76 | + d.setTime(d.getTime()); | |
| 77 | + var year = d.getFullYear(); | |
| 78 | + var month = d.getMonth() + 1; | |
| 79 | + var day = d.getDate(); | |
| 80 | + if(month < 10) | |
| 81 | + month = "0"+month; | |
| 82 | + if(day < 10) | |
| 83 | + day = "0"+day; | |
| 84 | + var dateTime = year + "-" + month + "-" + day; | |
| 85 | + $("#date").datetimepicker({ | |
| 86 | + format : 'YYYY-MM-DD', | |
| 87 | + locale : 'zh-cn', | |
| 88 | + maxDate : dateTime | |
| 89 | + }); | |
| 90 | + $("#date").val(dateTime); | |
| 91 | + //查询 | |
| 92 | + $("#query").on('click',function(){ | |
| 93 | + var date = $("#date").val(); | |
| 94 | + var userName = $("#userName").val(); | |
| 95 | + $get('/subjectUser/subjectUserList',{date:date,userName:userName,type:'query'},function(result){ | |
| 96 | + var subjectUserList = template('subjectUserList',{list:result}); | |
| 97 | + $('#forms tbody').html(subjectUserList); | |
| 98 | + $('.btn-subjectUserList').on('click', openSubjectUserList); | |
| 99 | + }); | |
| 100 | + }); | |
| 101 | + | |
| 102 | + function openSubjectUserList(){ | |
| 103 | + var id = $(this).data('id'); | |
| 104 | + id += ","+$(this).data('rq'); | |
| 105 | + $.get('/pages/subjectUser/subjectUserDetailList.html', function (content) { | |
| 106 | + layer.open({ | |
| 107 | + type: 1, | |
| 108 | + area: ['1300px', '600px'], | |
| 109 | + content: content, | |
| 110 | + title: '考生答题详细', | |
| 111 | + shift: 5, | |
| 112 | + scrollbar: false, | |
| 113 | + success: function () { | |
| 114 | + $('#subjectUserDetailList').trigger('init', id); | |
| 115 | + } | |
| 116 | + }); | |
| 117 | + }); | |
| 118 | + } | |
| 119 | + }); | |
| 120 | +</script> | |
| 121 | +<script type="text/html" id="subjectUserList"> | |
| 122 | + {{each list as obj i}} | |
| 123 | + <tr> | |
| 124 | + <td>{{i+1}}</td> | |
| 125 | + <td>{{obj.userName}}</td> | |
| 126 | + <td>{{obj.name}}</td> | |
| 127 | + <td>{{obj.rq}}</td> | |
| 128 | + <td>{{obj.sum}}</td>`` | |
| 129 | + <td>{{obj.t}}</td> | |
| 130 | + <td>{{obj.f}}</td> | |
| 131 | + <td>{{obj.na}}</td> | |
| 132 | + <td> | |
| 133 | + <button type="button" class="btn btn-sm blue btn-subjectUserList" | |
| 134 | + data-id="{{obj.userId}}" data-rq="{{obj.rq}}">查看</button> | |
| 135 | + </td> | |
| 136 | + </tr> | |
| 137 | + {{/each}} | |
| 138 | + {{if list.length == 0}} | |
| 139 | + <tr> | |
| 140 | + <td colspan="13"><h6 class="muted">没有找到相关数据</h6></td> | |
| 141 | + </tr> | |
| 142 | + {{/if}} | |
| 143 | +</script> | |
| 144 | + | |
| 145 | + | |
| 146 | + | ... | ... |