Pu Zhibing
2025-04-10 0f9ecda1919beb1e8fbbca0f669ac86badf70806
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CarServiceImpl.java
@@ -19,6 +19,8 @@
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;
@@ -36,6 +38,9 @@
 */
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarService {
   @Value("${live.output.path}")
   private String outputPath;
   
   @Resource
   private UPExgMsgRegisterClient upExgMsgRegisterClient;
@@ -151,4 +156,21 @@
         }
      }
   }
   /**
    * 检测视频播放,清除没有播放的视频流
    */
   @Override
   public void taskPlayDetection() {
      List<Car> list = this.list();
      for (Car car : list) {
         if(!redisTemplate.hasKey("live:" + car.getId())){
            String folderPath = outputPath + "hls\\" + car.getVehicleNumber();
            JavaCVStreamUtil.close(car.getId(), folderPath);
         }
      }
   }
}