瀏覽代碼

优化逻辑:对查询增加非空判断. 对事件流转时状态进行判定, 非指定状态不可流转

Memory_LG 2 月之前
父節點
當前提交
a94072f95c

+ 3 - 3
src/main/java/com/sooka/sponest/event/eventProcess/controller/EventProcessController.java

@@ -205,9 +205,9 @@ public class EventProcessController extends BaseController {
      *
      * @param eventInfo --> id=事件信息主键; deptIdList=部门id集合(仅签收时传递);
      */
-    @PostMapping("/gangedDeptList")
-    public AjaxResult gangedDeptList(@RequestBody EventInfo eventInfo) {
-        return eventProcessService.gangedDeptList(eventInfo);
+    @PostMapping("/cooperateDeptList")
+    public AjaxResult cooperateDeptList(@RequestBody EventInfo eventInfo) {
+        return eventProcessService.cooperateDeptList(eventInfo);
     }
 
     /**

+ 3 - 0
src/main/java/com/sooka/sponest/event/eventProcess/domain/EventInfo.java

@@ -148,4 +148,7 @@ public class EventInfo extends BaseBusinessEntity {
         this.setCreateTime(createTime);
     }
 
+    public EventInfo(String eventId) {
+        this.eventId = eventId;
+    }
 }

+ 1 - 1
src/main/java/com/sooka/sponest/event/eventProcess/service/EventProcessService.java

@@ -60,7 +60,7 @@ public interface EventProcessService {
 
     AjaxResult archive(EventInfo eventInfo);
 
-    AjaxResult gangedDeptList(EventInfo eventInfo);
+    AjaxResult cooperateDeptList(EventInfo eventInfo);
 
 
     void insertSensorEvent(SensorEventVo sensorEventVo);

+ 111 - 29
src/main/java/com/sooka/sponest/event/eventProcess/service/impl/EventProcessServiceImpl.java

@@ -10,7 +10,7 @@ import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.file.FilePrefixUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
-import com.ruoyi.common.redis.service.RedisService;
+import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.system.api.RemoteDeptService;
 import com.ruoyi.system.api.RemoteFileService;
 import com.ruoyi.system.api.domain.SysDept;
@@ -31,11 +31,11 @@ import com.sooka.sponest.event.eventProcess.service.EventProcessService;
 import com.sooka.sponest.event.eventType.domain.EventType;
 import com.sooka.sponest.event.eventType.service.EventTypeService;
 import com.sooka.sponest.event.utils.AddAttachPrefix;
-import com.sooka.sponest.event.utils.eventConstants.EventConstants;
 import com.sooka.sponest.event.utils.eventEnum.EventEnum;
 import com.sooka.sponest.monitor.api.RemoteMonitorService;
 import com.sooka.sponest.monitor.api.domain.CenterdataTAidevicedept;
 import com.sooka.sponest.monitor.api.domain.CenterdataTCamera;
+import org.apache.commons.collections4.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -77,18 +77,20 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
 
     /**
      * 事件中心 - 综合查询
+     *
      * @author limeng
-     * */
+     */
     @Override
     @DataScopeMutiDept(deptAlias = "d")
     public List<EventInfoBO> selectCompositeEventList(EventInfo eventInfo) {
         // 入参校验
-        if (eventInfo == null || eventInfo.getReportTimeStart() == null || eventInfo.getReportTimeEnd() == null ) return new ArrayList<>();
+        if (eventInfo == null || eventInfo.getReportTimeStart() == null || eventInfo.getReportTimeEnd() == null)
+            return new ArrayList<>();
         // 处理事件状态
         String eventStatus = Optional.ofNullable(eventInfo.getEventStatus()).orElseGet(() -> {
-                                eventInfo.setEventStatus(EVENT_STATUS_1);
-                                return EVENT_STATUS_1;
-                            });
+            eventInfo.setEventStatus(EVENT_STATUS_1);
+            return EVENT_STATUS_1;
+        });
         setSookaDataBase(eventInfo);
         if (eventStatus.equals(EVENT_STATUS_1)) { // 上报
             return eventProcessMapper.selectUnConfirmedList(eventInfo);
@@ -127,7 +129,7 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
 
                 // 构建事件对象
                 EventUnconfirmed eventUnconfirmed = new EventUnconfirmed(
-                        daHuaOtherEventVO.getEventId(), eventType.getId(),  centerdataTCamera.getCameraName() + DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS,
+                        daHuaOtherEventVO.getEventId(), eventType.getId(), centerdataTCamera.getCameraName() + DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS,
                         DateUtils.timestampToTime(daHuaOtherEventVO.getOccurrenceTime())) + daHuaOtherEventVO.getAlarmName(), daHuaOtherEventVO.toString(),
                         REPORTING_SOURCE_1, daHuaOtherEventVO.getLongitude(), daHuaOtherEventVO.getLatitude(), centerdataTCamera.getCameraName(), DateUtils.timestampToTime(daHuaOtherEventVO.getOccurrenceTime()),
                         centerdataTCamera.getCameraCode(), EVENT_STATUS_1, daHuaOtherEventVO.getAddress(), IS_URGE_0, daHuaOtherEventVO.getChannelSn(), DateUtils.timestampToTime(daHuaOtherEventVO.getOccurrenceTime()));
@@ -192,7 +194,7 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 eventDeptService.insertEventDept(daHuaFireEventVO.getEventId(), listDept);
 
                 // 插入事件日志
-                String logId = eventLogService.insertEventLog( daHuaFireEventVO.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_1, EVENT_LOG_SOURCE_1, messageInfo.getChannelSn(), reportTime);
+                String logId = eventLogService.insertEventLog(daHuaFireEventVO.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_1, EVENT_LOG_SOURCE_1, messageInfo.getChannelSn(), reportTime);
 
                 // 插入事件图片(待确认附件表)
                 eventAttachService.batchInsertEventAttachUnconfirmed(logId, daHuaFireEventVO.getEventId(), Arrays.asList(messageInfo.getPicture().split(",")), EVENT_LOG_FILE_SOURCE_1, DH_1);
@@ -222,7 +224,7 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
         eventDeptService.insertEventDept(sensorEventVo.getEventId(), listDept);
 
         // 插入事件日志
-        String logId = eventLogService.insertEventLog( sensorEventVo.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_1, EVENT_LOG_SOURCE_4, sensorEventVo.getSensorId(), sensorEventVo.getReportTime());
+        String logId = eventLogService.insertEventLog(sensorEventVo.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_1, EVENT_LOG_SOURCE_4, sensorEventVo.getSensorId(), sensorEventVo.getReportTime());
 
         // 插入事件图片(待确认附件表)
         eventAttachService.batchInsertEventAttachUnconfirmed(logId, sensorEventVo.getEventId(), Arrays.asList(sensorEventVo.getPicture().split(",")), EVENT_LOG_FILE_SOURCE_4, FILE_URL);
@@ -250,18 +252,17 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
 
 
         List<CenterdataTAidevicedept> listDept = new ArrayList<>();
-        deptList.forEach(dept->{
+        deptList.forEach(dept -> {
             listDept.add(new CenterdataTAidevicedept(dept.getDeptId(), dept.getDeptName()));
         });
         // 插入事件指挥中心
         eventDeptService.insertEventDept(sensorEventVo.getEventId(), listDept);
 
         // 插入事件日志
-        eventLogService.insertEventLog( sensorEventVo.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_6, EVENT_LOG_SOURCE_5, sensorEventVo.getReportor(), sensorEventVo.getReportTime());
+        eventLogService.insertEventLog(sensorEventVo.getEventId(), eventUnconfirmed.getEventName() + System.getProperty("line.separator") + eventUnconfirmed.getEventDescription(), EVENT_LOG_TYPE_6, EVENT_LOG_SOURCE_5, sensorEventVo.getReportor(), sensorEventVo.getReportTime());
     }
 
 
-
     @Override
     @DataScopeMutiDept(deptAlias = "d")
     public List<EventInfoBO> selectUnConfirmedList(EventInfo eventInfo) {
@@ -326,8 +327,17 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 sysUser.setDeptNames("四平市");
                 sysUser.setNickName("测试用户");
 
+                //查询事件
+                List<EventInfoBO> unconfirmedEventList = eventProcessMapper.selectUnConfirmedList(eventInfo);
+                if (unconfirmedEventList.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
                 //获取事件详情
-                EventInfoBO unconfirmedEventDetail = eventProcessMapper.selectUnConfirmedList(eventInfo).get(0);
+                EventInfoBO unconfirmedEventDetail = unconfirmedEventList.get(0);
+                if (!EVENT_STATUS_1.equals(unconfirmedEventDetail.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), unconfirmedEventDetail.getEventStatus()));
+                }
 
                 // 验证是否配置摄像头通道
                 CenterdataTCamera centerdataTCamera = SpringUtils.getBean(RemoteMonitorService.class).getInfoByChannelCode(unconfirmedEventDetail.getCameraCode()).getData();
@@ -386,6 +396,27 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 sysUser.setDeptNames("四平市");
                 sysUser.setNickName("测试用户");
 
+
+                // 根据事件 ID 查询事件未确认列表
+                List<EventInfoBO> eventInfoBOS = eventProcessMapper.selectUnConfirmedList(new EventInfo(eventInfo.getEventId()));
+
+                // 如果事件未确认列表为空,则查询事件确认列表
+                if (eventInfoBOS.isEmpty()) {
+                    eventInfoBOS = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+                }
+
+                // 如果最终的事件列表仍然为空,说明事件不存在,直接返回错误结果
+                if (eventInfoBOS.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
+                //获取事件详情
+                EventInfoBO eventInfoBO = eventInfoBOS.get(0);
+                if (!EVENT_STATUS_1.equals(eventInfoBO.getEventStatus()) && !EVENT_STATUS_2.equals(eventInfoBO.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus()));
+                }
+
+
                 //日志消息体
                 StringBuilder content = new StringBuilder();
                 //日志状态
@@ -402,9 +433,6 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                     content.append("操作错误");
                 }
 
-                //获取事件详情
-                EventInfoBO eventInfoBO = eventProcessMapper.selectUnConfirmedList(eventInfo).get(0);
-
                 //下载附件到本地
                 moveAttach(eventInfoBO.getAttachList(), eventInfo.getEventId());
 
@@ -439,18 +467,30 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
         if (lock.tryLock()) { //获取锁
             try {
                 //业务代码
-//                SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
-                SysUser sysUser = new SysUser();
-                sysUser.setUserId(1000L);
-                sysUser.setDeptId(365L);
-                sysUser.setDeptNames("四平市");
-                sysUser.setNickName("测试用户");
+                SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
+//                SysUser sysUser = new SysUser();
+//                sysUser.setUserId(1000L);
+//                sysUser.setDeptId(365L);
+//                sysUser.setDeptNames("四平市");
+//                sysUser.setNickName("测试用户");
+
+                List<EventInfoBO> eventInfoBOList = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+                if (eventInfoBOList.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
+                //获取事件详情
+                EventInfoBO eventInfoBO = eventInfoBOList.get(0);
+                //判断状态, 非确认状态事件, 不可签收
+                if (!EVENT_STATUS_2.equals(eventInfoBO.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus()));
+                }
 
                 // 插入事件日志
                 eventLogService.insertEventLog(eventInfo.getEventId(), sysUser.getDeptNames() + sysUser.getNickName() + "签收该事件", EVENT_LOG_TYPE_3, EVENT_LOG_SOURCE_99, String.valueOf(sysUser.getUserId()), DateUtils.getNowDate());
 
                 //签收时, 选择联动部门
-                gangedDeptList(eventInfo);
+                cooperateDeptList(eventInfo);
 
                 //更新主表状态
                 eventInfo.setEventStatus(EVENT_STATUS_3);
@@ -484,6 +524,17 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 sysUser.setDeptNames("四平市");
                 sysUser.setNickName("测试用户");
 
+                List<EventInfoBO> eventInfoBOList = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+                if (eventInfoBOList.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
+                EventInfoBO eventInfoBO = eventInfoBOList.get(0);
+                //非签收状态, 不可办结
+                if (!EVENT_STATUS_3.equals(eventInfoBO.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus()));
+                }
+
                 // 插入事件日志
                 eventLogService.insertEventLog(eventInfo.getEventId(), sysUser.getDeptNames() + sysUser.getNickName() + "办结该事件", EVENT_LOG_TYPE_4, EVENT_LOG_SOURCE_99, String.valueOf(sysUser.getUserId()), DateUtils.getNowDate());
 
@@ -519,11 +570,22 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 sysUser.setDeptNames("四平市");
                 sysUser.setNickName("测试用户");
 
+                List<EventInfoBO> eventInfoBOList = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+                if (eventInfoBOList.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
+                EventInfoBO eventInfoBO = eventInfoBOList.get(0);
+                //非办结状态不可审核
+                if (!EVENT_STATUS_4.equals(eventInfoBO.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus()));
+                }
+
                 // 插入事件日志
                 eventLogService.insertEventLog(eventInfo.getEventId(), sysUser.getDeptNames() + sysUser.getNickName() + "审核结果:" + eventInfo.getEventDescription(), EVENT_LOG_TYPE_5, EVENT_LOG_SOURCE_99, String.valueOf(sysUser.getUserId()), DateUtils.getNowDate());
 
                 //更新主表状态
-                if(StringUtils.isBlank(eventInfo.getEventStatus())){
+                if (StringUtils.isBlank(eventInfo.getEventStatus())) {
                     eventInfo.setEventStatus(EVENT_STATUS_5);
                 }
                 eventProcessMapper.updateEventProcess(eventInfo);
@@ -556,6 +618,17 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
                 sysUser.setDeptNames("四平市");
                 sysUser.setNickName("测试用户");
 
+                List<EventInfoBO> eventInfoBOList = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+                if (eventInfoBOList.isEmpty()) {
+                    return AjaxResult.error("获取事件不存在!");
+                }
+
+                EventInfoBO eventInfoBO = eventInfoBOList.get(0);
+                //非审核通过状态不可归档
+                if (!EVENT_STATUS_5.equals(eventInfoBO.getEventStatus())) {
+                    return AjaxResult.error("事件已被流转, 当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus()));
+                }
+
                 // 插入事件日志
                 eventLogService.insertEventLog(eventInfo.getEventId(), sysUser.getDeptNames() + sysUser.getNickName() + "归档该事件", EVENT_LOG_TYPE_6, EVENT_LOG_SOURCE_99, String.valueOf(sysUser.getUserId()), DateUtils.getNowDate());
 
@@ -579,7 +652,7 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
      * 协同处理事件部门
      */
     @Override
-    public AjaxResult gangedDeptList(EventInfo eventInfo) {
+    public AjaxResult cooperateDeptList(EventInfo eventInfo) {
         if (!eventInfo.getDeptIdList().isEmpty()) {
             //                SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
             SysUser sysUser = new SysUser();
@@ -588,6 +661,16 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
             sysUser.setDeptNames("四平市");
             sysUser.setNickName("测试用户");
 
+            List<EventInfoBO> eventInfoBOList = eventProcessMapper.selectEventProcessList(new EventInfo(eventInfo.getEventId()));
+            if (eventInfoBOList.isEmpty()) {
+                return AjaxResult.error("获取事件不存在!");
+            }
+
+            EventInfoBO eventInfoBO = eventInfoBOList.get(0);
+            if(!EVENT_STATUS_3.equals(eventInfoBO.getEventStatus())){
+                return AjaxResult.error("事件当前状态: " + MapUtils.getString(getEventStatusMap(), eventInfoBO.getEventStatus())+"不可设置协同部门");
+            }
+
             eventLogService.insertEventLog(eventInfo.getEventId(), sysUser.getDeptNames() + sysUser.getNickName() + "添加协同部门", EVENT_LOG_TYPE_100, EVENT_LOG_SOURCE_99, String.valueOf(sysUser.getUserId()), DateUtils.getNowDate());
 
             List<CenterdataTAidevicedept> listDept = new ArrayList<>();
@@ -632,10 +715,10 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
         boolean flag = true;
 
         for (EventAttach attach : attachList) {
-            if(FILE_URL.equals(attach.getSourceType())){
+            if (FILE_URL.equals(attach.getSourceType())) {
                 newPathList.add(attach.getPath());
                 ids.add(attach.getId());
-            }else{
+            } else {
                 MultipartFile multipartFile = FilePrefixUtils.urlToMultipartFile(attach.getPath(), System.currentTimeMillis() + ".jpg");
                 if (null != multipartFile) {
                     R<SysFile> upload = fileService.upload(multipartFile);
@@ -657,6 +740,5 @@ public class EventProcessServiceImpl extends BaseServiceImpl implements EventPro
             eventAttachService.batchInsertEventAttachProcess(attachList.get(0).getLogId(), eventId, newPathList, EVENT_LOG_FILE_SOURCE_99, FILE_URL);
             eventAttachService.removeAttachByIds(ids);
         }
-
     }
 }

+ 23 - 8
src/main/java/com/sooka/sponest/event/utils/eventConstants/EventConstants.java

@@ -1,10 +1,13 @@
 package com.sooka.sponest.event.utils.eventConstants;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class EventConstants {
 
     /**
      * 事件状态
-     * */
+     */
     public static final String EVENT_STATUS_1 = "event_status_1";// 上报
 
     public static final String EVENT_STATUS_2 = "event_status_2";// 确认
@@ -21,9 +24,23 @@ public class EventConstants {
 
     public static final String EVENT_STATUS_99 = "event_status_99";// 重复
 
+    public static Map<String, String> getEventStatusMap() {
+        HashMap<String, String> eventStatusMap = new HashMap<>();
+        eventStatusMap.put(EVENT_STATUS_1, "上报");
+        eventStatusMap.put(EVENT_STATUS_2, "确认");
+        eventStatusMap.put(EVENT_STATUS_3, "签收");
+        eventStatusMap.put(EVENT_STATUS_4, "办结");
+        eventStatusMap.put(EVENT_STATUS_5, "审核通过");
+        eventStatusMap.put(EVENT_STATUS_6, "归档");
+        eventStatusMap.put(EVENT_STATUS_98, "误报");
+        eventStatusMap.put(EVENT_STATUS_99, "重复");
+        return eventStatusMap;
+    }
+
+
     /**
      * 事件来源
-     * */
+     */
     public static final String REPORTING_SOURCE_1 = "reporting_source_1";// AI
 
     public static final String REPORTING_SOURCE_2 = "reporting_source_2";// PC
@@ -36,14 +53,14 @@ public class EventConstants {
 
     /**
      * 是否催办
-     * */
+     */
     public static final String IS_URGE_0 = "is_urge_0";// 否
 
     public static final String IS_URGE_1 = "is_urge_1";// 是
 
     /**
      * 事件日志操作类型
-     * */
+     */
     public static final String EVENT_LOG_TYPE_1 = "event_log_type_1";// 上报
 
     public static final String EVENT_LOG_TYPE_2 = "event_log_type_2";// 确认
@@ -65,7 +82,7 @@ public class EventConstants {
 
     /**
      * 事件日志操作来源
-     * */
+     */
     public static final String EVENT_LOG_SOURCE_1 = "event_log_source_1";// AI
 
     public static final String EVENT_LOG_SOURCE_2 = "event_log_source_2";// PC
@@ -81,7 +98,7 @@ public class EventConstants {
 
     /**
      * 事件日志附件来源
-     * */
+     */
     public static final String EVENT_LOG_FILE_SOURCE_1 = "event_log_file_source_1";// AI
 
     public static final String EVENT_LOG_FILE_SOURCE_2 = "event_log_file_source_2";// PC
@@ -100,8 +117,6 @@ public class EventConstants {
 
     /**
      * 附件来源类型(不同类型获取的图片访问地址不同)
-     *
-     *
      */
     public static final String DH_1 = "DH_1"; //大华火险事件
     public static final String DH_2 = "DH_2"; //大华其他事件