|
|
|
@ -255,4 +255,65 @@ public class DevopsVideoInfoServiceImpl extends ServiceImpl<DevopsVideoInfoMappe
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String drzfjly(DevopsVideoInfoDto bean){
|
|
|
|
|
String type = StringKit.toString(bean.getType());
|
|
|
|
|
type = "gbs";
|
|
|
|
|
if ("".equals(type)) {
|
|
|
|
|
return "error-导入类型未设置";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("gbs".equals(type)) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
String gbsip = PropertiesUtil.queryPropertiesByKey("gbsIp");
|
|
|
|
|
String gbsport = PropertiesUtil.queryPropertiesByKey("gbsPort");
|
|
|
|
|
|
|
|
|
|
String loginurl = "http://" + gbsip + ":" + gbsport + "/api/v1/login?username=admin&password=af7548eedff8e737c0e4b2a669497290#&url_token_only=true";
|
|
|
|
|
|
|
|
|
|
String res = JsoupUtils.getJsoupDocGet(loginurl);
|
|
|
|
|
JSONObject loginResJson = JSON.parseObject(res);
|
|
|
|
|
String urlToken = "";
|
|
|
|
|
if (loginResJson != null) {
|
|
|
|
|
urlToken = StringKit.toString(loginResJson.get("URLToken"));
|
|
|
|
|
}
|
|
|
|
|
//如果urltoken获取失败直接结束方法
|
|
|
|
|
if ("".equals(urlToken)) {
|
|
|
|
|
return "urltoken 获取失败!请检查配置文件是否正确";
|
|
|
|
|
}
|
|
|
|
|
List<DevopsVideoStatus> list = videoStatusService.lambdaQuery().like(DevopsVideoStatus::getDeviceName, "执法记录仪").list();
|
|
|
|
|
logger.info("执法记录仪数量:"+list.size());
|
|
|
|
|
for (DevopsVideoStatus devopsVideoStatus : list){
|
|
|
|
|
String channellistUrl = "http://" + gbsip + ":" + gbsport + "/api/v1/stream/start?token=" + urlToken + "&serial=32092400002005063063&code="+devopsVideoStatus.getGbsChannelNo();
|
|
|
|
|
logger.info("channellistUrl:"+ channellistUrl);
|
|
|
|
|
String channellistRes = JsoupUtils.getJsoupDocGet(channellistUrl);
|
|
|
|
|
if ("".equals(StringKit.toString(channellistRes)) || (StringKit.toString(channellistRes)).contains("error")) {
|
|
|
|
|
logger.info("视频流读取失败");
|
|
|
|
|
devopsVideoStatus.setIsOnline(2);
|
|
|
|
|
QueryWrapper<DevopsVideoStatus> devopsVideoStatusQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
devopsVideoStatusQueryWrapper.eq("gbs_channel_no",StringKit.toString(devopsVideoStatus.getGbsChannelNo()));
|
|
|
|
|
videoStatusService.update(devopsVideoStatus,devopsVideoStatusQueryWrapper);
|
|
|
|
|
logger.info("修改成功:" + devopsVideoStatus.getGbsChannelNo());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
logger.info("视频流读取成功" + devopsVideoStatus.getGbsChannelNo());
|
|
|
|
|
if (channellistRes != null && channellistRes.contains("ChannelName")) {
|
|
|
|
|
String channelUrl = "http://" + gbsip + ":" + gbsport + "/api/v1/stream/stop?token=" + urlToken + "&serial=32092400002005063063&code="+devopsVideoStatus.getGbsChannelNo();
|
|
|
|
|
logger.info("channelUrl:"+ channelUrl);
|
|
|
|
|
String channelRes = JsoupUtils.getJsoupDocGet(channellistUrl);
|
|
|
|
|
if ("OK".equals(channelRes)){
|
|
|
|
|
logger.info("视频流关闭");
|
|
|
|
|
}
|
|
|
|
|
devopsVideoStatus.setIsOnline(1);
|
|
|
|
|
QueryWrapper<DevopsVideoStatus> devopsVideoStatusQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
devopsVideoStatusQueryWrapper.eq("gbs_channel_no",StringKit.toString(devopsVideoStatus.getGbsChannelNo()));
|
|
|
|
|
videoStatusService.update(devopsVideoStatus,devopsVideoStatusQueryWrapper);
|
|
|
|
|
logger.info("修改成功:" + devopsVideoStatus.getGbsChannelNo());
|
|
|
|
|
} else {
|
|
|
|
|
return "结果集为空,请检查gbs是否配置。";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "success-" + count;
|
|
|
|
|
} else {
|
|
|
|
|
return "error-类型不正确";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|