| | |
| | | package com.ots.project.exam.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import org.springframework.context.i18n.LocaleContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ots.project.tool.report.reportCalculation.request.CalculationTypeEnum.*; |
| | | import static com.ots.project.tool.report.reportCalculation.request.ReportTypeEnum.firstPath; |
| | | import static com.ots.project.tool.report.reportCalculation.request.ReportTypeEnum.secondPath; |
| | | |
| | | /** |
| | | * 产品包列表Service业务层处理 |
| | | * |
| | | * @author ots |
| | | * @date 2019-11-20 |
| | | */ |
| | | @Service("examPaper") |
| | | @Slf4j |
| | | public class TExamPaperServiceImpl implements ITExamPaperService { |
| | | @Autowired |
| | | private TExamPaperMapper tExamPaperMapper; |
| | | |
| | | @Autowired |
| | | private TTextContentMapper tTextContentMapper; |
| | | |
| | | @Autowired |
| | | private TExamLevelMapper tExamLevelMapper; |
| | | |
| | | @Autowired |
| | | private TQuestionMapper questionMapper; |
| | | |
| | | @Autowired |
| | | private ITQuestionService tQuestionService; |
| | | |
| | | @Autowired |
| | | private IDictDataService dictDataService; |
| | | |
| | | @Autowired |
| | | private DictService dictService; |
| | | |
| | | @Autowired |
| | | private ITTextContentService tTextContentService; |
| | | |
| | | @Autowired |
| | | private TExamPaperQuestionMapper tExamPaperQuestionMapper; |
| | | |
| | | @Autowired |
| | | private ITExamPaperService tExamPaperService; |
| | | |
| | | @Autowired |
| | | private ISysUserPaperService userPaperService; |
| | | |
| | | @Autowired |
| | | private IExamUtilService examUtilService; |
| | | |
| | | protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); |
| | | |
| | | @Autowired |
| | | private ITReportTemplateService itReportTemplateService; |
| | | |
| | | @Autowired |
| | | private ITExamReportService examReportService; |
| | | |
| | | @Autowired |
| | | private EntTestMemberMapper entTestMemberMapper; |
| | | |
| | | @Autowired |
| | | EmailMessage emailMessage; |
| | | |
| | | @Autowired |
| | | ReportCalculationServices calculationServices; |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(Threads.class); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询产品包列表 |
| | | * |
| | | * @param id 产品包列表ID |
| | | * @return 产品包列表 |
| | | */ |
| | | @Override |
| | | public TExamPaper selectTExamPaperById(Long id) { |
| | | return tExamPaperMapper.selectTExamPaperById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询产品包列表列表 |
| | | * |
| | | * @param tExamPaper 产品包列表 |
| | | * @return 产品包列表 |
| | | */ |
| | | @Override |
| | | public List<TExamPaper> selectTExamPaperList(TExamPaper tExamPaper) { |
| | | |
| | | List<TExamPaper> tExamPaperList = tExamPaperMapper.selectTExamPaperList(tExamPaper); |
| | | List<TExamPaper> tExamPaperResultList = new ArrayList<>(); |
| | | |
| | | |
| | | // 遍历出各种语言 |
| | | for (TExamPaper tExamPaperTemp : tExamPaperList) { |
| | | Map<String, String> nameMap = JsonUtil.toJsonObject(tExamPaperTemp.getName(), HashMap.class); |
| | | if (Objects.isNull(nameMap)) { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 这样才能翻页 |
| | | tExamPaperList.clear(); |
| | | tExamPaperList.addAll(tExamPaperResultList); |
| | | return tExamPaperList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增产品包列表 |
| | | * |
| | | * @param tExamPaper 产品包列表 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int insertTExamPaper(TExamPaper tExamPaper) { |
| | | |
| | | |
| | | // 添加版本号 |
| | | if (Objects.nonNull(tExamPaper.getVersionId())) { |
| | | String maxVersion = tExamPaperMapper.selectEPaperMaxVBypermanentId(tExamPaper); |
| | | if (StringUtils.isEmpty(maxVersion) && StringUtils.isNotEmpty(tExamPaper.getVersionId())) { |
| | |
| | | } else { |
| | | setVersion(tExamPaper); |
| | | } |
| | | |
| | | |
| | | // 控制语言 |
| | | tExamPaper.setLangType(examUtilService.getLocalLangType(tExamPaper.getLangType())); |
| | | |
| | | tExamPaper.setCreateTime(DateUtils.getNowDate()); |
| | | |
| | | |
| | | //拼装t_text_content,tQuestion参数的属性也是会在此方法内部修改 |
| | | TTextContent textContent = new TTextContent(); |
| | | |
| | | |
| | | // 设置产品包名称和指导语 |
| | | setInserPerperNameAndGuide(tExamPaper); |
| | | |
| | | |
| | | // 设置产品包的content的内容,入t_exam_paper_question表 |
| | | setInsertPaperContent(tExamPaper, textContent); |
| | | |
| | | |
| | | //入库t_text_content |
| | | tTextContentMapper.insertTTextContent(textContent); |
| | | tExamPaper.setFrameTextContentId(textContent.getId()); |
| | | |
| | | |
| | | |
| | | //计算试卷总分 |
| | | // SetExamPaperAttribute(tExamPaper); |
| | | setQuestionContentJson(tExamPaper); |
| | | tExamPaperMapper.insertTExamPaper(tExamPaper); |
| | | |
| | | // 最后入t_exam_paper_question表 |
| | | return setExamPaperQuestion(tExamPaper); |
| | | } |
| | | |
| | | private void setVersion(TExamPaper tExamPaper) { |
| | | tExamPaper.setVersionId(UUID.randomUUID().toString().replaceAll("-", "")); |
| | | tExamPaper.setVersion("V1"); |
| | | } |
| | | |
| | | private void setInsertPaperContent(TExamPaper tExamPaper, TTextContent textContent) { |
| | | |
| | | // 多语言2、content表里面的,Multilingual不为空表示已经做了多语言 |
| | | if (StringUtils.isNotEmpty(tExamPaper.getMultilingual())) { |
| | | String content = tExamPaper.getQuestions(); |
| | | content = setPartsContent(tExamPaper, content); |
| | |
| | | textContent.setContent(JsonUtil.toJSONString(examPaperTitleItemList)); |
| | | } |
| | | } |
| | | |
| | | private String setPartsContent(TExamPaper tExamPaper, String content) { |
| | | List<ExamPaperTitleItem> examPaperTitleItemList = JsonUtil.parseArray(content, ExamPaperTitleItem.class); |
| | | List<QuestionPart> parts = examPaperTitleItemList.get(0).getParts(); |
| | |
| | | content = JsonUtil.toJSONString(examPaperTitleItemList); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | // 多语言 |
| | | private void setPartLangsData(TExamPaper tExamPaper, List<QuestionPart> parts) { |
| | | if (ExamUtil.isListNotEmpty(parts)) { |
| | | for (QuestionPart questionPart : parts) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private int setExamPaperQuestion(TExamPaper tExamPaper) { |
| | | List<ExamPaperTitleItem> examPaperTitleItemList = JsonUtil.toJsonListObject(tExamPaper.getQuestions(), ExamPaperTitleItem.class); |
| | | int size = examPaperTitleItemList.size(); |
| | |
| | | tExamPaperQuestionMapper.insertTExamPaperQuestion(tExamPaperQuestion); |
| | | }); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | private void setInserPerperNameAndGuide(TExamPaper tExamPaper) { |
| | | |
| | | |
| | | // 多语言 |
| | | // 多语言1、 题目转化为多语言,批量导入的不转化 |
| | | Map<String, String> nameMap = new HashMap<>(); |
| | | Map<String, String> guideMap = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(tExamPaper.getMultilingual())) { |
| | | |
| | | // 批量导入 |
| | | setInserPerperBatch(tExamPaper, nameMap, guideMap); |
| | | |
| | | // 名称和指导语 |
| | | setProductNameAndGuide(tExamPaper, nameMap, guideMap); |
| | | } else { |
| | | |
| | | } else { // 非批量导入 |
| | | // 如果是插入的覆盖 |
| | | if (tExamPaper.isCreate() && Objects.nonNull(tExamPaper.getId())) { |
| | | TExamPaper tExamPaperLast = tExamPaperMapper.selectTExamPaperById(tExamPaper.getId()); |
| | | String nameMapJson = ExamUtil.getStringMapJson(tExamPaper.getLangType(), tExamPaper.getName(), tExamPaperLast.getName()); |
| | |
| | | nameMap.put(tExamPaper.getLangType(), tExamPaper.getName()); |
| | | guideMap.put(tExamPaper.getLangType(), tExamPaper.getGuide()); |
| | | } |
| | | |
| | | // 名称和指导语 |
| | | setProductNameAndGuide(tExamPaper, nameMap, guideMap); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 批量导入插入 |
| | | private void setInserPerperBatch(TExamPaper tExamPaper, Map<String, String> nameMap, Map<String, String> guideMap) { |
| | | List<String> multilingualList = JsonUtil.toJsonListObject(tExamPaper.getMultilingual(), String.class); |
| | | for (int i = 0; i < multilingualList.size(); i++) { |
| | | |
| | | // 如果选择了多语言而导入的不是本地国际化的那种语言 |
| | | if (StringUtils.equals(tExamPaper.getLangType(), "ALL") && !multilingualList.contains(dictService.getLangType(LocaleContextHolder.getLocale().toString()))) { |
| | | nameMap.put(multilingualList.get(i), tExamPaper.getName()); |
| | | guideMap.put(multilingualList.get(i), tExamPaper.getGuide()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 设置产品包的名称和指导语 |
| | | private void setProductNameAndGuide(TExamPaper tExamPaper, Map<String, String> nameMap, Map<String, String> guideMap) { |
| | | tExamPaper.setName(JsonUtil.toJsonStr(nameMap)); |
| | | tExamPaper.setGuide(JsonUtil.toJsonStr(guideMap)); |
| | | } |
| | | |
| | | |
| | | // 添加到quesitonContent字段,专门为题目搜索,空间换时间,记录小题,不是大题 |
| | | private void setQuestionContentJson(TExamPaper tExamPaper) { |
| | | String langType = tExamPaper.getLangType(); |
| | | tExamPaper.setLangType(""); |
| | |
| | | tExamPaper.setQuestionContent(JsonUtil.toJsonStr(questionContentList)); |
| | | tExamPaper.setLangType(langType); |
| | | } |
| | | |
| | | private void SetExamPaperAttribute(TExamPaper tExamPaper) { |
| | | |
| | | // begin 计算整个产品包的分数 |
| | | List<ExamPaperTitleItemObject> examPaperTitleItemObjectList = JSONArray.parseArray(tExamPaper.getQuestions(), ExamPaperTitleItemObject.class); |
| | | |
| | | //将数据打横再转list[(1,2,3),(4,5,6)] ->(1,2,3,4,5,6) ->[(1),(2),(3),(4),(5),(6)] |
| | | List<Integer> questionIds = examPaperTitleItemObjectList.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList()); |
| | | Integer[] ids = questionIds.toArray(new Integer[questionIds.size()]); |
| | | List<TQuestion> tQuestionList = questionMapper.selectTQuestionScore(ids); |
| | | |
| | | |
| | | //sql语句是sum(),都是1条 |
| | | //tExamPaper.setScore(tQuestionList.get(0).getScore()); |
| | | tExamPaper.setScore(0l); |
| | | |
| | | |
| | | // end 计算整个产品包的分数 |
| | | |
| | | //题目总数 |
| | | tExamPaper.setQuestionCount(Long.valueOf(questionIds.size())); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改产品包列表 |
| | | * |
| | | * @param tExamPaper 产品包列表 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public int updateTExamPaper(TExamPaper tExamPaper) { |
| | | |
| | | // 多语言的情况 |
| | | if (StringUtils.isEmpty(tExamPaper.getVersion())) { |
| | | setVersion(tExamPaper); |
| | | updateTExamPaperVersion(tExamPaper); |
| | | } |
| | | |
| | | if (tExamPaper.isCreate()) { |
| | | insertTExamPaper(tExamPaper); |
| | | } |
| | | updateLangProduct(tExamPaper); |
| | | return setExamPaperQuestion(tExamPaper); |
| | | } |
| | | |
| | | |
| | | // 更新产品包的版本 |
| | | public int updateTExamPaperVersion(TExamPaper tExamPaper) { |
| | | return tExamPaperMapper.updateTExamPaperVersion(tExamPaper); |
| | | } |
| | | |
| | | private int updateLangProduct(TExamPaper tExamPaper) { |
| | | |
| | | // 产品包名称多语言 |
| | | TExamPaper tExamPaperForUpdate = selectTExamPaperById(tExamPaper.getId()); |
| | | |
| | | |
| | | // 更新产品包的内容 |
| | | setExamPaperInfor(tExamPaper, tExamPaperForUpdate); |
| | | |
| | | |
| | | // 处理content里面的,旧的content拼新的content |
| | | TTextContent textContent = tTextContentMapper.selectTTextContentById(tExamPaperForUpdate.getFrameTextContentId()); |
| | | |
| | | textContent.setContent(tExamPaper.getQuestions()); |
| | | textContent.setUpdateTime(DateUtils.getNowDate()); |
| | | tTextContentMapper.updateTTextContent(textContent); |
| | | tExamPaperForUpdate.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamPaperMapper.updateTExamPaper(tExamPaperForUpdate); |
| | | } |
| | | |
| | | private void setExamPaperInfor(TExamPaper tExamPaper, TExamPaper tExamPaperForUpdate) { |
| | | tExamPaperForUpdate.setName(ExamUtil.getStringMapJson(tExamPaper.getLangType(), tExamPaper.getName(), tExamPaperForUpdate.getName())); |
| | | |
| | | |
| | | // 指导语多语言 |
| | | tExamPaperForUpdate.setGuide(ExamUtil.getStringMapJson(tExamPaper.getLangType(), tExamPaper.getGuide(), tExamPaperForUpdate.getGuide())); |
| | | |
| | | tExamPaperForUpdate.setSuggestTime(tExamPaper.getSuggestTime()); |
| | | |
| | | tExamPaperForUpdate.setReportTemplateId(tExamPaper.getReportTemplateId()); |
| | | |
| | | |
| | | // 设置分段的多语言 |
| | | setLangsPart(tExamPaper, tExamPaperForUpdate); |
| | | } |
| | | |
| | | private void setLangsPart(TExamPaper tExamPaper, TExamPaper tExamPaperForUpdate) { |
| | | try { |
| | | List<ExamPaperTitleItem> examPaperTitleItemListNew = JsonUtil.parseArray(tExamPaper.getQuestions(), ExamPaperTitleItem.class); |
| | |
| | | } |
| | | tExamPaper.setQuestions(JsonUtil.toJSONString(examPaperTitleItemListNew)); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int deleteProductContent(TExamPaper tExamPaper) { |
| | | |
| | | // 产品包名称多语言 |
| | | TExamPaper tExamPaperForUpdate = selectTExamPaperById(tExamPaper.getId()); |
| | | tExamPaperForUpdate.setName(ExamUtil.deleteLangString(tExamPaper.getLangType(), tExamPaperForUpdate.getName())); |
| | | |
| | | |
| | | // 指导语多语言 |
| | | tExamPaperForUpdate.setGuide(ExamUtil.deleteLangString(tExamPaper.getLangType(), tExamPaperForUpdate.getGuide())); |
| | | |
| | | |
| | | // 处理content里面的,旧的content拼新的content |
| | | TTextContent textContent = tTextContentMapper.selectTTextContentById(tExamPaperForUpdate.getFrameTextContentId()); |
| | | List<ExamPaperTitleItem> examPaperTitleItemUpdateList = JsonUtil.toJsonListObject(textContent.getContent(), ExamPaperTitleItem.class); |
| | | int questionNum = 0; |
| | | for (ExamPaperTitleItem examPaperTitleItem : examPaperTitleItemUpdateList) { |
| | | |
| | | // 为问题的每一项添加多语言 |
| | | examPaperTitleItem.setName(ExamUtil.deleteLangString(tExamPaper.getLangType(), examPaperTitleItem.getName())); |
| | | examPaperTitleItem.setGuide(ExamUtil.deleteLangString(tExamPaper.getLangType(), examPaperTitleItem.getGuide())); |
| | | examPaperTitleItem.setDescription(ExamUtil.deleteLangString(tExamPaper.getLangType(), examPaperTitleItem.getDescription())); |
| | | } |
| | | |
| | | textContent.setContent(JsonUtil.toJsonStr(examPaperTitleItemUpdateList)); |
| | | textContent.setUpdateTime(DateUtils.getNowDate()); |
| | | |
| | | // 删除分段的多语言 |
| | | deleteLangParts(tExamPaper, textContent); |
| | | tTextContentMapper.updateTTextContent(textContent); |
| | | tExamPaperForUpdate.setUpdateTime(DateUtils.getNowDate()); |
| | | return tExamPaperMapper.updateTExamPaper(tExamPaperForUpdate); |
| | | } |
| | | |
| | | private void deleteLangParts(TExamPaper tExamPaper, TTextContent textContent) { |
| | | try { |
| | | List<ExamPaperTitleItem> examPaperTitleItemForPartList = JsonUtil.parseArray(textContent.getContent(), ExamPaperTitleItem.class); |
| | |
| | | textContent.setContent(JsonUtil.toJSONString(examPaperTitleItemForPartList)); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除产品包列表对象 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteTExamPaperByIds(String ids) { |
| | | |
| | | // 删除索引的表 |
| | | tExamPaperQuestionMapper.deleteTExamPaperQuestionByIds(Convert.toStrArray(ids)); |
| | | |
| | | // 删除content表,省空间 |
| | | return tExamPaperMapper.updateByDelete(Convert.toStrArray(ids)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除产品包列表信息 |
| | | * |
| | | * @param id 产品包列表ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteTExamPaperById(Long id) { |
| | | return tExamPaperMapper.deleteTExamPaperById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<TExamPaper> selectProdByDeleteList(List<Long> deletes) { |
| | | Map map = new HashMap<>(); |
| | | map.put("deleteds", deletes); |
| | | return tExamPaperMapper.selectProdByDeleteList(map); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 所有可选产品包 |
| | | * |
| | | * @return 所有可选产品包 |
| | | */ |
| | | public List<Ztree> selectProdTree(String testType) { |
| | | List<Ztree> ztrees = new ArrayList<>(); |
| | | List<TExamPaper> dictList = getUserPapers(); |
| | |
| | | continue; |
| | | } |
| | | String questionTemplateId = tExamLevel.getQuestionTemplateId(); |
| | | |
| | | if (!Objects.equals(testType, questionTemplateId)) { |
| | | if (Objects.equals("questionnaire",testType) && Objects.equals("job",questionTemplateId)) { |
| | | |
| | | } else { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | return ztrees; |
| | | } |
| | | |
| | | public List<TExamPaper> getUserPapers() { |
| | | User sysUser = ShiroUtils.getSysUser(); |
| | | List<TExamPaper> dictList; |
| | | if (Objects.equals(UserTypeEnum.SYS_USER.getUserType(), sysUser.getUserType())) { |
| | | TExamPaper tExamPaper = new TExamPaper(); |
| | | dictList = tExamPaperService.selectTExamPaperList(tExamPaper); |
| | | } |
| | | }//其他用户展示sys_user_paper分配的产品包 |
| | | else { |
| | | SysUserPaper sysUserPaper = new SysUserPaper(); |
| | | sysUserPaper.setUserId(sysUser.getUserId()); |
| | |
| | | return paper; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | //取真实名称 |
| | | dictList.stream().forEach(p -> { |
| | | p.setName(ExamUtil.getStringByLang(p.getLangType(), p.getName())); |
| | | }); |
| | | |
| | | return dictList; |
| | | } |
| | | |
| | | @Override |
| | | public int updateDeleted(TExamPaper tExamPaper) { |
| | | return tExamPaperMapper.updateTExamPaper(tExamPaper); |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public List<TQuestion> updateInsertQuestion(List<TQuestion> questionList, String multilingual) { |
| | | questionList.stream().forEach(question -> { |
| | | |
| | | // 更新旧的 |
| | | question.setMultilingual(multilingual); |
| | | tQuestionService.updateTQuestion(question); |
| | | }); |
| | | return questionList; |
| | | } |
| | | |
| | | |
| | | // 如果本题目已经有了该种语言,就不要展示,edit-*.html使用 |
| | | @Override |
| | | public List<DictData> getType(Long id) { |
| | | |
| | | |
| | | // 查询字典先 |
| | | List<DictData> dictDataList = dictDataService.selectDictDataByType("lang_type"); |
| | | |
| | | |
| | | // 查看已经存在的题目 |
| | | if (Objects.nonNull(id)) { |
| | | TExamPaper tExamPaper = selectTExamPaperById(id); |
| | | Map<String, String> titleMap = JsonUtil.toJsonObject(tExamPaper.getName(), HashMap.class); |
| | | if (Objects.isNull(titleMap)) { |
| | | return dictDataList; |
| | | } |
| | | |
| | | List<DictData> dictDataListResult = new ArrayList<>(); |
| | | for (DictData dictData : dictDataList) { |
| | | if (StringUtils.isEmpty(titleMap.get(dictData.getDictValue()))) { |
| | |
| | | return dictDataList; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void recallThaiInterface(TExamReport tExamReportResult, String reportType) { |
| | | TExamReport tExamReportUpdate = new TExamReport(); |
| | | tExamReportUpdate.setId(tExamReportResult.getId()); |
| | | tExamReportUpdate.setTokenId(tExamReportResult.getTokenId()); |
| | | |
| | | // 去掉原来的那些内容 |
| | | tExamReportResult.setInterfaceContent(""); |
| | | |
| | | |
| | | // Maq和SAQ重新掉 |
| | | recallMaqAndSaqThaiInterface(tExamReportResult, reportType, tExamReportUpdate); |
| | | |
| | | recallCaqThaiInterface(tExamReportResult, reportType, tExamReportUpdate); |
| | | } |
| | | |
| | | private void recallCaqThaiInterface(TExamReport tExamReportResult, String reportType, TExamReport tExamReportUpdate) { |
| | | if (Objects.equals("CAQ", reportType)) { |
| | | ExamPaperSubmitVM examPaperSubmitVM = new ExamPaperSubmitVM(); |
| | | |
| | | // 是否是重新调用泰国团队 |
| | | examPaperSubmitVM.setRecallThaiInterface(true); |
| | | |
| | | // 走手动提交的方式赋值 |
| | | examPaperSubmitVM.setSubmitClick(true); |
| | | |
| | | if (!recallThaiInterfaceForMAQAndCAQ(tExamReportResult, tExamReportUpdate, examPaperSubmitVM, 2)) { |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void recallMaqAndSaqThaiInterface(TExamReport tExamReportResult, String reportType, TExamReport tExamReportUpdate) { |
| | | List<QuestionReport> questionReports = JsonUtil.parseArray(tExamReportResult.getQuestionReport(), QuestionReport.class); |
| | | if (Objects.equals("MAQ", reportType) || Objects.equals("SAQ", reportType)) { |
| | |
| | | for (Integer partOrder : partOrderSet) { |
| | | ExamPaperSubmitVM examPaperSubmitVM = new ExamPaperSubmitVM(); |
| | | examPaperSubmitVM.setPartOrder(partOrder); |
| | | |
| | | // 是否是重新调用泰国团队 |
| | | examPaperSubmitVM.setRecallThaiInterface(true); |
| | | if (!recallThaiInterfaceForMAQAndCAQ(tExamReportResult, tExamReportUpdate, examPaperSubmitVM, examPaperSubmitVM.getPartOrder())) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean recallThaiInterfaceForMAQAndCAQ(TExamReport tExamReportResult, TExamReport tExamReportUpdate, ExamPaperSubmitVM examPaperSubmitVM, Integer partOrder2) { |
| | | ReportAPIResult reportAPIResult = getTaiInterface(examPaperSubmitVM, tExamReportResult, tExamReportUpdate); |
| | | if (Objects.equals(reportAPIResult.getCode(), "fail")) { |
| | |
| | | examReportService.updateTExamReportByTokenId(tExamReportUpdate); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // 更新泰国接口数据,保存泰国接口数据 |
| | | updateTaiInterfaceContent(tExamReportUpdate, tExamReportResult, reportAPIResult, partOrder2); |
| | | tExamReportResult.setInterfaceContent(tExamReportUpdate.getInterfaceContent()); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<ExamPaperTitleItem> getExamPaperTitleContent(TExamPaper tExamPaper) { |
| | | |
| | | //表示还没有添加题目 |
| | | if (Objects.isNull(tExamPaper.getFrameTextContentId())) { |
| | | return null; |
| | | } |
| | | |
| | | TTextContent tTextContent = tTextContentService.selectTTextContentById(tExamPaper.getFrameTextContentId()); |
| | | |
| | | |
| | | //大标题,第一段查t_exam_paper的t_text_content |
| | | List<ExamPaperTitleItemObject> examPaperTitleItemObjectList = JSONArray.parseArray(tTextContent.getContent(), ExamPaperTitleItemObject.class); |
| | | |
| | | |
| | | // 工作分析问卷去去question的题目作为展示 |
| | | examUtilService.setTitleName(tExamPaper, examPaperTitleItemObjectList); |
| | | |
| | | |
| | | //标题、题干=>选项 名字:name,题目:questionItems,大标题 |
| | | List<ExamPaperTitleItem> examPaperTitleItemList = new ArrayList<>(); |
| | | |
| | | |
| | | // 设置question的值 |
| | | setPaperQuestion(tExamPaper, examPaperTitleItemObjectList, examPaperTitleItemList); |
| | | |
| | | |
| | | // 分片的返回 |
| | | examPaperTitleItemList.get(0).setParts(examPaperTitleItemObjectList.get(0).getParts()); |
| | | |
| | | |
| | | // 处理分片多语言 |
| | | getPartsmultiLanguage(tExamPaper, examPaperTitleItemList); |
| | | |
| | | return examPaperTitleItemList; |
| | | } |
| | | |
| | | private void getPartsmultiLanguage(TExamPaper tExamPaper, List<ExamPaperTitleItem> examPaperTitleItemList) { |
| | | List<QuestionPart> parts = examPaperTitleItemList.get(0).getParts(); |
| | | if (CollUtil.isEmpty(parts)) { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | private void setPaperQuestion(TExamPaper tExamPaper, List<ExamPaperTitleItemObject> examPaperTitleItemObjectList, List<ExamPaperTitleItem> examPaperTitleItemList) { |
| | | |
| | | //ExamPaperTitleItem->QuestionItem->QuestionEditItem->(A,B,C) |
| | | for (ExamPaperTitleItemObject examPaperTitleItemObject : examPaperTitleItemObjectList) { |
| | | |
| | | //标题、题干=>选项(单个) |
| | | ExamPaperTitleItem examPaperTitleItem = new ExamPaperTitleItem(); |
| | | |
| | | examPaperTitleItem.setName(ExamUtil.getLangString(tExamPaper.getLangType(), examPaperTitleItemObject.getName())); |
| | | |
| | | |
| | | //大标题下面有多少个题,查t_question |
| | | List<ExamPaperQuestionItemObject> examPaperQuestionList = examPaperTitleItemObject.getQuestionItems(); |
| | | |
| | | |
| | | //map保存题目的顺序 |
| | | Map<Integer, ExamPaperQuestionItemObject> questionOrder = new HashMap<>(); |
| | | List<String> ids = new ArrayList<String>(); |
| | | for (ExamPaperQuestionItemObject examPaperQuestionItemObject : examPaperQuestionList) { |
| | | ids.add(examPaperQuestionItemObject.getId().toString()); |
| | | questionOrder.put(examPaperQuestionItemObject.getId(), examPaperQuestionItemObject); |
| | | } |
| | | |
| | | if (ExamUtil.isListEmpty(ids)) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | //begin 查询出每一个标题的题目{"analyze":"这个是解析","correct":"C","questionItemObjects":[{"content":"<p>B选项</p>","prefix":"B","score":500},{"content":"A选项","prefix":"A","score":500},{"content":"C选项","prefix":"C","score":500},{"content":"D选项的答案","prefix":"D","score":500}],"titleContent":"请问海洋最多的是什么"} |
| | | List<TTextContentAndQuestion> tTextContents = tTextContentService.selectTextContentAndQuestion(ids.toArray(new String[ids.size()])); |
| | | List<QuestionItem> questionItemList = tTextContents.stream().map(i -> { |
| | | QuestionItem questionItem = new QuestionItem(); |
| | | |
| | | |
| | | //begin 获取题干内容 |
| | | QuestionObject questionObject = JSONObject.parseObject(i.getContent(), QuestionObject.class); |
| | | |
| | | // 多语言 |
| | | questionItem.setTitle(ExamUtil.getLangString(tExamPaper.getLangType(), questionObject.getTitleContent())); |
| | | questionItem.setId(i.getId().intValue()); |
| | | questionItem.setQuestionId(i.getQuestionId().intValue()); |
| | | questionItem.setItemOrder(questionOrder.get(i.getQuestionId().intValue()).getItemOrder()); |
| | | questionItem.setPermanentId(i.getPermanentId()); |
| | | questionItem.setPartOrder(questionOrder.get(i.getQuestionId().intValue()).getPartOrder()); |
| | | |
| | | |
| | | //end 获取题干内容 |
| | | |
| | | //begin 获取里面的选项,如果选项为空,就给一个默认值,否则智力题会报错 |
| | | if (Objects.nonNull(questionObject.getQuestionItemObjects())) { |
| | | List<QuestionEditItem> items = questionObject.getQuestionItemObjects().stream().map(val -> { |
| | | QuestionEditItem questionEditItem = modelMapper.map(val, QuestionEditItem.class); |
| | |
| | | questionEditItem.setScore(0); |
| | | items.add(questionEditItem); |
| | | questionItem.setItems(items); |
| | | |
| | | } |
| | | |
| | | //end 获取里面的选项 |
| | | |
| | | return questionItem; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | |
| | | //end 查询出每一个标题的题目 |
| | | |
| | | //大标题里面的题目 |
| | | examPaperTitleItem.setQuestionItems(questionItemList); |
| | | |
| | | examPaperTitleItem.setDescription(ExamUtil.getLangString(tExamPaper.getLangType(), examPaperTitleItemObject.getDescription())); |
| | | |
| | | examPaperTitleItem.setGuide(ExamUtil.getLangString(tExamPaper.getLangType(), examPaperTitleItemObject.getGuide())); |
| | | |
| | | examPaperTitleItem.setPermanentId(examPaperTitleItemObject.getPermanentId()); |
| | | |
| | | examPaperTitleItem.setQuestionId(examPaperTitleItemObject.getQuestionId()); |
| | | |
| | | examPaperTitleItemList.add(examPaperTitleItem); |
| | | } |
| | | } |
| | | |
| | | public RestResponse<SignalObject> getSignalObjectRestResponse(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReport, List<TExamReport> tExamReportList, String langType) { |
| | | |
| | | // 查询结果 |
| | | TExamReport tExamReportResult = tExamReportList.get(0); |
| | | |
| | | |
| | | // 调用泰国接口 |
| | | ReportAPIResult reportAPIResult = getTaiInterface(examPaperSubmitVM, tExamReportResult, tExamReport); |
| | | |
| | | |
| | | // 更新泰国接口数据,保存泰国接口数据 |
| | | updateTaiInterfaceContent(tExamReport, tExamReportResult, reportAPIResult, examPaperSubmitVM.getPartOrder()); |
| | | |
| | | |
| | | // 发送邮件个用户和HR |
| | | sendHRAndMemberEmail(tExamReport, true, true); |
| | | |
| | | |
| | | // 返回提示给前台 |
| | | return getSignalObject(examPaperSubmitVM.getPartOrder(), tExamReportResult, reportAPIResult, langType); |
| | | } |
| | | |
| | | private RestResponse<SignalObject> getSignalObject(int partOrder, TExamReport tExamReportResult, ReportAPIResult reportAPIResult, String langType) { |
| | | TExamPaper tExamPaper = selectTExamPaperById(tExamReportResult.getProductId()); |
| | | List<ExamPaperTitleItem> examPaperTitleItemList = JsonUtil.parseArray(tExamPaper.getContent(), ExamPaperTitleItem.class); |
| | |
| | | signalObject.setMessage(reportAPIResult.getMessage()); |
| | | return RestResponse.ok(signalObject); |
| | | } |
| | | |
| | | |
| | | // 发送附件给HR |
| | | public void sendHRAndMemberEmail(TExamReport tExamReport, boolean justHr, boolean justMember) { |
| | | |
| | | // 附件的位置,具体邮件附件的位置 |
| | | List<String> fileNameResult = new ArrayList<>(); |
| | | |
| | | // 要删除的文件 |
| | | List<String> deleteStrList = new ArrayList<>(); |
| | | |
| | | TExamReport tExamReportResult = examReportService.getReportFromTemplate(tExamReport, fileNameResult, deleteStrList); |
| | | if (tExamReportResult == null) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 调用发送程序发给用户 |
| | | String title = tExamReportResult.getMemberName() + MessageUtils.message("jsp.exam.quesiton.reportTilte"); |
| | | String content = tExamReportResult.getMailContent(); |
| | | StringBuilder remark = new StringBuilder(); |
| | | remark.append("失败邮箱:"); |
| | | |
| | | if (justMember) { |
| | | |
| | | // 用户发邮件 |
| | | sendMemberEmail(tExamReport, fileNameResult, tExamReportResult, title, content, remark); |
| | | } |
| | | if (justHr) { |
| | | |
| | | // 发送给Hr,但取testEmail |
| | | sendHrEmail(tExamReport, fileNameResult, tExamReportResult, title, content, remark); |
| | | } |
| | | |
| | | |
| | | // 更新发送状态,历史邮件地址 |
| | | tExamReport.setReportAddress(JsonUtil.toJSONString(fileNameResult)); |
| | | |
| | | |
| | | // 放一个当前邮件的地址 |
| | | tExamReport.setReportAddressNew(JsonUtil.toJSONString(fileNameResult)); |
| | | examReportService.updateTExamReportByTokenId(tExamReport); |
| | | |
| | | |
| | | |
| | | // 节省空间删除文件 |
| | | // deleteStrList.addAll(fileNameResult); |
| | | WordUtil wordUtil = new WordUtil(); |
| | | wordUtil.deleteFileByStr(deleteStrList); |
| | | } |
| | | |
| | | public void sendHrEmail(TExamReport tExamReport, List<String> fileNameResult, TExamReport tExamReportResult, String title, String content, StringBuilder remark) { |
| | | |
| | | // 如果创建测试包的时候没有填邮箱,那么就用集团的取HR邮箱邮箱 |
| | | List<String> hrEmailList = null; |
| | | try { |
| | | hrEmailList = Arrays.asList(tExamReportResult.getTestEmail().split(",")); |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | if (ExamUtil.isListEmpty(hrEmailList)) { |
| | | try { |
| | | hrEmailList = Arrays.asList(tExamReportResult.getHrEmail().split(",")); |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | } |
| | | |
| | | if (Objects.isNull(hrEmailList)) { |
| | | throw new RuntimeException("Hr Email Is Not Configured"); |
| | | } |
| | | |
| | | |
| | | //替换公司名称 |
| | | String userName = ExamUtil.getLangString(tExamReportResult.getLangType(), tExamReportResult.getUserName()); |
| | | |
| | | //替换用户名称 |
| | | String fullName = ExamUtil.getLangString(tExamReportResult.getLangType(), tExamReportResult.getMemberName()); |
| | | String productName = ExamUtil.getLangString(tExamReportResult.getLangType(), tExamReportResult.getProductName()); |
| | | if (StringUtils.isEmpty(content)) { |
| | | |
| | | content = loadReportHrDefaultTemplate(fullName, userName, productName); |
| | | } |
| | | |
| | | content = content.replace("{Company}", StringUtils.isNotEmpty(userName) ? userName : ""); |
| | | content = content.replace("{fullName}", StringUtils.isNotEmpty(fullName) ? fullName : ""); |
| | | content = content.replace("{prodName}", StringUtils.isNotEmpty(productName) ? productName : ""); |
| | | |
| | | for (String email : hrEmailList) { |
| | | |
| | | String hrEmailStatus = "1"; |
| | | RushMailResult rushMailResult = emailMessage.sendEmailwithAttachment(email, title, content, fileNameResult.stream().toArray(String[]::new)); |
| | | if (rushMailResult.isResult()) { |
| | | tExamReport.setSendHrStatus(SenderCode.success.getCode()); |
| | | } else { |
| | | } else { // 发送成功,发送失败处理 |
| | | remark.append(tExamReportResult.getMemberEmail() + ","); |
| | | tExamReport.setSendHrStatus(SenderCode.fail.getCode()); |
| | | hrEmailStatus = "2"; |
| | |
| | | tExamReport.setHrSendTime(new Date()); |
| | | tExamReport.setHrUpdateTime(new Date()); |
| | | try { |
| | | |
| | | //更新用户表发送HR邮件状态 |
| | | EntTestMember entTestMember = entTestMemberMapper.selectEntTestMemberById(Long.valueOf(tExamReportResult.getMemberId())); |
| | | entTestMember.setHrEmailStatus(hrEmailStatus); |
| | | entTestMember.setHrEmailTime(new Date()); |
| | |
| | | } catch (Exception ex) { |
| | | log.error("update HrEmailStatus error:{}", ex.getMessage(), ex); |
| | | } |
| | | |
| | | } |
| | | |
| | | tExamReport.setRemark(remark.toString()); |
| | | } |
| | | |
| | | private String loadReportHrDefaultTemplate(String fullName, String userName, String productName) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | | builder.append("亲爱的{Company}人力资源部,").append("<br>"); |
| | | builder.append("Dear HR Staff at {Company},").append("<br><br>"); |
| | | |
| | | builder.append("附件是{fullName}最近完成的{prodName}测评报告。").append("<br>"); |
| | | builder.append("Attached please find the assessment report on ({prodName}) of ({fullName}).").append("<br><br>"); |
| | | |
| | | builder.append("如有疑问,请与客服联系,邮箱是:support@tai-online.com。").append("<br>"); |
| | | builder.append("Should you have questions, please contact our customer service at support@tai-online.com. ").append("<br><br><br>"); |
| | | |
| | | builder.append("谢谢!").append("<br>"); |
| | | builder.append("All the best,").append("<br><br><br>"); |
| | | |
| | | builder.append("TAI公司客户服务部").append("<br>"); |
| | | builder.append("Customer Service Dept., TAI, LLC").append("<br><br><br>"); |
| | | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | private String loadReportMemberDefaultTemplate(String fullName, String userName, String productName) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("Subject Line: Your assessment report is attached (您的测评报告附上了)"); |
| | |
| | | builder.append(userName); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | |
| | | private void sendMemberEmail(TExamReport tExamReport, List<String> fileNameResult, TExamReport tExamReportResult, String title, String content, StringBuilder remark) { |
| | | |
| | | if (StringUtils.isEmpty(content)) { |
| | | |
| | | //替换公司名称 |
| | | String userName = tExamReportResult.getUserName(); |
| | | |
| | | //替换用户名称 |
| | | String fullName = tExamReportResult.getMemberName(); |
| | | String productName = ExamUtil.getLangString(tExamReportResult.getLangType(), tExamReportResult.getProductName()); |
| | | content = loadReportMemberDefaultTemplate(fullName, userName, productName); |
| | | } |
| | | |
| | | if (Objects.nonNull(tExamReportResult.getAutoSendReport()) && tExamReportResult.getAutoSendReport() == 1) { |
| | | boolean result = emailMessage.sendEmailwithAttachment(tExamReportResult.getMemberEmail(), title, content, fileNameResult.stream().toArray(String[]::new)).isResult(); |
| | | if (result) { |
| | | tExamReport.setSendTesterStatus(SenderCode.success.getCode()); |
| | | } else { |
| | | } else { // 发送成功,发送失败处理 |
| | | remark.append(tExamReportResult.getMemberEmail() + ","); |
| | | tExamReport.setSendTesterStatus(SenderCode.fail.getCode()); |
| | | } |
| | | } else { |
| | | tExamReport.setSendTesterStatus(SenderCode.noSend.getCode()); |
| | | } |
| | | |
| | | tExamReport.setRemark(remark.toString()); |
| | | } |
| | | |
| | | |
| | | private void updateTaiInterfaceContent(TExamReport tExamReportUpdate, TExamReport tExamReportResult, ReportAPIResult reportAPIResult, int partOrder) { |
| | | List<ReportAPIResult> reportAPIResultList = JsonUtil.parseArray(tExamReportResult.getInterfaceContent(), ReportAPIResult.class); |
| | | if (CollUtil.isNotEmpty(reportAPIResultList)) { |
| | |
| | | reportAPIResultList.remove(reportAPIResultList.size() - 1); |
| | | } |
| | | } |
| | | |
| | | if (ExamUtil.isListEmpty(reportAPIResultList)) { |
| | | reportAPIResultList = new ArrayList<>(); |
| | | } else { |
| | | int size = reportAPIResultList.size(); |
| | | int deletNum = size - (partOrder - 1); |
| | | |
| | | |
| | | // 如果前台可以跳到上一题,则要删除原来入库的 |
| | | for (int i = size - 1; i >= 0 && deletNum > 0; i--, deletNum--) { |
| | | reportAPIResultList.remove(i); |
| | | } |
| | | |
| | | logger.info("reportAPIResultList:的个数" + reportAPIResultList.size()); |
| | | } |
| | | reportAPIResultList.add(reportAPIResult); |
| | | tExamReportUpdate.setInterfaceContent(JsonUtil.toJSONString(reportAPIResultList)); |
| | | examReportService.updateTExamReportByTokenId(tExamReportUpdate); |
| | | } |
| | | |
| | | private ReportAPIResult getTaiInterface(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportResult, TExamReport tExamReportUpdate) { |
| | | Map<Integer, ReportTypeEnum> reportTypeEnumMap = new HashMap<>(); |
| | | reportTypeEnumMap.put(1, firstPath); |
| | |
| | | if ("SAQ".equals(tReportTemplate.getTemplateType()) || Objects.equals("SAQ", tReportTemplate.getReportType())) { |
| | | calculationTypeEnum = SAQ; |
| | | } |
| | | |
| | | if ("RuiLin".equals(tReportTemplate.getReportType())) { |
| | | calculationTypeEnum = RUILIN; |
| | | } |
| | | |
| | | if ("CAQ".equals(tReportTemplate.getReportType())) { |
| | | calculationTypeEnum = CAQ; |
| | | } |
| | | } |
| | | |
| | | HolderInfo info = new HolderInfo(); |
| | | info.setAccessCode(tExamReportResult.getTokenId()); |
| | | info.setFullName(tExamReportResult.getMemberName()); |
| | |
| | | return getReportAPIMAQResult(examPaperSubmitVM, tExamReportResult, tExamReportUpdate, reportTypeEnumMap, info); |
| | | } |
| | | } |
| | | |
| | | private ReportAPIResult getReportAPICAQResult(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportResult, TExamReport tExamReport, HolderInfo info) { |
| | | Map data = new HashMap(); |
| | | |
| | | |
| | | // 造数据 |
| | | // createMAQAndCAQData(examPaperSubmitVM, CAQ, data); |
| | | getWaitTaiData(examPaperSubmitVM, tExamReportResult, data); |
| | | CaqRequest request = new CaqRequest(); |
| | | request.setInfo(info); |
| | |
| | | } |
| | | return reportAPIResult; |
| | | } |
| | | |
| | | public SignalObject callTaiData(String tokenId, String langType, ExamPaperSubmitVM examPaperSubmitVM) { |
| | | |
| | | // 查找当前的答题记录 |
| | | TExamReport tExamReport = new TExamReport(); |
| | | tExamReport.setTokenId(tokenId); |
| | | List<TExamReport> tExamReportList = examReportService.selectTExamReportList(tExamReport); |
| | |
| | | if (ExamUtil.isListEmpty(questionReportList)) { |
| | | return getEmptySignalObjectResult(); |
| | | } |
| | | |
| | | try { |
| | | |
| | | // 调用泰国团队之后更新报表记录,发送给HR邮件 |
| | | RestResponse<SignalObject> signalObject = getSignalObjectRestResponse(examPaperSubmitVM, tExamReport, tExamReportList, langType); |
| | | |
| | | if (Objects.nonNull(signalObject)) { |
| | | return signalObject.getResponse(); |
| | | } |
| | |
| | | updateChoice(examPaperSubmitVM, tExamReport, tExamReportOldResult); |
| | | throw e; |
| | | } |
| | | |
| | | return getEmptySignalObjectResult(); |
| | | } |
| | | |
| | | private SignalObject getEmptySignalObjectResult() { |
| | | SignalObject signalObject = new SignalObject(); |
| | | signalObject.setSignalDescription(""); |
| | | return signalObject; |
| | | } |
| | | |
| | | private void updateChoice(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReport, TExamReport tExamReportOldResult) { |
| | | tExamReport.setFinish(0); |
| | | if (StringUtils.isEmpty(tExamReport.getTokenId()) || StringUtils.isEmpty(examPaperSubmitVM.getItemOrder())) { |
| | | examReportService.updateTExamReportByTokenId(tExamReport); |
| | | return; |
| | | } |
| | | |
| | | String choice = tExamReportOldResult.getChoice(); |
| | | LinkedHashMap<String, String> linkedHashMap = JsonUtil.parseObject(choice, LinkedHashMap.class); |
| | | Iterator<String> iterator = linkedHashMap.keySet().iterator(); |
| | |
| | | tExamReport.setRemark(tExamReport.getRemark() + ",itemOrder:" + examPaperSubmitVM.getItemOrder()); |
| | | examReportService.updateTExamReportByTokenId(tExamReport); |
| | | } |
| | | |
| | | |
| | | // 造数据函数入口 |
| | | private void createMAQAndCAQData(ExamPaperSubmitVM examPaperSubmitVM, CalculationTypeEnum calculationTypeEnum, Map data) { |
| | | if (calculationTypeEnum == CAQ) { |
| | | |
| | | // 造CAQ的数据 |
| | | simulationCAQTaiData(examPaperSubmitVM.getPartOrder(), data); |
| | | } else { |
| | | |
| | | // 造数据,MAQ,不需要,上线的时候要注释掉 |
| | | simulationTaiData(examPaperSubmitVM.getPartOrder(), data); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 模拟泰国团队 |
| | | private void simulationTaiData(int partOrder, Map data) { |
| | | String topics = "MAQ0001,MAQ0003,MAQ0006,MAQ0009,MAQ0013,MAQ0020,MAQ0041,MAQ0048,MAQ0088,MAQ0094,MAQ0098,MAQ0112,MAQ0117,MAQ0133,MAQ0145,MAQ0163,MAQ0172,MAQ0174,MAQ0175,MAQ0183,MAQ0194,MAQ0203,MAQ0209,MAQ0212,MAQ0224,MAQ0232,MAQ0233,MAQ0235,MAQ0236,MAQ0241,MAQ0244,MAQ0249,MAQ0250,MAQ0251,MAQ0004,MAQ0005,MAQ0007,MAQ0010,MAQ0011,MAQ0014,MAQ0015,MAQ0019,MAQ0021,MAQ0024,MAQ0025,MAQ0026,MAQ0027,MAQ0028,MAQ0029,MAQ0030,MAQ0034,MAQ0035,MAQ0036,MAQ0038,MAQ0039,MAQ0040,MAQ0042,MAQ0044,MAQ0045,MAQ0046,MAQ0047,MAQ0049,MAQ0051,MAQ0053,MAQ0055,MAQ0058,MAQ0059,MAQ0060,MAQ0061,MAQ0062,MAQ0064,MAQ0065,MAQ0067,MAQ0069,MAQ0070,MAQ0071,MAQ0072,MAQ0073,MAQ0074,MAQ0076,MAQ0077,MAQ0078,MAQ0079,MAQ0080,MAQ0081,MAQ0082,MAQ0084,MAQ0085,MAQ0086,MAQ0087,MAQ0089,MAQ0090,MAQ0091,MAQ0092,MAQ0095,MAQ0097,MAQ0099,MAQ0100,MAQ0101,MAQ0103,MAQ0104,MAQ0106,MAQ0107,MAQ0110,MAQ0111,MAQ0113,MAQ0115,MAQ0118,MAQ0119,MAQ0120,MAQ0124,MAQ0126,MAQ0127,MAQ0129,MAQ0130,MAQ0131,MAQ0132,MAQ0134,MAQ0135,MAQ0136,MAQ0138,MAQ0140,MAQ0141,MAQ0142,MAQ0143,MAQ0144,MAQ0146,MAQ0147,MAQ0149,MAQ0150,MAQ0151,MAQ0152,MAQ0156,MAQ0157,MAQ0158,MAQ0159,MAQ0160,MAQ0161,MAQ0162,MAQ0164,MAQ0165,MAQ0166,MAQ0167,MAQ0168,MAQ0169,MAQ0170,MAQ0171,MAQ0173,MAQ0176,MAQ0178,MAQ0179,MAQ0180,MAQ0181,MAQ0182,MAQ0184,MAQ0185,MAQ0187,MAQ0190,MAQ0191,MAQ0192,MAQ0193,MAQ0195,MAQ0197,MAQ0199,MAQ0200,MAQ0201,MAQ0202,MAQ0204,MAQ0205,MAQ0206,MAQ0207,MAQ0208,MAQ0210,MAQ0211,MAQ0213,MAQ0214,MAQ0216,MAQ0218,MAQ0219,MAQ0220,MAQ0221,MAQ0223,MAQ0225,MAQ0226,MAQ0227,MAQ0228,MAQ0229,MAQ0230,MAQ0231,MAQ0234,MAQ0237,MAQ0240,MAQ0242,MAQ0243,MAQ0245,MAQ0247,MAQ0248,MAQ0253,MAQ0254,MAQ0255"; |
| | | if (partOrder == 1) { |
| | |
| | | data.put(item, "5"); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 模拟CAQ的数据 |
| | | private void simulationCAQTaiData(int partOrder, Map data) { |
| | | String topics = "CAQ1010,CAQ1020,CAQ1030,CAQ1040,CAQ1050,CAQ1060,CAQ1070,CAQ1080,CAQ1090,CAQ1100,CAQ1110,CAQ1120,CAQ1130,CAQ1140,CAQ1150,CAQ2010,CAQ2020,CAQ2030,CAQ2040,CAQ2050,CAQ2060,CAQ2070,CAQ2080,CAQ2090,CAQ2100,CAQ2110,CAQ2120,CAQ2130,CAQ2140,CAQ2150,CAQ2160,CAQ2170,CAQ2180,CAQ2190,CAQ2200"; |
| | | if (partOrder == 1) { |
| | |
| | | data.put(item, "5"); |
| | | }); |
| | | } |
| | | |
| | | private void setNormalSubmit(ExamPaperSubmitVM examPaperSubmitVM, Map data, List<QuestionReport> questionReportList) { |
| | | for (QuestionReport questionReport : questionReportList) { |
| | | |
| | | // PermanentId 等于0是智力题的大题,问答题,顺便判断为空 |
| | | if (questionReport.getPartOrder() > examPaperSubmitVM.getPartOrder() || Objects.isNull(questionReport.getPermanentId()) || Objects.equals(questionReport.getPermanentId(), "0")) { |
| | | continue; |
| | | } |
| | | data.put(questionReport.getPermanentId(), questionReport.getAnswer()); |
| | | } |
| | | } |
| | | |
| | | private void setManSubmit(Map data, List<QuestionReport> questionReportList) { |
| | | for (QuestionReport questionReport : questionReportList) { |
| | | |
| | | // PermanentId 等于0是智力题的大题,问答题,顺便判断为空 |
| | | if (StringUtils.isNotEmpty(questionReport.getPermanentId()) && !Objects.equals(questionReport.getPermanentId(), "0")) { |
| | | data.put(questionReport.getPermanentId(), questionReport.getAnswer()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private ReportAPIResult getReportAPISAQResult(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportResult, TExamReport tExamReport, Map<Integer, ReportTypeEnum> reportTypeEnumMap, HolderInfo info) { |
| | | return getReportAPIMAQResult(examPaperSubmitVM, tExamReportResult, tExamReport, reportTypeEnumMap, info); |
| | | } |
| | | |
| | | private ReportAPIResult getReportAPIMAQResult(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportResult, TExamReport tExamReport, Map<Integer, ReportTypeEnum> reportTypeEnumMap, HolderInfo info) { |
| | | Map data = new HashMap(); |
| | | |
| | | |
| | | // 造数据 |
| | | // createMAQAndCAQData(examPaperSubmitVM, MAQ, data); |
| | | getWaitTaiData(examPaperSubmitVM, tExamReportResult, data); |
| | | MaqRequest request = new MaqRequest(); |
| | | request.setInfo(info); |
| | |
| | | request.setData(data); |
| | | ReportAPIResult reportAPIResult = calculationServices.stageCalculation(request); |
| | | reportAPIResult.setAnswerData(data); |
| | | |
| | | // 重新调用泰国团队的接口的话,不需要更新题目了 |
| | | if (Objects.equals(reportAPIResult.getCode(), "fail") && !examPaperSubmitVM.isRecallThaiInterface()) { |
| | | updateChoice(examPaperSubmitVM, tExamReport, tExamReportResult); |
| | | } |
| | | return reportAPIResult; |
| | | } |
| | | |
| | | private void getWaitTaiData(ExamPaperSubmitVM examPaperSubmitVM, TExamReport tExamReportResult, Map data) { |
| | | List<QuestionReport> questionReportList = JsonUtil.parseArray(tExamReportResult.getQuestionReport(), QuestionReport.class); |
| | | if (examPaperSubmitVM.isSubmitClick()) { |
| | | |
| | | // 自己提交的那种,如智力题 |
| | | setManSubmit(data, questionReportList); |
| | | } else { |
| | | setNormalSubmit(examPaperSubmitVM, data, questionReportList); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |