Browse Source

校验信息

ywx
王宁 8 months ago
parent
commit
9807aad53c

+ 14
- 0
src/main/java/com/xhkjedu/mapper/EPaperVerifyMapper.java View File

@@ -1,7 +1,9 @@
1 1
 package com.xhkjedu.mapper;
2 2
 
3 3
 import com.xhkjedu.model.EPaperQtypeQuestion;
4
+import com.xhkjedu.model.EPaperStudent;
4 5
 import com.xhkjedu.model.EPaperStudent0608;
6
+import com.xhkjedu.model.EPaperStudentQuestion;
5 7
 import org.apache.ibatis.annotations.Param;
6 8
 import org.springframework.stereotype.Repository;
7 9
 
@@ -27,4 +29,16 @@ public interface EPaperVerifyMapper {
27 29
 
28 30
     //获取试卷原试题答案
29 31
     List<EPaperQtypeQuestion> listPaperAnswer(@Param("epid") Integer epid);
32
+
33
+    //批量修改学生试题
34
+    void updateBatchStuQuestion(@Param("list")List<EPaperStudentQuestion> list);
35
+
36
+    //修改学生试卷状态
37
+    void updateStuPaper(@Param("p")EPaperStudent p);
38
+
39
+    //修改单独试卷审核状态
40
+    void updateStuPaperVerified(@Param("p")EPaperStudent p);
41
+
42
+    //修改新表试卷状态
43
+    void updateStuPaper0608(@Param("p")EPaperStudent0608 p);
30 44
 }

+ 165
- 1
src/main/java/com/xhkjedu/service/EPaperVerifyService.java View File

@@ -1,10 +1,18 @@
1 1
 package com.xhkjedu.service;
2 2
 
3
+import com.alibaba.fastjson2.JSON;
3 4
 import com.xhkjedu.mapper.EPaperVerifyMapper;
5
+import com.xhkjedu.model.EPaperQtypeQuestion;
6
+import com.xhkjedu.model.EPaperStudent;
4 7
 import com.xhkjedu.model.EPaperStudent0608;
8
+import com.xhkjedu.model.EPaperStudentQuestion;
9
+import com.xhkjedu.utils.N_Utils;
10
+import com.xhkjedu.vo.PaperStudentParams;
5 11
 import org.springframework.stereotype.Service;
12
+import org.springframework.transaction.annotation.Transactional;
6 13
 
7 14
 import javax.annotation.Resource;
15
+import java.util.ArrayList;
8 16
 import java.util.List;
9 17
 import java.util.Map;
10 18
 
@@ -34,8 +42,164 @@ public class EPaperVerifyService {
34 42
         ePaperVerifyMapper.correctSkip(epsid);
35 43
     }
36 44
 
37
-    public void correctSave(){
45
+    //识别确认
46
+    @Transactional(rollbackFor = Exception.class)
47
+    public void correctSave(PaperStudentParams psParams){
48
+        Integer epid = psParams.getEpid();
49
+        Integer studentid = psParams.getStudentid();
38 50
 
51
+        //是否验证0待验证1验证通过2验证不通过
52
+        if(psParams.getVerified() == 2){
53
+            EPaperStudent paperStudent = new EPaperStudent();
54
+            paperStudent.setEpid(epid);
55
+            paperStudent.setStudentid(studentid);
56
+            paperStudent.setVerified(2);
57
+            ePaperVerifyMapper.updateStuPaperVerified(paperStudent);
58
+
59
+            //验证不通过,更改状态
60
+            EPaperStudent0608 ps0608 = new EPaperStudent0608();
61
+            ps0608.setEpid(epid);
62
+            ps0608.setStudentid(studentid);
63
+            ps0608.setVerified(2);
64
+            ps0608.setSamed(0);
65
+            ePaperVerifyMapper.updateStuPaper0608(ps0608);
66
+        }else{
67
+            //获取原试卷答案,
68
+            List<EPaperQtypeQuestion> questions = ePaperVerifyMapper.listPaperAnswer(psParams.getEpid());
69
+            List<EPaperStudentQuestion> stuQues = psParams.getQuestions();
70
+
71
+            Double paperscore = 0D;//学生试卷得分
72
+
73
+            for(EPaperStudentQuestion psq : stuQues){
74
+                EPaperQtypeQuestion pqtypeQues = questions.stream().filter(a -> a.getEptqid().equals(psq.getEptqid())).findFirst().orElse(null);
75
+                setCommitQuestion(psq,pqtypeQues);
76
+
77
+                paperscore = N_Utils.add(paperscore, psq.getStuscore());
78
+                psq.setStudentid(studentid);
79
+                psq.setEpid(epid);
80
+            }
81
+            ePaperVerifyMapper.updateBatchStuQuestion(stuQues);
82
+
83
+            EPaperStudent paperStudent = new EPaperStudent();
84
+            paperStudent.setEpid(epid);
85
+            paperStudent.setStudentid(studentid);
86
+            paperStudent.setStuscore(paperscore);
87
+            paperStudent.setStupic(psParams.getStupic());
88
+            paperStudent.setPagenum(psParams.getPagenum());
89
+            paperStudent.setSstate(2);
90
+            paperStudent.setChecked(2);
91
+            paperStudent.setVerified(1);
92
+            ePaperVerifyMapper.updateStuPaper(paperStudent);
93
+
94
+            EPaperStudent0608 ps0608 = new EPaperStudent0608();
95
+            ps0608.setEpid(epid);
96
+            ps0608.setStudentid(studentid);
97
+            ps0608.setVerified(1);
98
+            ps0608.setSamed(psParams.getSamed());
99
+            ePaperVerifyMapper.updateStuPaper0608(ps0608);
100
+        }
101
+
102
+
103
+
104
+    }
105
+
106
+    //判断单道题情况
107
+    private void setCommitQuestion(EPaperStudentQuestion psq, EPaperQtypeQuestion answerVo) {
108
+        int timestamp = N_Utils.getSecondTimestamp();
109
+        psq.setAnswertime(timestamp);
110
+        int coverted = 1;//是否转换0未转换1已转换2转换失败
111
+        String stuanswer = psq.getStuanswer();
112
+        String stuanswertxt = psq.getStuanswertxt();
113
+        Double stuscore = 0D;
114
+        if (N_Utils.isEmpty(stuanswer) && N_Utils.isEmpty(stuanswertxt)
115
+                && N_Utils.isListEmpty(JSON.parseArray(stuanswer, String.class))
116
+                && N_Utils.isListEmpty(JSON.parseArray(stuanswertxt, String.class))) {
117
+            psq.setAnswered(0);
118
+            psq.setStuanswer(null);
119
+            psq.setStuanswertxt(null);
120
+            psq.setStuscore(stuscore);
121
+            psq.setChecked(2);
122
+            psq.setChecktime(timestamp);
123
+            psq.setAnswered(0);
124
+        } else {
125
+            List<String> stuanswers = JSON.parseArray(stuanswer, String.class);
126
+            String qanswer = answerVo.getAnswer();
127
+            List<String> qanswers = JSON.parseArray(qanswer, String.class);
128
+            int ctype = answerVo.getCtype();
129
+            if (psq.getAnswertype() == 1) {
130
+                if (N_Utils.isObjectiveQuestion(ctype)) {
131
+                    //客观题进行批阅
132
+                    if (ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6) {
133
+                        //单选、判断
134
+                        if (stuanswer.equalsIgnoreCase(qanswer)) {
135
+                            stuscore = answerVo.getScore();
136
+                        }
137
+                    } else if (ctype == 2) {//多选
138
+                        //多选、选错不得分
139
+                        if (stuanswers.get(0).length() <= qanswer.length()) {
140
+                            String[] qanswerList = qanswers.get(0).split("");
141
+                            String[] stuanswerList = stuanswers.get(0).split("");
142
+                            int rightNum = 0;//选对个数
143
+                            for (String sa : stuanswerList) {
144
+                                int right = 0;
145
+                                for (String qa : qanswerList) {
146
+                                    if (qa.equals(sa)) {
147
+                                        right = 1;
148
+                                        rightNum++;
149
+                                    }
150
+                                }
151
+                                if (right == 0) {//说明选错
152
+                                    rightNum = 0;
153
+                                    break;
154
+                                }
155
+                            }
156
+                            if (rightNum > 0) {
157
+                                if (qanswerList.length == rightNum) {
158
+                                    //全选对
159
+                                    stuscore = answerVo.getScore();
160
+                                } else if (qanswerList.length > rightNum) {
161
+                                    //少选得半分
162
+                                    stuscore = N_Utils.div(answerVo.getScore(), 2, 1);
163
+                                }
164
+                            }
165
+                        }
166
+                    }
167
+
168
+                    psq.setChecked(2);
169
+                    psq.setChecktime(timestamp);
170
+                } else {
171
+                    if (stuanswers.size() > 1) {
172
+                        coverted = 0;//上传的多张图片设为0未转换
173
+                    }
174
+                    psq.setChecked(0);
175
+                }
176
+            } else {
177
+                if(N_Utils.isNotEmpty(stuanswertxt)){
178
+                    List<String> stuanswertxt_list = JSON.parseArray(stuanswertxt,String.class);
179
+                    String stuanswertxt_txt = stuanswertxt_list.get(0);
180
+                    if(N_Utils.isNotEmpty(stuanswertxt_txt)){
181
+                        stuanswertxt_txt = N_Utils.strTrim(stuanswertxt_txt);
182
+                        if(N_Utils.isNotEmpty(stuanswertxt_txt)){
183
+                            psq.setChecked(0);
184
+                            List<String> stuanswertxt_list_new = new ArrayList<>();
185
+                            stuanswertxt_list_new.add(stuanswertxt_txt);
186
+                            psq.setStuanswertxt(JSON.toJSONString(stuanswertxt_list_new));
187
+                        }else{
188
+                            psq.setChecked(2);
189
+                            psq.setStuanswertxt("[\"\"]");
190
+                        }
191
+                    }else{
192
+                        psq.setChecked(2);
193
+                        psq.setStuanswertxt("[\"\"]");
194
+                    }
195
+                }else{
196
+                    psq.setChecked(2);
197
+                }
198
+            }
199
+            psq.setStuscore(stuscore);
200
+        }
201
+
202
+        psq.setConverted(coverted);
39 203
     }
40 204
 
41 205
 

+ 26
- 418
src/main/java/com/xhkjedu/utils/N_Utils.java View File

@@ -4,14 +4,8 @@ import com.xhkjedu.exception.MissingParametersException;
4 4
 import lombok.extern.slf4j.Slf4j;
5 5
 import org.springframework.util.CollectionUtils;
6 6
 
7
-import java.io.BufferedReader;
8
-import java.io.IOException;
9
-import java.io.InputStreamReader;
10
-import java.io.OutputStreamWriter;
11 7
 import java.math.BigDecimal;
12 8
 import java.math.RoundingMode;
13
-import java.net.URL;
14
-import java.net.URLConnection;
15 9
 import java.text.DecimalFormat;
16 10
 import java.text.ParseException;
17 11
 import java.text.SimpleDateFormat;
@@ -721,259 +715,10 @@ public class N_Utils {
721 715
         return map;//返回包含数字及其对应百分比的哈希映射
722 716
     }
723 717
 
724
-    /**
725
-     * 格式化百分比
726
-     * @Param [arr]
727
-     * @Author ywx
728
-     * @Date 2020/10/12 11:58
729
-     * @return double[]
730
-     **/
731
-    public static double[] getPercentValue(int[] arr){
732
-        //求和
733
-        double sum = 0;
734
-        if(sum <= 0){
735
-            for (int i = 0; i < arr.length; i++) {
736
-                sum += arr[i];
737
-            }
738
-        }
739
-        //10的2次幂是100,用于计算精度。
740
-        double digits = 1;
741
-        //扩大比例100
742
-        double[] votesPerQuota = new double[arr.length];
743
-        for(int i = 0; i < arr.length; i++){
744
-            double val = arr[i] / sum * digits * 100;
745
-            votesPerQuota[i] = val;
746
-        }
747
-        //总数,扩大比例意味的总数要扩大
748
-        double targetSeats = digits * 100;
749
-        //再向下取值,组成数组
750
-        double[] seats = new double[arr.length];
751
-        for(int i = 0; i < votesPerQuota.length; i++){
752
-            seats[i] = Math.floor(votesPerQuota[i]);
753
-        }
754
-        //再新计算合计,用于判断与总数量是否相同,相同则占比会100%
755
-        double currentSum = 0;
756
-        for (int i = 0; i < seats.length; i++) {
757
-            currentSum += seats[i];
758
-        }
759
-        //余数部分的数组:原先数组减去向下取值的数组,得到余数部分的数组
760
-        double[] remainder = new double[arr.length];
761
-        for(int i = 0; i < seats.length; i++){
762
-            remainder[i] = votesPerQuota[i] - seats[i];
763
-        }
764
-        while(currentSum < targetSeats){
765
-            double max = 0;
766
-            int maxId = 0;
767
-            for(int i = 0;i < remainder.length;++i){
768
-                if(remainder[i] > max){
769
-                    max = remainder[i];
770
-                    maxId = i;
771
-                }
772
-            }
773
-            //对最大项余额加1
774
-            ++seats[maxId];
775
-            //已经增加最大余数加1,则下次判断就可以不需要再判断这个余额数。
776
-            remainder[maxId] = 0;
777
-            //总的也要加1,为了判断是否总数是否相同,跳出循环。
778
-            ++currentSum;
779
-        }
780
-        // 这时候的seats就会总数占比会100%
781
-        return seats;
782
-    }
783
-
784
-    /**
785
-     *功能描述 字符串是否包含中文
786
-     * @author WN
787
-     * @date 2020/11/21
788
-     * @param  * @param str 待校验字符串
789
-     * @return true 包含中文字符 false 不包含中文字符
790
-     */
791
-    public static boolean isContainChinese(String str){
792
-        Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
793
-        Matcher m = p.matcher(str);
794
-        if(m.find()){
795
-            return true;
796
-        }
797
-        return false;
798
-
799
-    }
800
-
801
-
802
-    /**
803
-     * 随机生成4位随机码
804
-     * @Param []
805
-     * @Author ywx
806
-     * @Date 2020/5/8 9:29
807
-     * @return java.lang.Integer
808
-     **/
809
-    public static Integer messageCode(){
810
-        return (int) ((Math.random()*9+1)*1000);
811
-    }
812
-
813
-    /**
814
-     * 向指定 URL 发送POST方法的请求
815
-     * @param url   发送请求的 URL
816
-     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
817
-     * @return 所代表远程资源的响应结果
818
-     */
819
-    public static String sendPost(String url, String param) {
820
-        OutputStreamWriter out = null;
821
-        BufferedReader in = null;
822
-        String result = "";
823
-        try {
824
-            URL realUrl = new URL(url);
825
-            // 打开和URL之间的连接
826
-            URLConnection conn = realUrl.openConnection();
827
-            // 设置通用的请求属性
828
-            conn.setRequestProperty("accept", "application/x-www-form-urlencoded");
829
-            conn.setRequestProperty("connection", "Keep-Alive");
830
-            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
831
-            // 发送POST请求必须设置如下两行
832
-            conn.setDoOutput(true);
833
-            conn.setDoInput(true);
834
-            //设置请求编码格式
835
-            conn.setRequestProperty("Accept-Charset", "UTF-8");
836
-            // 文件流编码设置
837
-            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
838
-            out.write(param);
839
-            // flush输出流的缓冲
840
-            out.flush();
841
-            // 定义BufferedReader输入流来读取URL的响应
842
-            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
843
-            String line;
844
-            while ((line = in.readLine()) != null) {
845
-                result += line;
846
-            }
847
-        } catch (Exception e) {
848
-            log.error("发送 POST 请求出现异常!" + e.getMessage());
849
-        }
850
-        // 使用finally块来关闭输出流、输入流
851
-        finally {
852
-            try {
853
-                if (out != null) {
854
-                    out.close();
855
-                }
856
-                if (in != null) {
857
-                    in.close();
858
-                }
859
-            } catch (IOException ex) {
860
-                log.error("关闭输入输出流异常", ex.getMessage());
861
-            }
862
-        }
863
-        return result;
864
-    }
865
-
866
-    /**
867
-     * 向指定 URL 发送POST方法的请求
868
-     * @Param [url, param]
869
-     * @Author ywx
870
-     * @Date 2021/5/6 16:01
871
-     * @return java.lang.String
872
-     **/
873
-    public static String sendJsonPost(String url, String param) {
874
-        OutputStreamWriter out = null;
875
-        BufferedReader in = null;
876
-        String result = "";
877
-        try {
878
-            URL realUrl = new URL(url);
879
-            // 打开和URL之间的连接
880
-            URLConnection conn = realUrl.openConnection();
881
-            // 设置通用的请求属性
882
-            conn.setRequestProperty("accept", "application/json");
883
-            conn.setRequestProperty("Content-Type","application/json;charset=UTF-8");
884
-            conn.setRequestProperty("connection", "Keep-Alive");
885
-            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
886
-            // 发送POST请求必须设置如下两行
887
-            conn.setDoOutput(true);
888
-            conn.setDoInput(true);
889
-            //设置请求编码格式
890
-            conn.setRequestProperty("Accept-Charset", "UTF-8");
891
-            // 文件流编码设置
892
-            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
893
-            out.write(param);
894
-            // flush输出流的缓冲
895
-            out.flush();
896
-            // 定义BufferedReader输入流来读取URL的响应
897
-            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
898
-            String line;
899
-            while ((line = in.readLine()) != null) {
900
-                result += line;
901
-            }
902
-        } catch (Exception e) {
903
-            System.out.println("发送 POST 请求出现异常!" + e.getMessage());
904
-        }
905
-        // 使用finally块来关闭输出流、输入流
906
-        finally {
907
-            try {
908
-                if (out != null) {
909
-                    out.close();
910
-                }
911
-                if (in != null) {
912
-                    in.close();
913
-                }
914
-            } catch (IOException ex) {
915
-                System.out.println("关闭输入输出流异常" + ex.getMessage());
916
-            }
917
-        }
918
-        return result;
919
-    }
920
-
921
-    /**
922
-     * 发送form-data请求返回json结果
923
-     * @Param [apiUrl, param]
924
-     * @Author ywx
925
-     * @Date 2021/5/14 17:41
926
-     * @return java.lang.String
927
-     **/
928
-    /*public static String sendFormData(String apiUrl, MultiValueMap<String, String> param) {
929
-        try {
930
-            HttpHeaders headers = new HttpHeaders();
931
-            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
932
-            List<MediaType> acceptableMediaTypes = new ArrayList<>();
933
-            acceptableMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
934
-            acceptableMediaTypes.add(MediaType.APPLICATION_PROBLEM_JSON_UTF8);
935
-            HttpEntity<MultiValueMap<String, String>> requestParams = new HttpEntity<>(param, headers);
936
-            ResponseEntity<String> response = new RestTemplate().postForEntity(apiUrl, requestParams, String.class);
937
-            String result = response.getBody();
938
-            return result;
939
-        } catch (RestClientException e) {
940
-            log.error("发送form-data请求失败",e.getMessage());
941
-            return null;
942
-        }
943
-    }*/
944
-
945 718
     static String CHN_NUMBER[] = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
946 719
     static String CHN_UNIT[] = { "", "十", "百", "千" }; // 权位
947 720
     static String CHN_UNIT_SECTION[] = { "", "万", "亿", "万亿" }; // 节权位
948 721
 
949
-    /**
950
-     * 阿拉伯数字转换为中文数字的核心算法实现。
951
-     * @return
952
-     */
953
-    public static String NumberToChn(int num) {
954
-        StringBuffer returnStr = new StringBuffer();
955
-        Boolean needZero = false;
956
-        int pos = 0; // 节权位的位置
957
-        if (num == 0) {
958
-            // 如果num为0,进行特殊处理。
959
-            returnStr.insert(0, CHN_NUMBER[0]);
960
-        }
961
-        while (num > 0) {
962
-            int section = num % 10000;
963
-            if (needZero) {
964
-                returnStr.insert(0, CHN_NUMBER[0]);
965
-            }
966
-            String sectionToChn = SectionNumToChn(section);
967
-            // 判断是否需要节权位
968
-            sectionToChn += (section != 0) ? CHN_UNIT_SECTION[pos] : CHN_UNIT_SECTION[0];
969
-            returnStr.insert(0, sectionToChn);
970
-            needZero = ((section < 1000 && section > 0) ? true : false); // 判断section中的千位上是不是为零,若为零应该添加一个零。
971
-            pos++;
972
-            num = num / 10000;
973
-        }
974
-        return returnStr.toString().replace("一十", "十");
975
-    }
976
-
977 722
     /**
978 723
      * 将四位的section转换为中文数字
979 724
      *
@@ -1006,39 +751,6 @@ public class N_Utils {
1006 751
         return returnStr.toString();
1007 752
     }
1008 753
 
1009
-    /**
1010
-     * 字符串是否包含在集合中的字符串集合
1011
-     * @Param [num, nums]
1012
-     * @Author ywx
1013
-     * @Date 2020/12/24 14:10
1014
-     * @return boolean
1015
-     **/
1016
-    public static boolean strInList(String num,List<String> nums){
1017
-        if (nums.contains(num)){
1018
-            return true;
1019
-        } else {
1020
-            return false;
1021
-        }
1022
-    }
1023
-
1024
-    //计算比例
1025
-    public static String getFs(int a, int b){  // 设置分子和分母
1026
-        int numerator;  // 分子
1027
-        int denominator; // 分母
1028
-        if(a == 0 || b == 0){
1029
-            numerator = a;
1030
-            denominator = b;
1031
-        }else{
1032
-            int c = f(Math.abs(a),Math.abs(b));         // 计算最大公约数
1033
-            numerator = a / c;
1034
-            denominator = b / c;
1035
-            if(numerator<0 && denominator<0){
1036
-                numerator = - numerator;
1037
-                denominator = - denominator;
1038
-            }
1039
-        }
1040
-        return numerator + ":" + denominator;
1041
-    }
1042 754
 
1043 755
     static int f(int a,int b){  // 求a和b的最大公约数
1044 756
         if(a < b){
@@ -1055,24 +767,7 @@ public class N_Utils {
1055 767
         return b;
1056 768
     }
1057 769
 
1058
-    //求一个数组的最大公约数
1059
-    public static int getArrMaxGys(int nums[]){
1060
-        int a=nums[0];int b=nums[1];int i=0;
1061
-        int temp;
1062
-        if(a<b){
1063
-            temp = a;
1064
-            a = b;
1065
-            b = temp;
1066
-            temp = a % b;
1067
-            while (temp != 0) {
1068
-                a = b;
1069
-                b = temp;
1070
-                temp = a % b;
1071
-            }
1072
-            nums[i + 1] = b;
1073
-        }
1074
-        return nums[nums.length - 1];
1075
-    }
770
+
1076 771
 
1077 772
     //处理题型中客观题1选择题2多选题456判断7完型填空全选择(弃用)8阅读理解全选择(弃用)10任务行阅读券选择(弃用)16完型填空复合17任务型阅读复合
1078 773
     private static int[] octypelist = new int[]{1,2,4,5,6,7,8,10,16,17};
@@ -1100,125 +795,38 @@ public class N_Utils {
1100 795
         }
1101 796
     }
1102 797
 
1103
-    //处理题型中复合题
1104
-    private static int[] cctypelist = new int[]{11,16,17};
1105
-    /*
1106
-     * 判断ctype是否是复合题
1107
-     * @Param [ctype]
1108
-     * @Author ywx
1109
-     * @Date 2022/10/18 19:11
1110
-     * @return boolean
1111
-     **/
1112
-    public static boolean isComplexQuestion(Integer ctype){
1113
-        if(ctype != null && ctype != 0){
1114
-            return IntStream.of(cctypelist).anyMatch(x -> x == ctype);
1115
-        }else{
1116
-            return false;
1117
-        }
1118
-    }
1119
-
1120
-    /*
1121
-    * @Description 年级集合(导入时根据名次获取对应数字)
1122
-    * @Author WN
1123
-    * @Date 2023/4/11 10:07
1124
-    */
1125
-    public static Map<String, Integer> listGrade() {
1126
-        Map m = new HashMap();
1127
-        m.put("一年级", 1);
1128
-        m.put("二年级", 2);
1129
-        m.put("三年级", 3);
1130
-        m.put("四年级", 4);
1131
-        m.put("五年级", 5);
1132
-        m.put("六年级", 6);
1133
-        m.put("七年级", 7);
1134
-        m.put("八年级", 8);
1135
-        m.put("九年级", 9);
1136
-        m.put("高一", 10);
1137
-        m.put("高二", 11);
1138
-        m.put("高三", 12);
1139
-        return m;
1140
-    }
1141
-
1142
-    /*
1143
-    * @Description 根据年级id获取年级名次
1144
-    * @Author WN
1145
-    * @Date 2023/4/11 10:07
1146
-    */
1147
-    public static String getGradeName(Integer gradeid){
1148
-        Map gradeMap = new HashMap();
1149
-        gradeMap.put(1, "一年级");
1150
-        gradeMap.put(2, "二年级");
1151
-        gradeMap.put(3, "三年级");
1152
-        gradeMap.put(4, "四年级");
1153
-        gradeMap.put(5, "五年级");
1154
-        gradeMap.put(6, "六年级");
1155
-        gradeMap.put(7, "七年级");
1156
-        gradeMap.put(8, "八年级");
1157
-        gradeMap.put(9, "九年级");
1158
-        gradeMap.put(10, "高一");
1159
-        gradeMap.put(11, "高二");
1160
-        gradeMap.put(12, "高三");
1161
-        String gradename = gradeMap.get(gradeid).toString();
1162
-        return gradename;
1163
-    }
1164 798
 
1165 799
     /**
1166
-     * 分数百分比
800
+     * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字舍弃。
1167 801
      *
1168
-     * @param v1 分数
1169
-     * @param v2 占比如80%写作0.8
1170
-     * @return
802
+     * @param v1    被除数
803
+     * @param v2    除数
804
+     * @param scale 表示表示需要精确到小数点以后几位。
805
+     * @return 两个参数的商
1171 806
      */
1172
-    public static double getScoreRateScore(double v1, double v2) {
1173
-        BigDecimal b1 = new BigDecimal(Double.toString(v1));
1174
-        BigDecimal b2 = new BigDecimal(Double.toString(v2));
1175
-
1176
-        return b1.multiply(b2).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
1177
-    }
1178
-
1179
-    /**
1180
-     * @Description 分值平均后得到的值,如果整除返回数组元素1,未整除返回元素数量2
1181
-     * @Param [num, score] 数量,分值
1182
-     * @Return java.lang.Double[] 第一个未平均分值,第二个值为最后一个数的分值
1183
-     * @Author wn
1184
-     * @Date 2022/8/18 11:07
1185
-     **/
1186
-    public static Double[] getPointAvgScore(int num, Double score) {
1187
-        BigDecimal bScore = new BigDecimal(Double.toString(score));
1188
-        BigDecimal bNum = new BigDecimal(Integer.toString(num));
1189
-
1190
-        //2023-07-04通过四舍五入进行计算,
1191
-        BigDecimal avg = bScore.divide(bNum, 1, BigDecimal.ROUND_HALF_UP);
1192
-        BigDecimal avgAllScore = avg.multiply(bNum);//平均分乘以数量得到的分值
1193
-        if (bScore.equals(avgAllScore)) {
1194
-            //说明整除
1195
-            return new Double[]{avg.doubleValue()};
1196
-        } else {
1197
-            //未整除,计算最后剩余分值,subtract总分减去平均分和数量的积
1198
-            // 平均分加上剩余得分得到最后一个分值
1199
-            BigDecimal lastScore = avg.add(bScore.subtract(avgAllScore));
1200
-            return new Double[]{avg.doubleValue(), lastScore.doubleValue()};
807
+    public static double div(double v1, double v2, int scale) {
808
+        try {
809
+            if (scale < 0) {
810
+                throw new IllegalArgumentException("The   scale   must   be   a   positive   integer   or   zero");
811
+            }
812
+            BigDecimal b1 = new BigDecimal(Double.toString(v1));
813
+            BigDecimal b2 = new BigDecimal(Double.toString(v2));
814
+            return b1.divide(b2, scale, BigDecimal.ROUND_DOWN).doubleValue();
815
+        } catch (Exception e) {
816
+            return 0;
1201 817
         }
1202 818
     }
1203 819
 
1204 820
     /**
1205
-     * @Description 是否是白名单接口
1206
-     * @Date 2023/11/3 9:26
1207
-     * @Author YWX
1208
-     * @Param [requestURI, whitelistAPI]
1209
-     * @Return boolean
1210
-     **/
1211
-    public static boolean whiteAPI(String requestURI, String whitelistAPI) {
1212
-        boolean rtn = false;
1213
-        if (isEmpty(whitelistAPI)) return rtn;
1214
-
1215
-        String[] apis = whitelistAPI.split(",");
1216
-        for (String api : apis) {
1217
-            if (requestURI.contains(api)) {
1218
-                rtn = true;
1219
-                break;
1220
-            }
1221
-        }
1222
-        return rtn;
821
+     * 提供精确的加法运算。
822
+     *
823
+     * @param v1 被加数
824
+     * @param v2 加数
825
+     * @return 两个参数的和
826
+     */
827
+    public static double add(double v1, double v2) {
828
+        BigDecimal b1 = new BigDecimal(Double.toString(v1));
829
+        BigDecimal b2 = new BigDecimal(Double.toString(v2));
830
+        return b1.add(b2).doubleValue();
1223 831
     }
1224 832
 }

+ 8
- 0
src/main/java/com/xhkjedu/vo/PaperStudentParams.java View File

@@ -23,8 +23,16 @@ public class PaperStudentParams {
23 23
     //学生答题卡图片
24 24
     private String stupic;
25 25
 
26
+    private Integer pagenum;
27
+
26 28
     private String examno;//学生准考证号
27 29
 
28 30
     //试卷中试题
29 31
     private List<EPaperStudentQuestion> questions;
32
+
33
+    //是否验证0待验证1验证通过2验证不通过
34
+    private Integer verified;
35
+
36
+    //是否和以前一致1一致2不一致
37
+    private Integer samed;
30 38
 }

+ 35
- 1
src/main/resources/EPaperVerifyMapper.xml View File

@@ -17,6 +17,7 @@
17 17
         <result column="epsid" property="epsid" />
18 18
         <result column="epid" property="epid" />
19 19
         <result column="stupic" property="stupic" />
20
+        <result column="pagenum" property="pagenum" />
20 21
         <result column="studentid" property="studentid" />
21 22
         <result column="username" property="username" />
22 23
         <result column="examno" property="examno" />
@@ -36,7 +37,7 @@
36 37
         </collection>
37 38
     </resultMap>
38 39
     <select id="getStudentPaper" resultMap="stuPaper">
39
-        SELECT ps.epsid,ps.epid,ps.stupic,ps.studentid,u.username,u.examno,ps.classid,c.classname,pt.qtypename,psq.epsqid,psq.eptqid,psq.qn,psq.ctype,psq.stuanswer
40
+        SELECT ps.epsid,ps.epid,ps.stupic,ps.pagenum,ps.studentid,u.username,u.examno,ps.classid,c.classname,pt.qtypename,psq.epsqid,psq.eptqid,psq.qn,psq.ctype,psq.stuanswer
40 41
         FROM e_paper_student0608 ps LEFT JOIN e_paper_student_question0608 psq ON ps.epsid=psq.epsid
41 42
         left JOIN e_paper_qtype_question pt ON psq.eptqid=pt.eptid
42 43
         left join t_user u on ps.studentid=u.userid
@@ -54,4 +55,37 @@
54 55
         select eptqid,eptid,epid,ctype,questionid,qtypeid,qtypename,qn,score,qorder,answer
55 56
         from e_paper_qtype_question where epid=#{epid} order by qorder
56 57
     </select>
58
+
59
+    <!--批量修改学生试题-->
60
+    <update id="updateBatchStuQuestion">
61
+        <foreach collection="list" item="q" separator=";">
62
+            update e_paper_student_question set answered=#{q.answered},answertype=#{q.answertype},stuanswer=#{q.stuanswer}
63
+            ,stuanswertxt=#{q.stuanswertxt},converted=#{q.converted}
64
+            <if test="q.answertime!=null">
65
+                ,answertime=#{q.answertime}
66
+            </if>
67
+            ,stuscore=#{q.stuscore}
68
+            ,checked=#{q.checked}
69
+            <if test="q.checktime!=null">
70
+                ,checktime=#{q.checktime}
71
+            </if>
72
+            where epid=#{q.epid} and studentid=#{studentid} and eptqid=#{q.eptqid}
73
+        </foreach>
74
+    </update>
75
+
76
+    <!--修改试卷状态-->
77
+    <update id="updateStuPaper">
78
+        update e_paper_student set stupic=#{p.stupic},pagenum=#{p.pagenum},sstate=#{p.sstate},checked=#{p.checked},
79
+        stuscore=#{p.stuscore},verified=1 where epid=#{p.epid} and studentid=#{p.studentid}
80
+    </update>
81
+
82
+    <!--修改单独试卷审核状态-->
83
+    <update id="updateStuPaperVerified">
84
+        update e_paper_student set verified=#{p.verified} where epid=#{p.epid} and studentid=#{p.studentid}
85
+    </update>
86
+
87
+    <!--修改新表试卷状态-->
88
+    <update id="updateStuPaper0608">
89
+        update e_paper_student0608 set verified=#{p.verified},samed=#{p.samed} where epid=#{p.epid} and studentid=#{p.studentid}
90
+    </update>
57 91
 </mapper>

Loading…
Cancel
Save