Browse Source

Merge branch 'dev_group_msg' into develop

# Conflicts:
#	epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java
dev_shibei_match
sunyuchao 4 years ago
parent
commit
b9ba9f9ac8
  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. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java
  4. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  5. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml
  6. 13
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java
  7. 12
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java
  8. 43
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java
  9. 14
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java
  10. 185
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  11. 74
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java
  12. 4
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java
  13. 8
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java
  14. 22
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java
  15. 22
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java
  16. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java
  17. 38
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  18. 26
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java
  19. 61
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  20. 11
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -523,4 +523,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;
}

2
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<String> staffIds;
//token中用户Id
private String staffId;
//人员是否禁用【未禁用enable,已禁用disabled】
private String enableFlag = "enable";
public interface OrgStaff extends CustomerClientShowGroup {}
}

14
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<String,String> roleMap = staffInfoCache.getRoleMap();
if (roleMap.containsKey("root_manager") || roleMap.containsKey("manager")) {
formDTO.setEnableFlag("disabled");
}
//2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】
List<ListStaffResultDTO> staffList = epmetUserService.getStaffInfoList(formDTO);

11
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 =
<choose>
<when test="orgType != null and orgType == 'agency' ">
'agency_leader'
@ -73,9 +73,14 @@
'grid_manager'
</otherwise>
</choose>
then 1 else 0 end is_first<!-- 有单位领导角色的人赋值为1,没有的赋值为0 -->
then 0
when cs.enable_flag = 'enable' AND gsr.role_key != 'agency_leader'
then 1 else 2 end is_first<!-- 未禁用有相应角色人员赋值0,未禁用无相应角色人员赋值1,禁用人员赋值2 -->
FROM staff_role sr
INNER JOIN customer_staff cs ON sr.staff_id = cs.user_id
<if test="enableFlag != null and enableFlag != '' and enableFlag == 'enable' ">
AND cs.enable_flag = 'enable' <!-- 非超级管理员、管理员只允许查看未禁用人员信息 -->
</if>
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 @@
</choose>
) t
GROUP BY t.staff_id
ORDER BY t.is_first <![CDATA[<>]]> 1, t.created_time desc<!-- 标注有单位领导角色的人不参与排序也就是默认拍在前边,再按创建时间降序 -->
ORDER BY t.is_first <![CDATA[<>]]> 0, t.is_first asc, t.created_time desc<!-- 标注有相应角色的人不参与排序也就是默认拍在前边,没有相对于角色的排在后边,禁用人员排在最后 -->
LIMIT #{pageNo}, #{pageSize}
</select>

13
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,18 @@ 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})
@NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class})
private String gridId;
@NotBlank(message = "客户Id不能为空", groups = {CustomerScopeRank.class})
private String customerId;
/** 页码 */
private Integer pageNo = 1;
/** 单页条数 */
private Integer pageSize = 10;
}

12
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java

@ -35,4 +35,16 @@ public class GroupPointRankingResultDTO implements Serializable {
* 小组ID
*/
private String groupId;
/** 头像 */
private String groupHeadPhoto;
/** 类型 branch 支部小组;o */
private String groupType;
/** 所属网格id */
private String gridId;
/** 所属网格名称 */
private String gridNamePath;
}

43
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;
@ -10,16 +11,20 @@ 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;
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 +118,42 @@ public class GroupPointController {
return new Result<BizPointTotalDetailDTO>().ok(result);
}
/**
* @description 小组排名- 网格范围内
*
* @param formDTO
* @return
* @author wxz
* @date 2021.09.07 13:35:45
*/
@PostMapping("grouppointranking/gridscope")
public Result<PageData<GroupPointRankingResultDTO>> listGroupPointRandingInGridScope(@RequestBody GroupPointFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.GridScopeRank.class);
String gridId = formDTO.getGridId();
Integer pageNo = formDTO.getPageNo();
Integer pageSize = formDTO.getPageSize();
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);
}
}

14
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.epmet.resi.group.enums.SearchScopeTypeEnum;
import java.util.List;
import java.util.Map;
@ -135,4 +136,17 @@ public interface BizPointTotalDetailService extends BaseService<BizPointTotalDet
* @return com.epmet.dto.BizPointTotalDetailDTO
*/
BizPointTotalDetailDTO getGroupPoint(GroupPointFormDTO formDTO);
/**
* @description 网格范围内查询小组排名
*
* @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(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize);
}

185
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java

@ -17,31 +17,48 @@
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;
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.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;
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;
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;
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;
@ -57,7 +74,7 @@ import java.util.stream.Collectors;
* @since v1.0.0 2021-04-20
*/
@Service
public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTotalDetailDao, BizPointTotalDetailEntity> implements BizPointTotalDetailService {
public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTotalDetailDao, BizPointTotalDetailEntity> implements BizPointTotalDetailService, ResultDataResolver {
@Autowired
private ResiGroupOpenFeignClient resiGroupOpenFeignClient;
@ -65,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) {
@ -239,4 +260,166 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
return ConvertUtils.sourceToTarget(entity, BizPointTotalDetailDTO.class);
}
@Override
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<>();
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.orderByDesc(BizPointTotalDetailEntity::getTotalPoint);
baseDao.selectList(query);
});
List<BizPointTotalDetailEntity> groupList = entityPageInfo.getList();
List<String> groupIds = groupList.stream().map(g -> g.getObjectId()).collect(Collectors.toList());
// 2.将列表填充基本信息并且转换为dto
List<GroupPointRankingResultDTO> rankingInfoDTOs = convertGroupRankingInfoEntity2DTOs(groupIds, groupList);
Page page = new Page(pageNo, pageSize);
// 3.如果不满一页,则填充分数为0的
if (pageSize > groupIds.size()) {
// 查出网格下已有积分的小组id
LambdaQueryWrapper<BizPointTotalDetailEntity> query = new LambdaQueryWrapper<>();
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());
int startRow = page.getStartRow() - existingGroupIds.size();
// 不足0的从0开始
startRow = Math.max(startRow, 0);
List<GroupPointRankingResultDTO> gap;
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());
return pageData;
}
/**
* @description 获取分页缺口group ranking信息
*
* @param startRow
* @param rowCount
* @return
* @author wxz
* @date 2021.09.07 16:30:28
*/
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(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的小组列表失败");
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());
dto.setGridId(g.getGridId());
return dto;
}).collect(Collectors.toList());
}
/**
* @description 将小组排名Entity转化为dto
*
* @param groupList
* @return
* @author wxz
* @date 2021.09.07 15:52:17
*/
private List<GroupPointRankingResultDTO> convertGroupRankingInfoEntity2DTOs(List<String> groupIds, List<BizPointTotalDetailEntity> groupList) {
if (CollectionUtils.isEmpty(groupIds)) {
return new ArrayList<>();
}
// 查询这些小组的基本信息
Result<List<GroupDetailResultDTO>> listResult = resiGroupOpenFeignClient.listGroupDetailsByGroupIds(groupIds);
List<GroupDetailResultDTO> groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错");
// 将小组基本信息转化为map
HashMap<String, GroupDetailResultDTO> groupMap = new HashMap<>();
groupInfos.stream().forEach(g -> groupMap.put(g.getGroupId(), g));
// 将小组信息填充到排名列表中
List<GroupPointRankingResultDTO> 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());
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;
}
}

74
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java

@ -1,8 +1,10 @@
package com.epmet.resi.group.dto.group.form;
import com.epmet.resi.group.enums.SearchScopeTypeEnum;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
@ -11,7 +13,77 @@ 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<String> 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;
}
}
}

4
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java

@ -9,7 +9,9 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class GroupDetailResultDTO {
private String gridId;
private String groupHeadPhoto;
private String groupId;
private String groupName;
private String groupIntroduction;
private Integer editNumLimit;
@ -17,5 +19,7 @@ public class GroupDetailResultDTO {
private String auditStatus;
private Boolean editable;
private String remark;
/** 群组类型:branch:支部小组,ordinary:楼院小组 */
private String groupType;
}

8
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(){

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

22
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/get-topicdetail-byid/batch")
Result<List<ResiTopicDetailResultDTO>> listTopicDetailsByIds(TopicDetailBatchFormDTO input);
/**
* @description 根据组id列表批量查询组信息列表
*
* @param groupIds
* @return
* @author wxz
* @date 2021.09.07 15:33:58
*/
@PostMapping("/resi/group/group/list-groupinfos-by-groupids")
Result<List<GroupDetailResultDTO>> listGroupDetailsByGroupIds(@RequestBody List<String> groupIds);
/**
* @description 排除指定的组id之后按照指定顺序取指定个数的组信息
*
* @param form
* @return
* @author wxz
* @date 2021.09.07 17:15:55
*/
@PostMapping("/resi/group/group/list-groupinfos-exclude-groupids")
Result<List<GroupDetailResultDTO>> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form);
}

10
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java

@ -232,4 +232,14 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien
public Result<List<TopicInfoResultDTO>> getTopicInfos(List<String> issueIds) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "getTopicInfos", issueIds);
}
@Override
public Result<List<GroupDetailResultDTO>> listGroupDetailsByGroupIds(List<String> groupIds) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsByGroupIds", groupIds);
}
@Override
public Result<List<GroupDetailResultDTO>> listGroupDetailsExcludeGroupIds(GroupFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsExcludeGroupIds", form);
}
}

38
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;
@ -598,4 +599,41 @@ public class ResiGroupController {
public Result<Boolean> initAchievement(@RequestParam String customerId) {
return new Result<Boolean>().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<List<GroupDetailResultDTO>> listGroupDetailsByGroupIds(@RequestBody List<String> groupIds) {
List<GroupDetailResultDTO> groupDetails = resiGroupService.listGroupsByGroupIds(groupIds);
return new Result<List<GroupDetailResultDTO>>().ok(groupDetails);
}
/**
* @description 排除指定的组id之后按照指定顺序取指定个数的组信息
*
* @param form
* @return
* @author wxz
* @date 2021.09.07 17:15:55
*/
@PostMapping("list-groupinfos-exclude-groupids")
public Result<List<GroupDetailResultDTO>> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form) {
ValidatorUtils.validateEntity(form, GroupFormDTO.GroupDetailsExcludeGroupIds.class);
Integer startRow = form.getStartRow();
Integer rowCount = form.getRowCount();
List<String> excludeGroupIds = form.getExcludeGroupIds();
GroupFormDTO.SortTypeEnum sort = form.getSort();
GroupFormDTO.OrderTypeEnum order = form.getOrder();
SearchScopeTypeEnum searchScopeType = form.getSearchScopeType();
String searchScopeObjectId = form.getSearchScopeObjectId();
List<GroupDetailResultDTO> groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType());
return new Result<List<GroupDetailResultDTO>>().ok(groups);
}
}

26
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<ResiGroupEntity> {
* @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<GroupDetailResultDTO> listGroupsByGroupIds(List<String> 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<GroupDetailResultDTO> listGroupDetailsExcludeGroupIds(List<String> excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType,String searchScopeObjectId, String sortType, String orderType);
}

61
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,8 +82,11 @@ 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;
import kotlin.jvm.internal.Lambda;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -1773,4 +1778,60 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
return resultList;
}
@Override
public List<GroupDetailResultDTO> listGroupsByGroupIds(List<String> groupIds) {
LambdaQueryWrapper<ResiGroupEntity> query = new LambdaQueryWrapper<>();
query.in(ResiGroupEntity::getId, groupIds);
query.orderByDesc(ResiGroupEntity::getCreatedTime);
query.eq(ResiGroupEntity::getDelFlag, 0);
List<ResiGroupEntity> groupEntities = baseDao.selectList(query);
List<GroupDetailResultDTO> 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<GroupDetailResultDTO> listGroupDetailsExcludeGroupIds(List<String> excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType, String searchScopeObjectId, String sortType, String orderType) {
LambdaQueryWrapper<ResiGroupEntity> query = new LambdaQueryWrapper<>();
if (CollectionUtils.isNotEmpty(excludeGroupIds)) {
query.notIn(ResiGroupEntity::getId, excludeGroupIds);
}
// 利用pagehelper计算起始条数
query.last(String.format("limit %s, %s", startRow, rowCount));
SFunction<ResiGroupEntity, ?> sortFieldFun = null;
if (GroupFormDTO.SortTypeEnum.CREATE_TIME.getSortField().equals(sortType)) {
sortFieldFun = ResiGroupEntity::getCreatedTime;
}
if (SearchScopeTypeEnum.GRID.getScopeType().equals(searchScopeType)) {
query.eq(ResiGroupEntity::getGridId, searchScopeObjectId);
} else if (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<ResiGroupEntity> 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());
dto.setGridId(ge.getGridId());
return dto;
}).collect(Collectors.toList());
}
}

11
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

@ -247,14 +247,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'

Loading…
Cancel
Save