张延森 5 anos atrás
pai
commit
6e09237265

+ 25
- 0
src/main/java/com/huiju/estateagents/common/StringUtils.java Ver arquivo

3
 import java.io.UnsupportedEncodingException;
3
 import java.io.UnsupportedEncodingException;
4
 import java.net.URLEncoder;
4
 import java.net.URLEncoder;
5
 import java.util.Random;
5
 import java.util.Random;
6
+import java.util.regex.Matcher;
7
+import java.util.regex.Pattern;
6
 
8
 
7
 public class StringUtils {
9
 public class StringUtils {
10
+    private static Pattern humpPattern = Pattern.compile("[A-Z]");
11
+
8
     public static boolean isEmpty(String str) {
12
     public static boolean isEmpty(String str) {
9
         return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
13
         return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
10
     }
14
     }
44
             return str;
48
             return str;
45
         }
49
         }
46
     }
50
     }
51
+
52
+    public static String humpToLine(String str) {
53
+        if (null == str || "".equals(str)) return "";
54
+
55
+        Matcher matcher = humpPattern.matcher(str);
56
+        StringBuffer sb = new StringBuffer();
57
+        while (matcher.find()) {
58
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
59
+        }
60
+        matcher.appendTail(sb);
61
+        return sb.toString();
62
+    }
63
+
64
+    public static String strToUnicode(String str) {
65
+        char[] chars = str.toCharArray();
66
+        String returnStr = "";
67
+        for (int i = 0; i < chars.length; i++) {
68
+            returnStr += "\\u" + Integer.toString(chars[i], 16);
69
+        }
70
+        return returnStr;
71
+    }
47
 }
72
 }

+ 453
- 0
src/main/java/com/huiju/estateagents/controller/TsConsultantKpiController.java Ver arquivo

1
+package com.huiju.estateagents.controller;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.ExcelWriter;
5
+import com.alibaba.excel.write.metadata.WriteSheet;
6
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7
+import com.baomidou.mybatisplus.core.metadata.IPage;
8
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
9
+import com.huiju.estateagents.base.BaseController;
10
+import com.huiju.estateagents.base.ResponseBean;
11
+import com.huiju.estateagents.common.DateUtils;
12
+import com.huiju.estateagents.common.StringUtils;
13
+import com.huiju.estateagents.entity.*;
14
+import com.huiju.estateagents.excel.ConsultantKPIExport;
15
+import com.huiju.estateagents.excel.TaActivityDynamicEnlistExport;
16
+import com.huiju.estateagents.excel.handler.CustomCellWriteHandler;
17
+import org.slf4j.Logger;
18
+import org.slf4j.LoggerFactory;
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.web.bind.annotation.*;
21
+import com.huiju.estateagents.service.ITsConsultantKpiService;
22
+
23
+import javax.servlet.http.HttpServletRequest;
24
+import javax.servlet.http.HttpServletResponse;
25
+import java.time.LocalDateTime;
26
+import java.util.ArrayList;
27
+import java.util.HashMap;
28
+import java.util.List;
29
+
30
+/**
31
+ * <p>
32
+    * 置业顾问KPI  前端控制器
33
+    * </p>
34
+ *
35
+ * @author yansen
36
+ * @since 2020-04-14
37
+ */
38
+@RestController
39
+@RequestMapping("/api/admin/stats")
40
+public class TsConsultantKpiController extends BaseController {
41
+
42
+    private final Logger logger = LoggerFactory.getLogger(TsConsultantKpiController.class);
43
+
44
+    @Autowired
45
+    public ITsConsultantKpiService iTsConsultantKpiService;
46
+
47
+    /**
48
+     * 分页查询列表
49
+     * @param pageNum
50
+     * @param pageSize
51
+     * @param startDate
52
+     * @param endDate
53
+     * @param buildingId
54
+     * @param asc
55
+     * @param desc
56
+     * @param request
57
+     * @return
58
+     */
59
+    @RequestMapping(value="/consultant/kpi",method= RequestMethod.GET)
60
+    public ResponseBean tsConsultantKpiList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
+                                            @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62
+                                            // startDate 默认格式 YYYYMMDD
63
+                                            @RequestParam(value ="startDate", required = false) String startDate,
64
+                                            @RequestParam(value ="endDate", required = false) String endDate,
65
+                                            @RequestParam(value ="buildingId", required = false) String buildingId,
66
+                                            @RequestParam(value ="asc", required = false) String asc,
67
+                                            @RequestParam(value ="desc", required = false) String desc,
68
+                                            HttpServletRequest request
69
+        ){
70
+        if (null == startDate || "".equals(startDate)) {
71
+            return ResponseBean.error("开始日期不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
72
+        }
73
+        if (null == endDate || "".equals(endDate)) {
74
+            endDate = DateUtils.today();
75
+        }
76
+
77
+        Integer orgId = getOrgId(request);
78
+        try {
79
+            // 汇总明细
80
+            IPage<TsConsultantKpi> result = iTsConsultantKpiService.stsKPIDaily(pageNum, pageSize, orgId, buildingId, startDate, endDate, StringUtils.humpToLine(asc), StringUtils.humpToLine(desc));
81
+            // 汇总
82
+            TsConsultantKpi total = iTsConsultantKpiService.stsKPITotalByOrg(orgId, buildingId, startDate, endDate);
83
+            return ResponseBean.success(new HashMap<String, Object>(){{
84
+                put("paged", result);
85
+                put("total", total);
86
+            }});
87
+        }catch (Exception e){
88
+//            e.printStackTrace();
89
+            return ResponseBean.error("查询出错, 请重试 : " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
90
+        }
91
+    }
92
+
93
+
94
+    /**
95
+     * 导出
96
+     * @param startDate
97
+     * @param endDate
98
+     * @param buildingId
99
+     * @param request
100
+     * @return
101
+     */
102
+    @RequestMapping(value="/consultant/kpi",method= RequestMethod.POST)
103
+    public ResponseBean tsConsultantKpiList(// startDate 默认格式 YYYYMMDD
104
+                                            @RequestParam(value ="startDate", required = false) String startDate,
105
+                                            @RequestParam(value ="endDate", required = false) String endDate,
106
+                                            @RequestParam(value ="buildingId", required = false) String buildingId,
107
+                                            HttpServletRequest request,
108
+                                            HttpServletResponse response
109
+    ){
110
+        if (null == startDate || "".equals(startDate)) {
111
+            return ResponseBean.error("开始日期不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
112
+        }
113
+        if (null == endDate || "".equals(endDate)) {
114
+            endDate = DateUtils.today();
115
+        }
116
+
117
+        Integer orgId = getOrgId(request);
118
+        try {
119
+            response.setContentType("application/octet-stream");
120
+            response.setCharacterEncoding("utf-8");
121
+            response.setHeader("Content-disposition", "attachment;filename="+StringUtils.strToUnicode("置业顾问KPI统计")+DateUtils.today()+".xlsx");
122
+
123
+            // 汇总明细
124
+            List<ConsultantKPIExport> result = iTsConsultantKpiService.stsKPIDailyExport(orgId, buildingId, startDate, endDate);
125
+            ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), ConsultantKPIExport.class).registerWriteHandler(new CustomCellWriteHandler()).build();
126
+            WriteSheet sheet1 = EasyExcel.writerSheet("sheet1").build();
127
+            excelWriter.write(result, sheet1);
128
+            excelWriter.finish();
129
+        } catch (Exception e){
130
+//            e.printStackTrace();
131
+            return ResponseBean.error("查询出错, 请重试 : " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
132
+        }
133
+
134
+        return null;
135
+    }
136
+
137
+    private LocalDateTime[] getLocalTimeRangeBy(String startDate, String endDate) throws Exception {
138
+        LocalDateTime startTime = null;
139
+        LocalDateTime endTime = null;
140
+
141
+        if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) {
142
+            if (startDate.length() != 8 && endDate.length() != 8) {
143
+                throw new Exception("日期格式必须为YYYYMMDD");
144
+            }
145
+
146
+            startTime = DateUtils.day2LocalDateime(startDate.substring(0,4) + "-" + startDate.substring(4, 6) + "-" + startDate.substring(6, 8));
147
+            endTime = DateUtils.day2LocalDateime(endDate.substring(0,4) + "-" + endDate.substring(4, 6) + "-" + endDate.substring(6, 8));
148
+        }
149
+
150
+        return new LocalDateTime[]{startTime, endTime};
151
+    }
152
+
153
+    /**
154
+     * 查询置业的客户
155
+     * startDate 存在则统计新增客户, 不存在则统计所有
156
+     * @param pageNum
157
+     * @param pageSize
158
+     * @param buildingId
159
+     * @param userId
160
+     * @param startDate
161
+     * @param endDate
162
+     * @param request
163
+     * @return
164
+     */
165
+    @GetMapping("/consultant/customer")
166
+    public ResponseBean tsConsultantKpiList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
167
+                                            @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
168
+                                            @RequestParam(value ="buildingId", required = false) String buildingId,
169
+                                            @RequestParam(value ="userId") String userId,
170
+                                            @RequestParam(value ="startDate", required = false) String startDate,
171
+                                            @RequestParam(value ="endDate", required = false) String endDate,
172
+                                            HttpServletRequest request
173
+    ){
174
+        LocalDateTime[] dateRange = {null, null};
175
+        try {
176
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
177
+        } catch (Exception e) {
178
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
179
+        }
180
+
181
+        Integer orgId = getOrgId(request);
182
+        IPage<TaRecommendCustomer> page = new Page<>(pageNum, pageSize);
183
+        IPage<TaRecommendCustomer> result = iTsConsultantKpiService.getCustomerListOfConsultant(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
184
+        return ResponseBean.success(result);
185
+    }
186
+
187
+    /**
188
+     * 置业分享拓客
189
+     * @param pageNum
190
+     * @param pageSize
191
+     * @param buildingId
192
+     * @param userId
193
+     * @param startDate
194
+     * @param endDate
195
+     * @param request
196
+     * @return
197
+     */
198
+    @GetMapping("/consultant/share/customer")
199
+    public ResponseBean getConsultantShareCustomers(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
200
+                                                    @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
201
+                                                    @RequestParam(value ="buildingId", required = false) String buildingId,
202
+                                                    @RequestParam(value ="userId") String userId,
203
+                                                    @RequestParam(value ="startDate", required = false) String startDate,
204
+                                                    @RequestParam(value ="endDate", required = false) String endDate,
205
+                                                    HttpServletRequest request) {
206
+
207
+        LocalDateTime[] dateRange = {null, null};
208
+        try {
209
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
210
+        } catch (Exception e) {
211
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
212
+        }
213
+
214
+        Integer orgId = getOrgId(request);
215
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
216
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantShareCustomers(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
217
+        return ResponseBean.success(result);
218
+    }
219
+
220
+    /**
221
+     * 置业首页访问人数
222
+     * @param pageNum
223
+     * @param pageSize
224
+     * @param buildingId
225
+     * @param userId
226
+     * @param startDate
227
+     * @param endDate
228
+     * @param request
229
+     * @return
230
+     */
231
+    @GetMapping("/consultant/homepage/persons")
232
+    public ResponseBean getConsultantHomePagePersons(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
233
+                                                     @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
234
+                                                     @RequestParam(value ="buildingId", required = false) String buildingId,
235
+                                                     @RequestParam(value ="userId") String userId,
236
+                                                     @RequestParam(value ="startDate", required = false) String startDate,
237
+                                                     @RequestParam(value ="endDate", required = false) String endDate,
238
+                                                     HttpServletRequest request) {
239
+        LocalDateTime[] dateRange = {null, null};
240
+        try {
241
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
242
+        } catch (Exception e) {
243
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
244
+        }
245
+
246
+        Integer orgId = getOrgId(request);
247
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
248
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantHomePagePersons(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
249
+        return ResponseBean.success(result);
250
+    }
251
+
252
+    /**
253
+     * 置业首页访问次数
254
+     * @param pageNum
255
+     * @param pageSize
256
+     * @param buildingId
257
+     * @param userId
258
+     * @param startDate
259
+     * @param endDate
260
+     * @param request
261
+     * @return
262
+     */
263
+    @GetMapping("/consultant/homepage/times")
264
+    public ResponseBean getConsultantHomePageTimes(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
265
+                                                     @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
266
+                                                     @RequestParam(value ="buildingId", required = false) String buildingId,
267
+                                                     @RequestParam(value ="userId") String userId,
268
+                                                     @RequestParam(value ="startDate", required = false) String startDate,
269
+                                                     @RequestParam(value ="endDate", required = false) String endDate,
270
+                                                     HttpServletRequest request) {
271
+        LocalDateTime[] dateRange = {null, null};
272
+        try {
273
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
274
+        } catch (Exception e) {
275
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
276
+        }
277
+
278
+        Integer orgId = getOrgId(request);
279
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
280
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantHomePageTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
281
+        return ResponseBean.success(result);
282
+    }
283
+
284
+    /**
285
+     * 咨询置业次数
286
+     * @param pageNum
287
+     * @param pageSize
288
+     * @param buildingId
289
+     * @param userId
290
+     * @param startDate
291
+     * @param endDate
292
+     * @param request
293
+     * @return
294
+     */
295
+    @GetMapping("/consultant/chat/persons")
296
+    public ResponseBean getConsultantChatPersons(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
297
+                                                 @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
298
+                                                 @RequestParam(value ="buildingId", required = false) String buildingId,
299
+                                                 @RequestParam(value ="userId") String userId,
300
+                                                 @RequestParam(value ="startDate", required = false) String startDate,
301
+                                                 @RequestParam(value ="endDate", required = false) String endDate,
302
+                                                 HttpServletRequest request) {
303
+        LocalDateTime[] dateRange = {null, null};
304
+        try {
305
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
306
+        } catch (Exception e) {
307
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
308
+        }
309
+
310
+        Integer orgId = getOrgId(request);
311
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
312
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantChatPersons(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
313
+        return ResponseBean.success(result);
314
+    }
315
+
316
+    /**
317
+     * 点赞详情
318
+     * @param pageNum
319
+     * @param pageSize
320
+     * @param buildingId
321
+     * @param userId
322
+     * @param startDate
323
+     * @param endDate
324
+     * @param request
325
+     * @return
326
+     */
327
+    @GetMapping("/consultant/favor")
328
+    public ResponseBean getConsultantFavor(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
329
+                                                 @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
330
+                                                 @RequestParam(value ="buildingId", required = false) String buildingId,
331
+                                                 @RequestParam(value ="userId") String userId,
332
+                                                 @RequestParam(value ="startDate", required = false) String startDate,
333
+                                                 @RequestParam(value ="endDate", required = false) String endDate,
334
+                                                 HttpServletRequest request) {
335
+        LocalDateTime[] dateRange = {null, null};
336
+        try {
337
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
338
+        } catch (Exception e) {
339
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
340
+        }
341
+
342
+        Integer orgId = getOrgId(request);
343
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
344
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantFavor(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
345
+        return ResponseBean.success(result);
346
+    }
347
+
348
+    /**
349
+     * 置业分享次数
350
+     * @param pageNum
351
+     * @param pageSize
352
+     * @param buildingId
353
+     * @param userId
354
+     * @param startDate
355
+     * @param endDate
356
+     * @param targetType
357
+     * @param targetName
358
+     * @param request
359
+     * @return
360
+     */
361
+    @GetMapping("/consultant/share/targets")
362
+    public ResponseBean getConsultantShareTargets(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
363
+                                                   @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
364
+                                                   @RequestParam(value ="buildingId", required = false) String buildingId,
365
+                                                   @RequestParam(value ="userId") String userId,
366
+                                                   @RequestParam(value ="startDate", required = false) String startDate,
367
+                                                   @RequestParam(value ="endDate", required = false) String endDate,
368
+                                                  @RequestParam(value ="targetType", required = false) String targetType,
369
+                                                  @RequestParam(value ="targetName", required = false) String targetName,
370
+                                                   HttpServletRequest request) {
371
+        LocalDateTime[] dateRange = {null, null};
372
+        try {
373
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
374
+        } catch (Exception e) {
375
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
376
+        }
377
+
378
+        Integer orgId = getOrgId(request);
379
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
380
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantShareTargets(page, orgId, userId, buildingId, dateRange[0], dateRange[1], targetType, targetName);
381
+        return ResponseBean.success(result);
382
+    }
383
+
384
+    /**
385
+     * 置业分享访问人数
386
+     * @param pageNum
387
+     * @param pageSize
388
+     * @param buildingId
389
+     * @param userId
390
+     * @param startDate
391
+     * @param endDate
392
+     * @param request
393
+     * @return
394
+     */
395
+    @GetMapping("/consultant/share/persons")
396
+    public ResponseBean getConsultantSharePersons(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
397
+                                                  @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
398
+                                                  @RequestParam(value ="buildingId", required = false) String buildingId,
399
+                                                  @RequestParam(value ="userId") String userId,
400
+                                                  @RequestParam(value ="startDate", required = false) String startDate,
401
+                                                  @RequestParam(value ="endDate", required = false) String endDate,
402
+                                                  HttpServletRequest request) {
403
+        LocalDateTime[] dateRange = {null, null};
404
+        try {
405
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
406
+        } catch (Exception e) {
407
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
408
+        }
409
+
410
+        Integer orgId = getOrgId(request);
411
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
412
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantSharePersons(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
413
+        return ResponseBean.success(result);
414
+    }
415
+
416
+    /**
417
+     * 置业分享访问次数
418
+     * @param pageNum
419
+     * @param pageSize
420
+     * @param buildingId
421
+     * @param userId
422
+     * @param startDate
423
+     * @param endDate
424
+     * @param targetType
425
+     * @param targetName
426
+     * @param request
427
+     * @return
428
+     */
429
+    @GetMapping("/consultant/share/times")
430
+    public ResponseBean getConsultantShareTimes(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
431
+                                                  @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
432
+                                                  @RequestParam(value ="buildingId", required = false) String buildingId,
433
+                                                  @RequestParam(value ="userId") String userId,
434
+                                                  @RequestParam(value ="startDate", required = false) String startDate,
435
+                                                  @RequestParam(value ="endDate", required = false) String endDate,
436
+                                                  @RequestParam(value ="targetType", required = false) String targetType,
437
+                                                  @RequestParam(value ="targetName", required = false) String targetName,
438
+                                                  HttpServletRequest request) {
439
+        LocalDateTime[] dateRange = {null, null};
440
+        try {
441
+            dateRange = getLocalTimeRangeBy(startDate, endDate);
442
+        } catch (Exception e) {
443
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
444
+        }
445
+
446
+        Integer orgId = getOrgId(request);
447
+        IPage<TaPerson> page = new Page<>(pageNum, pageSize);
448
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantShareTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1], targetType, targetName);
449
+        return ResponseBean.success(result);
450
+    }
451
+
452
+
453
+}

+ 15
- 0
src/main/java/com/huiju/estateagents/entity/TaPerson.java Ver arquivo

312
      */
312
      */
313
     @TableField(exist = false)
313
     @TableField(exist = false)
314
     private String sceneAlias;
314
     private String sceneAlias;
315
+
316
+    /**
317
+     * 访问内容类型
318
+     */
319
+    private String targetType;
320
+
321
+    /**
322
+     * 访问内容ID
323
+     */
324
+    private String targetId;
325
+
326
+    /**
327
+     * 访问内容名称
328
+     */
329
+    private String targetName;
315
 }
330
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/entity/TaShareCount.java Ver arquivo

43
      */
43
      */
44
     private String tagertType;
44
     private String tagertType;
45
 
45
 
46
+    /**
47
+     * 对象名称
48
+     */
49
+    private String targetName;
50
+
46
     /**
51
     /**
47
      * 创建时间
52
      * 创建时间
48
      */
53
      */
49
     private LocalDateTime createDate;
54
     private LocalDateTime createDate;
50
 
55
 
56
+    /**
57
+     * orgId
58
+     */
59
+    private Integer orgId;
60
+
51
     @TableField(exist = false)
61
     @TableField(exist = false)
52
     private String shareTitle;
62
     private String shareTitle;
53
 
63
 

+ 5
- 0
src/main/java/com/huiju/estateagents/entity/TaSharePersonFrom.java Ver arquivo

56
      */
56
      */
57
     private String targetId;
57
     private String targetId;
58
 
58
 
59
+    /**
60
+     * 目标名称
61
+     */
62
+    private String targetName;
63
+
59
     /**
64
     /**
60
      * 创建时间
65
      * 创建时间
61
      */
66
      */

+ 117
- 0
src/main/java/com/huiju/estateagents/entity/TsConsultantKpi.java Ver arquivo

1
+package com.huiju.estateagents.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import lombok.Data;
8
+import lombok.EqualsAndHashCode;
9
+import lombok.experimental.Accessors;
10
+
11
+/**
12
+ * <p>
13
+ * 置业顾问KPI 
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2020-04-14
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+public class TsConsultantKpi implements Serializable {
23
+
24
+    private static final long serialVersionUID = 1L;
25
+
26
+    /**
27
+     * 序号
28
+     */
29
+    @TableId(value = "serial_no", type = IdType.AUTO)
30
+    private Integer serialNo;
31
+
32
+    /**
33
+     * 统计日期 格式YYYYMMDD
34
+     */
35
+    private String statisDate;
36
+
37
+    /**
38
+     * 公司id
39
+     */
40
+    private Integer orgId;
41
+
42
+    /**
43
+     * 楼盘id
44
+     */
45
+    private String buildingId;
46
+
47
+    /**
48
+     * 楼盘名称
49
+     */
50
+    private String buildingName;
51
+
52
+    /**
53
+     * 置业顾问ID
54
+     */
55
+    private Integer userId;
56
+
57
+    /**
58
+     * 置业顾问名称
59
+     */
60
+    private String userName;
61
+
62
+    /**
63
+     * 置业顾问手机号
64
+     */
65
+    private String phone;
66
+
67
+    /**
68
+     * 新增客户
69
+     */
70
+    private Integer newPersons;
71
+
72
+    /**
73
+     * 分享次数
74
+     */
75
+    private Integer shareNum;
76
+
77
+    /**
78
+     * 分享访问人数
79
+     */
80
+    private Integer visitPersons;
81
+
82
+    /**
83
+     * 分享访问次数
84
+     */
85
+    private Integer visitNum;
86
+
87
+    /**
88
+     * 分享拓客
89
+     */
90
+    private Integer sharePersons;
91
+
92
+    /**
93
+     * 主页访问人数
94
+     */
95
+    private Integer homePagePersons;
96
+
97
+    /**
98
+     * 主页访问次数
99
+     */
100
+    private Integer homePageNums;
101
+
102
+    /**
103
+     * 咨询数
104
+     */
105
+    private Integer chatPersons;
106
+
107
+    /**
108
+     * 点赞数
109
+     */
110
+    private Integer favorNum;
111
+
112
+    /**
113
+     * 客户总计
114
+     */
115
+    @TableField(exist = false)
116
+    private Integer totalPersons;
117
+}

+ 84
- 0
src/main/java/com/huiju/estateagents/excel/ConsultantKPIExport.java Ver arquivo

1
+package com.huiju.estateagents.excel;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import lombok.Data;
5
+
6
+@Data
7
+public class ConsultantKPIExport {
8
+
9
+    /**
10
+     * 楼盘名称
11
+     */
12
+    @ExcelProperty(value = "项目", index = 0)
13
+    private String buildingName;
14
+
15
+
16
+    /**
17
+     * 置业顾问名称
18
+     */
19
+    @ExcelProperty(value = "置业顾问名称", index = 1)
20
+    private String userName;
21
+
22
+    /**
23
+     * 置业顾问手机号
24
+     */
25
+    @ExcelProperty(value = "置业顾问电话", index = 2)
26
+    private String phone;
27
+
28
+    @ExcelProperty(value = "客户总计", index = 3)
29
+    private Integer totalPersons;
30
+
31
+    /**
32
+     * 新增客户
33
+     */
34
+    @ExcelProperty(value = "新增客户数", index = 4)
35
+    private Integer newPersons;
36
+
37
+    /**
38
+     * 分享次数
39
+     */
40
+    @ExcelProperty(value = "分享次数", index = 5)
41
+    private Integer shareNum;
42
+
43
+    /**
44
+     * 分享访问人数
45
+     */
46
+    @ExcelProperty(value = "访问人数", index = 6)
47
+    private Integer visitPersons;
48
+
49
+    /**
50
+     * 分享访问次数
51
+     */
52
+    @ExcelProperty(value = "访问次数", index = 7)
53
+    private Integer visitNum;
54
+
55
+    /**
56
+     * 分享拓客
57
+     */
58
+    @ExcelProperty(value = "分享拓客数", index = 8)
59
+    private Integer sharePersons;
60
+
61
+    /**
62
+     * 主页访问人数
63
+     */
64
+    @ExcelProperty(value = "访问主页人数", index = 9)
65
+    private Integer homePagePersons;
66
+
67
+    /**
68
+     * 主页访问次数
69
+     */
70
+    @ExcelProperty(value = "访问主页次数", index = 10)
71
+    private Integer homePageNums;
72
+
73
+    /**
74
+     * 咨询数
75
+     */
76
+    @ExcelProperty(value = "咨询数", index = 11)
77
+    private Integer chatPersons;
78
+
79
+    /**
80
+     * 点赞数
81
+     */
82
+    @ExcelProperty(value = "点赞数", index = 12)
83
+    private Integer favorNum;
84
+}

+ 8
- 0
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java Ver arquivo

191
     List<PersonIntention> getCustomerIntentions(@Param("personId")String personId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
191
     List<PersonIntention> getCustomerIntentions(@Param("personId")String personId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
192
 
192
 
193
     IPage<TaRecommendCustomer>getCustomersIRecommended(IPage<TaRecommendCustomer> page,@Param("customerId")String customerId,@Param("status")Integer status,@Param("orgId") Integer orgId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
193
     IPage<TaRecommendCustomer>getCustomersIRecommended(IPage<TaRecommendCustomer> page,@Param("customerId")String customerId,@Param("status")Integer status,@Param("orgId") Integer orgId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
194
+
195
+    IPage<TaRecommendCustomer> getCustomerListOfConsultant(IPage<TaRecommendCustomer> page,
196
+                                                           @Param("orgId") Integer orgId,
197
+                                                           @Param("userId") String userId,
198
+                                                           @Param("buildingId") String buildingId,
199
+                                                           @Param("startDate") LocalDateTime startDate,
200
+                                                           @Param("endDate") LocalDateTime endDate
201
+                                                            );
194
 }
202
 }

+ 194
- 0
src/main/java/com/huiju/estateagents/mapper/TsConsultantKpiMapper.java Ver arquivo

1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.huiju.estateagents.entity.TaPerson;
5
+import com.huiju.estateagents.entity.TaShareCount;
6
+import com.huiju.estateagents.entity.TsConsultantKpi;
7
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
8
+import com.huiju.estateagents.excel.ConsultantKPIExport;
9
+import org.apache.ibatis.annotations.Mapper;
10
+import org.apache.ibatis.annotations.Param;
11
+
12
+import java.time.LocalDateTime;
13
+import java.util.List;
14
+
15
+/**
16
+ * <p>
17
+ * 置业顾问KPI  Mapper 接口
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2020-04-14
22
+ */
23
+@Mapper
24
+public interface TsConsultantKpiMapper extends BaseMapper<TsConsultantKpi> {
25
+
26
+    IPage<TsConsultantKpi> stsKPIDaily(IPage<TsConsultantKpi> page,
27
+                                       @Param("orgId") Integer orgId,
28
+                                       @Param("buildingId") String buildingId,
29
+                                       @Param("startDate") String startDate,
30
+                                       @Param("endDate") String endDate,
31
+                                       @Param("asc") String asc,
32
+                                       @Param("desc") String desc);
33
+
34
+    TsConsultantKpi stsKPITotalByOrg(@Param("orgId") Integer orgId, @Param("buildingId") String buildingId, @Param("startDate") String startDate, @Param("endDate") String endDate);
35
+
36
+    List<ConsultantKPIExport> stsKPIDailyExport(@Param("orgId") Integer orgId, @Param("buildingId") String buildingId, @Param("startDate") String startDate, @Param("endDate") String endDate);
37
+
38
+    /**
39
+     * 统计当前时间段内的, 已经固化的置业数据的所有客户
40
+     * @param orgId
41
+     * @param buildingId
42
+     * @param startDate
43
+     * @param endDate
44
+     * @return
45
+     */
46
+    Integer stsAllCustomersByOrg(@Param("orgId") Integer orgId, @Param("buildingId") String buildingId, @Param("startDate") String startDate, @Param("endDate") String endDate);
47
+
48
+
49
+    /**
50
+     * 获取置业分享拓客
51
+     * buildingId 暂时没有用到
52
+     * @param page
53
+     * @param orgId
54
+     * @param userId
55
+     * @param buildingId
56
+     * @param startDate
57
+     * @param endDate
58
+     * @return
59
+     */
60
+    IPage<TaPerson> getConsultantShareCustomers(IPage<TaPerson> page,
61
+                                              @Param("orgId") Integer orgId,
62
+                                              @Param("userId") String userId,
63
+                                              @Param("buildingId") String buildingId,
64
+                                              @Param("startDate") LocalDateTime startDate,
65
+                                              @Param("endDate") LocalDateTime endDate);
66
+
67
+    /**
68
+     * 置业卡片访问人数明细
69
+     * @param page
70
+     * @param orgId
71
+     * @param userId
72
+     * @param buildingId
73
+     * @param startDate
74
+     * @param endDate
75
+     * @return
76
+     */
77
+    IPage<TaPerson> getConsultantHomePagePersons(IPage<TaPerson> page,
78
+                                                 @Param("orgId") Integer orgId,
79
+                                                 @Param("userId") String userId,
80
+                                                 @Param("buildingId") String buildingId,
81
+                                                 @Param("startDate") LocalDateTime startDate,
82
+                                                 @Param("endDate") LocalDateTime endDate);
83
+
84
+    /**
85
+     * 置业卡片访问次数明细
86
+     * @param page
87
+     * @param orgId
88
+     * @param userId
89
+     * @param buildingId
90
+     * @param startDate
91
+     * @param endDate
92
+     * @return
93
+     */
94
+    IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page,
95
+                                               @Param("orgId") Integer orgId,
96
+                                               @Param("userId") String userId,
97
+                                               @Param("buildingId") String buildingId,
98
+                                               @Param("startDate") LocalDateTime startDate,
99
+                                               @Param("endDate") LocalDateTime endDate);
100
+
101
+    /**
102
+     * 咨询置业人员
103
+     * @param page
104
+     * @param orgId
105
+     * @param userId
106
+     * @param buildingId
107
+     * @param startDate
108
+     * @param endDate
109
+     * @return
110
+     */
111
+    IPage<TaPerson> getConsultantChatPersons(IPage<TaPerson> page,
112
+                                             @Param("orgId") Integer orgId,
113
+                                             @Param("userId") String userId,
114
+                                             @Param("buildingId") String buildingId,
115
+                                             @Param("startDate") LocalDateTime startDate,
116
+                                             @Param("endDate") LocalDateTime endDate);
117
+
118
+    /**
119
+     * 点赞详情
120
+     * @param page
121
+     * @param orgId
122
+     * @param userId
123
+     * @param buildingId
124
+     * @param startDate
125
+     * @param endDate
126
+     * @return
127
+     */
128
+    IPage<TaPerson> getConsultantFavor(IPage<TaPerson> page,
129
+                                       @Param("orgId") Integer orgId,
130
+                                       @Param("userId") String userId,
131
+                                       @Param("buildingId") String buildingId,
132
+                                       @Param("startDate") LocalDateTime startDate,
133
+                                       @Param("endDate") LocalDateTime endDate);
134
+
135
+
136
+    /**
137
+     * 置业分享记录
138
+     * @param page
139
+     * @param orgId
140
+     * @param userId
141
+     * @param buildingId
142
+     * @param startDate
143
+     * @param endDate
144
+     * @param targetType
145
+     * @param targetName
146
+     * @return
147
+     */
148
+    IPage<TaPerson> getConsultantShareTargets(IPage<TaPerson> page,
149
+                                                  @Param("orgId") Integer orgId,
150
+                                                  @Param("userId") String userId,
151
+                                                  @Param("buildingId") String buildingId,
152
+                                                  @Param("startDate") LocalDateTime startDate,
153
+                                                  @Param("endDate") LocalDateTime endDate,
154
+                                                  @Param("targetType") String targetType,
155
+                                                  @Param("targetName") String targetName);
156
+
157
+    /**
158
+     * 置业分享访问人
159
+     * @param page
160
+     * @param orgId
161
+     * @param userId
162
+     * @param buildingId
163
+     * @param startDate
164
+     * @param endDate
165
+     * @return
166
+     */
167
+    IPage<TaPerson> getConsultantSharePersons(IPage<TaPerson> page,
168
+                                              @Param("orgId") Integer orgId,
169
+                                              @Param("userId") String userId,
170
+                                              @Param("buildingId") String buildingId,
171
+                                              @Param("startDate") LocalDateTime startDate,
172
+                                              @Param("endDate") LocalDateTime endDate);
173
+
174
+    /**
175
+     * 置业分享访问明细
176
+     * @param page
177
+     * @param orgId
178
+     * @param userId
179
+     * @param buildingId
180
+     * @param startDate
181
+     * @param endDate
182
+     * @param targetType
183
+     * @param targetName
184
+     * @return
185
+     */
186
+    IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page,
187
+                                            @Param("orgId") Integer orgId,
188
+                                            @Param("userId") String userId,
189
+                                            @Param("buildingId") String buildingId,
190
+                                            @Param("startDate") LocalDateTime startDate,
191
+                                            @Param("endDate") LocalDateTime endDate,
192
+                                            @Param("targetType") String targetType,
193
+                                            @Param("targetName") String targetName);
194
+}

+ 44
- 0
src/main/java/com/huiju/estateagents/service/ITsConsultantKpiService.java Ver arquivo

1
+package com.huiju.estateagents.service;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.huiju.estateagents.entity.*;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.huiju.estateagents.excel.ConsultantKPIExport;
7
+
8
+import java.time.LocalDateTime;
9
+import java.util.List;
10
+
11
+/**
12
+ * <p>
13
+ * 置业顾问KPI  服务类
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2020-04-14
18
+ */
19
+public interface ITsConsultantKpiService extends IService<TsConsultantKpi> {
20
+
21
+    IPage<TsConsultantKpi> stsKPIDaily(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, String startDate, String endDate, String asc, String desc);
22
+
23
+    TsConsultantKpi stsKPITotalByOrg(Integer orgId, String buildingId, String startDate, String endDate);
24
+
25
+    List<ConsultantKPIExport> stsKPIDailyExport(Integer orgId, String buildingId, String startDate, String endDate);
26
+
27
+    IPage<TaRecommendCustomer> getCustomerListOfConsultant(IPage<TaRecommendCustomer> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
28
+
29
+    IPage<TaPerson> getConsultantShareCustomers(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
30
+
31
+    IPage<TaPerson> getConsultantHomePagePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
32
+
33
+    IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
34
+
35
+    IPage<TaPerson> getConsultantChatPersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
36
+
37
+    IPage<TaPerson> getConsultantFavor(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
38
+
39
+    IPage<TaPerson> getConsultantShareTargets(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName);
40
+
41
+    IPage<TaPerson> getConsultantSharePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
42
+
43
+    IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName);
44
+}

+ 1
- 0
src/main/java/com/huiju/estateagents/service/impl/TaShareServiceImpl.java Ver arquivo

79
         taShareCount.setCreateDate(LocalDateTime.now());
79
         taShareCount.setCreateDate(LocalDateTime.now());
80
         taShareCount.setPersonId(taPerson.getPersonId());
80
         taShareCount.setPersonId(taPerson.getPersonId());
81
         taShareCount.setTagertType(typeOf);
81
         taShareCount.setTagertType(typeOf);
82
+        taShareCount.setOrgId(taPerson.getOrgId());
82
         int countRow = taShareCountMapper.insert(taShareCount);
83
         int countRow = taShareCountMapper.insert(taShareCount);
83
         if (countRow < 1) {
84
         if (countRow < 1) {
84
             return ResponseBean.error("分享增加失败", ResponseBean.ERROR_UNAVAILABLE);
85
             return ResponseBean.error("分享增加失败", ResponseBean.ERROR_UNAVAILABLE);

+ 111
- 0
src/main/java/com/huiju/estateagents/service/impl/TsConsultantKpiServiceImpl.java Ver arquivo

1
+package com.huiju.estateagents.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.huiju.estateagents.common.StringUtils;
6
+import com.huiju.estateagents.entity.*;
7
+import com.huiju.estateagents.excel.ConsultantKPIExport;
8
+import com.huiju.estateagents.mapper.TaRecommendCustomerMapper;
9
+import com.huiju.estateagents.mapper.TsConsultantKpiMapper;
10
+import com.huiju.estateagents.service.ITsConsultantKpiService;
11
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Service;
14
+
15
+import java.time.LocalDateTime;
16
+import java.util.List;
17
+
18
+/**
19
+ * <p>
20
+ * 置业顾问KPI  服务实现类
21
+ * </p>
22
+ *
23
+ * @author yansen
24
+ * @since 2020-04-14
25
+ */
26
+@Service
27
+public class TsConsultantKpiServiceImpl extends ServiceImpl<TsConsultantKpiMapper, TsConsultantKpi> implements ITsConsultantKpiService {
28
+    @Autowired
29
+    TsConsultantKpiMapper tsConsultantKpiMapper;
30
+
31
+    @Autowired
32
+    TaRecommendCustomerMapper taRecommendCustomerMapper;
33
+
34
+    @Override
35
+    public IPage<TsConsultantKpi> stsKPIDaily(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, String startDate, String endDate, String asc, String desc) {
36
+        if (StringUtils.isEmpty(asc) && StringUtils.isEmpty(desc)) {
37
+            desc = "new_persons";
38
+        }
39
+
40
+        IPage<TsConsultantKpi> page = new Page<>(pageNum, pageSize);
41
+        return tsConsultantKpiMapper.stsKPIDaily(page, orgId, buildingId, startDate, endDate, asc, desc);
42
+    }
43
+
44
+    @Override
45
+    public TsConsultantKpi stsKPITotalByOrg(Integer orgId, String buildingId, String startDate, String endDate) {
46
+        // 合计数据, 但是不包含 客户总计 列
47
+        TsConsultantKpi result = tsConsultantKpiMapper.stsKPITotalByOrg(orgId, buildingId, startDate, endDate);
48
+
49
+        // 统计当前时间段内的已经固化的置业的客户
50
+        Integer totalPersons = tsConsultantKpiMapper.stsAllCustomersByOrg(orgId, buildingId, startDate, endDate);
51
+        result.setTotalPersons(totalPersons);
52
+
53
+        return result;
54
+    }
55
+
56
+    @Override
57
+    public List<ConsultantKPIExport> stsKPIDailyExport(Integer orgId, String buildingId, String startDate, String endDate) {
58
+        return tsConsultantKpiMapper.stsKPIDailyExport(orgId, buildingId, startDate, endDate);
59
+    }
60
+
61
+    @Override
62
+    public IPage<TaRecommendCustomer> getCustomerListOfConsultant(IPage<TaRecommendCustomer> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
63
+        return taRecommendCustomerMapper.getCustomerListOfConsultant(page, orgId, userId, buildingId, startDate, endDate);
64
+    }
65
+
66
+    @Override
67
+    public IPage<TaPerson> getConsultantShareCustomers(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
68
+        // buildingId 在表里不一定有数据, 实际执行 SQL 中没有这个条件
69
+        return tsConsultantKpiMapper.getConsultantShareCustomers(page, orgId, userId, buildingId, startDate, endDate);
70
+    }
71
+
72
+    @Override
73
+    public IPage<TaPerson> getConsultantHomePagePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
74
+        return tsConsultantKpiMapper.getConsultantHomePagePersons(page, orgId, userId, buildingId, startDate, endDate);
75
+    }
76
+
77
+    @Override
78
+    public IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
79
+        return tsConsultantKpiMapper.getConsultantHomePageTimes(page, orgId, userId, buildingId, startDate, endDate);
80
+    }
81
+
82
+    @Override
83
+    public IPage<TaPerson> getConsultantChatPersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
84
+        // buildingId 在聊天表不存在, 因此没有用到这个字段
85
+        return tsConsultantKpiMapper.getConsultantChatPersons(page, orgId, userId, buildingId, startDate, endDate);
86
+    }
87
+
88
+    @Override
89
+    public IPage<TaPerson> getConsultantFavor(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
90
+        // buildingId 在点赞表不存在, 因此没有用到这个字段
91
+        return tsConsultantKpiMapper.getConsultantFavor(page, orgId, userId, buildingId, startDate, endDate);
92
+    }
93
+
94
+    @Override
95
+    public IPage<TaPerson> getConsultantShareTargets(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName) {
96
+        return tsConsultantKpiMapper.getConsultantShareTargets(page, orgId, userId, buildingId, startDate, endDate, targetType, targetName);
97
+    }
98
+
99
+    @Override
100
+    public IPage<TaPerson> getConsultantSharePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate) {
101
+        // buildingId 在表里不一定有数据, 实际执行 SQL 中没有这个条件
102
+        return tsConsultantKpiMapper.getConsultantSharePersons(page, orgId, userId, buildingId, startDate, endDate);
103
+    }
104
+
105
+    @Override
106
+    public IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName) {
107
+        // buildingId 在表里不一定有数据, 实际执行 SQL 中没有这个条件
108
+        return tsConsultantKpiMapper.getConsultantShareTimes(page, orgId, userId, buildingId, startDate, endDate, targetType, targetName);
109
+    }
110
+
111
+}

+ 17
- 0
src/main/resources/mapper/TaRecommendCustomerMapper.xml Ver arquivo

823
         </if>
823
         </if>
824
     </select>
824
     </select>
825
 
825
 
826
+    <select id="getCustomerListOfConsultant" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
827
+        select s.*, t.avatarurl
828
+        from ta_recommend_customer s
829
+        left join ta_person t on t.person_id = s.person_id
830
+        where s.org_id = #{orgId}
831
+        and s.realty_consultant = #{userId}
832
+        <if test="startDate != null">
833
+            and s.create_date BETWEEN #{startDate} and #{endDate}
834
+        </if>
835
+        <if test="buildingId != null and buildingId !=''">
836
+        and s.building_id = #{buildingId}
837
+        </if>
838
+        and s.status &gt; 0
839
+        order by s.report_date desc
840
+    </select>
841
+
842
+
826
 </mapper>
843
 </mapper>

+ 344
- 0
src/main/resources/mapper/TsConsultantKpiMapper.xml Ver arquivo

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.mapper.TsConsultantKpiMapper">
4
+
5
+    <!-- 按照项目, 置业分组统计, 注意查询与分组条件, 必须与下面的汇总,导出一致 -->
6
+    <select id="stsKPIDaily" resultType="com.huiju.estateagents.entity.TsConsultantKpi">
7
+        SELECT * FROM (
8
+            SELECT
9
+                1 AS serial_no,
10
+                '2020' AS statis_date,
11
+                t.org_id,
12
+                t.building_id,
13
+                t.building_name,
14
+                t.user_id,
15
+                t.user_name,
16
+                IFNULL(sum( t.new_persons ),0) AS new_persons,
17
+                IFNULL(sum( t.share_num ),0) AS share_num,
18
+                IFNULL(sum( t.visit_persons ),0) AS visit_persons,
19
+                IFNULL(sum( t.visit_num ),0) AS visit_num,
20
+                IFNULL(sum( t.share_persons ),0) AS share_persons,
21
+                IFNULL(sum( t.home_page_persons ),0) AS home_page_persons,
22
+                IFNULL(sum( t.home_page_nums ),0) AS home_page_nums,
23
+                IFNULL(sum( t.chat_persons ),0) AS chat_persons,
24
+                IFNULL(sum( t.favor_num ),0) AS favor_num,
25
+                (select count(DISTINCT s.customer_id) from ta_recommend_customer s
26
+                 where s.org_id = t.org_id and (s.realty_consultant = t.user_id or s.realty_consultant = m.person_id) and (s.building_id = t.building_id or IFNULL(t.building_id, '') = '') and s.status > 0) as total_persons
27
+            FROM
28
+                ts_consultant_kpi t
29
+            LEFT JOIN ta_person m on m.org_id = #{orgId} and m.user_id = t.user_id
30
+            WHERE
31
+                t.org_id = #{orgId}
32
+                AND t.statis_date BETWEEN #{startDate} AND #{endDate}
33
+            <if test="buildingId != null and buildingId != ''">
34
+                AND t.building_id = #{buildingId}
35
+            </if>
36
+            GROUP BY
37
+                t.user_id,
38
+                t.building_id
39
+        ) a
40
+
41
+        <if test="asc != null and asc != ''">
42
+            ORDER BY ${asc} asc
43
+        </if>
44
+        <if test="desc != null and desc != ''">
45
+            ORDER BY ${desc} desc
46
+        </if>
47
+    </select>
48
+
49
+    <!-- 按照小程序分组统计, 注意查询与分组条件, 必须与之前的汇总,导出一致 -->
50
+    <select id="stsKPITotalByOrg" resultType="com.huiju.estateagents.entity.TsConsultantKpi">
51
+        SELECT
52
+            1 AS serial_no,
53
+            '2020' AS statis_date,
54
+            t.org_id,
55
+            '' as building_id,
56
+            '-' as building_name,
57
+            0 as user_id,
58
+            '-' as user_name,
59
+            IFNULL(sum( t.new_persons ),0) AS new_persons,
60
+            IFNULL(sum( t.share_num ),0) AS share_num,
61
+            IFNULL(sum( t.visit_persons ),0) AS visit_persons,
62
+            IFNULL(sum( t.visit_num ),0) AS visit_num,
63
+            IFNULL(sum( t.share_persons ),0) AS share_persons,
64
+            IFNULL(sum( t.home_page_persons ),0) AS home_page_persons,
65
+            IFNULL(sum( t.home_page_nums ),0) AS home_page_nums,
66
+            IFNULL(sum( t.chat_persons ),0) AS chat_persons,
67
+            IFNULL(sum( t.favor_num ),0) AS favor_num,
68
+
69
+            <!-- 这一列单独统计 -->
70
+            0 as total_persons
71
+        FROM
72
+            ts_consultant_kpi t
73
+        WHERE
74
+            t.org_id = #{orgId}
75
+            AND t.statis_date BETWEEN #{startDate} AND #{endDate}
76
+        <if test="buildingId != null and buildingId != ''">
77
+            AND t.building_id = #{buildingId}
78
+        </if>
79
+    </select>
80
+
81
+    <!-- 导出 -->
82
+    <select id="stsKPIDailyExport" resultType="com.huiju.estateagents.excel.ConsultantKPIExport">
83
+        SELECT
84
+            1 AS serial_no,
85
+            '2020' AS statis_date,
86
+            t.org_id,
87
+            t.building_id,
88
+            t.building_name,
89
+            t.user_id,
90
+            t.user_name,
91
+            t.phone,
92
+            IFNULL(sum( t.new_persons ),0) AS new_persons,
93
+            IFNULL(sum( t.share_num ),0) AS share_num,
94
+            IFNULL(sum( t.visit_persons ),0) AS visit_persons,
95
+            IFNULL(sum( t.visit_num ),0) AS visit_num,
96
+            IFNULL(sum( t.share_persons ),0) AS share_persons,
97
+            IFNULL(sum( t.home_page_persons ),0) AS home_page_persons,
98
+            IFNULL(sum( t.home_page_nums ),0) AS home_page_nums,
99
+            IFNULL(sum( t.chat_persons ),0) AS chat_persons,
100
+            IFNULL(sum( t.favor_num ),0) AS favor_num,
101
+            (select count(DISTINCT s.customer_id) from ta_recommend_customer s
102
+             where s.org_id = t.org_id and (s.realty_consultant = t.user_id or s.realty_consultant = m.person_id) and (s.building_id = t.building_id or IFNULL(t.building_id, '') = '') and s.status > 0) as total_persons
103
+        FROM
104
+            ts_consultant_kpi t
105
+        LEFT JOIN ta_person m on m.org_id = #{orgId} and m.user_id = t.user_id
106
+        WHERE
107
+            t.org_id = #{orgId}
108
+        AND t.statis_date BETWEEN #{startDate} AND #{endDate}
109
+        <if test="buildingId != null and buildingId != ''">
110
+            AND t.building_id = #{buildingId}
111
+        </if>
112
+        GROUP BY
113
+            t.user_id,
114
+            t.building_id
115
+        ORDER BY sum( new_persons ) desc
116
+    </select>
117
+
118
+    <select id="stsAllCustomersByOrg" resultType="java.lang.Integer">
119
+        SELECT
120
+            count(DISTINCT p.customer_id)
121
+        FROM
122
+            ta_recommend_customer p
123
+        INNER JOIN ta_person s ON s.org_id = p.org_id
124
+            AND ( p.realty_consultant = s.user_id OR p.realty_consultant = s.person_id )
125
+        INNER JOIN ts_consultant_kpi t ON t.org_id = s.org_id
126
+            AND t.user_id = s.user_id
127
+            AND ( t.building_id = p.building_id OR IFNULL( t.building_id, '' ) = '' )
128
+        WHERE
129
+            p.org_id = #{orgId}
130
+            AND p.`status` > 0
131
+            AND t.statis_date BETWEEN #{startDate} AND #{endDate}
132
+        <if test="buildingId != null and buildingId != ''">
133
+            AND t.building_id = #{buildingId}
134
+        </if>
135
+    </select>
136
+
137
+    <select id="getConsultantShareCustomers" resultType="com.huiju.estateagents.entity.TaPerson">
138
+        SELECT
139
+        t.*
140
+        FROM ta_share_person_from e
141
+        INNER JOIN ta_person t ON t.person_id = e.person_id
142
+        WHERE e.org_id = #{orgId}
143
+        AND e.share_person = #{userId}
144
+        AND e.create_date BETWEEN #{startDate} and #{endDate}
145
+        <!-- building_id 字段数据不全
146
+        <if test="buildingId != null and buildingId !=''">
147
+            AND e.building_id = #{buildingId}
148
+        </if>
149
+        -->
150
+        AND e.is_first_time = 1
151
+        AND t.phone is not null
152
+
153
+<!--        为了与存储过程一致 -->
154
+<!--        AND t.`status` = 1-->
155
+        ORDER BY e.create_date DESC;
156
+    </select>
157
+
158
+    <select id="getConsultantHomePagePersons" resultType="com.huiju.estateagents.entity.TaPerson">
159
+        SELECT
160
+            t.*,
161
+            count( * ) as visit_times,
162
+            MAX(f.visit_time) as visit_time
163
+        FROM
164
+            ta_person t
165
+        INNER JOIN ta_person_visit_record f ON f.org_id = #{orgId} AND f.person_id = t.person_id
166
+        INNER JOIN ta_person s on s.person_id = f.target_id
167
+        WHERE t.org_id = #{orgId}
168
+
169
+<!--        为了与存储过程一致 -->
170
+<!--            AND t.`status` = 1-->
171
+        <if test="buildingId != null and buildingId !=''">
172
+            AND f.building_id = #{buildingId}
173
+        </if>
174
+            AND f.event_type = 'card'
175
+            AND f.visit_time BETWEEN #{startDate} and #{endDate}
176
+            AND s.user_id = #{userId}
177
+
178
+<!--        为了与存储过程一致 -->
179
+<!--            AND s.`status` = 1-->
180
+        GROUP BY t.person_id
181
+        ORDER BY t.create_date DESC;
182
+    </select>
183
+
184
+    <select id="getConsultantHomePageTimes" resultType="com.huiju.estateagents.entity.TaPerson">
185
+        SELECT
186
+            t.*,
187
+            f.visit_time as visit_time
188
+        FROM
189
+            ta_person t
190
+        INNER JOIN ta_person_visit_record f ON f.org_id = #{orgId} AND f.person_id = t.person_id
191
+        INNER JOIN ta_person s on s.person_id = f.target_id
192
+        WHERE t.org_id = #{orgId}
193
+
194
+<!--        为了与存储过程一致 -->
195
+<!--            AND t.`status` = 1-->
196
+        <if test="buildingId != null and buildingId !=''">
197
+            AND f.building_id = #{buildingId}
198
+        </if>
199
+            AND f.event_type = 'card'
200
+            AND f.visit_time BETWEEN #{startDate} and #{endDate}
201
+            AND s.user_id = #{userId}
202
+
203
+<!--        为了与存储过程一致 -->
204
+<!--            AND s.`status` = 1-->
205
+        ORDER BY t.create_date DESC;
206
+    </select>
207
+
208
+    <select id="getConsultantChatPersons" resultType="com.huiju.estateagents.entity.TaPerson">
209
+        SELECT
210
+            t.*,
211
+            max( h.create_date ) AS visit_time
212
+        FROM
213
+            ta_person t
214
+        INNER JOIN ta_chat h ON h.send_person = t.person_id
215
+        INNER JOIN ta_person s ON s.person_id = h.receive_person
216
+        WHERE t.org_id = #{orgId}
217
+
218
+<!--        为了与存储过程一致 -->
219
+<!--            AND t.`status` = 1-->
220
+            AND h.create_date BETWEEN #{startDate} and #{endDate}
221
+            AND s.user_id = #{userId}
222
+
223
+<!--        为了与存储过程一致 -->
224
+<!--            AND s.`status` = 1-->
225
+        GROUP BY
226
+            t.person_id
227
+        ORDER BY
228
+            h.create_date DESC
229
+    </select>
230
+
231
+    <select id="getConsultantFavor" resultType="com.huiju.estateagents.entity.TaPerson">
232
+        SELECT
233
+            t.*,
234
+            max( i.create_date ) AS visit_time
235
+        FROM
236
+            ta_person t
237
+        INNER JOIN ta_favor i ON i.person_id = t.person_id
238
+        INNER JOIN ta_person s ON s.person_id = i.be_favor
239
+        WHERE t.org_id = #{orgId}
240
+
241
+<!--        为了与存储过程一致 -->
242
+<!--            AND t.`status` = 1-->
243
+            AND i.tagert_type = 'consultant'
244
+            AND i.create_date BETWEEN #{startDate} and #{endDate}
245
+            AND s.user_id = #{userId}
246
+
247
+<!--        为了与存储过程一致 -->
248
+<!--            AND s.`status` = 1-->
249
+        ORDER BY
250
+            i.create_date DESC
251
+    </select>
252
+
253
+    <select id="getConsultantShareTargets" resultType="com.huiju.estateagents.entity.TaPerson">
254
+        SELECT
255
+            s.*,
256
+            t.tagert_type as target_type,
257
+            t.target_name,
258
+            t.be_share as target_id,
259
+            t.create_date as visit_time
260
+        FROM
261
+            ta_share_count t
262
+        INNER JOIN ta_person s ON s.person_id = t.person_id
263
+        WHERE
264
+            t.org_id = #{orgId}
265
+
266
+        <!-- 没有设置 targetType 查询条件, 则只查询固定的几个 -->
267
+        <if test="targetType == null or targetType ==''">
268
+            AND (
269
+            t.tagert_type IN ( 'project', 'activity', 'group', 'h5', 'help', 'news', 'main' )
270
+            OR t.tagert_type like 'house%'
271
+            OR t.tagert_type like 'live%'
272
+            )
273
+        </if>
274
+        <if test="targetType != null and targetType !=''">
275
+            AND t.tagert_type like concat(#{targetType}, '%')
276
+        </if>
277
+
278
+            AND t.create_date BETWEEN #{startDate} and #{endDate}
279
+        <if test="targetName != null and targetName !=''">
280
+            AND t.target_name LIKE concat('%', #{targetName}, '%')
281
+        </if>
282
+            AND s.user_id = #{userId}
283
+
284
+<!--        为了与存储过程一致 -->
285
+<!--            AND s.`status` = 1-->
286
+        ORDER BY t.create_date DESC
287
+    </select>
288
+
289
+    <select id="getConsultantSharePersons" resultType="com.huiju.estateagents.entity.TaPerson">
290
+        SELECT
291
+            t.*,
292
+            count(*) as visit_times,
293
+            max(e.create_date) as visit_time
294
+        FROM ta_share_person_from e
295
+        INNER JOIN ta_person t ON t.person_id = e.person_id
296
+        WHERE e.org_id = #{orgId}
297
+            AND e.share_person = #{userId}
298
+            AND e.create_date BETWEEN #{startDate} and #{endDate}
299
+            <!-- building_id 字段数据不全
300
+            <if test="buildingId != null and buildingId !=''">
301
+                AND e.building_id = #{buildingId}
302
+            </if>
303
+            -->
304
+<!--            AND t.`status` = 1-->
305
+        GROUP BY t.person_id
306
+        ORDER BY e.create_date DESC
307
+    </select>
308
+
309
+    <select id="getConsultantShareTimes" resultType="com.huiju.estateagents.entity.TaPerson">
310
+        SELECT
311
+            t.*,
312
+            e.create_date as visit_times,
313
+            e.target_type,
314
+            e.target_id,
315
+            e.target_name
316
+        FROM ta_share_person_from e
317
+        INNER JOIN ta_person t ON t.person_id = e.person_id
318
+        WHERE e.org_id = #{orgId}
319
+            AND e.share_person = #{userId}
320
+
321
+        <!-- 没有设置 targetType 查询条件, 则只查询固定的几个 -->
322
+        <if test="targetType == null or targetType ==''">
323
+            AND (
324
+            e.target_type IN ( 'building_share', 'dynamic_share', 'group_share', 'h5_share', 'help_share', 'house_share', 'live_share', 'news_share' )
325
+            OR ( e.target_type = 'share' AND e.target_id = 'index' )
326
+            )
327
+        </if>
328
+        <if test="targetType != null and targetType !=''">
329
+            AND e.target_type = 'share'
330
+        </if>
331
+        <if test="targetType != null and targetType =='share'">
332
+            AND e.target_id = 'index'
333
+        </if>
334
+
335
+            AND e.create_date BETWEEN #{startDate} and #{endDate}
336
+            <!-- building_id 字段数据不全
337
+            <if test="buildingId != null and buildingId !=''">
338
+                AND e.building_id = #{buildingId}
339
+            </if>
340
+            -->
341
+            <!--            AND t.`status` = 1-->
342
+        ORDER BY e.create_date DESC
343
+    </select>
344
+</mapper>