101captain
2022-03-14 85cf42314fc04a637f1a44e78c1e476a445bf0f3
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BigScreenStatisticsServiceImpl.java
@@ -3,7 +3,7 @@
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import java.text.SimpleDateFormat;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
@@ -14,39 +14,72 @@
import javax.annotation.Resource;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
import com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenAlarmStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenCourtyardStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenVolunteerStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.EquipmentPointMapDataVO;
import com.panzhihua.common.model.vos.community.bigscreen.VolunteerOrgRelationVO;
import com.panzhihua.common.model.vos.grid.EventVO;
import com.panzhihua.common.model.vos.property.ComPropertyAlarmVO;
import com.panzhihua.common.model.vos.property.ComPropertyEquipmentVO;
import com.panzhihua.service_community.dao.ComMngVolunteerMngDAO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.PageBaseDTO;
import com.panzhihua.common.model.dtos.community.convenient.PagePopularMerchantDTO;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
import com.panzhihua.common.model.vos.community.ComActDynVO;
import com.panzhihua.common.model.vos.community.ComActFourMemberVO;
import com.panzhihua.common.model.vos.community.ComSwPatrolRecordVO;
import com.panzhihua.common.model.vos.community.StatisticsCommVO;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenActivityLine;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenCommunityStatisticsVO;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenDynStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenEasyPhotoStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenFmsStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenFourMemberStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkBaseInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectTypeInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkSocialOrgInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkSocialWorkerInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenMerchantStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenMicroWishStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenNeighborStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenPartyBuildIngStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenQuestionnaireStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenResidentActStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenVolunteerActStatisticsInfo;
import com.panzhihua.common.model.vos.community.bigscreen.FourMemberOrgRelationVO;
import com.panzhihua.common.model.vos.community.bigscreen.GridsGovernanceStatisticsVO;
import com.panzhihua.common.model.vos.community.bigscreen.ResidentAutonomyStatisticsVO;
import com.panzhihua.common.model.vos.community.convenient.ConvenientMerchantVO;
import com.panzhihua.common.model.vos.community.fms.ComFmsTeamVO;
import com.panzhihua.common.model.vos.community.screen.civil.CivilVillageStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.event.EventGridIncidentStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.event.EventGridStatisticsVO;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_community.dao.ComActActivityDAO;
import com.panzhihua.service_community.dao.ComActCommitteeDao;
import com.panzhihua.service_community.dao.ComActDiscussDAO;
import com.panzhihua.service_community.dao.ComActDynDAO;
import com.panzhihua.service_community.dao.ComActEasyPhotoDAO;
import com.panzhihua.service_community.dao.ComActFourMemberDao;
import com.panzhihua.service_community.dao.ComActMicroWishDAO;
import com.panzhihua.service_community.dao.ComActNeighborCircleDAO;
import com.panzhihua.service_community.dao.ComActQuestnaireDAO;
import com.panzhihua.service_community.dao.ComActSocialOrgDao;
import com.panzhihua.service_community.dao.ComActSocialProjectDao;
import com.panzhihua.service_community.dao.ComActSocialWorkerDao;
import com.panzhihua.service_community.dao.ComActWarehouseDonatesDao;
import com.panzhihua.service_community.dao.ComFmsServiceDAO;
import com.panzhihua.service_community.dao.ComMngPopulationDAO;
import com.panzhihua.service_community.dao.ComPropertyDao;
import com.panzhihua.service_community.dao.ConvenientMerchantDAO;
@@ -102,6 +135,21 @@
    @Resource
    private ComActCommitteeDao comActCommitteeDao;
    @Resource
    private ComActSocialProjectDao comActSocialProjectDao;
    @Resource
    private ComActSocialOrgDao comActSocialOrgDao;
    @Resource
    private ComActSocialWorkerDao comActSocialWorkerDao;
    @Resource
    private ComActFourMemberDao comActFourMemberDao;
    @Resource
    private ComFmsServiceDAO comFmsServiceDAO;
    @Resource
    private ComMngVolunteerMngDAO comMngVolunteerMngDAO;
    /**
     * 大数据分析平台-居民自治
@@ -550,6 +598,11 @@
     */
    @Override
    public R indexVolunteerAct(Long communityId) {
        BigScreenVolunteerActStatisticsInfo statisticsInfo = getBigScreenVolunteerActStatisticsInfo(communityId);
        return R.ok(statisticsInfo);
    }
    private BigScreenVolunteerActStatisticsInfo getBigScreenVolunteerActStatisticsInfo(Long communityId) {
        BigScreenVolunteerActStatisticsInfo statisticsInfo = new BigScreenVolunteerActStatisticsInfo();
        List<StatisticsCommVO> actCircleData = comActActivityDAO.getIndexResidentActBaseData(communityId, false);
        statisticsInfo.setActCircleData(actCircleData);
@@ -574,7 +627,7 @@
            actTotalPolylineData.add(temp);
        });
        statisticsInfo.setActTotalPolylineData(actTotalPolylineData);
        return R.ok(statisticsInfo);
        return statisticsInfo;
    }
    /**
@@ -632,6 +685,532 @@
        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));
    }
    /**
     * 金沙定制页面-党建引领基础数据
     * @param communityId
     * @return
     */
    @Override
    public R getPartyBuildIngBaseData(Long communityId) {
        //基础统计数据查询
        BigScreenPartyBuildIngStatisticsInfo statisticsInfo = comActDynDAO.getPartyBuildIngBaseData(communityId);
        statisticsInfo.setAqxTotal(statisticsInfo.getJmxcTotal() + statisticsInfo.getShjdTotal() + statisticsInfo.getXqxcTotal());
        statisticsInfo.setZyxHelpTotal(statisticsInfo.getZyxServiceTotal());
        statisticsInfo.setZyfwTotal(statisticsInfo.getZyxServiceTotal());
        //随手拍治安防控记录列表
        List<ComActEasyPhotoVO> zafkList = comActEasyPhotoDAO.getPartyBuildIngRecord(communityId, pageSize);
        statisticsInfo.setZafkList(zafkList);
        //居民宣传记录列表
        List<ComActDynVO> JMXCList = comActDynDAO.getPartyBuildIngDynRecord(communityId, pageSize);
        statisticsInfo.setJmxcList(JMXCList);
        //商户监督记录列表
        //辖区巡查记录列表
        List<ComSwPatrolRecordVO> XQXCList = comActDynDAO.getPartyBuildIngPatrolRecord(communityId, pageSize);
        StringBuilder sb = new StringBuilder();
        XQXCList.forEach(e -> {
            String personName = e.getPersonName();
            if (StringUtils.isNotBlank(personName)) {
                String[] split = personName.split(",");
                for (int i = 0;i < split.length;i++) {
                    sb.append(split[i].substring(0, 1).concat(split[i].substring(1).replaceAll("\\S", "*")));
                    if (i != split.length - 1) {
                        sb.append(",");
                    }
                }
                e.setPersonName(sb.toString());
                sb.delete(0, sb.length());
            }
        });
        statisticsInfo.setXqxcList(XQXCList);
        return R.ok(statisticsInfo);
    }
    /**
     * 党员活动展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pagePartyBuildIngAct(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comActDynDAO.pagePartyBuildIngAct(page, pageBaseDTO));
    }
    /**
     * 议事投票展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pagePartyBuildIngDiscuss(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comActDynDAO.pagePartyBuildIngDiscuss(page, pageBaseDTO));
    }
    /**
     * 金沙定制页面-四长四员
     * @param communityId
     * @return
     */
    @Override
    public R getFourMemberBaseData(Long communityId) {
        //基础统计数据查询
        BigScreenFourMemberStatisticsInfo statisticsInfo = comActFourMemberDao.getFourMemberBaseData(communityId);
        //四长四员楼栋组织关系
        List<ComActFourMemberVO> members = comActFourMemberDao.getFourMembers(communityId);
        List<FourMemberOrgRelationVO> relations = new ArrayList<>();
        if (!members.isEmpty()) {
            members.forEach(e -> e.setJurisdictionContent(e.getJurisdictionContent().replaceAll("\\[|\"|]", "")));
            Map<String, List<ComActFourMemberVO>> collect = members.stream().collect(Collectors.groupingBy(ComActFourMemberVO::getJurisdictionContent));
            for (Map.Entry<String, List<ComActFourMemberVO>> entry : collect.entrySet()) {
                FourMemberOrgRelationVO relationVO = new FourMemberOrgRelationVO();
                relationVO.setRelation(entry.getKey());
                relationVO.setMembers(entry.getValue());
                relations.add(relationVO);
            }
        }
        statisticsInfo.setFourMemberOrgList(relations);
        //新增解决问题数
        List<StatisticsCommVO> jjwtAddPolylineData = comActFourMemberDao.retrieveJJWTAddPolylineData(communityId);
        statisticsInfo.setJjwtAddPolylineData(jjwtAddPolylineData);
        //累计解决问题数
        List<StatisticsCommVO> jjwtTotalPolylineData = new ArrayList<>();
        jjwtAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comActFourMemberDao.retrieveJJWTTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            jjwtTotalPolylineData.add(temp);
        });
        statisticsInfo.setJjwtTotalPolylineData(jjwtTotalPolylineData);
        //新增院落议事数
        List<StatisticsCommVO> ylysAddPolylineData = comActFourMemberDao.retrieveYLYSAddPolylineData(communityId);
        statisticsInfo.setYlysAddPolylineData(ylysAddPolylineData);
        //累计院落议事数
        List<StatisticsCommVO> ylysTotalPolylineData = new ArrayList<>();
        ylysAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comActFourMemberDao.retrieveYLYSTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            ylysTotalPolylineData.add(temp);
        });
        statisticsInfo.setYlysTotalPolylineData(ylysTotalPolylineData);
        return R.ok(statisticsInfo);
    }
    /**
     * 杨家坪定制页面-五微服务
     * @param communityId
     * @return
     */
    @Override
    public R getFmsBaseData(Long communityId) {
        BigScreenFmsStatisticsInfo statisticsInfo = comFmsServiceDAO.getFmsBaseData(communityId);
        //团队类型占比圆形图
        List<ComFmsTeamVO> preTeamTypeCircleData = comFmsServiceDAO.retrieveTeamTypeCircleData(communityId);
        List<StatisticsCommVO> teamTypeCircleData = new ArrayList<>();
        if (!preTeamTypeCircleData.isEmpty()) {
            Integer teamCount = preTeamTypeCircleData.size();
            Map<String, List<ComFmsTeamVO>> collect = preTeamTypeCircleData.stream().collect(Collectors.groupingBy(ComFmsTeamVO::getTeamTypeName));
            for (Map.Entry<String, List<ComFmsTeamVO>> entry : collect.entrySet()) {
                StatisticsCommVO temp = new StatisticsCommVO();
                int size = entry.getValue().size();
                temp.setFiled(entry.getKey());
                temp.setNum(size);
                temp.setPercent(new BigDecimal(size/teamCount).setScale(2));
                teamTypeCircleData.add(temp);
            }
        }
        statisticsInfo.setTeamTypeCircleData(teamTypeCircleData);
        //微服务新增折线数据
        List<StatisticsCommVO> serviceAddPolylineData = comFmsServiceDAO.retrieveServiceAddPolylineData(communityId);
        statisticsInfo.setServiceAddPolylineData(serviceAddPolylineData);
        //微服务累计折线数据
        List<StatisticsCommVO> serviceTotalPolylineData = new ArrayList<>();
        serviceAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comFmsServiceDAO.retrieveServiceTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            serviceTotalPolylineData.add(temp);
        });
        statisticsInfo.setServiceTotalPolylineData(serviceTotalPolylineData);
        //微调节矛盾类型占比圆形图
        List<EventVO> preAdjustCircleData = comFmsServiceDAO.retrieveAdjustCircleData(communityId);
        List<StatisticsCommVO> adjustCircleData = new ArrayList<>();
        if (!preAdjustCircleData.isEmpty()) {
            Integer adjustCount = preAdjustCircleData.size();
            Map<String, List<EventVO>> collect = preAdjustCircleData.stream().collect(Collectors.groupingBy(EventVO::getEventClazz));
            for (Map.Entry<String, List<EventVO>> entry : collect.entrySet()) {
                StatisticsCommVO temp = new StatisticsCommVO();
                int size = entry.getValue().size();
                temp.setFiled(entry.getKey());
                temp.setNum(size);
                temp.setPercent(new BigDecimal(size/adjustCount).setScale(2));
                adjustCircleData.add(temp);
            }
        }
        statisticsInfo.setAdjustCircleData(adjustCircleData);
        //新增解决矛盾折线数据
        List<StatisticsCommVO> adjustAddPolylineData = comFmsServiceDAO.retrieveAdjustAddPolylineData(communityId);
        statisticsInfo.setAdjustAddPolylineData(adjustAddPolylineData);
        //累计解决矛盾折线数据
        List<StatisticsCommVO> adjustTotalPolylineData = new ArrayList<>();
        adjustAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comFmsServiceDAO.retrieveAdjustTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            adjustTotalPolylineData.add(temp);
        });
        statisticsInfo.setAdjustTotalPolylineData(adjustTotalPolylineData);
        //微防控防控类型占比圆形图
        List<EventVO> preControlCircleData = comFmsServiceDAO.retrieveControlCircleData(communityId);
        List<StatisticsCommVO> controlCircleData = new ArrayList<>();
        if (!preControlCircleData.isEmpty()) {
            Integer controlCount = preControlCircleData.size();
            Map<String, List<EventVO>> collect = preControlCircleData.stream().collect(Collectors.groupingBy(EventVO::getEventClazz));
            for (Map.Entry<String, List<EventVO>> entry : collect.entrySet()) {
                StatisticsCommVO temp = new StatisticsCommVO();
                int size = entry.getValue().size();
                temp.setFiled(entry.getKey());
                temp.setNum(size);
                temp.setPercent(new BigDecimal(size/controlCount).setScale(2));
                controlCircleData.add(temp);
            }
        }
        statisticsInfo.setControlCircleData(controlCircleData);
        return R.ok(statisticsInfo);
    }
    /**
     * 杨家坪定制页面-微团队展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pageFmsTeam(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comFmsServiceDAO.pageFmsTeam(page, pageBaseDTO));
    }
    /**
     * 杨家坪定制页面-居家养老基础数据
     * @param communityId
     * @return
     */
    @Override
    public R getAlarmBaseData(Long communityId) {
        BigScreenAlarmStatisticsInfo statisticsInfo = comPropertyDao.getAlarmBaseData(communityId);
        //异常报警新增折线数据
        List<StatisticsCommVO> abnormalAddPolylineData = comPropertyDao.retrieveAbnormalAddPolylineData(communityId);
        statisticsInfo.setAbnormalAddPolylineData(abnormalAddPolylineData);
        //异常报警累计折线数据
        List<StatisticsCommVO> abnormalTotalPolylineData = new ArrayList<>();
        abnormalAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comPropertyDao.retrieveAbnormalTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            abnormalTotalPolylineData.add(temp);
        });
        statisticsInfo.setAbnormalTotalPolylineData(abnormalTotalPolylineData);
        //一键求助服务新增折线数据
        List<StatisticsCommVO> serviceAddPolylineData = comPropertyDao.retrieveServiceAddPolylineData(communityId);
        statisticsInfo.setServiceAddPolylineData(serviceAddPolylineData);
        //一键求助服务累计折线数据
        List<StatisticsCommVO> serviceTotalPolylineData = new ArrayList<>();
        serviceAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comPropertyDao.retrieveServiceTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            serviceTotalPolylineData.add(temp);
        });
        statisticsInfo.setServiceTotalPolylineData(serviceTotalPolylineData);
        return R.ok(statisticsInfo);
    }
    /**
     * 杨家坪定制页面-报警记录展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pageAlarmRecord(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        Integer param3 = pageBaseDTO.getParam3();
        Long communityId = pageBaseDTO.getCommunityId();
        IPage<ComPropertyAlarmVO> abnormalList = null;
        switch (param3) {
            case 1:
                //待处理异常展示列表
                abnormalList = comPropertyDao.getAbnormalList(page,2, 0, communityId);
                break;
            case 2:
                //已处理异常展示列表
                abnormalList = comPropertyDao.getAbnormalList(page,2, 1, communityId);
                break;
            case 3:
                //待服务展示列表
                abnormalList = comPropertyDao.getAbnormalList(page,1, 0, communityId);
                break;
            case 4:
                //已服务展示列表
                abnormalList = comPropertyDao.getAbnormalList(page,1, 1, communityId);
                break;
            default:
                break;
        }
        return R.ok(abnormalList);
    }
    /**
     * 杨家坪定制页面-报警设备点位图
     * @param communityId
     * @return
     */
    @Override
    public R getAlarmPointMap(Long communityId) {
        List<ComPropertyEquipmentVO> list = comPropertyDao.getAlarmPointMapData(communityId);
        List<EquipmentPointMapDataVO> pointMapDataList = new ArrayList<>();
        if (!list.isEmpty()) {
            Map<String, List<ComPropertyEquipmentVO>> collect = list.stream().collect(Collectors.groupingBy(e -> "[" + e.getLatitude() + "," + e.getLongitude() + "]"));
            for (Map.Entry<String, List<ComPropertyEquipmentVO>> entry : collect.entrySet()) {
                EquipmentPointMapDataVO pointMapDataVO = new EquipmentPointMapDataVO();
                List<ComPropertyEquipmentVO> value = entry.getValue();
                pointMapDataVO.setPosition(entry.getKey());
                List<ComPropertyEquipmentVO> sortedList = value.stream()
                        .sorted(Comparator.comparing(ComPropertyEquipmentVO::getEquipmentStatus)).collect(Collectors.toList());
                pointMapDataVO.setEquipments(sortedList);
                pointMapDataVO.setEquipmentNum(value.size());
                boolean isRed = value.stream().anyMatch(e -> e.getEquipmentStatus().equals(1));
                boolean isYellow = value.stream().anyMatch(e -> e.getEquipmentStatus().equals(2));
                pointMapDataVO.setPointColor(isRed ? 1 : (isYellow ? 2 : 3));
                pointMapDataList.add(pointMapDataVO);
            }
        }
        return R.ok(pointMapDataList);
    }
    /**
     * 杨家坪定制页面-志愿服务
     * @param communityId
     * @return
     */
    @Override
    public R getVolunteerBaseData(Long communityId) {
        BigScreenVolunteerStatisticsInfo statisticsInfo = comMngVolunteerMngDAO.getVolunteerBaseData(communityId);
        BigScreenVolunteerActStatisticsInfo info = getBigScreenVolunteerActStatisticsInfo(communityId);
        BeanUtils.copyProperties(info, statisticsInfo);
        //志愿者统计-组织人数直方图
        statisticsInfo.setVolunteerOrgHistogram(comMngVolunteerMngDAO.retrieveVolunteerOrgHistogram(communityId));
        //志愿者服务类型占比圆形图
        List<ComMngVolunteerMngVO> preVolunteerServiceTypeCircleData = comMngVolunteerMngDAO.retrieveVolunteerServiceTypeCircleData(communityId);
        List<StatisticsCommVO> volunteerServiceTypeCircleData = new ArrayList<>();
        if (!preVolunteerServiceTypeCircleData.isEmpty()) {
            Integer count = preVolunteerServiceTypeCircleData.size();
            Map<String, List<ComMngVolunteerMngVO>> collect = preVolunteerServiceTypeCircleData.stream().collect(Collectors.groupingBy(ComMngVolunteerMngVO::getServiceTypeName));
            for (Map.Entry<String, List<ComMngVolunteerMngVO>> entry : collect.entrySet()) {
                StatisticsCommVO temp = new StatisticsCommVO();
                int size = entry.getValue().size();
                temp.setFiled(entry.getKey());
                temp.setNum(size);
                temp.setPercent(new BigDecimal(size/count).setScale(2));
                volunteerServiceTypeCircleData.add(temp);
            }
        }
        statisticsInfo.setVolunteerServiceTypeCircleData(volunteerServiceTypeCircleData);
        //志愿者年龄段占比圆形图
        List<StatisticsCommVO> volunteerAgeCircleData = comMngVolunteerMngDAO.retrieveVolunteerAgeCircleData(communityId);
        int sum = volunteerAgeCircleData.stream().mapToInt(StatisticsCommVO::getNum).sum();
        volunteerAgeCircleData.forEach(e -> {
            if (sum != 0) {
                e.setPercent(new BigDecimal(e.getNum()/sum).setScale(2));
            } else {
                e.setPercent(new BigDecimal(0));
            }
        });
        statisticsInfo.setVolunteerAgeCircleData(volunteerAgeCircleData);
        //志愿者技能占比圆形图
        List<ComMngVolunteerMngVO> preVolunteerSkillCircleData = comMngVolunteerMngDAO.retrieveVolunteerSkillCircleData(communityId);
        List<StatisticsCommVO> volunteerSkillCircleData = new ArrayList<>();
        if (!preVolunteerSkillCircleData.isEmpty()) {
            Integer count = preVolunteerSkillCircleData.size();
            Map<String, List<ComMngVolunteerMngVO>> collect = preVolunteerSkillCircleData.stream().collect(Collectors.groupingBy(ComMngVolunteerMngVO::getSkillName));
            for (Map.Entry<String, List<ComMngVolunteerMngVO>> entry : collect.entrySet()) {
                StatisticsCommVO temp = new StatisticsCommVO();
                int size = entry.getValue().size();
                temp.setFiled(entry.getKey());
                temp.setNum(size);
                temp.setPercent(new BigDecimal(size/count).setScale(2));
                volunteerSkillCircleData.add(temp);
            }
        }
        statisticsInfo.setVolunteerSkillCircleData(volunteerSkillCircleData);
        //志愿者组织数据
        List<VolunteerOrgRelationVO> volunteerOrgRelationList = new ArrayList<>();
        List<ComMngVolunteerMngVO> volunteerData = comMngVolunteerMngDAO.selectVolunteerByCommunityId(communityId);
        if (!volunteerData.isEmpty()) {
            Map<String, List<ComMngVolunteerMngVO>> collect = volunteerData.stream().collect(Collectors.groupingBy(ComMngVolunteerMngVO::getOrgName));
            for (Map.Entry<String, List<ComMngVolunteerMngVO>> entry : collect.entrySet()) {
                VolunteerOrgRelationVO relationVO = new VolunteerOrgRelationVO();
                relationVO.setOrg(entry.getKey());
                relationVO.setOrgPersonNum(entry.getValue().size());
                relationVO.setVolunteers(entry.getValue());
                volunteerOrgRelationList.add(relationVO);
            }
        }
        statisticsInfo.setVolunteerOrgRelationList(volunteerOrgRelationList);
        return R.ok(statisticsInfo);
    }
    /**
     * 金沙定制页面-志愿线展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pagePartyBuildIngMicroWish(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comActMicroWishDAO.pagePartyBuildIngMicroWish(page, pageBaseDTO));
    }
    /**
     * 金沙定制页面-四长四员解决问题展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pageFourMemberResolve(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comActMicroWishDAO.pageFourMemberResolve(page, pageBaseDTO));
    }
    /**
     * 金沙定制页面-四长四员院落议事展示列表
     * @param pageBaseDTO
     * @return
     */
    @Override
    public R pageCourtyardDiscuss(PageBaseDTO pageBaseDTO) {
        Page page = retrievePage(pageBaseDTO);
        return R.ok(comActDiscussDAO.pageCourtyardDiscuss(page, pageBaseDTO));
    }
    /**
     * 金沙定制页面-院落议事
     * @param communityId
     * @return
     */
    @Override
    public R getCourtyardBaseData(Long communityId) {
        BigScreenCourtyardStatisticsInfo statisticsInfo = comActDiscussDAO.getCourtyardBaseData(communityId);
        //新增院落议事数
        List<StatisticsCommVO> discussAddPolylineData = comActFourMemberDao.retrieveYLYSAddPolylineData(communityId);
        statisticsInfo.setDiscussAddPolylineData(discussAddPolylineData);
        //累计院落议事数
        List<StatisticsCommVO> discussTotalPolylineData = new ArrayList<>();
        discussAddPolylineData.forEach(e -> {
            StatisticsCommVO temp = comActFourMemberDao.retrieveYLYSTotalPolylineData(communityId, e.getFiled());
            temp.setFiled(e.getFiled());
            discussTotalPolylineData.add(temp);
        });
        statisticsInfo.setDiscussTotalPolylineData(discussTotalPolylineData);
        return R.ok(statisticsInfo);
    }
    private Page retrievePage(PageBaseDTO pageBaseDTO) {
        Long pageNum = pageBaseDTO.getPageNum();
        Long size = pageBaseDTO.getPageSize();
@@ -645,4 +1224,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;
    }
}