zhanghua
2022-09-27 6aae0fb74bb0414cf158bac825858006c92733ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
 
/**
 * <p>
 * 违规事件 服务实现类
 * </p>
 *
 * @author wl
 * @since 2022-09-24
 */
@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());
 
                violations.setVideoAlarmReportId(videoAlarmReport.getId());
            }
            baseCaseService.save(baseCase);
            violations.setId(baseCase.getId());
            baseMapper.insert(violations);
        }
    }
}