ProjectGroupController.java
11 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package cn.com.glsx.dj.strategy.controller;
import cn.com.glsx.dj.strategy.dto.projectgroup.*;
import cn.com.glsx.dj.strategy.remote.ProjectGroupRemote;
import cn.com.glsx.dj.strategy.request.*;
import cn.com.glsx.dj.strategy.uitl.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.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.IgnoreSignType;
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.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 项目组管理控制器。
*/
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("项目组管理")
public class ProjectGroupController {
@Autowired
private ProjectGroupRemote projectGroupRemote;
@ApiOperation("项目组分页列表")
@ServiceMethod(method = "dj.api.strategy.project.group.list", needInSession = NeedInSessionType.NO, ignoreSign = IgnoreSignType.YES)
public RopResponse<RpcPagination<ProjectGroupListDTO>> pageProjectGroup(ProjectGroupQueryRequest request) {
try {
RpcPagination<ProjectGroupQueryDTO> pagination = CommonUtil.getRpcPagination(ProjectGroupQueryDTO.class);
RpcResponse<RpcPagination<ProjectGroupListDTO>> response = projectGroupRemote.pageProjectGroup(pagination);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (Exception e) {
log.error("dj.api.strategy.project.group.list exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("查询项目组详情")
@ServiceMethod(method = "dj.api.strategy.project.group.detail")
public RopResponse<ProjectGroupDetailDTO> getProjectGroupDetail(ProjectGroupIdRequest request) {
try {
ProjectGroupIdDTO dto = CommonUtil.convertRequest(ProjectGroupIdDTO.class);
RpcResponse<ProjectGroupDetailDTO> response = projectGroupRemote.getProjectGroupDetail(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.error("dj.api.strategy.project.group.detail rpcServiceException", e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("dj.api.strategy.project.group.detail exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("保存项目组(支持编辑)")
@ServiceMethod(method = "dj.api.strategy.project.group.save")
public RopResponse<Boolean> saveProjectGroup(ProjectGroupSaveRequest request) {
try {
ProjectGroupSaveDTO dto = CommonUtil.convertRequest(ProjectGroupSaveDTO.class);
dto.setOperator(resolveOperator());
RpcResponse<Boolean> response = projectGroupRemote.saveProjectGroup(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.error("dj.api.strategy.project.group.save rpcServiceException", e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("dj.api.strategy.project.group.save exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("删除项目组")
@ServiceMethod(method = "dj.api.strategy.project.group.delete")
public RopResponse<Boolean> deleteProjectGroup(ProjectGroupIdRequest request) {
try {
ProjectGroupIdDTO dto = CommonUtil.convertRequest(ProjectGroupIdDTO.class);
dto.setOperator(resolveOperator());
RpcResponse<Boolean> response = projectGroupRemote.deleteProjectGroup(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.error("dj.api.strategy.project.group.delete rpcServiceException", e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("dj.api.strategy.project.group.delete exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("项目组门店分页列表")
@ServiceMethod(method = "dj.api.strategy.project.group.store.list", needInSession = NeedInSessionType.NO, ignoreSign = IgnoreSignType.YES)
public RopResponse<RpcPagination<ProjectGroupStoreDTO>> pageProjectGroupStore(ProjectGroupStoreQueryRequest request) {
try {
RpcPagination<ProjectGroupStoreQueryDTO> pagination = CommonUtil.getRpcPagination(ProjectGroupStoreQueryDTO.class);
RpcResponse<RpcPagination<ProjectGroupStoreDTO>> response = projectGroupRemote.pageProjectGroupStore(pagination);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (Exception e) {
log.error("dj.api.strategy.project.group.store.list exception", e);
return RopResponse.error(e.getMessage());
}
}
/* 异步导入项目组门店的接口放在rop-dj-smartcarlife */
@ApiOperation("批量新增项目组门店")
@ServiceMethod(method = "dj.api.strategy.project.group.store.add")
public RopResponse<Boolean> addProjectGroupStores(ProjectGroupStoreBatchAddRequest request) {
try {
ProjectGroupStoreBatchAddDTO dto = CommonUtil.convertRequest(ProjectGroupStoreBatchAddDTO.class);
dto.setOperator(resolveOperator());
RpcResponse<Boolean> response = projectGroupRemote.addProjectGroupStores(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.error("dj.api.strategy.project.group.store.add rpcServiceException", e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("dj.api.strategy.project.group.store.add exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("删除项目组门店")
@ServiceMethod(method = "dj.api.strategy.project.group.store.delete")
public RopResponse<Boolean> deleteProjectGroupStore(ProjectGroupStoreDeleteRequest request) {
try {
ProjectGroupStoreDeleteDTO dto = CommonUtil.convertRequest(ProjectGroupStoreDeleteDTO.class);
dto.setOperator(resolveOperator());
RpcResponse<Boolean> response = projectGroupRemote.deleteProjectGroupStore(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (RpcServiceException e) {
log.error("dj.api.strategy.project.group.store.delete rpcServiceException", e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("dj.api.strategy.project.group.store.delete exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("查询预警类型列表")
@ServiceMethod(method = "dj.api.strategy.project.group.warning.meta.types")
public RopResponse<List<WarningTypeOptionDTO>> listWarningTypes(ProjectGroupQueryRequest request) {
try {
RpcResponse<List<WarningTypeOptionDTO>> response = projectGroupRemote.listWarningTypes();
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult().stream()
.filter(item -> Objects.equals(item.getShowType(), 0)).collect(Collectors.toList()));
} catch (Exception e) {
log.error("dj.api.strategy.project.group.warning.meta.types exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("查询应用业务列表")
@ServiceMethod(method = "dj.api.strategy.project.group.warning.meta.bizs")
public RopResponse<List<BizOptionDTO>> listBizs(ProjectGroupQueryRequest request) {
try {
RpcResponse<List<BizOptionDTO>> response = projectGroupRemote.listBizs();
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (Exception e) {
log.error("dj.api.strategy.project.group.warning.meta.bizs exception", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("查询指标列表")
@ServiceMethod(method = "dj.api.strategy.project.group.warning.meta.metrics")
public RopResponse<List<MetricOptionDTO>> listMetrics(ProjectGroupMetricQueryRequest request) {
try {
ProjectGroupMetricQueryDTO dto = CommonUtil.convertRequest(ProjectGroupMetricQueryDTO.class);
RpcResponse<List<MetricOptionDTO>> response = projectGroupRemote.listMetrics(dto);
if (response.hasError()) {
log.error(response.getMessage());
return RopResponse.error(response.getError(), response.getMessage());
}
return RopResponse.success(response.getResult());
} catch (Exception e) {
log.error("dj.api.strategy.project.group.warning.meta.metrics exception", e);
return RopResponse.error(e.getMessage());
}
}
/**
* 获取当前操作人。
*
* @return 操作人
*/
private String resolveOperator() {
String userName = CommonUtil.getUserName();
return userName == null ? CommonUtil.getAccountName() : userName;
}
}