|
@ -26,25 +26,24 @@ import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.constant.IssueConstant; |
|
|
import com.epmet.constant.IssueConstant; |
|
|
import com.epmet.dao.IssueDao; |
|
|
import com.epmet.dao.IssueDao; |
|
|
import com.epmet.dao.IssueSatisfactionDetailDao; |
|
|
import com.epmet.dao.IssueSatisfactionDetailDao; |
|
|
|
|
|
import com.epmet.dao.IssueVoteDetailDao; |
|
|
import com.epmet.dao.IssueVoteStatisticalDao; |
|
|
import com.epmet.dao.IssueVoteStatisticalDao; |
|
|
|
|
|
import com.epmet.dto.IssueDTO; |
|
|
import com.epmet.dto.IssueVoteStatisticalDTO; |
|
|
import com.epmet.dto.IssueVoteStatisticalDTO; |
|
|
import com.epmet.dto.PolyLineDTO; |
|
|
import com.epmet.dto.PolyLineDTO; |
|
|
import com.epmet.dto.form.EvaluationListFormDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.IssueIdFormDTO; |
|
|
import com.epmet.dto.result.*; |
|
|
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.entity.IssueVoteStatisticalEntity; |
|
|
import com.epmet.entity.IssueVoteStatisticalEntity; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
|
|
import com.epmet.feign.ResiGroupFeignClient; |
|
|
import com.epmet.redis.IssueVoteDetailRedis; |
|
|
import com.epmet.redis.IssueVoteDetailRedis; |
|
|
import com.epmet.redis.IssueVoteStatisticalRedis; |
|
|
import com.epmet.redis.IssueVoteStatisticalRedis; |
|
|
import com.epmet.service.IssueVoteStatisticalService; |
|
|
import com.epmet.service.IssueVoteStatisticalService; |
|
|
|
|
|
import com.epmet.utils.ModuleConstants; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -54,11 +53,9 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.ZoneOffset; |
|
|
import java.time.ZoneOffset; |
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 议题表决统计表 |
|
|
* 议题表决统计表 |
|
@ -81,6 +78,10 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
private IssueVoteDetailRedis issueVoteDetailRedis; |
|
|
private IssueVoteDetailRedis issueVoteDetailRedis; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IssueDao issueDao; |
|
|
private IssueDao issueDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IssueVoteDetailDao issueVoteDetailDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiGroupFeignClient resiGroupFeignClient; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<IssueVoteStatisticalDTO> page(Map<String, Object> params) { |
|
|
public PageData<IssueVoteStatisticalDTO> page(Map<String, Object> params) { |
|
@ -98,8 +99,8 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
return ConvertUtils.sourceToTarget(entityList, IssueVoteStatisticalDTO.class); |
|
|
return ConvertUtils.sourceToTarget(entityList, IssueVoteStatisticalDTO.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private QueryWrapper<IssueVoteStatisticalEntity> getWrapper(Map<String, Object> params){ |
|
|
private QueryWrapper<IssueVoteStatisticalEntity> getWrapper(Map<String, Object> params) { |
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
QueryWrapper<IssueVoteStatisticalEntity> wrapper = new QueryWrapper<>(); |
|
|
QueryWrapper<IssueVoteStatisticalEntity> wrapper = new QueryWrapper<>(); |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
@ -135,19 +136,19 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 表决中议题详情——支持、反对数 |
|
|
|
|
|
* @param issueId |
|
|
* @param issueId |
|
|
|
|
|
* @Description 表决中议题详情——支持、反对数 |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public VoteResultDTO voteCount(TokenDto tokenDto,IssueIdFormDTO issueId) { |
|
|
public VoteResultDTO voteCount(TokenDto tokenDto, IssueIdFormDTO issueId) { |
|
|
VoteResultDTO voteResultDTO = issueVoteStatisticalDao.voteCount(issueId); |
|
|
VoteResultDTO voteResultDTO = issueVoteStatisticalDao.voteCount(issueId); |
|
|
//校验是否已经投票
|
|
|
//校验是否已经投票
|
|
|
String voteStatus = issueVoteStatisticalDao.checkVote(issueId.getIssueId(), tokenDto.getUserId()); |
|
|
String voteStatus = issueVoteStatisticalDao.checkVote(issueId.getIssueId(), tokenDto.getUserId()); |
|
|
if (voteResultDTO!=null){ |
|
|
if (voteResultDTO != null) { |
|
|
if (StringUtils.isBlank(voteStatus)){ |
|
|
if (StringUtils.isBlank(voteStatus)) { |
|
|
voteResultDTO.setVoteFlag(false); |
|
|
voteResultDTO.setVoteFlag(false); |
|
|
}else { |
|
|
} else { |
|
|
voteResultDTO.setVoteFlag(true); |
|
|
voteResultDTO.setVoteFlag(true); |
|
|
VoteRedisFormDTO redisData = issueVoteDetailRedis.get(issueId.getIssueId()); |
|
|
VoteRedisFormDTO redisData = issueVoteDetailRedis.get(issueId.getIssueId()); |
|
|
voteResultDTO.setVoteType(voteStatus); |
|
|
voteResultDTO.setVoteType(voteStatus); |
|
@ -160,25 +161,25 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 议题表决折线图 |
|
|
|
|
|
* @param issueId |
|
|
* @param issueId |
|
|
|
|
|
* @Description 议题表决折线图 |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public VotingTrendResultDTO votingTrend(IssueIdFormDTO issueId) { |
|
|
public VotingTrendResultDTO votingTrend(IssueIdFormDTO issueId) { |
|
|
VoteRedisFormDTO voteRedisFormDTO = issueVoteDetailRedis.get(issueId.getIssueId()); |
|
|
VoteRedisFormDTO voteRedisFormDTO = issueVoteDetailRedis.get(issueId.getIssueId()); |
|
|
VotingTrendResultDTO votingTrendResultDTO = new VotingTrendResultDTO(); |
|
|
VotingTrendResultDTO votingTrendResultDTO = new VotingTrendResultDTO(); |
|
|
BeanUtils.copyProperties(voteRedisFormDTO,votingTrendResultDTO); |
|
|
BeanUtils.copyProperties(voteRedisFormDTO, votingTrendResultDTO); |
|
|
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount()+voteRedisFormDTO.getOppositionAmount()); |
|
|
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount() + voteRedisFormDTO.getOppositionAmount()); |
|
|
List<PolyLineDTO> polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId); |
|
|
List<PolyLineDTO> polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId); |
|
|
PolyLineDTO polyLineDTO = new PolyLineDTO(); |
|
|
PolyLineDTO polyLineDTO = new PolyLineDTO(); |
|
|
polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"))); |
|
|
polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"))); |
|
|
//今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿
|
|
|
//今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿
|
|
|
if (polyLineDTOS.size()==NumConstant.ZERO){ |
|
|
if (polyLineDTOS.size() == NumConstant.ZERO) { |
|
|
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount()); |
|
|
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount()); |
|
|
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount()); |
|
|
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount()); |
|
|
polyLineDTOS.add(polyLineDTO); |
|
|
polyLineDTOS.add(polyLineDTO); |
|
|
}else { |
|
|
} else { |
|
|
//折线数据=DB
|
|
|
//折线数据=DB
|
|
|
String date = issueDao.operateTime(issueId.getIssueId()); |
|
|
String date = issueDao.operateTime(issueId.getIssueId()); |
|
|
if (date.equals(LocalDate.now().toString())) { |
|
|
if (date.equals(LocalDate.now().toString())) { |
|
@ -198,8 +199,8 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 满意度评价列表——已关闭 |
|
|
|
|
|
* @param formDTO |
|
|
* @param formDTO |
|
|
|
|
|
* @Description 满意度评价列表——已关闭 |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
@ -207,7 +208,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); |
|
|
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); |
|
|
formDTO.setPageNo(pageIndex); |
|
|
formDTO.setPageNo(pageIndex); |
|
|
List<EvaluationListResultDTO> data = issueSatisfactionDetailDao.evaluationList(formDTO); |
|
|
List<EvaluationListResultDTO> data = issueSatisfactionDetailDao.evaluationList(formDTO); |
|
|
if (data.size()==NumConstant.ZERO||data==null){ |
|
|
if (data.size() == NumConstant.ZERO || data == null) { |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
//获取头像和昵称 eg:山东路168号-周先生
|
|
|
//获取头像和昵称 eg:山东路168号-周先生
|
|
@ -228,4 +229,231 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
return resultList; |
|
|
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); |
|
|
|
|
|
Set<String> existedIds = new HashSet<>(); |
|
|
|
|
|
existedIds.addAll(ids); |
|
|
|
|
|
existedIds.retainAll(statisiticalIds); |
|
|
|
|
|
//更新
|
|
|
|
|
|
//对ids进行更新 - 从缓存中拿取
|
|
|
|
|
|
List<IssueVoteStatisticalDTO> listToUpdate = new ArrayList<>(); |
|
|
|
|
|
setVotableCountsAndUpdateCache(listToUpdate, |
|
|
|
|
|
existedIds.stream().flatMap(existedId -> issues.stream().filter(issue -> |
|
|
|
|
|
StringUtils.equals(issue.getId(),existedId)).map(issueDTO -> { |
|
|
|
|
|
return issueDTO; |
|
|
|
|
|
})).collect(Collectors.toSet()), |
|
|
|
|
|
votableCountMap); |
|
|
|
|
|
|
|
|
|
|
|
//TODO 批量更新listToUpdate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//批量查找summary的votableCount
|
|
|
|
|
|
Map<String,List<IssueDTO>> gridIssueMap = |
|
|
|
|
|
issues.stream().collect(Collectors.groupingBy(IssueDTO::getGridId)); |
|
|
|
|
|
for(IssueVoteStatisticalDTO vote : summary){ |
|
|
|
|
|
for(Map.Entry<String,List<IssueDTO>> entry : gridIssueMap.entrySet()){ |
|
|
|
|
|
String k = entry.getKey(); |
|
|
|
|
|
List<IssueDTO> v = entry.getValue(); |
|
|
|
|
|
if(null == v || v.size() < NumConstant.ONE) continue; |
|
|
|
|
|
for(IssueDTO issue : v){ |
|
|
|
|
|
if(StringUtils.equals(vote.getIssueId(),issue.getId())) |
|
|
|
|
|
vote.setVotableCount( |
|
|
|
|
|
null == votableCountMap ? NumConstant.ZERO |
|
|
|
|
|
: null == votableCountMap.get(k) ? NumConstant.ZERO : votableCountMap.get(k) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for(Map.Entry<String,List<IssueDTO>> entry : gridIssueMap.entrySet()){ |
|
|
|
|
|
String k = entry.getKey(); |
|
|
|
|
|
List<IssueDTO> v = entry.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
|
|
|
|
|
|
|
setVotableCountsAndUpdateCache(listToUpdate,issues,votableCountMap); |
|
|
|
|
|
|
|
|
|
|
|
//TODO listToUpdate批量更新
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 遍历应表决数 |
|
|
|
|
|
* @param list - List<IssueVoteStatisticalDTO> | Set<IssueDTO> | Map<String,Integer> |
|
|
|
|
|
* @return |
|
|
|
|
|
* @author wangc |
|
|
|
|
|
* @date 2020.05.22 11:55 |
|
|
|
|
|
**/ |
|
|
|
|
|
private void setVotableCountsAndUpdateCache(List<IssueVoteStatisticalDTO> list, |
|
|
|
|
|
Set<IssueDTO> issues, |
|
|
|
|
|
Map<String,Integer> votableCountMap){ |
|
|
|
|
|
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) |
|
|
|
|
|
); |
|
|
|
|
|
list.add(vote); |
|
|
|
|
|
if(cache.getShouldVoteCount() != vote.getVotableCount()){ |
|
|
|
|
|
issueVoteDetailRedis.hset(issue.getId(),ModuleConstants.SHOULD_VOTE_COUNT,vote.getVotableCount()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |