|
@@ -43,6 +43,9 @@ public class TaCheckItemController extends BaseController {
|
43
|
43
|
@Autowired
|
44
|
44
|
private TaCheckItemQuService taCheckItemQuService;
|
45
|
45
|
|
|
46
|
+ @Autowired
|
|
47
|
+ private TaCheckAnswerItemService taCheckAnswerItemService;
|
|
48
|
+
|
46
|
49
|
/**
|
47
|
50
|
* 通过ID查询单条数据
|
48
|
51
|
*
|
|
@@ -70,17 +73,27 @@ public class TaCheckItemController extends BaseController {
|
70
|
73
|
@ApiOperation("通过测评以及点位查询数据")
|
71
|
74
|
@GetMapping("/taCheck/{checkId}/item/{typeId}")
|
72
|
75
|
public ResponseBean queryByCheckId(@ApiParam("测评ID") @PathVariable String checkId,
|
73
|
|
- @ApiParam("点位ID") @PathVariable String typeId) throws Exception {
|
|
76
|
+ @ApiParam("点位ID 或者 调查问卷") @PathVariable String typeId) throws Exception {
|
|
77
|
+ TaCheckItem taCheckItem = getByCheckAndType(checkId, typeId);
|
|
78
|
+ if (null == taCheckItem || Constants.STATUS_DELETE == taCheckItem.getStatus()) {
|
|
79
|
+ return ResponseBean.error("未找到测评项目");
|
|
80
|
+ }
|
74
|
81
|
|
75
|
|
- return ResponseBean.success(getByCheckAndType(checkId, typeId));
|
|
82
|
+ return ResponseBean.success(taCheckItem);
|
76
|
83
|
}
|
77
|
84
|
|
78
|
85
|
private TaCheckItem getByCheckAndType(String checkId, String typeId) {
|
79
|
86
|
QueryWrapper<TaCheckItem> queryWrapper = new QueryWrapper<>();
|
80
|
87
|
queryWrapper.eq("check_id", checkId);
|
81
|
|
- queryWrapper.eq("item_type", Constants.CHECK_OF_LOC); // 只查点位
|
82
|
|
- queryWrapper.eq("type_id", typeId);
|
|
88
|
+
|
|
89
|
+ if (Constants.CHECK_OF_SURVEY.equals(typeId)) {
|
|
90
|
+ queryWrapper.eq("item_type", Constants.CHECK_OF_SURVEY);
|
|
91
|
+ } else {
|
|
92
|
+ queryWrapper.eq("item_type", Constants.CHECK_OF_LOC); // 只查点位
|
|
93
|
+ queryWrapper.eq("type_id", typeId);
|
|
94
|
+ }
|
83
|
95
|
queryWrapper.gt("status", Constants.STATUS_DELETE);
|
|
96
|
+ queryWrapper.last("limit 1");
|
84
|
97
|
|
85
|
98
|
return taCheckItemService.getOne(queryWrapper);
|
86
|
99
|
}
|
|
@@ -97,12 +110,11 @@ public class TaCheckItemController extends BaseController {
|
97
|
110
|
public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
98
|
111
|
@ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
99
|
112
|
@ApiParam("模拟测评ID") @RequestParam(value = "checkId") String checkId,
|
100
|
|
- @ApiParam("项目类型") @RequestParam(value = "itemType") String itemType,
|
101
|
|
- @ApiParam("是否校验") @RequestParam(value = "mustValid", defaultValue = "false") Boolean mustValid) throws Exception {
|
|
113
|
+ @ApiParam("项目类型") @RequestParam(value = "itemType") String itemType) throws Exception {
|
102
|
114
|
|
103
|
115
|
SysUser sysUser = currentUser();
|
104
|
116
|
IPage<TaCheckItem> pg = new Page<>(pageNum, pageSize);
|
105
|
|
- IPage<TaCheckItem> result = taCheckItemService.getPageBy(pg, checkId, itemType, mustValid, sysUser);
|
|
117
|
+ IPage<TaCheckItem> result = taCheckItemService.getPageBy(pg, checkId, itemType);
|
106
|
118
|
|
107
|
119
|
return ResponseBean.success(result);
|
108
|
120
|
}
|
|
@@ -175,15 +187,6 @@ public class TaCheckItemController extends BaseController {
|
175
|
187
|
}});
|
176
|
188
|
}
|
177
|
189
|
|
178
|
|
- SysUser sysUser = currentUser();
|
179
|
|
- int count = taCheckAnswerService.getCountByUser(taCheckItem.getItemId(), sysUser.getUserId());
|
180
|
|
- if (count > 0) {
|
181
|
|
- return ResponseBean.success(new HashMap<String, Object>(){{
|
182
|
|
- put("errorCode", 2);
|
183
|
|
- put("message", "本次测题您已作答完毕");
|
184
|
|
- }});
|
185
|
|
- }
|
186
|
|
-
|
187
|
190
|
int cnt = taCheckAnswerService.countByItem(taCheckItem.getItemId());
|
188
|
191
|
if (cnt >= taCheckItem.getNum()) {
|
189
|
192
|
return ResponseBean.success(new HashMap<String, Object>(){{
|
|
@@ -198,6 +201,21 @@ public class TaCheckItemController extends BaseController {
|
198
|
201
|
}});
|
199
|
202
|
}
|
200
|
203
|
|
|
204
|
+ /**
|
|
205
|
+ * 获取回答
|
|
206
|
+ *
|
|
207
|
+ * @param id 实例对象
|
|
208
|
+ * @return 实例对象
|
|
209
|
+ */
|
|
210
|
+ @ApiOperation("更新数据")
|
|
211
|
+ @GetMapping("/taCheckItem/{id}/answer")
|
|
212
|
+ public ResponseBean getAnswer(@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
|
213
|
+
|
|
214
|
+ SysUser sysUser = currentUser();
|
|
215
|
+ List<TaCheckAnswer> answerList = taCheckAnswerService.getByUser(id, sysUser.getUserId());
|
|
216
|
+ return ResponseBean.success(answerList);
|
|
217
|
+ }
|
|
218
|
+
|
201
|
219
|
/**
|
202
|
220
|
* 回答问题
|
203
|
221
|
*
|
|
@@ -209,6 +227,7 @@ public class TaCheckItemController extends BaseController {
|
209
|
227
|
public ResponseBean answer(@ApiParam("对象实体") @RequestBody TaCheckAnswer taCheckAnswer,
|
210
|
228
|
@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
211
|
229
|
|
|
230
|
+ SysUser sysUser = currentUser();
|
212
|
231
|
TaCheckItem taCheckItem = taCheckItemService.getById(id);
|
213
|
232
|
if (null == taCheckItem || taCheckItem.getStatus() == Constants.STATUS_DELETE) {
|
214
|
233
|
return ResponseBean.error("未找到有效的答题信息");
|
|
@@ -227,7 +246,11 @@ public class TaCheckItemController extends BaseController {
|
227
|
246
|
return ResponseBean.error("测评地点详情或小区名称未填写");
|
228
|
247
|
}
|
229
|
248
|
|
230
|
|
- SysUser sysUser = currentUser();
|
|
249
|
+ int count = taCheckAnswerService.getCountByUser(id, sysUser.getUserId());
|
|
250
|
+ if (count > 0) {
|
|
251
|
+ return ResponseBean.error("您已完成测评作答");
|
|
252
|
+ }
|
|
253
|
+
|
231
|
254
|
taCheckAnswer.setAnswerId(StringUtils.uuid());
|
232
|
255
|
taCheckAnswer.setCheckId(taCheck.getCheckId());
|
233
|
256
|
taCheckAnswer.setItemId(id);
|
|
@@ -237,7 +260,7 @@ public class TaCheckItemController extends BaseController {
|
237
|
260
|
taCheckAnswer.setCreateDate(LocalDateTime.now());
|
238
|
261
|
|
239
|
262
|
taCheckItemService.answer(taCheckItem, taCheckAnswer);
|
240
|
|
- return null;
|
|
263
|
+ return ResponseBean.success(taCheckAnswer);
|
241
|
264
|
}
|
242
|
265
|
|
243
|
266
|
/**
|