Procházet zdrojové kódy

Merge remote-tracking branch 'origin/ywx' into wn

tags/正式3.9.0
王宁 před 1 rokem
rodič
revize
408f128dfb

+ 0
- 13
sstudy/src/main/java/com/xhkjedu/sstudy/controller/paperstudent/PaperClassController.java Zobrazit soubor

@@ -27,19 +27,6 @@ public class PaperClassController {
27 27
     @Autowired
28 28
     private PaperClassService paperClassService;
29 29
 
30
-    /**
31
-     *功能描述  发布作业
32
-     * @author WN
33
-     * @date 2020/6/9
34
-     * @param  * @param paperGroupParam
35
-     * @return com.xhkjedu.vo.ResultVo
36
-     */
37
-    @PostMapping("/save")
38
-    public ResultVo save(@RequestBody PaperGroupParam paperGroupParam){
39
-        N_Utils.validation(new Object[]{paperGroupParam.getPaperid(),"作业id",1,paperGroupParam.getShowtype(),"公布答案",1,paperGroupParam.getClasslst(),"班级",1});
40
-        return paperClassService.savePaperGroup(paperGroupParam);
41
-    }
42
-
43 30
     //发布作业(兼容靶向作业)
44 31
     @PostMapping("/save2")
45 32
     public ResultVo save2(@RequestBody PaperGroupParam paperGroupParam){

+ 2
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/controller/resource/GuideController.java Zobrazit soubor

@@ -80,7 +80,8 @@ public class GuideController {
80 80
     @PostMapping("/list_class")
81 81
     public ResultVo listClass(@RequestBody TGuide guide) {
82 82
         Integer guideid = guide.getGuideid();
83
-        N_Utils.validation(new Object[]{guideid, "预习id", 1,guide.getCreateid(),"教师id",1});
83
+        N_Utils.validation(new Object[]{guideid, "预习id", 1,guide.getCreateid(),"教师id",1
84
+                ,guide.getSchoolid(),"学校id",1});
84 85
         Map<String, String> map = classService.getQxClassidsByTeacherid(guide.getCreateid());
85 86
         guide.setClassids(map.get("classids"));
86 87
         guide.setBxclassids(map.get("bxclassids"));

+ 64
- 130
sstudy/src/main/java/com/xhkjedu/sstudy/service/paperstudent/PaperClassService.java Zobrazit soubor

@@ -8,11 +8,14 @@ import com.xhkjedu.sstudy.mapper.paper.PaperScantronMapper;
8 8
 import com.xhkjedu.sstudy.mapper.paperstudent.PaperClassMapper;
9 9
 import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentMapper;
10 10
 import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentQuestionMapper;
11
+import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentScantronMapper;
11 12
 import com.xhkjedu.sstudy.model.paper.TPaper;
12 13
 import com.xhkjedu.sstudy.model.paper.TPaperQtypeQuestion;
14
+import com.xhkjedu.sstudy.model.paper.TPaperScantron;
13 15
 import com.xhkjedu.sstudy.model.paperstudent.TPaperClass;
14 16
 import com.xhkjedu.sstudy.model.paperstudent.TPaperStudent;
15 17
 import com.xhkjedu.sstudy.model.paperstudent.TPaperStudentQuestion;
18
+import com.xhkjedu.sstudy.model.paperstudent.TPaperStudentScantron;
16 19
 import com.xhkjedu.sstudy.utils.ArithUtil;
17 20
 import com.xhkjedu.sstudy.vo.paperstudent.PaperClassParam;
18 21
 import com.xhkjedu.sstudy.vo.paperstudent.PaperGroupParam;
@@ -23,9 +26,7 @@ import com.xhkjedu.sstudy.vo.subjectbook.PointVo;
23 26
 import com.xhkjedu.utils.N_Utils;
24 27
 import com.xhkjedu.vo.ResultVo;
25 28
 import lombok.extern.slf4j.Slf4j;
26
-import org.apache.commons.lang3.StringUtils;
27 29
 import org.springframework.beans.factory.annotation.Autowired;
28
-import org.springframework.dao.DuplicateKeyException;
29 30
 import org.springframework.stereotype.Service;
30 31
 import org.springframework.transaction.annotation.Transactional;
31 32
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -58,144 +59,61 @@ public class PaperClassService {
58 59
     private PaperScantronMapper paperScantronMapper;
59 60
     @Resource
60 61
     private PaperStudentQuestionMapper paperStudentQuestionMapper;
62
+    @Resource
63
+    private PaperStudentScantronMapper paperStudentScantronMapper;
61 64
 
62
-    /**
63
-     *功能描述
64
-     * @author WN
65
-     * @date 2020/6/9
66
-     * @param  * @param paperGroupVo
67
-     * @return void
68
-     */
69
-    @Transactional(rollbackFor = Exception.class)
70
-    public ResultVo savePaperGroup(PaperGroupParam paperGroupParam){
71
-        ResultVo resultVo = null;
72
-        try {
73
-            //获取试卷详细信息
74
-            TPaper paper = paperMapper.selectByPrimaryKey(paperGroupParam.getPaperid());
75
-            if (paper.getPaperstate() == 22) return new ResultVo(0,"保存成功");
76
-            //班级
77
-            List<TPaperClass> classlst = paperGroupParam.getClasslst().stream().distinct().collect(Collectors.toList());
78
-            List<Map> jtrclist = paperGroupParam.getJtrclist();
79
-
80
-            if (N_Utils.isListEmpty(classlst) && N_Utils.isListEmpty(jtrclist)) {
81
-                return new ResultVo(1, "发布作业未选择班级");
82
-            }else{
83
-
84
-                //保存作业分组、作业学生
85
-                resultVo = this.savePaperStudent(paperGroupParam,classlst,paper);
86
-                if(resultVo.getCode()==1){
87
-                    return resultVo;
88
-                }else{
89
-                    //获取作业是否全是非主观题
90
-                    int count = 0;
91
-                    if(paper.getPapertype()==1){
92
-                        //题库作业
93
-                        count = paperQtypeQuestionMapper.getQuestionCountCtype(paperGroupParam.getPaperid());
94
-                    }else{
95
-                        //答题卡作业
96
-                        count = paperScantronMapper.getQuestionCountCtype(paperGroupParam.getPaperid());
97
-                    }
98
-
99
-                    //保存作业分组、作业学生成功后,修改作业状态
100
-                    Integer hashb = 0;
101
-                    if (N_Utils.isListNotEmpty(jtrclist)) hashb = 1;
102
-                    paperMapper.updatePaperState(22,paperGroupParam.getPaperid(),count,hashb);
103
-
104
-                    resultVo.setObj(count);//如果count=0则,代表全部是选择题
105
-                }
106
-            }
107
-
108
-        }catch (Exception e){
109
-            log.error("发布作业失败:" + e.getMessage());
110
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
111
-            return new ResultVo(1,"发布失败");
112
-        }
113
-        return resultVo;
114
-    }
115
-
116
-    private ResultVo savePaperStudent(PaperGroupParam paperGroupParam, List<TPaperClass> classlst, TPaper paper) {
117
-        List<TPaperClass> savegroup = new ArrayList<>();//班级分组
118
-        List<TPaperStudent> saveps = new ArrayList<>();//班级分组学生
119
-
120
-        Integer schoolid = paperGroupParam.getSchoolid();
121
-        Integer paperid = paperGroupParam.getPaperid();
122
-        Integer starttime = paperGroupParam.getStarttime();
123
-        Integer stoptime = paperGroupParam.getStoptime();
124
-        Integer showtype = paperGroupParam.getShowtype();
125
-        Integer createid = paperGroupParam.getCreateid();
126
-        Integer papernum = paper.getPapernum();
127
-        Double paperscore = paper.getPaperscore();
128
-        for (TPaperClass pg : classlst) {
129
-            List<Integer> groups = pg.getGroups();
130
-            Integer classid = pg.getClassid();
131
-            //处理作业分组数据
132
-            setPaperGroup(savegroup, saveps, schoolid, paperid, starttime, stoptime, showtype
133
-                    , createid, papernum, paperscore, classid, groups);
134
-        }
135
-
136
-        //集团校班级学生
137
-        List<Map> jtrclist = paperGroupParam.getJtrclist();
138
-        for (Map schoolmap : jtrclist) {
139
-            schoolid = Integer.parseInt(schoolmap.get("schoolid").toString());
140
-            List<Map> classlist = (List<Map>) schoolmap.get("classlist");
141
-            for (Map classmap : classlist) {
142
-                Integer classid = Integer.parseInt(classmap.get("classid").toString());
143
-                List<Integer> groups = (List<Integer>) classmap.get("groups");
144
-                //处理作业分组数据
145
-                setPaperGroup(savegroup, saveps, schoolid, paperid, starttime, stoptime, showtype
146
-                        , createid, papernum, paperscore, classid, groups);
147
-            }
148
-        }
149
-
150
-        //批量保存作业班级,作业班级学生信息
151
-        try {
152
-            paperClassMapper.insertList(savegroup);
153
-        } catch (Exception e) {
154
-            if (e instanceof DuplicateKeyException) {
155
-                return new ResultVo(0, "保存成功");
156
-            }
157
-        }
158
-        paperStudentMapper.saveBatchPaperStudent(saveps);
159
-        return new ResultVo(0, "保存成功");
160
-    }
161
-
162
-    //处理作业分组数据
163
-    private void setPaperGroup(List<TPaperClass> savegroup, List<TPaperStudent> saveps
164
-            , Integer schoolid, Integer paperid, Integer starttime, Integer stoptime
165
-            , Integer showtype, Integer createid, Integer papernum, Double paperscore
166
-            , Integer classid, List<Integer> groups) {
167
-        if (N_Utils.isListNotEmpty(groups)) {
65
+    //处理作业分组数据(附件)
66
+    private Integer setPaperGroup(Integer stunum
67
+            , List<TPaperScantron> pquestions, Integer timestamp, Integer schoolid
68
+            , Integer paperid, Integer starttime, Integer stoptime, Integer showtype, Integer createid
69
+            , Integer papernum, Double paperscore, Integer classid, List<PaperStudentParam> students, Integer hasfc) {
70
+        List<TPaperStudentScantron> savestuque=new ArrayList<>();
71
+        if (N_Utils.isListNotEmpty(students)) {
168 72
             TPaperClass pg = new TPaperClass();
169
-            pg.setClassid(classid);
170 73
             pg.setPaperid(paperid);
171
-            pg.setPgstate(22);//布置作业
74
+            pg.setClassid(classid);
75
+            pg.setPgstate(22);
172 76
             pg.setStarttime(starttime);
173 77
             pg.setStoptime(stoptime);
174 78
             pg.setShowtype(showtype);
175 79
             pg.setCreateid(createid);
176 80
             pg.setSchoolid(schoolid);
177
-            pg.setCreatetime(N_Utils.getSecondTimestamp());
81
+            pg.setCreatetime(timestamp);
178 82
             pg.setChecked(0);
83
+            pg.setHasfc(hasfc);
84
+            paperClassMapper.insertSelective(pg);
179 85
 
180
-            savegroup.add(pg);
181
-            String groupids = StringUtils.join(groups, ",");
182
-            //获取选中班级分组下所有学生
183
-            List<Integer> stus = classMapper.listStudentidsByGroupids(groupids);
184
-
185
-            for (Integer stu : stus) {
86
+            //根据studentid集合去重
87
+            List<PaperStudentParam> students2 = students.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(PaperStudentParam::getStudentid))), ArrayList::new));
88
+            for (PaperStudentParam s : students2) {
186 89
                 TPaperStudent ps = new TPaperStudent();
187 90
                 ps.setPaperid(paperid);
188 91
                 ps.setClassid(classid);
189
-                ps.setStudentid(stu);
190
-                ps.setPapernum(papernum);
191
-                ps.setPaperscore(paperscore);
92
+                ps.setStudentid(s.getStudentid());
192 93
                 ps.setCreateid(createid);
193
-                ps.setSchoolid(schoolid);
194 94
                 ps.setCreatetime(N_Utils.getSecondTimestamp());
195
-
196
-                saveps.add(ps);
95
+                ps.setSchoolid(schoolid);
96
+                ps.setPapernum(papernum);
97
+                ps.setPaperscore(paperscore);
98
+                Integer psid = savePaperStu(ps);
99
+                for (TPaperScantron q : pquestions) {
100
+                    TPaperStudentScantron sq=new TPaperStudentScantron();
101
+                    sq.setPaperid(paperid);
102
+                    sq.setClassid(classid);
103
+                    sq.setStudentid(s.getStudentid());
104
+                    sq.setPsid(psid);
105
+                    sq.setPscaid(q.getPscaid());
106
+                    sq.setQscore(q.getPsscore());
107
+                    sq.setQn(q.getQn());
108
+                    sq.setQorder(q.getPsorder());
109
+                    sq.setSchoolid(schoolid);
110
+                    savestuque.add(sq);
111
+                }
112
+                stunum += 1;
197 113
             }
114
+            if(N_Utils.isListNotEmpty(savestuque)) paperStudentScantronMapper.saveBatchStudentScantron(savestuque);
198 115
         }
116
+        return stunum;
199 117
     }
200 118
 
201 119
     /**
@@ -326,7 +244,7 @@ public class PaperClassService {
326 244
                 return new ResultVo(1, "发布作业未选择班级");
327 245
             } else {
328 246
                 Integer stunum = 0;
329
-                List<TPaperQtypeQuestion> pquestions = new ArrayList<>();//试卷中所有试题
247
+                List pquestions;//试卷中所有试题
330 248
                 Integer timestamp = N_Utils.getSecondTimestamp();
331 249
                 Integer papertype = paper.getPapertype();
332 250
                 Integer schoolid = paperGroupParam.getSchoolid();
@@ -337,7 +255,9 @@ public class PaperClassService {
337 255
                 Integer createid = paperGroupParam.getCreateid();
338 256
                 Integer papernum = paper.getPapernum();
339 257
                 Double paperscore = paper.getPaperscore();
340
-                if (papertype == 3) {
258
+                if (papertype == 2) {//附件
259
+                    pquestions = paperScantronMapper.listPaperScansByPaperid(paperid);
260
+                } else {
341 261
                     pquestions = paperQtypeQuestionMapper.listQuestionByPaperid(paperid);
342 262
                 }
343 263
                 //遍历班级,班级学生
@@ -346,8 +266,13 @@ public class PaperClassService {
346 266
                     Integer hasfc = c.getHasfc();
347 267
                     List<PaperStudentParam> students = c.getStudents();
348 268
                     //处理作业分组数据
349
-                    stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
350
-                            , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students,hasfc);
269
+                    if (papertype == 2) {//附件
270
+                        stunum = setPaperGroup(stunum, pquestions, timestamp, schoolid, paperid
271
+                                , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
272
+                    } else {
273
+                        stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
274
+                                , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
275
+                    }
351 276
                 }
352 277
 
353 278
                 //集团校班级学生
@@ -356,11 +281,20 @@ public class PaperClassService {
356 281
                     List<Map> classlist = (List<Map>) schoolmap.get("classlist");
357 282
                     for (Map classmap : classlist) {
358 283
                         Integer classid = Integer.parseInt(classmap.get("classid").toString());
359
-                        Integer hasfc = Integer.parseInt(classmap.get("hasfc").toString());
284
+                        Integer hasfc = 0;
285
+                        Object fc = classmap.get("hasfc");
286
+                        if (N_Utils.isNotEmpty(fc)) {
287
+                            hasfc = N_Utils.str2Int(fc.toString());
288
+                        }
360 289
                         List<PaperStudentParam> students = JSON.parseArray(JSON.toJSONString(classmap.get("students")), PaperStudentParam.class);
361 290
                         //处理作业分组数据
362
-                        stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
363
-                                , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students,hasfc);
291
+                        if (papertype == 2) {//附件
292
+                            stunum = setPaperGroup(stunum, pquestions, timestamp, schoolid, paperid
293
+                                    , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
294
+                        } else {
295
+                            stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
296
+                                    , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
297
+                        }
364 298
                     }
365 299
                 }
366 300
 

+ 1
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/utils/StudyUtil.java Zobrazit soubor

@@ -104,6 +104,7 @@ public class StudyUtil {
104 104
                     q.setQscore(score);
105 105
                     q.setQorder(tq.getQorder());
106 106
                     q.setSonques(sonques);
107
+                    q.setStuscore(sonques.stream().mapToDouble(sq->sq.getStuscore()).sum());
107 108
                 }else {
108 109
                     q=tq;
109 110
                 }

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/PaperTeacherAppVo.java Zobrazit soubor

@@ -71,4 +71,7 @@ public class PaperTeacherAppVo {
71 71
     private Integer schoolid;
72 72
 
73 73
     private Integer logschoolid;
74
+
75
+    //创建人姓名
76
+    private String createname;
74 77
 }

+ 1
- 1
sstudy/src/main/resources/mapper/paper/PaperScantronMapper.xml Zobrazit soubor

@@ -24,6 +24,6 @@
24 24
 
25 25
     <!--作业中所有试题-->
26 26
     <select id="listPaperScansByPaperid" resultType="com.xhkjedu.sstudy.model.paper.TPaperScantron">
27
-        select pscaid,ctype,psorder,psscore,psanswer from t_paper_scantron where paperid=#{paperid} order by psorder
27
+        select pscaid,ctype,psorder,psscore,psanswer,qn from t_paper_scantron where paperid=#{paperid} order by psorder
28 28
     </select>
29 29
 </mapper>

+ 3
- 0
sstudy/src/main/resources/mapper/paper/PaperTeaAppMapper.xml Zobrazit soubor

@@ -12,6 +12,7 @@
12 12
         <result property="stoptime" column="stoptime"></result>
13 13
         <result property="schoolid" column="schoolid"></result>
14 14
         <result property="logschoolid" column="logschoolid"></result>
15
+        <result property="createname" column="createname"></result>
15 16
         <collection property="students" ofType="com.xhkjedu.sstudy.vo.paperstudent.StudentVo"
16 17
                     select="listPaperStu" column="{paperid=paperid,createid=createid,checkid=checkid,logschoolid=logschoolid,classids=classids}">
17 18
         </collection>
@@ -28,6 +29,7 @@
28 29
         select p.paperid,p.papername,p.papernum,p.papertype,p.paperclass,p.paperstate,p.checktype,p.createid,#{paper.teacherid} checkid
29 30
         ,min(pg.starttime)starttime,min(pg.stoptime)stoptime,pg.checked,p.subjectid,p.paperscore,p.schoolid,#{paper.schoolid} logschoolid
30 31
         ,group_concat(pg.classid) classids
32
+        ,(select u.username from t_user u where u.userid=p.createid)createname
31 33
         from t_paper p left join t_paper_class pg on p.paperid=pg.paperid
32 34
         where (p.createid=#{paper.teacherid} or pg.checkid=#{paper.teacherid} or
33 35
         (p.hashb=1 and pg.classid in (${paper.classids})) or
@@ -46,6 +48,7 @@
46 48
     <select id="listWbz" resultType="com.xhkjedu.sstudy.vo.paper.PaperTeacherAppVo">
47 49
         select p.paperid,p.papername,p.papernum,p.papertype,p.paperclass,p.paperstate,p.checktype,p.createid
48 50
         ,p.subjectid,p.paperscore,p.schoolid
51
+        ,(select u.username from t_user u where u.userid=p.createid)createname
49 52
         from t_paper p where p.createid=#{paper.teacherid} and p.paperstate=#{paper.psstate}
50 53
         order by p.createtime desc,p.paperid desc
51 54
     </select>

Načítá se…
Zrušit
Uložit