张延森 5 лет назад
Родитель
Сommit
bb098d8610

+ 13
- 5
src/main/java/com/huiju/estateagents/controller/TsConsultantKpiController.java Просмотреть файл

57
      * @return
57
      * @return
58
      */
58
      */
59
     @RequestMapping(value="/consultant/kpi",method= RequestMethod.GET)
59
     @RequestMapping(value="/consultant/kpi",method= RequestMethod.GET)
60
-    public ResponseBean tsConsultantKpiList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
60
+    public ResponseBean stsConsultantKpiList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
                                             @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
61
                                             @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62
                                             // startDate 默认格式 YYYYMMDD
62
                                             // startDate 默认格式 YYYYMMDD
63
                                             @RequestParam(value ="startDate", required = false) String startDate,
63
                                             @RequestParam(value ="startDate", required = false) String startDate,
100
      * @return
100
      * @return
101
      */
101
      */
102
     @RequestMapping(value="/consultant/kpi",method= RequestMethod.POST)
102
     @RequestMapping(value="/consultant/kpi",method= RequestMethod.POST)
103
-    public ResponseBean tsConsultantKpiList(// startDate 默认格式 YYYYMMDD
103
+    public ResponseBean stsConsultantKpiExport(// startDate 默认格式 YYYYMMDD
104
                                             @RequestParam(value ="startDate", required = false) String startDate,
104
                                             @RequestParam(value ="startDate", required = false) String startDate,
105
                                             @RequestParam(value ="endDate", required = false) String endDate,
105
                                             @RequestParam(value ="endDate", required = false) String endDate,
106
                                             @RequestParam(value ="buildingId", required = false) String buildingId,
106
                                             @RequestParam(value ="buildingId", required = false) String buildingId,
163
      * @return
163
      * @return
164
      */
164
      */
165
     @GetMapping("/consultant/customer")
165
     @GetMapping("/consultant/customer")
166
-    public ResponseBean tsConsultantKpiList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
166
+    public ResponseBean getConsultantCustomers(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
167
                                             @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
167
                                             @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
168
                                             @RequestParam(value ="buildingId", required = false) String buildingId,
168
                                             @RequestParam(value ="buildingId", required = false) String buildingId,
169
                                             @RequestParam(value ="userId") String userId,
169
                                             @RequestParam(value ="userId") String userId,
267
                                                      @RequestParam(value ="userId") String userId,
267
                                                      @RequestParam(value ="userId") String userId,
268
                                                      @RequestParam(value ="startDate", required = false) String startDate,
268
                                                      @RequestParam(value ="startDate", required = false) String startDate,
269
                                                      @RequestParam(value ="endDate", required = false) String endDate,
269
                                                      @RequestParam(value ="endDate", required = false) String endDate,
270
+                                                   @RequestParam(value ="personId", required = false) String personId,
270
                                                      HttpServletRequest request) {
271
                                                      HttpServletRequest request) {
271
         LocalDateTime[] dateRange = {null, null};
272
         LocalDateTime[] dateRange = {null, null};
272
         try {
273
         try {
277
 
278
 
278
         Integer orgId = getOrgId(request);
279
         Integer orgId = getOrgId(request);
279
         IPage<TaPerson> page = new Page<>(pageNum, pageSize);
280
         IPage<TaPerson> page = new Page<>(pageNum, pageSize);
280
-        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantHomePageTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1]);
281
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantHomePageTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1], personId);
281
         return ResponseBean.success(result);
282
         return ResponseBean.success(result);
282
     }
283
     }
283
 
284
 
435
                                                   @RequestParam(value ="endDate", required = false) String endDate,
436
                                                   @RequestParam(value ="endDate", required = false) String endDate,
436
                                                   @RequestParam(value ="targetType", required = false) String targetType,
437
                                                   @RequestParam(value ="targetType", required = false) String targetType,
437
                                                   @RequestParam(value ="targetName", required = false) String targetName,
438
                                                   @RequestParam(value ="targetName", required = false) String targetName,
439
+                                                @RequestParam(value ="userName", required = false) String userName,
440
+                                                @RequestParam(value ="personId", required = false) String personId,
438
                                                   HttpServletRequest request) {
441
                                                   HttpServletRequest request) {
439
         LocalDateTime[] dateRange = {null, null};
442
         LocalDateTime[] dateRange = {null, null};
440
         try {
443
         try {
443
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
446
             return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_ILLEGAL_PARAMS);
444
         }
447
         }
445
 
448
 
449
+        // 如果 personId 与 userName 同时存在, 以 personId 为准
450
+        if (!StringUtils.isEmpty(personId)) {
451
+            userName = null;
452
+        }
453
+
446
         Integer orgId = getOrgId(request);
454
         Integer orgId = getOrgId(request);
447
         IPage<TaPerson> page = new Page<>(pageNum, pageSize);
455
         IPage<TaPerson> page = new Page<>(pageNum, pageSize);
448
-        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantShareTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1], targetType, targetName);
456
+        IPage<TaPerson> result = iTsConsultantKpiService.getConsultantShareTimes(page, orgId, userId, buildingId, dateRange[0], dateRange[1], targetType, targetName, userName, personId);
449
         return ResponseBean.success(result);
457
         return ResponseBean.success(result);
450
     }
458
     }
451
 
459
 

+ 1
- 2
src/main/java/com/huiju/estateagents/mapper/TaRecommendCustomerMapper.java Просмотреть файл

197
                                                            @Param("userId") String userId,
197
                                                            @Param("userId") String userId,
198
                                                            @Param("buildingId") String buildingId,
198
                                                            @Param("buildingId") String buildingId,
199
                                                            @Param("startDate") LocalDateTime startDate,
199
                                                            @Param("startDate") LocalDateTime startDate,
200
-                                                           @Param("endDate") LocalDateTime endDate
201
-                                                            );
200
+                                                           @Param("endDate") LocalDateTime endDate);
202
 }
201
 }

+ 5
- 2
src/main/java/com/huiju/estateagents/mapper/TsConsultantKpiMapper.java Просмотреть файл

96
                                                @Param("userId") String userId,
96
                                                @Param("userId") String userId,
97
                                                @Param("buildingId") String buildingId,
97
                                                @Param("buildingId") String buildingId,
98
                                                @Param("startDate") LocalDateTime startDate,
98
                                                @Param("startDate") LocalDateTime startDate,
99
-                                               @Param("endDate") LocalDateTime endDate);
99
+                                               @Param("endDate") LocalDateTime endDate,
100
+                                               @Param("personId") String personId);
100
 
101
 
101
     /**
102
     /**
102
      * 咨询置业人员
103
      * 咨询置业人员
190
                                             @Param("startDate") LocalDateTime startDate,
191
                                             @Param("startDate") LocalDateTime startDate,
191
                                             @Param("endDate") LocalDateTime endDate,
192
                                             @Param("endDate") LocalDateTime endDate,
192
                                             @Param("targetType") String targetType,
193
                                             @Param("targetType") String targetType,
193
-                                            @Param("targetName") String targetName);
194
+                                            @Param("targetName") String targetName,
195
+                                            @Param("userName") String userName,
196
+                                            @Param("personId") String personId);
194
 }
197
 }

+ 2
- 2
src/main/java/com/huiju/estateagents/service/ITsConsultantKpiService.java Просмотреть файл

30
 
30
 
31
     IPage<TaPerson> getConsultantHomePagePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
31
     IPage<TaPerson> getConsultantHomePagePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
32
 
32
 
33
-    IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
33
+    IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String personId);
34
 
34
 
35
     IPage<TaPerson> getConsultantChatPersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
35
     IPage<TaPerson> getConsultantChatPersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
36
 
36
 
40
 
40
 
41
     IPage<TaPerson> getConsultantSharePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
41
     IPage<TaPerson> getConsultantSharePersons(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate);
42
 
42
 
43
-    IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName);
43
+    IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName, String userName, String personId);
44
 }
44
 }

+ 4
- 4
src/main/java/com/huiju/estateagents/service/impl/TsConsultantKpiServiceImpl.java Просмотреть файл

75
     }
75
     }
76
 
76
 
77
     @Override
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);
78
+    public IPage<TaPerson> getConsultantHomePageTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String personId) {
79
+        return tsConsultantKpiMapper.getConsultantHomePageTimes(page, orgId, userId, buildingId, startDate, endDate, personId);
80
     }
80
     }
81
 
81
 
82
     @Override
82
     @Override
103
     }
103
     }
104
 
104
 
105
     @Override
105
     @Override
106
-    public IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName) {
106
+    public IPage<TaPerson> getConsultantShareTimes(IPage<TaPerson> page, Integer orgId, String userId, String buildingId, LocalDateTime startDate, LocalDateTime endDate, String targetType, String targetName, String userName, String personId) {
107
         // buildingId 在表里不一定有数据, 实际执行 SQL 中没有这个条件
107
         // buildingId 在表里不一定有数据, 实际执行 SQL 中没有这个条件
108
-        return tsConsultantKpiMapper.getConsultantShareTimes(page, orgId, userId, buildingId, startDate, endDate, targetType, targetName);
108
+        return tsConsultantKpiMapper.getConsultantShareTimes(page, orgId, userId, buildingId, startDate, endDate, targetType, targetName, userName, personId);
109
     }
109
     }
110
 
110
 
111
 }
111
 }

+ 1
- 1
src/main/resources/application-blue.yml Просмотреть файл

6
   datasource:
6
   datasource:
7
     username: root
7
     username: root
8
     password: LUfZGvh7j1^qA*2c
8
     password: LUfZGvh7j1^qA*2c
9
-    url: jdbc:mysql://123.57.65.31:3306/estateagents_test?useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&zeroDateTimeBehavior=convertToNull
9
+    url: jdbc:mysql://123.57.65.31:3306/estateagents_20200417?useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&zeroDateTimeBehavior=convertToNull
10
     driver-class-name: com.mysql.cj.jdbc.Driver
10
     driver-class-name: com.mysql.cj.jdbc.Driver
11
     initial-size: 10 # 初始化连接数
11
     initial-size: 10 # 初始化连接数
12
     max-active: 20 # 最大连接数
12
     max-active: 20 # 最大连接数

+ 20
- 8
src/main/resources/mapper/TsConsultantKpiMapper.xml Просмотреть файл

13
                 t.building_name,
13
                 t.building_name,
14
                 t.user_id,
14
                 t.user_id,
15
                 t.user_name,
15
                 t.user_name,
16
+                t.phone,
16
                 IFNULL(sum( t.new_persons ),0) AS new_persons,
17
                 IFNULL(sum( t.new_persons ),0) AS new_persons,
17
                 IFNULL(sum( t.share_num ),0) AS share_num,
18
                 IFNULL(sum( t.share_num ),0) AS share_num,
18
                 IFNULL(sum( t.visit_persons ),0) AS visit_persons,
19
                 IFNULL(sum( t.visit_persons ),0) AS visit_persons,
148
         </if>
149
         </if>
149
         -->
150
         -->
150
         AND e.is_first_time = 1
151
         AND e.is_first_time = 1
152
+
151
         AND t.phone is not null
153
         AND t.phone is not null
152
 
154
 
153
 <!--        为了与存储过程一致 -->
155
 <!--        为了与存储过程一致 -->
154
 <!--        AND t.`status` = 1-->
156
 <!--        AND t.`status` = 1-->
155
-        ORDER BY e.create_date DESC;
157
+        ORDER BY e.create_date DESC
156
     </select>
158
     </select>
157
 
159
 
158
     <select id="getConsultantHomePagePersons" resultType="com.huiju.estateagents.entity.TaPerson">
160
     <select id="getConsultantHomePagePersons" resultType="com.huiju.estateagents.entity.TaPerson">
177
 
179
 
178
 <!--        为了与存储过程一致 -->
180
 <!--        为了与存储过程一致 -->
179
 <!--            AND s.`status` = 1-->
181
 <!--            AND s.`status` = 1-->
180
-        GROUP BY t.person_id
181
-        ORDER BY t.create_date DESC;
182
+        GROUP BY t.person_id, DATE_FORMAT(t.create_date, '%Y%m%d')
183
+        ORDER BY t.create_date DESC
182
     </select>
184
     </select>
183
 
185
 
184
     <select id="getConsultantHomePageTimes" resultType="com.huiju.estateagents.entity.TaPerson">
186
     <select id="getConsultantHomePageTimes" resultType="com.huiju.estateagents.entity.TaPerson">
202
 
204
 
203
 <!--        为了与存储过程一致 -->
205
 <!--        为了与存储过程一致 -->
204
 <!--            AND s.`status` = 1-->
206
 <!--            AND s.`status` = 1-->
205
-        ORDER BY t.create_date DESC;
207
+        <if test="personId != null and personId !=''">
208
+            AND t.person_id = #{personId}
209
+        </if>
210
+        ORDER BY t.create_date DESC
206
     </select>
211
     </select>
207
 
212
 
208
     <select id="getConsultantChatPersons" resultType="com.huiju.estateagents.entity.TaPerson">
213
     <select id="getConsultantChatPersons" resultType="com.huiju.estateagents.entity.TaPerson">
223
 <!--        为了与存储过程一致 -->
228
 <!--        为了与存储过程一致 -->
224
 <!--            AND s.`status` = 1-->
229
 <!--            AND s.`status` = 1-->
225
         GROUP BY
230
         GROUP BY
226
-            t.person_id
231
+            t.person_id, DATE_FORMAT(h.create_date, '%Y%m%d')
227
         ORDER BY
232
         ORDER BY
228
             h.create_date DESC
233
             h.create_date DESC
229
     </select>
234
     </select>
231
     <select id="getConsultantFavor" resultType="com.huiju.estateagents.entity.TaPerson">
236
     <select id="getConsultantFavor" resultType="com.huiju.estateagents.entity.TaPerson">
232
         SELECT
237
         SELECT
233
             t.*,
238
             t.*,
234
-            max( i.create_date ) AS visit_time
239
+            i.create_date AS visit_time
235
         FROM
240
         FROM
236
             ta_person t
241
             ta_person t
237
         INNER JOIN ta_favor i ON i.person_id = t.person_id
242
         INNER JOIN ta_favor i ON i.person_id = t.person_id
302
             </if>
307
             </if>
303
             -->
308
             -->
304
 <!--            AND t.`status` = 1-->
309
 <!--            AND t.`status` = 1-->
305
-        GROUP BY t.person_id
310
+        GROUP BY t.person_id, DATE_FORMAT(e.create_date, '%Y%m%d')
306
         ORDER BY e.create_date DESC
311
         ORDER BY e.create_date DESC
307
     </select>
312
     </select>
308
 
313
 
309
     <select id="getConsultantShareTimes" resultType="com.huiju.estateagents.entity.TaPerson">
314
     <select id="getConsultantShareTimes" resultType="com.huiju.estateagents.entity.TaPerson">
310
         SELECT
315
         SELECT
311
             t.*,
316
             t.*,
312
-            e.create_date as visit_times,
317
+            e.create_date as visit_time,
313
             e.target_type,
318
             e.target_type,
314
             e.target_id,
319
             e.target_id,
315
             e.target_name
320
             e.target_name
338
                 AND e.building_id = #{buildingId}
343
                 AND e.building_id = #{buildingId}
339
             </if>
344
             </if>
340
             -->
345
             -->
346
+
347
+        <if test="personId != null and personId !=''">
348
+            AND t.person_id = #{personId}
349
+        </if>
350
+        <if test="userName != null and userName !=''">
351
+            AND t.nickname like concat('%', #{userName} ,'%')
352
+        </if>
341
             <!--            AND t.`status` = 1-->
353
             <!--            AND t.`status` = 1-->
342
         ORDER BY e.create_date DESC
354
         ORDER BY e.create_date DESC
343
     </select>
355
     </select>