Преглед изворни кода

新增用户折线统计图

傅行帆 пре 5 година
родитељ
комит
e75a5029fb

+ 31
- 0
src/main/java/com/huiju/estateagents/controller/StatisticalController.java Прегледај датотеку

@@ -5,6 +5,7 @@ import com.alibaba.excel.ExcelWriter;
5 5
 import com.alibaba.excel.write.metadata.WriteSheet;
6 6
 import com.huiju.estateagents.base.BaseController;
7 7
 import com.huiju.estateagents.base.ResponseBean;
8
+import com.huiju.estateagents.excel.IntentionUser;
8 9
 import com.huiju.estateagents.excel.StatsBuilding;
9 10
 import com.huiju.estateagents.excel.StatsTimeBuilding;
10 11
 import com.huiju.estateagents.excel.handler.CustomCellWriteHandler;
@@ -64,6 +65,17 @@ public class StatisticalController extends BaseController {
64 65
         return iStatisticalService.selectNewsUserCount(getOrgId(request), startDate, endDate);
65 66
     }
66 67
 
68
+    /**
69
+     * 新增用户数
70
+     * @return
71
+     */
72
+    @GetMapping(value = "/admin/changeNewsUserCount")
73
+    public ResponseBean changeNewsUserCount(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
74
+                                            @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
75
+                                            HttpServletRequest request) {
76
+        return iStatisticalService.changeNewsUserCount(getOrgId(request), startDate, endDate);
77
+    }
78
+
67 79
     /**
68 80
      * 转化率 统计
69 81
      * @return
@@ -175,6 +187,25 @@ public class StatisticalController extends BaseController {
175 187
         return iStatisticalService.selectIntentionUser(pageNum, pageSize, getOrgId(request), buildingId, getTaPersonBuildingListByUserId(request));
176 188
     }
177 189
 
190
+    /**
191
+     * 意向用户 导出
192
+     * @return
193
+     */
194
+    @GetMapping(value = "/admin/exportIntentionUser")
195
+    public void getBuildingTimeTableList(@RequestParam(value = "buildingId", required = false) String buildingId,
196
+                                         HttpServletRequest request, HttpServletResponse response) throws IOException {
197
+        response.setContentType("application/octet-stream");
198
+        response.setCharacterEncoding("utf-8");
199
+        response.setHeader("Content-disposition", "attachment;filename=意向客户.xlsx");
200
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), IntentionUser.class).registerWriteHandler(new CustomCellWriteHandler()).build();
201
+        // 设置 sheet, 同一个sheet只需要设置一次
202
+        WriteSheet writeSheet = EasyExcel.writerSheet("项目详情统计").build();
203
+        List<IntentionUser> list = iStatisticalService.getExportIntentionUser(getOrgId(request), buildingId, getTaPersonBuildingListByUserId(request));
204
+        excelWriter.write(list, writeSheet);
205
+        // finish 会帮忙关闭流
206
+        excelWriter.finish();
207
+    }
208
+
178 209
     /**
179 210
      * 用户来源  首页
180 211
      * @return

+ 38
- 0
src/main/java/com/huiju/estateagents/excel/IntentionUser.java Прегледај датотеку

@@ -0,0 +1,38 @@
1
+package com.huiju.estateagents.excel;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+@Data
8
+public class IntentionUser {
9
+
10
+    /**
11
+     * 用户姓名
12
+     */
13
+    @ColumnWidth(15)
14
+    @ExcelProperty(value = "用户姓名", index = 0)
15
+    private String personName;
16
+
17
+    /**
18
+     * 手机号
19
+     */
20
+    @ColumnWidth(15)
21
+    @ExcelProperty(value = "手机号", index = 1)
22
+    private String phone;
23
+
24
+    /**
25
+     * 意向楼盘
26
+     */
27
+    @ColumnWidth(15)
28
+    @ExcelProperty(value = "意向楼盘", index = 2)
29
+    private String buildingName;
30
+
31
+    /**
32
+     * 意向值
33
+     */
34
+    @ColumnWidth(15)
35
+    @ExcelProperty(value = "意向值", index = 3)
36
+    private Integer intention;
37
+
38
+}

+ 3
- 0
src/main/java/com/huiju/estateagents/mapper/TaPersonIntentionRecordMapper.java Прегледај датотеку

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.huiju.estateagents.entity.TaPersonBuilding;
7 7
 import com.huiju.estateagents.entity.TaPersonIntentionRecord;
8
+import com.huiju.estateagents.excel.IntentionUser;
8 9
 import org.apache.ibatis.annotations.Mapper;
9 10
 import org.apache.ibatis.annotations.Param;
10 11
 
@@ -35,4 +36,6 @@ public interface TaPersonIntentionRecordMapper extends BaseMapper<TaPersonIntent
35 36
                                                    @Param("orgId") Integer orgId,
36 37
                                                    @Param("buildingId") String buildingId,
37 38
                                                    @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
39
+
40
+    List<IntentionUser> selectExportIntentionUser(@Param("orgId") Integer orgId,@Param("buildingId") String buildingId,@Param("personBuildingList") List<TaPersonBuilding> taPersonBuildingListByUserId);
38 41
 }

+ 9
- 4
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java Прегледај датотеку

@@ -1,17 +1,15 @@
1 1
 package com.huiju.estateagents.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.huiju.estateagents.entity.TaChannel;
5 6
 import com.huiju.estateagents.entity.TaPerson;
6
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
7 7
 import com.huiju.estateagents.entity.TaPersonPositon;
8 8
 import com.huiju.estateagents.po.PersonPO;
9
-import io.swagger.models.auth.In;
10 9
 import org.apache.ibatis.annotations.*;
11 10
 
12
-import java.io.Serializable;
13 11
 import java.time.LocalDate;
14
-import java.util.Date;
12
+import java.time.LocalDateTime;
15 13
 import java.util.List;
16 14
 import java.util.Map;
17 15
 
@@ -249,4 +247,11 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
249 247
      * @return
250 248
      */
251 249
     Integer savePersonPosition(TaPersonPositon record);
250
+
251
+    /**
252
+     * 今日新增人数
253
+     * @param orgId
254
+     * @return
255
+     */
256
+    Integer selectTodayRecentlyCount(@Param("orgId") Integer orgId, @Param("nowDate") LocalDateTime nowDate);
252 257
 }

+ 19
- 0
src/main/java/com/huiju/estateagents/service/IStatisticalService.java Прегледај датотеку

@@ -2,6 +2,7 @@ package com.huiju.estateagents.service;
2 2
 
3 3
 import com.huiju.estateagents.base.ResponseBean;
4 4
 import com.huiju.estateagents.entity.TaPersonBuilding;
5
+import com.huiju.estateagents.excel.IntentionUser;
5 6
 import com.huiju.estateagents.excel.StatsBuilding;
6 7
 import com.huiju.estateagents.excel.StatsTimeBuilding;
7 8
 
@@ -196,4 +197,22 @@ public interface IStatisticalService {
196 197
      * @return
197 198
      */
198 199
     List<StatsTimeBuilding> getExportTimeTableList(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
200
+
201
+    /**
202
+     * 意向客户导出
203
+     * @param orgId
204
+     * @param buildingId
205
+     * @param taPersonBuildingListByUserId
206
+     * @return
207
+     */
208
+    List<IntentionUser> getExportIntentionUser(Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
209
+
210
+    /**
211
+     * 新调整--新增用户
212
+     * @param orgId
213
+     * @param startDate
214
+     * @param endDate
215
+     * @return
216
+     */
217
+    ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate);
199 218
 }

+ 31
- 2
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java Прегледај датотеку

@@ -8,6 +8,7 @@ import com.huiju.estateagents.common.CommConstant;
8 8
 import com.huiju.estateagents.entity.TaPersonBuilding;
9 9
 import com.huiju.estateagents.entity.TaPersonVisitRecord;
10 10
 import com.huiju.estateagents.entity.TdWxDict;
11
+import com.huiju.estateagents.excel.IntentionUser;
11 12
 import com.huiju.estateagents.excel.StatsBuilding;
12 13
 import com.huiju.estateagents.excel.StatsTimeBuilding;
13 14
 import com.huiju.estateagents.mapper.*;
@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
20 21
 import org.springframework.stereotype.Service;
21 22
 
22 23
 import java.time.LocalDate;
24
+import java.time.LocalDateTime;
23 25
 import java.time.format.DateTimeFormatter;
24 26
 import java.time.temporal.ChronoUnit;
25 27
 import java.util.ArrayList;
@@ -74,8 +76,8 @@ public class StatisticalServiceImpl implements IStatisticalService {
74 76
         // 注册数
75 77
         Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId);
76 78
 
77
-        // 最近七天
78
-        Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT, null, null);
79
+        // 最近七天--> 调整为今日新增
80
+        Integer selectRecentlyCount = taPersonMapper.selectTodayRecentlyCount(orgId, LocalDateTime.now());
79 81
 
80 82
         // -------  用户来源 end ------------
81 83
 
@@ -550,6 +552,33 @@ public class StatisticalServiceImpl implements IStatisticalService {
550 552
         return taBuildingMapper.getStatsTimeBarList(orgId,startDate,endDate,buildingId);
551 553
     }
552 554
 
555
+    /**
556
+     * 意向客户导出
557
+     *
558
+     * @param orgId
559
+     * @param buildingId
560
+     * @param taPersonBuildingListByUserId
561
+     * @return
562
+     */
563
+    @Override
564
+    public List<IntentionUser> getExportIntentionUser(Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId) {
565
+        return taPersonIntentionRecordMapper.selectExportIntentionUser(orgId, buildingId, taPersonBuildingListByUserId);
566
+    }
567
+
568
+    /**
569
+     * 新调整--新增用户
570
+     *
571
+     * @param orgId
572
+     * @param startDate
573
+     * @param endDate
574
+     * @return
575
+     */
576
+    @Override
577
+    public ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate) {
578
+        List<TsPersonFromStatistic> tableList = tsPersonFromStatisticMapper.selectNewLinePersonFromGroupByData(orgId, startDate, endDate);
579
+        return ResponseBean.success(tableList);
580
+    }
581
+
553 582
     /**
554 583
      * 项目公客排行折线图获取
555 584
      * @param orgId

+ 2
- 0
src/main/java/com/huiju/estateagents/statistic/mapper/TsPersonFromStatisticMapper.java Прегледај датотеку

@@ -28,4 +28,6 @@ public interface TsPersonFromStatisticMapper extends BaseMapper<TsPersonFromStat
28 28
     List<TsPersonFromStatistic> selectPersonFromGroupByData(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
29 29
 
30 30
     void deleteByData();
31
+
32
+    List<TsPersonFromStatistic> selectNewLinePersonFromGroupByData(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);
31 33
 }

+ 28
- 0
src/main/resources/mapper/TaPersonIntentionRecordMapper.xml Прегледај датотеку

@@ -42,4 +42,32 @@
42 42
             tpir.person_id, tpir.building_id
43 43
         ORDER BY SUM(tpir.intention) DESC
44 44
     </select>
45
+    <select id="selectExportIntentionUser" resultType="com.huiju.estateagents.excel.IntentionUser">
46
+        SELECT
47
+        tpir.person_name as  person_name,
48
+        tp.phone as phone,
49
+        tpir.building_name as building_name,
50
+        SUM(tpir.intention) as intention
51
+        FROM
52
+        ta_person_intention_record tpir
53
+        LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
54
+        <trim prefix="where" prefixOverrides="and | or">
55
+            <if test="buildingId != null and buildingId != ''">
56
+                tpir.building_id = #{buildingId}
57
+            </if>
58
+            <if test="orgId != null">
59
+                AND tpir.org_id = #{orgId}
60
+                AND tp.org_id = #{orgId}
61
+            </if>
62
+            <if test="personBuildingList != null and personBuildingList.size > 0">
63
+                AND tpir.building_id in
64
+                <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
65
+                    #{personBuilding.buildingId}
66
+                </foreach>
67
+            </if>
68
+        </trim>
69
+        GROUP BY
70
+        tpir.person_id, tpir.building_id
71
+        ORDER BY SUM(tpir.intention) DESC
72
+    </select>
45 73
 </mapper>

+ 9
- 0
src/main/resources/mapper/TaPersonMapper.xml Прегледај датотеку

@@ -605,6 +605,15 @@ FROM
605 605
             </if>
606 606
                 GROUP BY t.person_id) d
607 607
     </select>
608
+    <select id="selectTodayRecentlyCount" resultType="java.lang.Integer">
609
+        SELECT
610
+            COUNT(1) as activity_count
611
+        FROM
612
+        ta_person tp
613
+        where tp.org_id = #{orgId} AND
614
+        tp.person_type IN ('customer','drift','estate agent')
615
+        AND DATE_FORMAT(tp.create_date,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
616
+    </select>
608 617
 
609 618
     <insert id="savePersonPosition" parameterType="com.huiju.estateagents.entity.TaPersonPositon">
610 619
         insert into ta_person_position

+ 23
- 0
src/main/resources/mapper/statistic/TsPersonFromStatisticMapper.xml Прегледај датотеку

@@ -66,4 +66,27 @@
66 66
         DATE_FORMAT( tp.create_date, '%Y-%m-%d' ),
67 67
         tp.scene_type
68 68
     </select>
69
+    <select id="selectNewLinePersonFromGroupByData"
70
+            resultType="com.huiju.estateagents.statistic.entity.TsPersonFromStatistic">
71
+        SELECT
72
+        sum( tp.from_num ) AS from_num,
73
+        sum( tp.registered_num ) AS registered_num,
74
+        DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) AS create_time,
75
+        tp.scene_type
76
+        FROM
77
+        ts_person_from_statistic tp
78
+        WHERE
79
+        tp.org_id = #{orgId}
80
+        and tp.scene_type != ''
81
+        and tp.scene_type is not null
82
+        <if test="startDate != null or endDate != null">
83
+            AND  DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN #{startDate} and #{endDate}
84
+        </if>
85
+        <if test="startDate == null or endDate == null">
86
+            AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
87
+        </if>
88
+        GROUP BY
89
+        DATE_FORMAT( tp.create_date, '%Y-%m-%d' )
90
+        ORDER BY tp.create_date
91
+    </select>
69 92
 </mapper>