瀏覽代碼

修改bug数据统计相关

傅行帆 3 年之前
父節點
當前提交
7fdc1c8d24

+ 5
- 1
src/main/java/com/yunzhi/marketing/base/BaseController.java 查看文件

131
     public List<String> getInstitutionIds(HttpServletRequest request) {
131
     public List<String> getInstitutionIds(HttpServletRequest request) {
132
         TaUser taUser = taUserService.getById(getUserId(request));
132
         TaUser taUser = taUserService.getById(getUserId(request));
133
         List<Institution> list = iInstitutionService.getAllByUser(taUser);
133
         List<Institution> list = iInstitutionService.getAllByUser(taUser);
134
-        return list.stream().map(Institution::getInstitutionId).collect(Collectors.toList());
134
+        List<String> institutions = list.stream().map(Institution::getInstitutionId).collect(Collectors.toList());
135
+        if (institutions.contains("01")) {
136
+            return null;
137
+        }
138
+        return institutions;
135
     }
139
     }
136
 
140
 
137
     /**
141
     /**

+ 4
- 4
src/main/java/com/yunzhi/marketing/controller/StatisticalController.java 查看文件

77
     public ResponseBean changeNewsUserCount(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
77
     public ResponseBean changeNewsUserCount(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
78
                                             @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
78
                                             @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
79
                                             HttpServletRequest request) {
79
                                             HttpServletRequest request) {
80
-        return iStatisticalService.changeNewsUserCount(getOrgId(request), startDate, endDate);
80
+        return iStatisticalService.changeNewsUserCount(getOrgId(request), startDate, endDate,getInstitutionIds(request));
81
     }
81
     }
82
 
82
 
83
     /**
83
     /**
198
                                             @RequestParam(value = "pageSize", defaultValue = "2") Integer pageSize,
198
                                             @RequestParam(value = "pageSize", defaultValue = "2") Integer pageSize,
199
                                             @RequestParam(value = "buildingId", required = false) String buildingId,
199
                                             @RequestParam(value = "buildingId", required = false) String buildingId,
200
                                             HttpServletRequest request) {
200
                                             HttpServletRequest request) {
201
-        return iStatisticalService.selectIntentionUser(pageNum, pageSize, getOrgId(request), buildingId, getTaPersonBuildingListByUserId(request));
201
+        return iStatisticalService.selectIntentionUser(pageNum, pageSize, getOrgId(request), buildingId, getTaPersonBuildingListByUserId(request), getInstitutionIds(request));
202
     }
202
     }
203
 
203
 
204
     /**
204
     /**
228
     public ResponseBean selectPersonFrom(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
228
     public ResponseBean selectPersonFrom(@RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
229
                                          @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate endDate,
229
                                          @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate endDate,
230
                                             HttpServletRequest request) {
230
                                             HttpServletRequest request) {
231
-        return iStatisticalService.selectPersonFrom(getOrgId(request), startDate,endDate);
231
+        return iStatisticalService.selectPersonFrom(getOrgId(request), startDate,endDate,getInstitutionIds(request));
232
     }
232
     }
233
 
233
 
234
     /**
234
     /**
354
         response.setContentType("application/octet-stream");
354
         response.setContentType("application/octet-stream");
355
         response.setCharacterEncoding("utf-8");
355
         response.setCharacterEncoding("utf-8");
356
         response.setHeader("Content-disposition", "attachment;filename=新增用户.xlsx");
356
         response.setHeader("Content-disposition", "attachment;filename=新增用户.xlsx");
357
-        ResponseBean responseBean = iStatisticalService.selectPersonFrom(getOrgId(request), startDate, endDate);
357
+        ResponseBean responseBean = iStatisticalService.selectPersonFrom(getOrgId(request), startDate, endDate,getInstitutionIds(request));
358
         List<List<String>> headerList = headerList(responseBean.getData());
358
         List<List<String>> headerList = headerList(responseBean.getData());
359
         List<List<String>> dataList = dataList(responseBean.getData(),userType);
359
         List<List<String>> dataList = dataList(responseBean.getData(),userType);
360
         EasyExcel.write(response.getOutputStream()).head(headerList).sheet("新增用户").doWrite(dataList);
360
         EasyExcel.write(response.getOutputStream()).head(headerList).sheet("新增用户").doWrite(dataList);

+ 2
- 1
src/main/java/com/yunzhi/marketing/mapper/TaPersonIntentionRecordMapper.java 查看文件

35
     IPage<Map<String, Object>> selectIntentionUser(IPage<Map<String, Object>> page,
35
     IPage<Map<String, Object>> selectIntentionUser(IPage<Map<String, Object>> page,
36
                                                    @Param("orgId") Integer orgId,
36
                                                    @Param("orgId") Integer orgId,
37
                                                    @Param("buildingId") String buildingId,
37
                                                    @Param("buildingId") String buildingId,
38
-                                                   @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
38
+                                                   @Param("personBuildingList") List<TaPersonBuilding> personBuildingList,
39
+                                                   @Param("institutionIds") List<String> institutions);
39
 
40
 
40
     List<IntentionUser> selectExportIntentionUser(@Param("orgId") Integer orgId,@Param("buildingId") String buildingId,@Param("personBuildingList") List<TaPersonBuilding> taPersonBuildingListByUserId);
41
     List<IntentionUser> selectExportIntentionUser(@Param("orgId") Integer orgId,@Param("buildingId") String buildingId,@Param("personBuildingList") List<TaPersonBuilding> taPersonBuildingListByUserId);
41
 }
42
 }

+ 3
- 3
src/main/java/com/yunzhi/marketing/service/IStatisticalService.java 查看文件

109
      * @param buildingId
109
      * @param buildingId
110
      * @return
110
      * @return
111
      */
111
      */
112
-    ResponseBean selectIntentionUser(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
112
+    ResponseBean selectIntentionUser(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId,List<String> institutions);
113
 
113
 
114
     /**
114
     /**
115
      * 用户来源数据 首页
115
      * 用户来源数据 首页
118
      * @param endDate
118
      * @param endDate
119
      * @return
119
      * @return
120
      */
120
      */
121
-    ResponseBean selectPersonFrom(Integer orgId, LocalDate startDate, LocalDate endDate);
121
+    ResponseBean selectPersonFrom(Integer orgId, LocalDate startDate, LocalDate endDate,List<String> institutions);
122
 
122
 
123
     /**
123
     /**
124
      * 用户来源数据统计折线图
124
      * 用户来源数据统计折线图
214
      * @param endDate
214
      * @param endDate
215
      * @return
215
      * @return
216
      */
216
      */
217
-    ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate);
217
+    ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate,List<String> institutions);
218
 
218
 
219
     /**
219
     /**
220
      * 人员城市分布
220
      * 人员城市分布

+ 7
- 7
src/main/java/com/yunzhi/marketing/service/impl/StatisticalServiceImpl.java 查看文件

320
     }
320
     }
321
 
321
 
322
     @Override
322
     @Override
323
-    public ResponseBean selectIntentionUser(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId) {
323
+    public ResponseBean selectIntentionUser(Integer pageNum, Integer pageSize, Integer orgId, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId,List<String> institutions) {
324
         ResponseBean responseBean = new ResponseBean();
324
         ResponseBean responseBean = new ResponseBean();
325
 
325
 
326
         IPage<Map<String, Object>> pg = new Page<>(pageNum, pageSize);
326
         IPage<Map<String, Object>> pg = new Page<>(pageNum, pageSize);
327
-        IPage<Map<String, Object>> page = taPersonIntentionRecordMapper.selectIntentionUser(pg, orgId, buildingId, taPersonBuildingListByUserId);
327
+        IPage<Map<String, Object>> page = taPersonIntentionRecordMapper.selectIntentionUser(pg, orgId, buildingId, taPersonBuildingListByUserId,institutions);
328
 
328
 
329
         responseBean.addSuccess(page);
329
         responseBean.addSuccess(page);
330
         return responseBean;
330
         return responseBean;
339
      * @return
339
      * @return
340
      */
340
      */
341
     @Override
341
     @Override
342
-    public ResponseBean selectPersonFrom(Integer orgId, LocalDate startDate, LocalDate endDate) {
342
+    public ResponseBean selectPersonFrom(Integer orgId, LocalDate startDate, LocalDate endDate,List<String> institutions) {
343
         ResponseBean responseBean = new ResponseBean();
343
         ResponseBean responseBean = new ResponseBean();
344
-        List<TsPersonFromStatistic> list = tsPersonFromStatisticMapper.selectPersonFrom(orgId, startDate, endDate);
344
+        List<TsPersonFromStatistic> list = tsPersonFromStatisticMapper.selectPersonFrom(orgId, startDate, endDate,institutions);
345
         QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
345
         QueryWrapper<TdWxDict> tdWxDictQueryWrapper = new QueryWrapper<>();
346
         tdWxDictQueryWrapper.groupBy("scene_type");
346
         tdWxDictQueryWrapper.groupBy("scene_type");
347
         List<TdWxDict> tdWxDicts = tdWxDictMapper.selectList(tdWxDictQueryWrapper);
347
         List<TdWxDict> tdWxDicts = tdWxDictMapper.selectList(tdWxDictQueryWrapper);
353
         });
353
         });
354
         Map<String, Object> map = new HashMap<>();
354
         Map<String, Object> map = new HashMap<>();
355
         map.put("tdWxDicts", tdWxDicts);
355
         map.put("tdWxDicts", tdWxDicts);
356
-        List<TsPersonFromStatistic> tableList = tsPersonFromStatisticMapper.selectPersonFromGroupByData(orgId, startDate, endDate);
356
+        List<TsPersonFromStatistic> tableList = tsPersonFromStatisticMapper.selectPersonFromGroupByData(orgId, startDate, endDate,institutions);
357
         map.put("list", tableList);
357
         map.put("list", tableList);
358
         responseBean.addSuccess(map);
358
         responseBean.addSuccess(map);
359
         return responseBean;
359
         return responseBean;
585
      * @return
585
      * @return
586
      */
586
      */
587
     @Override
587
     @Override
588
-    public ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate) {
589
-        List<TsPersonFromStatistic> tableList = tsPersonFromStatisticMapper.selectNewLinePersonFromGroupByData(orgId, startDate, endDate);
588
+    public ResponseBean changeNewsUserCount(Integer orgId, LocalDate startDate, LocalDate endDate,List<String> institutions) {
589
+        List<TsPersonFromStatistic> tableList = tsPersonFromStatisticMapper.selectNewLinePersonFromGroupByData(orgId, startDate, endDate,institutions);
590
         return ResponseBean.success(tableList);
590
         return ResponseBean.success(tableList);
591
     }
591
     }
592
 
592
 

+ 1
- 1
src/main/java/com/yunzhi/marketing/statistic/controller/TsUserBehaviorStatisticController.java 查看文件

158
                                            @RequestParam(value = "org", required = false) String org,
158
                                            @RequestParam(value = "org", required = false) String org,
159
                                            HttpServletRequest request) {
159
                                            HttpServletRequest request) {
160
         Integer orgId = StringUtils.isEmpty(org) ? getOrgId(request) : Integer.valueOf(org);
160
         Integer orgId = StringUtils.isEmpty(org) ? getOrgId(request) : Integer.valueOf(org);
161
-        return iTsUserBehaviorStatisticService.selectUserBehavior(orgId, startDate, endDate, buildingId);
161
+        return iTsUserBehaviorStatisticService.selectUserBehavior(orgId, startDate, endDate, buildingId,getInstitutionIds(request));
162
     }
162
     }
163
 }
163
 }

+ 5
- 0
src/main/java/com/yunzhi/marketing/statistic/entity/TsPersonFromStatistic.java 查看文件

66
      */
66
      */
67
     @TableField(exist = false)
67
     @TableField(exist = false)
68
     private String createTime;
68
     private String createTime;
69
+
70
+    /**
71
+     * 组织机构id
72
+     */
73
+    private String institutionId;
69
 }
74
 }

+ 4
- 1
src/main/java/com/yunzhi/marketing/statistic/entity/TsUserBehaviorStatistic.java 查看文件

60
      */
60
      */
61
     private LocalDateTime createDate;
61
     private LocalDateTime createDate;
62
 
62
 
63
-
63
+    /**
64
+     * 组织机构id
65
+     */
66
+    private String institutionId;
64
 }
67
 }

+ 3
- 3
src/main/java/com/yunzhi/marketing/statistic/mapper/TsPersonFromStatisticMapper.java 查看文件

21
 
21
 
22
     void insertStatisticList(List<TsPersonFromStatistic> list);
22
     void insertStatisticList(List<TsPersonFromStatistic> list);
23
 
23
 
24
-    List<TsPersonFromStatistic> selectPersonFrom(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
24
+    List<TsPersonFromStatistic> selectPersonFrom(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate,@Param("institutionIds") List<String> institutions);
25
 
25
 
26
     List<TsPersonFromStatistic> selectPersonFromGroupByDay(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
26
     List<TsPersonFromStatistic> selectPersonFromGroupByDay(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
27
 
27
 
28
-    List<TsPersonFromStatistic> selectPersonFromGroupByData(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
28
+    List<TsPersonFromStatistic> selectPersonFromGroupByData(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate,@Param("institutionIds") List<String> institutions);
29
 
29
 
30
     void deleteByData();
30
     void deleteByData();
31
 
31
 
32
-    List<TsPersonFromStatistic> selectNewLinePersonFromGroupByData(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);
32
+    List<TsPersonFromStatistic> selectNewLinePersonFromGroupByData(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("institutionIds") List<String> institutions);
33
 }
33
 }

+ 1
- 1
src/main/java/com/yunzhi/marketing/statistic/mapper/TsUserBehaviorStatisticMapper.java 查看文件

24
 
24
 
25
     int deleteByDate();
25
     int deleteByDate();
26
 
26
 
27
-    List<PersonPO>  seleBehaviorListByDate(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, @Param("buildingId") String buildingId);
27
+    List<PersonPO>  seleBehaviorListByDate(@Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, @Param("buildingId") String buildingId,@Param("institutionIds") List<String> institutions);
28
 }
28
 }

+ 2
- 1
src/main/java/com/yunzhi/marketing/statistic/service/ITsUserBehaviorStatisticService.java 查看文件

5
 import com.yunzhi.marketing.statistic.entity.TsUserBehaviorStatistic;
5
 import com.yunzhi.marketing.statistic.entity.TsUserBehaviorStatistic;
6
 
6
 
7
 import java.time.LocalDate;
7
 import java.time.LocalDate;
8
+import java.util.List;
8
 
9
 
9
 /**
10
 /**
10
  * <p>
11
  * <p>
26
      * @param buildingId
27
      * @param buildingId
27
      * @return
28
      * @return
28
      */
29
      */
29
-    ResponseBean selectUserBehavior(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId);
30
+    ResponseBean selectUserBehavior(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<String> institutionIds);
30
 }
31
 }

+ 2
- 2
src/main/java/com/yunzhi/marketing/statistic/service/impl/TsUserBehaviorStatisticServiceImpl.java 查看文件

52
      * @return
52
      * @return
53
      */
53
      */
54
     @Override
54
     @Override
55
-    public ResponseBean selectUserBehavior(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId) {
55
+    public ResponseBean selectUserBehavior(Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<String> institutionIds) {
56
         ResponseBean responseBean = new ResponseBean();
56
         ResponseBean responseBean = new ResponseBean();
57
-        List<PersonPO> tsUserBehaviorStatistics = tsUserBehaviorStatisticMapper.seleBehaviorListByDate(orgId, startDate, endDate, buildingId);
57
+        List<PersonPO> tsUserBehaviorStatistics = tsUserBehaviorStatisticMapper.seleBehaviorListByDate(orgId, startDate, endDate, buildingId,institutionIds);
58
         Map<String, Object> map = new HashMap<>();
58
         Map<String, Object> map = new HashMap<>();
59
         map.put("selectUserBehavior", tsUserBehaviorStatistics);
59
         map.put("selectUserBehavior", tsUserBehaviorStatistics);
60
         responseBean.addSuccess(map);
60
         responseBean.addSuccess(map);

+ 5
- 2
src/main/resources/mapper/TaPersonFromRecordMapper.xml 查看文件

9
             t.event_type,
9
             t.event_type,
10
             t.org_id,
10
             t.org_id,
11
             t.create_date,
11
             t.create_date,
12
-            sum( IF ( p.phone IS NOT NULL OR p.tel IS NOT NULL, 1, 0 ) ) AS registered_num
12
+            sum( IF ( p.phone IS NOT NULL OR p.tel IS NOT NULL, 1, 0 ) ) AS registered_num,
13
+            b.institution_id
13
         FROM
14
         FROM
14
             ta_person_from_record t
15
             ta_person_from_record t
15
             LEFT JOIN ta_person p ON t.person_id = p.person_id
16
             LEFT JOIN ta_person p ON t.person_id = p.person_id
17
+            LEFT JOIN ta_building b on t.building_id = b.building_id
16
         WHERE
18
         WHERE
17
             t.is_first_time = 1
19
             t.is_first_time = 1
18
             AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ), '%Y-%m-%d' )
20
             AND DATE_FORMAT( t.create_date, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ), '%Y-%m-%d' )
19
         GROUP BY
21
         GROUP BY
20
             t.scene_type,
22
             t.scene_type,
21
             t.event_type,
23
             t.event_type,
22
-            t.org_id
24
+            t.org_id,
25
+            b.institution_id
23
     </select>
26
     </select>
24
 </mapper>
27
 </mapper>

+ 7
- 0
src/main/resources/mapper/TaPersonIntentionRecordMapper.xml 查看文件

23
         FROM
23
         FROM
24
             ta_person_intention_record tpir
24
             ta_person_intention_record tpir
25
             LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
25
             LEFT JOIN ta_person tp on tpir.person_id = tp.person_id
26
+            Left join ta_building tb on tpir.building_id = tb.building_id
26
             <trim prefix="where" prefixOverrides="and | or">
27
             <trim prefix="where" prefixOverrides="and | or">
27
                 <if test="buildingId != null and buildingId != ''">
28
                 <if test="buildingId != null and buildingId != ''">
28
                     tpir.building_id = #{buildingId}
29
                     tpir.building_id = #{buildingId}
37
                         #{personBuilding.buildingId}
38
                         #{personBuilding.buildingId}
38
                     </foreach>
39
                     </foreach>
39
                 </if>
40
                 </if>
41
+                <if test="institutionIds != null and institutionIds.size > 0">
42
+                    AND tb.institution_id in
43
+                    <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
44
+                        #{item}
45
+                    </foreach>
46
+                </if>
40
             </trim>
47
             </trim>
41
         GROUP BY
48
         GROUP BY
42
             tpir.person_id, tpir.building_id
49
             tpir.person_id, tpir.building_id

+ 20
- 3
src/main/resources/mapper/statistic/TsPersonFromStatisticMapper.xml 查看文件

3
 <mapper namespace="com.yunzhi.marketing.statistic.mapper.TsPersonFromStatisticMapper">
3
 <mapper namespace="com.yunzhi.marketing.statistic.mapper.TsPersonFromStatisticMapper">
4
 
4
 
5
     <insert id="insertStatisticList">
5
     <insert id="insertStatisticList">
6
-        INSERT INTO ts_person_from_statistic(scene_type,event_type,from_num,org_id,create_date,registered_num)
6
+        INSERT INTO ts_person_from_statistic(scene_type,event_type,from_num,org_id,create_date,registered_num,institution_id)
7
         VALUES
7
         VALUES
8
         <foreach collection="list" item="item" separator=",">
8
         <foreach collection="list" item="item" separator=",">
9
-            (#{item.sceneType},#{item.eventType},#{item.fromNum},#{item.orgId},#{item.createDate},#{item.registeredNum})
9
+            (#{item.sceneType},#{item.eventType},#{item.fromNum},#{item.orgId},#{item.createDate},#{item.registeredNum},#{item.institutionId})
10
         </foreach>
10
         </foreach>
11
     </insert>
11
     </insert>
12
     <delete id="deleteByData">
12
     <delete id="deleteByData">
24
         <if test="startDate == null or endDate == null">
24
         <if test="startDate == null or endDate == null">
25
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
25
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
26
         </if>
26
         </if>
27
-
27
+        <if test="institutionIds != null and institutionIds.size > 0">
28
+            AND tp.institution_id in
29
+            <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
30
+                #{item}
31
+            </foreach>
32
+        </if>
28
     </select>
33
     </select>
29
     <select id="selectPersonFromGroupByDay"
34
     <select id="selectPersonFromGroupByDay"
30
             resultType="com.yunzhi.marketing.statistic.entity.TsPersonFromStatistic">
35
             resultType="com.yunzhi.marketing.statistic.entity.TsPersonFromStatistic">
63
         <if test="startDate == null or endDate == null">
68
         <if test="startDate == null or endDate == null">
64
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
69
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
65
         </if>
70
         </if>
71
+        <if test="institutionIds != null and institutionIds.size > 0">
72
+            AND tp.institution_id in
73
+            <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
74
+                #{item}
75
+            </foreach>
76
+        </if>
66
         GROUP BY DATE_FORMAT( tp.create_date, '%Y-%m-%d' ), tp.scene_type ORDER BY tp.create_date
77
         GROUP BY DATE_FORMAT( tp.create_date, '%Y-%m-%d' ), tp.scene_type ORDER BY tp.create_date
67
         ) as tp on date.date = tp.create_time
78
         ) as tp on date.date = tp.create_time
68
 
79
 
93
         <if test="startDate == null or endDate == null">
104
         <if test="startDate == null or endDate == null">
94
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
105
             AND DATE_FORMAT( tp.create_date, '%Y-%m-%d' ) BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
95
         </if>
106
         </if>
107
+        <if test="institutionIds != null and institutionIds.size > 0">
108
+            AND tp.institution_id in
109
+            <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
110
+                #{item}
111
+            </foreach>
112
+        </if>
96
         GROUP BY
113
         GROUP BY
97
         DATE_FORMAT( tp.create_date, '%Y-%m-%d' )
114
         DATE_FORMAT( tp.create_date, '%Y-%m-%d' )
98
         ORDER BY tp.create_date
115
         ORDER BY tp.create_date

+ 32
- 21
src/main/resources/mapper/statistic/TsUserBehaviorStatisticMapper.xml 查看文件

7
 
7
 
8
     <select id="seleUserBehaviorList"
8
     <select id="seleUserBehaviorList"
9
             resultType="com.yunzhi.marketing.statistic.entity.TsUserBehaviorStatistic">
9
             resultType="com.yunzhi.marketing.statistic.entity.TsUserBehaviorStatistic">
10
-                SELECT
10
+        SELECT
11
             temp_date.date AS create_date,
11
             temp_date.date AS create_date,
12
             temp_date.type_name AS event_name,
12
             temp_date.type_name AS event_name,
13
             temp_date.type_id AS event_type,
13
             temp_date.type_id AS event_type,
14
             temp.activityCount AS behavior_num,
14
             temp.activityCount AS behavior_num,
15
             temp.building_id,
15
             temp.building_id,
16
-            temp.org_id
16
+            temp.org_id,
17
+            temp.institution_id
17
         FROM
18
         FROM
18
-            (
19
+        (
19
         SELECT
20
         SELECT
20
             DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
21
             DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
21
             b.type_id,
22
             b.type_id,
24
         FROM
25
         FROM
25
             sequence a,
26
             sequence a,
26
             td_biz_event_type b
27
             td_biz_event_type b
27
-            ) AS temp_date
28
-            LEFT JOIN (
29
-        SELECT
30
-            COUNT( 1 ) AS activityCount,
31
-            tpvr.event_type,
32
-            DATE_FORMAT( tpvr.visit_time, '%Y-%m-%d' ) AS date,
33
-            tpvr.building_id,
34
-            tp.org_id
35
-        FROM
36
-            ta_person tp
28
+        ) AS temp_date
29
+        LEFT JOIN (
30
+            SELECT
31
+                COUNT( 1 ) AS activityCount,
32
+                tpvr.event_type,
33
+                DATE_FORMAT( tpvr.visit_time, '%Y-%m-%d' ) AS date,
34
+                tpvr.building_id,
35
+                tp.org_id,
36
+                tb.institution_id
37
+            FROM
38
+                ta_person tp
37
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
39
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
40
+            LEFT JOIN ta_building tb on tpvr.building_id = tb.building_id
41
+            WHERE
42
+                tp.person_type IN ( 'customer', 'drift', 'estate agent' )
43
+            GROUP BY
44
+                tpvr.event_type,
45
+                DATE_FORMAT( tpvr.visit_time, '%Y-%m-%d' ),
46
+                tp.org_id,
47
+                tpvr.building_id
48
+        ) AS temp ON temp_date.date = temp.date
49
+        AND temp_date.type_id = temp.event_type
38
         WHERE
50
         WHERE
39
-            tp.person_type IN ( 'customer', 'drift', 'estate agent' )
40
-        GROUP BY
41
-            tpvr.event_type,
42
-            DATE_FORMAT( tpvr.visit_time, '%Y-%m-%d' ),
43
-            tp.org_id,
44
-            tpvr.building_id
45
-            ) AS temp ON temp_date.date = temp.date
46
-            AND temp_date.type_id = temp.event_type where temp_date.date = DATE_FORMAT( now( ), '%Y-%m-%d' )
51
+        temp_date.date = DATE_FORMAT( now( ), '%Y-%m-%d' )
47
     </select>
52
     </select>
48
     <select id="seleBehaviorListByDate"
53
     <select id="seleBehaviorListByDate"
49
             resultType="com.yunzhi.marketing.po.PersonPO">
54
             resultType="com.yunzhi.marketing.po.PersonPO">
84
             <if test="buildingId != null and buildingId != ''">
89
             <if test="buildingId != null and buildingId != ''">
85
                 and tp.building_id = #{buildingId}
90
                 and tp.building_id = #{buildingId}
86
             </if>
91
             </if>
92
+            <if test="institutionIds != null and institutionIds.size > 0">
93
+                AND tp.institution_id in
94
+                <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
95
+                    #{item}
96
+                </foreach>
97
+            </if>
87
             GROUP BY
98
             GROUP BY
88
             DATE_FORMAT( tp.create_date, '%Y-%m-%d' ),
99
             DATE_FORMAT( tp.create_date, '%Y-%m-%d' ),
89
             tp.event_type
100
             tp.event_type