fangmingyue 2 lat temu
rodzic
commit
d1c6a27fe5

db/.back_文明创办/文明创办-backup-2023323142415.pdma.json → db/.back_文明创办/文明创办-backup-2023415134743.pdma.json Wyświetl plik

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-3-23 14:23:34",
7
+  "updatedTime": "2023-3-30 10:05:54",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -493,7 +493,8 @@
493 493
         "refKey": "extProps",
494 494
         "hideInGraph": true
495 495
       }
496
-    ]
496
+    ],
497
+    "modelType": "modalGroup"
497 498
   },
498 499
   "entities": [
499 500
     {
@@ -3911,6 +3912,23 @@
3911 3912
           "refDict": "",
3912 3913
           "uiHint": "",
3913 3914
           "id": "7FF626A4-AF1C-4CF5-B356-D46DB6D534B3"
3915
+        },
3916
+        {
3917
+          "defKey": "copy_from",
3918
+          "defName": "复制来源",
3919
+          "comment": "",
3920
+          "type": "",
3921
+          "len": "",
3922
+          "scale": "",
3923
+          "primaryKey": false,
3924
+          "notNull": false,
3925
+          "autoIncrement": false,
3926
+          "defaultValue": "",
3927
+          "hideInGraph": false,
3928
+          "refDict": "",
3929
+          "extProps": {},
3930
+          "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
3931
+          "id": "1F85BFC4-DBF4-4BA5-9BD8-DC9C2BFA1646"
3914 3932
         }
3915 3933
       ],
3916 3934
       "correlations": [],
@@ -5471,6 +5489,23 @@
5471 5489
           "refDict": "",
5472 5490
           "uiHint": "",
5473 5491
           "id": "4D9B5070-3252-4714-86D7-34928A0C5552"
5492
+        },
5493
+        {
5494
+          "defKey": "copy_from",
5495
+          "defName": "拷贝来源",
5496
+          "comment": "",
5497
+          "type": "",
5498
+          "len": "",
5499
+          "scale": "",
5500
+          "primaryKey": false,
5501
+          "notNull": false,
5502
+          "autoIncrement": false,
5503
+          "defaultValue": "",
5504
+          "hideInGraph": false,
5505
+          "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
5506
+          "refDict": "",
5507
+          "extProps": {},
5508
+          "id": "0279B08D-E12C-4409-8253-A5D7766A7133"
5474 5509
         }
5475 5510
       ],
5476 5511
       "correlations": [],
@@ -6460,6 +6495,23 @@
6460 6495
           "extProps": {},
6461 6496
           "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
6462 6497
           "id": "A8365D64-DE0A-4F0E-9427-83DFF0ED66C6"
6498
+        },
6499
+        {
6500
+          "defKey": "copy_from",
6501
+          "defName": "拷贝来源",
6502
+          "comment": "",
6503
+          "type": "",
6504
+          "len": "",
6505
+          "scale": "",
6506
+          "primaryKey": false,
6507
+          "notNull": false,
6508
+          "autoIncrement": false,
6509
+          "defaultValue": "",
6510
+          "hideInGraph": false,
6511
+          "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
6512
+          "refDict": "",
6513
+          "extProps": {},
6514
+          "id": "E2BA367C-D262-43FB-A729-D26D6453D20C"
6463 6515
         }
6464 6516
       ],
6465 6517
       "correlations": [],
@@ -7685,6 +7737,23 @@
7685 7737
           "refDict": "",
7686 7738
           "extProps": {},
7687 7739
           "id": "90218D19-7731-4AFE-8883-74944A66D6C8"
7740
+        },
7741
+        {
7742
+          "defKey": "copy_from",
7743
+          "defName": "拷贝来源",
7744
+          "comment": "",
7745
+          "type": "",
7746
+          "len": "",
7747
+          "scale": "",
7748
+          "primaryKey": false,
7749
+          "notNull": false,
7750
+          "autoIncrement": false,
7751
+          "defaultValue": "",
7752
+          "hideInGraph": false,
7753
+          "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
7754
+          "refDict": "",
7755
+          "extProps": {},
7756
+          "id": "C0B26905-831F-4891-9B83-F84E4D111C44"
7688 7757
         }
7689 7758
       ],
7690 7759
       "correlations": [],

+ 4
- 3
db/文明创办.pdma.json Wyświetl plik

@@ -2,9 +2,9 @@
2 2
   "name": "文明创办",
3 3
   "describe": "文明创办",
4 4
   "avatar": "",
5
-  "version": "4.1.4",
5
+  "version": "4.1.1",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-3-30 10:05:54",
7
+  "updatedTime": "2023-4-15 13:47:43",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -494,7 +494,8 @@
494 494
         "hideInGraph": true
495 495
       }
496 496
     ],
497
-    "modelType": "modalGroup"
497
+    "modelType": "modalGroup",
498
+    "menuWidth": "250px"
498 499
   },
499 500
   "entities": [
500 501
     {

+ 1
- 1
src/main/java/com/example/civilizedcity/entity/TdQuestion.java Wyświetl plik

@@ -37,7 +37,7 @@ public class TdQuestion implements Serializable,Cloneable{
37 37
      private String title ;
38 38
      /** 正确答案 */
39 39
      @ApiModelProperty(name = "正确答案",notes = "")
40
-     private String rightAnswers ;
40
+          private String rightAnswers ;
41 41
      /** 状态 */
42 42
      @ApiModelProperty(name = "状态",notes = "")
43 43
      private Integer status ;

+ 2
- 0
src/main/java/com/example/civilizedcity/mapper/TaCheckItemMapper.java Wyświetl plik

@@ -26,4 +26,6 @@ public interface TaCheckItemMapper  extends BaseMapper<TaCheckItem>{
26 26
      List<TaCheckItem> getListBy(@Param("checkId") String checkId, @Param("itemType") String itemType);
27 27
 
28 28
     long copyItems(@Param("oldCheckId") String oldCheckId, @Param("newCheckId") String newCheckId);
29
+
30
+    double sumScore(@Param("checkId") String checkId, @Param("itemType") String itemType);
29 31
 }

+ 59
- 73
src/main/java/com/example/civilizedcity/service/impl/TaCheckItemServiceImpl.java Wyświetl plik

@@ -84,95 +84,88 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
84 84
             throw new Exception("验证部分题干信息出错");
85 85
         }
86 86
 
87
-        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
88
-            // 如果是实地问卷, 试卷份数不能多于规定份数
89
-            int count = taCheckAnswerMapper.countByItem(taCheckItem.getItemId());
90
-            if (count >= taCheckItem.getNum()) {
91
-                throw new Exception("当前实地问卷已收齐, 无须作答");
92
-            }
93
-        }
94
-
95
-        // 答题的时候, 顺便把问题单生成好
96
-        double[] scores = answerItems(taCheckItem, taCheckAnswer, quList, answerItemList, sysUser);
97
-
98
-        if (Constants.CHECK_OF_SURVEY.equals(taCheckItem.getItemType())) {
99
-            // 调查问卷不需要计算当前试卷的分数, 最后才能计算出来
100
-            taCheckAnswerMapper.insert(taCheckAnswer);
101
-
102
-//            // 但是需要更新答卷份数
87
+//        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
88
+//            // 如果是实地问卷, 试卷份数不能多于规定份数
103 89
 //            int count = taCheckAnswerMapper.countByItem(taCheckItem.getItemId());
104
-//            taCheckItem.setNum(count);
105
-//            updateById(taCheckItem);
106
-            return;
107
-        }
108
-
109
-        if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
110
-            // 实地调查, 需要计算当前这份试卷的分数
111
-            double positiveScore = scores[0];
112
-            double negativeScore = scores[1];
113
-
114
-            // 每份试卷的得分 = 总分 / 份数
115
-            double maxScore = taCheckItem.getFullScore()  / taCheckItem.getNum();
116
-            double score = negativeScore + positiveScore;
117
-//
118
-            if (score > 0) {
119
-                // 没有扣分就是满分
120
-                score = maxScore;
121
-            } else {
122
-                // 有扣分项, 总分 - 扣分
123
-                score = maxScore + score;
124
-            }
125
-
126
-            // 如果得分超过总分
127
-            if (score > maxScore) {
128
-                score = maxScore;
129
-            }
130
-
131
-            taCheckAnswer.setScore(score);
132
-            taCheckAnswerMapper.insert(taCheckAnswer);
133
-        }
90
+//            if (count >= taCheckItem.getNum()) {
91
+//                throw new Exception("当前实地问卷已收齐, 无须作答");
92
+//            }
93
+//        }
94
+
95
+        // 计算每一题的得分, 以及总分
96
+        // 并同步生成问题单
97
+        double score = calcAnswerItems(sysUser, taCheckItem, taCheckAnswer, quList, answerItemList);
98
+        taCheckAnswer.setScore(score);
99
+        taCheckAnswerMapper.insert(taCheckAnswer);
134 100
     }
135 101
 
136 102
     /**
137
-     * 计算每份试卷份数
103
+     * 作答计算分数
104
+     * 试卷总分 = 每一题分数求和
105
+     * 选择题分数 = 选中的选项分数
106
+     * 填空题分数 = 填写的数字 * 对应的分值
107
+     * @param sysUser
138 108
      * @param taCheckItem
139 109
      * @param taCheckAnswer
110
+     * @param quList
111
+     * @param answerItemList
140 112
      * @throws Exception
141 113
      */
142
-    private double[] answerItems(TaCheckItem taCheckItem,
143
-                                 TaCheckAnswer taCheckAnswer,
144
-                                 List<TaCheckItemQu> quList,
145
-                                 List<TaCheckAnswerItem> answerItemList,
146
-                                 SysUser sysUser
147
-    ) throws Exception {
114
+    private double calcAnswerItems(
115
+            SysUser sysUser,
116
+            TaCheckItem taCheckItem,
117
+            TaCheckAnswer taCheckAnswer,
118
+            List<TaCheckItemQu> quList,
119
+            List<TaCheckAnswerItem> answerItemList
120
+    ) throws Exception{
148 121
         LocalDateTime now = LocalDateTime.now();
149
-        double negativeScore = 0.0; // 扣分
150
-        double positiveScore = 0.0; // 得分
122
+        //题目分值
123
+        double totalScore = 0.0;
151 124
         for(TaCheckAnswerItem item : answerItemList) {
152
-            boolean mustCreateIssue = false;
125
+            // 每一题分值
126
+            double score = 0.0;
153 127
             // 找到对应的题目
154 128
             TaCheckItemQu qu = getQu(quList, item.getQuId());
155 129
             // 如果是选择题, 对应的答案
156 130
             TaCheckItemAn standAn = null;
157
-            // + 代表得分, 否则代表扣分
158
-            int sign = "+".equals(qu.getComputeType()) ? 1 : -1;
159 131
 
160
-            double score = 0.0;
161 132
             if (Constants.QU_OF_FILL.equals(qu.getQuType())) {
162 133
                 // 如果是填空题, 用户填的应该是数字, 没填就是 0
163
-                Double an = StringUtils.isEmpty(item.getAnswer()) ? 0.0 : Double.parseDouble(item.getAnswer());
164
-                score = an * qu.getAnScore();
134
+                Double fillNum = StringUtils.isEmpty(item.getAnswer()) ? 0.0 : Double.parseDouble(item.getAnswer());
135
+
136
+                // 填空得分 = 填空的数字 * 每个数字的分数
137
+                Double fillScore = fillNum * qu.getAnScore();
138
+
139
+                // 如果是扣分项, 那么得分 = 总分 - 扣分
140
+                if (fillScore < 0) {
141
+                    score = qu.getMaxScore() + fillScore;
142
+                    if (score < 0) {
143
+                        score = 0;
144
+                    }
145
+                } else {
146
+                    // 如果是得分项, 那么 分数 = 得分
147
+                    score = fillScore;
148
+                }
165 149
             } else if (Constants.QU_OF_RADIO.equals(qu.getQuType())) {
166 150
                 // 如果是选择题, 找到对应的答案
167 151
                 standAn = taCheckItemAnMapper.getOneBy(qu.getQuId(), item.getAnswerCode());
168
-
169 152
                 score = standAn.getScore();
170 153
             }
171 154
 
155
+            // 如果得分超过最大值
172 156
             if (score > qu.getMaxScore()) {
173 157
                 score = qu.getMaxScore();
174 158
             }
175
-            score *= sign;
159
+
160
+            // 判断是否需要生成问题单
161
+            boolean isIssue = false;
162
+            if (score < qu.getMaxScore()) {
163
+                // 如果当前这个题目, 没有得到满分, 就生成问题单
164
+                isIssue = true;
165
+            }
166
+
167
+            // 每份试卷的分数 = 各题目的分数求和
168
+            totalScore += score;
176 169
 
177 170
             item.setItemId(StringUtils.uuid());
178 171
             item.setAnswerId(taCheckAnswer.getAnswerId());
@@ -182,13 +175,6 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
182 175
             item.setStatus(Constants.STATUS_NORMAL);
183 176
             taCheckAnswerItemMapper.insert(item);
184 177
 
185
-            if (score > 0) {
186
-                positiveScore += score;
187
-            } else {
188
-                mustCreateIssue = true;
189
-                negativeScore += score;
190
-            }
191
-
192 178
             // 保存附件
193 179
             if (null != item.getAttachList()) {
194 180
                 for (TaAttach taAttach : item.getAttachList()) {
@@ -202,13 +188,13 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
202 188
                 }
203 189
             }
204 190
 
205
-            // 如果得分小于0, 说明是扣分项, 生成问题单
206
-            if (mustCreateIssue && Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
191
+            // 点位问题,生成问题单
192
+            if (Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType()) && isIssue) {
207 193
                 createNewIssue(sysUser, taCheckItem, qu, standAn, taCheckAnswer, item);
208 194
             }
209 195
         }
210 196
 
211
-        return new double[] {positiveScore, negativeScore};
197
+        return totalScore;
212 198
     }
213 199
 
214 200
     private void createNewIssue(SysUser sysUser,

+ 2
- 131
src/main/java/com/example/civilizedcity/service/impl/TaCheckServiceImpl.java Wyświetl plik

@@ -38,16 +38,15 @@ public class TaCheckServiceImpl extends BaseServiceImpl<TaCheckMapper, TaCheck>
38 38
     public TaCheck calcScore(TaCheck taCheck) {
39 39
 
40 40
         // 调查问卷分数
41
-        double surveyScore = calcSurveyScore(taCheck);
41
+        double surveyScore = taCheckItemMapper.sumScore(taCheck.getCheckId(), Constants.CHECK_OF_SURVEY);
42 42
 
43 43
         // 计算点位分数
44
-        double locScore = calcLocScore(taCheck);
44
+        double locScore = taCheckItemMapper.sumScore(taCheck.getCheckId(), Constants.CHECK_OF_LOC);
45 45
 
46 46
         taCheck.setLocScore(locScore);
47 47
         taCheck.setSurveyScore(surveyScore);
48 48
 
49 49
         updateById(taCheck);
50
-
51 50
         return taCheck;
52 51
     }
53 52
 
@@ -78,132 +77,4 @@ public class TaCheckServiceImpl extends BaseServiceImpl<TaCheckMapper, TaCheck>
78 77
         return newCheck;
79 78
     }
80 79
 
81
-    /**
82
-     * 计算点位分数
83
-     * 计算的前提是, 每份试卷(ta_check_answer)的分数已经计算好了
84
-     * @param taCheck
85
-     * @return
86
-     */
87
-    private double calcLocScore(TaCheck taCheck) {
88
-        List<TaCheckItem> checkItemList = taCheckItemMapper.getListBy(taCheck.getCheckId(), Constants.CHECK_OF_LOC);
89
-        if (null == checkItemList || checkItemList.size() == 0) return 0.0;
90
-
91
-        // 所有试卷得分的和
92
-        double totalScore = 0.0;
93
-        for (TaCheckItem checkItem : checkItemList) {
94
-            Double score = taCheckAnswerMapper.sumScore(checkItem.getItemId(), checkItem.getNum());
95
-            double s = null == score ? 0.0 : score;
96
-
97
-            checkItem.setScore(s);
98
-            taCheckItemMapper.updateById(checkItem);
99
-
100
-            totalScore += s;
101
-        }
102
-
103
-        return totalScore;
104
-    }
105
-
106
-    /**
107
-     * 计算调查问卷分数
108
-     * 计算的前提是, 每个题目(ta_check_answer_item)的分数已经计算好了
109
-     * 暂仅支持选择题算法
110
-     * 总分数 = 100 / 问卷分数 / 每份问卷的题数
111
-     * @param taCheck
112
-     * @return
113
-     */
114
-    private double calcSurveyScore(TaCheck taCheck) {
115
-        // 目前的需求, 此处应该只能查询到一条数据
116
-        List<TaCheckItem> checkItemList = taCheckItemMapper.getListBy(taCheck.getCheckId(), Constants.CHECK_OF_SURVEY);
117
-        if (null == checkItemList || checkItemList.size() == 0) return 0.0;
118
-
119
-        // 所有问卷得分的和
120
-        double totalScore = 0.0;
121
-        for (TaCheckItem checkItem : checkItemList) {
122
-            // 问卷份数
123
-            List<TaCheckAnswer> answerList = taCheckAnswerMapper.getListByLimit(checkItem.getItemId(), checkItem.getNum());
124
-            if (answerList == null || answerList.size() == 0) continue;
125
-            int copyNum = answerList.size();
126
-
127
-            // 题目数
128
-            List<TaCheckItemQu> quList = taCheckItemQuMapper.getListBy(checkItem.getItemId());
129
-            if (quList == null || quList.size() == 0) continue;
130
-            int quNum = quList.size();
131
-
132
-            // 每份试卷的最大分数
133
-            double maxItemScore = 100.00 / copyNum;
134
-            // 每题的最大分数
135
-            double maxStandScore = maxItemScore / quNum;
136
-
137
-            // 总分
138
-            double score = 0.0;
139
-            for (TaCheckAnswer answer : answerList) {
140
-                // 获取答案列表
141
-                List<TaCheckAnswerItem> answerItemList = taCheckAnswerItemMapper.getListBy(answer.getAnswerId());
142
-                if (null == answerItemList || answerItemList.size() == 0) continue;
143
-
144
-                // 每份试卷得分
145
-                double quScore = 0.0;
146
-                for (TaCheckAnswerItem answerItem : answerItemList) {
147
-                    if (null == answerItem.getScore() || isZero(answerItem.getScore())) {
148
-                        // 如果得分是 0
149
-                        continue;
150
-                    }
151
-
152
-                    // 查询对应的问题
153
-                    TaCheckItemQu qu = getQu(quList, answerItem.getQuId());
154
-                    if (null == qu) continue;   // 找不到对应题目不计算
155
-                    if (null == qu.getMaxScore() || isZero(qu.getMaxScore())) continue; // 题目没有维护最大分数, 不计算
156
-
157
-                    // 计算转换比
158
-                    double ratio = maxStandScore / qu.getMaxScore();
159
-
160
-                    // 当前得分
161
-                    double s = answerItem.getScore();
162
-//                    double s = Math.abs(answerItem.getScore()) > qu.getMaxScore() ?  qu.getMaxScore() : answerItem.getScore();
163
-//                    if (answerItem.getScore() < 0) {
164
-//                        // 在与最大值的比较过程中, 最大值是正数, 有可能改变得分的符号
165
-//                        // 所以此处要纠正过来
166
-//                        s = 0 - Math.abs(s);
167
-//                    }
168
-
169
-                    // 分值
170
-                    quScore += s * ratio;
171
-                }
172
-
173
-                // 不能超过试卷的最大分数
174
-                if (quScore > maxItemScore) {
175
-                    quScore = maxItemScore;
176
-                }
177
-
178
-                answer.setScore(quScore);
179
-                taCheckAnswerMapper.updateById(answer);
180
-
181
-                // 分值
182
-                score += quScore;
183
-            }
184
-
185
-            // 调查问卷理论上不会出现分数为负的情况
186
-            if (score < 0) {
187
-                score = maxItemScore + score;
188
-                if (score < 0) {
189
-                    score = 0;
190
-                }
191
-            }
192
-
193
-            checkItem.setScore(score);
194
-            taCheckItemMapper.updateById(checkItem);
195
-
196
-            totalScore += score;
197
-        }
198
-
199
-        return totalScore;
200
-    }
201
-
202
-    private TaCheckItemQu getQu(List<TaCheckItemQu> quList, String quId) {
203
-        return quList.stream().filter(q -> q.getQuId().equals(quId)).findFirst().orElse(null);
204
-    }
205
-
206
-    private boolean isZero(Double d) {
207
-        return Math.abs(d) < 0.0001;
208
-    }
209 80
 }

+ 10
- 0
src/main/resources/mapper/TaCheckItemMapper.xml Wyświetl plik

@@ -89,4 +89,14 @@
89 89
           AND t.item_type = #{itemType}
90 90
           AND t.`status` &gt; -1
91 91
     </select>
92
+    <select id="sumScore" resultType="java.lang.Double">
93
+        SELECT
94
+            SUM(t.score)
95
+        FROM
96
+            ta_check_item t
97
+        WHERE
98
+            t.check_id = #{checkId}
99
+          AND t.item_type = #{itemType}
100
+          AND t.`status` &gt; -1
101
+    </select>
92 102
 </mapper>