刷新执法记录仪状态

develop
hanrenchun 10 months ago
parent 8633a2b667
commit 1ca86f15b2

@ -55,4 +55,26 @@ public class DevopsVideoInfoController {
}
}
@Scheduled(initialDelay = 100, fixedDelay = 3000)
public void drzfjly(){
if (!"true".equals(ConfigParam.ZfjlyVideoInfoSwitch)) {
return;
}
DevopsVideoInfoDto villageDeviceInfo = new DevopsVideoInfoDto();
String res = "error";
try {
res = devopsVideoInfoService.drzfjly(villageDeviceInfo);
if (res.contains("success")) {
logger.info("导入成功");
} else {
logger.info("导入失败");
}
} catch (Exception e) {
logger.error(StringKit.getTrace(e) + "导入出现错误");
}
}
}

@ -36,4 +36,6 @@ public interface DevopsVideoInfoService0 extends IService<DevopsVideoInfo0> {
public String yjdr(DevopsVideoInfoDto bean);
public List<DevopsVideoInfoVo> listPoliceVehicle(DevopsVideoInfo0 bean);
public String drzfjly(DevopsVideoInfoDto bean);
}

@ -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-类型不正确";
}
}
}

Loading…
Cancel
Save