From 2ca2e51f3a838252ed9cd8989f4f5d6fe35d468c Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期三, 30 六月 2021 18:02:00 +0800
Subject: [PATCH] Merge branch 'test' into 'master'
---
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java | 201 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 193 insertions(+), 8 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 626bc8f..87a87c6 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,7 +1,11 @@
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;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,7 +19,10 @@
import com.panzhihua.common.model.vos.community.ComActVO;
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.ExcelSelectListUtil;
import com.panzhihua.common.utlis.LngLatUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_grid.dao.*;
@@ -56,6 +63,14 @@
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[]{"一","二","三","四","五","六","七","八","九","十","十一","十二"};
/**
* 分页查找事件
@@ -155,6 +170,7 @@
EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(eventDO.getGridId());
if (eventGridDataDO != null) {
eventDetailsVO.setGridName(eventGridDataDO.getGridName());
+ eventDetailsVO.setCommunityId(eventGridDataDO.getGridCommunityId());
}
//查询事件关联附件
@@ -251,6 +267,11 @@
//当事件为特殊人群上报时,需要查询事件与人口关联关系
if(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);
@@ -276,7 +297,7 @@
//检查特殊人群上报时参数
if(commonEventAddDTO.getEventType().equals(6)){
- if(commonEventAddDTO.getPopulationIds().isEmpty()){
+ if(commonEventAddDTO.getPopulationIds() == null || commonEventAddDTO.getPopulationIds().size() <= 0){
return R.fail("上报人员为空");
}
}
@@ -1716,7 +1737,10 @@
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})?)$")){
+// 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(",");
@@ -2116,11 +2140,51 @@
* @return 事件列表
*/
@Override
- public R getScreenEventList(ScreenEventListDTO eventListDTO){
- if( eventListDTO.getEventType() != null && eventListDTO.getEventType().equals(ScreenEventListDTO.eventType.xc)){
- eventListDTO.setEventCategory(2);
+ 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);
+ 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);
}
@@ -2130,8 +2194,129 @@
* @return 社区人口数据列表
*/
@Override
- public R specialPopulationList(PageEventSpecialPopulationDTO specialPopulationDTO){
- IPage<EventSpecialPopulationVO> specialPopulationVOIPage = this.baseMapper.specialPopulationList(new Page(specialPopulationDTO.getPageNum(),specialPopulationDTO.getPageSize()),specialPopulationDTO);
+ 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 -> {
+ specialPopulation.setAge(IdcardUtil.getAgeByIdCard(specialPopulation.getIdCard()));
+ });
+ }
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());
+ });
+ return eventDetailsVOList;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Boolean updateLcUploadFlag(Long id) {
+ EventDO event = baseMapper.selectById(id);
+ event.setUpload(true);
+ baseMapper.updateById(event);
+ EventResourceDO eventResourceDO =new EventResourceDO();
+ eventResourceDO.setUpload(true);
+ int flag = eventResourceMapper.update(eventResourceDO, new QueryWrapper<EventResourceDO>()
+ .eq("ref_id", id));
+ if(flag>0){
+ return true;
+ }
+ return false;
+ }
+
+ 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("currentNum")== null ? 0L : Long.valueOf(countMap.get("currentNum").toString()));
+ }
+
+ //计算处理时间消耗的时间
+ 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.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);
+ 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:58");
+ dateList.add(eventWorkVO);
+ EventWorkVO eventWorkVO1 = new EventWorkVO();
+ eventWorkVO1.setMonth(monthStr[m]+"月下旬");
+ eventWorkVO1.setStart(month+ "-"+half+" 23:59:58");
+ eventWorkVO1.setEnd(DateUtils.getDateFormatString(endDay,"yyyy-MM-dd HH:mm:ss"));
+ dateList.add(eventWorkVO1);
+ }
+ return dateList;
+
+ }
+
+ public static void main(String[] args) {
+ String content = "30,104";
+ String re = "[1-9][0-9](\\.[0-9]{1,6})?,[1-9][0-9]{2}(\\.[0-9]{1,6})?";
+
+ System.out.println(content.matches(re));
+ }
+
}
--
Gitblit v1.7.1