SycService.java
5.83 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
package cn.com.glsx.entmicro.service;
import cn.com.glsx.entmicro.convert.ConvertRequest;
import cn.com.glsx.entmicro.model.request.SyncCustomerBaseRpcRequest;
import cn.com.glsx.entmicro.model.request.SyncCustomerRpcRequest;
import cn.com.glsx.entmicro.model.request.SyncDepartmentRpcRequest;
import cn.com.glsx.entmicro.model.request.SyncStaffRpcRequest;
import cn.com.glsx.entmicro.remote.SyncRemote;
import cn.com.glsx.entmicro.request.synchronization.SyncCustomerBaseRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncCustomerRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncDepartmentRequest;
import cn.com.glsx.entmicro.request.synchronization.SyncStaffRequest;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
/**
* @author Lichongyuan
* @Description: 同步服务
* @date 2021/10/19 16:07
*/
@Service
@Slf4j
public class SycService {
@Autowired
private SyncRemote syncRemote;
/**
* 同步部门
*
* @param syncDepartmentRequest
*/
public void sycDepartment(SyncDepartmentRequest syncDepartmentRequest) {
SyncDepartmentRpcRequest sycDepartmentRpcRequest = ConvertRequest.convertRequest(syncDepartmentRequest, new SyncDepartmentRpcRequest());
RpcResponse<Boolean> response = syncRemote.sycDepartment(sycDepartmentRpcRequest);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}
/**
* 同步员工
*
* @param syncStaffRequest
*/
public void sycStaff(SyncStaffRequest syncStaffRequest) {
SyncStaffRpcRequest sycStaffRpcRequest = ConvertRequest.convertRequest(syncStaffRequest, new SyncStaffRpcRequest());
RpcResponse<Boolean> response = syncRemote.sycStaff(sycStaffRpcRequest);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}
/**
* 同步客户
*
* @param syncCustomerRequest
*/
public void sycCustomer(SyncCustomerRequest syncCustomerRequest) {
SyncCustomerRpcRequest sycCustomerRpcRequest = ConvertRequest.convertRequest(syncCustomerRequest, new SyncCustomerRpcRequest());
RpcResponse<Boolean> response = syncRemote.sycCustomer(sycCustomerRpcRequest);
if (StringUtils.isNotEmpty(syncCustomerRequest.getUserIdList())) {
String[] split = syncCustomerRequest.getUserIdList().split(",");
sycCustomerRpcRequest.setUserIds(new ArrayList<>(Arrays.asList(split)));
}
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}
/**
* 同步客户群
*/
public void sycCustomerBase(SyncCustomerBaseRequest syncCustomerBaseRequest) {
SyncCustomerBaseRpcRequest sycCustomerBaseRpcRequest = ConvertRequest.convertRequest(syncCustomerBaseRequest, new SyncCustomerBaseRpcRequest());
if (StringUtils.isNotEmpty(syncCustomerBaseRequest.getUserIdList())) {
String[] split = syncCustomerBaseRequest.getUserIdList().split(",");
sycCustomerBaseRpcRequest.setUserIds(new ArrayList<>(Arrays.asList(split)));
}
RpcResponse<Boolean> response = syncRemote.sycCustomerBase(sycCustomerBaseRpcRequest);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}
/**
* 同步标签
*/
public void syncTag(SyncCustomerBaseRequest syncCustomerBaseRequest) {
SyncCustomerBaseRpcRequest sycCustomerBaseRpcRequest = ConvertRequest.convertRequest(syncCustomerBaseRequest, new SyncCustomerBaseRpcRequest());
RpcResponse<Boolean> response = syncRemote.syncTag(sycCustomerBaseRpcRequest);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
}
/**
* 维格表同步指定门店企微客户
*/
public Boolean syncCustomer2Vika(SyncDepartmentRequest syncDepartmentRequest) {
SyncDepartmentRpcRequest request = ConvertRequest.convertRequest(syncDepartmentRequest, new SyncDepartmentRpcRequest());
RpcResponse<Boolean> response = syncRemote.syncCustomer2Vika(request);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
return response.getResult();
}
/**
* 同步客户企微类型标签
*/
public Boolean syncCustomerTypeTagHandle(SyncCustomerRequest syncCustomerRequest) {
SyncCustomerRpcRequest request = ConvertRequest.convertRequest(syncCustomerRequest, new SyncCustomerRpcRequest());
RpcResponse<Boolean> response = syncRemote.syncCustomerTypeTagHandle(request);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
return response.getResult();
}
/**
* 同步客户企微类型标签
*/
public Boolean syncCustomerRemarkToCdp(SyncCustomerRequest syncCustomerRequest) {
SyncCustomerRpcRequest request = ConvertRequest.convertRequest(syncCustomerRequest, new SyncCustomerRpcRequest());
RpcResponse<Boolean> response = syncRemote.syncCustomerRemarkToCdp(null);
if (response.isFailed()) {
throw new RpcServiceException(response.getException().getErrId(), response.getMessage());
}
return response.getResult();
}
}