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/statisticsEvents/StatisticsEventsController.java | 182 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 160 insertions(+), 22 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java b/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java index 21d3745..330f40c 100644 --- a/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java +++ b/ycl-platform/src/main/java/com/ycl/controller/cockpit/statisticsEvents/StatisticsEventsController.java @@ -1,11 +1,23 @@ package com.ycl.controller.cockpit.statisticsEvents; +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.api.CommonResult; +import com.ycl.entity.cockpitManage.TeamConstruction; +import com.ycl.entity.cockpitManage.TeamIndex; +import com.ycl.service.apidata.IApiDataService; +import com.ycl.service.cockpitManage.ITeamConstructionService; +import com.ycl.service.equipment.IOrgGridService; +import com.ycl.service.video.impl.IVideoPointService; import com.ycl.util.CheckApiUtil; import com.ycl.vo.cockpit.CockpitVO; +import com.ycl.vo.cockpit.statisticsEvents.GridMapVO; import com.ycl.vo.cockpit.statisticsEvents.StatisticsEventsVO; +import com.ycl.vo.equipment.VideoPointVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -29,10 +41,39 @@ @Resource private CheckApiUtil checkApiUtil; + private IVideoPointService videoPointService; + + private ITeamConstructionService teamConstructionService; + + private IOrgGridService orgGridService; + + + private IApiDataService iApiDataService; + + @Autowired + public void setIApiDataService(IApiDataService apiDataService) { + this.iApiDataService = apiDataService; + } + + @Autowired + public void setTeamConstructionService(ITeamConstructionService teamConstructionService) { + this.teamConstructionService = teamConstructionService; + } + + @Autowired + public void setVideoPointService(IVideoPointService videoPointService) { + this.videoPointService = videoPointService; + } + + @Autowired + public void setOrgGridService(IOrgGridService orgGridService) { + this.orgGridService = orgGridService; + } + @ApiOperation(value = "鎵ф硶浜嬩欢") @GetMapping("/law_enforcement_event") - public CommonResult<List<StatisticsEventsVO.LawEnforcementEventVO>> detection(@Validated CockpitVO.Params2VO params) { - checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); + public CommonResult<List<StatisticsEventsVO.LawEnforcementEventVO>> detection(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); List<StatisticsEventsVO.LawEnforcementEventVO> lawEnforcementEventVOS = new ArrayList<>(); StatisticsEventsVO.LawEnforcementEventVO a = null; for (int i = 0; i < 4; i++) { @@ -48,24 +89,17 @@ @ApiOperation(value = "鐗╄仈鎰熺煡") @GetMapping("/lot") - public CommonResult<List<StatisticsEventsVO.LotVO>> lot(@Validated CockpitVO.Params1VO params) { - checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); - List<StatisticsEventsVO.LotVO> lotVOS = new ArrayList<>(); - StatisticsEventsVO.LotVO a = null; - for (int i = 0; i < 4; i++) { - a = new StatisticsEventsVO.LotVO(); - a.setName("鍥㈢粨灞�"); - a.setType("鎽勫儚澶�"); - a.setCount(10); - lotVOS.add(a); - } + public CommonResult<List<StatisticsEventsVO.LotVO>> lot(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + List<StatisticsEventsVO.LotVO> lotVOS = iApiDataService.listLot(params.getStreetId(), params.getBeginTime(), params.getEndTime()); + return CommonResult.success(lotVOS); } @ApiOperation(value = "鎵ф硶闃熶紞") @GetMapping("/team") - public CommonResult<StatisticsEventsVO.TeamVO> team(@Validated CockpitVO.Params1VO params) { - checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); + public CommonResult<StatisticsEventsVO.TeamVO> team(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); StatisticsEventsVO.TeamVO teamVO = new StatisticsEventsVO.TeamVO(); teamVO.setAll(30); teamVO.setAssistant(10); @@ -78,13 +112,13 @@ @ApiOperation(value = "缃戞牸鍛�") @GetMapping("/grid_member") - public CommonResult<List<StatisticsEventsVO.GridMemberVO>> gridMember(@Validated CockpitVO.Params1VO params) { - checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); + public CommonResult<List<StatisticsEventsVO.GridMemberVO>> gridMember(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); List<StatisticsEventsVO.GridMemberVO> gridMemberVOS = new ArrayList<>(); StatisticsEventsVO.GridMemberVO a = null; for (int i = 0; i < 4; i++) { a = new StatisticsEventsVO.GridMemberVO(); - a.setRatio(new BigDecimal("0.20").setScale(2, RoundingMode.HALF_UP)); + a.setRatio(new BigDecimal("0.20").setScale(4, RoundingMode.HALF_UP)); a.setName("鍥㈢粨灞�"); a.setCount(10); gridMemberVOS.add(a); @@ -94,14 +128,14 @@ @ApiOperation(value = "鎸囨暟浣撳緛") @GetMapping("/index_signs") - public CommonResult<StatisticsEventsVO.IndexSignsVO> indexSigns(@Validated CockpitVO.Params1VO params) { - checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); + public CommonResult<StatisticsEventsVO.IndexSignsVO> indexSigns(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); StatisticsEventsVO.IndexSignsVO indexSignsVO = new StatisticsEventsVO.IndexSignsVO(); indexSignsVO.setEvent(1); indexSignsVO.setGridMember(20); - indexSignsVO.setCompletePercentage(new BigDecimal("0.60").setScale(2, RoundingMode.HALF_UP)); + indexSignsVO.setCompletePercentage(new BigDecimal("0.60").setScale(4, RoundingMode.HALF_UP)); indexSignsVO.setEquipment(30); - indexSignsVO.setAccuracy(new BigDecimal("0.80").setScale(2, RoundingMode.HALF_UP)); + indexSignsVO.setAccuracy(new BigDecimal("0.80").setScale(4, RoundingMode.HALF_UP)); indexSignsVO.setTrigger(10); indexSignsVO.setLot(30); indexSignsVO.setLotOnline(10); @@ -109,4 +143,108 @@ indexSignsVO.setEvaluationData(10); return CommonResult.success(indexSignsVO); } + + + @ApiOperation(value = "top10") + @GetMapping("/top10") + public CommonResult<List<StatisticsEventsVO.Top10VO>> top10(@Validated CockpitVO params) { +// checkApiUtil.cockpit(params); +// List<StatisticsEventsVO.Top10VO> ls = new ArrayList<>(); +// ls.add(new StatisticsEventsVO.Top10VO("xx涓槦", 100.0)); +// ls.add(new StatisticsEventsVO.Top10VO("xx涓槦", 90.0)); +// ls.add(new StatisticsEventsVO.Top10VO("xx涓槦", 80.0)); +// ls.add(new StatisticsEventsVO.Top10VO("xx涓槦", 70.0)); +// return CommonResult.success(ls); + String beginTime = params.getBeginTime(); + String endTime = params.getEndTime(); + List<StatisticsEventsVO.Top10VO> res = iApiDataService.listTop10(beginTime, endTime); + return CommonResult.success(res); + } + + + @ApiOperation(value = "AI绠楁硶") + @GetMapping("/arithmetic_event") + public CommonResult<List<StatisticsEventsVO.ArithmeticVO>> arithmeticEvent(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + List<StatisticsEventsVO.ArithmeticVO> ls = iApiDataService.arithmeticEvent(params.getStreetId(), params.getBeginTime(), params.getEndTime()); + + return CommonResult.success(ls); + } + + + @ApiOperation(value = "鍩庡競浣撳緛鐪嬫澘") + @GetMapping("/city_panel") + public CommonResult<StatisticsEventsVO.CityPanelVo> cityPanel(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + + StatisticsEventsVO.CityPanelVo vo = new StatisticsEventsVO.CityPanelVo(92, true, 22, false, 12, true, + 22, false, 34, true, 99, false, 9, true, + 34, false, 6, true); + + return CommonResult.success(vo); + } + + + @ApiOperation(value = "鐐逛綅") + @GetMapping("/video_point") + public CommonResult<List<VideoPointVo>> videoPoint(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + IPage<VideoPointVo> page = videoPointService.getList(null, null, 1, 500); + return CommonResult.success(page.getRecords()); + } + + @ApiOperation(value = "缃戞牸鍦板浘") + @GetMapping("/grid_map") + public CommonResult<List<GridMapVO>> gridMap(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + + List<GridMapVO> list = orgGridService.statisticsGridMap(params.getBeginTime(), params.getEndTime()); + return CommonResult.success(list); + } + + @ApiOperation(value = "闃熶紞寤鸿") + @GetMapping("/team_construction") + public CommonResult<List<TeamConstruction>> teamConstruction(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0); + List<TeamConstruction> list = teamConstructionService.list(queryWrapper); + return CommonResult.success(list); + } + + + @ApiOperation(value = "涓槦鎸囨暟浣撳緛") + @GetMapping("/team_index") + public CommonResult<List<TeamIndex>> teamIndex(@Validated CockpitVO params) { + checkApiUtil.cockpit(params); + + // LambdaQueryWrapper<TeamConstruction> queryWrapper = new LambdaQueryWrapper<TeamConstruction>().eq(TeamConstruction::getStatus, 1).eq(TeamConstruction::getIsDelete, 0); + // List<TeamConstruction> list = teamConstructionService.list(queryWrapper); + // List<TeamIndex> teamIndexList = BeanUtil.copyToList(list, TeamIndex.class); + // teamIndexList.forEach(o -> { + // o.setStepTimely(0.0); + // o.setStepDelayed(0.0); + // o.setStepOvertime(0.0); + // o.setHandleTimely(0.0); + // o.setHandleDelayed(0.0); + // o.setHandleOvertime(0.0); + // o.setNoHandle(0.0); + // }); + List<TeamIndex> teamIndexList = teamConstructionService.teamIndex(params.getBeginTime(), params.getEndTime()); + teamIndexList.forEach(o -> { + + o.setAllocation(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount()) + + 18 * ((double) o.getOverCount() / (double) o.getAllCount()) + + 15 * ((double) o.getNoHandleCount() / (double) o.getAllCount())); + o.setHandle(20 * ((double) o.getPunctualityCount() / (double) o.getAllCount()) + + 5 * ((double) o.getOverCount() / (double) o.getAllCount()) + - 2 * ((double) o.getNoHandleCount() / (double) o.getAllCount())); + + o.setOnline(0.0); + o.setDuration(0.0); + o.setDistance(0.0); + }); + return CommonResult.success(teamIndexList); + } } + + -- Gitblit v1.8.0