From feffedd3a450e935debea24599cb5ce2f4c06ab2 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 14 三月 2023 10:18:39 +0800 Subject: [PATCH] bug修改 --- ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java | 172 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 139 insertions(+), 33 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java b/ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java index 2bfb1af..506d508 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java @@ -6,18 +6,17 @@ import com.ycl.api.CommonResult; import com.ycl.controller.BaseController; import com.ycl.dto.statistics.UnlawfulDto; -import com.ycl.dto.statistics.UnlawfulShopDto; +import com.ycl.service.unlawful.UnlawfulService; +import com.ycl.utils.EasyExcelUtils; 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.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -32,23 +31,26 @@ @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)) - ); +// 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("鎸夎繚瑙勭被鍨嬬粺璁�") @@ -57,9 +59,21 @@ @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) { + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String startTime = null; + String endTime1 = null; + if (beginTime != null){ + startTime = beginTime.format(fmt); + } + if (endTime != null){ + endTime1 = endTime.format(fmt); + } + IPage<UnlawfulDto> page = new Page<>(); - page.setTotal(ls.size()); - page.setRecords(ls); + List<UnlawfulDto> unlawfulByType = unlawfulService.getUnlawfulByType((currentPage - 1) * pageSize, pageSize, startTime, endTime1); + + page.setTotal(unlawfulService.getTotalByType(startTime, endTime1)); + page.setRecords(unlawfulByType); return CommonResult.success(page); } @@ -70,9 +84,20 @@ @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) { + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String startTime = null; + String endTime1 = null; + if (beginTime != null){ + startTime = beginTime.format(fmt); + } + if (endTime != null){ + endTime1 = endTime.format(fmt); + } IPage<UnlawfulDto> page = new Page<>(); - page.setTotal(ls.size()); - page.setRecords(ls); + List<UnlawfulDto> unlawfulByType = unlawfulService.getUnlawfulBySite((currentPage - 1) * pageSize, pageSize, startTime, endTime1); + + page.setTotal(unlawfulService.getTotalBySite(startTime, endTime1)); + page.setRecords(unlawfulByType); return CommonResult.success(page); } @@ -83,9 +108,19 @@ @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) { + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String startTime = null; + String endTime1 = null; + if (beginTime != null){ + startTime = beginTime.format(fmt); + } + if (endTime != null){ + endTime1 = endTime.format(fmt); + } IPage<UnlawfulDto> page = new Page<>(); - page.setTotal(ls.size()); - page.setRecords(ls); + List<UnlawfulDto> unlawfulByType = unlawfulService.getUnlawfulByTime((currentPage - 1) * pageSize, pageSize, startTime, endTime1); + page.setTotal(unlawfulService.getTotalByTime(startTime, endTime1)); + page.setRecords(unlawfulByType); return CommonResult.success(page); } @@ -96,13 +131,24 @@ @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) { + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String startTime = null; + String endTime1 = null; + if (beginTime != null){ + startTime = beginTime.format(fmt); + } + if (endTime != null){ + endTime1 = endTime.format(fmt); + } IPage<UnlawfulDto> page = new Page<>(); - page.setTotal(ls.size()); - page.setRecords(ls); + List<UnlawfulDto> unlawfulByType = unlawfulService.getUnlawfulByStreet((currentPage - 1) * pageSize, pageSize, startTime, endTime1); + + page.setTotal(unlawfulService.getTotalByStreet(startTime, endTime1)); + page.setRecords(unlawfulByType); return CommonResult.success(page); } - @GetMapping("/unlawful/shop") + /*@GetMapping("/unlawful/shop") @ApiOperation("闂ㄥ墠涓夊寘缁熻") @LogSave(operationType = "闂ㄥ墠涓夊寘缁熻", contain = "鏌ヨ") public CommonResult<IPage<UnlawfulShopDto>> searchByShop(@RequestParam(required = true) Integer currentPage, @@ -127,6 +173,66 @@ 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) { + List<UnlawfulDto> unlawfulByTypeExport = unlawfulService.getUnlawfulByTypeExport(); + String sheetName = "鎸夌被鍨嬬粺璁℃柟寮�"; + EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulByTypeExport); + } + + @PostMapping("/export/unlawful/street") + @ApiOperation("鎸夊尯鍩熺粺璁℃柟寮�-瀵煎嚭") + public void exportStreet(HttpServletResponse response) { + List<UnlawfulDto> unlawfulByStreetExport = unlawfulService.getUnlawfulByStreetExport(); + String sheetName = "鎸夊尯鍩熺粺璁℃柟寮�"; + EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulByStreetExport); + } + + @PostMapping("/export/unlawful/site") + @ApiOperation("鎸夋姤璀︾偣浣嶇粺璁℃柟寮�-瀵煎嚭") + public void exportSite(HttpServletResponse response) { + List<UnlawfulDto> unlawfulBySiteExport = unlawfulService.getUnlawfulBySiteExport(); + String sheetName = "鎸夋姤璀︾偣浣嶇粺璁℃柟寮�"; + EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulBySiteExport); + } + + @PostMapping("/export/unlawful/time") + @ApiOperation("鎸夋姤璀︾偣浣嶇粺璁℃柟寮�-瀵煎嚭") + public void exportTime(HttpServletResponse response) { + List<UnlawfulDto> unlawfulBySiteExport = unlawfulService.getUnlawfulByTimeExport(); + String sheetName = "鎸夋姤璀︾偣浣嶇粺璁℃柟寮�"; + EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulBySiteExport); + } + + /*@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); + }*/ } -- Gitblit v1.8.0