保誠-保戶業務員媒合平台
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java
@@ -1,5 +1,6 @@
package com.pollex.pam.appointment.process;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -8,6 +9,7 @@
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;
@@ -32,25 +34,23 @@
   
   public void process(AbstractAppointmentProcessDTO dto) {
      
//      AbstractAppointmentProcessDTO appointmentProcessDTO = dto;
      processList.stream().forEach(process ->{
         if(process.getProcessType() == dto.getContactStatus()) {
            process.createProcess(dto);
            Optional<AppointmentClosedInfo> closedInfoOP = appointmentClosedInfoRepository.findByAppointmentId(dto.getAppointmentId());
            if(closedInfoOP.isPresent()) {
               process.editClosedInfo(dto, closedInfoOP.get());
            }else {
               process.create(dto);
            }
         }
      });
      Appointment appointment = appointmentService.findById(dto.getAppointmentId());
      appointment.setCommunicateStatus(dto.getContactStatus());
      appointmentRepository.save(appointment);
      changeAppointmentCommunicateStatus(dto.getAppointmentId(), dto.getContactStatus());
   }
   public void editClosedInfo(AbstractAppointmentProcessDTO dto) {
      processList.stream().forEach(process ->{
         if(process.getProcessType() == dto.getContactStatus()) {
            process.editClosedInfo(dto);
         }
      });
      Appointment appointment = appointmentService.findById(dto.getAppointmentId());
      appointment.setCommunicateStatus(dto.getContactStatus());
   private void changeAppointmentCommunicateStatus(Long appointmentId, ContactStatusEnum contactStatus) {
      Appointment appointment = appointmentService.findById(appointmentId);
      appointment.setCommunicateStatus(contactStatus);
      appointmentRepository.save(appointment);
   }