From 41f73d425329ed0c1bc25c0a9b78b7ebc71e40b5 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 8 Sep 2021 09:13:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=911.?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E6=A0=BC=E5=86=85=E5=B0=8F=E7=BB=84?= =?UTF-8?q?=E6=8E=92=E5=90=8D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/GroupPointFormDTO.java | 10 +- .../result/GroupPointRankingResultDTO.java | 8 ++ .../controller/GroupPointController.java | 23 ++++ .../service/BizPointTotalDetailService.java | 13 ++ .../impl/BizPointTotalDetailServiceImpl.java | 128 +++++++++++++++++- .../group/dto/group/form/GroupFormDTO.java | 95 +++++++++++++ .../group/result/GroupDetailResultDTO.java | 3 + .../group/feign/ResiGroupOpenFeignClient.java | 22 +++ .../ResiGroupOpenFeignClientFallback.java | 10 ++ .../group/controller/ResiGroupController.java | 37 +++++ .../group/service/ResiGroupService.java | 26 ++++ .../service/impl/ResiGroupServiceImpl.java | 59 ++++++++ 12 files changed, 432 insertions(+), 2 deletions(-) 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 b727bb5d1b..8e6ded72e1 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 @@ -1,6 +1,7 @@ package com.epmet.dto.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.sun.webkit.LoadListenerClient; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -17,8 +18,15 @@ public class GroupPointFormDTO implements Serializable { public interface GroupPoint extends CustomerClientShowGroup {} public interface GridRank extends CustomerClientShowGroup {} + public interface GridScopeRank extends CustomerClientShowGroup {} @NotBlank(message = "小组Id不能为空", groups = {GroupPoint.class, GridRank.class}) private String groupId; - @NotBlank(message = "网格Id不能为空", groups = {GridRank.class}) + @NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class}) private String gridId; + + /** 页码 */ + private Integer pageNo = 1; + + /** 单页条数 */ + private Integer pageSize = 10; } 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 275a5917ba..e45a709d6e 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 @@ -35,4 +35,12 @@ public class GroupPointRankingResultDTO implements Serializable { * 小组ID */ private String groupId; + + /** 头像 */ + private String groupHeadPhoto; + + /** 类型 branch 支部小组;o */ + private String groupType; + + } 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 9fd48f00a1..55dbc70813 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 @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -14,12 +15,15 @@ import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; import com.epmet.service.PointRuleService; import com.epmet.utils.ModuleConstant; +import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.validation.constraints.NotBlank; +import java.lang.management.MemoryManagerMXBean; import java.util.List; /** @@ -113,4 +117,23 @@ public class GroupPointController { return new Result().ok(result); } + /** + * @description 【小组排名】- 网格范围内 + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.07 13:35:45 + */ + @PostMapping("grouppointranking/gridscope") + public Result> listGroupPointRandingInGridScope(@RequestBody GroupPointFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.GridScopeRank.class); + String gridId = formDTO.getGridId(); + Integer pageNo = formDTO.getPageNo(); + Integer pageSize = formDTO.getPageSize(); + + PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(gridId, pageNo, pageSize); + return new Result>().ok(page); + } + } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java index 8a81ff5ffb..1d2a0af41e 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java @@ -24,6 +24,7 @@ import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; +import com.github.pagehelper.PageInfo; import java.util.List; import java.util.Map; @@ -135,4 +136,16 @@ public interface BizPointTotalDetailService extends BaseService listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize); } \ 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 c1a7dbe14b..8d8648fc57 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 @@ -22,7 +22,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; @@ -30,7 +33,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dao.BizPointTotalDetailDao; import com.epmet.dto.BizPointTotalDetailDTO; import com.epmet.dto.form.GroupPointFormDTO; +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.result.GroupDetailResultDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; @@ -39,6 +44,9 @@ import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; import com.epmet.service.UserPointActionLogService; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -57,7 +65,7 @@ import java.util.stream.Collectors; * @since v1.0.0 2021-04-20 */ @Service -public class BizPointTotalDetailServiceImpl extends BaseServiceImpl implements BizPointTotalDetailService { +public class BizPointTotalDetailServiceImpl extends BaseServiceImpl implements BizPointTotalDetailService, ResultDataResolver { @Autowired private ResiGroupOpenFeignClient resiGroupOpenFeignClient; @@ -239,4 +247,122 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize) { + + // 1.查询有积分的小组得分排名 + PageInfo entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(BizPointTotalDetailEntity::getGridId, gridId); + query.eq(BizPointTotalDetailEntity::getBizType, "group"); + //query.eq(BizPointTotalDetailEntity::getDelFlag, 0); #用mybatis plus不需要手动指定,框架会自动指定 + query.orderByDesc(BizPointTotalDetailEntity::getTotalPoint); + baseDao.selectList(query); + }); + + List groupList = entityPageInfo.getList(); + + List groupIds = groupList.stream().map(g -> g.getObjectId()).collect(Collectors.toList()); + + // 2.将列表填充基本信息并且转换为dto + List rankingInfoDTOs = convertGroupRankingInfoEntity2DTOs(groupIds, groupList); + + Page page = new Page(pageNo, pageSize); + + // 3.如果不满一页,则填充分数为0的 + if (pageSize > groupIds.size()) { + // 查出网格下已有积分的小组id + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(BizPointTotalDetailEntity::getGridId, gridId); + query.eq(BizPointTotalDetailEntity::getBizType, "group"); + query.select(BizPointTotalDetailEntity::getObjectId); + List existingGroupIds = baseDao.selectObjs(query).stream().map(obj -> obj.toString()).collect(Collectors.toList()); + + int startRow = page.getStartRow() - existingGroupIds.size(); + // 不足0的从0开始 + startRow = Math.max(startRow, 0); + List gap; + gap = fillGroupPageGap(existingGroupIds, gridId, startRow, pageSize - groupList.size()); + rankingInfoDTOs.addAll(gap); + } + + // 4.排名填充 + Integer ranking = page.getStartRow() + 1; + for (GroupPointRankingResultDTO g : rankingInfoDTOs) { + g.setRanking(String.valueOf(ranking)); + ranking ++; + } + PageData pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal()); + return pageData; + } + + /** + * @description 获取分页缺口group ranking信息 + * + * @param startRow + * @param rowCount + * @return + * @author wxz + * @date 2021.09.07 16:30:28 + */ + private List fillGroupPageGap(List existingGroupIds,String searchScopeObjectId, Integer startRow, Integer rowCount) { + GroupFormDTO form = new GroupFormDTO(); + form.setExcludeGroupIds(existingGroupIds); + form.setOrder(GroupFormDTO.OrderTypeEnum.DESC); + form.setSort(GroupFormDTO.SortTypeEnum.CREATE_TIME); + form.setStartRow(startRow); + form.setRowCount(rowCount); + form.setSearchScopeType(GroupFormDTO.SearchScopeTypeEnum.GRID); + form.setSearchScopeObjectId(searchScopeObjectId); + + Result> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form); + List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】网格内排名:查询积分为0的小组列表失败"); + if (CollectionUtils.isEmpty(groups)) { + return new ArrayList<>(); + } + return groups.stream().map(g -> { + GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); + dto.setGroupType(g.getGroupType()); + dto.setPoint("0"); + dto.setGroupHeadPhoto(g.getGroupHeadPhoto()); + dto.setGroupName(g.getGroupName()); + dto.setGroupId(g.getGroupId()); + return dto; + }).collect(Collectors.toList()); + } + + /** + * @description 将小组排名信息Entity转化为dto + * + * @param groupList + * @return + * @author wxz + * @date 2021.09.07 15:52:17 + */ + private List convertGroupRankingInfoEntity2DTOs(List groupIds, List groupList) { + if (CollectionUtils.isEmpty(groupIds)) { + return new ArrayList<>(); + } + + // 查询这些小组的基本信息 + Result> listResult = resiGroupOpenFeignClient.listGroupDetailsByGroupIds(groupIds); + List groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错"); + + // 将小组基本信息转化为map + HashMap groupMap = new HashMap<>(); + groupInfos.stream().forEach(g -> groupMap.put(g.getGroupId(), g)); + + // 将小组信息填充到排名列表中 + List rankingDTOs = groupList.stream().map(g -> { + GroupDetailResultDTO groupInfo = groupMap.get(g.getObjectId()); + GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); + dto.setGroupId(g.getObjectId()); + dto.setGroupName(groupInfo.getGroupName()); + dto.setGroupType(groupInfo.getGroupType()); + dto.setPoint(g.getTotalPoint().toString()); + dto.setGroupHeadPhoto(groupInfo.getGroupHeadPhoto()); + return dto; + }).collect(Collectors.toList()); + return rankingDTOs; + } } \ 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/GroupFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java index 2fc8ba7b9a..23e00b4485 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java @@ -1,8 +1,14 @@ package com.epmet.resi.group.dto.group.form; import lombok.Data; +import sun.security.provider.PolicySpiFile; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.List; +import java.util.PrimitiveIterator; /** * @author zhaoqifeng @@ -11,7 +17,96 @@ import java.io.Serializable; */ @Data public class GroupFormDTO implements Serializable { + private static final long serialVersionUID = 5330629771935235995L; + + /** 排除某些指定id之外的组列表 */ + public interface GroupDetailsExcludeGroupIds {} + private String groupId; + private String gridId; + + /** 小组所属范围:grid网格,customer客户 */ + @NotNull(message = "搜索范围类型不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private SearchScopeTypeEnum searchScopeType; + + @NotNull(message = "搜索范围对象的ID不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private String searchScopeObjectId; + + private List excludeGroupIds; + + /** 从第几条开始取 */ + private Integer startRow = 0; + + /** 取几条数据 */ + private Integer rowCount = 10; + + @NotNull(message = "排序字段不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private SortTypeEnum sort; + + @NotNull(message = "排序方式不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private OrderTypeEnum order; + + /** + * @Description 排序类型 + * @author wxz + * @date 2021.09.07 17:00:24 + */ + public enum SortTypeEnum { + + CREATE_TIME("create_time"); + + private String sortField; + + SortTypeEnum(String sortField) { + this.sortField = sortField; + } + + public String getSortField() { + return sortField; + } + } + + /** + * @Description 排序方式 + * @author wxz + * @date 2021.09.07 17:02:05 + */ + public enum OrderTypeEnum { + + ASC("asc"), + DESC("desc"); + + private String orderType; + + OrderTypeEnum(String orderType) { + this.orderType = orderType; + } + + public String getOrderType() { + return orderType; + } + } + + /** + * @Description 搜索范围类型枚举 + * @author wxz + * @date 2021.09.07 20:14:21 + */ + public enum SearchScopeTypeEnum { + + CUSTOMER("customer"), + GRID("grid"); + + private String scopeType; + + SearchScopeTypeEnum(String scopeType) { + this.scopeType = scopeType; + } + + public String getScopeType() { + return scopeType; + } + } } 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 c7767054d4..82793a5ffd 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 @@ -10,6 +10,7 @@ import lombok.NoArgsConstructor; public class GroupDetailResultDTO { private String groupHeadPhoto; + private String groupId; private String groupName; private String groupIntroduction; private Integer editNumLimit; @@ -17,5 +18,7 @@ public class GroupDetailResultDTO { private String auditStatus; private Boolean editable; private String remark; + /** 群组类型:branch:支部小组,ordinary:楼院小组 */ + private String groupType; } 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 16e1d8b0c8..cf0844c02b 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 @@ -289,4 +289,26 @@ public interface ResiGroupOpenFeignClient { @PostMapping("resi/group/topic/gettopicinfos") Result> getTopicInfos(@RequestBody List issueIds); + /** + * @description 根据组id列表批量查询组信息列表 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:33:58 + */ + @PostMapping("/resi/group/group/list-groupinfos-by-groupids") + Result> listGroupDetailsByGroupIds(@RequestBody List groupIds); + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param form + * @return + * @author wxz + * @date 2021.09.07 17:15:55 + */ + @PostMapping("/resi/group/group/list-groupinfos-exclude-groupids") + Result> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form); + } 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 94f03f3d41..6b5584a51c 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 @@ -220,4 +220,14 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien public Result> getTopicInfos(List issueIds) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "getTopicInfos", issueIds); } + + @Override + public Result> listGroupDetailsByGroupIds(List groupIds) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsByGroupIds", groupIds); + } + + @Override + public Result> listGroupDetailsExcludeGroupIds(GroupFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsExcludeGroupIds", form); + } } 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 5fa0d56be9..57d8870685 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 @@ -599,4 +599,41 @@ public class ResiGroupController { public Result initAchievement(@RequestParam String customerId) { return new Result().ok(statsAchievementService.initAllGroupAchievement(customerId)); } + + /** + * @description 根据组id列表批量查询组信息列表 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:33:58 + */ + @PostMapping("list-groupinfos-by-groupids") + public Result> listGroupDetailsByGroupIds(@RequestBody List groupIds) { + List groupDetails = resiGroupService.listGroupsByGroupIds(groupIds); + return new Result>().ok(groupDetails); + } + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param form + * @return + * @author wxz + * @date 2021.09.07 17:15:55 + */ + @PostMapping("list-groupinfos-exclude-groupids") + public Result> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form) { + ValidatorUtils.validateEntity(form, GroupFormDTO.GroupDetailsExcludeGroupIds.class); + Integer startRow = form.getStartRow(); + Integer rowCount = form.getRowCount(); + List excludeGroupIds = form.getExcludeGroupIds(); + GroupFormDTO.SortTypeEnum sort = form.getSort(); + GroupFormDTO.OrderTypeEnum order = form.getOrder(); + GroupFormDTO.SearchScopeTypeEnum searchScopeType = form.getSearchScopeType(); + String searchScopeObjectId = form.getSearchScopeObjectId(); + + List groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType()); + return new Result>().ok(groups); + } } 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 d7761738d8..eed7a355e6 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 @@ -435,4 +435,30 @@ public interface ResiGroupService extends BaseService { * @return com.epmet.resi.group.dto.group.ResiGroupDTO */ ResiGroupDTO getGroupInfoAndGroupMember(String groupId); + + /** + * @description 根据id列表查询组信息 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:27:35 + */ + List listGroupsByGroupIds(List groupIds); + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param excludeGroupIds 排序的组id列表 + * @param startRow + * @param rowCount + * @param searchScopeObjectId 小组所属的范围对象id,如果是网格,那就是网格id,如果是客户那就是客户id + * @param searchScopeType 小组所属的范围,grid网格,customer客户 + * @param sortType 排序字段 + * @param orderType 排序类型 + * @return + * @author wxz + * @date 2021.09.07 17:17:09 + */ + List listGroupDetailsExcludeGroupIds(List excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType,String searchScopeObjectId, String sortType, String orderType); } 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 122fafce0d..8abf0eba12 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 @@ -18,8 +18,10 @@ package com.epmet.modules.group.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.tools.constant.*; @@ -80,7 +82,9 @@ import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; import com.epmet.resi.group.dto.member.result.GroupAchievementDTO; import com.epmet.send.SendMqMsgUtil; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import kotlin.jvm.internal.Lambda; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -1772,4 +1776,59 @@ public class ResiGroupServiceImpl extends BaseServiceImpl listGroupsByGroupIds(List groupIds) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.in(ResiGroupEntity::getId, groupIds); + query.orderByDesc(ResiGroupEntity::getCreatedTime); + query.eq(ResiGroupEntity::getDelFlag, 0); + List groupEntities = baseDao.selectList(query); + List groupDtos = groupEntities.stream().map(ge -> { + GroupDetailResultDTO dto = new GroupDetailResultDTO(); + dto.setGroupId(ge.getId()); + dto.setGroupName(ge.getGroupName()); + dto.setGroupHeadPhoto(ge.getGroupHeadPhoto()); + dto.setGroupIntroduction(ge.getGroupIntroduction()); + dto.setGroupType(ge.getGroupType()); + return dto; + }).collect(Collectors.toList()); + return groupDtos; + } + + @Override + public List listGroupDetailsExcludeGroupIds(List excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType, String searchScopeObjectId, String sortType, String orderType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + if (CollectionUtils.isNotEmpty(excludeGroupIds)) { + query.notIn(ResiGroupEntity::getId, excludeGroupIds); + } + // 利用pagehelper计算起始条数 + query.last(String.format("limit %s, %s", startRow, rowCount)); + + SFunction sortFieldFun = null; + if (GroupFormDTO.SortTypeEnum.CREATE_TIME.getSortField().equals(sortType)) { + sortFieldFun = ResiGroupEntity::getCreatedTime; + } + + if (GroupFormDTO.SearchScopeTypeEnum.GRID.getScopeType().equals(searchScopeType)) { + query.eq(ResiGroupEntity::getGridId, searchScopeObjectId); + } else if (GroupFormDTO.SearchScopeTypeEnum.CUSTOMER.getScopeType().equals(searchScopeType)) { + query.eq(ResiGroupEntity::getCustomerId, searchScopeObjectId); + } + + if (GroupFormDTO.OrderTypeEnum.ASC.getOrderType().equals(orderType)) { + query.orderByAsc(sortFieldFun); + } else { + query.orderByDesc(sortFieldFun); + } + List groupList = baseDao.selectList(query); + return groupList.stream().map(ge -> { + GroupDetailResultDTO dto = new GroupDetailResultDTO(); + dto.setGroupId(ge.getId()); + dto.setGroupName(ge.getGroupName()); + dto.setGroupHeadPhoto(ge.getGroupHeadPhoto()); + dto.setGroupIntroduction(ge.getGroupIntroduction()); + dto.setGroupType(ge.getGroupType()); + return dto; + }).collect(Collectors.toList()); + } } From 9a66324acfe2f83c9125d217434eae04b1e29f74 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 8 Sep 2021 12:42:05 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=911.?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B0=8F=E7=BB=84=E6=80=BB=E6=8E=92=E5=90=8D?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 12 +++ .../redis/common/bean/GridInfoCache.java | 12 +++ .../com/epmet/dto/form/GroupPointFormDTO.java | 3 + .../result/GroupPointRankingResultDTO.java | 4 + .../controller/GroupPointController.java | 22 +++++- .../service/BizPointTotalDetailService.java | 7 +- .../impl/BizPointTotalDetailServiceImpl.java | 75 ++++++++++++++++--- .../group/dto/group/form/GroupFormDTO.java | 25 +------ .../group/result/GroupDetailResultDTO.java | 1 + .../resi/group/enums/SearchScopeTypeEnum.java | 22 ++++++ .../group/controller/ResiGroupController.java | 3 +- .../service/impl/ResiGroupServiceImpl.java | 6 +- 12 files changed, 152 insertions(+), 40 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index bcbded2bd6..0196f02f44 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -522,4 +522,16 @@ public class RedisKeys { public static String getCustomerStaffInfoKey(String customerId, String staffId) { return rootPrefix.concat("gov:staff:").concat(customerId).concat(StrConstant.COLON).concat(staffId); } + + /** + * @description 网格信息 + * + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 11:03:48 + */ + public static String getGridInfoKey(String gridId) { + return rootPrefix.concat("gov:grid:").concat(gridId); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java new file mode 100644 index 0000000000..2900180581 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java @@ -0,0 +1,12 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +@Data +public class GridInfoCache { + private String gridId; + private String gridNamePath; + private String customerId; + private String pid; + private String pids; +} 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 8e6ded72e1..d1124fe9b8 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 @@ -19,10 +19,13 @@ 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 {} @NotBlank(message = "小组Id不能为空", groups = {GroupPoint.class, GridRank.class}) private String groupId; @NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class}) private String gridId; + @NotBlank(message = "客户Id不能为空", groups = {CustomerScopeRank.class}) + private String customerId; /** 页码 */ 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 e45a709d6e..b99d4313ac 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 @@ -42,5 +42,9 @@ public class GroupPointRankingResultDTO implements Serializable { /** 类型 branch 支部小组;o */ private String groupType; + /** 所属网格id */ + private String gridId; + /** 所属网格名称 */ + private String gridNamePath; } 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 55dbc70813..1ff898d97d 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 @@ -11,6 +11,7 @@ import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.dto.result.GroupPointRuleResultDTO; import com.epmet.dto.result.PointRankingResultDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; import com.epmet.service.PointRuleService; @@ -132,7 +133,26 @@ public class GroupPointController { Integer pageNo = formDTO.getPageNo(); Integer pageSize = formDTO.getPageSize(); - PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(gridId, pageNo, pageSize); + PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize); + return new Result>().ok(page); + } + + /** + * @description 【小组排名】- 客户范围内 + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.08 09:18:37 + */ + @PostMapping("grouppointranking/customerscope") + public Result> listGroupPointRandingInCustomerScope(@RequestBody GroupPointFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.CustomerScopeRank.class); + String customerId = formDTO.getCustomerId(); + Integer pageNo = formDTO.getPageNo(); + Integer pageSize = formDTO.getPageSize(); + + PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize); return new Result>().ok(page); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java index 1d2a0af41e..0b64de14bc 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java @@ -24,7 +24,7 @@ import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; -import com.github.pagehelper.PageInfo; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import java.util.List; import java.util.Map; @@ -140,12 +140,13 @@ public interface BizPointTotalDetailService extends BaseService listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize); + PageData listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize); } \ 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 8d8648fc57..29723b68a2 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 @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -27,12 +28,17 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.BizPointTotalDetailDao; import com.epmet.dto.BizPointTotalDetailDTO; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.form.CustomerGridFormDTO; 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.result.GroupDetailResultDTO; @@ -40,6 +46,7 @@ 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.enums.SearchScopeTypeEnum; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; @@ -50,6 +57,8 @@ import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -73,6 +82,10 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl redisTemplate; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; @Override public PageData page(Map params) { @@ -248,14 +261,17 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize) { + public PageData listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { // 1.查询有积分的小组得分排名 PageInfo entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(BizPointTotalDetailEntity::getGridId, gridId); + if (SearchScopeTypeEnum.CUSTOMER == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getCustomerId, searchScopeId); + } else if (SearchScopeTypeEnum.GRID == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getGridId, searchScopeId); + } query.eq(BizPointTotalDetailEntity::getBizType, "group"); - //query.eq(BizPointTotalDetailEntity::getDelFlag, 0); #用mybatis plus不需要手动指定,框架会自动指定 query.orderByDesc(BizPointTotalDetailEntity::getTotalPoint); baseDao.selectList(query); }); @@ -273,7 +289,11 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl groupIds.size()) { // 查出网格下已有积分的小组id LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.eq(BizPointTotalDetailEntity::getGridId, gridId); + if (SearchScopeTypeEnum.CUSTOMER == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getCustomerId, searchScopeId); + } else if (SearchScopeTypeEnum.GRID == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getGridId, searchScopeId); + } query.eq(BizPointTotalDetailEntity::getBizType, "group"); query.select(BizPointTotalDetailEntity::getObjectId); List existingGroupIds = baseDao.selectObjs(query).stream().map(obj -> obj.toString()).collect(Collectors.toList()); @@ -282,14 +302,17 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl gap; - gap = fillGroupPageGap(existingGroupIds, gridId, startRow, pageSize - groupList.size()); + gap = fillGroupPageGap(existingGroupIds, searchScopeType, searchScopeId, startRow, pageSize - groupList.size()); rankingInfoDTOs.addAll(gap); } // 4.排名填充 Integer ranking = page.getStartRow() + 1; for (GroupPointRankingResultDTO g : rankingInfoDTOs) { + GridInfoCache gridInfo = getGridInfo(g.getGridId()); g.setRanking(String.valueOf(ranking)); + g.setGridId(g.getGridId()); + g.setGridNamePath(gridInfo.getGridNamePath()); ranking ++; } PageData pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal()); @@ -305,18 +328,18 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl fillGroupPageGap(List existingGroupIds,String searchScopeObjectId, Integer startRow, Integer rowCount) { + private List fillGroupPageGap(List existingGroupIds, SearchScopeTypeEnum searchScopeType, String searchScopeObjectId, Integer startRow, Integer rowCount) { GroupFormDTO form = new GroupFormDTO(); form.setExcludeGroupIds(existingGroupIds); form.setOrder(GroupFormDTO.OrderTypeEnum.DESC); form.setSort(GroupFormDTO.SortTypeEnum.CREATE_TIME); form.setStartRow(startRow); form.setRowCount(rowCount); - form.setSearchScopeType(GroupFormDTO.SearchScopeTypeEnum.GRID); + form.setSearchScopeType(searchScopeType); form.setSearchScopeObjectId(searchScopeObjectId); Result> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form); - List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】网格内排名:查询积分为0的小组列表失败"); + List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询积分为0的小组列表失败"); if (CollectionUtils.isEmpty(groups)) { return new ArrayList<>(); } @@ -327,12 +350,13 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl ope = redisTemplate.opsForHash(); + Map entries = ope.entries(RedisKeys.getGridInfoKey(gridId)); + if (entries.size() != 0) { + return BeanUtil.mapToBean(entries, GridInfoCache.class, true); + } + + CustomerGridFormDTO form = new CustomerGridFormDTO(); + form.setGridId(gridId); + Result result = govOrgOpenFeignClient.getCustomerGridByGridId(form); + if (result == null || !result.success() || result.getData() == null) { + return null; + } + + GridInfoCache cache = new GridInfoCache(); + cache.setCustomerId(result.getData().getCustomerId()); + cache.setGridId(result.getData().getId()); + cache.setGridNamePath(result.getData().getGridName()); + cache.setPid(result.getData().getPid()); + cache.setPids(result.getData().getPids()); + ope.putAll(RedisKeys.getGridInfoKey(gridId), BeanUtil.beanToMap(cache)); + return cache; + } } \ 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/GroupFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java index 23e00b4485..96295879f1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java @@ -1,14 +1,10 @@ package com.epmet.resi.group.dto.group.form; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import lombok.Data; -import sun.security.provider.PolicySpiFile; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; -import java.util.PrimitiveIterator; /** * @author zhaoqifeng @@ -89,24 +85,5 @@ public class GroupFormDTO implements Serializable { } } - /** - * @Description 搜索范围类型枚举 - * @author wxz - * @date 2021.09.07 20:14:21 - */ - public enum SearchScopeTypeEnum { - - CUSTOMER("customer"), - GRID("grid"); - private String scopeType; - - SearchScopeTypeEnum(String scopeType) { - this.scopeType = scopeType; - } - - public String getScopeType() { - return scopeType; - } - } } 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 82793a5ffd..93247725a4 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 @@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class GroupDetailResultDTO { + private String gridId; private String groupHeadPhoto; private String groupId; private String groupName; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java new file mode 100644 index 0000000000..474a2662a1 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java @@ -0,0 +1,22 @@ +package com.epmet.resi.group.enums; + +/** + * @Description 搜索范围类型枚举 + * @author wxz + * @date 2021.09.07 20:14:21 + */ +public enum SearchScopeTypeEnum { + + CUSTOMER("customer"), + GRID("grid"); + + private String scopeType; + + SearchScopeTypeEnum(String scopeType) { + this.scopeType = scopeType; + } + + public String getScopeType() { + return scopeType; + } +} \ No newline at end of file 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 57d8870685..5acbf76bb2 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 @@ -33,6 +33,7 @@ import com.epmet.resi.group.dto.group.result.*; import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.form.ResiIdentityFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.PostMapping; @@ -630,7 +631,7 @@ public class ResiGroupController { List excludeGroupIds = form.getExcludeGroupIds(); GroupFormDTO.SortTypeEnum sort = form.getSort(); GroupFormDTO.OrderTypeEnum order = form.getOrder(); - GroupFormDTO.SearchScopeTypeEnum searchScopeType = form.getSearchScopeType(); + SearchScopeTypeEnum searchScopeType = form.getSearchScopeType(); String searchScopeObjectId = form.getSearchScopeObjectId(); List groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType()); 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 8abf0eba12..68586a600a 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 @@ -81,6 +81,7 @@ import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; import com.epmet.resi.group.dto.member.result.GroupAchievementDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.send.SendMqMsgUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -1809,9 +1810,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl Date: Wed, 8 Sep 2021 13:31:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8A=A0=E8=BF=94?= =?UTF-8?q?=E5=8F=82=E3=80=81=E4=BA=BA=E5=91=98=E5=88=97=E8=A1=A8=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/govorg/form/OrgStaffListFormDTO.java | 2 ++ .../service/govorg/impl/GovOrgServiceImpl.java | 14 ++++++++++---- .../mapper/epmetuser/CustomerStaffDao.xml | 11 ++++++++--- .../dto/group/result/GroupSummarizeResultDTO.java | 8 ++++++++ .../main/resources/mapper/group/ResiGroupDao.xml | 11 +++++++---- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java index 7d0ed2f595..391fe968c9 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java @@ -45,6 +45,8 @@ public class OrgStaffListFormDTO implements Serializable { private List staffIds; //token中用户Id private String staffId; + //人员是否禁用【未禁用enable,已禁用disabled】 + private String enableFlag = "enable"; public interface OrgStaff extends CustomerClientShowGroup {} } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index b7b23299ab..8142f4a728 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -3,8 +3,10 @@ package com.epmet.dataaggre.service.govorg.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.govorg.*; @@ -28,10 +30,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -393,6 +392,13 @@ public class GovOrgServiceImpl implements GovOrgService { staffIds.removeIf(s->s.equals(formDTO.getStaffId())); } + //是否具有超级管理员或管理员角色 + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + Map roleMap = staffInfoCache.getRoleMap(); + if (roleMap.containsKey("root_manager") || roleMap.containsKey("manager")) { + formDTO.setEnableFlag("disabled"); + } + //2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】 List staffList = epmetUserService.getStaffInfoList(formDTO); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml index 07039eeed0..a4ebcae961 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml @@ -61,7 +61,7 @@ SELECT DISTINCT sr.staff_id, cs.created_time, - case when gsr.role_key = + case when cs.enable_flag = 'enable' AND gsr.role_key = 'agency_leader' @@ -73,9 +73,14 @@ 'grid_manager' - then 1 else 0 end is_first + then 0 + when cs.enable_flag = 'enable' AND gsr.role_key != 'agency_leader' + then 1 else 2 end is_first FROM staff_role sr INNER JOIN customer_staff cs ON sr.staff_id = cs.user_id + + AND cs.enable_flag = 'enable' + INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id AND gsr.customer_id = #{customerId} WHERE sr.del_flag = '0' @@ -100,7 +105,7 @@ ) t GROUP BY t.staff_id - ORDER BY t.is_first ]]> 1, t.created_time desc + ORDER BY t.is_first ]]> 0, t.is_first asc, t.created_time desc LIMIT #{pageNo}, #{pageSize} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java index dbf681b90d..28755fffe8 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java @@ -69,6 +69,14 @@ public class GroupSummarizeResultDTO implements Serializable { * 进组审核open开启;close关闭 */ private String auditSwitch; + /** + * 小组类型(ordinary:楼院小组 branch:支部小组) + */ + private String groupType; + /** + * 小组类型名称 + */ + private String groupTypeName; private String level; public GroupSummarizeResultDTO(){ 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..a5893e1677 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 @@ -246,14 +246,17 @@ AND gmo.OPERATE_STATUS = 'under_auditting' ) AS totalApplyingMember, rgs.TOTAL_TOPICS, - rg.AUDIT_SWITCH + rg.AUDIT_SWITCH, + rg.group_type groupType, + gs.`name` groupTypeName FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON ( rg.id = rgs.RESI_GROUP_ID ) LEFT JOIN resi_group_member rgm - ON ( rg.id = rgm.RESI_GROUP_ID - AND rgm.DEL_FLAG='0' - AND rgm.CUSTOMER_USER_ID =#{userId}) + ON ( rg.id = rgm.RESI_GROUP_ID + AND rgm.DEL_FLAG='0' + AND rgm.CUSTOMER_USER_ID =#{userId}) + LEFT JOIN resi_group_setup gs ON rg.GROUP_TYPE = gs.GROUP_TYPE AND gs.CUSTOMER_ID = 'default' WHERE rg.DEL_FLAG = '0' AND rgs.DEL_FLAG = '0'