|
|
@ -21,6 +21,7 @@ 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.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
@ -52,6 +53,7 @@ import com.epmet.service.IssueVoteDetailService; |
|
|
|
import com.epmet.service.IssueVoteStatisticalService; |
|
|
|
import com.epmet.utils.ModuleConstants; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -226,7 +228,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 == null || data.size() == NumConstant.ZERO ) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
//获取头像和昵称 eg:山东路168号-周先生
|
|
|
@ -237,14 +239,13 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
if (null == userResiInfoList || userResiInfoList.size() < NumConstant.ONE) { |
|
|
|
throw new RenException(IssueConstant.SELECT_USERINFO_EXCEPTION); |
|
|
|
} |
|
|
|
List<EvaluationListResultDTO> resultList = data.stream().flatMap(evaluation -> userResiInfoList.stream().filter(user -> |
|
|
|
return data.stream().flatMap(evaluation -> userResiInfoList.stream().filter(user -> |
|
|
|
evaluation.getUserId().equals(user.getUserId())).map(userInfo -> { |
|
|
|
EvaluationListResultDTO resultDTO = ConvertUtils.sourceToTarget(evaluation, EvaluationListResultDTO.class); |
|
|
|
resultDTO.setUserNickName(null == userInfo.getShowName() ? "" : userInfo.getShowName()); |
|
|
|
resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? "" : userInfo.getHeadPhoto()); |
|
|
|
resultDTO.setUserNickName(null == userInfo.getShowName() ? StrConstant.EPMETY_STR : userInfo.getShowName()); |
|
|
|
resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? StrConstant.EPMETY_STR : userInfo.getHeadPhoto()); |
|
|
|
return resultDTO; |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -283,7 +284,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
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()); |
|
|
|
List<String> statisiticalIds = statisticalList.stream().map(IssueVoteStatisticalDTO::getIssueId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (ids.size() > statisiticalIds.size()) { |
|
|
|
//差集
|
|
|
@ -325,16 +326,19 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
|
|
|
|
notExistedIds.removeAll(votedIssueIds); |
|
|
|
if(!notExistedIds.isEmpty()){ |
|
|
|
List<IssueVoteStatisticalDTO> collect = notExistedIds.stream().map(issueId -> { |
|
|
|
IssueVoteStatisticalDTO dto = new IssueVoteStatisticalDTO(); |
|
|
|
dto.setIssueId(issueId); |
|
|
|
dto.setSupportCount(NumConstant.ZERO); |
|
|
|
dto.setOppositionCount(NumConstant.ZERO); |
|
|
|
dto.setVotableCount(Optional.ofNullable(votableCountMap.get(issueGridMap.get(issueId))).orElse(NumConstant.ZERO)); |
|
|
|
dto.setCreatedBy(ModuleConstants.CREATED_BY_SYSTEM);dto.setUpdatedBy(ModuleConstants.CREATED_BY_SYSTEM); |
|
|
|
return dto; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if(!CollectionUtils.isEmpty(collect)) toInsert.addAll(collect);} |
|
|
|
List<IssueVoteStatisticalDTO> collect = notExistedIds.stream().map(issueId -> { |
|
|
|
IssueVoteStatisticalDTO dto = new IssueVoteStatisticalDTO(); |
|
|
|
dto.setIssueId(issueId); |
|
|
|
dto.setSupportCount(NumConstant.ZERO); |
|
|
|
dto.setOppositionCount(NumConstant.ZERO); |
|
|
|
dto.setVotableCount(Optional.ofNullable(votableCountMap.get(issueGridMap.get(issueId))).orElse(NumConstant.ZERO)); |
|
|
|
dto.setCreatedBy(ModuleConstants.CREATED_BY_SYSTEM);dto.setUpdatedBy(ModuleConstants.CREATED_BY_SYSTEM); |
|
|
|
return dto; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if(!CollectionUtils.isEmpty(collect)) { |
|
|
|
toInsert.addAll(collect); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
List<IssueAttitudeCountResultDTO> summaryList = issueVoteDetailDao.getVotingSummaryList(notExistedIds); |
|
|
@ -427,8 +431,11 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
List<IssueVoteStatisticalDTO> listToUpdate = new ArrayList<>(); |
|
|
|
setVotableCountsAndUpdateCache(listToUpdate,issues,votableCountMap); |
|
|
|
|
|
|
|
// listToUpdate批量更新
|
|
|
|
baseDao.updateBatchByIssueId(listToUpdate); |
|
|
|
// listToUpdate批量更新 todo 暂时解决下 分批插入
|
|
|
|
if (CollectionUtils.isNotEmpty(listToUpdate)) { |
|
|
|
ListUtils.partition(listToUpdate, NumConstant.ONE_HUNDRED) |
|
|
|
.forEach(part -> baseDao.updateBatchByIssueId(part)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
@ -550,8 +557,12 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
IssueVoteStatisticalDTO vote = new IssueVoteStatisticalDTO(); |
|
|
|
vote.setIssueId(issue.getId()); |
|
|
|
VoteRedisFormDTO cache = issueVoteDetailRedis.getVoteStatistical(issue.getId()); |
|
|
|
if(null == cache) continue; |
|
|
|
if(StringUtils.isBlank(cache.getIssueId())) cache.setIssueId(issue.getId()); |
|
|
|
if(null == cache) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(StringUtils.isBlank(cache.getIssueId())) { |
|
|
|
cache.setIssueId(issue.getId()); |
|
|
|
} |
|
|
|
vote.setCreatedBy(ModuleConstants.CREATED_BY_SYSTEM); |
|
|
|
vote.setUpdatedBy(ModuleConstants.CREATED_BY_SYSTEM); |
|
|
|
vote.setSupportCount(cache.getSupportAmount()); |
|
|
@ -563,7 +574,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt |
|
|
|
|
|
|
|
list.add(vote); |
|
|
|
|
|
|
|
if(cache.getShouldVoteCount() != vote.getVotableCount()){ |
|
|
|
if(!cache.getShouldVoteCount().equals(vote.getVotableCount())){ |
|
|
|
cache.setShouldVoteCount(vote.getVotableCount()); |
|
|
|
cache.setIssueId(issue.getId()); |
|
|
|
issueVoteDetailRedis.set(cache); |
|
|
|