| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jetbrains.annotations.Nullable; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.discuss.entity.PublicDiscussEntity; |
| | | import org.springblade.modules.discuss.entity.TopicsEntity; |
| | | import org.springblade.modules.discuss.entity.UserTopicsEntity; |
| | | import org.springblade.modules.discuss.excel.UserTopicsExcel; |
| | | import org.springblade.modules.discuss.mapper.UserTopicsMapper; |
| | | import org.springblade.modules.discuss.service.IPublicDiscussService; |
| | | import org.springblade.modules.discuss.service.ITopicsService; |
| | | import org.springblade.modules.discuss.service.IUserTopicsService; |
| | | import org.springblade.modules.discuss.vo.TopicsVO; |
| | | import org.springblade.modules.discuss.vo.UserTopicsVO; |
| | | import org.springblade.modules.district.entity.DistrictEntity; |
| | | import org.springblade.modules.district.service.IDistrictService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户议题报表 服务实现类 |
| | |
| | | |
| | | @Override |
| | | public IPage<UserTopicsVO> selectUserTopicsPage(IPage<UserTopicsVO> page, UserTopicsVO userTopics) { |
| | | if (StringUtils.isNotBlank(userTopics.getDistrictId())) { |
| | | List<String> longs = JSON.parseArray(userTopics.getDistrictId()).toJavaList(String.class); |
| | | IDistrictService bean = SpringUtils.getBean(IDistrictService.class); |
| | | List<DistrictEntity> list = bean.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, longs)); |
| | | List<String> collect = list.stream().map(item -> |
| | | item.getAoiCode() |
| | | ).collect(Collectors.toList()); |
| | | if (collect != null) { |
| | | userTopics.setAoiCodeList(collect); |
| | | } |
| | | } |
| | | return page.setRecords(baseMapper.selectUserTopicsPage(page, userTopics)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean batchSave(List<TopicsVO> topics) throws Exception { |
| | | public String batchSave(List<TopicsVO> topics) throws Exception { |
| | | // 判断是否一户一票 还是一人一票 |
| | | IPublicDiscussService bean = SpringUtil.getBean(IPublicDiscussService.class); |
| | | PublicDiscussEntity one = bean.getOne(Wrappers.<PublicDiscussEntity>lambdaQuery().eq(PublicDiscussEntity::getArticleId, topics.get(0).getArticleId())); |
| | | // 一户一票 |
| | | if (one.getVoteRestrictions().equals(CommonConstant.NUMBER_ONE)) { |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery().eq(UserTopicsEntity::getHouseCode, topics.get(0).getHouseCode())); |
| | | if (count > 1) { |
| | | throw new Exception("您的房屋已投票,不能重复投票!"); |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery() |
| | | .eq(UserTopicsEntity::getHouseCode, topics.get(0).getHouseCode()) |
| | | .eq(UserTopicsEntity::getArticleId, topics.get(0).getArticleId())); |
| | | if (count > 0) { |
| | | return "您的房屋已投票,不能重复投票!"; |
| | | } |
| | | } else { |
| | | // |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery().eq(UserTopicsEntity::getUserId, AuthUtil.getUserId())); |
| | | if (count > 1) { |
| | | throw new Exception("您的已投票,不能重复投票!"); |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery() |
| | | .eq(UserTopicsEntity::getUserId, AuthUtil.getUserId()) |
| | | .eq(UserTopicsEntity::getArticleId, topics.get(0).getArticleId())); |
| | | if (count > 0) { |
| | | return "您已投票,不能重复投票!"; |
| | | } |
| | | } |
| | | Boolean userTopics = getaBoolean(topics); |
| | | if (userTopics != null) return userTopics; |
| | | return false; |
| | | if (userTopics) return "200"; |
| | | return "操作失败!"; |
| | | } |
| | | |
| | | @Nullable |
| | |
| | | return saveBatch(objectsTwo); |
| | | } |
| | | } |
| | | return null; |
| | | return false; |
| | | } |
| | | |
| | | |
| | |
| | | .groupBy(UserTopicsEntity::getUserId)); |
| | | return list.size(); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserTopicsExcel> exportUser(UserTopicsVO userTopics) { |
| | | if (StringUtils.isNotBlank(userTopics.getDistrictId())) { |
| | | List<String> longs = JSON.parseArray(userTopics.getDistrictId()).toJavaList(String.class); |
| | | IDistrictService bean = SpringUtils.getBean(IDistrictService.class); |
| | | List<DistrictEntity> list = bean.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, longs)); |
| | | List<String> collect = list.stream().map(item -> |
| | | item.getAoiCode() |
| | | ).collect(Collectors.toList()); |
| | | if (collect != null) { |
| | | userTopics.setAoiCodeList(collect); |
| | | } |
| | | } |
| | | List<UserTopicsExcel> userTopicsExcels = baseMapper.exportUser(userTopics); |
| | | return userTopicsExcels; |
| | | } |
| | | } |