From 633a43b1bc57187983d8bbe85f2e835026cc37b6 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期五, 21 一月 2022 17:05:24 +0800 Subject: [PATCH] Merge branch 'Phase3' of https://192.168.0.10:8443/r/pcalife/PAM into Phase3 --- pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java | 123 ++++++++++++++++++++ pamapi/src/doc/小鈴鐺通知API/取得登入者所有小鈴鐺通知API | 38 ++++++ pamapi/src/doc/sql/20220121_j.sql | 3 pamapi/src/main/java/com/pollex/pam/enums/NotificationTypeEnum.java | 6 + pamapi/src/main/java/com/pollex/pam/enums/PersonalNotificationRoleEnum.java | 6 + pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java | 24 ++++ pamapi/src/doc/sql/20220120_j.sql | 13 ++ pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java | 58 +++++++++ pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java | 1 pamapi/src/main/java/com/pollex/pam/repository/PersonalNotificationRepository.java | 16 ++ PAMapp/components/Client/ClientCard.vue | 4 pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 42 +++--- pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java | 1 PAMapp/pages/appointment/_appointmentId/index.vue | 23 +++ 14 files changed, 333 insertions(+), 25 deletions(-) diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue index 2200975..294eb5f 100644 --- a/PAMapp/components/Client/ClientCard.vue +++ b/PAMapp/components/Client/ClientCard.vue @@ -268,7 +268,9 @@ } navigateToCloseAppointment(): void { - this.$router.push(`/appointment/${this.client.id}/close`); + this.getAppointmentDetail(this.client.id).then((_) => { + this.$router.push(`/appointment/${this.client.id}/close`); + }); } inviteReview(): void { diff --git a/PAMapp/pages/appointment/_appointmentId/index.vue b/PAMapp/pages/appointment/_appointmentId/index.vue index fcc05b8..7f3c211 100644 --- a/PAMapp/pages/appointment/_appointmentId/index.vue +++ b/PAMapp/pages/appointment/_appointmentId/index.vue @@ -2,7 +2,9 @@ <div class="appointment-client-detail-page"> <div class="date-detail"> <div>{{ appointmentDetail.appointmentDate | formatDate }}����</div> - <div>{{ appointmentDetail.consultantReadTime | formatDate }}撌脰�</div> + <div>{{ appointmentDetail.consultantReadTime | formatDate }} + <span v-if="appointmentDetail.consultantReadTime">撌脰�</span> + </div> </div> <AppointmentProgress @@ -54,9 +56,13 @@ <el-button @click="inviteReview">��遛��漲</el-button> </div> - <div class="client-detail-action" v-else> + <div class="client-detail-action" v-if="showWhenAppointmentHasContacted"> <el-button @click="closeAppointment" >蝯��</el-button> <el-button @click="sendMsg" style="margin-left: 0px">�/蝝赤</el-button> + </div> + + <div class="client-detail-action" v-if="showWhenAppointmentHasCreate"> + <el-button @click="sendMsg">���赤�</el-button> </div> </section> @@ -71,11 +77,11 @@ </InterviewMsg> - <section class="mt-30"> + <section class="mt-30" v-if="!showWhenAppointmentHasCreate"> <AppointmentInterviewList :interviewList="appointmentDetail.interviewRecordDTOs" /> </section> - <section class="mt-30"> + <section class="mt-30" v-if="!showWhenAppointmentHasCreate"> <AppointmentRecordList :noticeLogs="appointmentDetail.appointmentNoticeLogs" /> </section> @@ -128,6 +134,15 @@ || this.appointmentDetail.communicateStatus === this.contactStatus.CANCEL; } + get showWhenAppointmentHasCreate(): boolean { + return this.appointmentDetail.communicateStatus === this.contactStatus.PICKED + || this.appointmentDetail.communicateStatus === this.contactStatus.RESERVED; + } + + get showWhenAppointmentHasContacted() :boolean { + return this.appointmentDetail.communicateStatus === this.contactStatus.CONTACTED; + } + get hopeContactTimeList(): any[] { return this.appointmentDetail.hopeContactTime.split("','") } diff --git a/pamapi/src/doc/sql/20220120_j.sql b/pamapi/src/doc/sql/20220120_j.sql new file mode 100644 index 0000000..72f8d15 --- /dev/null +++ b/pamapi/src/doc/sql/20220120_j.sql @@ -0,0 +1,13 @@ +-- 撱箇������able + +CREATE TABLE public.personal_notification ( + id bigserial NOT NULL, + title varchar NULL, + "content" varchar NOT NULL, + notification_type varchar NOT NULL, + owner_role varchar NOT NULL, + owner_id bigserial NOT NULL, + created_date timestamp NOT NULL, + read_date timestamp NULL, + CONSTRAINT personal_notification_pkey PRIMARY KEY (id) +); diff --git a/pamapi/src/doc/sql/20220121_j.sql b/pamapi/src/doc/sql/20220121_j.sql new file mode 100644 index 0000000..294abe9 --- /dev/null +++ b/pamapi/src/doc/sql/20220121_j.sql @@ -0,0 +1,3 @@ +-- 隤踵policy_entry_date ���� +ALTER TABLE appointment_closed_info +ALTER COLUMN policy_entry_date TYPE timestamp; \ No newline at end of file diff --git "a/pamapi/src/doc/\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API/\345\217\226\345\276\227\347\231\273\345\205\245\350\200\205\346\211\200\346\234\211\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API" "b/pamapi/src/doc/\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API/\345\217\226\345\276\227\347\231\273\345\205\245\350\200\205\346\211\200\346\234\211\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API" new file mode 100644 index 0000000..cca0197 --- /dev/null +++ "b/pamapi/src/doc/\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API/\345\217\226\345\276\227\347\231\273\345\205\245\350\200\205\346\211\200\346\234\211\345\260\217\351\210\264\351\220\272\351\200\232\347\237\245API" @@ -0,0 +1,38 @@ +http get: + +http://localhost:8080/api/personal_notification/getMyPersonalNotification + +title: 璅�� +content: ��摰� +notificationType: ACTIVITY(�犖瘣餃��)�YSTEM(蝟餌絞�) +ownerRole: CUSTOMER(摰X)�ONSULTANT(憿批��) +ownerId: ���d +readDate: 撌脰����� + +request body : + +[ + { + "id": 1, + "title": "title test", + "content": "content test", + "notificationType": "ACTIVITY", + "ownerRole": "CONSULTANT", + "ownerId": 11, + "createdDate": "2022-01-20T10:53:53.022Z", + "readDate": null + }, + { + "id": 2, + "title": "title test", + "content": "content test", + "notificationType": "ACTIVITY", + "ownerRole": "CONSULTANT", + "ownerId": 11, + "createdDate": "2022-01-20T10:59:17.242Z", + "readDate": null + } +] + + + diff --git a/pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java b/pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java new file mode 100644 index 0000000..8e4a57c --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/domain/PersonalNotification.java @@ -0,0 +1,123 @@ +package com.pollex.pam.domain; + +import java.io.Serializable; +import java.time.Instant; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.springframework.data.annotation.CreatedDate; + +import com.pollex.pam.enums.NotificationTypeEnum; +import com.pollex.pam.enums.PersonalNotificationRoleEnum; + +@Entity +@Table(name = "personal_notification") +public class PersonalNotification implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "title") + private String title; + + @Column(name = "content") + private String content; + + @Enumerated(EnumType.STRING) + @Column(name = "notification_type") + private NotificationTypeEnum notificationType; + + @Enumerated(EnumType.STRING) + @Column(name = "owner_role") + private PersonalNotificationRoleEnum ownerRole; + + @Column(name = "owner_id") + private Long ownerId; + + @CreatedDate + @Column(name = "created_date", updatable = false) + private Instant createdDate = Instant.now(); + + @Column(name = "read_date", updatable = false) + private Instant readDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public NotificationTypeEnum getNotificationType() { + return notificationType; + } + + public void setNotificationType(NotificationTypeEnum notificationType) { + this.notificationType = notificationType; + } + + public PersonalNotificationRoleEnum getOwnerRole() { + return ownerRole; + } + + public void setOwnerRole(PersonalNotificationRoleEnum ownerRole) { + this.ownerRole = ownerRole; + } + + public Long getOwnerId() { + return ownerId; + } + + public void setOwnerId(Long ownerId) { + this.ownerId = ownerId; + } + + public Instant getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Instant createdDate) { + this.createdDate = createdDate; + } + + public Instant getReadDate() { + return readDate; + } + + public void setReadDate(Instant readDate) { + this.readDate = readDate; + } + + + +} diff --git a/pamapi/src/main/java/com/pollex/pam/enums/NotificationTypeEnum.java b/pamapi/src/main/java/com/pollex/pam/enums/NotificationTypeEnum.java new file mode 100644 index 0000000..a14a84d --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/enums/NotificationTypeEnum.java @@ -0,0 +1,6 @@ +package com.pollex.pam.enums; + +public enum NotificationTypeEnum { + SYSTEM, + ACTIVITY +} diff --git a/pamapi/src/main/java/com/pollex/pam/enums/PersonalNotificationRoleEnum.java b/pamapi/src/main/java/com/pollex/pam/enums/PersonalNotificationRoleEnum.java new file mode 100644 index 0000000..0f063c2 --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/enums/PersonalNotificationRoleEnum.java @@ -0,0 +1,6 @@ +package com.pollex.pam.enums; + +public enum PersonalNotificationRoleEnum { + CUSTOMER, + CONSULTANT +} diff --git a/pamapi/src/main/java/com/pollex/pam/repository/PersonalNotificationRepository.java b/pamapi/src/main/java/com/pollex/pam/repository/PersonalNotificationRepository.java new file mode 100644 index 0000000..e6e4027 --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/repository/PersonalNotificationRepository.java @@ -0,0 +1,16 @@ +package com.pollex.pam.repository; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.pollex.pam.domain.PersonalNotification; +import com.pollex.pam.enums.PersonalNotificationRoleEnum; + +@Repository +public interface PersonalNotificationRepository extends JpaRepository<PersonalNotification, Long>{ + + List<PersonalNotification> findAllByOwnerRoleAndOwnerId(PersonalNotificationRoleEnum role, Long ownerId); + +} 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 4706c99..91e1ba3 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -97,49 +97,53 @@ .map(relation -> { Consultant consultant = relation.getConsultant(); CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant); - - dto.setContactStatus(ContactStatusEnum.PICKED); dto.setCreateTime(relation.getCreatedDate()); dto.setUpdateTime(relation.getCreatedDate()); dto.setCustomerViewTime(relation.getViewTime()); - setAvailableAppointmentInfo( + setInfoByAvailableAppointment( dto, appointmentService.findAvailableByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) ); - - appointmentService.findLatestAppointmentByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) - .ifPresent(latestAppointment -> { - dto.setUpdateTime(latestAppointment.getLastModifiedDate()); - }); - - if(dto.getUpdateTime().isBefore(relation.getCreatedDate())) { - dto.setUpdateTime(relation.getCreatedDate()); - } + + setFavoriteConsultantUpdatedTime(relation, dto); return dto; }).collect(Collectors.toList()); } - private void setAvailableAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { + public void setFavoriteConsultantUpdatedTime(CustomerFavoriteConsultant relation, + CustomerFavoriteConsultantDTO dto) { + Consultant consultant = relation.getConsultant(); + appointmentService.findLatestAppointmentByAgentNoAndCustomerId(consultant.getAgentNo(), relation.getCustomerId()) + .ifPresent(latestAppointment -> { + dto.setUpdateTime(latestAppointment.getLastModifiedDate()); + }); + + if(dto.getUpdateTime().isBefore(relation.getCreatedDate())) { + dto.setUpdateTime(relation.getCreatedDate()); + } + } + + private void setInfoByAvailableAppointment(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { List<AppointmentCustomerView> appointments = appointmentList.stream() .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) .collect(Collectors.toList()); List<AppointmentCustomerViewDTO> appointmentCustomerViewDTOS = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments); - appointmentCustomerViewDTOS.forEach(appointmentCustomerViewDTO -> { - appointmentService.setSatisfactionScore(appointmentCustomerViewDTO, appointmentCustomerViewDTO.getId()); - }); customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); if (!appointments.isEmpty()) { AppointmentCustomerView latestAvailableAppointment = appointments.get(0); - - if(latestAvailableAppointment.getCommunicateStatus() == RESERVED) - customerFavoriteConsultantDTO.setContactStatus(RESERVED); + ContactStatusEnum latestStatus = latestAvailableAppointment.getCommunicateStatus(); + if( latestStatus != ContactStatusEnum.DONE + || latestStatus != ContactStatusEnum.CLOSED) + customerFavoriteConsultantDTO.setContactStatus(latestStatus); else customerFavoriteConsultantDTO.setContactStatus(PICKED); + }else { + customerFavoriteConsultantDTO.setContactStatus(PICKED); } } diff --git a/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java new file mode 100644 index 0000000..5cf50ae --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java @@ -0,0 +1,24 @@ +package com.pollex.pam.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.pollex.pam.domain.PersonalNotification; +import com.pollex.pam.enums.PersonalNotificationRoleEnum; +import com.pollex.pam.repository.PersonalNotificationRepository; + +@Service +@Transactional +public class PersonalNotificationService { + + @Autowired + PersonalNotificationRepository personalNotificationRepository; + + public List<PersonalNotification> getMyPersonalNotification(Long ownerId, PersonalNotificationRoleEnum role) { + return personalNotificationRepository.findAllByOwnerRoleAndOwnerId(role, ownerId); + } + +} diff --git a/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java b/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java index 70de68f..b68986c 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java @@ -59,7 +59,6 @@ satisfaction.setStatus(SatisfactionStatusEnum.FILLED); return save(satisfaction); } - public Satisfaction createSatisfaction(Appointment appointment) { boolean isexist = getByAppointmentId(appointment.getId()).isPresent(); diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java index 1821d25..4389195 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java +++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java @@ -44,6 +44,7 @@ if(appointmentClosedInfoOP.isPresent()) { target.setAppointmentClosedInfo(appointmentClosedInfoOP.get()); } + appointmentService.setSatisfactionScore(target, source.getId()); return target; } diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java new file mode 100644 index 0000000..c00c6db --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/PersonalNotificationResource.java @@ -0,0 +1,58 @@ +package com.pollex.pam.web.rest; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.pollex.pam.domain.Consultant; +import com.pollex.pam.domain.PersonalNotification; +import com.pollex.pam.enums.NotificationTypeEnum; +import com.pollex.pam.enums.PersonalNotificationRoleEnum; +import com.pollex.pam.repository.PersonalNotificationRepository; +import com.pollex.pam.security.SecurityUtils; +import com.pollex.pam.service.ConsultantService; +import com.pollex.pam.service.PersonalNotificationService; + +@RestController +@RequestMapping("/api/personal_notification") +public class PersonalNotificationResource { + + @Autowired + PersonalNotificationService personalNotificationService; + + @Autowired + PersonalNotificationRepository personalNotificationRepository; + + @Autowired + ConsultantService consultantService; + + @GetMapping("/getMyPersonalNotification") + public ResponseEntity<List<PersonalNotification>> getMyPersonalNotification() { + List<PersonalNotification> personalNotificationList = new ArrayList<>(); + if(StringUtils.hasText(SecurityUtils.getAgentNo())) { + Consultant consultant = consultantService.findByAgentNo(SecurityUtils.getAgentNo()); + personalNotificationList = personalNotificationService.getMyPersonalNotification(consultant.getId(), PersonalNotificationRoleEnum.CONSULTANT); + }else if(SecurityUtils.getCustomerDBId()!=null){ + personalNotificationList = personalNotificationService.getMyPersonalNotification(SecurityUtils.getCustomerDBId(), PersonalNotificationRoleEnum.CUSTOMER); + } + return new ResponseEntity<>(personalNotificationList, HttpStatus.OK); + } + +// @GetMapping("/create") +// public void create() { +// PersonalNotification test = new PersonalNotification(); +// test.setContent("content test"); +// test.setNotificationType(NotificationTypeEnum.ACTIVITY); +// test.setOwnerId(Long.valueOf(11)); +// test.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); +// test.setTitle("title test"); +// personalNotificationRepository.save(test); +// } +} -- Gitblit v1.8.0