Browse Source

【新增】1.完成小组总排名接口

master
wxz 4 years ago
parent
commit
9a66324acf
  1. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java
  3. 3
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java
  4. 4
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java
  5. 22
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java
  6. 7
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java
  7. 75
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  8. 25
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java
  9. 1
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java
  10. 22
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java
  11. 3
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  12. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

12
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);
}
}

12
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;
}

3
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;

4
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;
}

22
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<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInGridScope(gridId, pageNo, pageSize);
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize);
return new Result<PageData<GroupPointRankingResultDTO>>().ok(page);
}
/**
* @description 小组排名- 客户范围内
*
* @param formDTO
* @return
* @author wxz
* @date 2021.09.08 09:18:37
*/
@PostMapping("grouppointranking/customerscope")
public Result<PageData<GroupPointRankingResultDTO>> listGroupPointRandingInCustomerScope(@RequestBody GroupPointFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.CustomerScopeRank.class);
String customerId = formDTO.getCustomerId();
Integer pageNo = formDTO.getPageNo();
Integer pageSize = formDTO.getPageSize();
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize);
return new Result<PageData<GroupPointRankingResultDTO>>().ok(page);
}

7
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<BizPointTotalDet
/**
* @description 网格范围内查询小组排名
*
* @param gridId 网格id
* @param searchScopeType 搜索小组的范围类型:GroupFormDTO.SearchScopeTypeEnum.GRID/GroupFormDTO.SearchScopeTypeEnum.CUSTOMER
* @param searchScopeId 搜索小组的范围id
* @param pageNo 页码默认0
* @param pageSize 单页条数默认10
* @return
* @author wxz
* @date 2021.09.07 14:18:08
*/
PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize);
PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize);
}

75
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<BizPointTota
private BizPointUserTotalDetailService bizPointUserTotalDetailService;
@Autowired
private UserPointActionLogService userPointActionLogService;
@Autowired
private RedisTemplate<String, ?> redisTemplate;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public PageData<BizPointTotalDetailDTO> page(Map<String, Object> params) {
@ -248,14 +261,17 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
}
@Override
public PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(String gridId, Integer pageNo, Integer pageSize) {
public PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) {
// 1.查询有积分的小组得分排名
PageInfo<BizPointTotalDetailEntity> entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> {
LambdaQueryWrapper<BizPointTotalDetailEntity> 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<BizPointTota
if (pageSize > groupIds.size()) {
// 查出网格下已有积分的小组id
LambdaQueryWrapper<BizPointTotalDetailEntity> 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<String> existingGroupIds = baseDao.selectObjs(query).stream().map(obj -> obj.toString()).collect(Collectors.toList());
@ -282,14 +302,17 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
// 不足0的从0开始
startRow = Math.max(startRow, 0);
List<GroupPointRankingResultDTO> 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<GroupPointRankingResultDTO> pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal());
@ -305,18 +328,18 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
* @author wxz
* @date 2021.09.07 16:30:28
*/
private List<GroupPointRankingResultDTO> fillGroupPageGap(List<String> existingGroupIds,String searchScopeObjectId, Integer startRow, Integer rowCount) {
private List<GroupPointRankingResultDTO> fillGroupPageGap(List<String> 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<List<GroupDetailResultDTO>> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form);
List<GroupDetailResultDTO> groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】网格内排名:查询积分为0的小组列表失败");
List<GroupDetailResultDTO> 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<BizPointTota
dto.setGroupHeadPhoto(g.getGroupHeadPhoto());
dto.setGroupName(g.getGroupName());
dto.setGroupId(g.getGroupId());
dto.setGridId(g.getGridId());
return dto;
}).collect(Collectors.toList());
}
/**
* @description 将小组排名信息Entity转化为dto
* @description 将小组排名Entity转化为dto
*
* @param groupList
* @return
@ -361,8 +385,41 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
dto.setGroupType(groupInfo.getGroupType());
dto.setPoint(g.getTotalPoint().toString());
dto.setGroupHeadPhoto(groupInfo.getGroupHeadPhoto());
dto.setGridId(g.getGridId());
return dto;
}).collect(Collectors.toList());
return rankingDTOs;
}
/**
* @description 查询网格信息
*
* @param gridId
* @return
* @author wxz
* @date 2021.09.08 11:17:17
*/
public GridInfoCache getGridInfo(String gridId) {
HashOperations<String, String, Object> ope = redisTemplate.opsForHash();
Map<String, Object> 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<CustomerGridDTO> 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;
}
}

25
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;
}
}
}

1
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;

22
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;
}
}

3
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<String> 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<GroupDetailResultDTO> groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType());

6
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<ResiGroupDao, ResiGrou
sortFieldFun = ResiGroupEntity::getCreatedTime;
}
if (GroupFormDTO.SearchScopeTypeEnum.GRID.getScopeType().equals(searchScopeType)) {
if (SearchScopeTypeEnum.GRID.getScopeType().equals(searchScopeType)) {
query.eq(ResiGroupEntity::getGridId, searchScopeObjectId);
} else if (GroupFormDTO.SearchScopeTypeEnum.CUSTOMER.getScopeType().equals(searchScopeType)) {
} else if (SearchScopeTypeEnum.CUSTOMER.getScopeType().equals(searchScopeType)) {
query.eq(ResiGroupEntity::getCustomerId, searchScopeObjectId);
}
@ -1828,6 +1829,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
dto.setGroupHeadPhoto(ge.getGroupHeadPhoto());
dto.setGroupIntroduction(ge.getGroupIntroduction());
dto.setGroupType(ge.getGroupType());
dto.setGridId(ge.getGridId());
return dto;
}).collect(Collectors.toList());
}

Loading…
Cancel
Save