wl
2022-09-20 4e260f558428dd81c4dd8981a965cdaa0ebf12de
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
package com.ycl.controller.zf;
 
 
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.api.CommonResult;
import com.ycl.controller.BaseController;
import com.ycl.entity.platform.zf.EnforcelawReport;
import com.ycl.service.platform.zf.IEnforcelawReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 违规事项处置管理:包含违法(违建)情况上报、立案、派遣、处置、核查、结案 前端控制器
 * </p>
 *
 * @author wl
 * @since 2022-09-14
 */
@RestController
@RequestMapping("/enforcelaw-report")
@Api(tags = "城市违建")
public class EnforcelawReportController extends BaseController {
 
    @Autowired
    IEnforcelawReportService enforcelawReportService;
 
    @GetMapping("/search")
    @ApiOperation("查询全部城市违建详情")
    public CommonResult getAll(@RequestParam(required = false) String startTime,
                               @RequestParam(required = false) String endTime,
                               @RequestParam(required = false) String community,
                               @RequestParam(required = false) String status,
                               @RequestParam(required = false) String partiesName,
                               @RequestParam(required = false) String partiesID,
                               @RequestParam(required = false) Integer current,
                               @RequestParam(required = false) Integer size
    ) {
        Page<EnforcelawReport> enforcelawReportPage = new Page<>();
        enforcelawReportPage.setCurrent(current);
        enforcelawReportPage.setSize(size);
        return CommonResult.success(enforcelawReportService.selectPageVo(enforcelawReportPage,startTime,endTime,community,status,partiesName,partiesID));
    }
    @GetMapping("/search/one")
    @ApiOperation("查询城市违建详情")
    public CommonResult getOne(@RequestParam Integer id) {
        return CommonResult.success(enforcelawReportService.getOne(new QueryWrapper<EnforcelawReport>().eq("id", id)));
    }
 
    @PostMapping("/add")
    @ApiOperation("添加城市违建详情")
    public CommonResult add(@RequestBody EnforcelawReport enforcelawReport) {
        return CommonResult.success(enforcelawReportService.save(enforcelawReport));
    }
 
    @DeleteMapping("/delete")
    @ApiOperation("删除城市违建详情")
    public CommonResult remove(@RequestParam Integer id) {
        return CommonResult.success(enforcelawReportService.removeById(id));
    }
 
    @PutMapping("/update")
    @ApiOperation("修改城市违建详情")
    public CommonResult modify(@RequestBody EnforcelawReport enforcelawReport) {
        return CommonResult.success(enforcelawReportService.updateById(enforcelawReport));
    }
 
    @GetMapping("/download")
    @ApiOperation("导出")
    @SneakyThrows
    public void downloadExcel(@RequestParam(required = false) String startTime,
                              @RequestParam(required = false) String endTime,
                              @RequestParam(required = false) String community,
                              @RequestParam(required = false) String status,
                              @RequestParam(required = false) String partiesName,
                              @RequestParam(required = false) String partiesID,
                              HttpServletResponse response) {
        QueryWrapper<EnforcelawReport> enforcelawReportQueryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
            enforcelawReportQueryWrapper.between("cTime", startTime, endTime);
        }
        if (StringUtils.isNotBlank(community)) {
            enforcelawReportQueryWrapper.eq("community", community);
        }
        if (StringUtils.isNotBlank(status)) {
            enforcelawReportQueryWrapper.eq("status", status);
        }
        if (StringUtils.isNotBlank(partiesName)) {
            enforcelawReportQueryWrapper.eq("partiesName", partiesName);
        }
        if (StringUtils.isNotBlank(partiesID)) {
            enforcelawReportQueryWrapper.eq("partiesID", partiesID);
        }
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-disposition", "attachment;filename=" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + URLEncoder.encode("城市违建" + ".xlsx", "utf-8"));
        EasyExcel.write(response.getOutputStream(), EnforcelawReport.class).sheet("列表").doWrite(enforcelawReportService.list(enforcelawReportQueryWrapper));
    }
}