package com.ycl.controller.cockpit.aiIot; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ycl.api.CommonResult; import com.ycl.entity.video.VideoPoint; 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.EfficiencyVO; import com.ycl.vo.cockpit.aiIot.VideoVO; 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; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @author Lyq * @version 1.0 * @date 2022/10/26 */ @Api(tags = "驾驶舱数据接口-AI物联") @RestController @RequestMapping("/api/lot") public class AIIotController { @Resource private CheckApiUtil checkApiUtil; @Autowired private IVideoPointService iVideoPointService; @Autowired private VideoUtil videoUtil; @Autowired IHandheldTerminalService iHandheldTerminalService; @Autowired ILoudspeakerService loudspeakerService; @Autowired ICarSlagcarService iCarSlagcarService; @ApiOperation(value = "监测数据") @GetMapping("/detection") public CommonResult detection(@Validated CockpitVO params) { checkApiUtil.cockpit(params); AIIotVO.DetectionVO detectionVO = new AIIotVO.DetectionVO(); detectionVO.setVideo(iVideoPointService.count()); detectionVO.setIndividual(iHandheldTerminalService.count()); detectionVO.setLampblack(154L); /// TODO: 2022/12/13 缺少油烟机监控表 detectionVO.setLoudspeaker(loudspeakerService.count()); detectionVO.setSlagCar(iCarSlagcarService.count()); return CommonResult.success(detectionVO); } @ApiOperation(value = "实时视频监控") @GetMapping("/video") public CommonResult video(@Validated CockpitVO params) { checkApiUtil.cockpit(params); /// TODO: 2022/12/13 视频点位设备为空 没数据 List list = iVideoPointService.list(new LambdaQueryWrapper() .eq(params.getStreetId() != null, VideoPoint::getStreetId, params.getStreetId()) .isNotNull(VideoPoint::getPlatResourceId)); List 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() != null ? item.getLatitude().toString() : ""); videoVO.setLongitude(item.getLongitude() != null ? item.getLongitude().toString() : ""); videoVO.setResourceId(item.getPlatResourceId()); return videoVO; }).collect(Collectors.toList()); return CommonResult.success(vos); } @ApiOperation(value = "AI算法效能") @GetMapping("/efficiency") public CommonResult efficiency(@Validated CockpitVO params) { checkApiUtil.cockpit(params); List efficiencyVOS = new ArrayList<>(); for (int i = 0; i < 4; i++) { EfficiencyVO a = new EfficiencyVO(); a.setType("道路破损"); a.setCount(12); a.setRatio(new BigDecimal("0.63").setScale(2, RoundingMode.HALF_UP)); efficiencyVOS.add(a); } return CommonResult.success(efficiencyVOS); } @ApiOperation(value = "渣土联动") @GetMapping("/slag_car") public CommonResult slagCar(@Validated CockpitVO params) { checkApiUtil.cockpit(params); AIIotVO.SlagCarVO slagCarVO = new AIIotVO.SlagCarVO(); slagCarVO.setCar(236); slagCarVO.setTeam(20); return CommonResult.success(slagCarVO); } @ApiOperation(value = "AI事件统计") @GetMapping("/event_statistics") public CommonResult> statistics(@Validated CockpitVO params) { checkApiUtil.cockpit(params); List statisticsVOS = new ArrayList<>(); List 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); } }