| | |
| | | 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; |
| | | |
| | | import java.util.*; |
| | |
| | | @Service |
| | | public class ConsultantMapper { |
| | | |
| | | private final static Character SPLIT_MASK = ','; |
| | | private static final Character SPLIT_MASK = ','; |
| | | |
| | | private final AppointmentService appointmentService; |
| | | |
| | | public ConsultantMapper(AppointmentService appointmentService) { |
| | | this.appointmentService = appointmentService; |
| | | } |
| | | |
| | | public ConsultantDTO toDto(Consultant source) { |
| | | ConsultantDTO consultantDTO = new ConsultantDTO(); |
| | | public CustomerFavoriteConsultantDTO toCustomerFavoriteConsultantDto(Consultant source) { |
| | | CustomerFavoriteConsultantDTO consultantDTO = new CustomerFavoriteConsultantDTO(); |
| | | consultantDTO.setAgentNo(source.getAgentNo()); |
| | | consultantDTO.setName(source.getName()); |
| | | consultantDTO.setAvgScore(source.getAvgScore()); |
| | | consultantDTO.setSeniority(source.getSeniority()); |
| | | consultantDTO.setSeniority(source.getSeniorityDTOString()); |
| | | consultantDTO.setExpertise(splitStringWithChar(source.getExpertise())); |
| | | consultantDTO.setImg(source.getPhotoPath()); |
| | | consultantDTO.setRole(source.getRole()); |
| | | |
| | | consultantDTO.setContactStatus(null); |
| | | consultantDTO.setUpdateTime(null); |
| | |
| | | return consultantDTO; |
| | | } |
| | | |
| | | public ConsultantDTO toDto(CustomerFavoriteConsultant customerFavoriteConsultant) { |
| | | Consultant consultant = customerFavoriteConsultant.getConsultant(); |
| | | ConsultantDTO dto = toDto(consultant); |
| | | public ConsultantDTO toDto(Consultant source) { |
| | | ConsultantDTO consultantDTO = new ConsultantDTO(); |
| | | 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()); |
| | | |
| | | final Optional<Appointment> latestAppointmentOptional = appointmentService.findByAgentNoAndCustomerId(consultant.getAgentNo(), customerFavoriteConsultant.getCustomerId()) |
| | | .stream() |
| | | .max(Comparator.comparing(Appointment::getAppointmentDate)); |
| | | consultantDTO.setContactStatus(null); |
| | | consultantDTO.setUpdateTime(null); |
| | | consultantDTO.setLatestAppointmentId(null); |
| | | |
| | | 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; |
| | | return consultantDTO; |
| | | } |
| | | |
| | | public ConsultantDetailDTO toDetailDto(Consultant source) { |
| | |
| | | consultantDetailDTO.setPhoneNumber(source.getPhoneNumber()); |
| | | consultantDetailDTO.setServeArea(source.getServeArea()); |
| | | consultantDetailDTO.setCompanyAddress(source.getCompanyAddress()); |
| | | consultantDetailDTO.setLatestLoginTime(source.getLatestLoginTime()); |
| | | consultantDetailDTO.setSeniority(source.getSeniority()); |
| | | consultantDetailDTO.setSeniority(source.getSeniorityDTOString()); |
| | | consultantDetailDTO.setConcept(source.getConcept()); |
| | | consultantDetailDTO.setAwards(source.getAward()); |
| | | consultantDetailDTO.setImage(source.getPhotoPath()); |
| | | consultantDetailDTO.setExpertises(splitStringWithChar(source.getExpertise())); |
| | | consultantDetailDTO.setExperiences(splitStringWithChar(source.getExperience())); |
| | | |
| | | // todo 決定匹配程度 |
| | | consultantDetailDTO.setSuitability(50); |
| | | consultantDetailDTO.setEvaluation(50); |
| | | consultantDetailDTO.setExpertises(splitStringWithChar(source.getExpertise())); |
| | | consultantDetailDTO.setExperiences(splitStringWithChar(source.getExperience())); |
| | | |
| | | return consultantDetailDTO; |
| | | } |