huanghongfa
2021-06-07 bd3a56723062aad602636ee47c91fccf2b2868f6
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
@@ -11,10 +11,7 @@
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.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventResourceVO;
import com.panzhihua.common.model.vos.grid.EventTransferRecordVO;
import com.panzhihua.common.model.vos.grid.EventVO;
import com.panzhihua.common.model.vos.grid.*;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_grid.dao.*;
@@ -52,6 +49,8 @@
    private CommunityService communityService;
    @Resource
    private EventGridDataMapper eventGridDataMapper;
    @Resource
    private EventGridMemberRelationMapper eventGridMemberRelationMapper;
    /**
     * 分页查找事件
@@ -485,7 +484,8 @@
        if(updated!=1){
            throw new ServiceException("更新突发事件状态更新失败");
        }
        addTransferRecord(eventDO.getId(), commonEventReportDTO.getToId(), comActVO.getName(), 2, commonEventReportDTO.getProcessResult(),2);
        addTransferRecord(eventDO.getId(), commonEventReportDTO.getToId(), comActVO.getName(), 2, commonEventReportDTO.getProcessResult(),
                commonEventReportDTO.getUserId(), commonEventReportDTO.getUserName(), 2);
        return R.ok();
    }
@@ -556,7 +556,7 @@
            processType = 1;
        }
        EventTransferRecordDO transferRecordDO =
                addTransferRecord(eventDO.getId(), commonEventDealDTO.getUserId(), commonEventDealDTO.getUserName(),1, "网格员自处理完成", processType);
                addTransferRecord(eventDO.getId(), commonEventDealDTO.getUserId(), commonEventDealDTO.getUserName(),1, "网格员自处理完成",  commonEventDealDTO.getUserId(), commonEventDealDTO.getUserName(), processType);
        if(transferRecordDO!=null && transferRecordDO.getId()!=null){
            //添加音频
            if(StringUtils.isNotEmpty(commonEventDealDTO.getAudio())){
@@ -636,16 +636,17 @@
        if(updated!=1){
            return R.fail("更新事件状态失败");
        }
        addTransferRecord(eventDO.getId(), commonEventVerifyDTO.getUserId(), commonEventVerifyDTO.getUserName(), 1, commonEventVerifyDTO.getProcessResult(), 6);
        addTransferRecord(eventDO.getId(), commonEventVerifyDTO.getUserId(), commonEventVerifyDTO.getUserName(), 1, commonEventVerifyDTO.getProcessResult(),
                commonEventVerifyDTO.getUserId(), commonEventVerifyDTO.getUserName(), 6);
        return R.ok();
    }
    @Override
    public R republishEvent(CommonEventRepublishDTO commonEventRepublishDTO) {
        EventDO eventDO = this.getBaseMapper().selectById(commonEventRepublishDTO.getId());
        boolean canRepublishByUser = eventDO.getEventStatus()==4;
        boolean canRepublishByUser = eventDO.getEventStatus()==4||eventDO.getEventStatus()==1;
        if(!canRepublishByUser){
            return R.fail("当前不是撤销状态");
            return R.fail("当前不是撤销/草稿状态");
        }
        eventDO.setEventStatus(2);//2 发布
@@ -656,7 +657,8 @@
        if(updated!=1){
            return R.fail("更新事件状态失败");
        }
        addTransferRecord(eventDO.getId(), commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 1, "重新发布已撤销事件", 8);
        addTransferRecord(eventDO.getId(), commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 1,
                "重新发布已撤销事件", commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 8);
        return R.ok();
    }
@@ -1281,7 +1283,8 @@
        eventDO.setInvalid(true);
        int updated = this.getBaseMapper().updateById(eventDO);
        if(updated == 1){
            addTransferRecord(eventDO.getId(), commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 1,"重新发布事件成功", 9 );
            addTransferRecord(eventDO.getId(), commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 1,"重新发布事件成功",
                    commonEventRepublishDTO.getUserId(), commonEventRepublishDTO.getUserName(), 9 );
            return R.ok();
        }
        return R.fail();
@@ -1298,6 +1301,24 @@
            return R.fail("事件当前不是上报状态");
        }
        List<EventTransferRecordDO> list = eventTransferRecordService.getBaseMapper().selectList(new LambdaQueryWrapper<EventTransferRecordDO>()
                .eq(EventTransferRecordDO::getEventId, eventDO.getId())
                .orderByDesc(EventTransferRecordDO::getCreateAt)
        );
        Long reportToInDB = -1L;
        for (int i = 0; i < list.size(); i++) {
            EventTransferRecordDO eventTransferRecordDO = list.get(i);
            if(eventTransferRecordDO.getProcessType()!=null && eventTransferRecordDO.getProcessType()==2){
                reportToInDB = eventTransferRecordDO.getToId();
            }
        }
        if(commonEventDealDTO.getCommunityId()==null){
            return R.fail("当前用户社区获取失败");
        }
        if(reportToInDB.longValue() != commonEventDealDTO.getCommunityId().longValue()){
            return R.fail("用户上报的社区不是当前社区");
        }
        if(commonEventDealDTO.getNeedVerify()){
            eventDO.setEventProcessStatus(3);//待验证状态
            eventDO.setProcessType(1);//交给网格员处理-验证
@@ -1317,7 +1338,8 @@
            return R.fail("更新事件状态失败");
        }
        EventTransferRecordDO transferRecordDO =
                addTransferRecord(eventDO.getId(), commonEventDealDTO.getUserId(), commonEventDealDTO.getUserName(),1, "社区处理完成", 3);
                addTransferRecord(eventDO.getId(), commonEventDealDTO.getUserId(), commonEventDealDTO.getUserName(),1,
                        "社区处理完成", commonEventDealDTO.getCommunityId(), commonEventDealDTO.getCommunityName(), 3);
        if(transferRecordDO!=null && transferRecordDO.getId()!=null){
            //添加音频
            if(StringUtils.isNotEmpty(commonEventDealDTO.getAudio())){
@@ -1443,7 +1465,7 @@
        eventTransferRecordDO.setProcessDate(new Date());
        eventTransferRecordDO.setEventId(eventId);
        eventTransferRecordDO.setProcessResult("发布成功");
        eventTransferRecordDO.setProcessType(1);//初始状态
        eventTransferRecordDO.setProcessType(0);//初始状态
        int inserted = eventTransferRecordService.getBaseMapper().insert(eventTransferRecordDO);
        if(inserted!=1){
            throw new ServiceException("事件流转记录添加失败");
@@ -1503,9 +1525,9 @@
     * @param msg 流转消息
     * @return
     */
    private EventTransferRecordDO addTransferRecord(Long eventId, Long toId, String toName, Integer toType, String msg,Integer processType){
   /* private EventTransferRecordDO addTransferRecord(Long eventId, Long toId, String toName, Integer toType, String msg,Integer processType){
        return addTransferRecord(eventId, toId, toName, toType, msg, null, null, processType);
    }
    }*/
    /**
     * 根据子状态 查询用户事件处理状态
@@ -1578,4 +1600,71 @@
        }
        return -1;
    }
    /**
     * 后台管理-统计模块
     * @param communityId   社区id
     * @return  统计信息
     */
    @Override
    public R eventStatistics(Long communityId){
        return R.ok(this.baseMapper.eventStatistics(communityId));
    }
    /**
     * 后台管理-网格员统计
     * @param statisticsAdminDTO    请求参数
     * @return  网格员统计信息
     */
    @Override
    public R gridMemberStatistics(MemberStatisticsAdminDTO statisticsAdminDTO){
        return R.ok(eventGridMemberRelationMapper.gridMemberStatistics(new Page(statisticsAdminDTO.getPageNum(),statisticsAdminDTO.getPageSize()),statisticsAdminDTO));
    }
    /**
     * 根据网格id查询网格统计数据
     * @param gridId    网格id
     * @return  网格统计数据
     */
    @Override
    public R getGridEventStatisticsByApp(Long gridId){
        return R.ok(this.baseMapper.getGridEventStatisticsByApp(gridId));
    }
    /**
     * 查询网格事件统计数据
     * @param statisticsDTO 请求参数
     * @return  网格事件统计数据
     */
    @Override
    public R getGridEventDetailStatisticsByApp(GridEventStatisticsDTO statisticsDTO){
        GridEventStatisticsDetailVO statisticsDetailVO = this.baseMapper.getGridEventDetailStatisticsByApp(statisticsDTO);
        if(statisticsDetailVO == null){
            statisticsDetailVO = new GridEventStatisticsDetailVO();
        }
        if(statisticsDetailVO.getEventSSPTotal() == null){
            statisticsDetailVO.setEventSSPTotal(0);
        }
        if(statisticsDetailVO.getNoEventSSPTotal() == null){
            statisticsDetailVO.setNoEventSSPTotal(0);
        }
        if(statisticsDetailVO.getEventZFTotal() == null){
            statisticsDetailVO.setEventZFTotal(0);
        }
        if(statisticsDetailVO.getNoEventZFTotal() == null){
            statisticsDetailVO.setNoEventZFTotal(0);
        }
        //统计数据
        Integer sum = statisticsDetailVO.getEventTFTotal() + statisticsDetailVO.getEventMDTotal() + statisticsDetailVO.getEventZATotal()
                + statisticsDetailVO.getEventBWDTotal() + statisticsDetailVO.getEventTSTotal() + statisticsDetailVO.getEventGGTotal()
                + statisticsDetailVO.getEventXCTotal() + statisticsDetailVO.getEventSSPTotal() + statisticsDetailVO.getEventZFTotal();
        statisticsDetailVO.setSum(sum);
        Integer noSum = statisticsDetailVO.getNoEventTFTotal() + statisticsDetailVO.getNoEventMDTotal() + statisticsDetailVO.getNoEventZATotal()
                + statisticsDetailVO.getNoEventBWDTotal() + statisticsDetailVO.getNoEventTSTotal() + statisticsDetailVO.getNoEventGGTotal()
                + statisticsDetailVO.getNoEventSSPTotal() + statisticsDetailVO.getNoEventZFTotal();
        statisticsDetailVO.setNoSum(noSum);
        return R.ok(statisticsDetailVO);
    }
}