|
|
@ -1,20 +1,28 @@ |
|
|
|
package com.ruoyi.code.camera.service.impl; |
|
|
|
package com.ruoyi.code.camera.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RuntimeUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.ruoyi.code.camera.domain.CameraBrand; |
|
|
|
|
|
|
|
import com.ruoyi.code.camera.service.ICameraBrandService; |
|
|
|
import com.ruoyi.code.sctaationinfo.domain.ScStationInfo; |
|
|
|
import com.ruoyi.code.sctaationinfo.domain.ScStationInfo; |
|
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig; |
|
|
|
import com.ruoyi.common.core.page.R; |
|
|
|
import com.ruoyi.common.core.page.R; |
|
|
|
import com.ruoyi.common.utils.Query; |
|
|
|
import com.ruoyi.common.utils.Query; |
|
|
|
import com.ruoyi.code.camera.domain.Camera; |
|
|
|
import com.ruoyi.code.camera.domain.Camera; |
|
|
|
import com.ruoyi.code.camera.mapper.CameraMapper; |
|
|
|
import com.ruoyi.code.camera.mapper.CameraMapper; |
|
|
|
import com.ruoyi.code.camera.service.ICameraService; |
|
|
|
import com.ruoyi.code.camera.service.ICameraService; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
|
|
|
|
import com.ruoyi.common.utils.http.HttpUtils; |
|
|
|
import com.sun.jna.NativeLong; |
|
|
|
import com.sun.jna.NativeLong; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import utils.CameraUtil; |
|
|
|
import utils.CameraUtil; |
|
|
|
import utils.RegisterUtil; |
|
|
|
import utils.RegisterUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
@ -29,6 +37,9 @@ import java.util.Map; |
|
|
|
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService |
|
|
|
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ICameraBrandService iCameraBrandService; |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R queryPage(Map<String, Object> params) { |
|
|
|
public R queryPage(Map<String, Object> params) { |
|
|
|
IPage<Camera> page = baseMapper.queryPage( |
|
|
|
IPage<Camera> page = baseMapper.queryPage( |
|
|
@ -144,4 +155,35 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme |
|
|
|
public Camera getCameraBySid(Long sid) { |
|
|
|
public Camera getCameraBySid(Long sid) { |
|
|
|
return baseMapper.queryCameraBYSid(sid); |
|
|
|
return baseMapper.queryCameraBYSid(sid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void pullRtspPhoto(){ |
|
|
|
|
|
|
|
String path = RuoYiConfig.getProfile() + File.separator; |
|
|
|
|
|
|
|
String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + File.separator; |
|
|
|
|
|
|
|
String currentTime = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".jpg"; |
|
|
|
|
|
|
|
List<Camera> list = list(new QueryWrapper<Camera>().eq("access_type","1")); |
|
|
|
|
|
|
|
for (Camera camera : list) { |
|
|
|
|
|
|
|
boolean isPing = HttpUtils.checkPing(camera.getIp()); |
|
|
|
|
|
|
|
System.out.println(camera.getIp()+" isPing = "+isPing); |
|
|
|
|
|
|
|
if(isPing){ |
|
|
|
|
|
|
|
camera.setStatus(1); |
|
|
|
|
|
|
|
CameraBrand cameraBrand = iCameraBrandService.getById(camera.getBrand()); |
|
|
|
|
|
|
|
String fileName = path+camera.getDevsn()+File.separator+currentDate; |
|
|
|
|
|
|
|
File file = new File(fileName); |
|
|
|
|
|
|
|
if (!file.exists()) { |
|
|
|
|
|
|
|
file.mkdirs(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String ffmpeg = "ffmpeg -i rtsp://"+camera.getUsername()+":"+camera.getPassword()+"@"+camera.getIp()+cameraBrand.getRtsp()+" -y -f image2 -t 0.001 "+fileName+currentTime+""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("ffmpeg="+ffmpeg); |
|
|
|
|
|
|
|
RuntimeUtil.execForStr(ffmpeg); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
camera.setStatus(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!list.isEmpty()){ |
|
|
|
|
|
|
|
updateBatchById(list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("ffmpeg 执行结束"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|