BiMatterController.java
11.3 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package cn.com.glsx.dj.controller;
import cn.com.glsx.dj.converter.BiMatterConvert;
import cn.com.glsx.dj.peanalysis.dto.analysis.*;
import cn.com.glsx.dj.peanalysis.enums.BiErrorEnum;
import cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote;
import cn.com.glsx.dj.request.biAnalyse.*;
import cn.com.glsx.dj.response.LoginUserInfoResponse;
import cn.com.glsx.dj.response.bianalysis.MerchantBiMatterResp;
import cn.com.glsx.dj.response.bianalysis.MerchantOperatorDetailResp;
import cn.com.glsx.dj.response.bianalysis.MyMerchantBiMatterResp;
import cn.com.glsx.dj.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.hutool.core.bean.BeanUtil;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.Optional;
/**
* BI事项处理控制器
* @author yangwei
* @version 1.0
* @since 2025/12/22 11:12
*/
@Slf4j
@Api("BI事项处理控制器")
@RequiredArgsConstructor
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
public class BiMatterController {
private final BiMatterConvert biMatterConvert;
private final BiAnalyseBackgroundRemote biAnalyseBackgroundRemote;
@ApiOperation("bi事项管理-新增待跟进事项")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.merchant.bi.matter.add", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> merchantBiMatterAdd(MerchantBiMatterAddReq request) {
try {
LoginUserInfoResponse loginUserDTO = Optional.ofNullable(CommonUtil.getLoginUserInfo())
.orElseThrow(() -> new RpcServiceException(BiErrorEnum.LOGIN_USER_NOT_EXIST));
MerchantBiMatterAddDTO merchantBiMatterAddDTO = BeanUtil.copyProperties(request, MerchantBiMatterAddDTO.class);
merchantBiMatterAddDTO.setCreator(loginUserDTO.getName());
merchantBiMatterAddDTO.setCreatorUnique(loginUserDTO.getUuid());
RpcResponse<Boolean> response = biAnalyseBackgroundRemote.merchantBiMatterAdd(merchantBiMatterAddDTO);
if (response.isFailed()) {
throw new RpcServiceException(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.matter.add occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.matter.add error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), "业务异常");
}
}
@ApiOperation("BI-事项管理处理")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.merchant.bi.matter.handle", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> merchantBiMatterHandle(MerchantBiMatterHandleReq request) {
try {
LoginUserInfoResponse loginUserDTO = Optional.ofNullable(CommonUtil.getLoginUserInfo())
.orElseThrow(() -> new RpcServiceException(BiErrorEnum.LOGIN_USER_NOT_EXIST));
String userName = loginUserDTO.getName();
String uuid = loginUserDTO.getUuid();
MerchantBiMatterHandleDTO merchantBiMatterHandleDTO = BeanUtil.copyProperties(request, MerchantBiMatterHandleDTO.class);
merchantBiMatterHandleDTO.setOperator(userName);
merchantBiMatterHandleDTO.setOperatorUniqueKey(uuid);
RpcResponse<Boolean> rpcResponse = biAnalyseBackgroundRemote.merchantBiMatterHandle(merchantBiMatterHandleDTO);
if (rpcResponse.isFailed()) {
throw new RpcServiceException(rpcResponse.getError(), rpcResponse.getMessage());
}
return RopResponse.success(rpcResponse.getResult());
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.matter.handle occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.matter.handle occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVICE_ERROR.getDisplayName());
}
}
@ApiOperation("BI-获取指定店铺的区域运营与线上运营")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.merchant.bi.operator", needInSession = NeedInSessionType.YES)
public RopResponse<MerchantOperatorDetailResp> findMerchantOperator(MerchantOperatorReq request) {
try {
MerchantOperatorDTO merchantOperatorDTO = BeanUtil.copyProperties(request, MerchantOperatorDTO.class);
RpcResponse<MerchantOperatorDetailDTO> rpcResponse = biAnalyseBackgroundRemote.findMerchantOperator(merchantOperatorDTO);
if (rpcResponse.isFailed()) {
throw new RpcServiceException(rpcResponse.getError(), rpcResponse.getMessage());
}
MerchantOperatorDetailDTO merchantOperatorDetailDTO = rpcResponse.getResult();
MerchantOperatorDetailResp merchantOperatorDetailResp = BeanUtil.copyProperties(merchantOperatorDetailDTO, MerchantOperatorDetailResp.class);
return RopResponse.success(merchantOperatorDetailResp);
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.operator occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.operator occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVICE_ERROR.getDisplayName());
}
}
@ApiOperation("BI-我的事项列表")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.my.merchant.bi.matter.page", needInSession = NeedInSessionType.YES)
public RopResponse<RpcPagination<MyMerchantBiMatterResp>> myMerchantBiMatterPage(MyMerchantBiMatterQryReq request) {
try {
LoginUserInfoResponse loginUserDTO = Optional.ofNullable(CommonUtil.getLoginUserInfo())
.orElseThrow(() -> new RpcServiceException(BiErrorEnum.LOGIN_USER_NOT_EXIST));
String uuid = loginUserDTO.getUuid();
RpcPagination<MyMerchantBiMatterQryDTO> rpcPagination = CommonUtil.getRpcPagination(MyMerchantBiMatterQryDTO.class);
MyMerchantBiMatterQryDTO condition = BeanUtil.copyProperties(request, MyMerchantBiMatterQryDTO.class);
condition.setOperator(uuid);
rpcPagination.setCondition(condition);
RpcResponse<RpcPagination<MyMerchantBiMatterDTO>> rpcPaginationRpcResponse = biAnalyseBackgroundRemote.myMerchantBiMatterPage(rpcPagination);
if (rpcPaginationRpcResponse.isFailed()) {
throw new RpcServiceException(rpcPaginationRpcResponse.getError(), rpcPaginationRpcResponse.getMessage());
}
RpcPagination<MyMerchantBiMatterDTO> rpcPaginationDTO = rpcPaginationRpcResponse.getResult();
RpcPagination<MyMerchantBiMatterResp> resultPage = biMatterConvert.MyMerchantBiMatterDto2ResponsePage(rpcPaginationDTO);
return RopResponse.success(resultPage);
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.my.merchant.bi.matter.page occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.my.merchant.bi.matter.page occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVICE_ERROR.getDisplayName());
}
}
@ApiOperation("BI-事项管理详情")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.merchant.bi.operator.detail", needInSession = NeedInSessionType.YES)
public RopResponse<MerchantBiMatterResp> biMatterOperatorDetail(MerchantBiMatterSingleIdReq request) {
try {
MerchantBiMatterSingleIdDTO merchantBiMatterSingleIdDTO = BeanUtil.copyProperties(request, MerchantBiMatterSingleIdDTO.class);
RpcResponse<MerchantBiMatterDTO> rpcResponse = biAnalyseBackgroundRemote.biMatterOperatorDetail(merchantBiMatterSingleIdDTO);
if (rpcResponse.isFailed()) {
throw new RpcServiceException(rpcResponse.getError(), rpcResponse.getMessage());
}
MerchantBiMatterDTO merchantBiMatterDTO = rpcResponse.getResult();
MerchantBiMatterResp merchantBiMatterResp = BeanUtil.copyProperties(merchantBiMatterDTO, MerchantBiMatterResp.class);
return RopResponse.success(merchantBiMatterResp);
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.operator.detail occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.bi.operator.detail occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVICE_ERROR.getDisplayName());
}
}
@ApiOperation("BI-我的事项未处理数量")
@ServiceMethod(method = "dj.api.smartcarlife.business.analysis.merchant.unhandle.count", needInSession = NeedInSessionType.YES)
public RopResponse<Integer> getMyBiMatterUnHandleCount(AbstractRopRequest request) {
try {
LoginUserInfoResponse loginUserDTO = Optional.ofNullable(CommonUtil.getLoginUserInfo())
.orElseThrow(() -> new RpcServiceException(BiErrorEnum.LOGIN_USER_NOT_EXIST));
String uuid = loginUserDTO.getUuid();
RpcResponse<Integer> rpcResponse = biAnalyseBackgroundRemote.getMyBiMatterUnHandleCount(uuid);
if (rpcResponse.isFailed()) {
throw new RpcServiceException(rpcResponse.getError(), rpcResponse.getMessage());
}
Integer unHandleCount = rpcResponse.getResult();
return RopResponse.success(unHandleCount);
} catch (RpcServiceException e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.unhandle.count occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage());
} catch (Exception e) {
log.info("dj.api.smartcarlife.business.analysis.merchant.unhandle.count occur error!", e);
return RopResponse.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVICE_ERROR.getDisplayName());
}
}
}