| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | | * @description: 一起议 |
| | | * @description: 议事投票 |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2021-01-22 14:51 |
| | | **/ |
| | |
| | | private ComActDiscussOptionService comActDiscussOptionService; |
| | | |
| | | /** |
| | | * 一起议-新增 |
| | | * 议事投票-新增 |
| | | * |
| | | * @param comActDiscussDTO |
| | | * 新增参数 |
| | |
| | | public R addDiscuss(ComActDiscussDTO comActDiscussDTO) { |
| | | ComActDiscussDO comActDiscussDO = new ComActDiscussDO(); |
| | | BeanUtils.copyProperties(comActDiscussDTO, comActDiscussDO); |
| | | Integer type = comActDiscussDTO.getType(); |
| | | Date nowDate = new Date(); |
| | | if(type.equals(ComActDiscussDO.type.tp)){//判断是投票,需要转义时间 |
| | | Date startTime = DateUtils.stringToDate(comActDiscussDTO.getStartTime(),DateUtils.ymdhms_format); |
| | | Date endTime = DateUtils.stringToDate(comActDiscussDTO.getEndTime(),DateUtils.ymdhms_format); |
| | | comActDiscussDO.setStartTime(startTime); |
| | | comActDiscussDO.setEndTime(endTime); |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.wks); |
| | | //根据时间判断状态是否开始 |
| | | if (startTime != null && startTime.getTime() <= nowDate.getTime()) { |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.jxz); |
| | | comActDiscussDO.setReleaseAt(nowDate); |
| | | } |
| | | }else{ |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.yfb); |
| | | } |
| | | //查询社区地址 |
| | | ComActVO comActVO = comActDiscussDAO.selectCommunity(comActDiscussDTO.getCommunityId()); |
| | | String address = comActDiscussDO.getAddress(); |
| | | if (ObjectUtils.isEmpty(address)) { |
| | |
| | | } |
| | | int insert = comActDiscussDAO.insert(comActDiscussDO); |
| | | if (insert > 0) { |
| | | ComActDiscussDO comActDiscussDO1 = comActDiscussDAO.selectOne(new QueryWrapper<ComActDiscussDO>().lambda() |
| | | .eq(ComActDiscussDO::getDiscussSubject, comActDiscussDTO.getDiscussSubject()) |
| | | .eq(ComActDiscussDO::getUserId, comActDiscussDTO.getUserId()) |
| | | .last(" order by create_at desc limit 1 ")); |
| | | Long comActDiscussDO1Id = comActDiscussDO1.getId(); |
| | | Integer type = comActDiscussDTO.getType(); |
| | | //如果是投票,需要把投票的选项存储 |
| | | if (type.equals(2)) { |
| | | Long comActDiscussDO1Id = comActDiscussDO.getId(); |
| | | List<ComActDiscussOptionDTO> discussOptions = comActDiscussDTO.getDiscussOptions(); |
| | | List<ComActDiscussOptionDO> comActDiscussOptionDOS = new ArrayList<>(); |
| | | discussOptions.forEach(s -> { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-详情 |
| | | * 议事投票-编辑 |
| | | * @param comActDiscussDTO 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R editDiscuss(ComActDiscussDTO comActDiscussDTO) { |
| | | Long comActDiscussDO1Id = comActDiscussDTO.getId(); |
| | | ComActDiscussDO comActDiscussDO = comActDiscussDAO.selectById(comActDiscussDO1Id); |
| | | if (ObjectUtils.isEmpty(comActDiscussDO)) { |
| | | return R.fail("议事投票不存在"); |
| | | } |
| | | if(!comActDiscussDO.getStatus().equals(ComActDiscussDO.status.wks) && !comActDiscussDO.getStatus().equals(ComActDiscussDO.status.yfb)){ |
| | | return R.fail("该状态不可修改"); |
| | | } |
| | | Integer type = comActDiscussDO.getType(); |
| | | Integer isRepeat = comActDiscussDO.getIsRepeat(); |
| | | BeanUtils.copyProperties(comActDiscussDTO, comActDiscussDO); |
| | | comActDiscussDO.setType(type); |
| | | comActDiscussDO.setIsRepeat(isRepeat); |
| | | Date nowDate = new Date(); |
| | | if(type.equals(ComActDiscussDO.type.tp)){//判断是投票,需要转义时间 |
| | | Date startTime = DateUtils.stringToDate(comActDiscussDTO.getStartTime(),DateUtils.ymdhms_format); |
| | | Date endTime = DateUtils.stringToDate(comActDiscussDTO.getEndTime(),DateUtils.ymdhms_format); |
| | | comActDiscussDO.setStartTime(startTime); |
| | | comActDiscussDO.setEndTime(endTime); |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.wks); |
| | | //根据时间判断状态是否开始 |
| | | if (startTime != null && startTime.getTime() <= nowDate.getTime()) { |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.jxz); |
| | | comActDiscussDO.setReleaseAt(nowDate); |
| | | } |
| | | }else{ |
| | | comActDiscussDO.setStatus(ComActDiscussDO.status.yfb); |
| | | } |
| | | comActDiscussDO.setUpdateAt(new Date()); |
| | | int insert = comActDiscussDAO.updateById(comActDiscussDO); |
| | | if (insert > 0) { |
| | | //如果是投票,需要把投票的选项存储 |
| | | if (type.equals(2)) { |
| | | comActDiscussOptionService.remove(new QueryWrapper<ComActDiscussOptionDO>().lambda() |
| | | .eq(ComActDiscussOptionDO::getDiscussId,comActDiscussDO1Id)); |
| | | List<ComActDiscussOptionDO> comActDiscussOptionDOS = new ArrayList<>(); |
| | | comActDiscussDTO.getDiscussOptions().forEach(s -> { |
| | | ComActDiscussOptionDO comActDiscussOptionDO = new ComActDiscussOptionDO(); |
| | | comActDiscussOptionDO.setDiscussId(comActDiscussDO1Id); |
| | | comActDiscussOptionDO.setOptionContent(s.getOptionContent()); |
| | | comActDiscussOptionDO.setOptionUrl(s.getOptionUrl()); |
| | | comActDiscussOptionDOS.add(comActDiscussOptionDO); |
| | | }); |
| | | comActDiscussOptionService.saveBatch(comActDiscussOptionDOS); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 议事投票-详情 |
| | | * |
| | | * @param id |
| | | * 主键 |
| | |
| | | public R detailDiscuss(Long id) { |
| | | ComActDiscussDO comActDiscussDO = comActDiscussDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comActDiscussDO)) { |
| | | return R.fail("一起议不存在"); |
| | | return R.fail("议事投票不存在"); |
| | | } |
| | | ComActDiscussVO comActDiscussVO = new ComActDiscussVO(); |
| | | BeanUtils.copyProperties(comActDiscussDO, comActDiscussVO); |
| | | Integer integer = comActDiscussCommentDAO.selectCount( |
| | | new QueryWrapper<ComActDiscussCommentDO>().lambda().eq(ComActDiscussCommentDO::getDiscussId, id)); |
| | | comActDiscussVO.setCommentNum(integer); |
| | | Integer integer1 = comActDiscussUserDAO |
| | | .selectCount(new QueryWrapper<ComActDiscussUserDO>().lambda().eq(ComActDiscussUserDO::getDiscussId, id)); |
| | | comActDiscussVO.setSignNum(integer1); |
| | | comActDiscussVO.setSignNum(comActDiscussDO.getFabulousNum()); |
| | | Integer type = comActDiscussVO.getType(); |
| | | if (type.equals(2)) { |
| | | List<ComActDiscussOptionDO> comActDiscussOptionDOS = comActDiscussOptionDAO.selectList( |
| | | new QueryWrapper<ComActDiscussOptionDO>().lambda().eq(ComActDiscussOptionDO::getDiscussId, id)); |
| | | List<ComActDiscussOptionVO> comActDiscussOptionVOS = new ArrayList<>(); |
| | | comActDiscussOptionDOS.forEach(comActDiscussOptionDO -> { |
| | | Long discussOptionDOId = comActDiscussOptionDO.getId(); |
| | | Integer selectCount = |
| | | comActDiscussOptionUserDAO.selectCount(new QueryWrapper<ComActDiscussOptionUserDO>().lambda() |
| | | .eq(ComActDiscussOptionUserDO::getDiscussOptionId, discussOptionDOId)); |
| | | ComActDiscussOptionVO comActDiscussOptionVO = new ComActDiscussOptionVO(); |
| | | BeanUtils.copyProperties(comActDiscussOptionDO, comActDiscussOptionVO); |
| | | comActDiscussOptionVO.setNum(selectCount); |
| | | comActDiscussOptionVOS.add(comActDiscussOptionVO); |
| | | }); |
| | | comActDiscussOptionVOS.sort(Comparator.comparing(ComActDiscussOptionVO::getNum).reversed()); |
| | | //查询选项列表 |
| | | List<ComActDiscussOptionVO> comActDiscussOptionVOS = comActDiscussOptionDAO.getDiscussOptionList(id); |
| | | comActDiscussVO.setComActDiscussOptionVOS(comActDiscussOptionVOS); |
| | | } |
| | | Long userId = comActDiscussDO.getUserId(); |
| | | LoginUserInfoVO loginUserInfoVO = comActDiscussDAO.selectUserByUserId(userId); |
| | | comActDiscussVO.setUserName(loginUserInfoVO.getName()); |
| | | |
| | | return R.ok(comActDiscussVO); |
| | | } |
| | | |
| | | /** |
| | | * 一起议-删除 |
| | | * 议事投票-删除 |
| | | * |
| | | * @param id |
| | | * 主键 |
| | |
| | | */ |
| | | @Override |
| | | public R deleteDiscuss(Long id) { |
| | | int delete = comActDiscussDAO.deleteById(id); |
| | | if (delete > 0) { |
| | | ComActDiscussDO comActDiscussDO = new ComActDiscussDO(); |
| | | comActDiscussDO.setId(id); |
| | | comActDiscussDO.setIsDel(ComActDiscussDO.isOk.yes); |
| | | if (comActDiscussDAO.updateById(comActDiscussDO) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 一起议-回复 |
| | | * 议事投票-回复 |
| | | * |
| | | * @param comActDiscussCommentDTO |
| | | * 评论内容 |
| | |
| | | Long discussId = comActDiscussCommentDTO.getDiscussId(); |
| | | ComActDiscussDO comActDiscussDO = comActDiscussDAO.selectById(discussId); |
| | | if (ObjectUtils.isEmpty(comActDiscussDO)) { |
| | | return R.fail("一起议不存在"); |
| | | return R.fail("议事投票不存在"); |
| | | } |
| | | ComActDiscussCommentDO comActDiscussCommentDO = new ComActDiscussCommentDO(); |
| | | BeanUtils.copyProperties(comActDiscussCommentDTO, comActDiscussCommentDO); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-分页查询 |
| | | * 议事投票-分页查询 |
| | | * |
| | | * @param pageComActDiscussDTO |
| | | * 查询参数 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-查看 |
| | | * 议事投票-后台分页查询 |
| | | * @param pageComActDiscussDTO 请求参数 |
| | | * @return 议事投票列表 |
| | | */ |
| | | @Override |
| | | public R pageDiscussAdmin(PageComActDiscussDTO pageComActDiscussDTO) { |
| | | return R.ok(comActDiscussDAO.pageDiscussAdmin(new Page<>(pageComActDiscussDTO.getPageNum(),pageComActDiscussDTO.getPageSize()), pageComActDiscussDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 议事投票-评论-查看 |
| | | * |
| | | * @param id |
| | | * 主键 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-置顶 |
| | | * 议事投票-评论-置顶 |
| | | * |
| | | * @param id |
| | | * 主键 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-回复 |
| | | * 议事投票-评论-回复 |
| | | * |
| | | * @param comActDiscussCommentDTO |
| | | * 回复内容 |
| | |
| | | Long discussId = comActDiscussCommentDO.getDiscussId(); |
| | | ComActDiscussDO comActDiscussDO = comActDiscussDAO.selectById(discussId); |
| | | if (ObjectUtils.isEmpty(comActDiscussDO)) { |
| | | return R.fail("一起议不存在"); |
| | | return R.fail("议事投票不存在"); |
| | | } |
| | | Long userId = comActDiscussDO.getUserId(); |
| | | Long userId1 = comActDiscussCommentDTO.getUserId(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-分页查询 |
| | | * 议事投票-评论-分页查询 |
| | | * |
| | | * @param pageComActDiscussCommentDTO |
| | | * 分页查询参数 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-分页查询 小程序 |
| | | * 议事投票-分页查询 小程序 |
| | | * |
| | | * @param pageComActDiscussDTO |
| | | * 查询参数 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-点赞、取消点赞 |
| | | * 议事投票-点赞、取消点赞 |
| | | * |
| | | * @param comActDiscussUserDTO |
| | | * 操作类型 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-分页查询 小程序 |
| | | * 议事投票-评论-分页查询 小程序 |
| | | * |
| | | * @param pageComActDiscussCommentDTO |
| | | * 分页参数 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-详情 小程序 |
| | | * 议事投票-详情 小程序 |
| | | * |
| | | * @param id |
| | | * 主键 |
| | |
| | | public R detailDiscussApplets(Long id, Long loginUserId) { |
| | | ComActDiscussDO comActDiscussDO = comActDiscussDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comActDiscussDO)) { |
| | | return R.fail("一起议不存在"); |
| | | return R.fail("议事投票不存在"); |
| | | } |
| | | ComActDiscussVO comActDiscussVO = new ComActDiscussVO(); |
| | | BeanUtils.copyProperties(comActDiscussDO, comActDiscussVO); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-投票 |
| | | * 议事投票-投票 |
| | | * |
| | | * @param comActDiscussOptionUserDTO |
| | | * 投票信息 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 一起议-评论-点赞、取消点赞 |
| | | * 议事投票-评论-点赞、取消点赞 |
| | | * |
| | | * @param comActDiscussCommentUserDTO |
| | | * 评论点赞 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 工作大屏-一起议列表 |
| | | * 工作大屏-议事投票列表 |
| | | * |
| | | * @param discussListDTO |
| | | * 请求参数 |
| | | * @return 一起议列表 |
| | | * @return 议事投票列表 |
| | | */ |
| | | @Override |
| | | public R getScreenDiscussList(ScreenDiscussListDTO discussListDTO) { |