From 13a5f7b7c1bd7733f62f2e76e15ce3660441df98 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期二, 01 三月 2022 15:36:00 +0800 Subject: [PATCH] [update] [todo 135940] 顧問預約未處理的網址,導到顧問登入頁面 --- pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java | 38 +++++++++++++++++++++++++++++++++++--- 1 files changed, 35 insertions(+), 3 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java b/pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java index 10f2e86..846287c 100644 --- a/pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java +++ b/pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java @@ -1,11 +1,21 @@ package com.pollex.pam.appointment.process; +import java.time.Instant; import java.util.List; +import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.pollex.pam.domain.Appointment; +import com.pollex.pam.domain.AppointmentClosedInfo; +import com.pollex.pam.enums.ContactStatusEnum; +import com.pollex.pam.repository.AppointmentClosedInfoRepository; +import com.pollex.pam.repository.AppointmentRepository; +import com.pollex.pam.service.AppointmentClosedInfoService; +import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; +import com.pollex.pam.service.dto.DoneProcessDTO; @Service public class AppointmentProcess{ @@ -13,13 +23,35 @@ @Autowired List<AppointmentProcessInterface> processList; + @Autowired + AppointmentService appointmentService; + + @Autowired + AppointmentRepository appointmentRepository; + + @Autowired + AppointmentClosedInfoRepository appointmentClosedInfoRepository; + public void process(AbstractAppointmentProcessDTO dto) { - AbstractAppointmentProcessDTO appointmentProcessDTO = (AbstractAppointmentProcessDTO)dto; + processList.stream().forEach(process ->{ - if(process.getProcessType() == appointmentProcessDTO.getContactStatus()) { - process.doProcess(appointmentProcessDTO); + if(process.getProcessType() == dto.getContactStatus()) { + Optional<AppointmentClosedInfo> closedInfoOP = appointmentClosedInfoRepository.findByAppointmentId(dto.getAppointmentId()); + if(closedInfoOP.isPresent()) { + process.editClosedInfo(dto, closedInfoOP.get()); + }else { + process.create(dto); + } } }); + + changeAppointmentCommunicateStatus(dto.getAppointmentId(), dto.getContactStatus()); + } + + private void changeAppointmentCommunicateStatus(Long appointmentId, ContactStatusEnum contactStatus) { + Appointment appointment = appointmentService.findById(appointmentId); + appointment.setCommunicateStatus(contactStatus); + appointmentRepository.save(appointment); } } -- Gitblit v1.8.0