From eda58e0e6d4abdd2b060e28867d103045845aa69 Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期一, 30 八月 2021 13:13:18 +0800
Subject: [PATCH] Merge branch 'test' into 'yuyue_dev'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java |  159 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 94 insertions(+), 65 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java
index df1c936..623fe85 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoActivityServiceImpl.java
@@ -1,5 +1,11 @@
 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;
@@ -13,12 +19,8 @@
 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
@@ -27,23 +29,27 @@
  */
 @Slf4j
 @Service
-public class ComActEasyPhotoActivityServiceImpl extends ServiceImpl<ComActEasyPhotoActivityMapper, ComActEasyPhotoActivityDO> implements ComActEasyPhotoActivityService {
+public class ComActEasyPhotoActivityServiceImpl extends
+    ServiceImpl<ComActEasyPhotoActivityMapper, ComActEasyPhotoActivityDO> implements ComActEasyPhotoActivityService {
 
     /**
      * 查询随手拍是否有活动
-     * @return  活动详情
+     * 
+     * @return 活动详情
      */
     @Override
-    public R getEasyPhotoActivity(Long communityId){
+    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)
-                        .eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz)
-                        .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate));
-        if(!photoActivityDOS.isEmpty()){
+        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));
+        if (!photoActivityDOS.isEmpty()) {
             ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0);
-            BeanUtils.copyProperties(photoActivityDO,photoActivityVO);
+            BeanUtils.copyProperties(photoActivityDO, photoActivityVO);
             return R.ok(photoActivityVO);
         }
         return R.ok();
@@ -51,47 +57,56 @@
 
     /**
      * 社区后台-分页查询随手拍活动列表
-     * @param pageEasyPhotoActivityDTO  请求参数
-     * @return  随手拍活动列表
+     * 
+     * @param pageEasyPhotoActivityDTO
+     *            请求参数
+     * @return 随手拍活动列表
      */
     @Override
-    public R pageActivity(PageEasyPhotoActivityDTO pageEasyPhotoActivityDTO){
-        return R.ok(this.baseMapper.pageActivity(new Page(pageEasyPhotoActivityDTO.getPageNum(),pageEasyPhotoActivityDTO.getPageSize()),pageEasyPhotoActivityDTO));
+    public R pageActivity(PageEasyPhotoActivityDTO pageEasyPhotoActivityDTO) {
+        return R.ok(this.baseMapper.pageActivity(
+            new Page(pageEasyPhotoActivityDTO.getPageNum(), pageEasyPhotoActivityDTO.getPageSize()),
+            pageEasyPhotoActivityDTO));
     }
 
     /**
      * 社区后台-添加随手拍活动
-     * @param addEasyPhotoActivityDTO   请求参数
-     * @return  添加结果
+     * 
+     * @param addEasyPhotoActivityDTO
+     *            请求参数
+     * @return 添加结果
      */
     @Override
-    public R addActivity(AddEasyPhotoActivityDTO addEasyPhotoActivityDTO){
+    public R addActivity(AddEasyPhotoActivityDTO addEasyPhotoActivityDTO) {
 
-        //判断当前活动时间是否与其他时间有冲突
-        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(addEasyPhotoActivityDTO.getActivityStartAt(),addEasyPhotoActivityDTO.getActivityEndAt(),null,addEasyPhotoActivityDTO.getCommunityId());
-        if(count > 0){
+        // 判断当前活动时间是否与其他时间有冲突
+        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));
+        BeanUtils.copyProperties(addEasyPhotoActivityDTO, photoActivityDO);
+        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()){
+        if (photoActivityDO.getActivityEndAt().getTime() <= nowDate.getTime()) {
             return R.fail("活动结束时间不可小于当前时间");
         }
 
-        if(nowDate.getTime() >= photoActivityDO.getActivityStartAt().getTime()){
+        if (nowDate.getTime() >= photoActivityDO.getActivityStartAt().getTime()) {
             photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.jxz);
-        }else{
+        } else {
             photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.dks);
         }
 
         photoActivityDO.setCount(0);
-        if(this.baseMapper.insert(photoActivityDO) > 0){
+        if (this.baseMapper.insert(photoActivityDO) > 0) {
             return R.ok();
         }
         return R.fail("添加失败");
@@ -99,35 +114,41 @@
 
     /**
      * 社区后台-编辑随手拍活动
-     * @param editEasyPhotoActivityDTO  请求参数
-     * @return  编辑结果
+     * 
+     * @param editEasyPhotoActivityDTO
+     *            请求参数
+     * @return 编辑结果
      */
     @Override
-    public R editActivity(EditEasyPhotoActivityDTO editEasyPhotoActivityDTO){
+    public R editActivity(EditEasyPhotoActivityDTO editEasyPhotoActivityDTO) {
 
         ComActEasyPhotoActivityDO photoActivityDO = this.baseMapper.selectById(editEasyPhotoActivityDTO.getId());
-        if(photoActivityDO == null){
+        if (photoActivityDO == null) {
             return R.fail("未查询到活动记录");
         }
 
-        Integer count = this.baseMapper.getEasyPhotoActivityTimeConflict(editEasyPhotoActivityDTO.getActivityStartAt(),editEasyPhotoActivityDTO.getActivityEndAt(),editEasyPhotoActivityDTO.getId(),photoActivityDO.getCommunityId());
-        if(count > 0){
+        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));
-        if(new Date().getTime() > photoActivityDO.getActivityStartAt().getTime()){
+        BeanUtils.copyProperties(editEasyPhotoActivityDTO, photoActivityDO);
+        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{
+        } else {
             photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.dks);
         }
 
-        if(new Date().getTime() > photoActivityDO.getActivityEndAt().getTime()){
+        if (new Date().getTime() > photoActivityDO.getActivityEndAt().getTime()) {
             photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.yjs);
         }
-        if(this.baseMapper.updateById(photoActivityDO) > 0){
+        if (this.baseMapper.updateById(photoActivityDO) > 0) {
             return R.ok();
         }
         return R.fail("编辑失败");
@@ -135,17 +156,19 @@
 
     /**
      * 社区后台-取消随手拍活动
-     * @param id    随手拍活动id
-     * @return  取消结果
+     * 
+     * @param id
+     *            随手拍活动id
+     * @return 取消结果
      */
     @Override
-    public R cancelActivity(Long id){
+    public R cancelActivity(Long id) {
         ComActEasyPhotoActivityDO photoActivityDO = this.baseMapper.selectById(id);
-        if(photoActivityDO == null){
+        if (photoActivityDO == null) {
             return R.fail("未查询到活动记录");
         }
         photoActivityDO.setStatus(ComActEasyPhotoActivityDO.status.yqx);
-        if(this.baseMapper.updateById(photoActivityDO) > 0){
+        if (this.baseMapper.updateById(photoActivityDO) > 0) {
             return R.ok();
         }
         return R.fail("取消失败");
@@ -153,41 +176,47 @@
 
     /**
      * 分页查询随手拍活动下居民参与记录
-     * @param activityUserDTO  请求参数
-     * @return  居民参与记录
+     * 
+     * @param activityUserDTO
+     *            请求参数
+     * @return 居民参与记录
      */
     @Override
-    public R pageActivityUser(PageEasyPhotoActivityUserDTO activityUserDTO){
-        return R.ok(this.baseMapper.pageActivityUser(new Page(activityUserDTO.getPageNum(),activityUserDTO.getPageSize()),activityUserDTO));
+    public R pageActivityUser(PageEasyPhotoActivityUserDTO activityUserDTO) {
+        return R.ok(this.baseMapper
+            .pageActivityUser(new Page(activityUserDTO.getPageNum(), activityUserDTO.getPageSize()), activityUserDTO));
     }
 
     /**
      * 随手拍活动定时任务
-     * @return  执行结果
+     * 
+     * @return 执行结果
      */
     @Override
-    public R timeTaskEasyPhotoActivity(){
-        //定时任务扫描未开始活动,如果开始时间大于当前时间则更新活动状态
+    public R timeTaskEasyPhotoActivity() {
+        // 定时任务扫描未开始活动,如果开始时间大于当前时间则更新活动状态
         log.info("定时任务检测未开始的随手拍活动,判断是否开始");
-        List<ComActEasyPhotoActivityDO> photoActivityDOS = this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>()
-                .lambda().eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.dks));
-        if(!photoActivityDOS.isEmpty()){
+        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 -> {
-                if(photoActivity.getActivityStartAt().getTime() <= nowDate.getTime()){
+                if (photoActivity.getActivityStartAt().getTime() <= nowDate.getTime()) {
                     photoActivity.setStatus(ComActEasyPhotoActivityDO.status.jxz);
                     this.baseMapper.updateById(photoActivity);
                 }
             });
         }
-        //定时任务扫描已开始活动,如果结束时间大于当前时间则更新活动状态
+        // 定时任务扫描已开始活动,如果结束时间大于当前时间则更新活动状态
         log.info("定时任务检测已开始的随手拍活动,判断活动是否已结束");
-        List<ComActEasyPhotoActivityDO> oldPhotoActivityDOS = this.baseMapper.selectList(new QueryWrapper<ComActEasyPhotoActivityDO>()
-                .lambda().eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz));
-        if(!oldPhotoActivityDOS.isEmpty()){
+        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 -> {
-                if(photoActivity.getActivityEndAt().getTime() <= nowDate.getTime()){
+                if (photoActivity.getActivityEndAt().getTime() <= nowDate.getTime()) {
                     photoActivity.setStatus(ComActEasyPhotoActivityDO.status.yjs);
                     this.baseMapper.updateById(photoActivity);
                 }

--
Gitblit v1.7.1