| | |
| | | import com.pollex.pam.service.AppointmentService; |
| | | import com.pollex.pam.service.dto.ConsultantDTO; |
| | | import com.pollex.pam.service.dto.ConsultantDetailDTO; |
| | | import com.pollex.pam.service.dto.CustomerFavoriteConsultantDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | private static final Character SPLIT_MASK = ','; |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | public CustomerFavoriteConsultantDTO toCustomerFavoriteConsultantDto(Consultant source) { |
| | | CustomerFavoriteConsultantDTO consultantDTO = new CustomerFavoriteConsultantDTO(); |
| | | consultantDTO.setAgentNo(source.getAgentNo()); |
| | | consultantDTO.setName(source.getName()); |
| | | consultantDTO.setAvgScore(source.getAvgScore()); |
| | | consultantDTO.setSeniority(source.getSeniorityDTOString()); |
| | | consultantDTO.setExpertise(splitStringWithChar(source.getExpertise())); |
| | | consultantDTO.setImg(source.getPhotoPath()); |
| | | consultantDTO.setRole(source.getRole()); |
| | | |
| | | consultantDTO.setContactStatus(null); |
| | | consultantDTO.setUpdateTime(null); |
| | | consultantDTO.setLatestAppointmentId(null); |
| | | |
| | | return consultantDTO; |
| | | } |
| | | |
| | | public ConsultantDTO toDto(Consultant source) { |
| | | ConsultantDTO consultantDTO = new ConsultantDTO(); |
| | |
| | | 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) { |