From a8a8b384f755b454242a709d86cfef6377a12d33 Mon Sep 17 00:00:00 2001
From: wl <173@qq.com>
Date: 星期一, 12 十二月 2022 17:46:09 +0800
Subject: [PATCH] fix: 对外提供Api

---
 ycl-platform/src/main/java/com/ycl/controller/cockpit/enforcementEvents/EnforcementEventsController.java |  101 ++++++++++++++++++++++++--------------------------
 1 files changed, 49 insertions(+), 52 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 ebfe719..012c29b 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,10 +1,13 @@
 package com.ycl.controller.cockpit.enforcementEvents;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ycl.api.CommonResult;
+import com.ycl.entity.caseHandler.BaseCase;
 import com.ycl.service.caseHandler.IBaseCaseService;
 import com.ycl.util.CheckApiUtil;
 import com.ycl.vo.cockpit.CockpitVO;
 import com.ycl.vo.cockpit.enforcementEvents.EnforcementEventsVO;
+import com.ycl.vo.cockpit.enforcementEvents.VideoAndAreaVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,33 +57,40 @@
 
     @ApiOperation(value = "浜嬩欢绫诲瀷")
     @GetMapping("/type")
-    public CommonResult<EnforcementEventsVO.TypeAndSourceVO> type(@Validated CockpitVO params) {
+    public CommonResult type(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        List<EnforcementEventsVO.TypeAndSourceVO1> typeVO1s = new ArrayList<>();
-        EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO();
-        EnforcementEventsVO.TypeAndSourceVO1 typeVO1 = null;
-        for (int i = 0; i < 4; i++) {
-            typeVO1 = new EnforcementEventsVO.TypeAndSourceVO1();
-            typeVO1.setName("鍥㈢粨灞�");
-            typeVO1.setCount(20);
-            typeVO1.setRatio(new BigDecimal("0.69").setScale(2, RoundingMode.HALF_UP));
-            typeVO1s.add(typeVO1);
-        }
-        typeVO.setAll(100);
-        typeVO.setRecords(typeVO1s);
-        return CommonResult.success(typeVO);
+        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);
+        return CommonResult.success(typeAndSourceVO);
     }
 
     @ApiOperation(value = "瑙嗛鎶撴媿鍛婂彂鐐逛綅")
     @GetMapping("/video")
-    public CommonResult<List<EnforcementEventsVO.VideoAndAreaVO>> video(@Validated CockpitVO params) {
+    public CommonResult video(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        List<EnforcementEventsVO.VideoAndAreaVO> videoVOS = new ArrayList<>();
-        EnforcementEventsVO.VideoAndAreaVO videoVO = null;
+        List<VideoAndAreaVO> videoVOS = new ArrayList<>();
+        VideoAndAreaVO videoVO = null;
         for (int i = 0; i < 4; i++) {
-            videoVO = new EnforcementEventsVO.VideoAndAreaVO();
+            videoVO = new VideoAndAreaVO();
             videoVO.setName("鍥㈢粨灞�");
-            videoVO.setCount(10);
+            videoVO.setCount(10L);
             videoVO.setRatio(new BigDecimal("0.65").setScale(2, RoundingMode.HALF_UP));
             videoVOS.add(videoVO);
         }
@@ -91,50 +101,38 @@
     @GetMapping("/source")
     public CommonResult<EnforcementEventsVO.TypeAndSourceVO> source(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        List<EnforcementEventsVO.TypeAndSourceVO1> typeVO1s = new ArrayList<>();
+        Long allCount = iBaseCaseService.count();
+        Long alCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getEventSource, "1"));
+        Long handCount = iBaseCaseService.count(new LambdaQueryWrapper<BaseCase>().eq(BaseCase::getEventSource, "2"));
+        List<VideoAndAreaVO> typeVO1s = new ArrayList<>();
         EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO();
-        EnforcementEventsVO.TypeAndSourceVO1 typeVO1 = null;
-        for (int i = 0; i < 4; i++) {
-            typeVO1 = new EnforcementEventsVO.TypeAndSourceVO1();
-            typeVO1.setName("鍥㈢粨灞�");
-            typeVO1.setCount(20);
-            typeVO1.setRatio(new BigDecimal("0.69").setScale(2, RoundingMode.HALF_UP));
-            typeVO1s.add(typeVO1);
-        }
-        typeVO.setAll(100);
+        VideoAndAreaVO al = new VideoAndAreaVO();
+        al.setName("瑙嗛宸℃煡");
+        al.setRatio(new BigDecimal(alCount * 1.0 / allCount).setScale(2, 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.setCount(handCount);
+        typeVO1s.add(hand);
+        typeVO.setAll(allCount);
         typeVO.setRecords(typeVO1s);
         return CommonResult.success(typeVO);
     }
 
     @ApiOperation(value = "浜嬩欢鍖哄煙缁熻")
     @GetMapping("/area")
-    public CommonResult<List<EnforcementEventsVO.VideoAndAreaVO>> area(@Validated CockpitVO params) {
+    public CommonResult area(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        List<EnforcementEventsVO.VideoAndAreaVO> videoVOS = new ArrayList<>();
-        EnforcementEventsVO.VideoAndAreaVO videoVO = null;
-        for (int i = 0; i < 4; i++) {
-            videoVO = new EnforcementEventsVO.VideoAndAreaVO();
-            videoVO.setName("鍥㈢粨灞�");
-            videoVO.setCount(10);
-            videoVOS.add(videoVO);
-        }
-        return CommonResult.success(videoVOS);
+        return CommonResult.success(iBaseCaseService.areaCount());
     }
 
     @ApiOperation(value = "寤惰浜嬩欢")
     @GetMapping("/delay")
-    public CommonResult<List<EnforcementEventsVO.DelayVO>> delay(@Validated CockpitVO params) {
+    public CommonResult delay(@Validated CockpitVO params) {
         checkApiUtil.cockpit(params);
-        List<EnforcementEventsVO.DelayVO> delayVOS = new ArrayList<>();
-        EnforcementEventsVO.DelayVO delayVO = null;
-        for (int i = 0; i < 4; i++) {
-            delayVO = new EnforcementEventsVO.DelayVO();
-            delayVO.setCode("201245555555");
-            delayVO.setDescription("鍥㈢粨灞�");
-            delayVO.setDuration(30);
-            delayVOS.add(delayVO);
-        }
-        return CommonResult.success(delayVOS);
+        return CommonResult.success(iBaseCaseService.selectDelayList());
     }
 
     @ApiOperation(value = "浜嬩欢淇℃伅")
@@ -146,8 +144,7 @@
         infoVO.setWeek(iBaseCaseService.weekCount());
         infoVO.setDispatch(iBaseCaseService.dispatchCount());
         infoVO.setIdentification(iBaseCaseService.alCount());
-        infoVO.setEvent(iBaseCaseService.selectEventList(params.getBeginTime(),params.getEndTime()));
+        infoVO.setEvent(iBaseCaseService.selectEventList(params.getBeginTime(), params.getEndTime()));
         return CommonResult.success(infoVO);
-
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0