zhanghua
2023-04-14 e8a0f05f99f33fa05085536541da6bc27e66a644
ycl-platform/src/main/java/com/ycl/controller/cockpit/aiIot/AIIotController.java
@@ -1,16 +1,27 @@
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.AIIotStatisticsVO;
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.ApiImplicitParam;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@@ -18,6 +29,9 @@
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;
/**
 * @author Lyq
@@ -32,53 +46,76 @@
    @Resource
    private CheckApiUtil checkApiUtil;
    @Autowired
    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<List<AIIotVO.VideoVO>> video(@Validated CockpitVO params) {
    public CommonResult video(@Validated CockpitVO params) {
        checkApiUtil.cockpit(params);
        List<AIIotVO.VideoVO> videoVOS = new ArrayList<>();
        AIIotVO.VideoVO a = null;
        for (int i = 0; i < 4; i++) {
            a = new AIIotVO.VideoVO();
            a.setLongitude("32.11");
            a.setLatitude("106.111");
            a.setName("设备一");
            a.setResourceId("012");
            a.setBrand("大华");
            a.setModel("球机");
            a.setIp("10.23.14.2");
            a.setUrl("http://10.23.14.2:12001");
            videoVOS.add(a);
        }
        return CommonResult.success(videoVOS);
        /// 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() != 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());
        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);
    }
@@ -86,31 +123,21 @@
    @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());
        return CommonResult.success(list);
    }