From 6aae0fb74bb0414cf158bac825858006c92733ea Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 27 九月 2022 17:54:07 +0800 Subject: [PATCH] 视频报警后将数据同步到违规事件中 --- ycl-platform/src/main/java/com/ycl/entity/caseHandler/QuestionCategory.java | 37 ++++++++++++ ycl-platform/src/main/java/com/ycl/service/video/impl/IVideoPointService.java | 2 ycl-platform/src/main/java/com/ycl/entity/video/VideoPoint.java | 4 ycl-platform/src/main/java/com/ycl/entity/caseHandler/BaseCase.java | 4 ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/ViolationsServiceImpl.java | 40 +++++++++++++ ycl-platform/src/main/java/com/ycl/entity/caseHandler/Violations.java | 5 + ycl-platform/src/main/java/com/ycl/entity/caseHandler/EventSource.java | 39 +++++++++++++ 7 files changed, 125 insertions(+), 6 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/BaseCase.java b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/BaseCase.java index c309fa4..eca8492 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/BaseCase.java +++ b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/BaseCase.java @@ -74,13 +74,13 @@ * 瀹氫綅淇℃伅 */ @TableField("longitude") - private Float longitude; + private Double longitude; /** * 瀹氫綅-绾害 */ @TableField("latitude") - private Float latitude; + private Double latitude; /** * 鎶ヨ鏃堕棿 diff --git a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/EventSource.java b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/EventSource.java new file mode 100644 index 0000000..8b40328 --- /dev/null +++ b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/EventSource.java @@ -0,0 +1,39 @@ +package com.ycl.entity.caseHandler; + + +/** + * EvnetSource 浜嬩欢鏉ユ簮 + * + * @author: AI + * @date: 2022-09-27 17:40 + * @version V1.0 +**/ +public enum EventSource { + VIDEO(1,"瑙嗛"), + MANUAL(2,"鎵嬪姩娣诲姞") + ; + + private Integer code; + private String name; + + EventSource(int code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/QuestionCategory.java b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/QuestionCategory.java new file mode 100644 index 0000000..c89c412 --- /dev/null +++ b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/QuestionCategory.java @@ -0,0 +1,37 @@ +package com.ycl.entity.caseHandler; + +/** + * EventType 浜嬩欢绫诲瀷 + * + * @version V1.0 + * @author: AI + * @date: 2022-09-27 17:47 + **/ +public enum QuestionCategory { + VIOLATION(1, "杩濊"), + ILLEGAL_BUILDING(2, "杩濆缓"); + + private Integer code; + private String name; + + QuestionCategory(int code, String name) { + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/Violations.java b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/Violations.java index 2f9bb72..4b13968 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/caseHandler/Violations.java +++ b/ycl-platform/src/main/java/com/ycl/entity/caseHandler/Violations.java @@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; + +import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** * <p> @@ -19,6 +22,8 @@ @Data @EqualsAndHashCode(callSuper = false) @TableName("ums_violations") +@Builder +@NoArgsConstructor public class Violations implements Serializable { private static final long serialVersionUID = 1L; diff --git a/ycl-platform/src/main/java/com/ycl/entity/video/VideoPoint.java b/ycl-platform/src/main/java/com/ycl/entity/video/VideoPoint.java index efd0a1c..8284680 100644 --- a/ycl-platform/src/main/java/com/ycl/entity/video/VideoPoint.java +++ b/ycl-platform/src/main/java/com/ycl/entity/video/VideoPoint.java @@ -35,13 +35,13 @@ * 鐐逛綅缁忓害 */ @TableField("longitude") - private BigDecimal longitude; + private Double longitude; /** * 鐐逛綅绾害 */ @TableField("latitude") - private BigDecimal latitude; + private Double latitude; /** * 鐐逛綅鍚嶇О diff --git a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/ViolationsServiceImpl.java b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/ViolationsServiceImpl.java index 8bab837..d5cbed7 100644 --- a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/ViolationsServiceImpl.java +++ b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/ViolationsServiceImpl.java @@ -1,13 +1,22 @@ package com.ycl.service.caseHandler.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ycl.entity.caseHandler.BaseCase; +import com.ycl.entity.caseHandler.EventSource; +import com.ycl.entity.caseHandler.QuestionCategory; import com.ycl.entity.caseHandler.Violations; +import com.ycl.entity.dict.DataDictionary; import com.ycl.entity.video.VideoAlarmReport; +import com.ycl.entity.video.VideoPoint; import com.ycl.mapper.caseHandler.ViolationsMapper; +import com.ycl.service.caseHandler.IBaseCaseService; import com.ycl.service.caseHandler.IViolationsService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ycl.service.video.impl.IVideoPointService; +import com.ycl.service.video.impl.VideoPointServiceImpl; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.List; /** @@ -21,11 +30,40 @@ @Service public class ViolationsServiceImpl extends ServiceImpl<ViolationsMapper, Violations> implements IViolationsService { + private IVideoPointService videoPointService; + private IBaseCaseService baseCaseService; + + public void setVideoPointService(IVideoPointService videoPointService) { + this.videoPointService = videoPointService; + } + + public void setBaseCaseService(IBaseCaseService baseCaseService) { + this.baseCaseService = baseCaseService; + } + @Override public void saveFromVideo(List<VideoAlarmReport> videoAlarmReports) { for (VideoAlarmReport videoAlarmReport : videoAlarmReports) { + VideoPoint videoPoint = null; + LambdaQueryWrapper<VideoPoint> queryWrapper = new LambdaQueryWrapper<VideoPoint>().eq(VideoPoint::getPlatResourceId, videoAlarmReport.getPlatResourceId()); + List<VideoPoint> pointList = videoPointService.list(queryWrapper); + if (pointList.size() > 0) { + videoPoint = pointList.get(0); + } + BaseCase baseCase = BaseCase.builder().eventSource(EventSource.VIDEO.getCode()).category(QuestionCategory.VIOLATION.getCode()) + .createTime(LocalDateTime.now()).createUser(0).alarmTime(videoAlarmReport.getAlarmTime()).build(); + Violations violations = new Violations(); + if (videoPoint != null) { + baseCase.setLatitude(videoPoint.getLatitude()); + baseCase.setLongitude(videoPoint.getLongitude()); + baseCase.setStreetId(videoPoint.getStreetId()); + baseCase.setCommunityId(videoPoint.getCommunityId()); - BaseCase baseCase = BaseCase.builder().build(); + violations.setVideoAlarmReportId(videoAlarmReport.getId()); + } + baseCaseService.save(baseCase); + violations.setId(baseCase.getId()); + baseMapper.insert(violations); } } } diff --git a/ycl-platform/src/main/java/com/ycl/service/video/impl/IVideoPointService.java b/ycl-platform/src/main/java/com/ycl/service/video/impl/IVideoPointService.java index 7ba16eb..79a83ad 100644 --- a/ycl-platform/src/main/java/com/ycl/service/video/impl/IVideoPointService.java +++ b/ycl-platform/src/main/java/com/ycl/service/video/impl/IVideoPointService.java @@ -12,6 +12,6 @@ * @author zhanghua * @since 2022-09-26 */ -interface IVideoPointService extends IService<VideoPoint> { +public interface IVideoPointService extends IService<VideoPoint> { } -- Gitblit v1.8.0