From 0955cf0500c546353988e7bcbce5d15606a3a43f Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 9 Sep 2021 10:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=911.=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=88=91=E6=89=80=E5=9C=A8=E7=9A=84=E5=B0=8F=E7=BB=84?= =?UTF-8?q?=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/GroupPointFormDTO.java | 9 ++- .../result/GroupPointRankingResultDTO.java | 6 ++ .../controller/GroupPointController.java | 20 ++++- .../com/epmet/dao/BizPointTotalDetailDao.java | 23 ++++++ .../service/BizPointTotalDetailService.java | 13 +++- .../impl/BizPointTotalDetailServiceImpl.java | 74 ++++++++++++++++++- .../mapper/BizPointTotalDetailDao.xml | 46 ++++++++++++ .../dto/group/form/GroupsByMemberFormDTO.java | 17 +++++ .../group/result/GroupDetailResultDTO.java | 2 +- .../dto/group/result/RankingResultDTO.java | 11 +++ .../group/feign/ResiGroupOpenFeignClient.java | 10 +++ .../ResiGroupOpenFeignClientFallback.java | 5 ++ .../group/controller/ResiGroupController.java | 17 +++++ .../epmet/modules/group/dao/ResiGroupDao.java | 11 +++ .../group/service/ResiGroupService.java | 11 +++ .../service/impl/ResiGroupServiceImpl.java | 6 ++ .../resources/mapper/group/ResiGroupDao.xml | 18 +++++ 17 files changed, 288 insertions(+), 11 deletions(-) create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java index d1124fe9b8..641d5fbe9f 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java @@ -18,14 +18,17 @@ public class GroupPointFormDTO implements Serializable { public interface GroupPoint extends CustomerClientShowGroup {} public interface GridRank extends CustomerClientShowGroup {} - public interface GridScopeRank extends CustomerClientShowGroup {} - public interface CustomerScopeRank extends CustomerClientShowGroup {} + public interface GridScopeRank {} + public interface CustomerScopeRank {} + public interface MyGroupRank {} @NotBlank(message = "小组Id不能为空", groups = {GroupPoint.class, GridRank.class}) private String groupId; - @NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class}) + @NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class, MyGroupRank.class}) private String gridId; @NotBlank(message = "客户Id不能为空", groups = {CustomerScopeRank.class}) private String customerId; + @NotBlank(message = "用户ID不能为空", groups = {MyGroupRank.class}) + private String userId; /** 页码 */ private Integer pageNo = 1; diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java index b99d4313ac..2f06640b73 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java @@ -47,4 +47,10 @@ public class GroupPointRankingResultDTO implements Serializable { /** 所属网格名称 */ private String gridNamePath; + + /** 网格内排名 */ + private Integer gridRanking; + + /** 客户下总排名 */ + private Integer customerRanking; } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java index 1ff898d97d..d2901df068 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java @@ -133,7 +133,7 @@ public class GroupPointController { Integer pageNo = formDTO.getPageNo(); Integer pageSize = formDTO.getPageSize(); - PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize); + PageData page = bizPointTotalDetailService.listGroupPointRandingInPercificScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize); return new Result>().ok(page); } @@ -152,8 +152,24 @@ public class GroupPointController { Integer pageNo = formDTO.getPageNo(); Integer pageSize = formDTO.getPageSize(); - PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize); + PageData page = bizPointTotalDetailService.listGroupPointRandingInPercificScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize); return new Result>().ok(page); } + /** + * @description 【小组排名】- 列出我所在的小组的积分排名 + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.08 13:31:09 + */ + @PostMapping("grouppointranking/mygroups") + public Result> listMyGroupPointRanding(@RequestBody GroupPointFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.MyGroupRank.class); + String userId = formDTO.getUserId(); + String gridId = formDTO.getGridId(); + List list = bizPointTotalDetailService.listMyGroupPointRanding(userId, gridId); + return new Result>().ok(list); + } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java index 26e05f5a7b..1fb34f99e7 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java @@ -40,4 +40,27 @@ public interface BizPointTotalDetailDao extends BaseDao listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize); + PageData listGroupPointRandingInPercificScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize); + + /** + * @description 【小组排名】- 列出我所在的小组的积分排名 + * + * @param userId + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 13:34:49 + */ + List listMyGroupPointRanding(String userId, String gridId); } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java index 29723b68a2..037779147b 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java @@ -41,11 +41,13 @@ import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.resi.group.dto.group.form.GroupFormDTO; import com.epmet.resi.group.dto.group.form.GroupPointDetailFormDTO; +import com.epmet.resi.group.dto.group.form.GroupsByMemberFormDTO; import com.epmet.resi.group.dto.group.result.GroupDetailResultDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; import com.epmet.resi.group.dto.group.ResiGroupDTO; +import com.epmet.resi.group.dto.group.result.RankingResultDTO; import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.service.BizPointTotalDetailService; @@ -261,7 +263,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { + public PageData listGroupPointRandingInPercificScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { // 1.查询有积分的小组得分排名 PageInfo entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> { @@ -306,14 +308,21 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl point) { + // 此举是为了在积分一样的情况下,给与相同的排名 + ranking ++; + } + GridInfoCache gridInfo = getGridInfo(g.getGridId()); - g.setRanking(String.valueOf(ranking)); g.setGridId(g.getGridId()); g.setGridNamePath(gridInfo.getGridNamePath()); - ranking ++; + g.setRanking(String.valueOf(ranking)); + prevPoint = point; } PageData pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal()); return pageData; @@ -422,4 +431,61 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl listMyGroupPointRanding(String userId, String gridId) { + // 1.查询网格内我所在的小组 + GroupsByMemberFormDTO form = new GroupsByMemberFormDTO(); + form.setGridId(gridId); + form.setUserId(userId); + List groupList = getResultDataOrThrowsException(resiGroupOpenFeignClient.listGroupsByMember(form), + ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【我所在的小组排名】查询组列表失败"); + + if (CollectionUtils.isEmpty(groupList)) { + return new ArrayList(); + } + + // 2.填充分数和排名 + GroupDetailResultDTO firstGroup = groupList.get(0); + + // 网格和客户下,分别有多少个有积分的小组,后面用于给哪些没有任何积分记录的小组排名 + Integer gridMinRanking = baseDao.getMinRanking("group", "grid", gridId); + Integer customerMinRanking = baseDao.getMinRanking("group", "customer", firstGroup.getCustomerId()); + + List groupDtoList = groupList.stream().map(g -> { + // 积分 + Integer point = 0; + // 网格内的排名 + Integer gridRanking = null; + // 客户下的排名 + Integer customerRanking = null; + + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(BizPointTotalDetailEntity::getBizType, "group"); + query.eq(BizPointTotalDetailEntity::getObjectId, g.getGroupId()); + BizPointTotalDetailEntity groupPoint = baseDao.selectOne(query); + if (groupPoint == null) { + // 该小组没有积分 + gridRanking = gridMinRanking + 1; + customerRanking = customerMinRanking + 1; + } else { + // 该小组有积分 + point = groupPoint.getTotalPoint(); + gridRanking = baseDao.getRanking("group", g.getGroupId(), "grid"); + customerRanking = baseDao.getRanking("group", g.getGroupId(), "customer"); + } + + GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); + dto.setGridId(g.getGridId()); + dto.setGroupHeadPhoto(g.getGroupHeadPhoto()); + dto.setGroupType(g.getGroupType()); + dto.setGroupId(g.getGroupId()); + dto.setGroupName(g.getGroupName()); + dto.setPoint(point.toString()); + dto.setGridRanking(gridRanking); + dto.setCustomerRanking(customerRanking); + return dto; + }).collect(Collectors.toList()); + return groupDtoList; + } } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml index e1e8202e83..e65cfbabf5 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml @@ -29,5 +29,51 @@ and OBJECT_ID = #{objectId} + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java new file mode 100644 index 0000000000..806b07629e --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Description 根据成员查询组列表form + * @author wxz + * @date 2021.09.08 14:12:44 +*/ +@Data +public class GroupsByMemberFormDTO { + private String gridId; + @NotNull(message = "成员用户ID不能为空") + private String userId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java index 93247725a4..fd585419a2 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java @@ -21,5 +21,5 @@ public class GroupDetailResultDTO { private String remark; /** 群组类型:branch:支部小组,ordinary:楼院小组 */ private String groupType; - + private String customerId; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java new file mode 100644 index 0000000000..99357eb400 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java @@ -0,0 +1,11 @@ +package com.epmet.resi.group.dto.group.result; + +import lombok.Data; + +@Data +public class RankingResultDTO { + + private Integer gridRanking; + private Integer customerRanking; + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java index cf0844c02b..1762b35d97 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java @@ -311,4 +311,14 @@ public interface ResiGroupOpenFeignClient { @PostMapping("/resi/group/group/list-groupinfos-exclude-groupids") Result> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form); + /** + * @description 根据组成员查询所在的小组列表。可选条件包括:grid + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.08 13:51:05 + */ + @PostMapping("/resi/group/group/list-groups-by-member") + Result> listGroupsByMember(@RequestBody GroupsByMemberFormDTO formDTO); } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java index 6b5584a51c..8c2f5303ee 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java @@ -230,4 +230,9 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien public Result> listGroupDetailsExcludeGroupIds(GroupFormDTO form) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsExcludeGroupIds", form); } + + @Override + public Result> listGroupsByMember(GroupsByMemberFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupsByMember", formDTO); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index 5acbf76bb2..e90adf8c14 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -637,4 +637,21 @@ public class ResiGroupController { List groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType()); return new Result>().ok(groups); } + + /** + * @description 根据组成员查询所在的小组列表。可选条件包括:grid + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.08 13:51:05 + */ + @PostMapping("list-groups-by-member") + public Result> listGroupsByMember(@RequestBody GroupsByMemberFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + String gridId = formDTO.getGridId(); + String userId = formDTO.getUserId(); + List groups = resiGroupService.listGroupsByMember(userId, gridId); + return new Result>().ok(groups); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java index 44f8312d9c..3a0b47c336 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java @@ -335,4 +335,15 @@ public interface ResiGroupDao extends BaseDao { * @return java.util.List */ List selectRecentGroupAchievements(@Param("userId") String userId, @Param("gridId") String gridId); + + /** + * @description 根据组成员查询所在组列表。如有需要,可以增加其他if条件,或者增加排序参数 + * + * @param memberUserId + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 14:00:52 + */ + List listGroupsByMember(@Param("memberUserId") String memberUserId, @Param("gridId") String gridId); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java index eed7a355e6..122083cceb 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java @@ -461,4 +461,15 @@ public interface ResiGroupService extends BaseService { * @date 2021.09.07 17:17:09 */ List listGroupDetailsExcludeGroupIds(List excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType,String searchScopeObjectId, String sortType, String orderType); + + /** + * @description 根据成员查询组列表 + * + * @param memberUserId + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 13:59:31 + */ + List listGroupsByMember(String memberUserId, String gridId); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 68586a600a..1c85fb903a 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -40,6 +40,7 @@ import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ReadFlagConstant; +import com.epmet.dto.BizPointTotalDetailDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.UserInfoResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; @@ -1833,4 +1834,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl listGroupsByMember(String memberUserId, String gridId) { + return baseDao.listGroupsByMember(memberUserId, gridId); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml index 82d1531781..4dc83a5c90 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml @@ -1059,4 +1059,22 @@ ORDER BY releaseTime DESC +