| | |
| | | package com.ycl.controller.cockpit.aiIot; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.dto.allot.EfficiencyDto; |
| | | import com.ycl.entity.video.VideoPoint; |
| | | import com.ycl.service.allot.IEfficiencyService; |
| | | import com.ycl.service.carManage.ICarSlagcarService; |
| | | import com.ycl.service.equipment.IHandheldTerminalService; |
| | | import com.ycl.service.equipment.ILoudspeakerService; |
| | | import com.ycl.service.video.impl.IVideoPointService; |
| | | import com.ycl.util.CheckApiUtil; |
| | | import com.ycl.util.VideoUtil; |
| | | import com.ycl.vo.cockpit.CockpitVO; |
| | | import com.ycl.vo.cockpit.aiIot.AIIotVO; |
| | | import com.ycl.vo.cockpit.aiIot.VideoVO; |
| | | import com.ycl.vo.cockpit.aiIot.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.function.Function; |
| | | import java.util.function.ToIntFunction; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private IVideoPointService iVideoPointService; |
| | | @Autowired |
| | | private VideoUtil videoUtil; |
| | | @Autowired |
| | | IHandheldTerminalService iHandheldTerminalService; |
| | | @Autowired |
| | | ILoudspeakerService loudspeakerService; |
| | | @Autowired |
| | | ICarSlagcarService iCarSlagcarService; |
| | | @Autowired |
| | | IEfficiencyService iEfficiencyService; |
| | | |
| | | |
| | | @ApiOperation(value = "监测数据") |
| | | @GetMapping("/detection") |
| | | public CommonResult<AIIotVO.DetectionVO> detection(@Validated CockpitVO params) { |
| | | checkApiUtil.cockpit(params); |
| | | AIIotVO.DetectionVO detectionVO = new AIIotVO.DetectionVO(); |
| | | detectionVO.setVideo(121); |
| | | detectionVO.setIndividual(20); |
| | | detectionVO.setLampblack(154); |
| | | detectionVO.setLoudspeaker(30); |
| | | detectionVO.setSlagCar(33); |
| | | detectionVO.setVideo(iVideoPointService.count()); |
| | | detectionVO.setIndividual(iHandheldTerminalService.count()); |
| | | detectionVO.setLampblack(iEfficiencyService.getSmokeCustomer()); |
| | | |
| | | detectionVO.setLoudspeaker(34L); |
| | | detectionVO.setSlagCar(iCarSlagcarService.count()); |
| | | return CommonResult.success(detectionVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "实时视频监控") |
| | | @GetMapping("/video") |
| | | public CommonResult video(@Validated CockpitVO params) { |
| | | //checkApiUtil.cockpit(params); |
| | | return CommonResult.success(iVideoPointService.list().stream().map(item -> { |
| | | checkApiUtil.cockpit(params); |
| | | /// TODO: 2022/12/13 视频点位设备为空 没数据 |
| | | List<VideoPoint> list = iVideoPointService.list(new LambdaQueryWrapper<VideoPoint>() |
| | | .eq(params.getStreetId() != null, VideoPoint::getStreetId, params.getStreetId()) |
| | | .isNotNull(VideoPoint::getPlatResourceId).orderByDesc(VideoPoint::getId)); |
| | | |
| | | List<VideoVO> vos = list.stream().map(item -> { |
| | | VideoVO videoVO = new VideoVO(); |
| | | videoVO.setName(item.getName()); |
| | | videoVO.setBrand(item.getEquipmentBrand()); |
| | | videoVO.setModel(item.getEquipmentModel()); |
| | | videoVO.setIp(item.getEquipmentIp()); |
| | | videoVO.setLatitude(item.getLatitude().toString()); |
| | | videoVO.setLongitude(item.getLongitude().toString()); |
| | | videoVO.setUrl(videoUtil.getVideo(item.getPlatResourceId(), "HLS", 0)); |
| | | videoVO.setLatitude(item.getLatitude() != null ? item.getLatitude().toString() : ""); |
| | | videoVO.setLongitude(item.getLongitude() != null ? item.getLongitude().toString() : ""); |
| | | videoVO.setResourceId(item.getPlatResourceId()); |
| | | videoVO.setCode(item.getCode()); |
| | | return videoVO; |
| | | }).collect(Collectors.toList())); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | return CommonResult.success(vos); |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "AI算法效能") |
| | | @GetMapping("/efficiency") |
| | | public CommonResult<List<AIIotVO.EfficiencyVO>> efficiency(@Validated CockpitVO params) { |
| | | public CommonResult efficiency(@Validated CockpitVO params) { |
| | | checkApiUtil.cockpit(params); |
| | | List<AIIotVO.EfficiencyVO> efficiencyVOS = new ArrayList<>(); |
| | | AIIotVO.EfficiencyVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | | a = new AIIotVO.EfficiencyVO(); |
| | | a.setType("道路破损"); |
| | | a.setCount(12); |
| | | a.setRatio(new BigDecimal("0.63").setScale(2, RoundingMode.HALF_UP)); |
| | | efficiencyVOS.add(a); |
| | | } |
| | | List<EfficiencyDto> list = iEfficiencyService.list(); |
| | | List<EfficiencyVO> efficiencyVOS = list.stream().map((Function<EfficiencyDto, EfficiencyVO>) efficiencyDto -> { |
| | | EfficiencyVO a = new EfficiencyVO(); |
| | | a.setType(efficiencyDto.getName()); |
| | | a.setCount(efficiencyDto.getNumber()); |
| | | a.setRatio(1.0 - ((double) efficiencyDto.getErrorNumber() / (double) efficiencyDto.getNumber())); |
| | | return a; |
| | | }).collect(Collectors.toList()); |
| | | efficiencyVOS.add(new EfficiencyVO("店外经营", 0, 0.0)); |
| | | efficiencyVOS.add(new EfficiencyVO("沿街晾晒", 0, 0.0)); |
| | | efficiencyVOS.add(new EfficiencyVO("无照经营游商", 0, 0.0)); |
| | | efficiencyVOS.add(new EfficiencyVO("违规撑伞", 0, 0.0)); |
| | | return CommonResult.success(efficiencyVOS); |
| | | } |
| | | |
| | |
| | | @GetMapping("/slag_car") |
| | | public CommonResult<AIIotVO.SlagCarVO> slagCar(@Validated CockpitVO params) { |
| | | checkApiUtil.cockpit(params); |
| | | |
| | | AIIotVO.SlagCarVO slagCarVO = new AIIotVO.SlagCarVO(); |
| | | slagCarVO.setCar(236); |
| | | slagCarVO.setTeam(20); |
| | | slagCarVO.setCar(iCarSlagcarService.count()); |
| | | slagCarVO.setTeam(0L); |
| | | |
| | | return CommonResult.success(slagCarVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "AI事件统计") |
| | | @GetMapping("/event_statistics") |
| | | public CommonResult<List<AIIotVO.StatisticsVO>> statistics(@Validated CockpitVO params) { |
| | | public CommonResult<List<AIIotStatisticsVO>> statistics(@Validated CockpitVO params) { |
| | | checkApiUtil.cockpit(params); |
| | | List<AIIotVO.StatisticsVO> statisticsVOS = new ArrayList<>(); |
| | | List<AIIotVO.Statistics1VO> statistics1VOS = new ArrayList<>(); |
| | | AIIotVO.StatisticsVO a = null; |
| | | AIIotVO.Statistics1VO a1 = null; |
| | | for (int i = 0; i < 4; i++) { |
| | | a = new AIIotVO.StatisticsVO(); |
| | | a1 = new AIIotVO.Statistics1VO(); |
| | | a.setType("道路破损"); |
| | | a1.setCount(12); |
| | | a1.setMonth("2022-10"); |
| | | statistics1VOS.add(a1); |
| | | a.setRecords(statistics1VOS); |
| | | statisticsVOS.add(a); |
| | | } |
| | | return CommonResult.success(statisticsVOS); |
| | | |
| | | List<AIIotStatisticsVO> list = iEfficiencyService.aiMonthList(params.getBeginTime(), params.getEndTime()); |
| | | // List<AIIotStatisticsVO> list = new ArrayList<>(); |
| | | // AIIotStatisticsVO a1 = new AIIotStatisticsVO(); |
| | | // String type1 = "非机动车乱停放"; |
| | | // List<AIIotStatisticsRecordVO> records1 = new ArrayList<>(); |
| | | // AIIotStatisticsRecordVO ai1 = new AIIotStatisticsRecordVO(); |
| | | // ai1.setMonth("2024-01"); |
| | | // ai1.setCount(210); |
| | | // AIIotStatisticsRecordVO ai2 = new AIIotStatisticsRecordVO(); |
| | | // ai2.setMonth("2023-12"); |
| | | // ai2.setCount(183); |
| | | // AIIotStatisticsRecordVO ai3 = new AIIotStatisticsRecordVO(); |
| | | // ai3.setMonth("2023-11"); |
| | | // ai3.setCount(157); |
| | | // AIIotStatisticsRecordVO ai4 = new AIIotStatisticsRecordVO(); |
| | | // ai4.setMonth("2023-10"); |
| | | // ai4.setCount(231); |
| | | // AIIotStatisticsRecordVO ai5 = new AIIotStatisticsRecordVO(); |
| | | // ai5.setMonth("2023-09"); |
| | | // ai5.setCount(256); |
| | | // AIIotStatisticsRecordVO ai6 = new AIIotStatisticsRecordVO(); |
| | | // ai6.setMonth("2023-08"); |
| | | // ai6.setCount(311); |
| | | // records1.add(ai1); |
| | | // records1.add(ai2); |
| | | // records1.add(ai3); |
| | | // records1.add(ai4); |
| | | // records1.add(ai5); |
| | | // records1.add(ai6); |
| | | // a1.setType(type1); |
| | | // a1.setRecords(records1); |
| | | // list.add(a1); |
| | | // |
| | | // AIIotStatisticsVO a2 = new AIIotStatisticsVO(); |
| | | // String type2 = "店外经营"; |
| | | // List<AIIotStatisticsRecordVO> records2 = new ArrayList<>(); |
| | | // AIIotStatisticsRecordVO bi1 = new AIIotStatisticsRecordVO(); |
| | | // bi1.setMonth("2024-01"); |
| | | // bi1.setCount(273); |
| | | // AIIotStatisticsRecordVO bi2 = new AIIotStatisticsRecordVO(); |
| | | // bi2.setMonth("2023-12"); |
| | | // bi2.setCount(231); |
| | | // AIIotStatisticsRecordVO bi3 = new AIIotStatisticsRecordVO(); |
| | | // bi3.setMonth("2023-11"); |
| | | // bi3.setCount(303); |
| | | // AIIotStatisticsRecordVO bi4 = new AIIotStatisticsRecordVO(); |
| | | // bi4.setMonth("2023-10"); |
| | | // bi4.setCount(219); |
| | | // AIIotStatisticsRecordVO bi5 = new AIIotStatisticsRecordVO(); |
| | | // bi5.setMonth("2023-09"); |
| | | // bi5.setCount(245); |
| | | // AIIotStatisticsRecordVO bi6 = new AIIotStatisticsRecordVO(); |
| | | // bi6.setMonth("2023-08"); |
| | | // bi6.setCount(223); |
| | | // records2.add(bi1); |
| | | // records2.add(bi2); |
| | | // records2.add(bi3); |
| | | // records2.add(bi4); |
| | | // records2.add(bi5); |
| | | // records2.add(bi6); |
| | | // a2.setType(type2); |
| | | // a2.setRecords(records2); |
| | | // list.add(a2); |
| | | // |
| | | // AIIotStatisticsVO a3 = new AIIotStatisticsVO(); |
| | | // String type3 = "无照经营游商"; |
| | | // List<AIIotStatisticsRecordVO> records3 = new ArrayList<>(); |
| | | // AIIotStatisticsRecordVO ci1 = new AIIotStatisticsRecordVO(); |
| | | // ci1.setMonth("2024-01"); |
| | | // ci1.setCount(313); |
| | | // AIIotStatisticsRecordVO ci2 = new AIIotStatisticsRecordVO(); |
| | | // ci2.setMonth("2023-12"); |
| | | // ci2.setCount(247); |
| | | // AIIotStatisticsRecordVO ci3 = new AIIotStatisticsRecordVO(); |
| | | // ci3.setMonth("2023-11"); |
| | | // ci3.setCount(267); |
| | | // AIIotStatisticsRecordVO ci4 = new AIIotStatisticsRecordVO(); |
| | | // ci4.setMonth("2023-10"); |
| | | // ci4.setCount(249); |
| | | // AIIotStatisticsRecordVO ci5 = new AIIotStatisticsRecordVO(); |
| | | // ci5.setMonth("2023-09"); |
| | | // ci5.setCount(265); |
| | | // AIIotStatisticsRecordVO ci6 = new AIIotStatisticsRecordVO(); |
| | | // ci6.setMonth("2023-08"); |
| | | // ci6.setCount(306); |
| | | // records3.add(ci1); |
| | | // records3.add(ci2); |
| | | // records3.add(ci3); |
| | | // records3.add(ci4); |
| | | // records3.add(ci5); |
| | | // records3.add(ci6); |
| | | // a3.setType(type3); |
| | | // a3.setRecords(records3); |
| | | // list.add(a3); |
| | | // |
| | | // |
| | | // AIIotStatisticsVO a4 = new AIIotStatisticsVO(); |
| | | // String type4 = "占道经营"; |
| | | // List<AIIotStatisticsRecordVO> records4 = new ArrayList<>(); |
| | | // AIIotStatisticsRecordVO di1 = new AIIotStatisticsRecordVO(); |
| | | // di1.setMonth("2024-01"); |
| | | // di1.setCount(267); |
| | | // AIIotStatisticsRecordVO di2 = new AIIotStatisticsRecordVO(); |
| | | // di2.setMonth("2023-12"); |
| | | // di2.setCount(347); |
| | | // AIIotStatisticsRecordVO di3 = new AIIotStatisticsRecordVO(); |
| | | // di3.setMonth("2023-11"); |
| | | // di3.setCount(354); |
| | | // AIIotStatisticsRecordVO di4 = new AIIotStatisticsRecordVO(); |
| | | // di4.setMonth("2023-10"); |
| | | // di4.setCount(314); |
| | | // AIIotStatisticsRecordVO di5 = new AIIotStatisticsRecordVO(); |
| | | // di5.setMonth("2023-09"); |
| | | // di5.setCount(317); |
| | | // AIIotStatisticsRecordVO di6 = new AIIotStatisticsRecordVO(); |
| | | // di6.setMonth("2023-08"); |
| | | // di6.setCount(274); |
| | | // records4.add(di1); |
| | | // records4.add(di2); |
| | | // records4.add(di3); |
| | | // records4.add(di4); |
| | | // records4.add(di5); |
| | | // records4.add(di6); |
| | | // a4.setType(type4); |
| | | // a4.setRecords(records4); |
| | | // list.add(a4); |
| | | |
| | | return CommonResult.success(list); |
| | | } |
| | | |
| | | |
| | | } |