101captain
2022-02-21 5a278a0965b417e7f39e8c209e2ff401f415066a
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BigScreenStatisticsServiceImpl.java
@@ -14,6 +14,10 @@
import javax.annotation.Resource;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.community.bigscreen.*;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_community.dao.*;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -102,6 +106,18 @@
    @Resource
    private ComActCommitteeDao comActCommitteeDao;
    @Resource
    private ComActSocialProjectDao comActSocialProjectDao;
    @Resource
    private ComActSocialOrgDao comActSocialOrgDao;
    @Resource
    private ComActSocialWorkerDao comActSocialWorkerDao;
    @Resource
    private ComActActivityDAO comActActivityDAO;
    /**
     * 大数据分析平台-居民自治
@@ -632,6 +648,107 @@
        return R.ok(iPage);
    }
    @Override
    public R hmkBaseInfo(CommonPage commonPage) {
        BigScreenHmkBaseInfo bigScreenHmkBaseInfo=comActSocialProjectDao.selectIndexBaseInfo();
        //项目数据
        BigScreenHmkProjectInfo bigScreenHmkProjectInfo=comActSocialProjectDao.selectBaseInfo(commonPage.getCommunityId());
        List<BigScreenHmkProjectTypeInfo> typeInfo=comActSocialProjectDao.selectType(null,commonPage.getCommunityId());
        if(bigScreenHmkProjectInfo.getCount()>0){
            typeInfo.forEach(bigScreenHmkProjectTypeInfo -> {
                bigScreenHmkProjectTypeInfo.setPercent(bigScreenHmkProjectTypeInfo.getCount()/bigScreenHmkProjectInfo.getCount());
            });
        }
        bigScreenHmkProjectInfo.setTypeInfoList(typeInfo);
        //活动数据
        Integer countAll=comActSocialProjectDao.selectActivity(0,commonPage.getCommunityId());
        BigScreenHmkProjectTypeInfo jm=new BigScreenHmkProjectTypeInfo();
        jm.setName("居民活动");
        jm.setCount(comActSocialProjectDao.selectActivity(2,commonPage.getCommunityId()));
        if(countAll>0){
            jm.setPercent(jm.getCount()/countAll);
        }
        BigScreenHmkProjectTypeInfo zyz=new BigScreenHmkProjectTypeInfo();
        zyz.setName("志愿者活动");
        zyz.setCount(comActSocialProjectDao.selectActivity(1,commonPage.getCommunityId()));
        if(countAll>0){
            zyz.setPercent(zyz.getCount()/countAll);
        }
        List<BigScreenHmkProjectTypeInfo> activityList=new ArrayList<>();
        activityList.add(jm);
        activityList.add(zyz);
        bigScreenHmkProjectInfo.setActivityTypeInfoList(activityList);
        //社会组织数据
        BigScreenHmkSocialOrgInfo bigScreenHmkSocialOrgInfo=comActSocialOrgDao.selectInfo(commonPage.getCommunityId());
        List<BigScreenHmkProjectTypeInfo> typeInfoList= comActSocialOrgDao.selectType(commonPage.getCommunityId());
        if(bigScreenHmkSocialOrgInfo.getCount()>0){
            typeInfoList.forEach(bigScreenHmkProjectTypeInfo -> {
                bigScreenHmkProjectTypeInfo.setPercent(bigScreenHmkProjectTypeInfo.getCount()/bigScreenHmkSocialOrgInfo.getCount());
            });
        }
        bigScreenHmkSocialOrgInfo.setTypeInfoList(typeInfoList);
        bigScreenHmkBaseInfo.setBigScreenHmkSocialOrgInfo(bigScreenHmkSocialOrgInfo);
        //社工数据
        BigScreenHmkSocialWorkerInfo bigScreenHmkSocialWorkerInfo=new BigScreenHmkSocialWorkerInfo();
        List<BigScreenHmkProjectTypeInfo> socialWorkerList=new ArrayList<>();
        Integer socialAll=comActSocialWorkerDao.selectType(0,commonPage.getCommunityId());
        BigScreenHmkProjectTypeInfo ss=new BigScreenHmkProjectTypeInfo();
        ss.setName("30岁以下");
        ss.setCount(comActSocialWorkerDao.selectType(1,commonPage.getCommunityId()));
        if(socialAll>0){
            ss.setPercent(ss.getCount()/socialAll);
        }
        BigScreenHmkProjectTypeInfo wj=new BigScreenHmkProjectTypeInfo();
        wj.setName("30-59岁");
        wj.setCount(comActSocialWorkerDao.selectType(2,commonPage.getCommunityId()));
        if(socialAll>0){
            wj.setPercent(wj.getCount()/socialAll);
        }
        BigScreenHmkProjectTypeInfo ls=new BigScreenHmkProjectTypeInfo();
        ls.setName("60岁以上");
        ls.setCount(comActSocialWorkerDao.selectType(3,commonPage.getCommunityId()));
        if(socialAll>0){
            ls.setPercent(ls.getCount()/socialAll);
        }
        socialWorkerList.add(ss);
        socialWorkerList.add(wj);
        socialWorkerList.add(ls);
        bigScreenHmkSocialWorkerInfo.setSocialWorkerAge(socialWorkerList);
        List<BigScreenHmkProjectTypeInfo> socialWorkerSkill=comActSocialWorkerDao.selectSkillType(commonPage.getCommunityId());
        if(socialAll>0){
            socialWorkerSkill.forEach(bigScreenHmkProjectTypeInfo -> {
                bigScreenHmkProjectTypeInfo.setPercent(bigScreenHmkProjectTypeInfo.getCount()/socialAll);
            });
        }
        bigScreenHmkSocialWorkerInfo.setSocialWorkerSkill(socialWorkerSkill);
        bigScreenHmkBaseInfo.setBigScreenHmkSocialWorkerInfo(bigScreenHmkSocialWorkerInfo);
        bigScreenHmkBaseInfo.setBigScreenHmkProjectInfo(bigScreenHmkProjectInfo);
        return R.ok(bigScreenHmkBaseInfo);
    }
    @Override
    public R partyProjectActivityLine() {
        List<BigScreenActivityLine> bigScreenActivityLines=this.getPastMonth();
        bigScreenActivityLines.forEach(bigScreenActivityLine -> {
            BigScreenActivityLine bigScreenActivityLine1=comActSocialProjectDao.selectActivityCountMonth(bigScreenActivityLine.getX(),bigScreenActivityLine.getYear());
            bigScreenActivityLine.setY(bigScreenActivityLine1.getY());
            bigScreenActivityLine.setCountY(bigScreenActivityLine1.getCountY());
            bigScreenActivityLine.setX(bigScreenActivityLine.getYear().substring(2,4)+"-"+bigScreenActivityLine.getX());
        });
        return R.ok(bigScreenActivityLines);
    }
    @Override
    public R projectActivityProject(CommonPage commonPage) {
        return R.ok(comActActivityDAO.selectProjectActivity(new Page(commonPage.getPage(),commonPage.getSize())));
    }
    @Override
    public R projectType(String name) {
        return R.ok(comActSocialProjectDao.selectType(name,null));
    }
    private Page retrievePage(PageBaseDTO pageBaseDTO) {
        Long pageNum = pageBaseDTO.getPageNum();
        Long size = pageBaseDTO.getPageSize();
@@ -645,4 +762,16 @@
        }
        return page;
    }
    public List<BigScreenActivityLine> getPastMonth(){
        List<BigScreenActivityLine> bigScreenActivityLines=new ArrayList<>();
        for(int i=11;i>=0;i--){
            BigScreenActivityLine bigScreenActivityLine=new BigScreenActivityLine();
            String date=DateUtils.getDateFormatString(DateUtils.addMonth(new Date(),-i),"MM");
            String year=DateUtils.getDateFormatString(DateUtils.addMonth(new Date(),-i),"yyyy");
            bigScreenActivityLine.setX(date);
            bigScreenActivityLine.setYear(year);
            bigScreenActivityLines.add(bigScreenActivityLine);
        }
        return bigScreenActivityLines;
    }
}