linzhijie
2021-03-11 93af1c6ffb9ae0e894689ad3a37b548e57d54cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
package com.ots.project.exam.restcontroller;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ots.common.enums.LangTypeEnum;
import com.ots.common.enums.TestMemberStatusEnum;
import com.ots.common.enums.UserTypeEnum;
import com.ots.common.utils.StringUtils;
import com.ots.common.utils.Threads;
import com.ots.common.utils.bean.BeanUtils;
import com.ots.project.common.BaseApiController;
import com.ots.project.exam.domain.*;
import com.ots.project.exam.dto.*;
import com.ots.project.exam.service.*;
import com.ots.project.exam.service.impl.TExamPaperServiceImpl;
import com.ots.project.exam.viewmodel.ExamPaperSubmitItemVM;
import com.ots.project.exam.viewmodel.ExamPaperSubmitVM;
import com.ots.project.exam.viewmodel.ExamPaperTitleItemVM;
import com.ots.project.exam.viewmodel.QuestionEditRequestVM;
import com.ots.project.tool.exam.DateTimeUtil;
import com.ots.project.tool.exam.ExamUtil;
import com.ots.project.tool.exam.JsonUtil;
import com.ots.project.tool.report.MAQ.MAQReport;
import com.ots.project.tool.report.ReportResultData;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.util.*;
import java.util.stream.Collectors;
 
import static com.ots.common.enums.ReportTypeEnum.Brief;
import static com.ots.common.enums.SenderCode.noSend;
import static com.ots.common.enums.SenderCode.send;
 
@RestController("StudentExamPaperAnswerController")
@RequestMapping(value = "/api/exam/exampaper/answer")
@AllArgsConstructor
public class ExamPaperAnswerController extends BaseApiController {
 
    @Autowired
    private ExamPaperAnswerService examPaperAnswerService;
    @Autowired
    private MemberService memberService;
    @Autowired
    private ITQuestionService questionService;
    @Autowired
    private ITExamReportService examReportService;
    @Autowired
    private IEntTestMemberService entTestMemberService;
    @Autowired
    private ExamPaperController examPaperController;
    @Autowired
    private TExamPaperServiceImpl examPaperService;
    private static final Logger logger = LoggerFactory.getLogger(Threads.class);
 
    // 答题提交
    @RequestMapping(value = "/answerSubmit/{tokenId}", method = RequestMethod.POST)
    public RestResponse answerSubmit(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId) {
        logger.info("tokenId:" + tokenId);
        logger.info("itemOrder:" + examPaperSubmitVM.getItemOrder());
 
        try {
            // 1、查询出用户的信息
            ExamUser user = new ExamUser();
            // testId等
            RelatedParty relatedParty = memberService.queryProdidByToken(tokenId);
            //入人口学的键值
            // Map<String, String> examInfoMap = getDemographicReport(tokenId, user);
            // dataReportList 对应基础数据导出content那个字段
            List<DataReport> dataReportList = getDemographicDataReport(examPaperSubmitVM, tokenId, user);
 
            // 3、把question取出来
            Map<Long, QuestionObject> questionObjectMap = getLongQuestionObjectMap(examPaperSubmitVM);
 
            // 4、测试包名称、产品名称、测试开始时间、测试完成时间的
            // setReportInfo(examPaperSubmitVM, relatedParty, examInfoMap);
            setReportInfo(examPaperSubmitVM, relatedParty, dataReportList);
 
            examPaperSubmitVM.setInterfaceContentList(new ArrayList<>());
            TExamReport tExamReportQuery = new TExamReport();
            tExamReportQuery.setTokenId(tokenId);
            setExamPaperSubTERList(examPaperSubmitVM, tExamReportQuery);
 
            // 5、保存调用泰国团队的数据,第一段结束调用泰国团队
            // setRemoteCallReport(examPaperSubmitVM, tokenId, relatedParty, dataReportList);
 
            //6、形成题目、回答选项,需要权限等等
            // setQuestionAndAnswer(examPaperSubmitVM, tokenId, relatedParty, dataReportList, questionObjectMap);
 
            // 7、上一次选什么
            Map<String, String> lastContentMap = getLastChioce(examPaperSubmitVM);
 
            // 8、这次选什么
            Map<String, String> choiceMap = getThisChioce(examPaperSubmitVM);
 
            // 9、设置报表的内容
            setQuestionReport(examPaperSubmitVM);
 
            // 10、题目入库
            ExamPaperAnswerInfo examPaperAnswerInfo = answerSubmitResult(examPaperSubmitVM, tokenId, relatedParty, user, dataReportList, lastContentMap, choiceMap);
 
            return RestResponse.ok(examPaperAnswerInfo.getSubmitReport());
        } catch (Exception e) {
            logger.error("{}", e.getMessage(), e);
            TExamReport tExamReportUpdate = new TExamReport();
            tExamReportUpdate.setTokenId(tokenId);
            tExamReportUpdate.setFinish(0);
            List<TExamReport> tExamReportList = examReportService.selectTExamReportList(tExamReportUpdate);
            tExamReportUpdate.setRemark(tExamReportList.get(0).getRemark() + "," + e.getMessage());
            examReportService.updateTExamReportDeleteLastOneByTokenId(tExamReportUpdate);
            throw e;
        }
    }
 
    private void setExamPaperSubTERList(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportQuery) {
        List<TExamReport> tExamReportList = examReportService.selectTExamReportList(tExamReportQuery);
        if (ExamUtil.isListEmpty(tExamReportList)) {
            tExamReportList = new ArrayList<>();
        }
 
        examPaperSubmitVM.setTExamReportList(tExamReportList);
    }
 
    private void setRemoteCallReport(ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId, RelatedParty relatedParty, List<DataReport> dataReportList) {
        List<InterfaceContent> interfaceContentList = examPaperSubmitVM.getInterfaceContentList();
        if (!StringUtils.equals(examPaperSubmitVM.getIsCallTain(), "callTain")) {
            // 要取原来的数据
            setInterfaceContent(examPaperSubmitVM, interfaceContentList);
            return;
        }
 
        // 模拟调用
        Map<String, String> thaiCalculationMap = new HashMap<>();
        MAQReport maqReport = new MAQReport();
        maqReport.setQuestionnaireTaker(relatedParty.getMemberName());
        maqReport.setQuestionnaireID(tokenId);
        maqReport.setReportGenerationDate(DateTimeUtil.dateShortFormat(new Date()));
        thaiCalculationMap.put("P_SDE_T1", "95");
        thaiCalculationMap.put("P_IM_T1", "95");
        thaiCalculationMap.put("P_INCON_T", "95");
        thaiCalculationMap.put("P_INCON_T1", "95");
        thaiCalculationMap.put("P_SDE23", "95");
        thaiCalculationMap.put("P_IM24", "95");
        thaiCalculationMap.put("P_INCON25", "96");
        thaiCalculationMap.put("P_Flex01", "80");
        thaiCalculationMap.put("P_Creat02", "80");
        ReportResultData resultData = maqReport.getTemplateParameters(thaiCalculationMap, Brief, LangTypeEnum.English);
        Map<String, String> thaiDataMap = resultData.getTextMap();
 
        InterfaceContent interfaceContent = new InterfaceContent();
        interfaceContent.setPartOrder(examPaperSubmitVM.getPartOrder());
        interfaceContent.setDataReportList(new ArrayList<>());
        List<DataReport> iterFDataReportList = interfaceContent.getDataReportList();
        thaiDataMap.forEach((key, value) -> {
            iterFDataReportList.add(new DataReport(key, value, UserTypeEnum.SYS_USER.getUserType(), examPaperSubmitVM.getLangType()));
        });
 
        // 把旧的report表数据拿出来
        setInterfaceContent(examPaperSubmitVM, interfaceContentList);
 
        interfaceContentList.add(interfaceContent);
    }
 
    private void setInterfaceContent(ExamPaperSubmitVM examPaperSubmitVM, List<InterfaceContent> interfaceContentList) {
        if (ExamUtil.isListNotEmpty(examPaperSubmitVM.getTExamReportList())) {
            List<InterfaceContent> interfaceContentOldList = null;
            String interfaceContentStr = examPaperSubmitVM.getTExamReportList().get(0).getInterfaceContent();
            if (StringUtils.isNotEmpty(interfaceContentStr)) {
                interfaceContentOldList = JsonUtil.toJsonListObject(interfaceContentStr, InterfaceContent.class);
                interfaceContentList.addAll(interfaceContentOldList);
            }
        }
    }
 
    // 测试包名称、产品名称、测试开始时间、测试完成时间的
    private void setReportInfo(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, RelatedParty relatedParty, List<DataReport> dataReportList) {
        dataReportList.add(new DataReport("Test Package", relatedParty.getTestName(), "", examPaperSubmitVM.getLangType()));
        dataReportList.add(new DataReport("Test", relatedParty.getProdName(), "", examPaperSubmitVM.getLangType()));
        List<ExamPaperSubmitItemVM> answerItemList = examPaperSubmitVM.getAnswerItems();
        String beginTime = answerItemList.get(0).getStartTime();
        String endTime = answerItemList.get(answerItemList.size() - 1).getEndTime();
        dataReportList.add(new DataReport("Begin Time", beginTime, "", examPaperSubmitVM.getLangType()));
        dataReportList.add(new DataReport("End Time", endTime, "", examPaperSubmitVM.getLangType()));
    }
 
    // 这次选什么
    private Map<String, String> getThisChioce(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
        Map<String, String> choiceMap = new LinkedHashMap<String, String>();
        examPaperSubmitVM.getAnswerItems().stream().forEach(it -> {
            choiceMap.put(it.getItemOrder().toString(), it.getContent());
        });
        return choiceMap;
    }
 
    // 上一次选什么
    private Map<String, String> getLastChioce(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
        Map<String, String> lastContentMap = new LinkedHashMap<String, String>();
        examPaperSubmitVM.getAnswerItems().stream().forEach(it -> {
            lastContentMap.put(it.getItemOrder().toString(), it.getLastContent());
        });
        return lastContentMap;
    }
 
    // 4、形成题目、回答选项
    private void setQuestionAndAnswer(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, String tokenId, RelatedParty relatedParty, List<DataReport> dataReportList, Map<Long, QuestionObject> questionObjectMap) {
 
        List<QuestionAnswer> questionAnswers = examPaperSubmitVM.getAnswerItems().stream().map(item -> {
 
            //题干,回答项
            QuestionAnswer questionAnswer = new QuestionAnswer();
            QuestionObject questionObject = questionObjectMap.get(item.getQuestionId().longValue());
 
            try {
                //1.取题干
                questionAnswer.setQuestionItem(item.getItemOrder() + "." + ExamUtil.html2Text(questionObject.getTitleContent()));
                //2、取回答的选项
                questionObject.getQuestionItemObjects().stream().forEach(q -> {
                    if (item.getContent().equals(q.getPrefix())) {
                        questionAnswer.setAnswerItem(q.getContent());
                    }
                });
                // 3、题目永久编号
                questionAnswer.setPermanentId(item.getQuestionReport().getPermanentId());
 
                // 4、本题目在那一段
                questionAnswer.setPartOrder(item.getQuestionReport().getPartOrder());
            } catch (Exception e) {
            }
            return questionAnswer;
        }).collect(Collectors.toList());
 
        for (int i = 0; i < questionAnswers.size(); i++) {
            if (StringUtils.isEmpty(questionAnswers.get(i).getAnswerItem())) {
                break;
            }
            // 插入泰国团队进来的数据,造数据,如果跳到了下一段,那就插入泰国团队的数据
            if (i == 0 || questionAnswers.get(i - 1).getPartOrder() != questionAnswers.get(i).getPartOrder()) {
                if (ExamUtil.isListNotEmpty(examPaperSubmitVM.getInterfaceContentList())) {
                    InterfaceContent interfaceContent = examPaperSubmitVM.getInterfaceContentList().get(0);
                    dataReportList.addAll(interfaceContent.getDataReportList());
                }
            }
            dataReportList.add(new DataReport(questionAnswers.get(i).getPermanentId(), questionAnswers.get(i).getAnswerItem(), UserTypeEnum.SYS_USER.getUserType(), examPaperSubmitVM.getLangType()));
        }
    }
 
    // 把question取出来
    private Map<Long, QuestionObject> getLongQuestionObjectMap(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
        List<Long> questionIdList = examPaperSubmitVM.getAnswerItems().stream().map(i -> {
            return i.getQuestionId().longValue();
        }).collect(Collectors.toList());
        //把quesitonId取出来
        List<TQuestion> tQuestionList = questionService.selectTQuestionByIds(questionIdList);
        //题目id,把题干,选项之类的内容取出来
        Map<Long, QuestionObject> questionObjectMap = new HashMap<Long, QuestionObject>();
        tQuestionList.stream().forEach(it -> {
            questionObjectMap.put(it.getId(), JSONObject.parseObject(it.getContent(), QuestionObject.class));
        });
        return questionObjectMap;
    }
 
    //入人口学的键值
    private Map<String, String> getDemographicReport(@PathVariable String tokenId, ExamUser user) {
        Map<String, String> examInfoMap = new LinkedHashMap<String, String>();
        try {
            List<EntDemographyInfo> entDemographyInfoList = memberService.queryDemographyParamInfo(tokenId);
            //2、获取用户的值
            EntDemographyInfo entDemographyInfo = entDemographyInfoList.get(0);
            user.setId(entDemographyInfo.getMemberId().intValue());
            entDemographyInfoList.stream().forEach(item -> examInfoMap.put(item.getParamName(), item.getParamValue()));
        } catch (Exception e) {
            RelatedParty relatedParty = memberService.queryProdidByToken(tokenId);
            user.setId(relatedParty.getMemberId().intValue());
        }
        return examInfoMap;
    }
 
    //入人口学的键值
    private List<DataReport> getDemographicDataReport(ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId, ExamUser user) {
        List<DataReport> dataReportList = new ArrayList<>();
        try {
            List<EntDemographyInfo> entDemographyInfoList = memberService.queryDemographyParamInfo(tokenId);
            //2、获取用户的值
            EntDemographyInfo entDemographyInfo = entDemographyInfoList.get(0);
            user.setId(entDemographyInfo.getMemberId().intValue());
            entDemographyInfoList.stream().forEach(item -> {
                dataReportList.add(new DataReport(item.getParamName(), item.getParamValue(), "", examPaperSubmitVM.getLangType()));
            });
        } catch (Exception e) {
            RelatedParty relatedParty = memberService.queryProdidByToken(tokenId);
            user.setId(relatedParty.getMemberId().intValue());
        }
        return dataReportList;
    }
 
    private void setQuestionReport(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
        List<ExamPaperTitleItemVM> titleItems = examPaperSubmitVM.getTitleItems();
        List<ExamPaperSubmitItemVM> anserItems = examPaperSubmitVM.getAnswerItems();
        // 人格测试题,只有一段的
        if (Objects.isNull(titleItems)) {
            if (Objects.isNull(anserItems)) {
                return;
            }
            for (ExamPaperSubmitItemVM examPaperSubmitItemVM : anserItems) {
                QuestionReport questionReport = examPaperSubmitItemVM.getQuestionReport();
                questionReport.setId(questionReport.getQuestionOrder() + 1);
                questionReport.setTimeSpent(ExamUtil.timeSpent(DateTimeUtil.parseToOften(questionReport.getStartTime()), DateTimeUtil.parseToOften(questionReport.getEndTime())));
            }
            // else 工作问卷测试题
        } else {
            for (ExamPaperTitleItemVM examPaperTitleItemVM : titleItems) {
                // 记录JAQ小题
                QuestionReport questionReport = examPaperTitleItemVM.getQuestionReport();
                questionReport.setId(questionReport.getQuestionOrder() + 1);
                questionReport.setTimeSpent(ExamUtil.timeSpent(DateTimeUtil.parseToOften(questionReport.getStartTime()), DateTimeUtil.parseToOften(questionReport.getEndTime())));
            }
        }
    }
 
    private ExamPaperAnswerInfo answerSubmitResult(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId, RelatedParty relatedParty, ExamUser user, List<DataReport> dataReportList, Map<String, String> lastContentMap, Map<String, String> choiceMap) {
        TExamReport tExamReport = new TExamReport();
        TExamReport tExamReportQuery = new TExamReport();
        tExamReport.setContent(JSON.toJSON(dataReportList).toString());
        tExamReport.setProductId(examPaperSubmitVM.getId().longValue());
        tExamReport.setQuestionReport(getQuestionReportsJson(examPaperSubmitVM));// 报告字段
        ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVM, user);
        TExamPaper examPaper = examPaperAnswerInfo.getExamPaper();
        tExamReport.setProductName(examPaper.getName());
        tExamReport.setTokenId(tokenId);
        tExamReport.setStates("1");
        tExamReport.setLastContent(JSON.toJSON(lastContentMap).toString());
        tExamReport.setChoice(JSON.toJSON(choiceMap).toString());
        tExamReport.setDoTime(examPaperSubmitVM.getDoTime());
        tExamReport.setLangType(examPaperSubmitVM.getLangType());
        // 是否自动发送状态报告
        setAutoSendReportStatus(relatedParty, tExamReport);
        BeanUtils.copyBeanProp(tExamReportQuery, tExamReport);
 
        tExamReportQuery.setProductId(null);
        tExamReportQuery.setProductName(null);
        List<TExamReport> tExamReportList = examPaperSubmitVM.getTExamReportList();
        // ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
        // questionCount 做题数目
        tExamReport.setQuestionCount(0);
        //member_id
        tExamReport.setMemberId(relatedParty.getMemberId().intValue());
        // user_id
        tExamReport.setUserId(relatedParty.getUser_id());
        // parent_id
        tExamReport.setParentId(relatedParty.getUser_parent_id());
        // test_id
        tExamReport.setTestId(relatedParty.getTestId());
        // finish
        tExamReport.setFinish(examPaperSubmitVM.getFinish());
        setVerifyStatus(examPaperSubmitVM, tExamReport);
 
        // questionTemplateId
        tExamReport.setQuestionTemplateId(relatedParty.getQuestionTemplateId());
 
        // 随机题目编号
        tExamReport.setQuestionOrder(JSON.toJSONString(examPaperSubmitVM.getQuestionOrder()));
 
        // 随机的选项编号
        tExamReport.setOptionOrder(JSON.toJSONString(examPaperSubmitVM.getOptionOrder()));
 
        // 设置成员名称
        tExamReport.setMemberName(relatedParty.getMemberName());
 
        // 模版名称
        tExamReport.setReportTemplateId(relatedParty.getReportTemplateId());
 
        // tExamReport
 
        // 用户答题的时间
        setRemainPartTime(examPaperSubmitVM, tExamReport, tExamReportList);
 
        // 更新报告
        updateTExamReport(examPaperSubmitVM, tokenId, relatedParty, tExamReport, tExamReportList);
 
        // 调用泰国团队
        callThaiInteface(examPaperSubmitVM, tokenId, tExamReport, examPaperAnswerInfo);
        return examPaperAnswerInfo;
    }
 
    private void updateTExamReport(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId, RelatedParty relatedParty, TExamReport tExamReport, List<TExamReport> tExamReportList) {
        // 开始时间没有更新就更新一下
        if (Objects.isNull(relatedParty.getStartTime())) {
            entTestMemberService.updateTestMemberStatus(TestMemberStatusEnum.answering, memberService.queryProdidByToken(tokenId).getMemberId());
        }
 
        if (tExamReportList.size() > 0) {
            // 更新本段的答题时间,先把原来的段读出来
            examReportService.updateTExamReportByTokenId(tExamReport);
        } else {
            examReportService.insertTExamReport(tExamReport);
        }
 
        //更新测试包的状态
        if (!Objects.isNull(examPaperSubmitVM.getFinish())) {
 
            // 校验每一题是否都答了,没有意义,因为有的人会提交空的答题记录上来
            checkCaqQuestionItem(tExamReport);
 
            // MAQ 有答完不改状态的情况
            TestMemberStatusEnum testMemberStatusEnum = TestMemberStatusEnum.codeOf(examPaperSubmitVM.getFinish().toString());
            if (Objects.equals(Integer.parseInt(TestMemberStatusEnum.completed.getCode()), tExamReport.getVerifyStatus())) {
                testMemberStatusEnum = TestMemberStatusEnum.completed;
            }
 
            entTestMemberService.updateTestMemberStatus(testMemberStatusEnum, tExamReport.getMemberId());
        }
    }
 
    private void checkCaqQuestionItem(TExamReport tExamReport) {
        if (!Objects.equals(tExamReport.getQuestionTemplateId(), "job")) {
            return;
        }
 
        List<QuestionReport> questionReportList = JsonUtil.parseArray(tExamReport.getQuestionReport(), QuestionReport.class);
        for (QuestionReport questionReport : questionReportList) {
//            questionReport = null; // 测试用
            List<QuestionEditRequestVM> questionItems = questionReport.getQuestionItems();
        }
 
    }
 
    private void setVerifyStatus(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReport) {
        if (Objects.equals(examPaperSubmitVM.getFinish(), 6)) {
            tExamReport.setVerifyStatus(Integer.parseInt(TestMemberStatusEnum.timeOut.getCode()));
        } else {
            // 更新用户的答题状态
            tExamReport.setVerifyStatus(examPaperSubmitVM.getVerifyStatus());
        }
    }
 
    private void setRemainPartTime(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReport, List<TExamReport> tExamReportList) {
        if (Objects.isNull(examPaperSubmitVM.getRemainTime())) {
            return;
        }
 
        Map<Integer, Integer> remainPartTimeMap = null;
 
        if (tExamReportList.size() > 0) {
            remainPartTimeMap = JsonUtil.parseObject(tExamReportList.get(0).getRemainPartTime(), HashMap.class);
        } else {
            remainPartTimeMap = new HashMap<>();
        }
 
        remainPartTimeMap.put(examPaperSubmitVM.getPartOrder(), examPaperSubmitVM.getRemainTime());
        tExamReport.setRemainPartTime(JsonUtil.toJSONString(remainPartTimeMap));
    }
 
    private void callThaiInteface(ExamPaperSubmitVM examPaperSubmitVM, @PathVariable String tokenId, TExamReport tExamReport, ExamPaperAnswerInfo examPaperAnswerInfo) {
        if (Objects.equals(examPaperSubmitVM.getIsCallTain(), "CallThai")) {
            SignalObject signalObject = examPaperService.callTaiData(tokenId, tExamReport.getLangType(), examPaperSubmitVM);
            SubmitReport submitReport = examPaperAnswerInfo.getSubmitReport();
            submitReport.setSignalObject(signalObject);
        }
    }
 
    // 自动发送状态报告需要处理的内容
    private void setAutoSendReportStatus(RelatedParty relatedParty, TExamReport tExamReport) {
        // 0:待发送;1:已发送;2:不发送
        if (relatedParty.isAutoSendReport()) {
            tExamReport.setSendHrStatus(send.getCode());
            tExamReport.setSendTesterStatus(send.getCode());
            tExamReport.setReportTemplateId(relatedParty.getReportTemplateId());
        } else {
            tExamReport.setSendHrStatus(noSend.getCode());
            tExamReport.setSendTesterStatus(noSend.getCode());
        }
    }
 
    // 获得QuestionReport列表的Json字符串入t_exam_roport表
    private String getQuestionReportsJson(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
        List<ExamPaperTitleItemVM> titleItems = examPaperSubmitVM.getTitleItems();
        List<ExamPaperSubmitItemVM> answerItems = examPaperSubmitVM.getAnswerItems();
        List<QuestionReport> questionReportList = null;
        if (Objects.isNull(titleItems)) {
            if (Objects.isNull(answerItems)) {
                return "";
            }
            questionReportList = answerItems.stream().map(answer -> {
                return answer.getQuestionReport();
            }).collect(Collectors.toList());
        } else {
            questionReportList = titleItems.stream().map(title -> {
                return title.getQuestionReport();
            }).collect(Collectors.toList());
        }
        return JsonUtil.toJsonStr(questionReportList);
    }
 
    // 点击开始答题的时候,改成答题中,仅执行一次
    @RequestMapping(value = "/updateTestMemberStatus/{tokenId}", method = RequestMethod.POST)
    public RestResponse updateTestMemberStatus(@PathVariable String tokenId) {
        entTestMemberService.updateTestMemberStatus(TestMemberStatusEnum.answering, memberService.queryProdidByToken(tokenId).getMemberId());
        return RestResponse.ok();
    }
}