傅行帆 vor 5 Jahren
Ursprung
Commit
0f2cd13444

+ 29
- 0
src/main/java/com/huiju/estateagents/controller/StatisticalController.java Datei anzeigen

@@ -244,4 +244,33 @@ public class StatisticalController extends BaseController {
244 244
         // finish 会帮忙关闭流
245 245
         excelWriter.finish();
246 246
     }
247
+
248
+    /**
249
+     * 项目排行统计图
250
+     * @return
251
+     */
252
+    @GetMapping(value = "/admin/stats/timeBarList")
253
+    public ResponseBean selectBuildingTimeBar(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
254
+                                          @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
255
+                                          @RequestParam(value = "buildingId", required = false) String buildingId,
256
+                                          HttpServletRequest request) {
257
+        return iStatisticalService.getStatsTimeBarList(getOrgId(request), startDate, endDate, buildingId, getTaPersonBuildingListByUserId(request));
258
+    }
259
+
260
+    /**
261
+     * 项目排行统计图
262
+     * @return
263
+     */
264
+    @GetMapping(value = "/admin/stats/timeTableList")
265
+    public ResponseBean selectBuildingTimeTableList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
266
+                                                @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
267
+                                                @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
268
+                                                @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
269
+                                                @RequestParam(value = "buildingId", required = false) String buildingId,
270
+                                                @RequestParam(value = "sortField", required = false) String sortField,
271
+                                                @RequestParam(value = "sortOrder", required = false) String sortOrder,
272
+                                                HttpServletRequest request) {
273
+        return iStatisticalService.getStatsTimeTableList(pageNum,pageSize,getOrgId(request), startDate, endDate,buildingId, getTaPersonBuildingListByUserId(request),sortField,sortOrder);
274
+    }
275
+
247 276
 }

+ 3
- 1
src/main/java/com/huiju/estateagents/excel/StatsBuilding.java Datei anzeigen

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.excel;
2 2
 
3
+import com.alibaba.excel.annotation.ExcelIgnore;
3 4
 import com.alibaba.excel.annotation.ExcelProperty;
4 5
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
5 6
 import lombok.Data;
@@ -50,7 +51,8 @@ public class StatsBuilding {
50 51
     private Integer pvNum;
51 52
 
52 53
 
53
-
54
+    @ExcelIgnore
55
+    private String buildingId;
54 56
 
55 57
 
56 58
 

+ 52
- 0
src/main/java/com/huiju/estateagents/excel/StatsTimeBuilding.java Datei anzeigen

@@ -0,0 +1,52 @@
1
+package com.huiju.estateagents.excel;
2
+
3
+import com.alibaba.excel.annotation.ExcelIgnore;
4
+import com.alibaba.excel.annotation.ExcelProperty;
5
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
6
+import lombok.Data;
7
+
8
+@Data
9
+public class StatsTimeBuilding {
10
+
11
+    /**
12
+     * 日期
13
+     */
14
+    @ColumnWidth(15)
15
+    @ExcelProperty(value = "日期", index = 0)
16
+    private String createDate;
17
+
18
+    /**
19
+     * 新增客户 公客加私客
20
+     */
21
+    @ColumnWidth(15)
22
+    @ExcelProperty(value = "新增客户", index = 1)
23
+    private Integer khNum;
24
+
25
+    /**
26
+     * 公客
27
+     */
28
+    @ColumnWidth(15)
29
+    @ExcelProperty(value = "公客", index = 2)
30
+    private Integer gkNum;
31
+
32
+    /**
33
+     * 私客
34
+     */
35
+    @ColumnWidth(15)
36
+    @ExcelProperty(value = "私客", index = 3)
37
+    private Integer skNum;
38
+
39
+    /**
40
+     * 观看人数
41
+     */
42
+    @ColumnWidth(15)
43
+    @ExcelProperty(value = "访问人数", index = 4)
44
+    private Integer uvNum;
45
+
46
+    @ExcelIgnore
47
+    private String buildingId;
48
+
49
+
50
+
51
+
52
+}

+ 24
- 0
src/main/java/com/huiju/estateagents/mapper/TaBuildingMapper.java Datei anzeigen

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.huiju.estateagents.entity.TaBuilding;
6 6
 import com.huiju.estateagents.entity.TaPersonBuilding;
7 7
 import com.huiju.estateagents.excel.StatsBuilding;
8
+import com.huiju.estateagents.excel.StatsTimeBuilding;
8 9
 import org.apache.ibatis.annotations.Mapper;
9 10
 import org.apache.ibatis.annotations.Param;
10 11
 import org.apache.ibatis.annotations.Update;
@@ -157,4 +158,27 @@ public interface TaBuildingMapper extends BaseMapper<TaBuilding> {
157 158
      * @return
158 159
      */
159 160
     List<StatsBuilding> getExportTableList(@Param("orgId") Integer orgId, @Param("startDate")  LocalDate startDate, @Param("endDate")  LocalDate endDate, @Param("buildingId") String buildingId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
161
+
162
+    /**
163
+     * 获取单独building的折线图数据
164
+     * @param orgId
165
+     * @param startDate
166
+     * @param endDate
167
+     * @param buildingId
168
+     * @return
169
+     */
170
+    List<StatsTimeBuilding> getStatsTimeBarList(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("buildingId") String buildingId);
171
+
172
+    /**
173
+     * 获取详情数据表格
174
+     * @param pg
175
+     * @param orgId
176
+     * @param startDate
177
+     * @param endDate
178
+     * @param buildingId
179
+     * @param sortField
180
+     * @param orderType
181
+     * @return
182
+     */
183
+    IPage<StatsTimeBuilding> getStatsTimeTableList(IPage<StatsTimeBuilding> pg,@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("buildingId") String buildingId,@Param("sortField") String sortField,@Param("orderType") String orderType);
160 184
 }

+ 26
- 0
src/main/java/com/huiju/estateagents/service/IStatisticalService.java Datei anzeigen

@@ -158,4 +158,30 @@ public interface IStatisticalService {
158 158
      * @return
159 159
      */
160 160
     List<StatsBuilding> getExportTableList(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
161
+
162
+    /**
163
+     * 按时间获取此楼盘的数据折线图
164
+     * @param orgId
165
+     * @param startDate
166
+     * @param endDate
167
+     * @param buildingId
168
+     * @param taPersonBuildingListByUserId
169
+     * @return
170
+     */
171
+    ResponseBean getStatsTimeBarList(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
172
+
173
+    /**
174
+     * 分页统计楼盘详情数据
175
+     * @param pageNum
176
+     * @param pageSize
177
+     * @param orgId
178
+     * @param startDate
179
+     * @param endDate
180
+     * @param buildingId
181
+     * @param taPersonBuildingListByUserId
182
+     * @param sortField
183
+     * @param sortOrder
184
+     * @return
185
+     */
186
+    ResponseBean getStatsTimeTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId, String sortField, String sortOrder);
161 187
 }

+ 61
- 0
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java Datei anzeigen

@@ -9,6 +9,7 @@ import com.huiju.estateagents.entity.TaPersonBuilding;
9 9
 import com.huiju.estateagents.entity.TaPersonVisitRecord;
10 10
 import com.huiju.estateagents.entity.TdWxDict;
11 11
 import com.huiju.estateagents.excel.StatsBuilding;
12
+import com.huiju.estateagents.excel.StatsTimeBuilding;
12 13
 import com.huiju.estateagents.mapper.*;
13 14
 import com.huiju.estateagents.po.PersonPO;
14 15
 import com.huiju.estateagents.service.IStatisticalService;
@@ -474,6 +475,66 @@ public class StatisticalServiceImpl implements IStatisticalService {
474 475
         return taBuildingMapper.getExportTableList(orgId, startDate, endDate, buildingId, personBuildingList);
475 476
     }
476 477
 
478
+    /**
479
+     * 按时间获取此楼盘的数据折线图
480
+     *
481
+     * @param orgId
482
+     * @param startDate
483
+     * @param endDate
484
+     * @param buildingId
485
+     * @param taPersonBuildingListByUserId
486
+     * @return
487
+     */
488
+    @Override
489
+    public ResponseBean getStatsTimeBarList(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId) {
490
+        Map<String,Object> map = new HashMap<>();
491
+        List<StatsTimeBuilding> list = taBuildingMapper.getStatsTimeBarList(orgId,startDate,endDate,buildingId);
492
+        //日期维度
493
+        List<String> timeList = list.stream().map(StatsTimeBuilding::getCreateDate).collect(Collectors.toList());
494
+        //公客维度
495
+        List<Integer> gkList = list.stream().map(StatsTimeBuilding::getGkNum).collect(Collectors.toList());
496
+        //私客维度
497
+        List<Integer> skList = list.stream().map(StatsTimeBuilding::getSkNum).collect(Collectors.toList());
498
+        //新增客户维度
499
+        List<Integer> khList = list.stream().map(StatsTimeBuilding::getKhNum).collect(Collectors.toList());
500
+        //访问人数维度
501
+        List<Integer> uvList = list.stream().map(StatsTimeBuilding::getUvNum).collect(Collectors.toList());
502
+        map.put("list",list);
503
+        map.put("timeList",timeList);
504
+        map.put("gkList",gkList);
505
+        map.put("skList",skList);
506
+        map.put("khList",khList);
507
+        map.put("uvList",uvList);
508
+        return ResponseBean.success(map);
509
+    }
510
+
511
+    /**
512
+     * 分页统计楼盘详情数据
513
+     *
514
+     * @param pageNum
515
+     * @param pageSize
516
+     * @param orgId
517
+     * @param startDate
518
+     * @param endDate
519
+     * @param buildingId
520
+     * @param taPersonBuildingListByUserId
521
+     * @param sortField
522
+     * @param sortOrder
523
+     * @return
524
+     */
525
+    @Override
526
+    public ResponseBean getStatsTimeTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId, String sortField, String sortOrder) {
527
+        String orderType = "asc";
528
+        if ("descend".equals(sortOrder)){
529
+            orderType = "desc";
530
+        }else if ("ascend".equals(sortOrder)){
531
+            orderType = "asc";
532
+        }
533
+        IPage<StatsTimeBuilding> pg = new Page<>(pageNum, pageSize);
534
+        IPage<StatsTimeBuilding> page = taBuildingMapper.getStatsTimeTableList(pg, orgId, startDate, endDate, buildingId,sortField,orderType);
535
+        return ResponseBean.success(page);
536
+    }
537
+
477 538
     /**
478 539
      * 项目公客排行折线图获取
479 540
      * @param orgId

+ 167
- 3
src/main/resources/mapper/TaBuildingMapper.xml Datei anzeigen

@@ -562,9 +562,173 @@
562 562
         <if test="buildingId != null and buildingId != '' ">
563 563
             AND t.building_id = #{buildingId}
564 564
         </if>
565
-<!--        <if test="sortField != null and sortField != ''">-->
566
-<!--            ORDER BY ${sortField} ${orderType}-->
567
-<!--        </if>-->
565
+    </select>
566
+    <select id="getStatsTimeBarList" resultType="com.huiju.estateagents.excel.StatsTimeBuilding">
567
+        SELECT
568
+            t.date as create_date,
569
+            IFNULL( s.sk_num, 0 ) AS sk_num,
570
+            IFNULL( g.gk_num, 0 ) AS gk_num,
571
+            IFNULL( u.uv_num, 0 ) AS uv_num,
572
+            IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
573
+        FROM
574
+        (
575
+            SELECT
576
+            DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
577
+            FROM
578
+            sequence a
579
+            WHERE
580
+            a.rownum &lt;= datediff( #{endDate}, #{startDate} )
581
+        ) t
582
+        LEFT JOIN (
583
+            SELECT
584
+                count( * ) AS sk_num,
585
+                a.building_id,
586
+                DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
587
+            FROM
588
+                ta_recommend_customer a
589
+            WHERE
590
+                a.STATUS > 0
591
+                AND a.verify_status = 1
592
+                AND a.realty_consultant IS NOT NULL
593
+                AND a.realty_consultant != ''
594
+                AND a.org_id = #{orgId}
595
+                AND a.building_id = #{buildingId}
596
+                <if test="startDate != null">
597
+                    and  TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
598
+                </if>
599
+                <if test="endDate != null">
600
+                    and  TO_DAYS(a.create_date) &lt;= TO_DAYS(#{endDate})
601
+                </if>
602
+            GROUP BY
603
+                DATE_FORMAT( a.create_date, '%Y-%m-%d' )
604
+        ) s ON t.date = s.create_date
605
+        LEFT JOIN (
606
+            SELECT
607
+                count( * ) AS gk_num,
608
+                b.building_id,
609
+                DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
610
+            FROM
611
+                ta_person b
612
+            WHERE
613
+                b.STATUS > 0
614
+                AND b.org_id = #{orgId}
615
+                AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
616
+                AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
617
+                AND b.building_id = #{buildingId}
618
+                <if test="startDate != null">
619
+                    and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
620
+                </if>
621
+                <if test="endDate != null">
622
+                    and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{endDate})
623
+                </if>
624
+            GROUP BY
625
+                b.person_id,
626
+                DATE_FORMAT( b.create_date, '%Y-%m-%d' )
627
+        ) g ON t.date = g.create_date
628
+        LEFT JOIN (
629
+            SELECT
630
+                count( * ) AS uv_num,
631
+                be_uv AS building_id,
632
+                DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
633
+            FROM
634
+                ta_uv
635
+            WHERE
636
+                tagert_type = 'project'
637
+                AND be_uv = #{buildingId}
638
+                <if test="startDate != null">
639
+                    and  TO_DAYS(create_date) >= TO_DAYS(#{startDate})
640
+                </if>
641
+                <if test="endDate != null">
642
+                    and  TO_DAYS(create_date) &lt;= TO_DAYS(#{endDate})
643
+                </if>
644
+            GROUP BY
645
+                DATE_FORMAT( create_date, '%Y-%m-%d' )
646
+        ) u ON t.date = u.create_date
647
+    </select>
648
+    <select id="getStatsTimeTableList" resultType="com.huiju.estateagents.excel.StatsTimeBuilding">
649
+        SELECT
650
+        t.date as create_date,
651
+        IFNULL( s.sk_num, 0 ) AS sk_num,
652
+        IFNULL( g.gk_num, 0 ) AS gk_num,
653
+        IFNULL( u.uv_num, 0 ) AS uv_num,
654
+        IFNULL( s.sk_num, 0 ) + IFNULL( g.gk_num, 0 ) AS kh_num
655
+        FROM
656
+        (
657
+        SELECT
658
+        DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
659
+        FROM
660
+        sequence a
661
+        WHERE
662
+        a.rownum &lt;= datediff( #{endDate}, #{startDate} )
663
+        ) t
664
+        LEFT JOIN (
665
+        SELECT
666
+        count( * ) AS sk_num,
667
+        a.building_id,
668
+        DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS create_date
669
+        FROM
670
+        ta_recommend_customer a
671
+        WHERE
672
+        a.STATUS > 0
673
+        AND a.verify_status = 1
674
+        AND a.realty_consultant IS NOT NULL
675
+        AND a.realty_consultant != ''
676
+        AND a.org_id = #{orgId}
677
+        AND a.building_id = #{buildingId}
678
+        <if test="startDate != null">
679
+            and  TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
680
+        </if>
681
+        <if test="endDate != null">
682
+            and  TO_DAYS(a.create_date) &lt;= TO_DAYS(#{endDate})
683
+        </if>
684
+        GROUP BY
685
+        DATE_FORMAT( a.create_date, '%Y-%m-%d' )
686
+        ) s ON t.date = s.create_date
687
+        LEFT JOIN (
688
+        SELECT
689
+        count( * ) AS gk_num,
690
+        b.building_id,
691
+        DATE_FORMAT( b.create_date, '%Y-%m-%d' ) AS create_date
692
+        FROM
693
+        ta_person b
694
+        WHERE
695
+        b.STATUS > 0
696
+        AND b.org_id = #{orgId}
697
+        AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
698
+        AND b.person_id NOT IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = 84 AND person_id IS NOT NULL AND person_id != '' )
699
+        AND b.building_id = #{buildingId}
700
+        <if test="startDate != null">
701
+            and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
702
+        </if>
703
+        <if test="endDate != null">
704
+            and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{endDate})
705
+        </if>
706
+        GROUP BY
707
+        b.person_id,
708
+        DATE_FORMAT( b.create_date, '%Y-%m-%d' )
709
+        ) g ON t.date = g.create_date
710
+        LEFT JOIN (
711
+        SELECT
712
+        count( * ) AS uv_num,
713
+        be_uv AS building_id,
714
+        DATE_FORMAT( create_date, '%Y-%m-%d' ) AS create_date
715
+        FROM
716
+        ta_uv
717
+        WHERE
718
+        tagert_type = 'project'
719
+        AND be_uv = #{buildingId}
720
+        <if test="startDate != null">
721
+            and  TO_DAYS(create_date) >= TO_DAYS(#{startDate})
722
+        </if>
723
+        <if test="endDate != null">
724
+            and  TO_DAYS(create_date) &lt;= TO_DAYS(#{endDate})
725
+        </if>
726
+        GROUP BY
727
+        DATE_FORMAT( create_date, '%Y-%m-%d' )
728
+        ) u ON t.date = u.create_date
729
+        <if test="sortField != null and sortField != ''">
730
+            ORDER BY ${sortField} ${orderType}
731
+        </if>
568 732
     </select>
569 733
 
570 734
 </mapper>