UsedCarDataStatsController.java
11.1 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
package cn.com.glsx.dj.controller;
import cn.com.glsx.dj.converter.*;
import cn.com.glsx.dj.peanalysis.dto.req.UserdCarDataStats.*;
import cn.com.glsx.dj.peanalysis.dto.res.UserdCarDataStats.*;
import cn.com.glsx.dj.peanalysis.dto.res.output.LostStoreDetailResponse;
import cn.com.glsx.dj.peanalysis.remote.UsedCarDataStatsRemote;
import cn.com.glsx.dj.request.UserdCarDataStats.*;
import cn.com.glsx.dj.response.UserdCarDataStats.*;
import cn.com.glsx.dj.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
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 java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
/**
* 二手车数据统计分析
*/
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("二手车数据统计分析")
public class UsedCarDataStatsController {
@Resource
private UsedCarDataStatsRemote usedCarDataStatsRemote;
@ApiOperation("经营情况-累计至今")
@ServiceMethod(method = "dj.api.used.car.data.stats.operation.status", needInSession = NeedInSessionType.YES)
public RopResponse<OperationStatusResponse> getOperationStatus(OperationStatusRequest request) {
OperationStatusReq operationStatusReq = CommonUtil.convertRequest(OperationStatusReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
operationStatusReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
operationStatusReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<OperationStatusRes> operationStatus = usedCarDataStatsRemote.getOperationStatus(operationStatusReq);
return CommonUtil.convertRopResponse(operationStatus, OperationStatusResponseConvert.INSTANCE::toOperationStatusResponse);
}
@ApiOperation("整体收车成本分布")
@ServiceMethod(method = "dj.api.used.car.data.stats.receiving.cost.distribution", needInSession = NeedInSessionType.YES)
public RopResponse<ReceivingCostDistributionResponse> getReceivingCostDistribution(OperationStatusRequest request) {
OperationStatusReq operationStatusReq = CommonUtil.convertRequest(OperationStatusReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
operationStatusReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
operationStatusReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<ReceivingCostDistributionRes> operationStatus = usedCarDataStatsRemote.getReceivingCostDistribution(operationStatusReq);
return CommonUtil.convertRopResponse(operationStatus, ReceivingCostDistributionResponseConvert.INSTANCE::toReceivingCostDistributionResponse);
}
@ApiOperation("按周期统计数据")
@ServiceMethod(method = "dj.api.used.car.data.stats.cycle.data", needInSession = NeedInSessionType.YES)
public RopResponse<CycleDataResponse> getCycleData(CycleDataRequest request) {
CycleDataReq cycleDataReq = CommonUtil.convertRequest(CycleDataReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
cycleDataReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
cycleDataReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<CycleDataRes> cycleData = usedCarDataStatsRemote.getCycleData(cycleDataReq);
return CommonUtil.convertRopResponse(cycleData, CycleDataResponseConvert.INSTANCE::toCycleDataResponse);
}
/**
* 二手车相关趋势图
*/
@ApiOperation("二手车相关趋势图")
@ServiceMethod(method = "dj.api.used.car.data.stats.trend.chart", needInSession = NeedInSessionType.YES)
public RopResponse<TrendChartInfoResponse> getTrendChart(TrendChartRequest request) {
TrendChartReq trendChartReq = CommonUtil.convertRequest(TrendChartReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
trendChartReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
trendChartReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<TrendChartInfoRes> trendChart = usedCarDataStatsRemote.getTrendChart(trendChartReq);
return CommonUtil.convertRopResponse(trendChart, TrendChartInfoResponseConvert.INSTANCE::toTrendChartInfoResponse);
}
@ApiOperation("存量门店分析")
@ServiceMethod(method = "dj.api.used.car.data.stats.stock.store.analysis", needInSession = NeedInSessionType.YES)
public RopResponse<StockStoreAnalysisResponse> getStockStoreAnalysis(StockStoreAnalysisRequest request) {
StockStoreAnalysisReq stockStoreAnalysisReq = CommonUtil.convertRequest(StockStoreAnalysisReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
stockStoreAnalysisReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
stockStoreAnalysisReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<StockStoreAnalysisRes> stockStoreAnalysis = usedCarDataStatsRemote.getStockStoreAnalysis(stockStoreAnalysisReq);
return CommonUtil.convertRopResponse(stockStoreAnalysis, StockStoreAnalysisResponseConvert.INSTANCE::toStockStoreAnalysisResponse);
}
@ApiOperation("区域分布")
@ServiceMethod(method = "dj.api.used.car.data.stats.region.distribution", needInSession = NeedInSessionType.YES)
public RopResponse<List<RegionDistributionResponse>> getRegionDistribution(RegionDistributionRequest request) {
RegionDistributionReq regionDistributionReq = CommonUtil.convertRequest(RegionDistributionReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
regionDistributionReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
regionDistributionReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<List<RegionDistributionRes>> regionDistribution = usedCarDataStatsRemote.getRegionDistribution(regionDistributionReq);
return CommonUtil.convertRopResponse(regionDistribution, RegionDistributionResponseConvert.INSTANCE::toListRegionDistributionResponse);
}
@ApiOperation("门店列表统计")
@ServiceMethod(method = "dj.api.used.car.data.stats.store.list.count", needInSession = NeedInSessionType.YES)
public RopResponse<StoreListCountResponse> getStoreListCount(StoreListCountRequest request) {
StoreListCountReq storeListCountReq = CommonUtil.convertRequest(StoreListCountReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
storeListCountReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
storeListCountReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<StoreListCountRes> storeListCount = usedCarDataStatsRemote.getStoreListCount(storeListCountReq);
return CommonUtil.convertRopResponse(storeListCount, StoreListCountResponseConvert.INSTANCE::toStoreListCountResponse);
}
@ApiOperation("门店列表")
@ServiceMethod(method = "dj.api.used.car.data.stats.store.list", needInSession = NeedInSessionType.YES)
public RopResponse<List<StoreListResponse>> getStoreList(StoreListRequest request) {
StoreListReq storeListReq = CommonUtil.convertRequest(StoreListReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
storeListReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
storeListReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<List<StoreListRes>> storeList = usedCarDataStatsRemote.getStoreList(storeListReq);
return CommonUtil.convertRopResponse(storeList, StoreListResponseConvert.INSTANCE::toListStoreListResponse);
}
@ApiOperation("流量贡献排行榜")
@ServiceMethod(method = "dj.api.used.car.data.stats.flow.contribution.ranking", needInSession = NeedInSessionType.YES)
public RopResponse<List<FlowContributionRankingResponse>> getFlowContributionRanking(FlowContributionRankingRequest request) {
FlowContributionRankingReq flowContributionRankingReq = CommonUtil.convertRequest(FlowContributionRankingReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
RopResponse.error("您暂无使用权限,请确认后重新操作。");
}
flowContributionRankingReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
flowContributionRankingReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<List<FlowContributionRankingRes>> flowContributionRanking = usedCarDataStatsRemote.getFlowContributionRanking(flowContributionRankingReq);
return CommonUtil.convertRopResponse(flowContributionRanking, FlowContributionRankingResponseConvert.INSTANCE::toListFlowContributionRankingResponse);
}
@ApiOperation("二手车-流失门店列表")
@ServiceMethod(method = "dj.api.used.car.data.stats.stock.store.getLostStockStore", needInSession = NeedInSessionType.YES)
public RopResponse<List<LostStoreDetailResponse>> getLostStockStore(StockStoreAnalysisRequest request) {
StockStoreAnalysisReq stockStoreAnalysisReq = CommonUtil.convertRequest(StockStoreAnalysisReq.class);
boolean b = CommonUtil.validLeadRole();
if (!b) {
return RopResponse.error("您暂无使用权限...");
}
stockStoreAnalysisReq.setRole(CommonUtil.getLoginUserInfo().getLoginRole());
stockStoreAnalysisReq.setRegionId(CommonUtil.getLoginUserInfo().getRegionId());
RpcResponse<List<LostStoreDetailResponse>> stockStoreAnalysis = usedCarDataStatsRemote.getLostStockStore(stockStoreAnalysisReq);
String search = request.getSearch();
// 轻量级的数据,http接口查询出来的,暂时无法使用sql过滤
if (StringUtils.isNotBlank(search) && CollectionUtils.isNotEmpty(stockStoreAnalysis.getResult())) {
List<LostStoreDetailResponse> filteredList = stockStoreAnalysis.getResult().stream()
.filter(p -> p.getStoreName() != null && p.getStoreName().contains(search))
.collect(Collectors.toList());
return RopResponse.success(filteredList);
}
return RopResponse.success(stockStoreAnalysis.getResult());
}
}