| | |
| | | package com.pollex.pam.service.mapper; |
| | | |
| | | import com.pollex.pam.domain.Appointment; |
| | | import com.pollex.pam.domain.Consultant; |
| | | 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.time.Instant; |
| | | import java.time.ZonedDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class ConsultantMapper { |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | |
| | | private static final Character SPLIT_MASK = ','; |
| | | |
| | |
| | | ConsultantDTO consultantDTO = new ConsultantDTO(); |
| | | consultantDTO.setAgentNo(source.getAgentNo()); |
| | | consultantDTO.setName(source.getName()); |
| | | consultantDTO.setRole(source.getRole()); |
| | | consultantDTO.setAvgScore(source.getAvgScore()); |
| | | consultantDTO.setServeArea(splitStringWithChar(source.getServeArea())); |
| | | consultantDTO.setSeniority_year(source.getSeniorityYear()); |
| | | consultantDTO.setSeniority_month(source.getSeniorityMonth()); |
| | | consultantDTO.setSeniority(source.getSeniorityDTOString()); |
| | | consultantDTO.setExpertise(splitStringWithChar(source.getExpertise())); |
| | | consultantDTO.setGender(source.getGender()); |
| | | consultantDTO.setCommunicationStyle(source.getCommunicationStyle()); |
| | | consultantDTO.setImg(source.getPhotoPath()); |
| | | consultantDTO.setRole(source.getRole()); |
| | | |
| | | consultantDTO.setSuitability(0); |
| | | consultantDTO.setContactStatus(null); |
| | | consultantDTO.setUpdateTime(null); |
| | | // consultantDTO.setLatestAppointmentId(null); |
| | | |
| | | return consultantDTO; |
| | | } |
| | |
| | | consultantDetailDTO.setAvgScore(source.getAvgScore()); |
| | | consultantDetailDTO.setTitle(source.getTitle()); |
| | | consultantDetailDTO.setPhoneNumber(source.getPhoneNumber()); |
| | | consultantDetailDTO.setServeArea(splitStringWithChar(source.getServeArea())); |
| | | consultantDetailDTO.setServeArea(source.getServeArea()); |
| | | consultantDetailDTO.setCompanyAddress(source.getCompanyAddress()); |
| | | consultantDetailDTO.setSeniority(source.getSeniorityDTOString()); |
| | | consultantDetailDTO.setConcept(source.getConcept()); |
| | | consultantDetailDTO.setAwards(source.getAward()); |
| | | consultantDetailDTO.setImg(source.getPhotoPath()); |
| | | consultantDetailDTO.setExpertise(splitStringWithChar(source.getExpertise())); |
| | | consultantDetailDTO.setExperiences(source.getExperience()); |
| | | |
| | | // todo 需確認諮詢度表現 |
| | | consultantDetailDTO.setEvaluation(50); |
| | | List<Appointment> appointments = appointmentService.findByAgentNo(source.getAgentNo()); |
| | | long allAppointmentCount = appointments.size(); |
| | | long nearlyMonthAppointmentCount = appointments |
| | | .stream() |
| | | .filter(appointment -> { |
| | | Instant oneMonthAgo = ZonedDateTime.now().minusMonths(1).toInstant(); |
| | | return appointment.getAppointmentDate().isAfter(oneMonthAgo); |
| | | }).count(); |
| | | |
| | | consultantDetailDTO.setAllAppointmentCount(allAppointmentCount); |
| | | consultantDetailDTO.setNearlyMonthAppointmentCount(nearlyMonthAppointmentCount); |
| | | |
| | | return consultantDetailDTO; |
| | | } |