Browse Source

完善集团校、发布对象、预习统计

tags/正式3.9.0
王宁 1 year ago
parent
commit
667b146e62

+ 0
- 4
sapi/src/main/java/com/xhkjedu/sapi/controller/system/SchoolController.java View File

@@ -133,11 +133,7 @@ public class SchoolController {
133 133
     @PostMapping("/sfschool")
134 134
     public ResultVo saveSchoolFriend(@RequestBody SchoolParams params) {
135 135
         Integer schoolid = params.getSchoolid();
136
-        List<Integer> schoolids = params.getSchoolids();
137 136
         N_Utils.validation(new Object[]{schoolid, "学校id", 1});
138
-        if(N_Utils.isListEmpty(schoolids)){
139
-            return new ResultVo(1,"未选择学校");
140
-        }
141 137
         schoolService.saveSchoolFriend(params);
142 138
         return new ResultVo(0, "保存成功");
143 139
     }

+ 17
- 14
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolService.java View File

@@ -429,22 +429,25 @@ public class SchoolService {
429 429
     public void saveSchoolFriend(SchoolParams params){
430 430
         //先移除学校关联学校
431 431
         schoolFriendMapper.deleteBySchoolid(params.getSchoolid());
432
-
433
-        List<TSchoolFriend> schoolfriends = new ArrayList<>();
434 432
         List<Integer> schoolids  = params.getSchoolids();
435
-        int timestemp = N_Utils.getSecondTimestamp();
436
-        for(Integer shid : schoolids){
437
-            if(!params.getSchoolid().equals(shid)){
438
-                TSchoolFriend sf = new TSchoolFriend();
439
-                sf.setSchoolid(params.getSchoolid());
440
-                sf.setFschoolid(shid);
441
-                sf.setCreateid(params.getCreateid());
442
-                sf.setCreatetime(timestemp);
443
-                schoolfriends.add(sf);
433
+
434
+        if(N_Utils.isListNotEmpty(schoolids)){
435
+            List<TSchoolFriend> schoolfriends = new ArrayList<>();
436
+
437
+            int timestemp = N_Utils.getSecondTimestamp();
438
+            for(Integer shid : schoolids){
439
+                if(!params.getSchoolid().equals(shid)){
440
+                    TSchoolFriend sf = new TSchoolFriend();
441
+                    sf.setSchoolid(params.getSchoolid());
442
+                    sf.setFschoolid(shid);
443
+                    sf.setCreateid(params.getCreateid());
444
+                    sf.setCreatetime(timestemp);
445
+                    schoolfriends.add(sf);
446
+                }
447
+            }
448
+            if(N_Utils.isListNotEmpty(schoolfriends)){
449
+                schoolFriendMapper.insertList(schoolfriends);
444 450
             }
445
-        }
446
-        if(N_Utils.isListNotEmpty(schoolfriends)){
447
-            schoolFriendMapper.insertList(schoolfriends);
448 451
         }
449 452
     }
450 453
 

+ 5
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/controller/paperstudent/PaperClassController.java View File

@@ -53,7 +53,11 @@ public class PaperClassController {
53 53
         N_Utils.validation(new Object[]{paperid, "试卷id", 1, createid, "发布人id", 1
54 54
                 , papertype, "作业类型", 1, schoolid, "学校id", 1});
55 55
         Map list = paperClassService.listObject(paperid, createid, papertype, schoolid);
56
-        return new ResultVo(0, "获取发布对象成功", list);
56
+        if(N_Utils.isEmpty(list.get("classes"))){
57
+            return new ResultVo(1,"发布对象为空,请联系管理员设置班级权限");
58
+        }else{
59
+            return new ResultVo(0, "获取发布对象成功", list);
60
+        }
57 61
     }
58 62
 
59 63
     /**

+ 74
- 70
sstudy/src/main/java/com/xhkjedu/sstudy/service/paperstudent/PaperClassService.java View File

@@ -146,82 +146,86 @@ public class PaperClassService {
146 146
                 , LinkedHashMap::new, Collectors.toList()));
147 147
         List<Integer> studentids = groups.stream().map(m -> (Integer) m.get("studentid")).distinct().collect(Collectors.toList());
148 148
 
149
-        List<Map> users = paperClassMapper.listUserByIds(studentids);
150
-        Map<Integer, Map> userMap = users.stream().collect(Collectors.toMap(m -> (Integer) m.get("userid"), m -> m));
151
-        if (papertype == 3) {//靶向作业
152
-            List<QuestionVo> questions = paperClassMapper.listPaperQuestions(paperid);
153
-            for (QuestionVo question : questions) {
154
-                String qstemtxt = question.getQstemtxt();
155
-                if(N_Utils.isNotEmpty(qstemtxt)){
156
-                    List<Map> sonqlist=JSON.parseArray(qstemtxt, Map.class);
157
-                    question.setSonqlist(sonqlist);
158
-                }
159
-                question.setQstemtxt(null);
160
-                List<PointVo> points = JSON.parseArray(question.getSource(), PointVo.class);
161
-                question.setPoints(points);
162
-                question.setSource(null);
163
-            }
164
-            paper.put("questions", questions);
165
-            List<String> questionids = questions.stream().map(QuestionVo::getQuestionid).collect(Collectors.toList());
166
-            List<Map> stuQuestions = paperClassMapper.listStuQuestion(questionids, studentids);
167
-            for (Integer studentid : studentids) {
168
-                List<String> stuQuestionIds = new ArrayList<>();//学生未收到或未得满分的试题ids
169
-                Double paperscore = 0.0;//试卷总分
149
+        List<Map> classes = new ArrayList<>();
150
+
151
+        if(N_Utils.isListNotEmpty(studentids)){
152
+            List<Map> users = paperClassMapper.listUserByIds(studentids);
153
+            Map<Integer, Map> userMap = users.stream().collect(Collectors.toMap(m -> (Integer) m.get("userid"), m -> m));
154
+            if (papertype == 3) {//靶向作业
155
+                List<QuestionVo> questions = paperClassMapper.listPaperQuestions(paperid);
170 156
                 for (QuestionVo question : questions) {
171
-                    String questionid = question.getQuestionid();
172
-                    boolean anyMatch = stuQuestions.stream().anyMatch(m -> m.get("studentid").equals(studentid)
173
-                            && m.get("questionid").equals(questionid));
174
-                    if (!anyMatch) {
175
-                        stuQuestionIds.add(questionid);
176
-                        paperscore = ArithUtil.add(paperscore, question.getScore());
157
+                    String qstemtxt = question.getQstemtxt();
158
+                    if(N_Utils.isNotEmpty(qstemtxt)){
159
+                        List<Map> sonqlist=JSON.parseArray(qstemtxt, Map.class);
160
+                        question.setSonqlist(sonqlist);
177 161
                     }
162
+                    question.setQstemtxt(null);
163
+                    List<PointVo> points = JSON.parseArray(question.getSource(), PointVo.class);
164
+                    question.setPoints(points);
165
+                    question.setSource(null);
178 166
                 }
179
-                Map stuQue = userMap.get(studentid);
180
-                stuQue.put("questionids", stuQuestionIds);
181
-                stuQue.put("paperscore", paperscore);
182
-                userMap.put(studentid, stuQue);
183
-            }
184
-        }
185
-        List<Map> classes = new ArrayList<>();
186
-        for (Map.Entry<Integer, List<Map>> entry : classList.entrySet()) {
187
-            Integer classid = entry.getKey();
188
-            List<Map> groupList = entry.getValue();
189
-            Map gMap = groupList.get(0);
190
-            Map c = new HashMap();
191
-            c.put("classid", classid);
192
-            c.put("gradeid", gMap.get("gradeid"));
193
-            c.put("classname", gMap.get("classname"));
194
-            LinkedHashMap<Integer, List<Map>> groupCollect = groupList.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("groupid")
195
-                    , LinkedHashMap::new, Collectors.toList()));
196
-            List<Map> groups2 = new ArrayList<>();
197
-            for (Map.Entry<Integer, List<Map>> gentry : groupCollect.entrySet()) {
198
-                List<Map> studentList = gentry.getValue();
199
-                Map sMap = studentList.get(0);
200
-                Map g = new HashMap();
201
-                g.put("groupid", gentry.getKey());
202
-                g.put("groupname", sMap.get("groupname"));
203
-                g.put("groupnum", sMap.get("groupnum"));
204
-                g.put("grouptype", sMap.get("grouptype"));
205
-                List<Map> students = new ArrayList<>();
206
-                for (Map map : studentList) {
207
-                    Map s = new HashMap();
208
-                    Object studentid = map.get("studentid");
209
-                    s.put("studentid", studentid);
210
-                    Map stuMap = userMap.get(studentid);
211
-                    s.put("studentname", stuMap.get("username"));
212
-                    s.put("questionids", stuMap.get("questionids"));
213
-                    s.put("paperscore", stuMap.get("paperscore"));
214
-                    s.put("headpic", stuMap.get("headpic"));
215
-                    students.add(s);
167
+                paper.put("questions", questions);
168
+                List<String> questionids = questions.stream().map(QuestionVo::getQuestionid).collect(Collectors.toList());
169
+                List<Map> stuQuestions = paperClassMapper.listStuQuestion(questionids, studentids);
170
+                for (Integer studentid : studentids) {
171
+                    List<String> stuQuestionIds = new ArrayList<>();//学生未收到或未得满分的试题ids
172
+                    Double paperscore = 0.0;//试卷总分
173
+                    for (QuestionVo question : questions) {
174
+                        String questionid = question.getQuestionid();
175
+                        boolean anyMatch = stuQuestions.stream().anyMatch(m -> m.get("studentid").equals(studentid)
176
+                                && m.get("questionid").equals(questionid));
177
+                        if (!anyMatch) {
178
+                            stuQuestionIds.add(questionid);
179
+                            paperscore = ArithUtil.add(paperscore, question.getScore());
180
+                        }
181
+                    }
182
+                    Map stuQue = userMap.get(studentid);
183
+                    stuQue.put("questionids", stuQuestionIds);
184
+                    stuQue.put("paperscore", paperscore);
185
+                    userMap.put(studentid, stuQue);
216 186
                 }
187
+            }
217 188
 
218
-                students = students.stream().sorted(Comparator.comparing(m -> m.get("studentname").toString()))
219
-                        .collect(Collectors.toList());
220
-                g.put("students", students);
221
-                groups2.add(g);
189
+            for (Map.Entry<Integer, List<Map>> entry : classList.entrySet()) {
190
+                Integer classid = entry.getKey();
191
+                List<Map> groupList = entry.getValue();
192
+                Map gMap = groupList.get(0);
193
+                Map c = new HashMap();
194
+                c.put("classid", classid);
195
+                c.put("gradeid", gMap.get("gradeid"));
196
+                c.put("classname", gMap.get("classname"));
197
+                LinkedHashMap<Integer, List<Map>> groupCollect = groupList.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("groupid")
198
+                        , LinkedHashMap::new, Collectors.toList()));
199
+                List<Map> groups2 = new ArrayList<>();
200
+                for (Map.Entry<Integer, List<Map>> gentry : groupCollect.entrySet()) {
201
+                    List<Map> studentList = gentry.getValue();
202
+                    Map sMap = studentList.get(0);
203
+                    Map g = new HashMap();
204
+                    g.put("groupid", gentry.getKey());
205
+                    g.put("groupname", sMap.get("groupname"));
206
+                    g.put("groupnum", sMap.get("groupnum"));
207
+                    g.put("grouptype", sMap.get("grouptype"));
208
+                    List<Map> students = new ArrayList<>();
209
+                    for (Map map : studentList) {
210
+                        Map s = new HashMap();
211
+                        Object studentid = map.get("studentid");
212
+                        s.put("studentid", studentid);
213
+                        Map stuMap = userMap.get(studentid);
214
+                        s.put("studentname", stuMap.get("username"));
215
+                        s.put("questionids", stuMap.get("questionids"));
216
+                        s.put("paperscore", stuMap.get("paperscore"));
217
+                        s.put("headpic", stuMap.get("headpic"));
218
+                        students.add(s);
219
+                    }
220
+
221
+                    students = students.stream().sorted(Comparator.comparing(m -> m.get("studentname").toString()))
222
+                                       .collect(Collectors.toList());
223
+                    g.put("students", students);
224
+                    groups2.add(g);
225
+                }
226
+                c.put("groups", groups2);
227
+                classes.add(c);
222 228
             }
223
-            c.put("groups", groups2);
224
-            classes.add(c);
225 229
         }
226 230
 
227 231
         paper.put("classes", classes);

Loading…
Cancel
Save