| | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.pollex.pam.consts.SeniorityQueryConst.*; |
| | |
| | | } |
| | | |
| | | public void setConsultantAvgScore(Satisfaction satisfaction) { |
| | | float avgScore = getAgentAvgScore(satisfaction.getAgentNo()); |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) |
| | | .get(); |
| | | consultant.setAvgScore(avgScore); |
| | | Optional<Float> avgScore = getAgentAvgScore(satisfaction.getAgentNo()); |
| | | |
| | | if(avgScore.isPresent()) { |
| | | BigDecimal bigDecimal = BigDecimal.valueOf(avgScore.get()); |
| | | |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()).get(); |
| | | consultant.setAvgScore(bigDecimal.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue()); |
| | | consultantRepository.save(consultant); |
| | | } |
| | | } |
| | | |
| | | public float getAgentAvgScore(String agentNo) { |
| | | Float avgScore = satisfactionRepository.getAgentScoreAvg(agentNo); |
| | | if(avgScore==null)return 0; |
| | | BigDecimal bigDecimal = new BigDecimal(avgScore); |
| | | return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); |
| | | public Optional<Float> getAgentAvgScore(String agentNo) { |
| | | return satisfactionRepository.getAgentScoreAvg(agentNo); |
| | | } |
| | | } |