| | |
| | | package com.pollex.pam.service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.pollex.pam.domain.Appointment; |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | | import com.pollex.pam.repository.CustomerRepository; |
| | | import com.pollex.pam.repository.SatisfactionRepository; |
| | | import com.pollex.pam.service.dto.SatisfactionCustomerCreateDTO; |
| | |
| | | |
| | | @Autowired |
| | | CustomerRepository customerRepository; |
| | | |
| | | @Autowired |
| | | ConsultantRepository consultantRepository; |
| | | |
| | | public Satisfaction createSatisfaction(Satisfaction satisfaction) { |
| | | return satisfactionRepository.save(satisfaction); |
| | | satisfaction = satisfactionRepository.save(satisfaction); |
| | | setConsultantAvgScore(satisfaction); |
| | | return satisfaction; |
| | | } |
| | | |
| | | |
| | | |
| | | private void setConsultantAvgScore(Satisfaction satisfaction) { |
| | | float avgScore = getAgentAvgScore(satisfaction); |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) |
| | | .get(); |
| | | consultant.setAvgScore(avgScore); |
| | | consultantRepository.save(consultant); |
| | | } |
| | | |
| | | |
| | | |
| | | private float getAgentAvgScore(Satisfaction satisfaction) { |
| | | Float avgScore = satisfactionRepository.getAgentScoreAvg(satisfaction.getAgentNo()); |
| | | BigDecimal bigDecimal = new BigDecimal(avgScore); |
| | | return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); |
| | | } |
| | | |
| | | |
| | | |
| | | public Satisfaction createSatisfaction(Appointment appointment) { |
| | | Satisfaction satisfaction = appointmentMapper.toSatisfaction(appointment); |
| | | return createSatisfaction(satisfaction); |