From 8dd5c057222ea4f6d22d6bc3fba468600f14a330 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期二, 28 十二月 2021 16:28:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java |  212 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 209 insertions(+), 3 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
index 48cf622..87aa649 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
@@ -1,10 +1,15 @@
 package com.panzhihua.service_grid.service.impl;
 
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import com.panzhihua.common.model.vos.community.screen.event.EventComprehensiveGovernanceStatisticsVO;
+import com.panzhihua.common.model.vos.community.StatisticsCommVO;
+import com.panzhihua.common.model.vos.community.bigscreen.GridsGovernanceStatisticsVO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -1376,10 +1381,11 @@
         } else {
             return R.fail("事件所属错误");
         }
-        eventDO.setInvalid(false);
+//        eventDO.setInvalid(false);
         // 标为无效后, 交给网格员处理
         eventDO.setUpdateBy(eventRevokeDTO.getUserId());
         eventDO.setEventStatus(4);// 4、撤销
+        eventDO.setEventDealStatus(6);// 4、撤销
         eventDO.setProcessType(1);// 网格员处理
         eventDO.setCommunityProcess(0);// 非 社区处理
         eventDO.setRevokeId(eventRevokeDTO.getRevokeId());
@@ -1399,11 +1405,13 @@
         if (eventDO == null) {
             return R.fail("事件不存在");
         }
-        boolean canRepulish = eventDO.getEventDealStatus() == 7 | eventDO.getEventDealStatus() == 5; // 已失效状态
+        boolean canRepulish = eventDO.getEventDealStatus() == 7 || eventDO.getEventDealStatus() == 5 || eventDO.getEventDealStatus() == 6; // 已失效状态
         if (!canRepulish) {
-            return R.fail("当前事件不是已失效状态/草稿状态,不能重新发布");
+            return R.fail("当前事件不是已失效状态/草稿状态/撤销状态,不能重新发布");
         }
         eventDO.setInvalid(true);
+        eventDO.setEventStatus(2);
+        eventDO.setEventDealStatus(1);
         int updated = this.getBaseMapper().updateById(eventDO);
         if (updated == 1) {
             addTransferRecord(eventDO.getId(), commonEventRepublishDTO.getUserId(),
@@ -2616,6 +2624,174 @@
         return R.ok(drawEventVO);
     }
 
+    @Override
+    public R getCivilDrawListNew(ScreenDrawEventListDTO eventListDTO) {
+        GridsGovernanceStatisticsVO statisticsVO = new GridsGovernanceStatisticsVO();
+        // 返回事件列表结果集
+        List<EventGridIncidentStatisticsVO> eventResultList = new ArrayList<>();
+        // 返回小区列表结果集
+        List<CivilVillageStatisticsVO> villageResultList = new ArrayList<>();
+        // 返回人口统计
+        ScreenDrawEventPopulationTotalVO drawEventPopulationTotalVO = new ScreenDrawEventPopulationTotalVO();
+        //年龄段统计
+        List<StatisticsCommVO> ageGroupStatistics = new ArrayList<>();
+        // 查询所有事件
+        List<EventGridIncidentStatisticsVO> gridIncidentList =
+                this.baseMapper.getGridsGovernanceEventList(eventListDTO.getCommunityId());
+        if (!gridIncidentList.isEmpty()) {
+            gridIncidentList.forEach(gridIncident -> {
+                // 拆分事件经纬度
+                Double lng = 0.0;// 经度
+                Double lat = 0.0;// 纬度
+                String[] lngLatString = gridIncident.getLatLng().split(",");
+                if (gridIncident.getEventType().equals(1)) {
+                    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);
+                        }
+                        countGridIncidentData(statisticsVO, gridIncident);
+                    }
+                } else {// 多边形类型
+                    if (GisPointUtil.isInPolygon(lng, lat, eventListDTO.getLngLatList())) {
+                        if (eventResultList.size() <= eventListDTO.getCount()) {
+                            eventResultList.add(gridIncident);
+                        }
+                        countGridIncidentData(statisticsVO, gridIncident);
+                    }
+                }
+            });
+        }
+        statisticsVO.setGridIncidentList(eventResultList);
+        // 查询所有小区
+        List<CivilVillageStatisticsVO> villageStatisticsList =
+                this.baseMapper.getCivilScreenVillageList(eventListDTO.getCommunityId());
+        if (!villageStatisticsList.isEmpty()) {
+            List<Long> villageIds = villageStatisticsList.stream().map(CivilVillageStatisticsVO::getVillageId).collect(Collectors.toList());
+            ageGroupStatistics = this.baseMapper.selectStatisticsForAge(villageIds);
+            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())) {
+                        fillVillageResultList(villageResultList, drawEventPopulationTotalVO, village);
+                    }
+                } else {// 多边形类型
+                    if (GisPointUtil.isInPolygon(Double.parseDouble(village.getLng()),
+                            Double.parseDouble(village.getLat()), eventListDTO.getLngLatList())) {
+                        fillVillageResultList(villageResultList, drawEventPopulationTotalVO, village);
+                    }
+                }
+            });
+        }
+        statisticsVO.setVillageStatisticsList(villageResultList);
+        statisticsVO.setDrawEventPopulationTotalVO(drawEventPopulationTotalVO);
+        statisticsVO.setAgeGroupStatistics(ageGroupStatistics);
+        statisticsVO.generateStatisticsData();
+        List<StatisticsCommVO> eventTypeCircleDrawData = new ArrayList<>();
+        if (!eventResultList.isEmpty()) {
+            Map<Integer, List<EventGridIncidentStatisticsVO>> collect = eventResultList.stream().collect(Collectors.groupingBy(EventGridIncidentStatisticsVO::getType));
+            for (Map.Entry<Integer, List<EventGridIncidentStatisticsVO>> entry : collect.entrySet()) {
+                StatisticsCommVO temp = new StatisticsCommVO();
+                int size = entry.getValue().size();
+                Integer eventTotal = statisticsVO.getEventTotal();
+                temp.setFiled(entry.getKey().toString());
+                temp.setNum(size);
+                temp.setPercent(new BigDecimal(size/eventTotal).setScale(2));
+                eventTypeCircleDrawData.add(temp);
+            }
+        }
+        statisticsVO.setEventTypeCircleDrawData(eventTypeCircleDrawData);
+        return R.ok(statisticsVO);
+    }
+
+    private void fillVillageResultList(List<CivilVillageStatisticsVO> villageResultList,
+                                       ScreenDrawEventPopulationTotalVO drawEventPopulationTotalVO, CivilVillageStatisticsVO village) {
+        villageResultList.add(village);
+        ScreenDrawEventPopulationTotalVO populationTotalVO =
+                this.baseMapper.getVillagePopulationTotalNew(village.getVillageId());
+        if (populationTotalVO != null) {
+            drawEventPopulationTotalVO.setVillageTotal(drawEventPopulationTotalVO.getVillageTotal() + 1);
+            drawEventPopulationTotalVO.setPopulationTotal(drawEventPopulationTotalVO.getPopulationTotal() + populationTotalVO.getPopulationTotal());
+            drawEventPopulationTotalVO.setBuildTotal(drawEventPopulationTotalVO.getBuildTotal() + populationTotalVO.getBuildTotal());
+            drawEventPopulationTotalVO.setHouseTotal(drawEventPopulationTotalVO.getHouseTotal() + populationTotalVO.getHouseTotal());
+            drawEventPopulationTotalVO.setLocalTotal(drawEventPopulationTotalVO.getLocalTotal() + populationTotalVO.getLocalTotal());
+            drawEventPopulationTotalVO.setOutTotal(drawEventPopulationTotalVO.getOutTotal() + populationTotalVO.getOutTotal());
+            drawEventPopulationTotalVO.setDisabilityTotal(drawEventPopulationTotalVO.getDisabilityTotal() + populationTotalVO.getDisabilityTotal());
+            drawEventPopulationTotalVO.setLowSecurityTotal(drawEventPopulationTotalVO.getLowSecurityTotal() + populationTotalVO.getLowSecurityTotal());
+            drawEventPopulationTotalVO.setElderTotal(drawEventPopulationTotalVO.getElderTotal() + populationTotalVO.getElderTotal());
+            drawEventPopulationTotalVO.setSpecialSituationTotal(drawEventPopulationTotalVO.getSpecialSituationTotal() + populationTotalVO.getSpecialSituationTotal());
+            drawEventPopulationTotalVO.setOtherTotal(drawEventPopulationTotalVO.getOtherTotal() + populationTotalVO.getOtherTotal());
+            drawEventPopulationTotalVO.setSpecialHelpTotal(drawEventPopulationTotalVO.getSpecialHelpTotal() + populationTotalVO.getSpecialHelpTotal());
+            drawEventPopulationTotalVO.setVeteransTotal(drawEventPopulationTotalVO.getVeteransTotal() + populationTotalVO.getVeteransTotal());
+            drawEventPopulationTotalVO.setOldTotal(drawEventPopulationTotalVO.getOldTotal() + populationTotalVO.getOldTotal());
+            drawEventPopulationTotalVO.setPensionTotal(drawEventPopulationTotalVO.getPensionTotal() + populationTotalVO.getPensionTotal());
+            drawEventPopulationTotalVO.setRentingHouseTotal(drawEventPopulationTotalVO.getRentingHouseTotal() + populationTotalVO.getRentingHouseTotal());
+            drawEventPopulationTotalVO.setVolunteerTotal(drawEventPopulationTotalVO.getVolunteerTotal() + populationTotalVO.getVolunteerTotal());
+            drawEventPopulationTotalVO.setAverageAge(drawEventPopulationTotalVO.getAverageAge() + populationTotalVO.getAverageAge());
+        }
+    }
+
+    private void countGridIncidentData(GridsGovernanceStatisticsVO statisticsVO, EventGridIncidentStatisticsVO gridIncident) {
+        switch (gridIncident.getType()) {
+            case 1:
+                statisticsVO.setEventZATotal(statisticsVO.getEventZATotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventZADeal(statisticsVO.getEventZADeal() + 1);
+                }
+                break;
+            case 2:
+                statisticsVO.setEventMSTotal(statisticsVO.getEventMSTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventMSDeal(statisticsVO.getEventMSDeal() + 1);
+                }
+                break;
+            case 3:
+                statisticsVO.setEventMDTotal(statisticsVO.getEventMDTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventMDDeal(statisticsVO.getEventMDDeal() + 1);
+                }
+                break;
+            case 5:
+                statisticsVO.setEventTFTotal(statisticsVO.getEventTFTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventTFDeal(statisticsVO.getEventTFDeal() + 1);
+                }
+                break;
+            case 6:
+                statisticsVO.setEventTSTotal(statisticsVO.getEventTSTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventTSDeal(statisticsVO.getEventTSDeal() + 1);
+                }
+                break;
+            case 9:
+                statisticsVO.setEventFJTotal(statisticsVO.getEventFJTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setEventFJDeal(statisticsVO.getEventFJDeal() + 1);
+                }
+                break;
+            case 10:
+                statisticsVO.setOtherTotal(statisticsVO.getOtherTotal() + 1);
+                if (gridIncident.getStatus().equals(1)) {
+                    statisticsVO.setOtherDeal(statisticsVO.getOtherDeal() + 1);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
     /**
      * 大屏-根据小区id查询小区统计人数
      * 
@@ -2641,4 +2817,34 @@
     public R gridMemberStatisticsAll(MemberStatisticsAdminDTO statisticsAdminDTO) {
         return R.ok(eventGridMemberRelationMapper.gridMemberStatisticsAll(statisticsAdminDTO));
     }
+
+    /**
+     * 大屏-新根据小区id查询小区统计人数
+     *
+     * @param villageId
+     *            小区id
+     * @return 小区统计数据
+     */
+    @Override
+    public R civilVillageStatisticsNew(Long villageId) {
+        GridsGovernanceStatisticsVO statisticsVO = new GridsGovernanceStatisticsVO();
+        List<Long> villageIds = new ArrayList<>();
+        villageIds.add(villageId);
+        List<StatisticsCommVO> ageGroupStatistics = this.baseMapper.selectStatisticsForAge(villageIds);
+        ScreenDrawEventPopulationTotalVO populationTotalVO = this.baseMapper.getVillagePopulationTotalNew(villageId);
+        statisticsVO.setAgeGroupStatistics(ageGroupStatistics);
+        statisticsVO.setDrawEventPopulationTotalVO(populationTotalVO);
+        return R.ok(statisticsVO);
+    }
+
+    /**
+     * 西区大数据分析平台-综合治理栏
+     * @return
+     */
+    @Override
+    public R getComprehensiveGovernanceStatics() {
+        EventComprehensiveGovernanceStatisticsVO governanceStatisticsVO = this.baseMapper.selectComprehensiveGovernanceStatics();
+        governanceStatisticsVO.generateGovernanceTotal();
+        return R.ok(governanceStatisticsVO);
+    }
 }

--
Gitblit v1.7.1