Yansen 2 yıl önce
ebeveyn
işleme
ee81287cdd

+ 3
- 3
src/main/java/com/example/civilizedcity/controller/TaCheckItemController.java Dosyayı Görüntüle

@@ -207,7 +207,7 @@ public class TaCheckItemController extends BaseController {
207 207
      * @param id 实例对象
208 208
      * @return 实例对象
209 209
      */
210
-    @ApiOperation("更新数据")
210
+    @ApiOperation("获取回答")
211 211
     @GetMapping("/taCheckItem/{id}/answer")
212 212
     public ResponseBean getAnswer(@ApiParam("对象ID") @PathVariable String id) throws Exception {
213 213
 
@@ -222,7 +222,7 @@ public class TaCheckItemController extends BaseController {
222 222
      * @param taCheckAnswer 实例对象
223 223
      * @return 实例对象
224 224
      */
225
-    @ApiOperation("更新数据")
225
+    @ApiOperation("回答问题")
226 226
     @PutMapping("/taCheckItem/{id}/answer")
227 227
     public ResponseBean answer(@ApiParam("对象实体") @RequestBody TaCheckAnswer taCheckAnswer,
228 228
                                @ApiParam("对象ID") @PathVariable String id) throws Exception {
@@ -259,7 +259,7 @@ public class TaCheckItemController extends BaseController {
259 259
         taCheckAnswer.setCreateUser(sysUser.getUserId());
260 260
         taCheckAnswer.setCreateDate(LocalDateTime.now());
261 261
 
262
-        taCheckItemService.answer(taCheckItem, taCheckAnswer);
262
+        taCheckItemService.answer(taCheckItem, taCheckAnswer, sysUser);
263 263
         return ResponseBean.success(taCheckAnswer);
264 264
     }
265 265
 

+ 4
- 2
src/main/java/com/example/civilizedcity/controller/TaIssueApplyController.java Dosyayı Görüntüle

@@ -11,6 +11,7 @@ import com.example.civilizedcity.common.StringUtils;
11 11
 import com.example.civilizedcity.entity.SysUser;
12 12
 import com.example.civilizedcity.service.TaIssueService;
13 13
 import com.example.civilizedcity.service.TaOrgIssueService;
14
+import com.sun.org.apache.xpath.internal.operations.Bool;
14 15
 import io.swagger.annotations.Api;
15 16
 import io.swagger.annotations.ApiOperation;
16 17
 import io.swagger.annotations.ApiParam;
@@ -97,13 +98,14 @@ public class TaIssueApplyController extends BaseController {
97 98
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
98 99
                              @ApiParam("问题单ID") @RequestParam(value = "issueId", required = false) Integer issueId,
99 100
                              @ApiParam("申请类型") @RequestParam(value = "applyType", required = false) String applyType,
100
-                             @ApiParam("问题单来源") @RequestParam(value = "sourceType", required = false) String sourceType) throws Exception {
101
+                             @ApiParam("问题单来源") @RequestParam(value = "sourceType", required = false) String sourceType,
102
+                             @ApiParam(value = "是否全部") @RequestParam(value = "isAll", defaultValue = "false") Boolean isAll) throws Exception {
101 103
 
102 104
         SysUser sysUser = currentUser();
103 105
         String orgId = isManager(sysUser) ? null : sysUser.getOrgId();
104 106
 
105 107
         IPage<TaIssueApply> pg = new Page<>(pageNum, pageSize);
106
-        IPage<TaIssueApply> result = taIssueApplyService.getPageBy(pg, issueId, applyType, orgId, sourceType);
108
+        IPage<TaIssueApply> result = taIssueApplyService.getPageBy(pg, issueId, applyType, orgId, sourceType, isAll);
107 109
 
108 110
         return ResponseBean.success(result);
109 111
     }

+ 3
- 0
src/main/java/com/example/civilizedcity/controller/TaIssueController.java Dosyayı Görüntüle

@@ -111,6 +111,9 @@ public class TaIssueController extends BaseController {
111 111
             // 已打回
112 112
             queryWrapper.eq("process_node", Constants.PROCESS_APPLY_REJECT);
113 113
             queryWrapper.eq("process_status", Constants.APPLY_PASS);
114
+        } else {
115
+            // 其余节点
116
+            queryWrapper.likeRight(!StringUtils.isEmpty(bizStatus), "process_node", bizStatus);
114 117
         }
115 118
 
116 119
         if (mine) {

+ 2
- 1
src/main/java/com/example/civilizedcity/mapper/TaIssueApplyMapper.java Dosyayı Görüntüle

@@ -18,5 +18,6 @@ public interface TaIssueApplyMapper  extends BaseMapper<TaIssueApply>{
18 18
                                    @Param("issueId") Integer issueId,
19 19
                                    @Param("applyType") String applyType,
20 20
                                    @Param("orgId") String orgId,
21
-                                   @Param("sourceType") String sourceType);
21
+                                   @Param("sourceType") String sourceType,
22
+                                   @Param("isAll") Boolean isAll);
22 23
  }

+ 1
- 1
src/main/java/com/example/civilizedcity/service/TaCheckItemService.java Dosyayı Görüntüle

@@ -17,5 +17,5 @@ public interface TaCheckItemService extends IBaseService<TaCheckItem> {
17 17
 
18 18
      void createNewItems(TaCheck taCheck);
19 19
 
20
-     void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer) throws Exception;
20
+     void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer, SysUser sysUser) throws Exception;
21 21
  }

+ 1
- 2
src/main/java/com/example/civilizedcity/service/TaIssueApplyService.java Dosyayı Görüntüle

@@ -1,7 +1,6 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5 4
 import com.example.civilizedcity.entity.SysUser;
6 5
 import com.example.civilizedcity.entity.TaIssueApply;
7 6
 
@@ -14,7 +13,7 @@ public interface TaIssueApplyService extends IBaseService<TaIssueApply> {
14 13
 
15 14
      void createNewApply(TaIssueApply taIssueApply, SysUser sysUser) throws Exception;
16 15
 
17
-     IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType);
16
+     IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType, Boolean isAll);
18 17
 
19 18
      void verify(TaIssueApply taIssueApply, SysUser sysUser, TaIssueApply origin) throws Exception;
20 19
  }

+ 89
- 7
src/main/java/com/example/civilizedcity/service/impl/TaCheckItemServiceImpl.java Dosyayı Görüntüle

@@ -11,7 +11,9 @@ import com.example.civilizedcity.service.TaCheckItemService;
11 11
 import org.springframework.transaction.annotation.Transactional;
12 12
 
13 13
 import java.time.LocalDateTime;
14
+import java.util.ArrayList;
14 15
 import java.util.List;
16
+import java.util.stream.Collectors;
15 17
 
16 18
 /**
17 19
  * 测评点位;(ta_check_item)表服务实现类
@@ -37,6 +39,15 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
37 39
     @Autowired
38 40
     TaAttachMapper taAttachMapper;
39 41
 
42
+    @Autowired
43
+    SysUserMapper sysUserMapper;
44
+
45
+    @Autowired
46
+    TaIssueMapper taIssueMapper;
47
+
48
+    @Autowired
49
+    TaIssueProcessMapper taIssueProcessMapper;
50
+
40 51
     @Override
41 52
     public IPage<TaCheckItem> getPageBy(IPage<TaCheckItem> pg, String checkId, String itemType) {
42 53
         return baseMapper.getPageBy(pg, checkId, itemType);
@@ -56,7 +67,7 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
56 67
 
57 68
     @Transactional(rollbackFor = Exception.class)
58 69
     @Override
59
-    public void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer) throws Exception {
70
+    public void answer(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer, SysUser sysUser) throws Exception {
60 71
         List<TaCheckItemQu> quList = taCheckItemQuMapper.getListBy(taCheckItem.getItemId());
61 72
         if (null == quList || quList.size() < 1) {
62 73
             throw new Exception("校验测评问题列表出错");
@@ -81,8 +92,8 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
81 92
             }
82 93
         }
83 94
 
84
-
85
-        double[] scores = answerItems(taCheckItem, taCheckAnswer, quList, answerItemList);
95
+        // 答题的时候, 顺便把问题单生成好
96
+        double[] scores = answerItems(taCheckItem, taCheckAnswer, quList, answerItemList, sysUser);
86 97
 
87 98
         if (Constants.CHECK_OF_SURVEY.equals(taCheckItem.getItemType())) {
88 99
             // 调查问卷不需要计算当前试卷的分数, 最后才能计算出来
@@ -124,14 +135,20 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
124 135
      * @param taCheckAnswer
125 136
      * @throws Exception
126 137
      */
127
-    private double[] answerItems(TaCheckItem taCheckItem, TaCheckAnswer taCheckAnswer, List<TaCheckItemQu> quList, List<TaCheckAnswerItem> answerItemList) throws Exception {
128
-
138
+    private double[] answerItems(TaCheckItem taCheckItem,
139
+                                 TaCheckAnswer taCheckAnswer,
140
+                                 List<TaCheckItemQu> quList,
141
+                                 List<TaCheckAnswerItem> answerItemList,
142
+                                 SysUser sysUser
143
+    ) throws Exception {
129 144
         LocalDateTime now = LocalDateTime.now();
130 145
         double negativeScore = 0.0; // 扣分
131 146
         double positiveScore = 0.0; // 得分
132 147
         for(TaCheckAnswerItem item : answerItemList) {
133 148
             // 找到对应的题目
134 149
             TaCheckItemQu qu = getQu(quList, item.getQuId());
150
+            // 如果是选择题, 对应的答案
151
+            TaCheckItemAn standAn = null;
135 152
             // + 代表得分, 否则代表扣分
136 153
             int sign = "+".equals(qu.getComputeType()) ? 1 : -1;
137 154
 
@@ -146,8 +163,8 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
146 163
 
147 164
                 score *= sign;
148 165
             } else if (Constants.QU_OF_RADIO.equals(qu.getQuType())) {
149
-                // 如果是选择题, 找到对应的答案
150
-                TaCheckItemAn standAn = taCheckItemAnMapper.getOneBy(qu.getQuId(), item.getAnswerCode());
166
+                // 如果是选择题, 找到对应的答案
167
+                standAn = taCheckItemAnMapper.getOneBy(qu.getQuId(), item.getAnswerCode());
151 168
 
152 169
                 score = standAn.getScore();
153 170
                 if (score > qu.getMaxScore()) {
@@ -174,6 +191,7 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
174 191
             // 保存附件
175 192
             if (null != item.getAttachList()) {
176 193
                 for (TaAttach taAttach : item.getAttachList()) {
194
+                    taAttach.setAttachId(null);
177 195
                     taAttach.setOwnerType(Constants.SOURCE_CHECK_ANSWER);
178 196
                     taAttach.setOwnerId(item.getItemId());
179 197
                     taAttach.setStatus(Constants.STATUS_NORMAL);
@@ -182,11 +200,75 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
182 200
                     taAttachMapper.insert(taAttach);
183 201
                 }
184 202
             }
203
+
204
+            // 如果得分小于0, 说明是扣分项, 生成问题单
205
+            if (score < 0 && Constants.CHECK_OF_LOC.equals(taCheckItem.getItemType())) {
206
+                createNewIssue(sysUser, taCheckItem, qu, standAn, item);
207
+            }
185 208
         }
186 209
 
187 210
         return new double[] {positiveScore, negativeScore};
188 211
     }
189 212
 
213
+    private void createNewIssue(SysUser sysUser,
214
+                                   TaCheckItem taCheckItem,
215
+                                   TaCheckItemQu qu,
216
+                                   TaCheckItemAn an,
217
+                                   TaCheckAnswerItem answer) {
218
+        LocalDateTime now = LocalDateTime.now();
219
+        TaIssue taIssue = new TaIssue();
220
+        taIssue.setLocId(taCheckItem.getTypeId());
221
+        taIssue.setLocName(taCheckItem.getName());
222
+
223
+        // 如果是选择题, 答案 answer 的内容只是代码, 所以需要从 TaCheckItemAn 把对应的文字拿出来
224
+        // 如果是填空题, 那么文字是 答案(数字) + 单位(fillUnit) , 最后结果类似 5 处。
225
+        String answerStr = Constants.QU_OF_FILL.equals(qu.getQuType())
226
+                ? an.getAnswer()
227
+                : String.format("%s %s", answer.getAnswer(), qu.getFillUnit());
228
+        taIssue.setContent(String.format("%s 测评结果 %s", qu.getTitle(), answerStr));
229
+        taIssue.setProcessNode(Constants.PROCESS_START);
230
+        taIssue.setProcessStatus(Constants.APPLY_PASS); // 模拟测评的不需要审核
231
+        taIssue.setProcessNum(0);
232
+        taIssue.setOrgId(null);
233
+        taIssue.setSourceType(Constants.SOURCE_CHECK);
234
+        taIssue.setSourceTarget(answer.getItemId()); // 实际作答的ID, 非测评项目表 ID
235
+        taIssue.setStatus(Constants.STATUS_NORMAL);
236
+        taIssue.setCreateUser(sysUser.getUserId());
237
+        taIssue.setUserName(sysUser.getName());
238
+        taIssue.setCreateDate(now);
239
+        taIssueMapper.insert(taIssue);
240
+
241
+        // 保存文件
242
+        List<TaAttach> attachList = answer.getAttachList();
243
+        if (null != attachList && attachList.size() > 0) {
244
+            for (TaAttach item : attachList) {
245
+                // 生成新对象, 目的是不影响 item;
246
+                TaAttach newItem = new TaAttach();
247
+                newItem.setAttachId(null);
248
+                newItem.setFileType(item.getFileType());
249
+                newItem.setName(item.getName());
250
+                newItem.setUrl(item.getUrl());
251
+                newItem.setOwnerType(Constants.SOURCE_ISSUE);
252
+                newItem.setOwnerId(taIssue.getIssueId().toString());
253
+                newItem.setStatus(Constants.STATUS_NORMAL);
254
+                newItem.setCreateDate(now);
255
+                taAttachMapper.insert(newItem);
256
+            }
257
+        }
258
+
259
+        // 流程开始
260
+        TaIssueProcess process = new TaIssueProcess();
261
+        process.setIssueId(taIssue.getIssueId());
262
+        process.setOrgId(sysUser.getOrgId());
263
+        process.setProcessNode(taIssue.getProcessNode());
264
+        process.setProcessStatus(taIssue.getProcessStatus());
265
+        process.setStatus(Constants.STATUS_NORMAL);
266
+        process.setCreateUser(sysUser.getUserId());
267
+        process.setUserName(sysUser.getName());
268
+        process.setCreateDate(LocalDateTime.now());
269
+        taIssueProcessMapper.insert(process);
270
+    }
271
+
190 272
     private TaCheckItemQu getQu(List<TaCheckItemQu> quList, String quId) {
191 273
         return quList.stream().filter(q -> q.getQuId().equals(quId)).findFirst().orElse(null);
192 274
     }

+ 6
- 4
src/main/java/com/example/civilizedcity/service/impl/TaIssueApplyServiceImpl.java Dosyayı Görüntüle

@@ -1,9 +1,7 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 4
 import com.example.civilizedcity.common.Constants;
6
-import com.example.civilizedcity.common.ResponseBean;
7 5
 import com.example.civilizedcity.entity.*;
8 6
 import com.example.civilizedcity.event.MessagEvent;
9 7
 import com.example.civilizedcity.mapper.*;
@@ -79,8 +77,12 @@ public class TaIssueApplyServiceImpl extends BaseServiceImpl<TaIssueApplyMapper,
79 77
     }
80 78
 
81 79
     @Override
82
-    public IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType) {
83
-        return baseMapper.getPageBy(pg, issueId, applyType, orgId, sourceType);
80
+    public IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType, Boolean isAll) {
81
+
82
+        // 如果 isAll 是 false
83
+        // 那么只查询还未审核的
84
+
85
+        return baseMapper.getPageBy(pg, issueId, applyType, orgId, sourceType, isAll);
84 86
     }
85 87
 
86 88
     @Transactional(rollbackFor = Exception.class)

+ 3
- 0
src/main/resources/mapper/TaIssueApplyMapper.xml Dosyayı Görüntüle

@@ -28,6 +28,9 @@
28 28
         <if test="sourceType != null and sourceType != 'feedback'">
29 29
             AND s.source_type != 'feedback'
30 30
         </if>
31
+        <if test="isAll == null or !isAll">
32
+            AND t.verify_date is null
33
+        </if>
31 34
         ORDER BY
32 35
             IFNULL(t.verify_status, -1) ASC,
33 36
             t.create_date DESC