ClientCustomerServiceImpl.java
7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package com.infoloop.tianting.service.impl;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefResponseDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto;
import com.infoloop.tianting.service.ClientCustomerService;
import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient;
import com.infoloop.tianting.utils.DateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientCustomerServiceImpl implements ClientCustomerService {
private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient;
@Override
public ClientCustomerDto getClientCustomerByHISCustomerId(String hisCustomerId) {
var response = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId(hisCustomerId).getResponse();
if (response.getId() == 0) {
response = clientCustomerServiceRpcClient.getClientCustomerByContactNo(hisCustomerId).getResponse();
}
return ClientCustomerDto.builder()
.id(response.getId())
.clientId(response.getClientId())
.enterpriseId(response.getEnterpriseId())
.age(response.getAge())
.height(response.getHeight())
.HISCustomerId(response.getHISCustomerId())
.identityCardNo(response.getIdentityCardNo())
.mobile(response.getMobile())
.name(response.getName())
.openId(response.getOpenId())
.sex(response.getSex())
.stallId(response.getStallId())
.weight(response.getWeight())
.isDeleted(response.getIsDeleted())
.birthday(DateUtil.formatDate(response.getBirthday()))
.createdAt(DateUtil.formatDate(response.getCreatedAt()))
.createdBy(response.getCreatedBy())
.creationSource(response.getCreationSource())
.updatedAt(DateUtil.formatDate(response.getUpdatedAt()))
.updateSource(response.getUpdateSource())
.updatedBy(response.getUpdatedBy())
.build();
}
@Override
public ClientCustomerDto getClientCustomerByPhone(String phone) {
final var response = clientCustomerServiceRpcClient.getClientCustomerByMobile(phone);
return ClientCustomerDto.builder()
.id(response.getResponse().getId())
.clientId(response.getResponse().getClientId())
.enterpriseId(response.getResponse().getEnterpriseId())
.age(response.getResponse().getAge())
.height(response.getResponse().getHeight())
.HISCustomerId(response.getResponse().getHISCustomerId())
.identityCardNo(response.getResponse().getIdentityCardNo())
.mobile(response.getResponse().getMobile())
.name(response.getResponse().getName())
.openId(response.getResponse().getOpenId())
.sex(response.getResponse().getSex())
.stallId(response.getResponse().getStallId())
.weight(response.getResponse().getWeight())
.isDeleted(response.getResponse().getIsDeleted())
.birthday(DateUtil.formatDate(response.getResponse().getBirthday()))
.createdAt(DateUtil.formatDate(response.getResponse().getCreatedAt()))
.createdBy(response.getResponse().getCreatedBy())
.creationSource(response.getResponse().getCreationSource())
.updatedAt(DateUtil.formatDate(response.getResponse().getUpdatedAt()))
.updateSource(response.getResponse().getUpdateSource())
.updatedBy(response.getResponse().getUpdatedBy())
.build();
}
@Override
public List<HospitalRecordDto> getClientCustomerHospitalRecordsByCustomerId(
Integer enterpriseId, Integer customerId) {
final var response = clientCustomerServiceRpcClient
.getClientCustomerHospitalRecordsByCustomerId(enterpriseId, customerId);
final var record = response.getResponse();
return List.of(HospitalRecordDto.builder()
.id(record.getId())
.enterpriseId(record.getEnterpriseId())
.clientId(record.getClientId())
.stallId(record.getStallId())
.customerId(record.getCustomerId())
.actualDischargeTime(DateUtil.formatDate(record.getActualDischargeTime()))
.birthDate(DateUtil.formatDate(record.getBirthDate()))
.contractNo(record.getContractNo())
.departmentName(record.getDepartmentName())
.dueDate(DateUtil.formatDate(record.getDueDate()))
.expectDischargeTime(DateUtil.formatDate(record.getExpectDischargeTime()))
.hospitalStatus(record.getHospitalStatus())
.hospitalTime(DateUtil.formatDate(record.getHospitalTime()))
.remark(record.getRemark())
.roomNo(record.getRoomNo())
.isDeleted(record.getIsDeleted())
.createdAt(DateUtil.formatDate(record.getCreatedAt()))
.createdBy(record.getCreatedBy())
.creationSource(record.getCreationSource())
.updatedAt(DateUtil.formatDate(record.getUpdatedAt()))
.updatedBy(record.getUpdatedBy())
.updateSource(record.getUpdateSource())
.build());
}
@Override
public BatchCreateCustomerLabelRefResponseDto batchCreateClientCustomerLabelRefs(
BatchCreateCustomerLabelRefDto batchCreateCustomerLabelRefDto) {
final var response = clientCustomerServiceRpcClient.batchCreateClientCustomerLabelRefs(
batchCreateCustomerLabelRefDto);
return BatchCreateCustomerLabelRefResponseDto.builder()
.isCreated(response.getIsCreated())
.ids(response.getIdsList())
.build();
}
@Override
public List<CustomerLabelRefDetailDto> getCustomerLabelsByCustomerId(
Integer enterpriseId, Integer customerId) {
final var response = clientCustomerServiceRpcClient.getCustomerLabelsByCustomerId(
enterpriseId, customerId
);
return response.getResponsesList().stream().map(
labelRef -> CustomerLabelRefDetailDto.builder()
.id(labelRef.getId())
.customerId(labelRef.getCustomerId())
.enterpriseId(labelRef.getEnterpriseId())
.labelId(labelRef.getLabelId())
.creationSource(labelRef.getCreationSource())
.createdAt(DateUtil.formatDate(labelRef.getCreatedAt()))
.createdBy(labelRef.getCreatedBy())
.build()
).collect(Collectors.toList());
}
@Override
public BatchDeleteCustomerLabelRefResponseDto deleteClientCustomerLabelRefsByIds(
BatchDeleteCustomerLabelRefRequestDto deleteRequestDto) {
final var response = clientCustomerServiceRpcClient.batchDeleteClientCustomerLabelRefsByIds(
deleteRequestDto);
return BatchDeleteCustomerLabelRefResponseDto.builder().isDeleted(response.getIsDeleted()).build();
}
}