| | |
| | | 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 = ','; |
| | | |
| | |
| | | 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; |
| | | } |