保誠-保戶業務員媒合平台
Jack
2022-01-13 03e918bf6861d9b62b2ad0c5d043086969e0d9f6
[ADD] 預約單結案API
修改3個檔案
新增12個檔案
525 ■■■■■ 已變更過的檔案
pamapi/src/doc/sql/20220112_j.sql 24 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/預約單/結案API.txt 30 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java 25 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcessInterface.java 11 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java 35 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java 34 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/domain/Appointment.java 38 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/domain/AppointmentClosedInfo.java 112 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/repository/AppointmentClosedInfoRepository.java 11 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentClosedInfoService.java 10 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/AbstractAppointmentProcessDTO.java 28 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCloseDTO.java 68 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/ClosedProcessDTO.java 29 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/DoneProcessDTO.java 39 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java 31 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/sql/20220112_j.sql
@@ -40,3 +40,27 @@
    CONSTRAINT interview_record_pkey PRIMARY KEY (id)
);
-- æ–°å¢žé ç´„單結案資料table
-- Drop table
-- DROP TABLE public.appointment_closed_info;
-- Drop table
-- DROP TABLE public.appointment_closed_info;
CREATE TABLE public.appointment_closed_info (
    id bigserial NOT NULL,
    policyholder_identity_id varchar NULL,
    plan_code varchar NULL,
    policy_entry_date date NULL,
    remark varchar NULL,
    closed_reason varchar NULL,
    closed_other_reason varchar NULL,
    appointment_id bigserial NOT NULL,
    CONSTRAINT appointment_closed_info_pkey PRIMARY KEY (id)
);
pamapi/src/doc/¹w¬ù³æ/µ²®×API.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,30 @@
http post :
http://localhost:8080/api/appointment/close
request body :
成交
contactStatus: done
{
    "policyholderIdentityId":"A123456789",
    "planCode":"ATM",
    "policyEntryDate":"2022-01-12",
    "contactStatus":"done",
    "appointmentId": 385
}
未成交
contactStatus: closed
{
    "contactStatus":"closed",
    "closedReason":"other",
    "closedOtherReason":"心情不好不想買",
    "appointmentId": 385,
    "remark":"test remark"
}
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,25 @@
package com.pollex.pam.appointment.process;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO;
@Service
public class AppointmentProcess{
    @Autowired
    List<AppointmentProcessInterface> processList;
    public void process(AbstractAppointmentProcessDTO dto) {
        AbstractAppointmentProcessDTO appointmentProcessDTO = (AbstractAppointmentProcessDTO)dto;
        processList.stream().forEach(process ->{
            if(process.getProcessType() == appointmentProcessDTO.getContactStatus()) {
                process.doProcess(appointmentProcessDTO);
            }
        });
    }
}
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcessInterface.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,11 @@
package com.pollex.pam.appointment.process;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO;
public interface AppointmentProcessInterface {
    void doProcess(AbstractAppointmentProcessDTO dto);
    ContactStatusEnum getProcessType();
}
pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,35 @@
package com.pollex.pam.appointment.process;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pollex.pam.domain.AppointmentClosedInfo;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.repository.AppointmentClosedInfoRepository;
import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO;
import com.pollex.pam.service.dto.ClosedProcessDTO;
import com.pollex.pam.service.dto.DoneProcessDTO;
@Service
public class ClosedProcess implements AppointmentProcessInterface{
    @Autowired
    AppointmentClosedInfoRepository appointmentClosedInfoRepository;
    @Override
    public void doProcess(AbstractAppointmentProcessDTO processDTO) {
        ClosedProcessDTO doneProcess = (ClosedProcessDTO)processDTO;
        BeanUtils.copyProperties(processDTO, doneProcess);
        AppointmentClosedInfo closedInfo = new AppointmentClosedInfo();
        BeanUtils.copyProperties(doneProcess, closedInfo);
        appointmentClosedInfoRepository.save(closedInfo);
    }
    @Override
    public ContactStatusEnum getProcessType() {
        return ContactStatusEnum.CLOSED;
    }
}
pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,34 @@
package com.pollex.pam.appointment.process;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pollex.pam.domain.AppointmentClosedInfo;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.repository.AppointmentClosedInfoRepository;
import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO;
import com.pollex.pam.service.dto.DoneProcessDTO;
@Service
public class DoneProcess implements AppointmentProcessInterface{
    @Autowired
    AppointmentClosedInfoRepository appointmentClosedInfoRepository;
    @Override
    public void doProcess(AbstractAppointmentProcessDTO processDTO) {
        DoneProcessDTO doneProcess = (DoneProcessDTO)processDTO;
        BeanUtils.copyProperties(processDTO, doneProcess);
        AppointmentClosedInfo closedInfo = new AppointmentClosedInfo();
        BeanUtils.copyProperties(doneProcess, closedInfo);
        appointmentClosedInfoRepository.save(closedInfo);
    }
    @Override
    public ContactStatusEnum getProcessType() {
        return ContactStatusEnum.DONE;
    }
}
pamapi/src/main/java/com/pollex/pam/domain/Appointment.java
@@ -4,13 +4,26 @@
import java.time.Instant;
import java.util.List;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.pollex.pam.enums.AppointmentStatusEnum;
import com.pollex.pam.enums.ContactStatusEnum;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@EntityListeners(AuditingEntityListener.class)
@Entity
@@ -86,6 +99,15 @@
    @JoinColumn(name = "appointment_id")
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
    private List<AppointmentMemo> appointmentMemoList;
//    @OneToOne(cascade = CascadeType.REMOVE,fetch=FetchType.EAGER)
////    @JoinColumn(name = "form_authority_id", referencedColumnName = "id")
//    @JoinColumn(name = "appointment_id", referencedColumnName = "id")
//    private AppointmentClosedInfo closedInfo;
//    @OneToOne(cascade = CascadeType.REMOVE
//            , mappedBy = "appointment", fetch=FetchType.LAZY)
//    private AppointmentClosedInfo closedInfo;
    public Long getId() {
        return id;
@@ -246,6 +268,14 @@
    public void setAppointmentMemoList(List<AppointmentMemo> appointmentMemoList) {
        this.appointmentMemoList = appointmentMemoList;
    }
//    public AppointmentClosedInfo getClosedInfo() {
//        return closedInfo;
//    }
//
//    public void setClosedInfo(AppointmentClosedInfo closedInfo) {
//        this.closedInfo = closedInfo;
//    }
    
    
    
pamapi/src/main/java/com/pollex/pam/domain/AppointmentClosedInfo.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,112 @@
package com.pollex.pam.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "appointment_closed_info")
public class AppointmentClosedInfo implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column(name = "policyholder_identity_id")
    private String policyholderIdentityId;
    @Column(name = "plan_code")
    private String planCode;
    @Column(name = "policy_entry_date")
    private Date policyEntryDate;
    @Column(name = "remark")
    private String remark;
    @Column(name = "closed_reason")
    private String closedReason;
    @Column(name = "closed_other_reason")
    private String closedOtherReason;
    @Column(name = "appointment_id")
    private Long appointmentId;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getPolicyholderIdentityId() {
        return policyholderIdentityId;
    }
    public void setPolicyholderIdentityId(String policyholderIdentityId) {
        this.policyholderIdentityId = policyholderIdentityId;
    }
    public String getPlanCode() {
        return planCode;
    }
    public void setPlanCode(String planCode) {
        this.planCode = planCode;
    }
    public Date getPolicyEntryDate() {
        return policyEntryDate;
    }
    public void setPolicyEntryDate(Date policyEntryDate) {
        this.policyEntryDate = policyEntryDate;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getClosedReason() {
        return closedReason;
    }
    public void setClosedReason(String closedReason) {
        this.closedReason = closedReason;
    }
    public String getClosedOtherReason() {
        return closedOtherReason;
    }
    public void setClosedOtherReason(String closedOtherReason) {
        this.closedOtherReason = closedOtherReason;
    }
    public Long getAppointmentId() {
        return appointmentId;
    }
    public void setAppointmentId(Long appointmentId) {
        this.appointmentId = appointmentId;
    }
}
pamapi/src/main/java/com/pollex/pam/repository/AppointmentClosedInfoRepository.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,11 @@
package com.pollex.pam.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.pollex.pam.domain.AppointmentClosedInfo;
@Repository
public interface AppointmentClosedInfoRepository extends JpaRepository<AppointmentClosedInfo, Long>{
}
pamapi/src/main/java/com/pollex/pam/service/AppointmentClosedInfoService.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,10 @@
package com.pollex.pam.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class AppointmentClosedInfoService {
}
pamapi/src/main/java/com/pollex/pam/service/dto/AbstractAppointmentProcessDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,28 @@
package com.pollex.pam.service.dto;
import com.pollex.pam.enums.ContactStatusEnum;
public abstract class AbstractAppointmentProcessDTO{
    private ContactStatusEnum contactStatus;
    private Long appointmentId;
    public ContactStatusEnum getContactStatus() {
        return contactStatus;
    }
    public void setContactStatus(ContactStatusEnum contactStatus) {
        this.contactStatus = contactStatus;
    }
    public Long getAppointmentId() {
        return appointmentId;
    }
    public void setAppointmentId(Long appointmentId) {
        this.appointmentId = appointmentId;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCloseDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,68 @@
package com.pollex.pam.service.dto;
import java.util.Date;
import com.pollex.pam.enums.ContactStatusEnum;
public class AppointmentCloseDTO{
    private String policyholderIdentityId;
    private String planCode;
    private Date policyEntryDate;
    private String remark;
    private String closedReason;
    private String closedOtherReason;
    private ContactStatusEnum contactStatus;
    private Long appointmentId;
    public String getPolicyholderIdentityId() {
        return policyholderIdentityId;
    }
    public void setPolicyholderIdentityId(String policyholderIdentityId) {
        this.policyholderIdentityId = policyholderIdentityId;
    }
    public String getPlanCode() {
        return planCode;
    }
    public void setPlanCode(String planCode) {
        this.planCode = planCode;
    }
    public Date getPolicyEntryDate() {
        return policyEntryDate;
    }
    public void setPolicyEntryDate(Date policyEntryDate) {
        this.policyEntryDate = policyEntryDate;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getClosedReason() {
        return closedReason;
    }
    public void setClosedReason(String closedReason) {
        this.closedReason = closedReason;
    }
    public String getClosedOtherReason() {
        return closedOtherReason;
    }
    public void setClosedOtherReason(String closedOtherReason) {
        this.closedOtherReason = closedOtherReason;
    }
    public ContactStatusEnum getContactStatus() {
        return contactStatus;
    }
    public void setContactStatus(ContactStatusEnum contactStatus) {
        this.contactStatus = contactStatus;
    }
    public Long getAppointmentId() {
        return appointmentId;
    }
    public void setAppointmentId(Long appointmentId) {
        this.appointmentId = appointmentId;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/ClosedProcessDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,29 @@
package com.pollex.pam.service.dto;
public class ClosedProcessDTO extends AbstractAppointmentProcessDTO{
    private String remark;
    private String closedReason;
    private String closedOtherReason;
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getClosedReason() {
        return closedReason;
    }
    public void setClosedReason(String closedReason) {
        this.closedReason = closedReason;
    }
    public String getClosedOtherReason() {
        return closedOtherReason;
    }
    public void setClosedOtherReason(String closedOtherReason) {
        this.closedOtherReason = closedOtherReason;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/DoneProcessDTO.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,39 @@
package com.pollex.pam.service.dto;
import java.util.Date;
public class DoneProcessDTO extends AbstractAppointmentProcessDTO{
    private String policyholderIdentityId;
    private String planCode;
    private Date policyEntryDate;
    private String remark;
    public String getPolicyholderIdentityId() {
        return policyholderIdentityId;
    }
    public void setPolicyholderIdentityId(String policyholderIdentityId) {
        this.policyholderIdentityId = policyholderIdentityId;
    }
    public String getPlanCode() {
        return planCode;
    }
    public void setPlanCode(String planCode) {
        this.planCode = planCode;
    }
    public Date getPolicyEntryDate() {
        return policyEntryDate;
    }
    public void setPolicyEntryDate(Date policyEntryDate) {
        this.policyEntryDate = policyEntryDate;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -1,14 +1,22 @@
package com.pollex.pam.web.rest;
import com.pollex.pam.appointment.process.AppointmentProcess;
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.service.SendMsgService;
import com.pollex.pam.service.dto.AppointmentUpdateDTO;
import com.pollex.pam.service.dto.ClosedProcessDTO;
import com.pollex.pam.service.dto.DoneProcessDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.SatisfactionService;
import com.pollex.pam.service.dto.AppointmentCloseDTO;
import com.pollex.pam.service.dto.AppointmentCreateDTO;
import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
@@ -24,6 +32,9 @@
    @Autowired
    SendMsgService sendMsgService;
    @Autowired
    AppointmentProcess abstractAppointmentProcess;
    @PutMapping("")
    public ResponseEntity<Void> updateAppointment(@RequestBody AppointmentUpdateDTO appointment) {
@@ -59,4 +70,24 @@
        appointmentService.recordConsultantReadTime(appointmentId);
        return ResponseEntity.noContent().build();
    }
    @PostMapping("/close")
    public ResponseEntity<Void> closeAppointment(@RequestBody AppointmentCloseDTO closeDTO) {
        if(closeDTO.getContactStatus() == ContactStatusEnum.DONE) {
            DoneProcessDTO dto = new DoneProcessDTO();
            BeanUtils.copyProperties(closeDTO, dto);
            abstractAppointmentProcess.process(dto);
        }else if(closeDTO.getContactStatus() == ContactStatusEnum.CLOSED){
            ClosedProcessDTO dto = new ClosedProcessDTO();
            BeanUtils.copyProperties(closeDTO, dto);
            abstractAppointmentProcess.process(dto);
        }
//        Appointment ap = appointmentService.findById(closeDTO.getAppointmentId());
//        System.out.println("getClosedInfo().getClosedOtherReason()::"+ap.getClosedInfo().getClosedOtherReason());
        return ResponseEntity.noContent().build();
    }
}