Browse Source

新需求

傅行帆 5 years ago
parent
commit
e79215dbd2

+ 3
- 1
src/main/java/com/huiju/estateagents/controller/StatisticalController.java View File

207
                                                 @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
207
                                                 @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
208
                                                 @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
208
                                                 @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
209
                                                 @RequestParam(value = "buildingId", required = false) String buildingId,
209
                                                 @RequestParam(value = "buildingId", required = false) String buildingId,
210
+                                                @RequestParam(value = "sortField", required = false) String sortField,
211
+                                                @RequestParam(value = "sortOrder", required = false) String sortOrder,
210
                                                 HttpServletRequest request) {
212
                                                 HttpServletRequest request) {
211
-        return iStatisticalService.getStatsTableList(pageNum,pageSize,getOrgId(request), startDate, endDate,buildingId, getTaPersonBuildingListByUserId(request));
213
+        return iStatisticalService.getStatsTableList(pageNum,pageSize,getOrgId(request), startDate, endDate,buildingId, getTaPersonBuildingListByUserId(request),sortField,sortOrder);
212
     }
214
     }
213
 }
215
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/mapper/TaBuildingMapper.java View File

145
      * @param personBuildingList
145
      * @param personBuildingList
146
      * @return
146
      * @return
147
      */
147
      */
148
-    IPage<StatsBuilding> getStatsTableList(IPage<StatsBuilding> page, @Param("orgId") Integer orgId, @Param("startDate")  LocalDate startDate, @Param("endDate")  LocalDate endDate, @Param("buildingId") String buildingId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
148
+    IPage<StatsBuilding> getStatsTableList(IPage<StatsBuilding> page, @Param("orgId") Integer orgId, @Param("startDate")  LocalDate startDate, @Param("endDate")  LocalDate endDate, @Param("buildingId") String buildingId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList,@Param("sortField") String sortField,@Param("orderType") String orderType);
149
 
149
 
150
 }
150
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/service/IStatisticalService.java View File

145
      * @param taPersonBuildingListByUserId
145
      * @param taPersonBuildingListByUserId
146
      * @return
146
      * @return
147
      */
147
      */
148
-    ResponseBean getStatsTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId);
148
+    ResponseBean getStatsTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> taPersonBuildingListByUserId,String sortField,String sortOrder);
149
 }
149
 }

+ 8
- 2
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java View File

447
      * @return
447
      * @return
448
      */
448
      */
449
     @Override
449
     @Override
450
-    public ResponseBean getStatsTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> personBuildingList) {
450
+    public ResponseBean getStatsTableList(Integer pageNum, Integer pageSize, Integer orgId, LocalDate startDate, LocalDate endDate, String buildingId, List<TaPersonBuilding> personBuildingList,String sortField,String sortOrder) {
451
+        String orderType = "asc";
452
+        if ("descend".equals(sortOrder)){
453
+            orderType = "desc";
454
+        }else if ("ascend".equals(sortOrder)){
455
+            orderType = "asc";
456
+        }
451
         IPage<StatsBuilding> pg = new Page<>(pageNum, pageSize);
457
         IPage<StatsBuilding> pg = new Page<>(pageNum, pageSize);
452
-        IPage<StatsBuilding> page = taBuildingMapper.getStatsTableList(pg, orgId, startDate, endDate, buildingId, personBuildingList);
458
+        IPage<StatsBuilding> page = taBuildingMapper.getStatsTableList(pg, orgId, startDate, endDate, buildingId, personBuildingList,sortField,orderType);
453
         return ResponseBean.success(page);
459
         return ResponseBean.success(page);
454
     }
460
     }
455
 
461
 

+ 30
- 0
src/main/resources/mapper/TaBuildingMapper.xml View File

407
                 AND a.realty_consultant IS NOT NULL
407
                 AND a.realty_consultant IS NOT NULL
408
                 AND a.realty_consultant != ''
408
                 AND a.realty_consultant != ''
409
                 AND a.org_id = #{orgId}
409
                 AND a.org_id = #{orgId}
410
+                <if test="startDate != null">
411
+                    and  TO_DAYS(a.create_date) >= TO_DAYS(#{startDate})
412
+                </if>
413
+                <if test="endDate != null">
414
+                    and  TO_DAYS(a.create_date) &lt;= TO_DAYS(#{endDate})
415
+                </if>
410
             GROUP BY
416
             GROUP BY
411
                 a.building_id
417
                 a.building_id
412
         ) aa ON aa.building_id = t.building_id
418
         ) aa ON aa.building_id = t.building_id
425
                     AND b.org_id = #{orgId}
431
                     AND b.org_id = #{orgId}
426
                     AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
432
                     AND IFNULL( b.person_type, '' ) IN ( 'estate agent', 'customer' )
427
                     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 != '' )
433
                     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 != '' )
434
+                    <if test="startDate != null">
435
+                        and  TO_DAYS(b.create_date) >= TO_DAYS(#{startDate})
436
+                    </if>
437
+                    <if test="endDate != null">
438
+                        and  TO_DAYS(b.create_date) &lt;= TO_DAYS(#{endDate})
439
+                    </if>
428
                 GROUP BY
440
                 GROUP BY
429
                     b.person_id
441
                     b.person_id
430
             ) bb
442
             ) bb
439
                 ta_uv u
451
                 ta_uv u
440
             WHERE
452
             WHERE
441
                 u.tagert_type = 'project'
453
                 u.tagert_type = 'project'
454
+            <if test="startDate != null">
455
+                and  TO_DAYS(u.create_date) >= TO_DAYS(#{startDate})
456
+            </if>
457
+            <if test="endDate != null">
458
+                and  TO_DAYS(u.create_date) &lt;= TO_DAYS(#{endDate})
459
+            </if>
442
             GROUP BY
460
             GROUP BY
443
                 u.be_uv
461
                 u.be_uv
444
         ) uu ON uu.building_id = t.building_id
462
         ) uu ON uu.building_id = t.building_id
445
         WHERE
463
         WHERE
446
         t.org_id = #{orgId}
464
         t.org_id = #{orgId}
465
+        <if test="personBuildingList != null and personBuildingList.size > 0">
466
+            AND t.building_id in
467
+            <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
468
+                #{personBuilding.buildingId}
469
+            </foreach>
470
+        </if>
471
+        <if test="buildingId != null and buildingId != '' ">
472
+            AND t.building_id = #{buildingId}
473
+        </if>
474
+        <if test="sortField != null and sortField != ''">
475
+            ORDER BY ${sortField} ${orderType}
476
+        </if>
447
     </select>
477
     </select>
448
 
478
 
449
 </mapper>
479
 </mapper>