| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.panzhihua.service_community.dao.ComActEasyPhotoActivityMapper; |
| | | import com.panzhihua.service_community.model.dos.ComActEasyPhotoActivityDO; |
| | | import com.panzhihua.service_community.service.ComActEasyPhotoActivityService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActEasyPhotoActivityServiceImpl extends ServiceImpl<ComActEasyPhotoActivityMapper, ComActEasyPhotoActivityDO> implements ComActEasyPhotoActivityService { |
| | | public class ComActEasyPhotoActivityServiceImpl extends |
| | | ServiceImpl<ComActEasyPhotoActivityMapper, ComActEasyPhotoActivityDO> implements ComActEasyPhotoActivityService { |
| | | |
| | | /** |
| | | * 查询随手拍是否有活动 |
| | | * |
| | | * @return 活动详情 |
| | | */ |
| | | @Override |
| | | public R getEasyPhotoActivity(Long communityId){ |
| | | ComActEasyPhotoActivityVO photoActivityVO = new ComActEasyPhotoActivityVO(); |
| | | Date nowDate = DateUtils.getCurrentDate(DateUtils.ymdhms_format); |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = this.baseMapper.selectList( |
| | | new QueryWrapper<ComActEasyPhotoActivityDO>().lambda().eq(ComActEasyPhotoActivityDO::getCommunityId,communityId) |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = |
| | | this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>().lambda() |
| | | .eq(ComActEasyPhotoActivityDO::getCommunityId, communityId) |
| | | .eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz) |
| | | .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate)); |
| | | .le(ComActEasyPhotoActivityDO::getActivityStartAt, nowDate) |
| | | .ge(ComActEasyPhotoActivityDO::getActivityEndAt, nowDate)); |
| | | if(!photoActivityDOS.isEmpty()){ |
| | | ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0); |
| | | BeanUtils.copyProperties(photoActivityDO,photoActivityVO); |
| | |
| | | |
| | | /** |
| | | * 社区后台-分页查询随手拍活动列表 |
| | | * @param pageEasyPhotoActivityDTO 请求参数 |
| | | * |
| | | * @param pageEasyPhotoActivityDTO |
| | | * 请求参数 |
| | | * @return 随手拍活动列表 |
| | | */ |
| | | @Override |
| | | public R pageActivity(PageEasyPhotoActivityDTO pageEasyPhotoActivityDTO){ |
| | | return R.ok(this.baseMapper.pageActivity(new Page(pageEasyPhotoActivityDTO.getPageNum(),pageEasyPhotoActivityDTO.getPageSize()),pageEasyPhotoActivityDTO)); |
| | | return R.ok(this.baseMapper.pageActivity( |
| | | new Page(pageEasyPhotoActivityDTO.getPageNum(), pageEasyPhotoActivityDTO.getPageSize()), |
| | | pageEasyPhotoActivityDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 社区后台-添加随手拍活动 |
| | | * @param addEasyPhotoActivityDTO 请求参数 |
| | | * |
| | | * @param addEasyPhotoActivityDTO |
| | | * 请求参数 |
| | | * @return 添加结果 |
| | | */ |
| | | @Override |
| | | public R addActivity(AddEasyPhotoActivityDTO addEasyPhotoActivityDTO){ |
| | | |
| | | //判断当前活动时间是否与其他时间有冲突 |
| | | Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(addEasyPhotoActivityDTO.getActivityStartAt(),addEasyPhotoActivityDTO.getActivityEndAt(),null,addEasyPhotoActivityDTO.getCommunityId()); |
| | | Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(addEasyPhotoActivityDTO.getActivityStartAt(), |
| | | addEasyPhotoActivityDTO.getActivityEndAt(), null, addEasyPhotoActivityDTO.getCommunityId()); |
| | | if(count > 0){ |
| | | return R.fail("在此期间已有活动,请勿重复添加"); |
| | | } |
| | |
| | | Date nowDate = new Date(); |
| | | ComActEasyPhotoActivityDO photoActivityDO = new ComActEasyPhotoActivityDO(); |
| | | BeanUtils.copyProperties(addEasyPhotoActivityDTO,photoActivityDO); |
| | | photoActivityDO.setActivityStartAt(DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityStartAt(),DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityEndAt(DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityEndAt(),DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityStartAt( |
| | | DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityStartAt(), DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityEndAt( |
| | | DateUtils.stringToDate(addEasyPhotoActivityDTO.getActivityEndAt(), DateUtils.ymdhm_format)); |
| | | photoActivityDO.setCreateAt(new Date()); |
| | | photoActivityDO.setReleaseAt(new Date()); |
| | | if(photoActivityDO.getActivityEndAt().getTime() <= nowDate.getTime()){ |
| | |
| | | |
| | | /** |
| | | * 社区后台-编辑随手拍活动 |
| | | * @param editEasyPhotoActivityDTO 请求参数 |
| | | * |
| | | * @param editEasyPhotoActivityDTO |
| | | * 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | |
| | | return R.fail("未查询到活动记录"); |
| | | } |
| | | |
| | | Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(editEasyPhotoActivityDTO.getActivityStartAt(),editEasyPhotoActivityDTO.getActivityEndAt(),editEasyPhotoActivityDTO.getId(),photoActivityDO.getCommunityId()); |
| | | Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(editEasyPhotoActivityDTO.getActivityStartAt(), |
| | | editEasyPhotoActivityDTO.getActivityEndAt(), editEasyPhotoActivityDTO.getId(), |
| | | photoActivityDO.getCommunityId()); |
| | | if(count > 0){ |
| | | return R.fail("在此期间已有活动,请勿重复添加"); |
| | | } |
| | | |
| | | BeanUtils.copyProperties(editEasyPhotoActivityDTO,photoActivityDO); |
| | | photoActivityDO.setActivityStartAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityStartAt(),DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityEndAt(DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityEndAt(),DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityStartAt( |
| | | DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityStartAt(), DateUtils.ymdhm_format)); |
| | | photoActivityDO.setActivityEndAt( |
| | | DateUtils.stringToDate(editEasyPhotoActivityDTO.getActivityEndAt(), DateUtils.ymdhm_format)); |
| | | if(new Date().getTime() > photoActivityDO.getActivityStartAt().getTime()){ |
| | | photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.jxz); |
| | | }else{ |
| | |
| | | |
| | | /** |
| | | * 社区后台-取消随手拍活动 |
| | | * @param id 随手拍活动id |
| | | * |
| | | * @param id |
| | | * 随手拍活动id |
| | | * @return 取消结果 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 分页查询随手拍活动下居民参与记录 |
| | | * @param activityUserDTO 请求参数 |
| | | * |
| | | * @param activityUserDTO |
| | | * 请求参数 |
| | | * @return 居民参与记录 |
| | | */ |
| | | @Override |
| | | public R pageActivityUser(PageEasyPhotoActivityUserDTO activityUserDTO){ |
| | | return R.ok(this.baseMapper.pageActivityUser(new Page(activityUserDTO.getPageNum(),activityUserDTO.getPageSize()),activityUserDTO)); |
| | | return R.ok(this.baseMapper |
| | | .pageActivityUser(new Page(activityUserDTO.getPageNum(), activityUserDTO.getPageSize()), activityUserDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 随手拍活动定时任务 |
| | | * |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R timeTaskEasyPhotoActivity(){ |
| | | //定时任务扫描未开始活动,如果开始时间大于当前时间则更新活动状态 |
| | | log.info("定时任务检测未开始的随手拍活动,判断是否开始"); |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>() |
| | | .lambda().eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.dks)); |
| | | List<ComActEasyPhotoActivityDO> photoActivityDOS = |
| | | this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>().lambda() |
| | | .eq(ComActEasyPhotoActivityDO::getStatus, ComActEasyPhotoActivityDO.status.dks)); |
| | | if(!photoActivityDOS.isEmpty()){ |
| | | Date nowDate = new Date(); |
| | | photoActivityDOS.forEach(photoActivity -> { |
| | |
| | | } |
| | | //定时任务扫描已开始活动,如果结束时间大于当前时间则更新活动状态 |
| | | log.info("定时任务检测已开始的随手拍活动,判断活动是否已结束"); |
| | | List<ComActEasyPhotoActivityDO> oldPhotoActivityDOS = this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>() |
| | | .lambda().eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz)); |
| | | List<ComActEasyPhotoActivityDO> oldPhotoActivityDOS = |
| | | this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>().lambda() |
| | | .eq(ComActEasyPhotoActivityDO::getStatus, ComActEasyPhotoActivityDO.status.jxz)); |
| | | if(!oldPhotoActivityDOS.isEmpty()){ |
| | | Date nowDate = new Date(); |
| | | oldPhotoActivityDOS.forEach(photoActivity -> { |