huanghongfa
2021-07-30 b200b681bc401bb11c133a79273ba78cb6ebedf8
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
@@ -1,5 +1,8 @@
package com.panzhihua.service_grid.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdcardUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -9,25 +12,28 @@
import com.panzhihua.common.enums.EventType;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO;
import com.panzhihua.common.model.dtos.community.bigscreen.event.ScreenDrawEventListDTO;
import com.panzhihua.common.model.dtos.community.bigscreen.event.ScreenEventListDTO;
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActVO;
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.EventLeftDownStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.event.EventListVO;
import com.panzhihua.common.model.vos.grid.*;
import com.panzhihua.common.model.vos.screen.*;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.ExcelSelectListUtil;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.GisPointUtil;
import com.panzhihua.common.utlis.LngLatUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_grid.dao.*;
import com.panzhihua.service_grid.model.dos.*;
import com.panzhihua.service_grid.service.EventGridDataService;
import com.panzhihua.service_grid.service.EventResourceService;
import com.panzhihua.service_grid.service.EventService;
import com.panzhihua.service_grid.service.EventTransferRecordService;
import com.panzhihua.service_grid.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -57,9 +63,17 @@
    @Resource
    private EventGridMemberRelationMapper eventGridMemberRelationMapper;
    @Resource
    private EventSpecialCrowdRecordService eventSpecialCrowdRecordService;
    @Resource
    private EventSpecialCrowdRecordMapper eventSpecialCrowdRecordMapper;
    @Resource
    private EventGridDataService eventGridDataService;
    @Resource
    private EventResourceMapper eventResourceMapper;
    private final String moth_format_str = "yyyy-MM";
    private final String[] monthStr = new String[]{"一","二","三","四","五","六","七","八","九","十","十一","十二"};
    /**
     * 分页查找事件
@@ -112,9 +126,10 @@
                eventVO.setVideos(videoList);
                //查询网格员头像
                String imageUrl = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(imageUrl)) {
                    eventVO.setGridMemberImageUrl(imageUrl);
                Map<String,String> userMap = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(userMap)) {
                    eventVO.setGridMemberName(userMap.get("nick_name"));
                    eventVO.setGridMemberImageUrl(userMap.get("image_url"));
                }
            });
            return R.ok(ipage);
@@ -159,6 +174,7 @@
            EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(eventDO.getGridId());
            if (eventGridDataDO != null) {
                eventDetailsVO.setGridName(eventGridDataDO.getGridName());
                eventDetailsVO.setCommunityId(eventGridDataDO.getGridCommunityId());
            }
            //查询事件关联附件
@@ -242,16 +258,26 @@
            //查询网格员头像,姓名
            Map<String,Object> gridMember = eventMapper.getUserBaseInfo(eventDO.getGridMemberId());
            if (!CollectionUtils.isEmpty(gridMember)) {
                eventDetailsVO.setGridMemberName(gridMember.get("name") == null ? "" : gridMember.get("name").toString());
                eventDetailsVO.setGridMemberName(gridMember.get("nick_name") == null ? "" : gridMember.get("nick_name").toString());
                eventDetailsVO.setGridMemberImageUrl(gridMember.get("image_url") == null ? "" : gridMember.get("image_url").toString());
            }
            if(Objects.equals(eventDO.getGridMemberId(),eventDO.getCreateBy())){
                eventDetailsVO.setCreator(eventDetailsVO.getGridMemberName());
            }else{
                Map<String,Object> createUser = eventMapper.getUserBaseInfo(eventDO.getCreateBy());
                eventDetailsVO.setCreator(createUser.get("name") == null ? "" : createUser.get("name").toString());
                eventDetailsVO.setCreator(createUser.get("nick_name") == null ? "" : createUser.get("nick_name").toString());
            }
            //当事件为特殊人群上报时,需要查询事件与人口关联关系
            if(eventDetailsVO.getEventType() != null && eventDetailsVO.getEventType().equals(6)){
                List<EventSpecialPopulationDetailsVO> specialPopulationList = eventSpecialCrowdRecordMapper.getSpecialPopulationIds(eventDetailsVO.getId());
                if(!specialPopulationList.isEmpty()){
                    specialPopulationList.forEach(special -> {
                        special.setAge(IdcardUtil.getAgeByIdCard(special.getIdCard()));
                    });
                }
                eventDetailsVO.setPopulationList(specialPopulationList);
            }
            return R.ok(eventDetailsVO);
        }
        return R.fail("事件不存在");
@@ -272,6 +298,16 @@
        if (eventGridDataDO == null) {
            return R.fail("网格不存在");
        }
        eventDO.setGridMemberCommunity(eventGridDataDO.getGridCommunityId());
        eventDO.setGridMemberStreet(eventGridDataDO.getGridStreetId());
        //检查特殊人群上报时参数
//        if(commonEventAddDTO.getEventType().equals(6)){
//            if(commonEventAddDTO.getPopulationIds() == null || commonEventAddDTO.getPopulationIds().size() <= 0){
//                return R.fail("上报人员为空");
//            }
//        }
        eventDO.setEventCategory(1l);//办件事件
        eventDO.setEventStatus(2);//事件状态 2发布
        eventDO.setProcessType(1);//网格员处理
@@ -282,7 +318,24 @@
        eventDO.setCreateBy(commonEventAddDTO.getUserId());
        eventDO.setSubmitDate(new Date());
        eventDO.setOrderSn(getEventOrderSn(eventDO.getEventType()));
        if (eventMapper.insert(eventDO) == 1) {
            //如果是特殊人群,则新增特殊人群与事件关系
            if(commonEventAddDTO.getEventType().equals(6)){
                if(commonEventAddDTO.getPopulationIds() != null && commonEventAddDTO.getPopulationIds().size() > 0){
                    List<EventSpecialCrowdRecordDO> crowdRecordList = new ArrayList<>();
                    commonEventAddDTO.getPopulationIds().forEach(populationId -> {
                        EventSpecialCrowdRecordDO specialCrowdRecordDO = new EventSpecialCrowdRecordDO();
                        specialCrowdRecordDO.setEventId(eventDO.getId());
                        specialCrowdRecordDO.setPopulationId(populationId);
                        specialCrowdRecordDO.setCreateAt(new Date());
                        crowdRecordList.add(specialCrowdRecordDO);
                    });
                    //添加特殊人群上报事件与人口关系
                    eventSpecialCrowdRecordService.saveBatch(crowdRecordList);
                }
            }
            //添加音频
            if (StringUtils.isNotEmpty(commonEventAddDTO.getAudio())) {
                EventResourceDO eventResourceDO = new EventResourceDO();
@@ -343,7 +396,15 @@
        if (eventGridDataDO == null) {
            return R.fail("网格不存在");
        }
        if (commonEventEditDTO.getId() == null) {
            //检查特殊人群上报时参数
            if(commonEventEditDTO.getEventType().equals(6)){
                if(commonEventEditDTO.getPopulationIds().isEmpty()){
                    return R.fail("上报人员为空");
                }
            }
            EventDO eventDO = new EventDO();
            BeanUtils.copyProperties(commonEventEditDTO, eventDO);
            eventDO.setGridMemberId(commonEventEditDTO.getUserId());
@@ -357,6 +418,21 @@
            eventDO.setGridMemberTelephone(commonEventEditDTO.getPhone());
            eventDO.setEventDealStatus(5);
            if (eventMapper.insert(eventDO) > 0) {
                //如果是特殊人群,则新增特殊人群与事件关系
                if(commonEventEditDTO.getEventType().equals(6)){
                    List<EventSpecialCrowdRecordDO> crowdRecordList = new ArrayList<>();
                    commonEventEditDTO.getPopulationIds().forEach(populationId -> {
                        EventSpecialCrowdRecordDO specialCrowdRecordDO = new EventSpecialCrowdRecordDO();
                        specialCrowdRecordDO.setEventId(eventDO.getId());
                        specialCrowdRecordDO.setPopulationId(populationId);
                        specialCrowdRecordDO.setCreateAt(new Date());
                        crowdRecordList.add(specialCrowdRecordDO);
                    });
                    //添加特殊人群上报事件与人口关系
                    eventSpecialCrowdRecordService.saveBatch(crowdRecordList);
                }
                //添加音频
                if (StringUtils.isNotEmpty(commonEventEditDTO.getAudio())) {
                    EventResourceDO eventResourceDO = new EventResourceDO();
@@ -668,15 +744,20 @@
    public R republishEvent(CommonEventRepublishDTO commonEventRepublishDTO) {
        EventDO eventDO = this.getBaseMapper().selectById(commonEventRepublishDTO.getId());
        //boolean canRepublishByUser = eventDO.getEventStatus() == 4 || eventDO.getEventStatus() == 1;
        boolean canRepublishByUser = eventDO.getEventDealStatus() == 7|eventDO.getEventDealStatus() == 5; //已失效状态
        boolean canRepublishByUser = eventDO.getEventDealStatus() == 6|eventDO.getEventDealStatus() == 5; //已失效状态
        if (!canRepublishByUser) {
            return R.fail("当前不是撤销/草稿状态");
        }
        if(eventDO.getEventCategory().equals(2L)){//宣传教育
            eventDO.setEventDealStatus(8);
        }else{
            eventDO.setEventProcessStatus(1); //待解决
            eventDO.setProcessType(1);   //网格员处理
        }
        eventDO.setEventStatus(2);//2 发布
        eventDO.setEventProcessStatus(1); //待解决
        eventDO.setProcessType(1);   //网格员处理
        eventDO.setUpdateBy(commonEventRepublishDTO.getUserId());
        int updated = this.getBaseMapper().updateById(eventDO);
        if (updated != 1) {
            return R.fail("更新事件状态失败");
@@ -954,10 +1035,13 @@
        }
        EventDO eventDO = new EventDO();
        BeanUtils.copyProperties(publicityEventAddDTO, eventDO);
        eventDO.setHappenTime(publicityEventAddDTO.getPropagandaTime());
        eventDO.setGridMemberId(publicityEventAddDTO.getUserId());
        eventDO.setEventCategory(2l);//宣传事件
        eventDO.setEventStatus(2);//事件状态 2发布
        eventDO.setEventType(8);
        eventDO.setGridMemberCommunity(eventGridDataDO.getGridCommunityId());
        eventDO.setGridMemberStreet(eventGridDataDO.getGridStreetId());
        if(publicityEventAddDTO.getGridMemberId()!=null) {
            eventDO.setGridMemberId(publicityEventAddDTO.getGridMemberId());
        }else{
@@ -1198,9 +1282,10 @@
                eventVO.setPics(picList);
                eventVO.setVideos(videoList);
                //查询网格员头像
                String imageUrl = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(imageUrl)) {
                    eventVO.setGridMemberImageUrl(imageUrl);
                Map<String,String> userMap = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(userMap)) {
                    eventVO.setGridMemberName(userMap.get("nick_name"));
                    eventVO.setGridMemberImageUrl(userMap.get("image_url"));
                }
            });
            return R.ok(ipage);
@@ -1259,9 +1344,10 @@
                eventVO.setVideos(videoList);
                //查询网格员头像
                String imageUrl = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(imageUrl)) {
                    eventVO.setGridMemberImageUrl(imageUrl);
                Map<String,String> userMap = eventMapper.getGridMemberImageUrl(eventVO.getGridMemberId());
                if (StringUtils.isNotEmpty(userMap)) {
                    eventVO.setGridMemberName(userMap.get("nick_name"));
                    eventVO.setGridMemberImageUrl(userMap.get("image_url"));
                }
            });
            return R.ok(ipage);
@@ -1669,9 +1755,13 @@
    public R getNearByGrid(PageEventGridNearbyDTO pageEventGridNearbyDTO) {
        Page page = new Page(pageEventGridNearbyDTO.getPageNum(), pageEventGridNearbyDTO.getPageSize());
        String latLng = pageEventGridNearbyDTO.getHappentLatLng();
        if(!latLng.matches("^[\\-\\+]?(0(\\.\\d{1,10})?|([1-9](\\d)?)(\\.\\d{1,10})?|1[0-7]\\d{1}(\\.\\d{1,10})?|180\\.0{1,10}),[\\-\\+]?((0|([1-8]\\d?))(\\.\\d{1,10})?|90(\\.0{1,10})?)$")){
            return R.fail("经纬度参数错误");
        }
//        if(!latLng.matches("^[\\-\\+]?(0(\\.\\d{1,10})?|([1-9](\\d)?)(\\.\\d{1,10})?|1[0-7]\\d{1}(\\.\\d{1,10})?|180\\.0{1,10}),[\\-\\+]?((0|([1-8]\\d?))(\\.\\d{1,10})?|90(\\.0{1,10})?)$")){
//            return R.fail("经纬度参数错误");
//        }
        //经纬度匹配规则:(短(纬度)在前长(经度)在后,不要擅自修改此规则,否则出现问题后果自负)
//        if(!latLng.matches("[1-9][0-9](\\.[0-9]{1,6})?,[1-9][0-9]{2}(\\.[0-9]{1,6})?")){
//            return R.fail("经纬度参数错误");
//        }
        String latLngArr[] = latLng.split(",");
        try {
            Double lat = Double.valueOf(latLngArr[1]);
@@ -1837,8 +1927,26 @@
     * @return  网格统计数据
     */
    @Override
    public R getGridEventStatisticsByApp(Long gridId){
        return R.ok(this.baseMapper.getGridEventStatisticsByApp(gridId));
    public R getGridEventStatisticsByApp(Long gridId,Long userId){
        GridEventStatisticsVO result = this.baseMapper.getGridEventStatisticsByApp(gridId);
        if(result != null){
            result.setTodayNum(result.getTodayNum() + result.getZfTodayNum());
            result.setMonthNum(result.getMonthNum() + result.getZfMonthNum());
            //查询当前网格员下管理的楼栋名称
            List<Map<String,Object>> buildNameList = this.baseMapper.getMemberBuildName(userId);
            Integer specialTotal = 0;
            if(!buildNameList.isEmpty()){
                for (Map<String,Object> buildMap:buildNameList) {
                    String buildName = buildMap.get("name").toString();
                    Long villageId = Long.parseLong(buildMap.get("village_id").toString());
                    Integer num = this.baseMapper.getPopulationByLabelCount(buildName,villageId);
                    specialTotal += num;
                }
            }
            result.setSpecialTotal(specialTotal);
        }
        return R.ok(result);
    }
    /**
@@ -1864,6 +1972,16 @@
        }
        if(statisticsDetailVO.getNoEventZFTotal() == null){
            statisticsDetailVO.setNoEventZFTotal(0);
        }
        //查询网格
        EventGridDataDO gridDataDO = eventGridDataMapper.selectById(statisticsDTO.getGridId());
        if(gridDataDO != null){
            Map<String,Long> sspCountMap = this.baseMapper.getSSPEventTotal(gridDataDO.getGridCommunityId());
            if(!sspCountMap.isEmpty()){
                statisticsDetailVO.setEventSSPTotal(sspCountMap.get("eventSSPTotal")!=null?sspCountMap.get("eventSSPTotal").intValue():0);
                statisticsDetailVO.setNoEventSSPTotal(sspCountMap.get("noEventSSPTotal")!=null?sspCountMap.get("noEventSSPTotal").intValue():0);
            }
        }
        //统计数据
@@ -2069,19 +2187,82 @@
     * @return  事件列表
     */
    @Override
    public R getScreenEventList(ScreenEventListDTO eventListDTO){
        if( eventListDTO.getEventType() != null && eventListDTO.getEventType().equals(ScreenEventListDTO.eventType.xc)){
            eventListDTO.setEventCategory(2);
        }
        IPage<EventListVO> eventPageList = this.baseMapper.getScreenEventList(new Page(eventListDTO.getPageNum(),eventListDTO.getPageSize()),eventListDTO);
        return R.ok(eventPageList);
    public R getScreenEventList(ScreenEventListDTO eventListDTO) {
        if (eventListDTO.getEventTypes() != null && !eventListDTO.getEventTypes().isEmpty()) {
            eventListDTO.getEventTypes().forEach(eventType -> {
                if(eventType.equals(ScreenEventListDTO.eventType.xc)){
                    eventListDTO.setEventCategory(null);
                }
            });
        }
        IPage<EventListVO> eventPageList = this.baseMapper.getScreenEventList(new Page(eventListDTO.getPageNum(), eventListDTO.getPageSize()), eventListDTO);
        if(!eventPageList.getRecords().isEmpty()){
            eventPageList.getRecords().forEach(event -> {
                //查询事件关联附件
                List<EventResourceDO> eventResourceDOList =
                        eventResourceService.getBaseMapper().selectList(new LambdaQueryWrapper<EventResourceDO>()
                                .eq(EventResourceDO::getClassification, 1)
                                .eq(EventResourceDO::getRefId, event.getId())
                        );
                List<EventResourceVO> picList = new ArrayList<>();
                List<EventResourceVO> audioList = new ArrayList<>();
                List<EventResourceVO> videoList = new ArrayList<>();
                eventResourceDOList.forEach(eventResourceDO -> {
                    switch (eventResourceDO.getType()) {
                        case 1:
                            EventResourceVO picEventResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, picEventResourceVO);
                            picList.add(picEventResourceVO);
                            break;
                        case 2:
                            EventResourceVO audioResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, audioResourceVO);
                            audioList.add(audioResourceVO);
                            break;
                        case 3:
                            EventResourceVO videoResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, videoResourceVO);
                            videoList.add(videoResourceVO);
                            break;
                    }
                });
                event.setAudios(audioList);
                event.setPics(picList);
                event.setVideos(videoList);
            });
        }
        return R.ok(eventPageList);
    }
    /**
     * 特殊人群上报-社区人口数据列表
     * @param specialPopulationDTO   请求参数
     * @return  社区人口数据列表
     */
    @Override
    public R specialPopulationList(PageEventSpecialPopulationDTO specialPopulationDTO) {
        IPage<EventSpecialPopulationVO> specialPopulationVOIPage = this.baseMapper.specialPopulationList(new Page(specialPopulationDTO.getPageNum(), specialPopulationDTO.getPageSize()), specialPopulationDTO);
        if(!specialPopulationVOIPage.getRecords().isEmpty()){
            specialPopulationVOIPage.getRecords().forEach(specialPopulation -> {
                try {
                    Integer age = IdcardUtil.getAgeByIdCard(specialPopulation.getIdCard());
                    specialPopulation.setAge(age);
                }catch (Exception e){
                    log.error("身份证号码转换年龄失败,人员id:" + specialPopulation.getId());
                }
            });
        }
        return R.ok(specialPopulationVOIPage);
    }
    @Override
    public List<EventDetailsVO> getUnUploadEvent() {
        List<EventDetailsVO> eventDetailsVOList =new ArrayList<>();
        List<EventDO> unEventList = baseMapper.selectList(
                new QueryWrapper<EventDO>()
                        .eq("upload", false)
                        .eq("event_process_status", 2)
        );
        unEventList.forEach(eventDO -> {
            eventDetailsVOList.add(eventDetails(eventDO.getId()).getData());
@@ -2104,4 +2285,293 @@
        }
        return false;
    }
    @Override
    public R eventWork(Long communityId){
        EventWorkScreenVO workScreenVO = new EventWorkScreenVO();
        String date = DateUtils.getDateFormatString(new Date(),moth_format_str);
        Map<String,Long> countMap = this.eventMapper.countByCommunityId(communityId,date);
        if(!countMap.isEmpty()){
            workScreenVO.setResolvedNum(countMap.get("resolvedNum")== null ? 0L : Long.valueOf(countMap.get("resolvedNum").toString()));
            workScreenVO.setPendingNum(countMap.get("pendingNum")== null ? 0L : Long.valueOf(countMap.get("pendingNum").toString()));
            workScreenVO.setPropagandaNum(countMap.get("propagandaNum")== null ? 13L : Long.valueOf(countMap.get("propagandaNum").toString()));
            workScreenVO.setCurrentNum(countMap.get("sspCurrentNum") + countMap.get("currentNum"));
        }
        //计算处理时间消耗的时间
        DateScreenVO countAvg = this.eventMapper.countByAvgCommunityId(communityId);
        if(countAvg != null){
            int second = (int) (countAvg.getEndTime().getTime() - countAvg.getStartTime().getTime())/1000;
            if(second > 0){
                second = second/workScreenVO.getResolvedNum().intValue();
                workScreenVO.setAvgCost(second);
            }
        }
        //查询最新事件轮播列表
        List<EventDetailWorkVO> eventList = this.eventMapper.getWorkScreenEventList(communityId);
        if(!eventList.isEmpty()){
            workScreenVO.setEventList(eventList);
        }
        //统计近半年数据
        List<EventWorkVO> list = new ArrayList<>();
        for(EventWorkVO eventWorkVO: listHalfYearByDyn()){
            EventWorkVO result = this.eventMapper.countByTime(eventWorkVO.getStart(),eventWorkVO.getEnd(),communityId);
            result.setEventTotal(result.getEventTotal() + result.getSspTotal());
            result.setEventAdd(result.getEventAdd() + result.getSspAdd());
            result.setEventSolve(result.getEventSolve() + result.getSspSolve());
            result.setMonth(eventWorkVO.getMonth());
            list.add(result);
        }
        workScreenVO.setList(list);
        //查询完成事件统计
        EventTypeWorkVO complete = this.eventMapper.getComplete(communityId);
        if(complete != null){
            workScreenVO.setComplete(complete);
        }
        //查询未完成事件统计
        EventTypeWorkVO noComplete = this.eventMapper.getNoComplete(communityId);
        if(complete != null){
            workScreenVO.setNoComplete(noComplete);
        }
        return R.ok(workScreenVO);
    }
    private List<EventWorkVO> listHalfYearByDyn() {
        List<EventWorkVO> dateList = new ArrayList<>();
        Date now  = new Date();
        for(int i= 6;i>=1;i--){
            Date date = DateUtils.getDateM(now,-(i-1));
            DateTime endDay = DateUtil.endOfMonth(date);
            int m = DateUtil.month(endDay);
//            m++;
            if(m == 12){
                m = 0;
            }
            int day = DateUtil.dayOfMonth(endDay);
            int half = day/2;
            String month = DateUtil.format(date,moth_format_str);
            EventWorkVO eventWorkVO = new EventWorkVO();
            eventWorkVO.setMonth(monthStr[m]+"月上旬");
            eventWorkVO.setStart(month+ "-01 00:00:00");
            eventWorkVO.setEnd(month+ "-"+half+" 23:59:59");
            dateList.add(eventWorkVO);
            EventWorkVO eventWorkVO1 = new EventWorkVO();
            eventWorkVO1.setMonth(monthStr[m]+"月下旬");
            eventWorkVO1.setStart(month+ "-"+half+" 23:59:59");
            eventWorkVO1.setEnd(DateUtils.getDateFormatString(endDay,"yyyy-MM-dd HH:mm:ss"));
            dateList.add(eventWorkVO1);
        }
        return dateList;
    }
    /**
     * 绘制多边形统计数据
     * @param eventListDTO  请求参数
     * @return  统计数据
     */
    @Override
    public R getCivilDrawList(ScreenDrawEventListDTO eventListDTO){
        ScreenDrawEventVO drawEventVO = new ScreenDrawEventVO();
        //返回事件列表结果集
        List<EventGridIncidentStatisticsVO> eventResultList = new ArrayList<>();
        //返回小区列表结果集
        List<CivilVillageStatisticsVO> villageResultList = new ArrayList<>();
        //返回事件统计
        EventLeftDownStatisticsVO leftDownStatisticsVO = new EventLeftDownStatisticsVO();
        //返回人口统计
        ScreenDrawEventPopulationTotalVO drawEventPopulationTotalVO = new ScreenDrawEventPopulationTotalVO();
        //查询所有事件
        List<EventGridIncidentStatisticsVO> gridIncidentList = this.baseMapper.getEventListByCommunityId(eventListDTO.getCommunityId());
        if(!gridIncidentList.isEmpty()){
            gridIncidentList.forEach(gridIncident -> {
                //拆分事件经纬度
                Double lng = 0.0;//经度
                Double lat = 0.0;//纬度
                String []lngLatString = gridIncident.getLatLng().split(",");
                if(!gridIncident.getType().equals(7)){
                    lat = Double.parseDouble(lngLatString[0]);
                    lng = Double.parseDouble(lngLatString[1]);
                }else {
                    lat = Double.parseDouble(lngLatString[1]);
                    lng = Double.parseDouble(lngLatString[0]);
                }
                //判断绘制的图形类型
                if(eventListDTO.getType().equals(ScreenDrawEventListDTO.type.yx)){
                    //判断这个点是否在圆形范围内
                    if(GisPointUtil.isInCircle(eventListDTO.getCenterLng(),eventListDTO.getCenterLat(),lng,lat,eventListDTO.getRadius())){
                        if(eventResultList.size() <= eventListDTO.getCount()){
                            eventResultList.add(gridIncident);
                        }
                    switch (gridIncident.getType()){
                            case 1:
                                leftDownStatisticsVO.setEventZATotal(leftDownStatisticsVO.getEventZATotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventZATotal(leftDownStatisticsVO.getYesEventZATotal() + 1);
                                }
                                break;
                            case 2:
                                leftDownStatisticsVO.setEventGGTotal(leftDownStatisticsVO.getEventGGTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventGGTotal(leftDownStatisticsVO.getYesEventGGTotal() + 1);
                                }
                                break;
                            case 3:
                                leftDownStatisticsVO.setEventMDTotal(leftDownStatisticsVO.getEventMDTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventMDTotal(leftDownStatisticsVO.getYesEventMDTotal() + 1);
                                }
                                break;
                            case 4:
                                leftDownStatisticsVO.setEventBWDTotal(leftDownStatisticsVO.getEventBWDTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventBWDTotal(leftDownStatisticsVO.getYesEventBWDTotal() + 1);
                                }
                                break;
                            case 5:
                                leftDownStatisticsVO.setEventTFTotal(leftDownStatisticsVO.getEventTFTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventTFTotal(leftDownStatisticsVO.getYesEventTFTotal() + 1);
                                }
                                break;
                            case 6:
                                leftDownStatisticsVO.setEventTSTotal(leftDownStatisticsVO.getEventTSTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventTSTotal(leftDownStatisticsVO.getYesEventTSTotal() + 1);
                                }
                                break;
                            case 7:
                                leftDownStatisticsVO.setEventSSPTotal(leftDownStatisticsVO.getEventSSPTotal() + 1);
                                if(gridIncident.getStatus().equals(2)){
                                    leftDownStatisticsVO.setYesEventSSPTotal(leftDownStatisticsVO.getYesEventSSPTotal() + 1);
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }else{//多边形类型
                    if(GisPointUtil.isInPolygon(lng,lat,eventListDTO.getLngLatList())){
                        if(eventResultList.size() <= eventListDTO.getCount()){
                            eventResultList.add(gridIncident);
                        }
                        switch (gridIncident.getType()){
                            case 1:
                                leftDownStatisticsVO.setEventZATotal(leftDownStatisticsVO.getEventZATotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventZATotal(leftDownStatisticsVO.getYesEventZATotal() + 1);
                                }
                                break;
                            case 2:
                                leftDownStatisticsVO.setEventGGTotal(leftDownStatisticsVO.getEventGGTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventGGTotal(leftDownStatisticsVO.getYesEventGGTotal() + 1);
                                }
                                break;
                            case 3:
                                leftDownStatisticsVO.setEventMDTotal(leftDownStatisticsVO.getEventMDTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventMDTotal(leftDownStatisticsVO.getYesEventMDTotal() + 1);
                                }
                                break;
                            case 4:
                                leftDownStatisticsVO.setEventBWDTotal(leftDownStatisticsVO.getEventBWDTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventBWDTotal(leftDownStatisticsVO.getYesEventBWDTotal() + 1);
                                }
                                break;
                            case 5:
                                leftDownStatisticsVO.setEventTFTotal(leftDownStatisticsVO.getEventTFTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventTFTotal(leftDownStatisticsVO.getYesEventTFTotal() + 1);
                                }
                                break;
                            case 6:
                                leftDownStatisticsVO.setEventTSTotal(leftDownStatisticsVO.getEventTSTotal() + 1);
                                if(gridIncident.getStatus().equals(4)){
                                    leftDownStatisticsVO.setYesEventTSTotal(leftDownStatisticsVO.getYesEventTSTotal() + 1);
                                }
                                break;
                            case 7:
                                leftDownStatisticsVO.setEventSSPTotal(leftDownStatisticsVO.getEventSSPTotal() + 1);
                                if(gridIncident.getStatus().equals(2)){
                                    leftDownStatisticsVO.setYesEventSSPTotal(leftDownStatisticsVO.getYesEventSSPTotal() + 1);
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }
            });
        }
        drawEventVO.setGridIncidentList(eventResultList);
        drawEventVO.setLeftDownStatisticsVO(leftDownStatisticsVO);
        //查询所有小区
        List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(eventListDTO.getCommunityId());
        if(!villageStatisticsList.isEmpty()){
            villageStatisticsList.forEach(village -> {
                //判断绘制的图形类型
                if(eventListDTO.getType().equals(ScreenDrawEventListDTO.type.yx)){
                    //判断这个点是否在圆形范围内
                    if(GisPointUtil.isInCircle(eventListDTO.getCenterLng(),eventListDTO.getCenterLat(),Double.parseDouble(village.getLng()),Double.parseDouble(village.getLat()),eventListDTO.getRadius())){
                        villageResultList.add(village);
                        ScreenDrawEventPopulationTotalVO populationTotalVO = this.baseMapper.getVillagePopulationTotal(village.getVillageId());
                        if(populationTotalVO != null){
                            drawEventPopulationTotalVO.setVillageTotal(drawEventPopulationTotalVO.getVillageTotal() + 1);
                            drawEventPopulationTotalVO.setPopulationTotal(drawEventPopulationTotalVO.getPopulationTotal() + populationTotalVO.getPopulationTotal());
                            drawEventPopulationTotalVO.setLocalTotal(drawEventPopulationTotalVO.getLocalTotal() + populationTotalVO.getLocalTotal());
                            drawEventPopulationTotalVO.setOutTotal(drawEventPopulationTotalVO.getOutTotal() + populationTotalVO.getOutTotal());
                            drawEventPopulationTotalVO.setSpecialTotal(drawEventPopulationTotalVO.getSpecialTotal() + populationTotalVO.getSpecialTotal());
                            drawEventPopulationTotalVO.setBuildTotal(drawEventPopulationTotalVO.getBuildTotal() + populationTotalVO.getBuildTotal());
                        }
                    }
                }else {//多边形类型
                    if(GisPointUtil.isInPolygon(Double.parseDouble(village.getLng()),Double.parseDouble(village.getLat()),eventListDTO.getLngLatList())){
                        villageResultList.add(village);
                        ScreenDrawEventPopulationTotalVO populationTotalVO = this.baseMapper.getVillagePopulationTotal(village.getVillageId());
                        if(populationTotalVO != null){
                            drawEventPopulationTotalVO.setVillageTotal(drawEventPopulationTotalVO.getVillageTotal() + 1);
                            drawEventPopulationTotalVO.setPopulationTotal(drawEventPopulationTotalVO.getPopulationTotal() + populationTotalVO.getPopulationTotal());
                            drawEventPopulationTotalVO.setLocalTotal(drawEventPopulationTotalVO.getLocalTotal() + populationTotalVO.getLocalTotal());
                            drawEventPopulationTotalVO.setOutTotal(drawEventPopulationTotalVO.getOutTotal() + populationTotalVO.getOutTotal());
                            drawEventPopulationTotalVO.setSpecialTotal(drawEventPopulationTotalVO.getSpecialTotal() + populationTotalVO.getSpecialTotal());
                            drawEventPopulationTotalVO.setBuildTotal(drawEventPopulationTotalVO.getBuildTotal() + populationTotalVO.getBuildTotal());
                        }
                    }
                }
            });
        }
        drawEventVO.setVillageStatisticsList(villageResultList);
        drawEventVO.setDrawEventPopulationTotalVO(drawEventPopulationTotalVO);
        return R.ok(drawEventVO);
    }
    /**
     * 大屏-根据小区id查询小区统计人数
     * @param villageId 小区id
     * @return  小区统计数据
     */
    @Override
    public R civilVillageStatistics(Long villageId){
        ScreenDrawEventPopulationTotalVO result = this.baseMapper.getVillagePopulationTotal(villageId);
        result.setVillageTotal(1);
        return R.ok(result);
    }
    /**
     * 查询所有网格员工作汇总数据
     * @param statisticsAdminDTO    请求参数
     * @return  网格员工作汇总数据
     */
    @Override
    public R gridMemberStatisticsAll(MemberStatisticsAdminDTO statisticsAdminDTO){
        return R.ok(eventGridMemberRelationMapper.gridMemberStatisticsAll(statisticsAdminDTO));
    }
}