From 7ef4892f9f24f941aca37e6b3991b808a0aca619 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 08 九月 2023 11:16:35 +0800
Subject: [PATCH] 优化

---
 ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java |   31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 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 244ee39..a8800de 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
@@ -1,6 +1,7 @@
 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;
@@ -8,11 +9,10 @@
 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.EventVO;
 import com.ycl.vo.cockpit.enforcementEvents.VideoAndAreaVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -24,9 +24,7 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -54,16 +52,7 @@
     @GetMapping("/statistics")
     public CommonResult<Map<String, Object>> statistics(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        Map<String, Object> map = new HashMap<>();
-        EnforcementEventsVO.StatisticsEventVO eventVO = new EnforcementEventsVO.StatisticsEventVO();
-        eventVO.setCount(10);
-        eventVO.setRatio(new BigDecimal("0.69").setScale(2, RoundingMode.HALF_UP));
-        eventVO.setUp(true);
-        map.put("reported", eventVO);
-        map.put("disposition", eventVO);
-        map.put("dispositionInTime", eventVO);
-        map.put("register", eventVO);
-        return CommonResult.success(map);
+        return CommonResult.success(iBaseCaseService.statistics());
     }
 
     @ApiOperation(value = "浜嬩欢绫诲瀷")
@@ -74,7 +63,7 @@
         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)));
+        videoAndAreaVOS.stream().forEach(item -> item.setRatio(new BigDecimal(item.getCount() * 1.0 / count).setScale(4, BigDecimal.ROUND_HALF_UP)));
         typeAndSourceVO.setRecords(videoAndAreaVOS);
         return CommonResult.success(typeAndSourceVO);
     }
@@ -88,7 +77,7 @@
             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));
+            videoAndAreaVO.setRatio(new BigDecimal(item.getCount() * 1.0 / count).setScale(4, BigDecimal.ROUND_HALF_UP));
             return videoAndAreaVO;
         }).collect(Collectors.toList());
         return CommonResult.success(collect);
@@ -105,12 +94,12 @@
         EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO();
         VideoAndAreaVO al = new VideoAndAreaVO();
         al.setName("瑙嗛宸℃煡");
-        al.setRatio(new BigDecimal(alCount * 1.0 / allCount).setScale(2, BigDecimal.ROUND_HALF_UP));
+        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(2, BigDecimal.ROUND_HALF_UP));
+        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);
@@ -141,7 +130,9 @@
         infoVO.setWeek(iBaseCaseService.weekCount());
         infoVO.setDispatch(iBaseCaseService.dispatchCount());
         infoVO.setIdentification(iBaseCaseService.alCount());
-        infoVO.setEvent(iBaseCaseService.selectEventList(params.getBeginTime(), params.getEndTime()));
+        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);
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0