| | |
| | | public Boolean saveAnswer(List<SubjectChoicesVO> subjectChoicesVO) { |
| | | BigDecimal bigDecimal = BigDecimal.valueOf(0); |
| | | List<AnswerRecordEntity> objects = new ArrayList<>(); |
| | | // 遍历题目和选项 |
| | | for (SubjectChoicesVO choicesVO : subjectChoicesVO) { |
| | | List<SubjectOptionVO> subjectOptionList = choicesVO.getSubjectOptionList(); |
| | | if (choicesVO.getChoicesType().intValue() == 3) { |
| | | bigDecimal = bigDecimal.add(choicesVO.getScore()); |
| | | } |
| | | for (SubjectOptionVO subjectOptionVO : subjectOptionList) { |
| | | boolean update = remove(Wrappers.<AnswerRecordEntity>lambdaQuery() |
| | | // 删除掉之前保存的记录 |
| | | remove(Wrappers.<AnswerRecordEntity>lambdaQuery() |
| | | .eq(AnswerRecordEntity::getPropertyId, choicesVO.getPropertyId()) |
| | | .eq(AnswerRecordEntity::getSubjectChoicesId, choicesVO.getId())); |
| | | if (subjectOptionVO.getIds() != null) { |
| | |
| | | } else if (subjectChoicesVO.get(0).getSubclassName().equals("违法违规行为惩戒")) { |
| | | one.setLllegalAndIrregularScore(bigDecimal); |
| | | } |
| | | // 计算总分 |
| | | BigDecimal add = one.getBaseInfoScore() |
| | | .add(one.getOperateinfoScore()) |
| | | .add(one.getOperateinfoScore()) |
| | |
| | | .add(one.getGoodProjectScore()) |
| | | .add(one.getLllegalAndIrregularScore()) |
| | | .add(one.getEvaluateScore()); |
| | | one.setAllScore(add); |
| | | one.setAllScore(getAllScore(add)); |
| | | bean.updateById(one); |
| | | return saveBatch(objects); |
| | | } |
| | | |
| | | /** |
| | | * 判断结果,如果大于100 则设置100 小于/等于0 设置为0 |
| | | * |
| | | * @param allScore |
| | | * @return |
| | | */ |
| | | private BigDecimal getAllScore(BigDecimal allScore) { |
| | | if (allScore.compareTo(BigDecimal.valueOf(0)) > 100) { |
| | | return BigDecimal.valueOf(100); |
| | | } |
| | | if (allScore.compareTo(BigDecimal.valueOf(0)) > 0) { |
| | | return allScore; |
| | | } |
| | | return BigDecimal.valueOf(0); |
| | | } |
| | | |
| | | |
| | | } |