From 0e73f60f5e9acede5438b0c38332183916f9d552 Mon Sep 17 00:00:00 2001 From: Jack <jack.su@pollex.com.tw> Date: 星期五, 03 十二月 2021 16:54:57 +0800 Subject: [PATCH] Merge branch 'master' of ssh://192.168.0.10:29418/pcalife/PAM --- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 36 ++++++++++-------------------------- 1 files changed, 10 insertions(+), 26 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java index 7a9c552..adbb6ab 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -3,7 +3,6 @@ import com.pollex.pam.domain.AppointmentCustomerView; import com.pollex.pam.domain.Consultant; import com.pollex.pam.domain.CustomerFavoriteConsultant; -import com.pollex.pam.domain.Satisfaction; import com.pollex.pam.enums.ContactStatusEnum; import com.pollex.pam.enums.LoginResult; import com.pollex.pam.repository.ConsultantRepository; @@ -21,7 +20,6 @@ import java.util.Comparator; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; @Service @@ -60,10 +58,7 @@ CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant); dto.setContactStatus(ContactStatusEnum.PICKED); - dto.setLatestAppointmentId(null); - dto.setLatestAppointmentDate(null); - dto.setLatestAppointmentScore(null); - dto.setCreateTime(customerFavoriteConsultantRelation.getLastModifiedDate()); + dto.setCreateTime(customerFavoriteConsultantRelation.getCreatedDate()); setAppointmentInfo( dto, @@ -75,32 +70,21 @@ }).collect(Collectors.toList()); } - private void setAppointmentInfo(CustomerFavoriteConsultantDTO dto, List<AppointmentCustomerView> appointmentList) { + private void setAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { List<AppointmentCustomerView> appointments = appointmentList.stream() .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) .collect(Collectors.toList()); - dto.setAppointments(appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments)); + List<AppointmentCustomerViewDTO> appointmentCustomerViewDTOS = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments); + appointmentCustomerViewDTOS.forEach(appointmentCustomerViewDTO -> { + appointmentService.setSatisfactionScore(appointmentCustomerViewDTO, appointmentCustomerViewDTO.getId()); + }); + customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); if (!appointments.isEmpty()) { AppointmentCustomerView latestAppointment = appointments.get(0); - dto.setContactStatus(latestAppointment.getCommunicateStatus()); - dto.setLatestAppointmentId(latestAppointment.getId()); - dto.setLatestAppointmentDate(latestAppointment.getAppointmentDate()); - dto.setUpdateTime(latestAppointment.getLastModifiedDate()); - - setLatestAppointmentScore(dto, latestAppointment); - } - } - - private void setLatestAppointmentScore(CustomerFavoriteConsultantDTO dto, AppointmentCustomerView latestAppointment) { - Optional<Satisfaction> satisfactionOptional = satisfactionService.getByAppointmentId(latestAppointment.getId()); - if(satisfactionOptional.isPresent()) { - Satisfaction satisfaction = satisfactionOptional.get(); - dto.setLatestAppointmentScore(satisfaction.getScore()); - } - else { - dto.setLatestAppointmentScore(null); + customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); + customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate()); } } @@ -160,7 +144,7 @@ public List<AppointmentCustomerViewDTO> getMyAppointment() { String agentNo = SecurityUtils.getAgentNo(); - return appointmentService.getConsultantAppointments(agentNo); + return appointmentService.getConsultantAvailableAppointments(agentNo); } public void removeConsultantFromCustomList(String agentNo) { -- Gitblit v1.8.0