Browse Source

议题表决统计

master
wangchao 5 years ago
parent
commit
492326b041
  1. 19
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  2. 19
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/CommonGridIdListFormDTO.java
  3. 19
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/GridVotableCountResultDTO.java
  4. 19
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/IssueAttitudeCountResultDTO.java
  5. 15
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/constant/IssueConstant.java
  6. 10
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java
  7. 25
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java
  8. 28
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteStatisticalDao.java
  9. 24
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/feign/ResiGroupFeignClient.java
  10. 13
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/feign/fallback/ResiGroupFeignClientFallBack.java
  11. 122
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java
  12. 10
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java
  13. 12
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteDetailService.java
  14. 27
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteStatisticalService.java
  15. 12
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java
  16. 13
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteDetailServiceImpl.java
  17. 230
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java
  18. 12
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml
  19. 36
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml
  20. 45
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDao.xml
  21. 25
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/CommonGridIdFormDTO.java
  22. 19
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/CommonGridIdListFormDTO.java
  23. 19
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/GridVotableCountResultDTO.java
  24. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java
  25. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java
  26. 27
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  27. 32
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java
  28. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java
  29. 30
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java
  30. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java
  31. 14
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

19
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -241,4 +241,23 @@ public class RedisUtils {
Long count = entityIdCounter.decrementAndGet();
return count;
}
/**
* @Description 对hash数据某一的属性进行递增操作
* @param key
* @param field
* @param delta
* @return
* @author wangc
* @date 2020.05.21 15:42
**/
public Map<String, Object> hincrby(String key,String field,Long delta){
//hincrby
Long count = redisTemplate.opsForHash().increment(key,field,delta);
if(count == -1){
return null;
}else{
return hGetAll(key);
}
}
}

19
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/CommonGridIdListFormDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 网格IdList
* @ClassName CommonGridIdListFormDTO
* @Auth wangc
* @Date 2020-05-22 09:17
*/
@Data
public class CommonGridIdListFormDTO implements Serializable {
private static final long serialVersionUID = 3188828578545996470L;
private List<String> gridIds;
}

19
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/GridVotableCountResultDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @Description 网格的应表决数 <GridId,votableCount>
* @ClassName GridVotableCountResultDTO
* @Auth wangc
* @Date 2020-05-22 09:18
*/
@Data
public class GridVotableCountResultDTO implements Serializable {
private static final long serialVersionUID = 5621545224177991150L;
Map<String,Integer> votableCountMap;
}

19
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/IssueAttitudeCountResultDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 议题Id和表决态度的数量
* @ClassName IssueAttitudeCountResultDTO
* @Auth wangc
* @Date 2020-05-22 01:19
*/
@Data
public class IssueAttitudeCountResultDTO implements Serializable {
private static final long serialVersionUID = 4471863386031944261L;
private String issueId;
private Integer count;
private String attitude;
}

15
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/constant/IssueConstant.java

@ -64,4 +64,19 @@ public interface IssueConstant {
String OPPOSE = "opposition";
String REDIS_KEY = "epmet:issue:";
/**
* 议题表决缓存属性值 supportAmount
* */
String CACHE_ATTRIBUTE_SUPPORT_AMOUNT = "supportAmount";
/**
* 议题表决缓存属性值 oppositionAmount
* */
String CACHE_ATTRIBUTE_OPPOSITION_AMOUNT = "oppositionAmount";
/**
* 议题表决缓存属性值 shouldVoteCount
* */
String CACHE_ATTRIBUTE_SHOULD_VOTE_COUNT = "shouldVoteCount";
}

10
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java

@ -33,6 +33,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 议题详情 关联话题转议题时间必须要和话题转议题时间一致关闭时间必须要和操作记录表的关闭记录时间一致转项目时间必须要和项目记录生成时间一致注意服务间调用的时间一致性每个议题最后总会被关闭
@ -117,4 +118,13 @@ public interface IssueDao extends BaseDao<IssueEntity> {
* @date 2020.05.19 15:00
**/
List<IssuesToBeCountedResultDTO> getIssueVotingStatistical();
/**
* @Description 条件查询出符合指定条件的议题ID集合
* @param issueDTO
* @return Set<IssueDTO>
* @author wangc
* @date 2020.05.22 00:36
**/
Set<IssueDTO> selectIssueIdsByCondition(IssueDTO issueDTO);
}

25
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java

@ -19,9 +19,12 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.VoteFormDTO;
import com.epmet.dto.result.IssueAttitudeCountResultDTO;
import com.epmet.entity.IssueVoteDetailEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
@ -48,4 +51,26 @@ public interface IssueVoteDetailDao extends BaseDao<IssueVoteDetailEntity> {
* @date 2020.05.20 10:52
**/
Set<String> getAttitudes();
/**
* @Description 得到某个议题某个态度的表决数
* @param issueId
* @param attitude
* @return int
* @author wangc
* @date 2020.05.21 17:16
**/
int getVotingCount(@Param("issueId")String issueId,@Param("attitude")String attitude);
/**
* @Description 批量查找议题某个态度的表决数
* @param ids
* @param attitude
* @return List<IssueVoteStatisticalDTO>
* @author wangc
* @date 2020.05.22 01:14
**/
List<IssueAttitudeCountResultDTO> getVotingCountList(@Param("ids")Set<String> ids, @Param("attitude")String attitude);
List<IssueAttitudeCountResultDTO> getVotingSummaryList(@Param("ids")Set<String> ids);
}

28
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteStatisticalDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IssueVoteStatisticalDTO;
import com.epmet.dto.PolyLineDTO;
import com.epmet.dto.form.IssueIdFormDTO;
import com.epmet.dto.result.VoteResultDTO;
@ -27,6 +28,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 议题表决统计表
@ -66,4 +68,30 @@ public interface IssueVoteStatisticalDao extends BaseDao<IssueVoteStatisticalEnt
*/
List<PolyLineDTO> polyLineData(IssueIdFormDTO issueId);
/**
* @Description 得到表决中的议题 来进行缓存与数据库的同步
* @param
* @return
* @author wangc
* @date 2020.05.21 14:45
**/
List<IssueVoteStatisticalDTO> getVotingIssuesStatisticalForSync();
/**
* @Description 通过IssueId获取
* @param issueId
* @return IssueVoteStatisticalDTO
* @author wangc
* @date 2020.05.21 16:33
**/
IssueVoteStatisticalDTO selectByIssueId(@Param("issueId")String issueId);
/**
* @Description 得到指定Id的统计数据
* @param ids
* @return List<IssueVoteStatisticalDTO>
* @author wangc
* @date 2020.05.22 00:49
**/
List<IssueVoteStatisticalDTO> selectListByIds(@Param("ids") Set<String> ids);
}

24
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/feign/ResiGroupFeignClient.java

@ -3,10 +3,11 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CheckTopicPublisherFormDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.CommonGridIdListFormDTO;
import com.epmet.dto.form.ShouldVoteCountFormDTO;
import com.epmet.dto.form.VoteFormDTO;
import com.epmet.dto.result.AgencyGridResultDTO;
import com.epmet.dto.result.CheckTopicPublisherResultDTO;
import com.epmet.dto.result.GridVotableCountResultDTO;
import com.epmet.dto.result.ShouldVoteCountResultDTO;
import com.epmet.feign.fallback.ResiGroupFeignClientFallBack;
import com.epmet.resi.group.dto.topic.ResiTopicDTO;
@ -59,4 +60,23 @@ public interface ResiGroupFeignClient {
@PostMapping("/resi/group/topic/checktopicpublisher")
Result<CheckTopicPublisherResultDTO> checkTopicPublisher(@RequestBody CheckTopicPublisherFormDTO formDTO);
/**
* @Description 得到一个网格下的应表数
* @param gridIdFormDTO
* @return Result<Integer>
* @author wangc
* @date 2020.05.21 15:12
**/
@PostMapping("/resi/group/member/votablecount")
Result<Integer> votableCount(@RequestBody CommonGridIdFormDTO gridIdFormDTO);
/**
* @Description 根据网格Id列表查询网格下所有加入组的组员
* @param gridList
* @return Result<GridVotableCountResultDTO>
* @author wangc
* @date 2020.05.22 10:12
**/
@PostMapping("votablecounts")
Result<GridVotableCountResultDTO> votableCounts(@RequestBody CommonGridIdListFormDTO gridList);
}

13
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/feign/fallback/ResiGroupFeignClientFallBack.java

@ -4,9 +4,12 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CheckTopicPublisherFormDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.CommonGridIdListFormDTO;
import com.epmet.dto.form.ShouldVoteCountFormDTO;
import com.epmet.dto.result.AgencyGridResultDTO;
import com.epmet.dto.result.CheckTopicPublisherResultDTO;
import com.epmet.dto.result.GridVotableCountResultDTO;
import com.epmet.dto.result.ShouldVoteCountResultDTO;
import com.epmet.feign.ResiGroupFeignClient;
import com.epmet.resi.group.dto.topic.ResiTopicDTO;
@ -39,4 +42,14 @@ public class ResiGroupFeignClientFallBack implements ResiGroupFeignClient {
public Result<CheckTopicPublisherResultDTO> checkTopicPublisher(CheckTopicPublisherFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "checkTopicPublisher", formDTO);
}
@Override
public Result<Integer> votableCount(CommonGridIdFormDTO gridIdFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "votableCount", gridIdFormDTO);
}
@Override
public Result<GridVotableCountResultDTO> votableCounts(CommonGridIdListFormDTO gridList) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "votableCounts", gridList);
}
}

122
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java

@ -20,8 +20,20 @@ package com.epmet.redis;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.IssueConstant;
import com.epmet.dto.IssueDTO;
import com.epmet.dto.IssueVoteStatisticalDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.VoteRedisFormDTO;
import com.epmet.entity.IssueVoteStatisticalEntity;
import com.epmet.feign.ResiGroupFeignClient;
import com.epmet.service.IssueService;
import com.epmet.service.IssueVoteDetailService;
import com.epmet.service.IssueVoteStatisticalService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -36,13 +48,29 @@ import java.util.Map;
*/
@Component
public class IssueVoteDetailRedis {
protected static final Logger logger = LoggerFactory.getLogger(IssueVoteDetailRedis.class);
@Autowired
private RedisUtils redisUtils;
@Autowired
private IssueVoteStatisticalService issueVoteStatisticalService;
@Autowired
private ResiGroupFeignClient resiGroupFeignClient;
@Autowired
private IssueService issueService;
@Autowired
private IssueVoteDetailService issueVoteDetailService;
public void delete(Object[] ids) {
}
public void set(VoteRedisFormDTO vote){
String key = IssueConstant.REDIS_KEY +vote.getIssueId();
//bean to map
@ -90,4 +118,98 @@ public class IssueVoteDetailRedis {
return t;
}
/**
* @Description 表决
* @param issueId
* @param attitude
* @return VoteRedisFormDTO
* @author wangc
* @date 2020.05.21 16:26
**/
public VoteRedisFormDTO vote(String issueId,String attitude){
Map<String, Object> objectMap = redisUtils.hincrby(
new StringBuilder(IssueConstant.REDIS_KEY).append(issueId).toString(),
StringUtils.equals(IssueConstant.SUPPORT,attitude) ? IssueConstant.CACHE_ATTRIBUTE_SUPPORT_AMOUNT
: IssueConstant.CACHE_ATTRIBUTE_OPPOSITION_AMOUNT,
NumConstant.ONE_L);
if(null != objectMap && objectMap.size() > NumConstant.ZERO){
return mapToEntity(objectMap, VoteRedisFormDTO.class);
}
//如果缓存中无相应数据,去投票详情表中计算出实时的数据放入缓存
//无需查询issue_vote_statistical中的数据,因为不是实时数据,可能不准确,有定时任务会自动同步
VoteRedisFormDTO voteCache = new VoteRedisFormDTO();
voteCache.setIssueId(issueId);
voteCache.setOppositionAmount(
StringUtils.equals(IssueConstant.SUPPORT,attitude) ?
issueVoteDetailService.getVotingCount(issueId,IssueConstant.OPPOSE) :
issueVoteDetailService.getVotingCount(issueId,IssueConstant.OPPOSE) + NumConstant.ONE
);
voteCache.setSupportAmount(
StringUtils.equals(IssueConstant.SUPPORT,attitude) ?
issueVoteDetailService.getVotingCount(issueId,IssueConstant.SUPPORT) + NumConstant.ONE :
issueVoteDetailService.getVotingCount(issueId,IssueConstant.SUPPORT)
);
IssueDTO issue = issueService.get(issueId);
if(null != issue){
CommonGridIdFormDTO gridId = new CommonGridIdFormDTO();
gridId.setGridId(issue.getGridId());
Result<Integer> votableCount =
resiGroupFeignClient.votableCount(gridId);
if(votableCount.success() && null != votableCount.getData()){
voteCache.setShouldVoteCount(votableCount.getData());
}else{
voteCache.setShouldVoteCount(NumConstant.ONE);
}
}else{
//如果没有该议题,终止所有操作
logger.warn(String.format("找不到指定Id的议题,Id:【%s】",issueId));
return null;
}
set(voteCache);
return voteCache;
}
/**
* @Description 根据issueId去缓存取表决统计数据如果没有去数据库查询并放入缓存
* @param issueId
* @return
* @author wangc
* @date 2020.05.21 22:31
**/
public VoteRedisFormDTO getVoteStatistical(String issueId){
String key = new StringBuilder(IssueConstant.REDIS_KEY).append(issueId).toString();
Map<String, Object> stringObjectMap = redisUtils.hGetAll(key);
if ( null != stringObjectMap && stringObjectMap.size() > NumConstant.ZERO ){
return mapToEntity(stringObjectMap, VoteRedisFormDTO.class);
}
//如果缓存中没有,去表决详情中计算出实时数据,并放入缓存中
//无需查询issue_vote_statistical中的数据,因为不是实时数据,可能不准确,有定时任务会自动同步
VoteRedisFormDTO voteCache = new VoteRedisFormDTO();
voteCache.setSupportAmount(issueVoteDetailService.getVotingCount(issueId,IssueConstant.SUPPORT));
voteCache.setOppositionAmount(issueVoteDetailService.getVotingCount(issueId,IssueConstant.OPPOSE));
IssueDTO issue = issueService.get(issueId);
if(null != issue){
CommonGridIdFormDTO gridId = new CommonGridIdFormDTO();
gridId.setGridId(issue.getGridId());
Result<Integer> votableCount =
resiGroupFeignClient.votableCount(gridId);
if(votableCount.success() && null != votableCount.getData()){
voteCache.setShouldVoteCount(votableCount.getData());
}else{
voteCache.setShouldVoteCount(NumConstant.ZERO);
}
set(voteCache);
return voteCache;
}else{
logger.warn(String.format("找不到指定Id的议题,Id:【%s】",issueId));
return null;
}
}
}

10
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java

@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author zxc
@ -197,4 +198,13 @@ public interface IssueService extends BaseService<IssueEntity> {
* @date 2020.05.14 10:33
**/
List<ClosedIssueListGovResultDTO> closedListGov(CommonIssueListFormDTO issueListForm);
/**
* @Description 条件查询出符合指定条件的议题ID集合
* @param issueDTO
* @return Set<IssueDTO>
* @author wangc
* @date 2020.05.22 00:36
**/
Set<IssueDTO> getIssueIdsByCondition(IssueDTO issueDTO);
}

12
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteDetailService.java

@ -24,6 +24,7 @@ import com.epmet.dto.form.CheckVoteFormDTO;
import com.epmet.dto.form.VoteFormDTO;
import com.epmet.dto.result.JoinVoteResultDTO;
import com.epmet.entity.IssueVoteDetailEntity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -109,4 +110,15 @@ public interface IssueVoteDetailService extends BaseService<IssueVoteDetailEntit
* @author zxc
*/
JoinVoteResultDTO joinVote(CheckVoteFormDTO checkVoteFormDTO);
/**
* @Description 得到某个议题某个态度的表决数
* @param issueId
* @param attitude
* @return
* @author wangc
* @date 2020.05.21 17:17
**/
int getVotingCount(String issueId, String attitude);
}

27
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteStatisticalService.java

@ -121,4 +121,31 @@ public interface IssueVoteStatisticalService extends BaseService<IssueVoteStatis
* @author zxc
*/
List<EvaluationListResultDTO> evaluationList(EvaluationListFormDTO formDTO);
/**
* @Description 将所有表决中的投票数从缓存同步到数据库要进行数据对比若数据一致无需更新
* @param
* @return
* @author wangc
* @date 2020.05.21 09:07
**/
void syncVotingCacheToDb();
/**
* @Description 对指定的issueId的议题表决统计数缓存与Db同步
* @param issueId
* @return
* @author wangc
* @date 2020.05.21 09:09
**/
void syncVotingCacheToDbByIssueId(String issueId);
/**
* @Description 通过IssueId获取
* @param issueId
* @return IssueVoteStatisticalDTO
* @author wangc
* @date 2020.05.21 16:33
**/
IssueVoteStatisticalDTO getByIssueId(String issueId);
}

12
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

@ -588,4 +588,16 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
return baseDao.selectClosedListGov(issueListForm);
}
/**
* @Description 条件查询出符合指定条件的议题ID集合
* @param issueDTO
* @return Set<IssueDTO>
* @author wangc
* @date 2020.05.22 00:36
**/
@Override
public Set<IssueDTO> getIssueIdsByCondition(IssueDTO issueDTO) {
return baseDao.selectIssueIdsByCondition(issueDTO);
}
}

13
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteDetailServiceImpl.java

@ -187,5 +187,18 @@ public class IssueVoteDetailServiceImpl extends BaseServiceImpl<IssueVoteDetailD
return resultDTO;
}
/**
* @Description 得到某个议题某个态度的表决数
* @param issueId
* @param attitude
* @return
* @author wangc
* @date 2020.05.21 17:17
**/
@Override
public int getVotingCount(String issueId, String attitude) {
return baseDao.getVotingCount(issueId,attitude);
}
}

230
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java

@ -26,25 +26,24 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.IssueConstant;
import com.epmet.dao.IssueDao;
import com.epmet.dao.IssueSatisfactionDetailDao;
import com.epmet.dao.IssueVoteDetailDao;
import com.epmet.dao.IssueVoteStatisticalDao;
import com.epmet.dto.IssueDTO;
import com.epmet.dto.IssueVoteStatisticalDTO;
import com.epmet.dto.PolyLineDTO;
import com.epmet.dto.form.EvaluationListFormDTO;
import com.epmet.dto.form.IssueIdFormDTO;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.form.VoteRedisFormDTO;
import com.epmet.dto.result.EvaluationListResultDTO;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.dto.result.VoteResultDTO;
import com.epmet.dto.result.VotingTrendResultDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.IssueVoteStatisticalEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.ResiGroupFeignClient;
import com.epmet.redis.IssueVoteDetailRedis;
import com.epmet.redis.IssueVoteStatisticalRedis;
import com.epmet.service.IssueVoteStatisticalService;
import com.epmet.utils.ModuleConstants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,11 +53,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 议题表决统计表
@ -81,6 +78,10 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
private IssueVoteDetailRedis issueVoteDetailRedis;
@Autowired
private IssueDao issueDao;
@Autowired
private IssueVoteDetailDao issueVoteDetailDao;
@Autowired
private ResiGroupFeignClient resiGroupFeignClient;
@Override
public PageData<IssueVoteStatisticalDTO> page(Map<String, Object> params) {
@ -98,8 +99,8 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
return ConvertUtils.sourceToTarget(entityList, IssueVoteStatisticalDTO.class);
}
private QueryWrapper<IssueVoteStatisticalEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<IssueVoteStatisticalEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<IssueVoteStatisticalEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -135,19 +136,19 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
}
/**
* @Description 表决中议题详情支持反对数
* @param issueId
* @Description 表决中议题详情支持反对数
* @author zxc
*/
@Override
public VoteResultDTO voteCount(TokenDto tokenDto,IssueIdFormDTO issueId) {
public VoteResultDTO voteCount(TokenDto tokenDto, IssueIdFormDTO issueId) {
VoteResultDTO voteResultDTO = issueVoteStatisticalDao.voteCount(issueId);
//校验是否已经投票
String voteStatus = issueVoteStatisticalDao.checkVote(issueId.getIssueId(), tokenDto.getUserId());
if (voteResultDTO!=null){
if (StringUtils.isBlank(voteStatus)){
if (voteResultDTO != null) {
if (StringUtils.isBlank(voteStatus)) {
voteResultDTO.setVoteFlag(false);
}else {
} else {
voteResultDTO.setVoteFlag(true);
VoteRedisFormDTO redisData = issueVoteDetailRedis.get(issueId.getIssueId());
voteResultDTO.setVoteType(voteStatus);
@ -160,25 +161,25 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
/**
* @Description 议题表决折线图
* @param issueId
* @Description 议题表决折线图
* @author zxc
*/
@Override
public VotingTrendResultDTO votingTrend(IssueIdFormDTO issueId) {
VoteRedisFormDTO voteRedisFormDTO = issueVoteDetailRedis.get(issueId.getIssueId());
VotingTrendResultDTO votingTrendResultDTO = new VotingTrendResultDTO();
BeanUtils.copyProperties(voteRedisFormDTO,votingTrendResultDTO);
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount()+voteRedisFormDTO.getOppositionAmount());
BeanUtils.copyProperties(voteRedisFormDTO, votingTrendResultDTO);
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount() + voteRedisFormDTO.getOppositionAmount());
List<PolyLineDTO> polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId);
PolyLineDTO polyLineDTO = new PolyLineDTO();
polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
//今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿
if (polyLineDTOS.size()==NumConstant.ZERO){
if (polyLineDTOS.size() == NumConstant.ZERO) {
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount());
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount());
polyLineDTOS.add(polyLineDTO);
}else {
} else {
//折线数据=DB
String date = issueDao.operateTime(issueId.getIssueId());
if (date.equals(LocalDate.now().toString())) {
@ -198,8 +199,8 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
}
/**
* @Description 满意度评价列表已关闭
* @param formDTO
* @Description 满意度评价列表已关闭
* @author zxc
*/
@Override
@ -207,7 +208,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
formDTO.setPageNo(pageIndex);
List<EvaluationListResultDTO> data = issueSatisfactionDetailDao.evaluationList(formDTO);
if (data.size()==NumConstant.ZERO||data==null){
if (data.size() == NumConstant.ZERO || data == null) {
return new ArrayList<>();
}
//获取头像和昵称 eg:山东路168号-周先生
@ -228,4 +229,181 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
return resultList;
}
/**
* @param
* @return
* @Description 将所有表决中的投票数从缓存同步到数据库要进行数据对比若数据一致无需更新
* @author wangc
* @date 2020.05.21 09:07
**/
@Override
public void syncVotingCacheToDb() {
IssueDTO issueParam = new IssueDTO();
issueParam.setIssueStatus(ModuleConstants.ISSUE_STATUS_VOTING);
//获取所有voting的议题
Set<IssueDTO> issues =
issueDao.selectIssueIdsByCondition(issueParam);
if(null == issues || issues.size()< NumConstant.ONE){
return;
}
Set<String> ids = issues.stream().map(IssueDTO::getId).collect(Collectors.toSet());
List<String> gridIds = issues.stream().map(IssueDTO::getGridId).collect(Collectors.toList());
CommonGridIdListFormDTO gridIdList = new CommonGridIdListFormDTO();
gridIdList.setGridIds(gridIds);
Result<GridVotableCountResultDTO> votableCountResult = resiGroupFeignClient.votableCounts(gridIdList);
Map<String,Integer> votableCountMap = null;
if(votableCountResult.success() && null != votableCountResult.getData() && null != votableCountResult.getData().getVotableCountMap()){
votableCountMap = votableCountResult.getData().getVotableCountMap();
}
List<IssueVoteStatisticalDTO> statisticalList =
baseDao.selectListByIds(ids);
if (null != statisticalList && statisticalList.size() > NumConstant.ZERO) {
List<String> statisiticalIds = statisticalList.stream().map(vote -> vote.getIssueId()).collect(Collectors.toList());
if (ids.size() > statisiticalIds.size()) {
//差集
Set<String> notExistedIds = new HashSet<String>();
notExistedIds.addAll(ids);
notExistedIds.removeAll(statisiticalIds);
//更新
//TODO 对ids进行更新 - 从缓存中拿取
if (notExistedIds.size() > NumConstant.ZERO) {
//新增
List<IssueVoteStatisticalDTO> toInsert = new ArrayList<>();
List<IssueAttitudeCountResultDTO> summaryList = issueVoteDetailDao.getVotingSummaryList(ids);
Map<String, List<IssueAttitudeCountResultDTO>> summaryMap =
summaryList.stream().collect(Collectors.groupingBy(IssueAttitudeCountResultDTO::getIssueId));
for (Map.Entry<String, List<IssueAttitudeCountResultDTO>> entry : summaryMap.entrySet()) {
IssueVoteStatisticalDTO obj = new IssueVoteStatisticalDTO();
obj.setIssueId(entry.getKey());
List<IssueAttitudeCountResultDTO> v = entry.getValue();
if (v.size() > NumConstant.ONE) {
v.forEach(dto -> {
if (StringUtils.equals(ModuleConstants.ISSUE_VOTING_ATTITUDE_SUPPORT, dto.getAttitude())) {
obj.setSupportCount(dto.getCount());
} else {
obj.setOppositionCount(dto.getCount());
}
});
} else {
if (StringUtils.equals(ModuleConstants.ISSUE_VOTING_ATTITUDE_SUPPORT, v.get(0).getAttitude())) {
obj.setSupportCount(v.get(0).getCount());
obj.setOppositionCount(NumConstant.ZERO);
} else {
obj.setOppositionCount(v.get(0).getCount());
obj.setSupportCount(NumConstant.ZERO);
}
}
toInsert.add(obj);
}
Set<String> setToInsert = toInsert.stream().map(IssueVoteStatisticalDTO::getIssueId).collect(Collectors.toSet());
Set<String> issuesNeverVotedIds = new HashSet<String>();
issuesNeverVotedIds.addAll(ids);
issuesNeverVotedIds.removeAll(setToInsert);
List<IssueVoteStatisticalDTO> summary = toInsert;
if (issuesNeverVotedIds.size() > NumConstant.ZERO) {
List<IssueVoteStatisticalDTO> toInsert2 = new ArrayList<>();
toInsert2 = issuesNeverVotedIds.stream().map(id -> {
IssueVoteStatisticalDTO dto = new IssueVoteStatisticalDTO();
dto.setOppositionCount(NumConstant.ZERO);
dto.setSupportCount(NumConstant.ZERO);
return dto;
}).collect(Collectors.toList());
summary = Stream.of(toInsert, toInsert2)
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
}
//TODO 批量查找collect的votableCount
//TODO 批量插入
}
}
else if (ids.size() < statisiticalIds.size()) {
//统计数大于议题数,数据出错
//找出多余数据,删除
//差集
Set<String> redundantIds = new HashSet<String>();
redundantIds.addAll(statisiticalIds);
redundantIds.removeAll(ids);
//将redundantIds的议题统计信息删除
//因为statisiticalIds是通过ids查询出,因此不会出现这种情况
} else {
//数据吻合,全部更新
List<IssueVoteStatisticalDTO> listToUpdate = new ArrayList<>();
Map<String,List<IssueDTO>> gridIssueMap =
issues.stream().collect(Collectors.groupingBy(IssueDTO::getGridId);
for(Map.Entry<String,List<IssueDTO>> entry : gridIssueMap.entrySet()){
String k = entry.getKey();
List<IssueDTO> v = entry.getValue();
for(IssueDTO issue : v){
IssueVoteStatisticalDTO vote = new IssueVoteStatisticalDTO();
vote.setIssueId(issue.getId());
VoteRedisFormDTO cache = issueVoteDetailRedis.get(issue.getId());
if(null == cache)
continue;
vote.setSupportCount(cache.getSupportAmount());
vote.setOppositionCount(cache.getOppositionAmount());
vote.setVotableCount( null == votableCountMap ?
NumConstant.ZERO :
null == votableCountMap.get(k) ? NumConstant.ZERO : votableCountMap.get(k)
);
//if(cache.get)
}
}
}
}else{
//ids中的议题没有任何统计信息 - 全部添加
//TODO 根据ids去缓存中取值
}
}
/**
* @Description 对指定的issueId的议题表决统计数缓存与Db同步
* @param issueId
* @return
* @author wangc
* @date 2020.05.21 09:09
**/
@Override
public void syncVotingCacheToDbByIssueId(String issueId) {
}
/**
* @Description 通过IssueId获取
* @param issueId
* @return IssueVoteStatisticalDTO
* @author wangc
* @date 2020.05.21 16:33
**/
@Override
public IssueVoteStatisticalDTO getByIssueId(String issueId) {
return baseDao.selectByIssueId(issueId);
}
}

12
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml

@ -324,5 +324,17 @@
</select>
<!-- 条件查询出符合指定条件的议题ID集合 -->
<select id="selectIssueIdsByCondition" parameterType="com.epmet.dto.IssueDTO" resultType="com.epmet.dto.IssueDTO">
SELECT
ID,
GRID_ID
FROM
ISSUE
WHERE
DEL_FLAG = '0'
AND
ISSUE_STATUS = #{issueStatus}
</select>
</mapper>

36
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml

@ -35,4 +35,40 @@
FROM
ISSUE_VOTE_DETAIL
</select>
<!-- 得到某个议题某个态度的表决数 -->
<select id="getVotingCount" resultType="int">
SELECT COUNT(ATTITUDE) AS count
FROM ISSUE_VOTE_DETAIL
WHERE
DEL_FLAG = '0'
AND ISSUE_ID = #{issueId}
AND ATTITUDE = #{attitude}
</select>
<!-- 批量查找议题某个态度的表决数 -->
<select id="getVotingCountList" resultType="com.epmet.dto.result.IssueAttitudeCountResultDTO">
SELECT ISSUE_ID,COUNT(ATTITUDE) AS count
FROM ISSUE_VOTE_DETAIL
WHERE
DEL_FLAG = '0'
AND ATTITUDE = #{attitude}
<foreach collection="issueId" item="ids" open="AND (" separator="OR" close=")">
ISSUE_ID = #{issueId}
</foreach>
</select>
<select id="getVotingSummaryList" resultType="com.epmet.dto.result.IssueAttitudeCountResultDTO">
SELECT
issue_id,
attitude,
count( attitude ) as count
FROM
ISSUE_VOTE_DETAIL
WHERE
del_flag = '0'
GROUP BY
issue_id,
attitude
</select>
</mapper>

45
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDao.xml

@ -69,4 +69,49 @@
ORDER BY statistical_date ASC
</select>
<!-- 得到表决中的议题 来进行缓存与数据库的同步 -->
<select id="getVotingIssuesStatisticalForSync" resultType="com.epmet.dto.IssueVoteStatisticalDTO" >
SELECT
vote.ID,
issue.ID AS issueId,
vote.SUPPORT_COUNT,
vote.OPPOSITION_COUNT,
vote.VOTABLE_COUNT
FROM
ISSUE issue
LEFT JOIN ISSUE_VOTE_STATISTICAL vote ON issue.ID = vote.ISSUE_ID
AND vote.DEL_FLAG = '0'
WHERE
issue.DEL_FLAG = '0'
AND issue.ISSUE_STATUS = 'voting'
</select>
<!-- 通过IssueId获取 -->
<select id="selectByIssueId" resultType="com.epmet.dto.IssueVoteStatisticalDTO">
SELECT
*
FROM
ISSUE_VOTE_STATISTICAL
WHERE
DEL_FLAG = '0'
AND
ISSUE_ID = #{issueId}
</select>
<!-- 得到指定Id的统计数据 -->
<select id="selectListByIds" resultType="com.epmet.dto.IssueVoteStatisticalDTO">
SELECT
ID,
ISSUE_ID,
SUPPORT_COUNT,
OPPOSITION_COUNT,
VOTABLE_COUNT
FROM
ISSUE_VOTE_STATISTICAL
WHERE
DEL_FLAG = '0'
<foreach item="issueId" collection="ids" open="AND (" separator="or" close=")" index="">
ISSUE_ID = #{issueId}
</foreach>
</select>
</mapper>

25
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/CommonGridIdFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.resi.group.dto.member.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description
* @ClassName CommonGridIdFormDTO
* @Author wangc
* @date 2020.04.24 14:17
*/
@Data
public class CommonGridIdFormDTO implements Serializable {
private static final long serialVersionUID = 2496019865436084805L;
/**
* 网格Id
* */
@NotBlank(message = "网格Id不能为空")
private String gridId;
}

19
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/CommonGridIdListFormDTO.java

@ -0,0 +1,19 @@
package com.epmet.resi.group.dto.member.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 网格IdList
* @ClassName CommonGridIdListFormDTO
* @Auth wangc
* @Date 2020-05-22 09:17
*/
@Data
public class CommonGridIdListFormDTO implements Serializable {
private static final long serialVersionUID = 3188828578545996470L;
private List<String> gridIds;
}

19
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/GridVotableCountResultDTO.java

@ -0,0 +1,19 @@
package com.epmet.resi.group.dto.member.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @Description 网格的应表决数 <GridId,votableCount>
* @ClassName GridVotableCountResultDTO
* @Auth wangc
* @Date 2020-05-22 09:18
*/
@Data
public class GridVotableCountResultDTO implements Serializable {
private static final long serialVersionUID = 5621545224177991150L;
Map<String,Integer> votableCountMap;
}

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

@ -19,6 +19,7 @@ package com.epmet.modules.group.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.group.entity.ResiGroupEntity;
import com.epmet.resi.group.dto.group.ResiGroupDTO;
import com.epmet.resi.group.dto.group.form.*;
import com.epmet.resi.group.dto.group.result.*;
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO;
@ -162,4 +163,13 @@ public interface ResiGroupDao extends BaseDao<ResiGroupEntity> {
* @author zxc
*/
ShouldVoteCountResultDTO shouldVoteCount(ShouldVoteCountFormDTO formDTO);
/**
* @Description 根据网格IdList查询小组信息
* @param gridIds
* @return List<ResiGroupDTO>
* @author wangc
* @date 2020.05.22 09:54
**/
List<ResiGroupDTO> selectGroupListByGridIds(@Param("gridIds") List<String> gridIds);
}

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

@ -30,6 +30,7 @@ import com.epmet.resi.group.dto.group.result.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 群组信息表
@ -261,6 +262,15 @@ public interface ResiGroupService extends BaseService<ResiGroupEntity> {
**/
List<String> getGroupIdByGridId(String gridId);
/**
* @Description 返回 Map<gridId,List<ResiGroupDTO>>
* @param gridIdList
* @return Map<String,List<ResiGroupDTO>>
* @author wangc
* @date 2020.05.22 09:27
**/
Map<String, Set<String>> getGroupIdsByGridIdList(List<String> gridIdList);
/**
* @Description 校验用户是否加入小组
* @param gridId

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

@ -72,6 +72,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 群组信息表
@ -508,7 +509,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
ResiGroupMemberInfoRedisDTO memberRedis = new ResiGroupMemberInfoRedisDTO();
memberRedis.setUserId(resiGroupMemberDTO.getCustomerUserId());
memberRedis.setGroupLeaderFlag("leader");
memberRedis.setGroupLeaderFlag(ModuleConstant.GROUP_LEADER);
memberRedis.setEnterGroupType(resiGroupMemberDTO.getEnterGroupType());
memberRedis.setMemberStatus(resiGroupMemberDTO.getStatus());
memberRedis.setGroupId(resiGroupMemberDTO.getResiGroupId());
@ -816,6 +817,30 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
return baseDao.getGroupIdByGridId(gridId);
}
/**
* @Description 返回 Map<gridId,List<ResiGroupDTO>>
* @param gridIdList
* @return Map<String,List<ResiGroupDTO>>
* @author wangc
* @date 2020.05.22 09:27
**/
@Override
public Map<String, Set<String>> getGroupIdsByGridIdList(List<String> gridIdList) {
if(null == gridIdList || gridIdList.size() < NumConstant.ONE)
return null;
Map<String, Set<String>> result = new HashMap<>();
List<ResiGroupDTO> groups = new ArrayList<>();
Map<String,List<ResiGroupDTO>> groupMap
= groups.stream().collect(Collectors.groupingBy(ResiGroupDTO::getGridId));
groupMap.forEach((k,v)->{
Set<String> groupIds =
v.stream().map(ResiGroupDTO::getId).collect(Collectors.toSet());
result.put(k,groupIds);
});
return result;
}
/**
* @Description 校验用户是否加入小组
* @param gridId

32
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java

@ -24,12 +24,11 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.resi.group.dto.member.form.*;
import com.epmet.resi.group.dto.member.result.ApplyingMemberResultDTO;
import com.epmet.resi.group.dto.member.result.GridVotableCountResultDTO;
import com.epmet.resi.group.dto.member.result.GroupMemberListResultDTO;
import oracle.jdbc.proxy.annotation.Post;
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 org.springframework.web.bind.annotation.*;
import java.util.List;
@ -160,4 +159,29 @@ public class ResiGroupMemberController {
return resiGroupMemberService.slientMember(slientMemberFormDTO);
}
/**
* @Description 得到一个网格下的应表决数
* @param gridIdFormDTO
* @return Result<Integer>
* @author wangc
* @date 2020.05.21 15:03
**/
@PostMapping(value = "votablecount")
public Result<Integer> votableCount(@RequestBody CommonGridIdFormDTO gridIdFormDTO){
ValidatorUtils.validateEntity(gridIdFormDTO);
return new Result<Integer>().ok(resiGroupMemberService.gridResiCount(gridIdFormDTO.getGridId()));
}
/**
* @Description 根据网格Id列表查询网格下所有加入组的组员
* @param gridList
* @return Result<GridVotableCountResultDTO>
* @author wangc
* @date 2020.05.22 10:12
**/
@PostMapping("votablecounts")
public Result<GridVotableCountResultDTO> votableCounts(@RequestBody CommonGridIdListFormDTO gridList){
return new Result<GridVotableCountResultDTO>().ok(resiGroupMemberService.votableCount(gridList));
}
}

10
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java

@ -24,6 +24,7 @@ import com.epmet.modules.member.entity.ResiGroupMemberEntity;
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO;
import com.epmet.resi.group.dto.member.form.*;
import com.epmet.resi.group.dto.member.result.ApplyingMemberResultDTO;
import com.epmet.resi.group.dto.member.result.GridVotableCountResultDTO;
import com.epmet.resi.group.dto.member.result.GroupMemberListResultDTO;
import java.util.List;
@ -185,4 +186,13 @@ public interface ResiGroupMemberService extends BaseService<ResiGroupMemberEntit
* @date 2020.05.14 10:48
**/
Integer gridResiCount(String gridId);
/**
* @Description 根据网格Id查询网格下所有加入组的组员
* @param gridList
* @return GridVotableCountResultDTO
* @author wangc
* @date 2020.05.22 09:23
**/
GridVotableCountResultDTO votableCount(CommonGridIdListFormDTO gridList);
}

30
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java

@ -63,6 +63,7 @@ import com.epmet.resi.group.dto.member.ResiGroupMemberDTO;
import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO;
import com.epmet.resi.group.dto.member.form.*;
import com.epmet.resi.group.dto.member.result.ApplyingMemberResultDTO;
import com.epmet.resi.group.dto.member.result.GridVotableCountResultDTO;
import com.epmet.resi.group.dto.member.result.GroupMemberListResultDTO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -582,6 +583,35 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
return NumConstant.ZERO;
}
/**
* @Description 根据网格Id查询网格下所有加入组的组员
* @param gridList
* @return GridVotableCountResultDTO
* @author wangc
* @date 2020.05.22 09:23
**/
@Override
public GridVotableCountResultDTO votableCount(CommonGridIdListFormDTO gridList) {
if(null == gridList || null == gridList.getGridIds() || gridList.getGridIds().size() < NumConstant.ONE)
return null;
Map<String,Integer> votableCountMap = new HashMap<>();
Map<String,Set<String>> gridGroups =
resiGroupService.getGroupIdsByGridIdList(gridList.getGridIds());
gridGroups.forEach((k,v)->{
Set<String> set = new HashSet<>();
v.forEach(groupId -> {
Set<String> members = resiGroupMemberRedis.getGroupMemberIds(groupId);
if(null != members && members.size() > NumConstant.ZERO){
set.addAll(members);
}
});
votableCountMap.put(k,set.size());
});
GridVotableCountResultDTO result = new GridVotableCountResultDTO();
result.setVotableCountMap(votableCountMap);
return result;
}
/**
* @Description 将ResiGroupMemberDTO转换成ResiGroupMemberInfoRedisDTO
* @Param

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java

@ -209,6 +209,8 @@ public interface ModuleConstant extends Constant {
* */
String RESI_GROUP_ID_CAMEL = "resiGroupId";
String RESI_GOUP_ID = "RESI_GOUP_ID";
/**
* APP 居民端
* */

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

@ -322,4 +322,18 @@
AND rg.del_flag = 0
AND rg.grid_id = #{gridId}
</select>
<!-- 根据网格IdList查询小组信息 -->
<select id="selectGroupListByGridIds" resultType="com.epmet.resi.group.dto.group.ResiGroupDTO">
SELECT
ID,
GRID_ID
FROM
RESI_GROUP
WHERE
DEL_FLAG = '0'
<foreach collection="gridIds" item="gridId" open="AND (" separator=" or " close=")" index="index">
GRID_ID = #{gridId}
</foreach>
</select>
</mapper>

Loading…
Cancel
Save