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