|
@@ -15,7 +15,6 @@ import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
|
15
|
15
|
import com.xhkjedu.utils.N_Utils;
|
16
|
16
|
import com.xhkjedu.vo.ResultVo;
|
17
|
17
|
import org.springframework.beans.BeanUtils;
|
18
|
|
-import org.springframework.scheduling.annotation.Async;
|
19
|
18
|
import org.springframework.stereotype.Service;
|
20
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
21
|
20
|
import org.springframework.util.CollectionUtils;
|
|
@@ -89,7 +88,16 @@ public class QuestionService {
|
89
|
88
|
|
90
|
89
|
//获取列表
|
91
|
90
|
public List <Map<String, Object>> findAll(TQuestion question) {
|
92
|
|
- return questionMapper.findAll(question);
|
|
91
|
+ List<Map<String, Object>> list = questionMapper.findAll(question);
|
|
92
|
+ Integer schoolid = question.getSchoolid();
|
|
93
|
+ if(N_Utils.isEmptyInteger(schoolid)) return list;
|
|
94
|
+ String shareqids = list.stream().filter(m -> schoolid.equals(m.get("schoolid")) && !m.get("belong").equals(10))
|
|
95
|
+ .map(m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
|
|
96
|
+ List<Map<String, String>> shareList = questionMapper.listShareNumByIds(shareqids);
|
|
97
|
+ for (Map<String, Object> map : list) {
|
|
98
|
+ setShareNum(shareList, map);
|
|
99
|
+ }
|
|
100
|
+ return list;
|
93
|
101
|
}
|
94
|
102
|
|
95
|
103
|
/**
|
|
@@ -272,15 +280,49 @@ public class QuestionService {
|
272
|
280
|
List<Map<String, Object>> list = questionMapper.listForSelect(question);
|
273
|
281
|
String questionids = list.stream().filter(m -> m.get("qlevel").toString().equals("2")).map(
|
274
|
282
|
m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
|
|
283
|
+ boolean rtn = false;
|
|
284
|
+ List<Map<String, String>> sonList;
|
275
|
285
|
if (N_Utils.isNotEmpty(questionids)) {
|
276
|
|
- List<Map<String, String>> sonList = questionMapper.listSonQuestionForSelect(questionids);
|
277
|
|
- for (Map<String, Object> map : list) {
|
|
286
|
+ sonList = questionMapper.listSonQuestionForSelect(questionids);
|
|
287
|
+ rtn = true;
|
|
288
|
+ } else {
|
|
289
|
+ sonList = null;
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ Integer createid = question.getCreateid();
|
|
293
|
+ String shareqids = list.stream().filter(m -> createid.equals(m.get("createid")) && !m.get("belong").equals(10))
|
|
294
|
+ .map(m -> m.get("questionid").toString()).collect(Collectors.joining("','"));
|
|
295
|
+ List<Map<String, String>> shareList = questionMapper.listShareNumByIds(shareqids);
|
|
296
|
+ for (Map<String, Object> map : list) {
|
|
297
|
+ setShareNum(shareList, map);
|
|
298
|
+ if (rtn) {
|
278
|
299
|
setSonQList(sonList, map);
|
279
|
300
|
}
|
280
|
301
|
}
|
281
|
302
|
return list;
|
282
|
303
|
}
|
283
|
304
|
|
|
305
|
+ /**
|
|
306
|
+ * @Description 试题是否分享过
|
|
307
|
+ * @Date 2023/9/1 14:28
|
|
308
|
+ * @Author YWX
|
|
309
|
+ * @Param [shareList, map]
|
|
310
|
+ * @Return void
|
|
311
|
+ **/
|
|
312
|
+ private void setShareNum(List<Map<String, String>> shareList, Map<String, Object> map) {
|
|
313
|
+ Object shareqid = map.get("questionid");
|
|
314
|
+ Object sharenum = 0;
|
|
315
|
+ if (N_Utils.isListNotEmpty(shareList)) {
|
|
316
|
+ for (Map<String, String> s : shareList) {
|
|
317
|
+ if (s.get("shareqid").equals(shareqid)) {
|
|
318
|
+ sharenum = s.get("sharenum");
|
|
319
|
+ break;
|
|
320
|
+ }
|
|
321
|
+ }
|
|
322
|
+ }
|
|
323
|
+ map.put("sharenum", sharenum);
|
|
324
|
+ }
|
|
325
|
+
|
284
|
326
|
/**
|
285
|
327
|
* @Description 处理试题子题
|
286
|
328
|
* @Date 2023/8/16 8:38
|
|
@@ -288,7 +330,6 @@ public class QuestionService {
|
288
|
330
|
* @Param [sonList, map]
|
289
|
331
|
* @Return void
|
290
|
332
|
**/
|
291
|
|
- @Async("asyncPoolTaskExecutor")
|
292
|
333
|
public void setSonQList(List<Map<String, String>> sonList, Map<String, Object> map) {
|
293
|
334
|
if (map.get("qlevel").toString().equals("2")) {
|
294
|
335
|
Object questionid = map.get("questionid");
|