| | |
| | | package com.panzhihua.service_grid.service.impl; |
| | | |
| | | 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; |
| | | 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.ScreenEventListDTO; |
| | | import com.panzhihua.common.model.dtos.grid.*; |
| | | import com.panzhihua.common.model.helper.AESUtil; |
| | | import com.panzhihua.common.model.vos.R; |
| | | 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.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.ExcelSelectListUtil; |
| | | 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.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author cedoo |
| | |
| | | @Resource |
| | | private EventGridMemberRelationMapper eventGridMemberRelationMapper; |
| | | @Resource |
| | | private EventSpecialCrowdRecordService eventSpecialCrowdRecordService; |
| | | @Resource |
| | | private EventSpecialCrowdRecordMapper eventSpecialCrowdRecordMapper; |
| | | @Resource |
| | | private EventGridDataService eventGridDataService; |
| | | @Resource |
| | | private EventResourceMapper eventResourceMapper; |
| | | |
| | | /** |
| | | * 分页查找事件 |
| | |
| | | EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(eventDO.getGridId()); |
| | | if (eventGridDataDO != null) { |
| | | eventDetailsVO.setGridName(eventGridDataDO.getGridName()); |
| | | eventDetailsVO.setCommunityId(eventGridDataDO.getGridCommunityId()); |
| | | } |
| | | |
| | | //查询事件关联附件 |
| | |
| | | } |
| | | eventDetailsVO.setTrans(eventTransferRecordVOS); |
| | | |
| | | //查询事件发布人头像 |
| | | String imageUrl = eventMapper.getGridMemberImageUrl(eventDO.getGridMemberId()); |
| | | if (StringUtils.isNotEmpty(imageUrl)) { |
| | | eventDetailsVO.setGridMemberImageUrl(imageUrl); |
| | | //查询网格员头像,姓名 |
| | | Map<String,Object> gridMember = eventMapper.getUserBaseInfo(eventDO.getGridMemberId()); |
| | | if (!CollectionUtils.isEmpty(gridMember)) { |
| | | eventDetailsVO.setGridMemberName(gridMember.get("name") == null ? "" : gridMember.get("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()); |
| | | } |
| | | |
| | | //当事件为特殊人群上报时,需要查询事件与人口关联关系 |
| | | 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); |
| | | } |
| | | return R.fail("事件不存在"); |
| | |
| | | if (eventGridDataDO == null) { |
| | | 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发布 |
| | | eventDO.setProcessType(1);//网格员处理 |
| | |
| | | eventDO.setSubmitDate(new Date()); |
| | | 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 (StringUtils.isNotEmpty(commonEventAddDTO.getAudio())) { |
| | | EventResourceDO eventResourceDO = new EventResourceDO(); |
| | |
| | | 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()); |
| | |
| | | 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(); |
| | |
| | | |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 事件大屏查询事件列表 |
| | | * @param eventListDTO 请求参数 |
| | | * @return 事件列表 |
| | | */ |
| | | @Override |
| | | 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 -> { |
| | | 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; |
| | | } |
| | | } |