保誠-保戶業務員媒合平台
wayne
2021-12-03 210abe8695707b725f093eea2f95cfc49980c59f
[update] 預約單dto加上預約單對應的滿意度分數

預約單至少會對到1至0個滿意度評分
刪除1個檔案
修改6個檔案
新增1個檔案
340 ■■■■ 已變更過的檔案
pamapi/src/doc/預約單/顧問取得所有自己的預約單API 85 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/預約單/顧問取得所有自己的預約單API.txt 134 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/顧問API/客戶的顧問清單.txt 19 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java 30 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java 36 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java 8 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java 27 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java 1 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/¹w¬ù³æ/ÅU°Ý¨ú±o©Ò¦³¦Û¤vªº¹w¬ù³æAPI
Àɮפw§R°£
pamapi/src/doc/¹w¬ù³æ/ÅU°Ý¨ú±o©Ò¦³¦Û¤vªº¹w¬ù³æAPI.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,134 @@
http get :
http://localhost:8080/api/consultant/getMyAppointment
[
    {
        "id": 110,
        "phone": "09123456789",
        "email": "",
        "contactType": "mobile",
        "gender": "male",
        "age": "30",
        "job": "內勤",
        "requirement": "子女教育,資產規劃,防疫保單相關",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜三,禮拜五、12:00~14:00,14:00~18:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T09:58:58.932Z",
        "lastModifiedDate": "2021-12-02T09:58:58.932Z",
        "agentNo": "AG0109051204",
        "customerId": 70,
        "name": null,
        "consultantViewTime": "2021-12-02T09:58:12.066Z",
        "consultantReadTime": "2021-12-02T09:58:58.930Z",
        "contactTime": "2021-12-02T09:58:58.930Z",
    },
    {
        "id": 109,
        "phone": "09123456789",
        "email": "",
        "contactType": "mobile",
        "gender": "male",
        "age": "20",
        "job": "內勤",
        "requirement": "健康與保障,子女教育,保單健檢/規劃,防疫保單相關",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜一,禮拜二,禮拜三,禮拜四,禮拜五,禮拜六,禮拜日、12:00~14:00,14:00~18:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T10:12:24.613Z",
        "lastModifiedDate": "2021-12-02T10:12:24.613Z",
        "agentNo": "AG0109051204",
        "customerId": 67,
        "name": null,
        "consultantViewTime": "2021-12-02T09:58:12.066Z",
        "consultantReadTime": "2021-12-02T10:12:24.612Z",
        "contactTime": null
    },
    {
        "id": 114,
        "phone": "09123456789",
        "email": "",
        "contactType": "mobile",
        "gender": "male",
        "age": "70",
        "job": "內勤",
        "requirement": "健康與保障,子女教育,資產規劃,樂活退休,防疫保單相關",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜一,禮拜二,禮拜三,禮拜四,禮拜五,禮拜六,禮拜日、12:00~14:00,14:00~18:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T09:58:12.248Z",
        "lastModifiedDate": "2021-12-02T09:58:12.248Z",
        "agentNo": "AG0109051204",
        "customerId": 71,
        "name": null,
        "consultantViewTime": "2021-12-02T09:58:12.066Z",
        "consultantReadTime": null,
        "contactTime": null
    },
    {
        "id": 121,
        "phone": "09123456789",
        "email": "",
        "contactType": "mobile",
        "gender": "male",
        "age": "20",
        "job": "內勤",
        "requirement": "子女教育",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜一,禮拜二,禮拜三,禮拜四,禮拜五,禮拜六,禮拜日、9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T09:58:12.248Z",
        "lastModifiedDate": "2021-12-02T09:58:12.248Z",
        "agentNo": "AG0109051204",
        "customerId": 76,
        "name": "李哲維",
        "consultantViewTime": "2021-12-02T09:58:12.066Z",
        "consultantReadTime": "2021-12-02T09:54:20.872Z",
        "contactTime": null
    },
    {
        "id": 118,
        "phone": "09123456789",
        "email": "",
        "contactType": "mobile",
        "gender": "male",
        "age": "20",
        "job": "內勤",
        "requirement": "健康與保障",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜一,禮拜二,禮拜三,禮拜四,禮拜五,禮拜六,禮拜日、12:00~14:00,14:00~18:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T10:02:52.797Z",
        "lastModifiedDate": "2021-12-02T10:02:52.797Z",
        "agentNo": "AG0109051204",
        "customerId": 72,
        "name": null,
        "consultantViewTime": "2021-12-02T09:58:12.066Z",
        "consultantReadTime": "2021-12-02T10:02:52.796Z",
        "contactTime": null
    },
    {
        "id": 180,
        "phone": "0911111111",
        "email": "",
        "contactType": "phone",
        "gender": "female",
        "age": "31-40",
        "job": "內勤",
        "requirement": "子女教育,健康與保障",
        "communicateStatus": "contacted",
        "hopeContactTime": "'禮拜二,禮拜三,禮拜四,禮拜五,禮拜六、9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00','禮拜一,禮拜二,禮拜三,禮拜四,禮拜五,禮拜日、12:00~14:00,14:00~18:00,18:00~21:00','禮拜一,禮拜四,禮拜六,禮拜日、14:00~18:00,18:00~21:00'",
        "otherRequirement": null,
        "appointmentDate": "2021-12-02T10:10:53.341Z",
        "lastModifiedDate": "2021-12-03T03:40:16.344Z",
        "agentNo": "AG0109051204",
        "customerId": 77,
        "name": "111",
        "consultantViewTime": "2021-12-02T10:10:46.358Z",
        "consultantReadTime": "2021-12-02T10:10:53.340Z",
        "contactTime": "2021-12-03T03:40:16.215Z"
    }
]
pamapi/src/doc/ÅU°ÝAPI/«È¤áªºÅU°Ý²M³æ.txt
@@ -20,9 +20,6 @@
        "updateTime": "2021-12-02T10:56:32.741Z",   // æœ€è¿‘更新時間
        "role": "威盛保險經紀人",
        "seniority": "22 å¹´ 8 æœˆ",
        "latestAppointmentId": 130,                 // æœ€å¾Œä¸€ç­†é ç´„å–®ID
        "latestAppointmentDate": "2021-12-02T10:56:32.741Z",    // æœ€å¾Œä¸€ç­†é ç´„單預約時間
        "latestAppointmentScore": null,                 // æœ€å¾Œä¸€ç­†é ç´„單的分數 (null為尚未評分)
        "appointments": [       // å®¢æˆ¶å·²é ç´„的顧問清單
            {
                "id": 130,
@@ -42,7 +39,8 @@
                "customerId": 76,
                "name": "李哲維",
                "consultantViewTime": null,
                "consultantReadTime": null
                "consultantReadTime": null,
                "satisfactionScore":30 // null ä»£è¡¨è©²ç­†é ç´„單尚未填寫滿意度
            }
        ],
        "new": true
@@ -65,9 +63,6 @@
        "updateTime": "2021-12-02T10:56:56.946Z",
        "role": "錠嵂保險經紀人",
        "seniority": "30 å¹´ 8 æœˆ",
        "latestAppointmentId": 131,
        "latestAppointmentDate": "2021-12-02T10:56:56.946Z",
        "latestAppointmentScore": null,
        "appointments": [
            {
                "id": 131,
@@ -87,7 +82,8 @@
                "customerId": 76,
                "name": "李哲維",
                "consultantViewTime": null,
                "consultantReadTime": null
                "consultantReadTime": null,
                "satisfactionScore":30 // null ä»£è¡¨è©²ç­†é ç´„單尚未填寫滿意度
            }
        ],
        "new": true
@@ -110,9 +106,6 @@
        "updateTime": null,
        "role": "台名保險經紀人",
        "seniority": "38 å¹´ ",
        "latestAppointmentId": null,
        "latestAppointmentDate": null,
        "latestAppointmentScore": null,
        "appointments": [],
        "new": true
    },
@@ -133,10 +126,6 @@
        "createTime": "2021-12-02T10:56:04.620Z",
        "updateTime": null,
        "role": "和泰保險經紀人",
        "seniority": "17 å¹´ 1 æœˆ",
        "latestAppointmentId": null,
        "latestAppointmentDate": null,
        "latestAppointmentScore": null,                 // æœ€å¾Œä¸€ç­†é ç´„單的分數 (null為尚未評分)
        "appointments": [],
        "new": true
    }
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -5,6 +5,7 @@
import java.util.Objects;
import java.util.stream.Collectors;
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.service.dto.AppointmentUpdateDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,8 +97,28 @@
    public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) {
        AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId)
                .orElseThrow(AppointmentNotFoundException::new);
        return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
        AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
        setSatisfactionScore(dto, appointmentId);
        return dto;
    }
    public List<AppointmentCustomerViewDTO> getConsultantAvailableAppointments(String agentNo) {
        return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream()
            .filter(appointment -> appointment.getStatus() == AVAILABLE)
            .map(appointmentCustomerView -> {
                AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentCustomerView);
                setSatisfactionScore(dto, appointmentCustomerView.getId());
                return dto;
            })
            .collect(Collectors.toList());
    }
    public void setSatisfactionScore(AppointmentCustomerViewDTO dto, Long appointmentId) {
        satisfactionService.getByAppointmentId(appointmentId).ifPresent(satisfaction -> {
            dto.setSatisfactionScore(satisfaction.getScore());
        });
    }
    public List<AppointmentCustomerView> findAvailableByAgentNoAndCustomerId(String agentNo, Long customerId) {
        return appointmentCustomerViewRepository.findByAgentNoAndCustomerId(agentNo, customerId)
@@ -126,12 +147,5 @@
        consultantNotViewAppointments.forEach(appointment -> appointment.setConsultantViewTime(Instant.now()));
        appointmentRepository.saveAll(consultantNotViewAppointments);
    }
    public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) {
        return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream()
            .filter(appointment -> appointment.getStatus() != DELETED)
            .map(appointmentCustomerViewMapper::toAppointmentCustomerViewDTO)
            .collect(Collectors.toList());
    }
}
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) {
pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
@@ -25,6 +25,8 @@
    private Instant consultantViewTime;
    private Instant consultantReadTime;
    private Instant contactTime;
    private Float satisfactionScore;
    public Long getId() {
        return id;
    }
@@ -139,4 +141,10 @@
    public void setContactTime(Instant contactTime) {
        this.contactTime = contactTime;
    }
    public Float getSatisfactionScore() {
        return satisfactionScore;
    }
    public void setSatisfactionScore(Float satisfactionScore) {
        this.satisfactionScore = satisfactionScore;
    }
}
pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java
@@ -21,9 +21,6 @@
    private Instant updateTime;
    private String role;
    private String seniority;
    private Long latestAppointmentId;
    private Instant latestAppointmentDate;
    private Float latestAppointmentScore;
    private List<AppointmentCustomerViewDTO> appointments;
    public boolean isNewConsultant() {
@@ -66,14 +63,6 @@
        this.expertise = expertise;
    }
    public Float getLatestAppointmentScore() {
        return latestAppointmentScore;
    }
    public void setLatestAppointmentScore(Float latestAppointmentScore) {
        this.latestAppointmentScore = latestAppointmentScore;
    }
    public Float getAvgScore() {
        return avgScore;
    }
@@ -88,14 +77,6 @@
    public void setContactStatus(ContactStatusEnum contactStatus) {
        this.contactStatus = contactStatus;
    }
    public Instant getLatestAppointmentDate() {
        return latestAppointmentDate;
    }
    public void setLatestAppointmentDate(Instant latestAppointmentDate) {
        this.latestAppointmentDate = latestAppointmentDate;
    }
    public Instant getCreateTime() {
@@ -132,14 +113,6 @@
    public void setNewConsultant(boolean newConsultant) {
        this.newConsultant = newConsultant;
    }
    public Long getLatestAppointmentId() {
        return latestAppointmentId;
    }
    public void setLatestAppointmentId(Long latestAppointmentId) {
        this.latestAppointmentId = latestAppointmentId;
    }
    public List<AppointmentCustomerViewDTO> getAppointments() {
pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
@@ -1,6 +1,5 @@
package com.pollex.pam.web.rest;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.ConsultantService;
import com.pollex.pam.service.dto.*;
import org.apache.commons.compress.utils.IOUtils;