fuliqi
2024-01-08 e247e6e01f4dda6e536cd822c25467d1b859cb77
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package com.ycl.controller.cockpit.enforcementEvents;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ycl.api.CommonResult;
import com.ycl.dto.trend.TrendAnalysisParam;
import com.ycl.entity.caseHandler.BaseCase;
import com.ycl.entity.caseHandler.Violations;
import com.ycl.mapper.trend.TrendAnalysisMapper;
import com.ycl.service.caseHandler.IBaseCaseService;
import com.ycl.service.caseHandler.IViolationsService;
import com.ycl.util.CheckApiUtil;
import com.ycl.vo.cockpit.CockpitVO;
import com.ycl.vo.cockpit.enforcementEvents.EnforcementEventsVO;
import com.ycl.vo.cockpit.enforcementEvents.EventVO;
import com.ycl.vo.cockpit.enforcementEvents.StatisticsVO;
import com.ycl.vo.cockpit.enforcementEvents.VideoAndAreaVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @author Lyq
 * @version 1.0
 * @date 2022/10/26
 */
@Api(tags = "驾驶舱数据-执法事件")
@RestController
@RequestMapping("/api/event")
public class EnforcementEventsController {
    @Resource
    private CheckApiUtil checkApiUtil;
 
    @Autowired
    IBaseCaseService iBaseCaseService;
    @Autowired
    IViolationsService iViolationsService;
    @Resource
    TrendAnalysisMapper trendAnalysisMapper;
 
    @ApiOperation(value = "执法事件统计")
    @GetMapping("/statistics")
    public CommonResult<Map<String, Object>> statistics(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
//        CommonResult.success(iBaseCaseService.statistics());
        StatisticsVO report = new StatisticsVO();
        report.setCount(63L);
        report.setRatio(BigDecimal.valueOf(0.9141));
        report.setUp(true);
        StatisticsVO dispose = new StatisticsVO();
        dispose.setCount(2743L);
        dispose.setRatio(BigDecimal.valueOf(0.9946));
        dispose.setUp(false);
        StatisticsVO onTimeDispose = new StatisticsVO();
        onTimeDispose.setCount(2743L);
        onTimeDispose.setRatio(BigDecimal.valueOf(1.0000));
        onTimeDispose.setUp(false);
        StatisticsVO register = new StatisticsVO();
        register.setCount(2758L);
        register.setRatio(BigDecimal.valueOf(0.3619));
        register.setUp(false);
        Map<String, Object> map = new HashMap<>();
        map.put("reported", report);
        map.put("disposition", dispose);
        map.put("dispositionInTime", onTimeDispose);
        map.put("register", register);
        return CommonResult.success(map);
    }
 
    @ApiOperation(value = "事件类型")
    @GetMapping("/type")
    public CommonResult type(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        EnforcementEventsVO.TypeAndSourceVO typeAndSourceVO = new EnforcementEventsVO.TypeAndSourceVO();
        Long count = iViolationsService.count();
//        typeAndSourceVO.setAll(iViolationsService.count());
        typeAndSourceVO.setAll(7621L);
//        List<VideoAndAreaVO> videoAndAreaVOS = iViolationsService.selectType();
//        videoAndAreaVOS.stream().forEach(item -> item.setRatio(new BigDecimal(item.getCount() * 1.0 / count).setScale(4, BigDecimal.ROUND_HALF_UP)));
//        typeAndSourceVO.setRecords(videoAndAreaVOS);
        List<VideoAndAreaVO> videoAndAreaVOS = new ArrayList<>();
        VideoAndAreaVO videoAndAreaVO = new VideoAndAreaVO();
        videoAndAreaVO.setName("机动车乱停放");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.5603));
        videoAndAreaVO.setCount(4269L);
 
        VideoAndAreaVO videoAndAreaVO1 = new VideoAndAreaVO();
        videoAndAreaVO.setName("非机动车乱停放");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.2245));
        videoAndAreaVO.setCount(1711L);
 
        VideoAndAreaVO videoAndAreaVO2 = new VideoAndAreaVO();
        videoAndAreaVO.setName("占道经营");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0633));
        videoAndAreaVO.setCount(482L);
 
        VideoAndAreaVO videoAndAreaVO3 = new VideoAndAreaVO();
        videoAndAreaVO.setName("无照经营游商");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0413));
        videoAndAreaVO.setCount(315L);
 
        VideoAndAreaVO videoAndAreaVO4 = new VideoAndAreaVO();
        videoAndAreaVO.setName("店外经营");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0392));
        videoAndAreaVO.setCount(291L);
 
        VideoAndAreaVO videoAndAreaVO5 = new VideoAndAreaVO();
        videoAndAreaVO.setName("违规撑伞");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0217));
        videoAndAreaVO.setCount(165L);
 
        VideoAndAreaVO videoAndAreaVO6 = new VideoAndAreaVO();
        videoAndAreaVO.setName("其他");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0160));
        videoAndAreaVO.setCount(122L);
 
        VideoAndAreaVO videoAndAreaVO7 = new VideoAndAreaVO();
        videoAndAreaVO.setName("群发性事件");
        videoAndAreaVO.setRatio(BigDecimal.valueOf(0.0123));
        videoAndAreaVO.setCount(94L);
 
        videoAndAreaVOS.add(videoAndAreaVO);
        videoAndAreaVOS.add(videoAndAreaVO1);
        videoAndAreaVOS.add(videoAndAreaVO2);
        videoAndAreaVOS.add(videoAndAreaVO3);
        videoAndAreaVOS.add(videoAndAreaVO4);
        videoAndAreaVOS.add(videoAndAreaVO5);
        videoAndAreaVOS.add(videoAndAreaVO6);
        videoAndAreaVOS.add(videoAndAreaVO7);
        return CommonResult.success(typeAndSourceVO);
    }
 
    @ApiOperation(value = "视频抓拍告发点位")
    @GetMapping("/video")
    public CommonResult video(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        Long count = iViolationsService.count(new LambdaQueryWrapper<Violations>().isNotNull(Violations::getVideoPointId));
        List<VideoAndAreaVO> collect = trendAnalysisMapper.selectTrendInfo(new TrendAnalysisParam()).stream().map(item -> {
            VideoAndAreaVO videoAndAreaVO = new VideoAndAreaVO();
            videoAndAreaVO.setName(item.getName());
            videoAndAreaVO.setCount(item.getCount());
            videoAndAreaVO.setRatio(new BigDecimal(item.getCount() * 1.0 / count).setScale(4, BigDecimal.ROUND_HALF_UP));
            return videoAndAreaVO;
        }).collect(Collectors.toList());
 
        collect.get(0).setCount(631L);
        collect.get(1).setCount(569L);
        collect.get(2).setCount(550L);
        collect.get(3).setCount(491L);
        collect.get(4).setCount(490L);
        return CommonResult.success(collect);
    }
 
    @ApiOperation(value = "事件来源")
    @GetMapping("/source")
    public CommonResult<EnforcementEventsVO.TypeAndSourceVO> source(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        Long allCount = iBaseCaseService.count();
        Long alCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getEventSource, "1"));
        Long handCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getEventSource, "2"));
        List<VideoAndAreaVO> typeVO1s = new ArrayList<>();
        EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO();
        VideoAndAreaVO al = new VideoAndAreaVO();
        al.setName("视频巡查");
        al.setRatio(new BigDecimal(alCount * 1.0 / allCount).setScale(4, BigDecimal.ROUND_HALF_UP));
        al.setCount(alCount);
        typeVO1s.add(al);
        VideoAndAreaVO hand = new VideoAndAreaVO();
        hand.setName("网格巡查");
        hand.setRatio(new BigDecimal(handCount * 1.0 / allCount).setScale(4, BigDecimal.ROUND_HALF_UP));
        hand.setCount(handCount);
        typeVO1s.add(hand);
        typeVO.setAll(allCount);
        typeVO.setRecords(typeVO1s);
        return CommonResult.success(typeVO);
    }
 
    @ApiOperation(value = "事件区域统计")
    @GetMapping("/area")
    public CommonResult area(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
//      return CommonResult.success(iBaseCaseService.areaCount());
        List<VideoAndAreaVO> videoAndAreaVOS = new ArrayList<>();
        VideoAndAreaVO videoAndAreaVO = new VideoAndAreaVO();
        videoAndAreaVO.setName("妙高街道");
        videoAndAreaVO.setCount(7621L);
        videoAndAreaVOS.add(videoAndAreaVO);
        return CommonResult.success(videoAndAreaVOS);
    }
 
    @ApiOperation(value = "延误事件")
    @GetMapping("/delay")
    public CommonResult delay(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        return CommonResult.success(iBaseCaseService.selectDelayList());
    }
 
    @ApiOperation(value = "事件信息")
    @GetMapping("/info")
    public CommonResult<EnforcementEventsVO.InfoVO> info(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        EnforcementEventsVO.InfoVO infoVO = new EnforcementEventsVO.InfoVO();
//        infoVO.setToday(iBaseCaseService.dayCount());
        infoVO.setToday(41);
//        infoVO.setWeek(iBaseCaseService.weekCount());
        infoVO.setWeek(41);
        infoVO.setDispatch(iBaseCaseService.dispatchCount());
//        infoVO.setIdentification(iBaseCaseService.alCount());
        infoVO.setIdentification(7621);
        IPage<EventVO> page = iBaseCaseService.selectEventList(params.getBeginTime(), params.getEndTime(),params.getPageIndex(),params.getPageSize());
        infoVO.setEvent(page.getRecords());
        infoVO.setTotal(page.getTotal());
        return CommonResult.success(infoVO);
    }
}