BusinessAnalysisService.java
18.9 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
package com.glsk.service;
import com.glsk.component.HttpUtil;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 此服务针对经营进行总览分析
*/
@Service
@Slf4j
public class BusinessAnalysisService {
final String HOST_URL = "https://glsx-bi-report.glsx.com.cn/overview/";
// 字段描述
final String BUSINESS_TYPE_DESC = "业务场景:quanyi/yanbao/qinggai其中一个,权益-quanyi 延保-yanbao 轻该-qinggai";
final String QUERY_TYPE_DESC = "查询维度:day/week/month/self其中之一,日-day、周-week、月-month,自定义-self";
final String RANK_FIELD_DESC = "排序字段:output/atv/yinliulv/zhuanhualv/shentoulv其中之一,产值-output、客单价-atv、引流率-yinliulv、转化率-zhuanhualv、渗透率-shentoulv";
final String RANK_FIELD_TYPE_DESC = "升降序:asc/desc其中之一,升序-asc,desc-降序";
final String BUSINESS_ATTRIBUTE_DESC = "业务性质:all/qudao/shop4s/hezi/fuwushang其中一个,全部-all,直营渠道-qudao,直营4S店-shop4s,合资收购-hezi,服务商投资-fuwushang";
@Autowired
private HttpUtil httpUtil;
@Tool(description = "查询门店产值和展业门店数")
public String queryOutputAndMernum(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute
) {
String method = "queryOutputAndMernum";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "根据门店查询项目名称")
public String queryItemName(@ToolParam(description = "门店Id列表,用逗号分隔") String ids) {
String method = "queryItemName";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("ids", ids);
try {
String response = httpUtil.doGet(url, params);
log.info("查询项目名称成功: {}", response);
return response;
} catch (Exception e) {
log.error("查询项目名称失败", e);
throw new RuntimeException("查询项目名称失败", e);
}
}
@Tool(description = "查询门店产值趋势")
public String queryOutputTrend(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute
) {
String method = "queryOutputTrend";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
try {
String response = httpUtil.doGet(url, params);
log.info("查询门店产值趋势成功: {}", response);
return response;
} catch (Exception e) {
log.error("查询门店产值趋势失败", e);
throw new RuntimeException("查询门店产值趋势失败", e);
}
}
@Tool(description = "查询门店排名")
public String queryMerRanking(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute,
@ToolParam(description = RANK_FIELD_DESC) String rankfield,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType,
@ToolParam(description = "可见门店id列表") String ids,
@ToolParam(description = "门店名称(模糊匹配)") String merchantname
) {
String method = "queryMerRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
params.put("rankfield", rankfield);
params.put("rankType", rankType);
params.put("ids", ids);
params.put("merchantname", merchantname);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "获取服务商排行")
public String getServiceBossRanking(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute,
@ToolParam(description = RANK_FIELD_DESC) String rankfield,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType,
@ToolParam(description = "服务老板名称") String serviceBossname
) {
String method = "getServiceBossRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
params.put("rankfield", rankfield);
params.put("rankType", rankType);
params.put("serviceBossname", serviceBossname);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "获取督导排行")
public String getSupervisionRanking(@ToolParam(description = "项目名称") String itemname,
@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute,
@ToolParam(description = RANK_FIELD_DESC) String rankfield,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType,
@ToolParam(description = "可见门店id列表") String ids,
@ToolParam(description = "督导名称") String supervisionname
) {
String method = "getSupervisionRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
params.put("rankfield", rankfield);
params.put("rankType", rankType);
params.put("itemname", itemname);
params.put("ids", ids);
params.put("supervisionname", supervisionname);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "获取销售排行")
public String getSaleRanking(@ToolParam(description = "项目名称") String itemname,
@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = QUERY_TYPE_DESC) String queryType,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute,
@ToolParam(description = RANK_FIELD_DESC) String rankfield,
@ToolParam(description = RANK_FIELD_TYPE_DESC) String rankType,
@ToolParam(description = "可见门店id列表") String ids,
@ToolParam(description = "销售名称") String salename
) {
String method = "getSaleRanking";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("queryType", queryType);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
params.put("rankfield", rankfield);
params.put("rankType", rankType);
params.put("itemname", itemname);
params.put("ids", ids);
params.put("salename", salename);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
@Tool(description = "品类分析")
public String queryProductOutput(@ToolParam(description = BUSINESS_TYPE_DESC) String business_type,
@ToolParam(description = "开始时间") String startDay,
@ToolParam(description = "结束时间") String endDay,
@ToolParam(description = "品牌,默认全部") String brand,
@ToolParam(description = "省份,默认全部") String province,
@ToolParam(description = "城市,默认全部") String city,
@ToolParam(description = "服务商,默认全部") String service,
@ToolParam(description = "区域督导,默认全部") String supervision,
@ToolParam(description = "销售,默认全部") String salesman,
@ToolParam(description = BUSINESS_ATTRIBUTE_DESC) String businessAttribute,
@ToolParam(description = "可见门店id列表") String ids
) {
String method = "queryProductOutput";
String url = HOST_URL + method;
Map<String, Object> params = new HashMap<>();
params.put("business_type", business_type);
params.put("startDay", startDay);
params.put("endDay", endDay);
params.put("brand", brand);
params.put("province", province);
params.put("city", city);
params.put("service", service);
params.put("supervision", supervision);
params.put("salesman", salesman);
params.put("businessAttribute", businessAttribute);
params.put("ids", ids);
try {
String response = httpUtil.doGet(url, params);
log.info("返回成功: {}", response);
return response;
} catch (Exception e) {
log.error("返回失败", e);
throw new RuntimeException("返回失败", e);
}
}
}