zhanghua
2023-12-12 bc2da7908a227c09e5cc7b6d8dab3e9c94b784a1
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
package com.ycl.controller.intelligentPatrol;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.annotation.LogSave;
import com.ycl.api.CommonResult;
import com.ycl.controller.BaseController;
import com.ycl.dto.statistics.UnlawfulDto;
import com.ycl.service.unlawful.UnlawfulService;
import com.ycl.utils.EasyExcelUtils;
import com.ycl.vo.cockpit.CockpitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
 
/**
 * StatisticsController
 *
 * @version V1.0
 * @author: AI
 * @date: 2022-11-01 16:40
 **/
@RestController
@RequestMapping("/intelligentPatrol/statistics")
@Api(tags = "违章-违法统计")
public class StatisticsController extends BaseController {
 
//    List<UnlawfulDto> ls = new ArrayList<>(Arrays.asList(
//            new UnlawfulDto("市场监管", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("公安", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("自然资源", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("生态环境", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("地方立法", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("地震", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("教育", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("经信", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("林业", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("农村环境卫生", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("气象", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("人防", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("水行政", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("应急管理", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("其他", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0))
//    );
 
    @Autowired
    private UnlawfulService unlawfulService;
 
    @GetMapping("/unlawful/type")
    @ApiOperation("按违规类型统计")
    @LogSave(operationType = "按违规类型统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByType(@RequestParam(required = true) Integer currentPage,
                                                         @RequestParam(required = true) Integer pageSize,
                                                         @RequestParam(required = false) String beginTime,
                                                         @RequestParam(required = false) String endTime) {
 
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByType(currentPage, pageSize, beginTime, endTime);
 
        return CommonResult.success(page);
    }
 
    @GetMapping("/unlawful/point")
    @ApiOperation("按点位统计")
    @LogSave(operationType = "按点位统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByPoint(@RequestParam(required = true) Integer currentPage,
                                                          @RequestParam(required = true) Integer pageSize,
                                                          @RequestParam(required = false) String beginTime,
                                                          @RequestParam(required = false) String endTime) {
 
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByPoint(currentPage, pageSize, beginTime, endTime);
 
        return CommonResult.success(page);
    }
 
    @GetMapping("/unlawful/time")
    @ApiOperation("按时间统计")
    @LogSave(operationType = "按时间统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByTime(@RequestParam(required = true) Integer currentPage,
                                                         @RequestParam(required = true) Integer pageSize,
                                                         @RequestParam(required = false) String beginTime,
                                                         @RequestParam(required = false) String endTime) {
 
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByTime(currentPage, pageSize, beginTime, endTime);
 
        return CommonResult.success(page);
    }
 
    @GetMapping("/unlawful/area")
    @ApiOperation("按区域统计")
    @LogSave(operationType = "按区域统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByArea(@RequestParam(required = true) Integer currentPage,
                                                         @RequestParam(required = true) Integer pageSize,
                                                         @RequestParam(required = false) String beginTime,
                                                         @RequestParam(required = false) String endTime) {
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByStreet(currentPage, pageSize, beginTime, endTime);
 
        return CommonResult.success(page);
    }
 
    /*@GetMapping("/unlawful/shop")
    @ApiOperation("门前三包统计")
    @LogSave(operationType = "门前三包统计", contain = "查询")
    public CommonResult<IPage<UnlawfulShopDto>> searchByShop(@RequestParam(required = true) Integer currentPage,
                                                             @RequestParam(required = true) Integer pageSize,
                                                             @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beginTime,
                                                             @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
        IPage<UnlawfulShopDto> page = new Page<>();
        List<UnlawfulShopDto> ls = new ArrayList<>();
        ls.add(new UnlawfulShopDto("店铺1", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺2", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺3", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺4", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺5", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺6", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺7", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺8", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺9", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺10", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺11", 100, 10, 1, 20, 5, 20, 0.7));
        ls.add(new UnlawfulShopDto("店铺12", 100, 10, 1, 20, 5, 20, 0.8));
        ls.add(new UnlawfulShopDto("店铺13", 100, 10, 1, 20, 5, 20, 0.9));
        page.setTotal(ls.size());
        page.setRecords(ls);
        return CommonResult.success(page);
    }*/
 
//    @PostMapping("/export/unlawful")
//    @ApiOperation("按各种统计方式-导出")
//    public void export(HttpServletResponse response) {
//        List<UnlawfulDto> unlawfulByTypeExport = unlawfulService.getUnlawfulByTypeExport();
//        String sheetName = "按统计方式";
//        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulByTypeExport);
//    }
 
    @PostMapping("/export/unlawful/type")
    @ApiOperation("按类型统计方式-导出")
    public void exportType(HttpServletResponse response,
                           @RequestBody CockpitVO vo) {
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByType(1, 500, vo.getBeginTime(), vo.getEndTime());
        String sheetName = "按统计方式";
        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, page.getRecords());
    }
 
    @PostMapping("/export/unlawful/street")
    @ApiOperation("按区域统计方式-导出")
    public void exportStreet(HttpServletResponse response,
                             @RequestBody CockpitVO vo) {
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByStreet(1, 500, vo.getBeginTime(), vo.getEndTime());
 
        String sheetName = "按区域统计方式";
        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, page.getRecords());
    }
 
    @PostMapping("/export/unlawful/site")
    @ApiOperation("按报警点位统计方式-导出")
    public void exportSite(HttpServletResponse response,
                           @RequestBody CockpitVO vo) {
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByPoint(1, 500, vo.getBeginTime(), vo.getEndTime());
 
        String sheetName = "按报警点位统计方式";
        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, page.getRecords());
    }
 
    @PostMapping("/export/unlawful/time")
    @ApiOperation("按报警点位统计方式-导出")
    public void exportTime(HttpServletResponse response,
                           @RequestBody CockpitVO vo) {
        IPage<UnlawfulDto> page = unlawfulService.getUnlawfulByTime(1, 500, vo.getBeginTime(), vo.getEndTime());
 
        String sheetName = "按报警点位统计方式";
        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, page.getRecords());
    }
 
    /*@PostMapping("/export/shop")
    @ApiOperation("门前三包-导出")
    public void exportShop(HttpServletResponse response) {
        List<UnlawfulShopDto> ls = new ArrayList<>();
        ls.add(new UnlawfulShopDto("店铺1", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺2", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺3", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺4", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺5", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺6", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺7", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺8", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺9", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺10", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺11", 100, 10, 1, 20, 5, 20, 0.7));
        ls.add(new UnlawfulShopDto("店铺12", 100, 10, 1, 20, 5, 20, 0.8));
        ls.add(new UnlawfulShopDto("店铺13", 100, 10, 1, 20, 5, 20, 0.9));
        String sheetName = "门前三包";
        EasyExcelUtils.export(response, sheetName, UnlawfulShopDto.class, ls);
    }*/
}