| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ActivitySignUpDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActActivityVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.PageActivityMembersVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.PartyBuildingActivityVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO; |
| | | import com.panzhihua.service_dangjian.dao.ComBpActivityDAO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbActivityMemberDAO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbMemberDAO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComBpActivityDO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbActivityDO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbActivityMemberDO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbMemberDO; |
| | | import com.panzhihua.service_dangjian.service.ComBpActivityService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.client.utils.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @author: huang.hongfa weixin hhf9596 qq 959656820 |
| | | * @create: 2020-12-01 09:16 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | public class ComBpActivityServiceImpl implements ComBpActivityService { |
| | | @Resource |
| | |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageActivityMembersVO.getPageNum(); |
| | | Long pageSize = pageActivityMembersVO.getPageSize(); |
| | | if (ObjectUtils.isEmpty(pageNum)) { |
| | | Long activityId = pageActivityMembersVO.getActivityId(); |
| | | if (null == pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (ObjectUtils.isEmpty(pageSize)) { |
| | | if (null == pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<PageActivityMembersVO> iPage = comPbActivityMemberDAO.pageActivityMembers(page, pageActivityMembersVO); |
| | | return R.ok(iPage); |
| | | Map<String,Object> map=new HashMap<>(3); |
| | | ComPbActivityDO comPbActivityDO = comBpActivityDAO.selectById(activityId); |
| | | map.put("page",iPage); |
| | | map.put("name",comPbActivityDO.getName()); |
| | | map.put("createAt",DateUtils.formatDate(comPbActivityDO.getCreateAt(),"yyyy-MM-dd HH:mm:ss")); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 活动详情内容 |
| | | */ |
| | | @Override |
| | | public R activityinfo(Long id) { |
| | | ComBpActivityDO comBpActivityDO = comBpActivityDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comBpActivityDO)) { |
| | | return R.fail(); |
| | | public R activityinfo(Long id,Long userId) { |
| | | ComPbActivityDO comPbActivityDO = comBpActivityDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comPbActivityDO)) { |
| | | return R.fail("活动不存在"); |
| | | } |
| | | PartyBuildingActivityVO partyBuildingActivityVO=new PartyBuildingActivityVO(); |
| | | BeanUtils.copyProperties(comBpActivityDO,partyBuildingActivityVO); |
| | | List<ComPbActivityMemberDO> comPbActivityMemberDOS = comPbActivityMemberDAO.selectList(new QueryWrapper<ComPbActivityMemberDO>().lambda().eq(ComPbActivityMemberDO::getActivityId, id)); |
| | | PartyBuildingActivityVO partyBuildingActivityVO = new PartyBuildingActivityVO(); |
| | | BeanUtils.copyProperties(comPbActivityDO, partyBuildingActivityVO); |
| | | List<ComPbActivityMemberDO> comPbActivityMemberDOS = comPbActivityMemberDAO.selectList(new QueryWrapper<ComPbActivityMemberDO>().lambda().eq(ComPbActivityMemberDO::getActivityId, id).orderByDesc(ComPbActivityMemberDO::getCreateAt)); |
| | | List<PartyBuildingMemberVO> partyBuildingMemberVOS = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(comPbActivityMemberDOS)) { |
| | | List<Long> collect = comPbActivityMemberDOS.stream().map(ComPbActivityMemberDO::getMemberId).collect(Collectors.toList()); |
| | | int size = collect.size(); |
| | | if (size>=6) { |
| | | collect=collect.subList(0,6); |
| | | } |
| | | List<ComPbMemberDO> comPbMemberDOS = comPbMemberDAO.selectList(new QueryWrapper<ComPbMemberDO>().lambda().in(ComPbMemberDO::getId, collect)); |
| | | List<PartyBuildingMemberVO> partyBuildingMemberVOS=new ArrayList<>(); |
| | | comPbMemberDOS.forEach(comPbMemberDO -> { |
| | | PartyBuildingMemberVO partyBuildingMemberVO=new PartyBuildingMemberVO(); |
| | | BeanUtils.copyProperties(comPbMemberDO,partyBuildingMemberVO); |
| | | PartyBuildingMemberVO partyBuildingMemberVO = new PartyBuildingMemberVO(); |
| | | BeanUtils.copyProperties(comPbMemberDO, partyBuildingMemberVO); |
| | | partyBuildingMemberVOS.add(partyBuildingMemberVO); |
| | | }); |
| | | partyBuildingActivityVO.setPartyBuildingMemberVOS(partyBuildingMemberVOS); |
| | | partyBuildingActivityVO.setParticipationActualNum(size); |
| | | } else { |
| | | partyBuildingActivityVO.setParticipationActualNum(0); |
| | | } |
| | | ComPbActivityMemberDO comPbActivityMemberDO=comPbActivityMemberDAO.selectByUserIdActivityId(id,userId); |
| | | if (ObjectUtils.isEmpty(comPbActivityMemberDO)) { |
| | | partyBuildingActivityVO.setIsSign(0); |
| | | } else { |
| | | partyBuildingActivityVO.setIsSign(1); |
| | | } |
| | | partyBuildingActivityVO.setPartyBuildingMemberVOS(partyBuildingMemberVOS); |
| | | return R.ok(partyBuildingActivityVO); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public R addactivity(PartyBuildingActivityVO partyBuildingActivityVO) { |
| | | ComBpActivityDO comBpActivityDO=new ComBpActivityDO(); |
| | | BeanUtils.copyProperties(partyBuildingActivityVO,comBpActivityDO); |
| | | comBpActivityDO.setCreateAt(new Date()); |
| | | int insert = comBpActivityDAO.insert(comBpActivityDO); |
| | | if (insert>0) { |
| | | ComPbActivityDO comPbActivityDO = new ComPbActivityDO(); |
| | | BeanUtils.copyProperties(partyBuildingActivityVO, comPbActivityDO); |
| | | comPbActivityDO.setCreateAt(new Date()); |
| | | int insert = comBpActivityDAO.insert(comPbActivityDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | */ |
| | | @Override |
| | | public R updateActivity(PartyBuildingActivityVO partyBuildingActivityVO) { |
| | | ComBpActivityDO comBpActivityDO=new ComBpActivityDO(); |
| | | BeanUtils.copyProperties(partyBuildingActivityVO,comBpActivityDO); |
| | | int update = comBpActivityDAO.updateById(comBpActivityDO); |
| | | if (update>0) { |
| | | ComPbActivityDO comPbActivityDO = new ComPbActivityDO(); |
| | | BeanUtils.copyProperties(partyBuildingActivityVO, comPbActivityDO); |
| | | int update = comBpActivityDAO.updateById(comPbActivityDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | */ |
| | | @Override |
| | | public R releaseActivity(Long id) { |
| | | ComBpActivityDO comBpActivityDO=new ComBpActivityDO(); |
| | | comBpActivityDO.setId(id); |
| | | comBpActivityDO.setStatus(2); |
| | | comBpActivityDO.setReleaseTime(new Date()); |
| | | int update = comBpActivityDAO.updateById(comBpActivityDO); |
| | | if (update>0) { |
| | | ComPbActivityDO comPbActivityDO = new ComPbActivityDO(); |
| | | comPbActivityDO.setId(id); |
| | | comPbActivityDO.setStatus(2); |
| | | comPbActivityDO.setReleaseTime(new Date()); |
| | | int update = comBpActivityDAO.updateById(comPbActivityDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | @Override |
| | | public R deleteActivity(Long id) { |
| | | int delete = comBpActivityDAO.deleteById(id); |
| | | if (delete>0) { |
| | | if (delete > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | Page page = new Page<>(); |
| | | Long pageNum = partyBuildingActivityVO.getPageNum(); |
| | | Long pageSize = partyBuildingActivityVO.getPageSize(); |
| | | if (ObjectUtils.isEmpty(pageNum)) { |
| | | if (null == pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (ObjectUtils.isEmpty(pageSize)) { |
| | | if (null == pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | IPage<PageActivityMembersVO> iPage = comBpActivityDAO.pageActivity(page, partyBuildingActivityVO); |
| | | IPage<PartyBuildingActivityVO> iPage = comBpActivityDAO.pageActivity(page, partyBuildingActivityVO); |
| | | List<PartyBuildingActivityVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | | DateFormat formatTo = new SimpleDateFormat("M月d ahh:mm"); |
| | | records.forEach(partyBuildingActivityVO1 -> { |
| | | Date activityTimeBegin = partyBuildingActivityVO1.getActivityTimeBegin(); |
| | | if (!ObjectUtils.isEmpty(activityTimeBegin)) { |
| | | partyBuildingActivityVO1.setActivityTimeBeginFormat(formatTo.format(activityTimeBegin)); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public R cancelActivity(PartyBuildingActivityVO partyBuildingActivityVO) { |
| | | ComBpActivityDO comBpActivityDO=new ComBpActivityDO(); |
| | | comBpActivityDO.setId(partyBuildingActivityVO.getId()); |
| | | comBpActivityDO.setCancelReason(partyBuildingActivityVO.getCancelReason()); |
| | | comBpActivityDO.setCreateBy(partyBuildingActivityVO.getCreateBy()); |
| | | int update = comBpActivityDAO.updateById(comBpActivityDO); |
| | | if (update>0) { |
| | | ComPbActivityDO comPbActivityDO = new ComPbActivityDO(); |
| | | comPbActivityDO.setId(partyBuildingActivityVO.getId()); |
| | | comPbActivityDO.setCancelReason(partyBuildingActivityVO.getCancelReason()); |
| | | comPbActivityDO.setStatus(6); |
| | | int update = comBpActivityDAO.updateById(comPbActivityDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 用户的所有党建活动 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 党建活动列表 |
| | | */ |
| | | @Override |
| | | public R listActivity(Long userId) { |
| | | List<ComPbActivityMemberDO> comPbActivityMemberDOS = comPbActivityMemberDAO.selectList(new QueryWrapper<ComPbActivityMemberDO>().lambda().eq(ComPbActivityMemberDO::getMemberId, userId)); |
| | | if (ObjectUtils.isEmpty(comPbActivityMemberDOS)) { |
| | | return R.fail(); |
| | | } |
| | | List<Long> collect = comPbActivityMemberDOS.stream().map(comPbActivityMemberDO -> comPbActivityMemberDO.getActivityId()).collect(Collectors.toList()); |
| | | List<ComPbActivityDO> comPbActivityDOS = comBpActivityDAO.selectBatchIds(collect); |
| | | List<ComActActivityVO> comActActivityVOS = new ArrayList<>(); |
| | | comPbActivityDOS.forEach(comPbActivityDO -> { |
| | | ComActActivityVO comActActivityVO = new ComActActivityVO(); |
| | | comActActivityVO.setType(3); |
| | | comActActivityVO.setId(comPbActivityDO.getId()); |
| | | comActActivityVO.setStatus(comPbActivityDO.getStatus()); |
| | | comActActivityVO.setActivityName(comPbActivityDO.getName()); |
| | | comActActivityVO.setCover(comPbActivityDO.getCover()); |
| | | comActActivityVO.setBeginAt(comPbActivityDO.getActivityTimeBegin()); |
| | | comActActivityVOS.add(comActActivityVO); |
| | | }); |
| | | return R.ok(comActActivityVOS); |
| | | } |
| | | |
| | | /** |
| | | * 党员活动人员参入列表 |
| | | * |
| | | * @param id 活动id |
| | | * @return 党员集合 |
| | | */ |
| | | @Override |
| | | public R listPartyBuildingMember(Long id) { |
| | | List<PartyBuildingMemberVO> partyBuildingMemberVOS = new ArrayList<>(); |
| | | List<ComPbActivityMemberDO> comPbActivityMemberDOS = comPbActivityMemberDAO.selectList(new QueryWrapper<ComPbActivityMemberDO>().lambda().eq(ComPbActivityMemberDO::getActivityId, id).orderByDesc(ComPbActivityMemberDO::getCreateAt)); |
| | | if (!ObjectUtils.isEmpty(comPbActivityMemberDOS)) { |
| | | List<Long> collect = comPbActivityMemberDOS.stream().map(ComPbActivityMemberDO::getMemberId).collect(Collectors.toList()); |
| | | List<ComPbMemberDO> comPbMemberDOS = comPbMemberDAO.selectList(new QueryWrapper<ComPbMemberDO>().lambda().in(ComPbMemberDO::getId, collect)); |
| | | comPbMemberDOS.forEach(comPbMemberDO -> { |
| | | PartyBuildingMemberVO partyBuildingMemberVO = new PartyBuildingMemberVO(); |
| | | BeanUtils.copyProperties(comPbMemberDO, partyBuildingMemberVO); |
| | | partyBuildingMemberVOS.add(partyBuildingMemberVO); |
| | | }); |
| | | } |
| | | return R.ok(partyBuildingMemberVOS); |
| | | } |
| | | |
| | | /** |
| | | * 报名、取消报名党员活动 |
| | | * |
| | | * @param activitySignUpDTO 操作参数 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | public R putActivitySignUp(ActivitySignUpDTO activitySignUpDTO) { |
| | | Long id=activitySignUpDTO.getId(); |
| | | Long userId=activitySignUpDTO.getUserId(); |
| | | ComPbActivityDO comPbActivityDO = comBpActivityDAO.selectById(id); |
| | | if (ObjectUtils.isEmpty(comPbActivityDO)) { |
| | | return R.fail("活动不存在"); |
| | | } |
| | | ComPbMemberDO comPbMemberDO=comPbMemberDAO.selectByUserId(userId); |
| | | if (ObjectUtils.isEmpty(comPbMemberDO)) { |
| | | return R.fail("您不是党员"); |
| | | } |
| | | Integer type=activitySignUpDTO.getType(); |
| | | ComPbActivityMemberDO comPbActivityMemberDO = comPbActivityMemberDAO.selectOne(new QueryWrapper<ComPbActivityMemberDO>().lambda().eq(ComPbActivityMemberDO::getMemberId, comPbMemberDO.getId()).eq(ComPbActivityMemberDO::getActivityId, id)); |
| | | boolean empty = ObjectUtils.isEmpty(comPbActivityMemberDO); |
| | | int mum=0; |
| | | if (type.intValue()==1) { |
| | | if (empty) { |
| | | ComPbActivityMemberDO comPbActivityMemberDO1=new ComPbActivityMemberDO(); |
| | | comPbActivityMemberDO1.setActivityId(id); |
| | | comPbActivityMemberDO1.setMemberId(comPbMemberDO.getId()); |
| | | comPbActivityMemberDO1.setCreateAt(new Date()); |
| | | mum=comPbActivityMemberDAO.insert(comPbActivityMemberDO1); |
| | | } else { |
| | | return R.ok(null,"已经加入了"); |
| | | } |
| | | }else{ |
| | | if (empty) { |
| | | return R.ok(null,"已经取消"); |
| | | }else{ |
| | | mum=comPbActivityMemberDAO.deleteById(comPbActivityMemberDO.getId()); |
| | | } |
| | | } |
| | | if (mum>0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 获取党建活动所有参入人员的id集合 |
| | | * |
| | | * @param id 党建活动id |
| | | * @return 人员id集合 |
| | | */ |
| | | @Override |
| | | public R selectAllPartyBuildingActivityMembers(Long id) { |
| | | List<Long> longs=comPbActivityMemberDAO.selectAllPartyBuildingActivityMembers(id); |
| | | return R.ok(longs); |
| | | } |
| | | |
| | | /** |
| | | * 定时任务取消党建活动 |
| | | * |
| | | * @return 取消党建活动数量 |
| | | */ |
| | | @Override |
| | | public R timedTaskPartyBuildingActivity() { |
| | | List<Long> ids=comBpActivityDAO.selectTimedTaskPartyBuildingActivity(); |
| | | List<PartyBuildingActivityVO> partyBuildingActivityVOS = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(ids)) { |
| | | List<ComPbActivityDO> comPbActivityDOS = comBpActivityDAO.selectBatchIds(ids); |
| | | comPbActivityDOS.forEach(comPbActivityDO -> { |
| | | PartyBuildingActivityVO partyBuildingActivityVO = new PartyBuildingActivityVO(); |
| | | BeanUtils.copyProperties(comPbActivityDO,partyBuildingActivityVO); |
| | | List<Long> userIdS=comBpActivityDAO.selectTimedTaskPartyBuildingActivityUserids(comPbActivityDO.getId()); |
| | | partyBuildingActivityVO.setUserIds(userIdS); |
| | | partyBuildingActivityVOS.add(partyBuildingActivityVO); |
| | | }); |
| | | int i = comBpActivityDAO.updateBatchIds(ids); |
| | | log.info("定时任务取消党建活动数量【{}】",i); |
| | | } |
| | | return R.ok(partyBuildingActivityVOS); |
| | | } |
| | | |
| | | /** |
| | | * 定时任务刷新党建活动的各个状态 除取消外 |
| | | * |
| | | * @return 修改结果 |
| | | */ |
| | | @Override |
| | | public R timedTaskPartyBuildingActivityAll() { |
| | | // 修改发布状态为未开始 |
| | | int num=comBpActivityDAO.updateStatusToNotBegin(); |
| | | log.info("定时任务修改党建活动--修改发布状态为未开始数量【{}】",num); |
| | | // 修改报名状态为报名中 |
| | | int num1=comBpActivityDAO.updateStatusToSign(); |
| | | log.info("定时任务修改党建活动--修改报名状态为报名中始数量【{}】",num1); |
| | | // 修改进行状态为进行中 或者已结束 |
| | | int num2=comBpActivityDAO.updateStatusToActiveOrEnd(); |
| | | log.info("定时任务修改党建活动--修改进行状态为进行中 或者已结束数量【{}】",num2); |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | DateFormat formatTo = new SimpleDateFormat("M月d ahh:mm"); |
| | | String format = formatTo.format(new Date()); |
| | | System.out.println(format); |
| | | } |
| | | |
| | | } |