From 8d5fb4ee9d27fd6a61b210eaee74af265f76aa7c Mon Sep 17 00:00:00 2001 From: manailin <261030956@qq.com> Date: 星期五, 08 四月 2022 14:55:18 +0800 Subject: [PATCH] [修改]修改配置 --- springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java | 254 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 228 insertions(+), 26 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 c3920a7..e7d55dd 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; @@ -166,11 +171,9 @@ */ @Override public R<EventDetailsVO> eventDetails(Long id) { - EventDO eventDO = eventMapper.selectById(id); - if (eventDO != null) { - EventDetailsVO eventDetailsVO = new EventDetailsVO(); - BeanUtils.copyProperties(eventDO, eventDetailsVO); - EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(eventDO.getGridId()); + EventDetailsVO eventDetailsVO = eventMapper.getById(id); + if (eventDetailsVO != null) { + EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(eventDetailsVO.getGridId()); if (eventGridDataDO != null) { eventDetailsVO.setGridName(eventGridDataDO.getGridName()); eventDetailsVO.setCommunityId(eventGridDataDO.getGridCommunityId()); @@ -248,17 +251,17 @@ eventDetailsVO.setTrans(eventTransferRecordVOS); // 查询网格员头像,姓名 - Map<String, Object> gridMember = eventMapper.getUserBaseInfo(eventDO.getGridMemberId()); + Map<String, Object> gridMember = eventMapper.getUserBaseInfo(eventDetailsVO.getGridMemberId()); if (!CollectionUtils.isEmpty(gridMember)) { 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())) { + if (Objects.equals(eventDetailsVO.getGridMemberId(), eventDetailsVO.getCreateBy())) { eventDetailsVO.setCreator(eventDetailsVO.getGridMemberName()); } else { - Map<String, Object> createUser = eventMapper.getUserBaseInfo(eventDO.getCreateBy()); + Map<String, Object> createUser = eventMapper.getUserBaseInfo(eventDetailsVO.getCreateBy()); eventDetailsVO .setCreator(createUser.get("nick_name") == null ? "" : createUser.get("nick_name").toString()); } @@ -317,7 +320,9 @@ if (eventMapper.insert(eventDO) == 1) { // 如果是特殊人群,则新增特殊人群与事件关系 - if (commonEventAddDTO.getEventType().equals(6)) { + if (commonEventAddDTO.getEventType().equals(6) + && commonEventAddDTO.getPopulationIds() != null + && commonEventAddDTO.getPopulationIds().size() > 0) { if (commonEventAddDTO.getPopulationIds() != null && commonEventAddDTO.getPopulationIds().size() > 0) { List<EventSpecialCrowdRecordDO> crowdRecordList = new ArrayList<>(); commonEventAddDTO.getPopulationIds().forEach(populationId -> { @@ -397,11 +402,11 @@ if (commonEventEditDTO.getId() == null) { // 检查特殊人群上报时参数 - if (commonEventEditDTO.getEventType().equals(6)) { - if (commonEventEditDTO.getPopulationIds().isEmpty()) { - return R.fail("上报人员为空"); - } - } +// if (commonEventEditDTO.getEventType().equals(6)) { +// if (commonEventEditDTO.getPopulationIds().isEmpty()) { +// return R.fail("上报人员为空"); +// } +// } EventDO eventDO = new EventDO(); BeanUtils.copyProperties(commonEventEditDTO, eventDO); @@ -418,7 +423,8 @@ if (eventMapper.insert(eventDO) > 0) { // 如果是特殊人群,则新增特殊人群与事件关系 - if (commonEventEditDTO.getEventType().equals(6)) { + if (commonEventEditDTO.getEventType().equals(6) && commonEventEditDTO.getPopulationIds() != null + && commonEventEditDTO.getPopulationIds().size() > 0) { List<EventSpecialCrowdRecordDO> crowdRecordList = new ArrayList<>(); commonEventEditDTO.getPopulationIds().forEach(populationId -> { EventSpecialCrowdRecordDO specialCrowdRecordDO = new EventSpecialCrowdRecordDO(); @@ -1292,7 +1298,7 @@ @Override public R<ComActVO> actList() { - return communityService.listCommunityAll(); + return communityService.listCommunityAll(null); } @Override @@ -1373,10 +1379,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()); @@ -1396,11 +1403,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(), @@ -1816,11 +1825,7 @@ if (eventDO == null) { throw new ServiceException("id为" + id + "的事件不存在"); } - if (eventDO.getEventStatus() != null - && (eventDO.getEventStatus().intValue() == 1 || eventDO.getEventStatus().intValue() == 4)) {// 草稿 - // 或者 - // 已撤销 - // 的事件可以删除 + if (eventDO.getEventStatus() != null) { eventDO.setEventStatus(3);// 逻辑删除 eventDO.setUpdateBy(userId); int updated = this.getBaseMapper().updateById(eventDO); @@ -1945,8 +1950,8 @@ 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()); + result.setTodayNum(result.getTodayNum() + result.getZfTodayNum() + result.getSspTodayNum()); + result.setMonthNum(result.getMonthNum() + result.getZfMonthNum() + result.getSspMonthNum()); // 查询当前网格员下管理的楼栋名称 List<Map<String, Object>> buildNameList = this.baseMapper.getMemberBuildName(userId); @@ -2617,6 +2622,173 @@ 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); + } + } + }); + } + // 查询所有小区 + 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查询小区统计人数 * @@ -2642,4 +2814,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