From f057850aac83d7b154b5b96592ec1c944ebdf375 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 13 十二月 2022 17:05:02 +0800 Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/sccg_server --- ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java | 53 +++++++++++++++++++++++++---------------------------- 1 files changed, 25 insertions(+), 28 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java b/ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java index 012c29b..78cfda3 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java @@ -2,9 +2,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.service.trend.TrendAnalysisService; import com.ycl.util.CheckApiUtil; +import com.ycl.vo.TrendVo; import com.ycl.vo.cockpit.CockpitVO; import com.ycl.vo.cockpit.enforcementEvents.EnforcementEventsVO; import com.ycl.vo.cockpit.enforcementEvents.VideoAndAreaVO; @@ -23,6 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @author Lyq @@ -38,6 +45,10 @@ @Autowired IBaseCaseService iBaseCaseService; + @Autowired + IViolationsService iViolationsService; + @Autowired + TrendAnalysisMapper trendAnalysisMapper; @ApiOperation(value = "鎵ф硶浜嬩欢缁熻") @GetMapping("/statistics") @@ -60,24 +71,11 @@ public CommonResult type(@Validated CockpitVO params) { checkApiUtil.cockpit(params); EnforcementEventsVO.TypeAndSourceVO typeAndSourceVO = new EnforcementEventsVO.TypeAndSourceVO(); - Long allCount = iBaseCaseService.count(); - Long violationCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getCategory, "1")); - Long illegalBuildingCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getCategory, "2")); - - ArrayList<VideoAndAreaVO> typeAndSourceVO1s = new ArrayList<>(); - VideoAndAreaVO violationVO1 = new VideoAndAreaVO(); - violationVO1.setName("杩濊"); - violationVO1.setCount(violationCount); - violationVO1.setRatio(new BigDecimal(violationCount * 1.0 / allCount).setScale(2, BigDecimal.ROUND_HALF_UP)); - VideoAndAreaVO illegalBuildingVO1 = new VideoAndAreaVO(); - illegalBuildingVO1.setName("杩濆缓"); - illegalBuildingVO1.setCount(illegalBuildingCount); - illegalBuildingVO1.setRatio(new BigDecimal(illegalBuildingCount * 1.0 / allCount).setScale(2, BigDecimal.ROUND_HALF_UP)); - typeAndSourceVO1s.add(violationVO1); - typeAndSourceVO1s.add(illegalBuildingVO1); - typeAndSourceVO.setRecords(typeAndSourceVO1s); - typeAndSourceVO.setAll(allCount); - System.out.println(illegalBuildingCount / allCount); + Long count = iViolationsService.count(); + typeAndSourceVO.setAll(iViolationsService.count()); + List<VideoAndAreaVO> videoAndAreaVOS = iViolationsService.selectType(); + videoAndAreaVOS.stream().forEach(item->item.setRatio(new BigDecimal(item.getCount()*1.0/count).setScale(2,BigDecimal.ROUND_HALF_UP))); + typeAndSourceVO.setRecords(videoAndAreaVOS); return CommonResult.success(typeAndSourceVO); } @@ -85,16 +83,15 @@ @GetMapping("/video") public CommonResult video(@Validated CockpitVO params) { checkApiUtil.cockpit(params); - List<VideoAndAreaVO> videoVOS = new ArrayList<>(); - VideoAndAreaVO videoVO = null; - for (int i = 0; i < 4; i++) { - videoVO = new VideoAndAreaVO(); - videoVO.setName("鍥㈢粨灞�"); - videoVO.setCount(10L); - videoVO.setRatio(new BigDecimal("0.65").setScale(2, RoundingMode.HALF_UP)); - videoVOS.add(videoVO); - } - return CommonResult.success(videoVOS); + 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(2, BigDecimal.ROUND_HALF_UP)); + return videoAndAreaVO; + }).collect(Collectors.toList()); + return CommonResult.success(collect); } @ApiOperation(value = "浜嬩欢鏉ユ簮") -- Gitblit v1.8.0