From 973caebefdd691d45108d56fc96b9aa2e5fc6fe8 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期二, 27 七月 2021 16:59:30 +0800
Subject: [PATCH] 修改bug以及综治后台网格员工作汇总导出接口

---
 springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java |  273 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 253 insertions(+), 20 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 ed84092..7e80a09 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
@@ -12,15 +12,20 @@
 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.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.*;
@@ -253,14 +258,14 @@
             //查询网格员头像,姓名
             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());
             }
 
             //当事件为特殊人群上报时,需要查询事件与人口关联关系
@@ -297,11 +302,11 @@
         eventDO.setGridMemberStreet(eventGridDataDO.getGridStreetId());
 
         //检查特殊人群上报时参数
-        if(commonEventAddDTO.getEventType().equals(6)){
-            if(commonEventAddDTO.getPopulationIds() == null || commonEventAddDTO.getPopulationIds().size() <= 0){
-                return R.fail("上报人员为空");
-            }
-        }
+//        if(commonEventAddDTO.getEventType().equals(6)){
+//            if(commonEventAddDTO.getPopulationIds() == null || commonEventAddDTO.getPopulationIds().size() <= 0){
+//                return R.fail("上报人员为空");
+//            }
+//        }
 
         eventDO.setEventCategory(1l);//办件事件
         eventDO.setEventStatus(2);//事件状态 2发布
@@ -315,19 +320,20 @@
         eventDO.setOrderSn(getEventOrderSn(eventDO.getEventType()));
 
         if (eventMapper.insert(eventDO) == 1) {
-
             //如果是特殊人群,则新增特殊人群与事件关系
             if(commonEventAddDTO.getEventType().equals(6)){
-                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(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);
+                }
             }
 
             //添加音频
@@ -1921,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);
     }
 
     /**
@@ -2262,6 +2286,7 @@
         return false;
     }
 
+    @Override
     public R eventWork(Long communityId){
         EventWorkScreenVO workScreenVO = new EventWorkScreenVO();
         String date = DateUtils.getDateFormatString(new Date(),moth_format_str);
@@ -2341,4 +2366,212 @@
         }
         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));
+    }
 }

--
Gitblit v1.7.1