[update][todo 135158] 列出滿意度問卷也需要包含系統滿意度問卷
小鈴鐺裡呈現多筆平台滿意度 api
| | |
| | | |
| | | [ |
| | | { |
| | | "id": 11, |
| | | "createdDate": "2021-12-03T03:59:07.854Z", |
| | | "lastModifiedDate": "2021-12-03T03:59:07.854Z", |
| | | "customerId": 90, |
| | | "agentNo": "B282677963", |
| | | "status": "FILLED", |
| | | "score": 4.0, |
| | | "appointmentId": 134, |
| | | "customerName": "Jack", |
| | | "agentName": "å¬å¦¹" |
| | | "id" : 85, |
| | | "createdDate" : "2022-01-24T11:48:58.039Z", |
| | | "lastModifiedDate" : "2022-01-24T11:48:58.039Z", |
| | | "customerId" : 165, |
| | | "agentNo" : "AGAM11249699", |
| | | "status" : "UNFILLED", |
| | | "score" : null, |
| | | "appointmentId" : 483, |
| | | "customerName" : "Mila la", |
| | | "agentName" : "è«æé lala", |
| | | "type" : "APPOINTMENT" // "APPOINTMENT"æ¯å°é¡§åé ç´ç滿æåº¦ï¼"SYSTEM"æ¯å°å¹³å°ç滿æåº¦ |
| | | }, |
| | | { |
| | | "id": 12, |
| | | "createdDate": "2021-12-03T04:00:43.181Z", |
| | | "lastModifiedDate": "2021-12-03T04:00:43.181Z", |
| | | "customerId": 90, |
| | | "agentNo": "B282677963", |
| | | "status": "FILLED", |
| | | "score": 4.0, |
| | | "appointmentId": 135, |
| | | "customerName": "Jack", |
| | | "agentName": "å¬å¦¹" |
| | | }, |
| | | { |
| | | "id": 13, |
| | | "createdDate": "2021-12-03T04:01:20.095Z", |
| | | "lastModifiedDate": "2021-12-03T04:01:20.095Z", |
| | | "customerId": 90, |
| | | "agentNo": "B282677963", |
| | | "status": "FILLED", |
| | | "score": 2.0, |
| | | "appointmentId": 136, |
| | | "customerName": "Jack", |
| | | "agentName": "å¬å¦¹" |
| | | "id" : 84, |
| | | "createdDate" : "2022-01-24T10:31:03.799Z", |
| | | "lastModifiedDate" : "2022-01-24T10:31:03.799Z", |
| | | "customerId" : 165, |
| | | "agentNo" : "AGAM11249699", |
| | | "status" : "FILLED", |
| | | "score" : 1.0, |
| | | "appointmentId" : 482, |
| | | "customerName" : "Mila la", |
| | | "agentName" : "è«æé lala", |
| | | "type" : "APPOINTMENT" |
| | | }, { |
| | | "id" : 95, |
| | | "createdDate" : "2022-02-10T07:28:39.095Z", |
| | | "lastModifiedDate" : "2022-02-10T07:28:39.095Z", |
| | | "customerId" : 165, |
| | | "agentNo" : null, |
| | | "status" : "UNFILLED", |
| | | "score" : null, |
| | | "appointmentId" : 527, |
| | | "customerName" : "Mila la", |
| | | "agentName" : null, |
| | | "type" : "SYSTEM" |
| | | } |
| | | ] |
| | | ] |
| | |
| | | |
| | | List<Satisfaction> findByAgentNoAndType(String agentNo, SatisfactionTypeEnum type); |
| | | |
| | | List<Satisfaction> findByCustomerIdAndType(Long customerId, SatisfactionTypeEnum type); |
| | | List<Satisfaction> findByCustomerId(Long customerId); |
| | | |
| | | Optional<Satisfaction> findOneByAppointmentIdAndType(Long appointmentId, SatisfactionTypeEnum type); |
| | | |
| | |
| | | import com.pollex.pam.enums.SatisfactionTypeEnum; |
| | | import com.pollex.pam.security.SecurityUtils; |
| | | import com.pollex.pam.service.dto.SatisfactionSystemScoreDTO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Service |
| | | @Transactional |
| | | public class SatisfactionService { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(SatisfactionService.class); |
| | | |
| | | @Autowired |
| | | SatisfactionRepository satisfactionRepository; |
| | |
| | | return satisfactionMapper.toDTO(satisfactionList); |
| | | } |
| | | |
| | | public List<SatisfactionDTO> getByCustomerIdAndType(Long customerDBId, SatisfactionTypeEnum type) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerIdAndType(customerDBId, type); |
| | | public List<SatisfactionDTO> getByCustomerId(Long customerDBId) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerId(customerDBId); |
| | | return satisfactionMapper.toDTO(satisfactionList); |
| | | } |
| | | |
| | |
| | | return satisfactionList; |
| | | } |
| | | |
| | | public Satisfaction createSystemSatisfaction(SatisfactionSystemScoreDTO scoreDTO) { |
| | | public void createUnfilledSystemSatisfaction(Appointment appointment) { |
| | | Satisfaction satisfaction = new Satisfaction(); |
| | | satisfaction.setAppointmentId(appointment.getId()); |
| | | satisfaction.setCustomerId(SecurityUtils.getCustomerDBId()); |
| | | satisfaction.setAppointmentId(scoreDTO.getAppointmentId()); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.UNFILLED); |
| | | satisfaction.setType(SatisfactionTypeEnum.SYSTEM); |
| | | return satisfactionRepository.save(satisfaction); |
| | | |
| | | satisfactionRepository.save(satisfaction); |
| | | } |
| | | |
| | | public Satisfaction fillSystemSatisfaction(SatisfactionSystemScoreDTO scoreDTO) { |
| | | Optional<Satisfaction> systemSatisfactionOptional = |
| | | satisfactionRepository.findOneByAppointmentIdAndType(scoreDTO.getAppointmentId(), SatisfactionTypeEnum.SYSTEM); |
| | | |
| | | if(systemSatisfactionOptional.isPresent()) { |
| | | Satisfaction satisfaction = systemSatisfactionOptional.get(); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | return satisfactionRepository.save(satisfaction); |
| | | } |
| | | else { |
| | | log.warn("not found the satisfaction record, so can't fill system satisfaction"); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.time.Instant; |
| | | |
| | | import com.pollex.pam.enums.SatisfactionStatusEnum; |
| | | import com.pollex.pam.enums.SatisfactionTypeEnum; |
| | | |
| | | public class SatisfactionDTO { |
| | | |
| | |
| | | private Long appointmentId; |
| | | private String customerName; |
| | | private String agentName; |
| | | |
| | | private SatisfactionTypeEnum type; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | |
| | | public void setAgentName(String agentName) { |
| | | this.agentName = agentName; |
| | | } |
| | | |
| | | |
| | | public SatisfactionTypeEnum getType() { |
| | | return type; |
| | | } |
| | | public void setType(SatisfactionTypeEnum type) { |
| | | this.type = type; |
| | | } |
| | | } |
| | |
| | | import static java.util.stream.Collectors.toList; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Service |
| | | public class SatisfactionMapper { |
| | | |
| | | |
| | | @Autowired |
| | | ConsultantRepository consultantRepository; |
| | | |
| | | |
| | | @Autowired |
| | | CustomerRepository customerRepository; |
| | | |
| | | |
| | | public SatisfactionDTO toDTO(Satisfaction source) { |
| | | SatisfactionDTO target = new SatisfactionDTO(); |
| | | BeanUtils.copyProperties(source, target); |
| | | target.setScore(source.getScore()); |
| | | Consultant consultant= consultantRepository.findOneByAgentNo(source.getAgentNo()).get(); |
| | | target.setAgentName(consultant.getName()); |
| | | Consultant consultant= consultantRepository.findOneByAgentNo(source.getAgentNo()).orElse(null); |
| | | target.setAgentName(Objects.isNull(consultant) ? null : consultant.getName()); |
| | | Customer customer = customerRepository.findById(source.getCustomerId()).get(); |
| | | target.setCustomerName(customer.getName()); |
| | | return target; |
| | |
| | | import com.pollex.pam.service.PersonalNotificationService; |
| | | import com.pollex.pam.service.SatisfactionService; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api/appointment") |
| | | public class AppointmentResource { |
| | |
| | | public AppointmentDTO clientCreateAppointment(@RequestBody AppointmentCreateDTO appointmentCreateDTO) { |
| | | Appointment appointment = appointmentService.customerCreateAppointment(appointmentCreateDTO); |
| | | appointmentService.sendAppointmentNotify(appointment); |
| | | satisfactionService.createUnfilledSystemSatisfaction(appointment); |
| | | |
| | | return appointmentMapper.toAppointmentDTO(appointment); |
| | | } |
| | |
| | | if(StringUtils.hasText(SecurityUtils.getAgentNo())) { |
| | | return satisfactionService.getByAgentNoAndType(SecurityUtils.getAgentNo(), SatisfactionTypeEnum.APPOINTMENT); |
| | | }else if(SecurityUtils.getCustomerDBId()!=null){ |
| | | return satisfactionService.getByCustomerIdAndType(SecurityUtils.getCustomerDBId(), SatisfactionTypeEnum.APPOINTMENT); |
| | | return satisfactionService.getByCustomerId(SecurityUtils.getCustomerDBId()); |
| | | } |
| | | log.error("Not has agent code and customer id"); |
| | | throw new IllegalArgumentException("Not has agent code and customer id"); |
| | |
| | | |
| | | @PostMapping("/system/score") |
| | | public Satisfaction createSystemSatisfaction(@RequestBody SatisfactionSystemScoreDTO scoreDTO) { |
| | | return satisfactionService.createSystemSatisfaction(scoreDTO); |
| | | return satisfactionService.fillSystemSatisfaction(scoreDTO); |
| | | } |
| | | } |