wl
2022-12-13 3cf5e9483f60c94d29df1a79bc0c1ca910ca46ef
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
70
71
72
73
74
75
76
77
78
79
80
81
package com.ycl.service.caseHandler.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.video.VideoAlarmReport;
import com.ycl.entity.video.VideoPoint;
import com.ycl.mapper.caseHandler.BaseCaseMapper;
import com.ycl.mapper.caseHandler.ViolationsMapper;
import com.ycl.service.caseHandler.IBaseCaseService;
import com.ycl.service.caseHandler.IViolationsService;
import com.ycl.service.video.impl.IVideoPointService;
import com.ycl.vo.cockpit.enforcementEvents.VideoAndAreaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
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;
 
    @Resource
    BaseCaseMapper baseCaseMapper;
 
    @Autowired
    public void setVideoPointService(IVideoPointService videoPointService) {
        this.videoPointService = videoPointService;
    }
    @Autowired
    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(0L).state(1).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.setSite(videoPoint.getAddress());
            }
            baseCaseService.save(baseCase);
            violations.setId(baseCase.getId());
            violations.setVideoAlarmReportId(videoAlarmReport.getId());
            violations.setVideoPointId(videoPoint.getId());
            baseMapper.insert(violations);
        }
    }
 
    @Override
    public List<VideoAndAreaVO> selectType() {
        return  baseCaseMapper.selectType();
    }
}