|
@@ -15,6 +15,7 @@ import com.zcxk.facilities.uitls.RedisUtil;
|
|
|
import com.zcxk.common.utils.UserUtil;
|
|
|
import com.zcxk.facilities.dao.CameraMapper;
|
|
|
import com.zcxk.facilities.service.CameraService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
|
|
|
* @since 2020-12-02 17:40:57
|
|
|
*/
|
|
|
@Service("cameraService")
|
|
|
+@Slf4j
|
|
|
public class CameraServiceImpl implements CameraService {
|
|
|
@Autowired
|
|
|
private CameraMapper cameraMapper;
|
|
@@ -48,6 +50,7 @@ public class CameraServiceImpl implements CameraService {
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
private String getTokenUrl="https://open.ys7.com/api/lapp/token/get";
|
|
|
+ private String captureUrl="https://open.ys7.com/api/lapp/device/capture";
|
|
|
@Autowired
|
|
|
private ManufacturerMapper manufacturerMapper;
|
|
|
@Autowired
|
|
@@ -304,11 +307,17 @@ public class CameraServiceImpl implements CameraService {
|
|
|
args.put("appKey",videoRecorderDTO.getAppKey());
|
|
|
args.put("appSecret",videoRecorderDTO.getAppSecret());
|
|
|
String token=getToken(args,getTokenUrl);
|
|
|
- args.clear();
|
|
|
- String findInfoUrl="https://open.ys7.com/api/lapp/device/camera/list";
|
|
|
- args.put("accessToken",token);
|
|
|
- args.put("deviceSerial",videoRecorderDTO.getDeviceSerial());
|
|
|
- JSONObject info = postRequestEntity(args, findInfoUrl);
|
|
|
+ JSONObject info=new JSONObject();
|
|
|
+ info.put("code",-1);
|
|
|
+ info.put("msg","萤石云token已经失效了");
|
|
|
+ if(token!=null){
|
|
|
+ args.clear();
|
|
|
+ String findInfoUrl="https://open.ys7.com/api/lapp/device/camera/list";
|
|
|
+ args.put("accessToken",token);
|
|
|
+ args.put("deviceSerial",videoRecorderDTO.getDeviceSerial());
|
|
|
+ info = postRequestEntity(args, findInfoUrl);
|
|
|
+ }
|
|
|
+
|
|
|
return info;
|
|
|
|
|
|
}
|
|
@@ -344,29 +353,35 @@ public class CameraServiceImpl implements CameraService {
|
|
|
JSONObject info =getDeviceChannelsInfo(videoRecorderDTO);
|
|
|
|
|
|
Integer code = info.getInteger("code");
|
|
|
- List<Camera>cameras=null;
|
|
|
+ List<Camera>cameras=new ArrayList<>();
|
|
|
if(code==200){
|
|
|
|
|
|
cameras= JSONArray.parseArray(info.getString("data"),Camera.class);
|
|
|
+ Camera queryCamera=new Camera();
|
|
|
+ queryCamera.setMonitorPointId(videoRecorderDTO.getPointId());
|
|
|
+ List<Camera> selectedCamra = cameraMapper.selectList(queryCamera);
|
|
|
+ Map<String, Integer>map=new HashMap<>();
|
|
|
+ selectedCamra.forEach(c->{
|
|
|
+ map.put(c.getDeviceSerial()+"_"+c.getChannelNo(),1);
|
|
|
+ });
|
|
|
+
|
|
|
+ cameras= cameras.stream().filter(c->{
|
|
|
+ boolean flag=true;
|
|
|
+ if(map.get(c.getDeviceSerial()+"_"+c.getChannelNo())!=null){
|
|
|
+ flag=false;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ cameras.forEach(c->{
|
|
|
+ String url="ezopen://open.ys7.com/"+c.getDeviceSerial()+"/"+c.getChannelNo()+".live";
|
|
|
+ c.setPlayUrl(url);
|
|
|
+ });
|
|
|
+
|
|
|
+ }else{
|
|
|
+ log.info("查询通道信息接口失败:"+info.toJSONString());
|
|
|
}
|
|
|
- Camera queryCamera=new Camera();
|
|
|
- queryCamera.setMonitorPointId(videoRecorderDTO.getPointId());
|
|
|
- List<Camera> selectedCamra = cameraMapper.selectList(queryCamera);
|
|
|
- Map<String, Integer>map=new HashMap<>();
|
|
|
- selectedCamra.forEach(c->{
|
|
|
- map.put(c.getDeviceSerial()+"_"+c.getChannelNo(),1);
|
|
|
- });
|
|
|
- cameras= cameras.stream().filter(c->{
|
|
|
- boolean flag=true;
|
|
|
- if(map.get(c.getDeviceSerial()+"_"+c.getChannelNo())!=null){
|
|
|
- flag=false;
|
|
|
- }
|
|
|
- return flag;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- cameras.forEach(c->{
|
|
|
- String url="ezopen://open.ys7.com/"+c.getDeviceSerial()+"/"+c.getChannelNo()+".live";
|
|
|
- c.setPlayUrl(url);
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
return cameras;
|
|
|
}
|
|
|
|
|
@@ -432,7 +447,7 @@ public class CameraServiceImpl implements CameraService {
|
|
|
public void capture(){
|
|
|
List<Camera> cameras = cameraMapper.selectAll();
|
|
|
ExecutorService executorService = Executors.newFixedThreadPool(10);
|
|
|
- String captureUrl="https://open.ys7.com/api/lapp/device/capture";
|
|
|
+
|
|
|
cameras.forEach(camera -> {
|
|
|
executorService.execute(()->{
|
|
|
catureSevice(camera,captureUrl);
|
|
@@ -619,7 +634,10 @@ public class CameraServiceImpl implements CameraService {
|
|
|
args.put("deviceSerial",camera.getDeviceSerial());
|
|
|
args.put("name",camera.getChannelName());
|
|
|
args.put("channelNo",camera.getChannelNo()+"");
|
|
|
+ //同步名称
|
|
|
postRequestEntity(args,syncNameUrl);
|
|
|
+ //抓拍
|
|
|
+ catureSevice(camera,captureUrl);
|
|
|
});
|
|
|
}
|
|
|
|