lyq 3 місяців тому
батько
коміт
9df9852fbd

+ 17 - 0
src/main/java/com/sooka/sponest/event/download/mapper/CentereventTDownloadsMapper.java

@@ -0,0 +1,17 @@
+package com.sooka.sponest.event.download.mapper;
+
+import com.sooka.sponest.event.download.domain.CentereventTDownloads;
+import com.sooka.sponest.monitor.base.util.database.MyDataSource;
+import com.sooka.sponest.monitor.dahua.domain.PlayBackProperties;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CentereventTDownloadsMapper {
+
+    @MyDataSource("event")
+    List<PlayBackProperties> getbeforedateDownload(Map<String, Object> params);
+
+    @MyDataSource("event")
+    int insertCentereventTDownloads(CentereventTDownloads centereventTDownloads);
+}

+ 15 - 0
src/main/java/com/sooka/sponest/event/download/service/ICentereventTDownloadsService.java

@@ -0,0 +1,15 @@
+package com.sooka.sponest.event.download.service;
+
+
+import com.sooka.sponest.event.download.domain.CentereventTDownloads;
+import com.sooka.sponest.monitor.dahua.domain.PlayBackProperties;
+
+import java.util.List;
+import java.util.Map;
+
+public interface ICentereventTDownloadsService {
+
+    List<PlayBackProperties> downloadsCommon(Map<String, Object> params);
+
+    int insertCentereventTDownloads(CentereventTDownloads centereventTDownloads);
+}

+ 31 - 0
src/main/java/com/sooka/sponest/event/download/service/impl/CentereventTDownloadsServiceImpl.java

@@ -0,0 +1,31 @@
+package com.sooka.sponest.event.download.service.impl;
+
+import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.datascope.base.service.BaseService;
+import com.sooka.sponest.event.download.domain.CentereventTDownloads;
+import com.sooka.sponest.event.download.mapper.CentereventTDownloadsMapper;
+import com.sooka.sponest.event.download.service.ICentereventTDownloadsService;
+import com.sooka.sponest.monitor.dahua.domain.PlayBackProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class CentereventTDownloadsServiceImpl extends BaseService implements ICentereventTDownloadsService {
+
+    @Autowired
+    private CentereventTDownloadsMapper centereventTDownloadsMapper;
+
+    @Override
+    public List<PlayBackProperties> downloadsCommon(Map<String, Object> params) {
+        return centereventTDownloadsMapper.getbeforedateDownload(params);
+    }
+
+    @Override
+    public int insertCentereventTDownloads(CentereventTDownloads centereventTDownloads) {
+        centereventTDownloads.setCreateTime(DateUtils.getNowDate());
+        return centereventTDownloadsMapper.insertCentereventTDownloads(centereventTDownloads);
+    }
+}

+ 1 - 1
src/main/java/com/sooka/sponest/monitor/SookaMonitorPlaybackByTimeApplication.java

@@ -16,7 +16,7 @@ import javax.servlet.MultipartConfigElement;
 @EnableCustomConfig
 @EnableCustomSwagger2
 @EnableRyFeignClients
-@SpringBootApplication
+@SpringBootApplication(scanBasePackages = "com.sooka.sponest")
 public class SookaMonitorPlaybackByTimeApplication {
     public static void main(String[] args) {
         SpringApplication.run(SookaMonitorPlaybackByTimeApplication.class, args);

+ 3 - 1
src/main/java/com/sooka/sponest/monitor/dahua/domain/PlayBackProperties.java

@@ -7,7 +7,9 @@ import org.springframework.stereotype.Component;
 @Component
 public class PlayBackProperties {
 
-    private String id;
+    private String eventCode;
+
+    private String eventName;
 
     private String logId;
 

+ 8 - 4
src/main/java/com/sooka/sponest/monitor/dahua/service/impl/DahuaServiceImpl.java

@@ -19,10 +19,12 @@ import com.ruoyi.common.core.constant.HttpStatus;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.redis.service.RedisService;
 import com.ruoyi.system.api.domain.SysFile;
 import com.sooka.sponest.event.download.domain.CentereventTDownloads;
+import com.sooka.sponest.event.download.service.ICentereventTDownloadsService;
 import com.sooka.sponest.monitor.base.service.impl.BaseService;
 import com.sooka.sponest.monitor.camera.domain.CentermonitorTCamera;
 import com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper;
@@ -33,7 +35,6 @@ import com.sooka.sponest.monitor.dahua.service.DahuaService;
 import com.sooka.sponest.monitor.dahua.utils.HttpEnum;
 import com.sooka.sponest.monitor.dahua.utils.HttpTestUtils;
 import com.sooka.sponest.monitor.remoteapi.service.data.RemoteDataBaseService;
-import com.sooka.sponest.monitor.remoteapi.service.event.RemoteEventBaseService;
 import com.sooka.sponest.monitor.remoteapi.service.file.RemoteFileBaseService;
 import com.sooka.sponest.monitor.util.Mp4ParserUtils;
 import org.apache.commons.collections4.CollectionUtils;
@@ -73,7 +74,7 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
     private RemoteDataBaseService dataBaseService;
 
     @Resource
-    private RemoteEventBaseService eventBaseService;
+    private ICentereventTDownloadsService downloadsService;
 
 
 
@@ -84,13 +85,16 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
             AjaxResult ajaxResult = getPlaybackByTime(property);
             //将视频下载结果保存至事件中心
             CentereventTDownloads downloads = new CentereventTDownloads();
-            downloads.setId(property.getId());
+            downloads.setId(IdUtils.simpleUUID());
+            downloads.setEventCode(property.getEventCode());
+            downloads.setEventName(property.getEventName());
+            downloads.setLogId(property.getLogId());
             if (Integer.parseInt(ajaxResult.get("code").toString()) == HttpStatus.SUCCESS) {
                 downloads.setPath(ajaxResult.get("data").toString());
             }
             downloads.setFlag(ajaxResult.get("code").toString());
             downloads.setReason(ajaxResult.get("msg").toString());
-            eventBaseService.downloads(downloads);
+            downloadsService.insertCentereventTDownloads(downloads);
         }
         log.info("**GetPlaybackByTime->"+new Date()+"->end**");
         return AjaxResult.success();

+ 0 - 33
src/main/java/com/sooka/sponest/monitor/remoteapi/fallback/event/RemoteEventBaseServiceFallbackFactory.java

@@ -1,33 +0,0 @@
-package com.sooka.sponest.monitor.remoteapi.fallback.event;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.event.download.domain.CentereventTDownloads;
-import com.sooka.sponest.monitor.remoteapi.service.event.RemoteEventBaseService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.openfeign.FallbackFactory;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestBody;
-
-@Component
-public class RemoteEventBaseServiceFallbackFactory implements FallbackFactory<RemoteEventBaseService> {
-
-    private static final Logger log = LoggerFactory.getLogger(RemoteEventBaseServiceFallbackFactory.class);
-
-    @Override
-    public RemoteEventBaseService create(Throwable cause) {
-        log.error("事件中心-服务调用失败:{}", cause.getMessage());
-
-        return new RemoteEventBaseService() {
-
-            @Override
-            public R downloads(@RequestBody CentereventTDownloads centereventTDownloads) {
-                return null;
-            }
-        };
-
-
-
-    }
-}

+ 0 - 24
src/main/java/com/sooka/sponest/monitor/remoteapi/service/event/RemoteEventBaseService.java

@@ -1,24 +0,0 @@
-package com.sooka.sponest.monitor.remoteapi.service.event;
-
-
-import com.ruoyi.common.core.domain.R;
-import com.sooka.sponest.event.download.domain.CentereventTDownloads;
-import com.sooka.sponest.monitor.remoteapi.fallback.event.RemoteEventBaseServiceFallbackFactory;
-import com.sooka.sponest.monitor.remoteapi.service.ModulesServiceNameContants;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-
-@FeignClient(
-        contextId = "RemoteEventBaseService",
-        value = ModulesServiceNameContants.CENTER_EVENT,
-        fallbackFactory = RemoteEventBaseServiceFallbackFactory.class
-)
-public interface RemoteEventBaseService {
-
-    @PutMapping("/downloads")
-    R downloads(@RequestBody CentereventTDownloads centereventTDownloads);
-
-}

+ 93 - 0
src/main/resources/mapper/event/download/CentereventTDownloadsMapper.xml

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sooka.sponest.event.download.mapper.CentereventTDownloadsMapper">
+
+    <resultMap type="CentereventTDownloads" id="CentereventTDownloadsResult">
+        <result property="id" column="id"/>
+        <result property="eventCode" column="event_code"/>
+        <result property="eventName" column="event_name"/>
+        <result property="path" column="path"/>
+        <result property="flag" column="flag"/>
+        <result property="reason" column="reason"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createName" column="create_name"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateName" column="update_name"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="attachPath" column="attachPath"/>
+    </resultMap>
+
+    <select id="getbeforedateDownload" parameterType="map" resultMap="PlayBackPropertiesResult">
+        SELECT l.event_code eventCode, a.event_name eventName, l.id logId, a.create_by cameraId, DATE_SUB(a.report_time,
+        INTERVAL 2 MINUTE) startTime, DATE_ADD(a.report_time, INTERVAL 1 MINUTE) endTime
+        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( l.create_time, now( ) ) = -1
+            </if>
+            <if test="monthValueStart != null and monthValueStart != ''">
+                AND DATE_FORMAT(l.create_time,'%Y-%m-%d') = #{monthValueStart}
+            </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="id != null and id != ''">
+                    AND event_code = #{id}
+                </if>
+                <if test="taskValue != null and taskValue != ''">
+                    AND DATEDIFF( create_time, now( ) ) = 0
+                </if>
+                <if test="monthValueStart != null and monthValueStart != ''">
+                    AND DATE_FORMAT(create_time,'%Y-%m-%d') >= #{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>
+
+    <insert id="insertCentereventTDownloads" parameterType="CentereventTDownloads">
+        insert into centerevent_t_downloads
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="eventCode != null">event_code,</if>
+            <if test="eventName != null">event_name,</if>
+            <if test="path != null">path,</if>
+            <if test="flag != null">flag,</if>
+            <if test="reason != null">reason,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createName != null">create_name,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateName != null">update_name,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="logId != null">log_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="eventCode != null">#{eventCode},</if>
+            <if test="eventName != null">#{eventName},</if>
+            <if test="path != null">#{path},</if>
+            <if test="flag != null">#{flag},</if>
+            <if test="reason != null">#{reason},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createName != null">#{createName},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateName != null">#{updateName},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="logId != null">#{logId},</if>
+        </trim>
+    </insert>
+</mapper>