| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveSubjectChoicesAndOption(ExamSubjectChoicesVO examSubjectChoices) { |
| | | ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); |
| | | subjectChoices.setCreateDate(new Date()); |
| | | subjectChoices.setDelFlag(0); |
| | | subjectChoices.setAnswer(examSubjectChoices.getAnswer()); |
| | | if (null!=examSubjectChoices.getAnalysis() && examSubjectChoices.getAnalysis()!=""){ |
| | | subjectChoices.setAnalysis(examSubjectChoices.getAnalysis()); |
| | | } |
| | | subjectChoices.setCreator(examSubjectChoices.getCreator()); |
| | | subjectChoices.setChoicesType(examSubjectChoices.getChoicesType()); |
| | | subjectChoices.setSubjectName(examSubjectChoices.getSubjectName()); |
| | | subjectChoices.setScore(examSubjectChoices.getScore()); |
| | | subjectChoices.setTktype(examSubjectChoices.getTktype()); |
| | | //题目新增 |
| | | boolean status = this.save(subjectChoices); |
| | | //判断类型,单选,多选 |
| | | if (examSubjectChoices.getChoicesType()==0 || examSubjectChoices.getChoicesType()==1 || examSubjectChoices.getChoicesType()==3){ |
| | | //选项新增 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setCreateDate(new Date()); |
| | | examSubjectOption.setDelFlag(0); |
| | | //新增 |
| | | examSubjectOptionService.save(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //内网数据同步 |
| | | try { |
| | | boolean status = false; |
| | | //新增 |
| | | if (null == examSubjectChoices.getId()) { |
| | | ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); |
| | | subjectChoices.setCreateDate(new Date()); |
| | | subjectChoices.setDelFlag(0); |
| | | subjectChoices.setAnswer(examSubjectChoices.getAnswer()); |
| | | if (null != examSubjectChoices.getAnalysis() && examSubjectChoices.getAnalysis() != "") { |
| | | subjectChoices.setAnalysis(examSubjectChoices.getAnalysis()); |
| | | } |
| | | subjectChoices.setCreator(examSubjectChoices.getCreator()); |
| | | subjectChoices.setChoicesType(examSubjectChoices.getChoicesType()); |
| | | subjectChoices.setSubjectName(examSubjectChoices.getSubjectName()); |
| | | subjectChoices.setScore(examSubjectChoices.getScore()); |
| | | subjectChoices.setTktype(examSubjectChoices.getTktype()); |
| | | //题目新增 |
| | | status = this.save(subjectChoices); |
| | | //判断类型,单选,多选,实操 |
| | | if (examSubjectChoices.getChoicesType() == 0 || examSubjectChoices.getChoicesType() == 1 || examSubjectChoices.getChoicesType() == 3) { |
| | | //选项新增 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setCreateDate(new Date()); |
| | | examSubjectOption.setDelFlag(0); |
| | | //新增 |
| | | examSubjectOptionService.save(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //内网数据同步 |
| | | try { |
| | | // arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | //修改 |
| | | ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); |
| | | subjectChoices.setId(examSubjectChoices.getId()); |
| | | subjectChoices.setModifyDate(new Date()); |
| | | subjectChoices.setAnswer(examSubjectChoices.getAnswer()); |
| | | if (null != examSubjectChoices.getAnalysis() && examSubjectChoices.getAnalysis() != "") { |
| | | subjectChoices.setAnalysis(examSubjectChoices.getAnalysis()); |
| | | } |
| | | subjectChoices.setModifier(examSubjectChoices.getCreator()); |
| | | subjectChoices.setChoicesType(examSubjectChoices.getChoicesType()); |
| | | subjectChoices.setSubjectName(examSubjectChoices.getSubjectName()); |
| | | subjectChoices.setScore(examSubjectChoices.getScore()); |
| | | subjectChoices.setTktype(examSubjectChoices.getTktype()); |
| | | //题目修改 |
| | | status = this.updateById(subjectChoices); |
| | | //判断类型,单选,多选 |
| | | if (examSubjectChoices.getChoicesType() == 0 || examSubjectChoices.getChoicesType() == 1) { |
| | | //选项修改 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setModifyDate(new Date()); |
| | | examSubjectOption.setModifier(examSubjectChoices.getCreator()); |
| | | //修改 |
| | | examSubjectOptionService.updateById(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //实操 |
| | | if (examSubjectChoices.getChoicesType() == 3) { |
| | | //先将选项删除 |
| | | baseMapper.removeBySubjectId(examSubjectChoices.getId()); |
| | | //选项新增 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setCreateDate(new Date()); |
| | | examSubjectOption.setDelFlag(0); |
| | | //新增 |
| | | examSubjectOptionService.save(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //内网数据同步 |
| | | try { |
| | | // arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return status; |
| | | } |