瀏覽代碼

功能优化:下载已确认事件发生前后视频

lyq 10 月之前
父節點
當前提交
3743b98d0f

+ 9 - 4
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/controller/CentereventTDownloadsController.java

@@ -1,5 +1,6 @@
 package com.sooka.sponest.event.centereventteventcatalogue.controller;
 
+import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.SpringUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
@@ -14,6 +15,7 @@ import com.sooka.sponest.event.centereventteventcatalogue.domain.CentereventTDow
 import com.sooka.sponest.event.centereventteventcatalogue.service.ICentereventTDownloadsService;
 import com.sooka.sponest.event.centereventteventcatalogue.service.ICentereventTEventcatalogueService;
 import com.sooka.sponest.event.utils.EventConstants;
+import com.sooka.sponest.monitor.api.RemoteMonitorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -37,6 +39,9 @@ public class CentereventTDownloadsController extends BaseController {
     @Autowired
     private ICentereventTEventcatalogueService centereventTEventcatalogueService;
 
+    @Autowired
+    private RemoteMonitorService remoteMonitorService;
+
 //    @Autowired
 //    private RemoteMessageService remoteMessageService;
 //
@@ -81,9 +86,9 @@ public class CentereventTDownloadsController extends BaseController {
     }
 
     @PostMapping("/downloadsMonth")
-    public AjaxResult downloadsMonth(@RequestBody Map<String, Object> params) throws Exception {
-        centereventTEventcatalogueService.downloadsCommon(params);
-        return AjaxResult.success();
+    public R downloadsMonth(@RequestBody Map<String, Object> params) {
+        List<Map<String, Object>> list = centereventTEventcatalogueService.downloadsCommon(params);
+        return remoteMonitorService.getPlaybackByTime(list);
     }
 
     /**
@@ -120,7 +125,7 @@ public class CentereventTDownloadsController extends BaseController {
     /**
      * 修改【请填写功能名称】
      */
-    @RequiresPermissions("event:downloads:edit")
+//    @RequiresPermissions("event:downloads:edit")
     @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody CentereventTDownloads centereventTDownloads) {

+ 10 - 4
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/controller/CentereventTEventcatalogueController.java

@@ -361,6 +361,9 @@ public class CentereventTEventcatalogueController extends BaseController {
         return AjaxResult.success();
     }
 
+    @Autowired
+    private RemoteMonitorService remoteMonitorService;
+
     /**
      * 事件视频下载
      *
@@ -369,16 +372,19 @@ public class CentereventTEventcatalogueController extends BaseController {
      */
     @Log(title = "事件视频下载", businessType = BusinessType.OTHER)
     @GetMapping("/eventhandleDownload/{id}")
-    public AjaxResult eventhandleDownload(@PathVariable("id") String id) {
-        //校验 已下载不让重复下载
+    public R eventhandleDownload(@PathVariable("id") String id) {
+        // 校验 已下载不让重复下载
         CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
         centereventTDownloads.setEventCode(id);
         centereventTDownloads.setFlag("1");
         List<CentereventTDownloads> downloadsList = centereventTDownloadsService.selectCentereventTDownloadsList(centereventTDownloads);
         if (StringUtils.isNotEmpty(downloadsList)) {
-            return AjaxResult.error("已下载的视频,不能重复下载!");
+            return R.fail("已下载的视频,不能重复下载!");
         } else {
-            return AjaxResult.success(centereventTEventcatalogueService.eventhandleDownload(id));
+            Map<String, Object> params = new HashMap<>();
+            params.put("id", id);
+            List<Map<String, Object>> list = centereventTEventcatalogueService.downloadsCommon(params);
+            return remoteMonitorService.getPlaybackByTime(list);
         }
     }
 }

+ 1 - 4
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/service/ICentereventTEventcatalogueService.java

@@ -1,6 +1,5 @@
 package com.sooka.sponest.event.centereventteventcatalogue.service;
 
-import com.ruoyi.common.core.domain.R;
 import com.sooka.sponest.event.centereventteventcatalogue.domain.CentereventTEventcatalogue;
 import com.sooka.sponest.event.centereventteventcatalogue.domain.bo.CentereventtDeptEventBO;
 import com.sooka.sponest.event.urge.domain.EventReminder;
@@ -82,9 +81,7 @@ public interface ICentereventTEventcatalogueService {
 
     void reportFirePreventionOffice(CentereventtDeptEventBO centereventtDeptEventBO);
 
-    R eventhandleDownload(String id);
-
     CentereventTEventcatalogue mqtest(String start, String end, int limit);
 
-    void downloadsCommon(Map<String, Object> params) throws InterruptedException;
+    List<Map<String, Object>> downloadsCommon(Map<String, Object> params);
 }

+ 17 - 100
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/service/impl/CentereventTEventcatalogueServiceImpl.java

@@ -1,6 +1,5 @@
 package com.sooka.sponest.event.centereventteventcatalogue.service.impl;
 
-import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.SpringUtils;
 import com.ruoyi.common.core.utils.StringUtils;
@@ -37,14 +36,12 @@ import com.sooka.sponest.event.centereventtregionalflag.domain.RegionalFlag;
 import com.sooka.sponest.event.centereventtregionalflag.mapper.CentereventTRegionalFlagMapper;
 import com.sooka.sponest.event.remoteapi.RemoteDataService;
 import com.sooka.sponest.event.remoteapi.domain.CenterdataTAttach;
-import com.sooka.sponest.event.urge.domain.EventDown;
 import com.sooka.sponest.event.urge.domain.EventReminder;
 import com.sooka.sponest.event.urge.domain.EventUrge;
 import com.sooka.sponest.event.urge.service.EventDownService;
 import com.sooka.sponest.event.urge.service.EventUrgeService;
 import com.sooka.sponest.event.utils.EventProducerUtil;
 import com.sooka.sponest.event.utils.RemoteApiUtil;
-import com.sooka.sponest.monitor.api.RemoteMonitorService;
 import com.sooka.sponest.monitor.api.domain.CenterdataTAidevicedept;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -78,8 +75,6 @@ public class CentereventTEventcatalogueServiceImpl extends BaseService implement
     @Autowired
     private RemoteDataService remoteDataService;
     @Autowired
-    private RemoteMonitorService remoteMonitorService;
-    @Autowired
     private ICentereventDeptEventService centereventDeptEventService;
     @Autowired
     private ICentereventTEventtypemapdeptService centereventTEventtypemapdeptService;
@@ -639,110 +634,32 @@ public class CentereventTEventcatalogueServiceImpl extends BaseService implement
     }
 
     @Override
-    public R eventhandleDownload(String id) {
-        CentereventTEventcatalogue eventcatalogue = centereventTEventcatalogueMapper.selectCentereventTEventcatalogueById(id);
-        String busIndex = "bus_indx_other";// 其他
-        if ("1".equals(eventcatalogue.getEventType())) {
-            busIndex = BUS_INDEX_1;// 火情
-        }
-        String uuid = IdUtils.simpleUUID();
-        R result = remoteMonitorService.getPlaybackByTime(uuid, busIndex, eventcatalogue.getCreateBy(),
-                DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), -2)),
-                DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), 1)));
-        if (200 == result.getCode()) {
-            CentereventTFireLog centereventTFireLog = new CentereventTFireLog();
-            centereventTFireLog.setId(uuid);
-            centereventTFireLog.setEventCode(eventcatalogue.getEventCode());
-            centereventTFireLog.setLogContent(SecurityUtils.getLoginUser().getSysUser().getNickName() + "下载该事件视频。");
-            centereventTFireLog.setOperation(BUS_OPER_TYPE_1);
-            centereventTFireLog.setOperationType(LOG_OPER_TYPE_1);
-            centereventTFireLogService.insertCentereventTFireLog(centereventTFireLog);
-            CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
-            centereventTDownloads.setId(IdUtils.simpleUUID());
-            centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
-            centereventTDownloads.setEventName(eventcatalogue.getEventName());
-            centereventTDownloads.setLogId(uuid);
-            centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
-            Map<String, Object> maps = new HashMap<>();
-            maps.put("LogId", uuid);
-            applicationContext.publishEvent(new EventDown(eventDownService, maps));
-        } else {
-            //失败
-            CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
-            centereventTDownloads.setId(IdUtils.simpleUUID());
-            centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
-            centereventTDownloads.setEventName(eventcatalogue.getEventName());
-            centereventTDownloads.setFlag("0");
-            centereventTDownloads.setReason(result.getMsg());//失败原因
-            centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
-        }
-        return result;
-    }
-
-    @Override
     public CentereventTEventcatalogue mqtest(String start, String end, int limit) {
         return centereventTEventcatalogueMapper.mqtest(start, end, limit);
     }
 
     @Override
-    public void downloadsCommon(Map<String, Object> params) throws InterruptedException {
+    public List<Map<String, Object>> downloadsCommon(Map<String, Object> params) {
         List<CentereventTEventcatalogue> eventcatalogues = centereventTEventcatalogueMapper.getbeforedateDownload(params);
+        List<Map<String, Object>> param = new ArrayList<>();
         int i = 0;
         for (CentereventTEventcatalogue eventcatalogue : eventcatalogues) {
-            i++;
-            String busIndex = "bus_indx_other";// 其他
-            if ("1".equals(eventcatalogue.getEventType())) {
-                busIndex = BUS_INDEX_1;// 火情
-            }
             String uuid = IdUtils.simpleUUID();
-            R result = remoteMonitorService.getPlaybackByTime(uuid, busIndex, eventcatalogue.getCreateBy(),
-                    DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), -2)),
-                    DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), 1)));
-            if (200 == result.getCode()) {
-                //成功
-                CentereventTFireLog centereventTFireLog = new CentereventTFireLog();
-                centereventTFireLog.setId(uuid);
-                centereventTFireLog.setEventCode(eventcatalogue.getEventCode());
-                centereventTFireLog.setLogContent("系统管理员下载该事件视频。");
-                centereventTFireLog.setOperation(BUS_OPER_TYPE_1);
-                centereventTFireLog.setOperationType(LOG_OPER_TYPE_1);
-                centereventTFireLog.setCreateName("系统管理员");
-                centereventTFireLogService.insertCentereventTFireLog(centereventTFireLog);
-                CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
-                centereventTDownloads.setId(IdUtils.simpleUUID());
-                centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
-                centereventTDownloads.setEventName(eventcatalogue.getEventName());
-                centereventTDownloads.setLogId(uuid);
-                centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
-//                TimeUnit.MINUTES.sleep(5);//延时5分钟在调取
-                logger.info("定时任务等待下载=====>{}", DateUtils.dateTimeNow());
-            } else {
-                //失败
-                CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
-                centereventTDownloads.setId(IdUtils.simpleUUID());
-                centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
-                centereventTDownloads.setEventName(eventcatalogue.getEventName());
-                centereventTDownloads.setFlag("0");
-                centereventTDownloads.setReason(result.getMsg());//失败原因
-                centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
-            }
-            if (i % 10 == 0) {
-                Thread.sleep(300000);
-            }
-        }
-        Thread.sleep(300000);
-        logger.info("附件表查询回写=====>{}", DateUtils.dateTimeNow());
-        //视频下载日志表 视频下载成功  定时任务结束回调,检验是否真的成功
-        List<CentereventTDownloads> downloadsList = centereventTDownloadsService.validDownloadIs();
-        for (CentereventTDownloads down : downloadsList) {
-            if (StringUtils.isNotEmpty(down.getAttachPath())) {
-                down.setFlag("1");
-                down.setPath(down.getAttachPath());
-            } else {
-                down.setFlag("0");
-                down.setReason("视频在下载过程中失败!");
-            }
-            centereventTDownloadsService.updateCentereventTDownloads(down);
+            CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
+            centereventTDownloads.setId(uuid);
+            centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
+            centereventTDownloads.setEventName(eventcatalogue.getEventName());
+            centereventTDownloads.setLogId(eventcatalogue.getId());
+            centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
+
+            Map<String, Object> map = new HashMap<>();
+            map.put("id", uuid);
+            map.put("logId", eventcatalogue.getId());
+            map.put("cameraId", eventcatalogue.getCreateBy());
+            map.put("startTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), -2)));
+            map.put("endTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), 1)));
+            param.add(map);
         }
+        return param;
     }
 }

+ 28 - 64
src/main/resources/mapper/centereventteventcatalogue/CentereventTEventcatalogueMapper.xml

@@ -303,76 +303,40 @@
         where a.create_time between #{start} and #{end}
         limit #{limit}, 1
     </select>
-    <select id="getbeforedateDownload" parameterType="map" resultMap="CentereventTEventcatalogueResult">
-
-        SELECT
-            a.id,
-            a.event_code,
-            a.event_type,
-            a.event_type_xl,
-            a.event_name,
-            a.event_description,
-            a.report_source,
-            a.longitude,
-            a.latitude,
-            a.reportor,
-            a.report_time,
-            a.is_urged,
-            a.event_status,
-            a.event_status_value,
-            a.create_by,
-            a.create_name,
-            a.create_time,
-            a.update_by,
-            a.update_name,
-            a.update_time,
-            a.data_status,
-            a.dept_id,
-            a.dept_name,
-            IFNULL( a.version, 0 ) version,
-            a.urge_count,
-            a.address,
-            a.escalation,
-            a.is_examine
-        FROM
-            centerevent_t_eventcatalogue a
-        WHERE
-             event_status_value NOT IN ( 'forest_event_status_3', 'forest_event_status_4' )
-             AND
-						report_source = 'reporting_source_1'
-            AND event_code IN (
-            SELECT
-                l.event_code
-            FROM
-                centerevent_t_fire_log l
-            WHERE
-                l.log_content LIKE '%确认该事件%'
 
-        <if test="taskValue != null and taskValue != ''">
-            AND DATEDIFF( l.create_time, now( ) ) = - 1
-        </if>
-        <if test="monthValueStart != null and monthValueStart != ''">
-            AND DATE_FORMAT(l.create_time,'%Y-%m-%d') &gt;= #{monthValueStart}
-        </if>
-        <if test="monthValueEnd != null and monthValueEnd != ''">
-            AND DATE_FORMAT(l.create_time,'%Y-%m-%d') &lt;= #{monthValueEnd}
-        </if>
-            AND l.event_code not IN  (
-            select  d.event_code from centerevent_t_downloads d where d.flag='1'
+    <select id="getbeforedateDownload" parameterType="map" resultMap="CentereventTEventcatalogueResult">
+        SELECT l.id, l.event_code, a.event_name, a.report_time, a.create_by
+        FROM centerevent_t_fire_log l
+        LEFT JOIN centerevent_t_eventcatalogue a ON a.event_code = l.event_code
+        <where>
+            <if test="id != null and id != ''">
+                AND a.id = #{id}
+            </if>
             <if test="taskValue != null and taskValue != ''">
-                AND DATEDIFF( d.create_time, now( ) ) = - 1
+                AND DATEDIFF( l.create_time, now( ) ) = -1
             </if>
             <if test="monthValueStart != null and monthValueStart != ''">
-                AND DATE_FORMAT(d.create_time,'%Y-%m-%d') &gt;= #{monthValueStart}
+                AND DATE_FORMAT(l.create_time,'%Y-%m-%d') &gt;= #{monthValueStart}
             </if>
             <if test="monthValueEnd != null and monthValueEnd != ''">
-                AND DATE_FORMAT(d.create_time,'%Y-%m-%d') &lt;= #{monthValueEnd}
+                AND DATE_FORMAT(l.create_time,'%Y-%m-%d') &lt;= #{monthValueEnd}
             </if>
-
-
-						)
-
-
-            )
+            AND l.log_content LIKE '%确认该事件%' AND l.event_code NOT IN (
+            SELECT event_code FROM centerevent_t_downloads
+            <where>
+                flag IN ( 200, 202 )
+                <if test="taskValue != null and taskValue != ''">
+                    AND DATEDIFF( create_time, now( ) ) = -1
+                </if>
+                <if test="monthValueStart != null and monthValueStart != ''">
+                    AND DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= #{monthValueStart}
+                </if>
+                <if test="monthValueEnd != null and monthValueEnd != ''">
+                    AND DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{monthValueEnd}
+                </if>
+            </where>
+            ) AND report_source = 'reporting_source_1'
+            AND a.event_status_value NOT IN ( 'forest_event_status_3', 'forest_event_status_4' )
+        </where>
     </select>
 </mapper>