File was renamed from ycl-platform/src/main/java/com/ycl/service/videoAlarm/impl/VideoAlarmReportServiceImpl.java |
| | |
| | | package com.ycl.service.videoAlarm.impl; |
| | | package com.ycl.service.video.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.dto.media.Media; |
| | | import com.ycl.dto.media.PictureZoomParameter; |
| | | import com.ycl.dto.videoAlarm.AlarmDataParam; |
| | | import com.ycl.dto.videoAlarm.AlarmParam; |
| | | import com.ycl.dto.videoAlarm.CameraInfParam; |
| | | import com.ycl.entity.videoAlarm.VideoAlarmReport; |
| | | import com.ycl.mapper.videoAlarm.VideoAlarmReportMapper; |
| | | import com.ycl.service.videoAlarm.IVideoAlarmReportService; |
| | | import com.ycl.dto.video.AlarmDataParam; |
| | | import com.ycl.dto.video.AlarmParam; |
| | | import com.ycl.dto.video.CameraInfParam; |
| | | import com.ycl.entity.video.VideoAlarmReport; |
| | | import com.ycl.mapper.video.VideoAlarmReportMapper; |
| | | import com.ycl.service.caseHandler.IViolationsService; |
| | | import com.ycl.service.video.IVideoAlarmReportService; |
| | | import com.ycl.utils.MediaFileUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.xml.bind.DatatypeConverter; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * VideoAlarmReportServiceImpl |
| | |
| | | public class VideoAlarmReportServiceImpl extends ServiceImpl<VideoAlarmReportMapper, VideoAlarmReport> implements IVideoAlarmReportService { |
| | | |
| | | private MediaFileUtil mediaFileUtil; |
| | | private IViolationsService violationsService; |
| | | |
| | | @Autowired |
| | | public void setMediaFileUtil(MediaFileUtil mediaFileUtil) { |
| | | this.mediaFileUtil = mediaFileUtil; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setViolationsService(IViolationsService violationsService) { |
| | | this.violationsService = violationsService; |
| | | } |
| | | |
| | | @Override |
| | |
| | | InputStream inputStream = new ByteArrayInputStream(data); |
| | | try { |
| | | picData = mediaFileUtil.savePicture(inputStream, extension); |
| | | |
| | | List<VideoAlarmReport> videoAlarmReports = new ArrayList<>(); |
| | | for (int i = 0; i < alarmParam.getAlarmData().size(); i++) { |
| | | AlarmDataParam alarmData = alarmParam.getAlarmData().get(i); |
| | | /******************** 处理图片 **********************/ |
| | |
| | | .alarmId(alarmData.getAlarmID()).algoType(alarmData.getAlgoType()) |
| | | .algoName(alarmData.getAlgoName()).alarmObj(JSON.toJSONString(alarmData.getAlarmObject())) |
| | | .build(); |
| | | baseMapper.insert(videoAlarmReport); |
| | | videoAlarmReports.add(videoAlarmReport); |
| | | |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | this.saveBatch(videoAlarmReports, videoAlarmReports.size()); |
| | | |
| | | violationsService.saveFromVideo(videoAlarmReports); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |