| | |
| | | |
| | | private static final Character SPLIT_MASK = ','; |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | |
| | | public ConsultantDTO toDto(Consultant source) { |
| | | ConsultantDTO consultantDTO = new ConsultantDTO(); |
| | | consultantDTO.setAgentNo(source.getAgentNo()); |
| | |
| | | consultantDTO.setLatestAppointmentId(null); |
| | | |
| | | return consultantDTO; |
| | | } |
| | | |
| | | public ConsultantDTO toDto(CustomerFavoriteConsultant customerFavoriteConsultant) { |
| | | Consultant consultant = customerFavoriteConsultant.getConsultant(); |
| | | ConsultantDTO dto = toDto(consultant); |
| | | |
| | | final Optional<Appointment> latestAppointmentOptional = appointmentService.findByAgentNoAndCustomerId(consultant.getAgentNo(), customerFavoriteConsultant.getCustomerId()) |
| | | .stream() |
| | | .max(Comparator.comparing(Appointment::getAppointmentDate)); |
| | | |
| | | if(latestAppointmentOptional.isPresent()) { |
| | | Appointment latestAppointment = latestAppointmentOptional.get(); |
| | | dto.setContactStatus(latestAppointment.getCommunicateStatus()); |
| | | dto.setLatestAppointmentId(latestAppointment.getId()); |
| | | dto.setUpdateTime(latestAppointment.getAppointmentDate()); |
| | | } |
| | | else { |
| | | dto.setContactStatus(ContactStatusEnum.PICKED); |
| | | dto.setLatestAppointmentId(null); |
| | | dto.setUpdateTime(customerFavoriteConsultant.getLastModifiedDate()); |
| | | } |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | public ConsultantDetailDTO toDetailDto(Consultant source) { |