Pu Zhibing
2025-07-23 1ee76c252f2dbba62e0ec34cccf9eaac51de9083
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CarServiceImpl.java
@@ -26,7 +26,6 @@
import com.ruoyi.system.service.ICarTypeService;
import com.ruoyi.system.service.IDriverService;
import com.ruoyi.system.service.IEnterpriseService;
import com.ruoyi.system.util.JavaCVStreamUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -38,8 +37,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
@@ -84,8 +81,13 @@
      }
      List<Enterprise> list1 = enterpriseService.list();
      List<Driver> driverList = driverService.list(new LambdaQueryWrapper<Driver>().eq(Driver::getStatus, 1));
      List<Car> list2 = this.list();
      List<Car> carList = new ArrayList<>();
      for (UPExgMsgRegisterVo vo : list) {
         Optional<Car> first = list2.stream().filter(s -> s.getVehicleNumber().equals(vo.getVehicleNo())).findFirst();
         if(first.isPresent()){
            continue;
         }
         car = new Car();
         car.setVehicleNumber(vo.getVehicleNo());
         car.setLicensePlateColor(VehicleColorEnum.getName(vo.getVehicleColor()));
@@ -187,26 +189,7 @@
   }
   
   
   /**
    * 检测视频播放,清除没有播放的视频流
    */
   @Override
   public void taskPlayDetection(Integer deviceNumber) {
      Car car = this.getById(deviceNumber);
      try {
         ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
         executorService.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
               if(!redisTemplate.hasKey("live:" + car.getId())){
                  String folderPath = hlsOutputPath + "hls\\" + car.getVehicleNumber();
                  JavaCVStreamUtil.close(car.getId(), folderPath);
               }
            }}, 1, 1, TimeUnit.MINUTES);
      }catch (Exception e){
         e.printStackTrace();
      }
   }