From 65c7ded03175596fcfacc43f3f2c60076277c21a Mon Sep 17 00:00:00 2001
From: huanghongfa <18228131219@163.com>
Date: 星期四, 28 一月 2021 16:19:04 +0800
Subject: [PATCH] 社区首页

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
index f6ce162..613d172 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java
@@ -4,11 +4,9 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.model.vos.IndexDataVO;
 import com.panzhihua.common.model.vos.R;
-import com.panzhihua.common.model.vos.community.ActivitySignVO;
-import com.panzhihua.common.model.vos.community.ComActActivityVO;
-import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
-import com.panzhihua.common.model.vos.community.SignactivityVO;
+import com.panzhihua.common.model.vos.community.*;
 import com.panzhihua.service_community.dao.ComActActSignDAO;
 import com.panzhihua.service_community.dao.ComActActivityDAO;
 import com.panzhihua.service_community.dao.ComActDiscussOptionUserDAO;
@@ -16,12 +14,14 @@
 import com.panzhihua.service_community.model.dos.ComActActivityDO;
 import com.panzhihua.service_community.service.ComActActivityService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.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.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -369,5 +369,55 @@
         return R.ok(iPage);
     }
 
+    /**
+     * 首页图表数据汇总
+     *
+     * @param communityId 社区id
+     * @return 图表数据 IndexDataVO
+     */
+    @Override
+    public R indexDataCommunityBackstageEchart(Long communityId) {
+        IndexDataVO indexDataVO=new IndexDataVO();
+        CommunityGovernanceTrendsVO communityGovernanceTrendsVO=new CommunityGovernanceTrendsVO();
+        List<CommunityActivitiesVO> communityActivitiesVOS=new ArrayList<>();
+        List<Date>dates=this.getServenDays();
+        String s=comActActivityDAO.selectCommunityGovernanceTrendsVO(communityId);
+        List<String>y= Arrays.asList(s.split(","));
+        communityGovernanceTrendsVO.setY(y);
+        communityGovernanceTrendsVO.setX(Arrays.asList(new String[]{"一起议","微心愿","随手拍","社区活动"}));
+        dates.forEach(date -> {
+            CommunityActivitiesVO communityActivitiesVO=comActActivityDAO.selectCommunityActivitiesVO(communityId,date);
+            communityActivitiesVO.setDate(date);
+            communityActivitiesVOS.add(communityActivitiesVO);
+        });
+
+        indexDataVO.setCommunityGovernanceTrendsVO(communityGovernanceTrendsVO);
+        indexDataVO.setCommunityActivitiesVOS(communityActivitiesVOS);
+        return R.ok(indexDataVO);
+    }
+
+    /**
+     * 获取最近七天的时间
+     * @return
+     */
+    private List<Date> getServenDays() {
+        List<Date> dates=new ArrayList<>();
+        Date date=new Date();
+        for(int i=6;i>=0;i--){
+            Date date1= DateUtils.addDays(date,-i);
+            dates.add(date1);
+        }
+        return dates;
+    }
+
+    public static void main(String[] args) {
+        List<Date> dates=new ArrayList<>();
+        Date date=new Date();
+        for(int i=6;i>=0;i--){
+            Date date1= DateUtils.addDays(date,-i);
+            dates.add(date1);
+        }
+        System.out.println(dates);
+    }
 
 }

--
Gitblit v1.7.1