| | |
| | | package com.project.enforce.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.project.common.exception.base.BaseException; |
| | | import com.project.common.utils.JsonUtils; |
| | | import com.project.common.utils.NumberUtils; |
| | | import com.project.common.utils.StringUtils; |
| | | import com.project.enforce.domain.EnforceEvaluateAnswer; |
| | | import com.project.enforce.domain.EnforceEvaluateLog; |
| | | import com.project.enforce.domain.EnforceEvaluateQuestion; |
| | | import com.project.enforce.domain.EnforceOrder; |
| | | import com.project.enforce.domain.bo.editBo.EnforceEvaluateBo; |
| | | import com.project.enforce.domain.vo.EnforceEvaluateVo; |
| | | import com.project.enforce.service.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | if (StringUtils.isEmpty(questionList)){ |
| | | throw new BaseException("评价项不可为空!"); |
| | | } |
| | | for (EnforceEvaluateQuestion question : bo.getQuestionList()) { |
| | | for (EnforceEvaluateQuestion question : questionList) { |
| | | if (question.getQuestionType()==1 && StringUtils.isEmpty(question.getAnswerList())){ |
| | | throw new BaseException("选择类型答案不可为空!"); |
| | | } |
| | |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean saveOrder(EnforceEvaluateBo bo) |
| | | { |
| | | if (bo.getOrderId()==null){ |
| | | throw new BaseException("请选择评价执法单!"); |
| | | } |
| | | List<EnforceEvaluateQuestion> questionList = bo.getQuestionList(); |
| | | if (StringUtils.isEmpty(questionList)){ |
| | | throw new BaseException("评价项不可为空!"); |
| | | } |
| | | int count = evaluateLogService.count(EnforceEvaluateLog::getOrderId, bo.getOrderId()); |
| | | if (count>0) { |
| | | throw new BaseException("该执法单已评价!"); |
| | | } |
| | | BigDecimal totalScore = BigDecimal.ZERO; |
| | | for (EnforceEvaluateQuestion question : questionList) { |
| | | totalScore = NumberUtils.add(totalScore, question.getGetScore()); |
| | | } |
| | | EnforceOrder order = orderService.getById(bo.getOrderId()); |
| | | EnforceEvaluateLog evaluateLog = Convert.convert(EnforceEvaluateLog.class, order); |
| | | evaluateLog.setQuestionRemark(bo.getQuestionRemark()); |
| | | evaluateLog.setTotalScore(NumberUtils.divToBigDecSca2(totalScore,1)); |
| | | evaluateLog.setQuestionStatic(JsonUtils.objectToJson(bo.getQuestionList())); |
| | | |
| | | evaluateLogService.saveOrUpdate(evaluateLog); |
| | | return orderService.update(orderService.lu() |
| | | .set(EnforceOrder::getIsEva,1) |
| | | .set(EnforceOrder::getTotalScore, totalScore) |
| | | ); |
| | | } |
| | | |
| | | |
| | | } |