Browse Source

【新增】1.完成我所在的小组排名

dev_shibei_match
wxz 4 years ago
parent
commit
0955cf0500
  1. 9
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java
  2. 6
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java
  3. 20
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java
  4. 23
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java
  5. 13
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java
  6. 74
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  7. 46
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml
  8. 17
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java
  9. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java
  10. 11
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java
  11. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java
  12. 5
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java
  13. 17
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  14. 11
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java
  15. 11
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java
  16. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  17. 18
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

9
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java

@ -18,14 +18,17 @@ public class GroupPointFormDTO implements Serializable {
public interface GroupPoint extends CustomerClientShowGroup {}
public interface GridRank extends CustomerClientShowGroup {}
public interface GridScopeRank extends CustomerClientShowGroup {}
public interface CustomerScopeRank extends CustomerClientShowGroup {}
public interface GridScopeRank {}
public interface CustomerScopeRank {}
public interface MyGroupRank {}
@NotBlank(message = "小组Id不能为空", groups = {GroupPoint.class, GridRank.class})
private String groupId;
@NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class})
@NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class, MyGroupRank.class})
private String gridId;
@NotBlank(message = "客户Id不能为空", groups = {CustomerScopeRank.class})
private String customerId;
@NotBlank(message = "用户ID不能为空", groups = {MyGroupRank.class})
private String userId;
/** 页码 */
private Integer pageNo = 1;

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

@ -47,4 +47,10 @@ public class GroupPointRankingResultDTO implements Serializable {
/** 所属网格名称 */
private String gridNamePath;
/** 网格内排名 */
private Integer gridRanking;
/** 客户下总排名 */
private Integer customerRanking;
}

20
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java

@ -133,7 +133,7 @@ public class GroupPointController {
Integer pageNo = formDTO.getPageNo();
Integer pageSize = formDTO.getPageSize();
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize);
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInPercificScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize);
return new Result<PageData<GroupPointRankingResultDTO>>().ok(page);
}
@ -152,8 +152,24 @@ public class GroupPointController {
Integer pageNo = formDTO.getPageNo();
Integer pageSize = formDTO.getPageSize();
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize);
PageData<GroupPointRankingResultDTO> page = bizPointTotalDetailService.listGroupPointRandingInPercificScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize);
return new Result<PageData<GroupPointRankingResultDTO>>().ok(page);
}
/**
* @description 小组排名- 列出我所在的小组的积分排名
*
* @param formDTO
* @return
* @author wxz
* @date 2021.09.08 13:31:09
*/
@PostMapping("grouppointranking/mygroups")
public Result<List<GroupPointRankingResultDTO>> listMyGroupPointRanding(@RequestBody GroupPointFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.MyGroupRank.class);
String userId = formDTO.getUserId();
String gridId = formDTO.getGridId();
List<GroupPointRankingResultDTO> list = bizPointTotalDetailService.listMyGroupPointRanding(userId, gridId);
return new Result<List<GroupPointRankingResultDTO>>().ok(list);
}
}

23
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/BizPointTotalDetailDao.java

@ -40,4 +40,27 @@ public interface BizPointTotalDetailDao extends BaseDao<BizPointTotalDetailEntit
* @return com.epmet.dto.BizPointTotalDetailDTO
*/
BizPointTotalDetailDTO selectDataByObject(@Param("type")String type, @Param("objectId")String objectId);
/**
* @description 查询object在指定范围内的排名
*
* @param bizType
* @param groupId
* @param scope
* @return
* @author wxz
* @date 2021.09.08 17:36:17
*/
Integer getRanking(@Param("bizType") String bizType, @Param("groupId") String groupId, @Param("scope") String scope);
/**
* @description 搜索指定范围内最低名次
*
* @param scope
* @param scopeId
* @return
* @author wxz
* @date 2021.09.09 09:53:37
*/
Integer getMinRanking(@Param("bizType") String bizType,@Param("searchScope") String scope, @Param("searchScopeId") String scopeId);
}

13
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java

@ -148,5 +148,16 @@ public interface BizPointTotalDetailService extends BaseService<BizPointTotalDet
* @author wxz
* @date 2021.09.07 14:18:08
*/
PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize);
PageData<GroupPointRankingResultDTO> listGroupPointRandingInPercificScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize);
/**
* @description 小组排名- 列出我所在的小组的积分排名
*
* @param userId
* @param gridId
* @return
* @author wxz
* @date 2021.09.08 13:34:49
*/
List<GroupPointRankingResultDTO> listMyGroupPointRanding(String userId, String gridId);
}

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

@ -41,11 +41,13 @@ import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.resi.group.dto.group.form.GroupFormDTO;
import com.epmet.resi.group.dto.group.form.GroupPointDetailFormDTO;
import com.epmet.resi.group.dto.group.form.GroupsByMemberFormDTO;
import com.epmet.resi.group.dto.group.result.GroupDetailResultDTO;
import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO;
import com.epmet.dto.result.GroupPointRankingResultDTO;
import com.epmet.entity.BizPointTotalDetailEntity;
import com.epmet.resi.group.dto.group.ResiGroupDTO;
import com.epmet.resi.group.dto.group.result.RankingResultDTO;
import com.epmet.resi.group.enums.SearchScopeTypeEnum;
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient;
import com.epmet.service.BizPointTotalDetailService;
@ -261,7 +263,7 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
}
@Override
public PageData<GroupPointRankingResultDTO> listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) {
public PageData<GroupPointRankingResultDTO> listGroupPointRandingInPercificScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) {
// 1.查询有积分的小组得分排名
PageInfo<BizPointTotalDetailEntity> entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> {
@ -306,14 +308,21 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
rankingInfoDTOs.addAll(gap);
}
// 4.排名填充
// 4.排名填充。有积分的按照积分排序,分数一样的名次一样
Integer ranking = page.getStartRow() + 1;
Integer prevPoint = null;
for (GroupPointRankingResultDTO g : rankingInfoDTOs) {
Integer point = Integer.valueOf(g.getPoint());
if (prevPoint != null && prevPoint > point) {
// 此举是为了在积分一样的情况下,给与相同的排名
ranking ++;
}
GridInfoCache gridInfo = getGridInfo(g.getGridId());
g.setRanking(String.valueOf(ranking));
g.setGridId(g.getGridId());
g.setGridNamePath(gridInfo.getGridNamePath());
ranking ++;
g.setRanking(String.valueOf(ranking));
prevPoint = point;
}
PageData<GroupPointRankingResultDTO> pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal());
return pageData;
@ -422,4 +431,61 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
ope.putAll(RedisKeys.getGridInfoKey(gridId), BeanUtil.beanToMap(cache));
return cache;
}
@Override
public List<GroupPointRankingResultDTO> listMyGroupPointRanding(String userId, String gridId) {
// 1.查询网格内我所在的小组
GroupsByMemberFormDTO form = new GroupsByMemberFormDTO();
form.setGridId(gridId);
form.setUserId(userId);
List<GroupDetailResultDTO> groupList = getResultDataOrThrowsException(resiGroupOpenFeignClient.listGroupsByMember(form),
ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【我所在的小组排名】查询组列表失败");
if (CollectionUtils.isEmpty(groupList)) {
return new ArrayList();
}
// 2.填充分数和排名
GroupDetailResultDTO firstGroup = groupList.get(0);
// 网格和客户下,分别有多少个有积分的小组,后面用于给哪些没有任何积分记录的小组排名
Integer gridMinRanking = baseDao.getMinRanking("group", "grid", gridId);
Integer customerMinRanking = baseDao.getMinRanking("group", "customer", firstGroup.getCustomerId());
List<GroupPointRankingResultDTO> groupDtoList = groupList.stream().map(g -> {
// 积分
Integer point = 0;
// 网格内的排名
Integer gridRanking = null;
// 客户下的排名
Integer customerRanking = null;
LambdaQueryWrapper<BizPointTotalDetailEntity> query = new LambdaQueryWrapper<>();
query.eq(BizPointTotalDetailEntity::getBizType, "group");
query.eq(BizPointTotalDetailEntity::getObjectId, g.getGroupId());
BizPointTotalDetailEntity groupPoint = baseDao.selectOne(query);
if (groupPoint == null) {
// 该小组没有积分
gridRanking = gridMinRanking + 1;
customerRanking = customerMinRanking + 1;
} else {
// 该小组有积分
point = groupPoint.getTotalPoint();
gridRanking = baseDao.getRanking("group", g.getGroupId(), "grid");
customerRanking = baseDao.getRanking("group", g.getGroupId(), "customer");
}
GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO();
dto.setGridId(g.getGridId());
dto.setGroupHeadPhoto(g.getGroupHeadPhoto());
dto.setGroupType(g.getGroupType());
dto.setGroupId(g.getGroupId());
dto.setGroupName(g.getGroupName());
dto.setPoint(point.toString());
dto.setGridRanking(gridRanking);
dto.setCustomerRanking(customerRanking);
return dto;
}).collect(Collectors.toList());
return groupDtoList;
}
}

46
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/BizPointTotalDetailDao.xml

@ -29,5 +29,51 @@
and OBJECT_ID = #{objectId}
</select>
<!--查询object在指定范围内的排名-->
<select id="getRanking" resultType="java.lang.Integer">
select count(distinct p_2.TOTAL_POINT) + 1 as ranking
from biz_point_total_detail point
inner join biz_point_total_detail p_2
on (point.BIZ_TYPE = p_2.BIZ_TYPE and p_2.DEL_FLAG = 0 and
point.TOTAL_POINT &lt; p_2.TOTAL_POINT
<if test="scope == 'grid'">
and point.GRID_ID = p_2.GRID_ID
</if>
<if test="scope == 'customer'">
and point.CUSTOMER_ID = p_2.CUSTOMER_ID
</if>
)
where
point.OBJECT_ID = #{groupId}
and point.BIZ_TYPE = #{bizType}
and point.DEL_FLAG = 0
</select>
<!--获取指定范围内最低排名。子查询是取最低分的那个对象出来-->
<select id="getMinRanking" resultType="java.lang.Integer">
select count(distinct p.TOTAL_POINT) + 1 as ranking
from biz_point_total_detail p
inner join
(select point.OBJECT_ID, point.BIZ_TYPE, point.GRID_ID, point.CUSTOMER_ID, point.TOTAL_POINT
from biz_point_total_detail point
where point.BIZ_TYPE = #{bizType}
and point.DEL_FLAG = 0
<if test="searchScope == 'grid'">
and point.GRID_ID = #{searchScopeId}
</if>
<if test="searchScope == 'customer'">
and point.CUSTOMER_ID = #{searchScopeId}
</if>
order by point.TOTAL_POINT asc limit 1) t
on (p.BIZ_TYPE = t.BIZ_TYPE
and p.TOTAL_POINT > t.TOTAL_POINT
<if test="searchScope == 'grid'">
and p.GRID_ID = t.GRID_ID
</if>
<if test="searchScope == 'customer'">
and p.CUSTOMER_ID = t.CUSTOMER_ID
</if>
)
</select>
</mapper>

17
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupsByMemberFormDTO.java

@ -0,0 +1,17 @@
package com.epmet.resi.group.dto.group.form;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @Description 根据成员查询组列表form
* @author wxz
* @date 2021.09.08 14:12:44
*/
@Data
public class GroupsByMemberFormDTO {
private String gridId;
@NotNull(message = "成员用户ID不能为空")
private String userId;
}

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

@ -21,5 +21,5 @@ public class GroupDetailResultDTO {
private String remark;
/** 群组类型:branch:支部小组,ordinary:楼院小组 */
private String groupType;
private String customerId;
}

11
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RankingResultDTO.java

@ -0,0 +1,11 @@
package com.epmet.resi.group.dto.group.result;
import lombok.Data;
@Data
public class RankingResultDTO {
private Integer gridRanking;
private Integer customerRanking;
}

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

@ -311,4 +311,14 @@ public interface ResiGroupOpenFeignClient {
@PostMapping("/resi/group/group/list-groupinfos-exclude-groupids")
Result<List<GroupDetailResultDTO>> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form);
/**
* @description 根据组成员查询所在的小组列表可选条件包括:grid
*
* @param formDTO
* @return
* @author wxz
* @date 2021.09.08 13:51:05
*/
@PostMapping("/resi/group/group/list-groups-by-member")
Result<List<GroupDetailResultDTO>> listGroupsByMember(@RequestBody GroupsByMemberFormDTO formDTO);
}

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

@ -230,4 +230,9 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien
public Result<List<GroupDetailResultDTO>> listGroupDetailsExcludeGroupIds(GroupFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsExcludeGroupIds", form);
}
@Override
public Result<List<GroupDetailResultDTO>> listGroupsByMember(GroupsByMemberFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupsByMember", formDTO);
}
}

17
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java

@ -637,4 +637,21 @@ public class ResiGroupController {
List<GroupDetailResultDTO> groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType());
return new Result<List<GroupDetailResultDTO>>().ok(groups);
}
/**
* @description 根据组成员查询所在的小组列表可选条件包括:grid
*
* @param formDTO
* @return
* @author wxz
* @date 2021.09.08 13:51:05
*/
@PostMapping("list-groups-by-member")
public Result<List<GroupDetailResultDTO>> listGroupsByMember(@RequestBody GroupsByMemberFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
String gridId = formDTO.getGridId();
String userId = formDTO.getUserId();
List<GroupDetailResultDTO> groups = resiGroupService.listGroupsByMember(userId, gridId);
return new Result<List<GroupDetailResultDTO>>().ok(groups);
}
}

11
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java

@ -335,4 +335,15 @@ public interface ResiGroupDao extends BaseDao<ResiGroupEntity> {
* @return java.util.List<com.epmet.resi.group.dto.member.result.GroupAchievementDTO>
*/
List<GroupAchievementDTO> selectRecentGroupAchievements(@Param("userId") String userId, @Param("gridId") String gridId);
/**
* @description 根据组成员查询所在组列表如有需要可以增加其他if条件或者增加排序参数
*
* @param memberUserId
* @param gridId
* @return
* @author wxz
* @date 2021.09.08 14:00:52
*/
List<GroupDetailResultDTO> listGroupsByMember(@Param("memberUserId") String memberUserId, @Param("gridId") String gridId);
}

11
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java

@ -461,4 +461,15 @@ public interface ResiGroupService extends BaseService<ResiGroupEntity> {
* @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);
/**
* @description 根据成员查询组列表
*
* @param memberUserId
* @param gridId
* @return
* @author wxz
* @date 2021.09.08 13:59:31
*/
List<GroupDetailResultDTO> listGroupsByMember(String memberUserId, String gridId);
}

6
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -40,6 +40,7 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.constant.ReadFlagConstant;
import com.epmet.dto.BizPointTotalDetailDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.UserInfoResultDTO;
import com.epmet.dto.result.UserResiInfoResultDTO;
@ -1833,4 +1834,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
return dto;
}).collect(Collectors.toList());
}
@Override
public List<GroupDetailResultDTO> listGroupsByMember(String memberUserId, String gridId) {
return baseDao.listGroupsByMember(memberUserId, gridId);
}
}

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

@ -1059,4 +1059,22 @@
ORDER BY releaseTime DESC
</select>
<select id="listGroupsByMember" resultType="com.epmet.resi.group.dto.group.result.GroupDetailResultDTO">
select resi_group.ID as groupId,
resi_group.GRID_ID,
resi_group.GROUP_HEAD_PHOTO,
resi_group.GROUP_NAME,
resi_group.GROUP_INTRODUCTION,
resi_group.GROUP_TYPE,
resi_group.CUSTOMER_ID
from resi_group
inner join resi_group_member
on (resi_group.ID = resi_group_member.RESI_GROUP_ID and resi_group_member.DEL_FLAG = 0)
where resi_group_member.CUSTOMER_USER_ID = #{memberUserId}
and resi_group.DEL_FLAG = 0
<if test="gridId != null and gridId.trim() != ''">
and resi_group.GRID_ID=#{gridId}
</if>
order by resi_group.CREATED_TIME desc
</select>
</mapper>

Loading…
Cancel
Save