Loading src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java +18 −9 Original line number Original line Diff line number Diff line Loading @@ -41,19 +41,26 @@ public class WarnPushBaseServer { public void addMessage(String message) { public void addMessage(String message) { LOGGER.info("预警信息:" + message); LOGGER.info("预警信息:" + message); WarnPushBase warnPushBase = JSON.parseObject(message, WarnPushBase.class); WarnPushBase warnPushBase = JSON.parseObject(message, WarnPushBase.class); // if("乌海矿".equals(warnPushBase.getBelong())){ //获取视频地址 //获取视频地址 先不截取布控球的视频 String video; if(!warnPushBase.getAlarmDeviceName().contains("布控球")){ //获取前后五秒时间戳 //获取前后五秒时间戳 Date alarmTime = warnPushBase.getAlarmTime(); Date alarmTime = warnPushBase.getAlarmTime(); String video = getVideo(warnPushBase.getChannelId(), alarmTime.getTime() / 1000 - 5, alarmTime.getTime() / 1000 + 5); video = getVideo(warnPushBase.getChannelId(), alarmTime.getTime() / 1000 - 3, alarmTime.getTime() / 1000 + 3); }else{ video = "http://172.16.20.211:8080/profile/MP4/1001952$1$0$0_1698988966.mp4"; } // String video ="F:\\ruoyi\\uploadPath\\MP4"; warnPushBase.setAlarmMsg(warnPushBase.getGradeType()); warnPushBase.setAlarmMsg(warnPushBase.getGradeType()); warnPushBase.setGradeType("摄像头预警"); warnPushBase.setGradeType(warnPushBase.getGradeType()); warnPushBase.setVideo(video); warnPushBase.setVideo(video); warnPushBaseMapper.add(warnPushBase); warnPushBaseMapper.add(warnPushBase); //发送iot的http请求 //发送iot的http请求 iotPush(warnPushBase); iotPush(warnPushBase); // } } } public String getVideo(String channelId, Long startTime, Long endTime) { public String getVideo(String channelId, Long startTime, Long endTime) { Loading @@ -73,7 +80,7 @@ public class WarnPushBaseServer { }).start(); }).start(); Thread.sleep(3 * 1000); Thread.sleep(6 * 1000); rtspToMP4.stopRecord(process[0]); rtspToMP4.stopRecord(process[0]); Loading Loading @@ -115,7 +122,7 @@ public class WarnPushBaseServer { public void iotPush(WarnPushBase warnPushBase) { public void iotPush(WarnPushBase warnPushBase) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String url = "http://172.16.20.170:8089/api/v1"; String url = "http://172.16.20.170:8089/api/v1/aqgl/warn"; String result_info = null; String result_info = null; try { try { //同步IOT //同步IOT Loading @@ -123,12 +130,14 @@ public class WarnPushBaseServer { bodys.put("order_name", "AI预警平台"); bodys.put("order_name", "AI预警平台"); bodys.put("alarm_device_name", warnPushBase.getAlarmDeviceName()); bodys.put("alarm_device_name", warnPushBase.getAlarmDeviceName()); bodys.put("grade_name", warnPushBase.getGradeName()); bodys.put("grade_name", warnPushBase.getGradeName()); bodys.put("grade_type", "摄像头预警"); bodys.put("grade_type", warnPushBase.getGradeType()); bodys.put("grade_type_code", PinYinUtil.getPinYinHeadChar(warnPushBase.getGradeType())); bodys.put("grade_type_code", PinYinUtil.getPinYinHeadChar(warnPushBase.getGradeType())); bodys.put("alarm_time", simpleDateFormat.format(warnPushBase.getAlarmTime())); bodys.put("alarm_time", simpleDateFormat.format(warnPushBase.getAlarmTime())); bodys.put("alarm_msg", warnPushBase.getAlarmMsg()); bodys.put("alarm_msg", warnPushBase.getAlarmMsg()); bodys.put("picture", warnPushBase.getPicture()); bodys.put("picture", warnPushBase.getPicture()); bodys.put("mine", warnPushBase.getBelong()); bodys.put("mine", warnPushBase.getBelong()); bodys.put("video",warnPushBase.getVideo()); bodys.put("channel_id",warnPushBase.getChannelId()); bodys.put("create_time", simpleDateFormat.format(new Date())); bodys.put("create_time", simpleDateFormat.format(new Date())); result_info = HttpUtils.doPostJson(url, null, JsonUtil.getObjectToString(bodys)); result_info = HttpUtils.doPostJson(url, null, JsonUtil.getObjectToString(bodys)); } catch (Exception e) { } catch (Exception e) { Loading src/main/java/com/example/mykafkaproject/utils/RtspToMP4.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class RtspToMP4 { command.add(streamUrl); command.add(streamUrl); command.add("-c:v"); command.add("-c:v"); command.add("copy"); command.add("copy"); // command.add("libx264"); command.add("-an"); command.add("-an"); command.add("-reset_timestamps"); command.add("-reset_timestamps"); command.add("1"); command.add("1"); Loading src/main/resources/config/iccSdk.properties +4 −3 Original line number Original line Diff line number Diff line #服务地址 端口默认是443 #服务地址 端口默认是443 #icc.sdk.host=115.236.17.59:9021 #icc.sdk.host=115.236.17.59:9021 icc.sdk.host=172.16.51.2 #icc.sdk.host=172.16.51.2 icc.sdk.host=172.16.51.4 #是否启用https访问,默认:是 #是否启用https访问,默认:是 #icc.sdk.enable.https=false #icc.sdk.enable.https=false #认证类型=[client_credentials],[password],client_credentials:客户端鉴权模式;password:用户密码鉴权模式 #认证类型=[client_credentials],[password],client_credentials:客户端鉴权模式;password:用户密码鉴权模式 Loading @@ -14,9 +15,9 @@ icc.sdk.clientSecret=67987667-8651-44f1-a3da-f6796e5f23e6 #icc.sdk.config.client.userId=1 #icc.sdk.config.client.userId=1 #-----------用户密码鉴权模式-------------- #-----------用户密码鉴权模式-------------- #用户密码鉴权模式申请访问凭证id #用户密码鉴权模式申请访问凭证id icc.sdk.pwdClientId=CompanyName icc.sdk.pwdClientId=aqpt #用户密码鉴权模式申请访问凭证密钥 #用户密码鉴权模式申请访问凭证密钥 icc.sdk.pwdClientSecret=67987667-8651-44f1-a3da-f6796e5f23e6 icc.sdk.pwdClientSecret=2faa3446-7e32-4fff-b661-a54d2c4cec7f #用户名 #用户名 icc.sdk.username=system icc.sdk.username=system #密码 #密码 Loading src/main/resources/mapper/WarnPushBaseMapper.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ <if test="sendUserIds != null and sendUserIds != ''">send_user_ids,</if> <if test="sendUserIds != null and sendUserIds != ''">send_user_ids,</if> <if test="delFlag != null ">del_flag,</if> <if test="delFlag != null ">del_flag,</if> <if test="remark != null ">remark,</if> <if test="remark != null ">remark,</if> <if test="alarmMsg != null and alarmMsg != ''">alarm_msg,</if> </trim> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="orderName != null and orderName != ''">#{orderName},</if> <if test="orderName != null and orderName != ''">#{orderName},</if> Loading @@ -33,6 +34,7 @@ <if test="sendUserIds != null and sendUserIds != ''">#{sendUserIds},</if> <if test="sendUserIds != null and sendUserIds != ''">#{sendUserIds},</if> <if test="delFlag != null ">#{delFlag},</if> <if test="delFlag != null ">#{delFlag},</if> <if test="remark != null ">#{remark},</if> <if test="remark != null ">#{remark},</if> <if test="alarmMsg != null and alarmMsg != ''">#{alarmMsg},</if> </trim> </trim> </insert> </insert> Loading Loading
src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java +18 −9 Original line number Original line Diff line number Diff line Loading @@ -41,19 +41,26 @@ public class WarnPushBaseServer { public void addMessage(String message) { public void addMessage(String message) { LOGGER.info("预警信息:" + message); LOGGER.info("预警信息:" + message); WarnPushBase warnPushBase = JSON.parseObject(message, WarnPushBase.class); WarnPushBase warnPushBase = JSON.parseObject(message, WarnPushBase.class); // if("乌海矿".equals(warnPushBase.getBelong())){ //获取视频地址 //获取视频地址 先不截取布控球的视频 String video; if(!warnPushBase.getAlarmDeviceName().contains("布控球")){ //获取前后五秒时间戳 //获取前后五秒时间戳 Date alarmTime = warnPushBase.getAlarmTime(); Date alarmTime = warnPushBase.getAlarmTime(); String video = getVideo(warnPushBase.getChannelId(), alarmTime.getTime() / 1000 - 5, alarmTime.getTime() / 1000 + 5); video = getVideo(warnPushBase.getChannelId(), alarmTime.getTime() / 1000 - 3, alarmTime.getTime() / 1000 + 3); }else{ video = "http://172.16.20.211:8080/profile/MP4/1001952$1$0$0_1698988966.mp4"; } // String video ="F:\\ruoyi\\uploadPath\\MP4"; warnPushBase.setAlarmMsg(warnPushBase.getGradeType()); warnPushBase.setAlarmMsg(warnPushBase.getGradeType()); warnPushBase.setGradeType("摄像头预警"); warnPushBase.setGradeType(warnPushBase.getGradeType()); warnPushBase.setVideo(video); warnPushBase.setVideo(video); warnPushBaseMapper.add(warnPushBase); warnPushBaseMapper.add(warnPushBase); //发送iot的http请求 //发送iot的http请求 iotPush(warnPushBase); iotPush(warnPushBase); // } } } public String getVideo(String channelId, Long startTime, Long endTime) { public String getVideo(String channelId, Long startTime, Long endTime) { Loading @@ -73,7 +80,7 @@ public class WarnPushBaseServer { }).start(); }).start(); Thread.sleep(3 * 1000); Thread.sleep(6 * 1000); rtspToMP4.stopRecord(process[0]); rtspToMP4.stopRecord(process[0]); Loading Loading @@ -115,7 +122,7 @@ public class WarnPushBaseServer { public void iotPush(WarnPushBase warnPushBase) { public void iotPush(WarnPushBase warnPushBase) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String url = "http://172.16.20.170:8089/api/v1"; String url = "http://172.16.20.170:8089/api/v1/aqgl/warn"; String result_info = null; String result_info = null; try { try { //同步IOT //同步IOT Loading @@ -123,12 +130,14 @@ public class WarnPushBaseServer { bodys.put("order_name", "AI预警平台"); bodys.put("order_name", "AI预警平台"); bodys.put("alarm_device_name", warnPushBase.getAlarmDeviceName()); bodys.put("alarm_device_name", warnPushBase.getAlarmDeviceName()); bodys.put("grade_name", warnPushBase.getGradeName()); bodys.put("grade_name", warnPushBase.getGradeName()); bodys.put("grade_type", "摄像头预警"); bodys.put("grade_type", warnPushBase.getGradeType()); bodys.put("grade_type_code", PinYinUtil.getPinYinHeadChar(warnPushBase.getGradeType())); bodys.put("grade_type_code", PinYinUtil.getPinYinHeadChar(warnPushBase.getGradeType())); bodys.put("alarm_time", simpleDateFormat.format(warnPushBase.getAlarmTime())); bodys.put("alarm_time", simpleDateFormat.format(warnPushBase.getAlarmTime())); bodys.put("alarm_msg", warnPushBase.getAlarmMsg()); bodys.put("alarm_msg", warnPushBase.getAlarmMsg()); bodys.put("picture", warnPushBase.getPicture()); bodys.put("picture", warnPushBase.getPicture()); bodys.put("mine", warnPushBase.getBelong()); bodys.put("mine", warnPushBase.getBelong()); bodys.put("video",warnPushBase.getVideo()); bodys.put("channel_id",warnPushBase.getChannelId()); bodys.put("create_time", simpleDateFormat.format(new Date())); bodys.put("create_time", simpleDateFormat.format(new Date())); result_info = HttpUtils.doPostJson(url, null, JsonUtil.getObjectToString(bodys)); result_info = HttpUtils.doPostJson(url, null, JsonUtil.getObjectToString(bodys)); } catch (Exception e) { } catch (Exception e) { Loading
src/main/java/com/example/mykafkaproject/utils/RtspToMP4.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class RtspToMP4 { command.add(streamUrl); command.add(streamUrl); command.add("-c:v"); command.add("-c:v"); command.add("copy"); command.add("copy"); // command.add("libx264"); command.add("-an"); command.add("-an"); command.add("-reset_timestamps"); command.add("-reset_timestamps"); command.add("1"); command.add("1"); Loading
src/main/resources/config/iccSdk.properties +4 −3 Original line number Original line Diff line number Diff line #服务地址 端口默认是443 #服务地址 端口默认是443 #icc.sdk.host=115.236.17.59:9021 #icc.sdk.host=115.236.17.59:9021 icc.sdk.host=172.16.51.2 #icc.sdk.host=172.16.51.2 icc.sdk.host=172.16.51.4 #是否启用https访问,默认:是 #是否启用https访问,默认:是 #icc.sdk.enable.https=false #icc.sdk.enable.https=false #认证类型=[client_credentials],[password],client_credentials:客户端鉴权模式;password:用户密码鉴权模式 #认证类型=[client_credentials],[password],client_credentials:客户端鉴权模式;password:用户密码鉴权模式 Loading @@ -14,9 +15,9 @@ icc.sdk.clientSecret=67987667-8651-44f1-a3da-f6796e5f23e6 #icc.sdk.config.client.userId=1 #icc.sdk.config.client.userId=1 #-----------用户密码鉴权模式-------------- #-----------用户密码鉴权模式-------------- #用户密码鉴权模式申请访问凭证id #用户密码鉴权模式申请访问凭证id icc.sdk.pwdClientId=CompanyName icc.sdk.pwdClientId=aqpt #用户密码鉴权模式申请访问凭证密钥 #用户密码鉴权模式申请访问凭证密钥 icc.sdk.pwdClientSecret=67987667-8651-44f1-a3da-f6796e5f23e6 icc.sdk.pwdClientSecret=2faa3446-7e32-4fff-b661-a54d2c4cec7f #用户名 #用户名 icc.sdk.username=system icc.sdk.username=system #密码 #密码 Loading
src/main/resources/mapper/WarnPushBaseMapper.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ <if test="sendUserIds != null and sendUserIds != ''">send_user_ids,</if> <if test="sendUserIds != null and sendUserIds != ''">send_user_ids,</if> <if test="delFlag != null ">del_flag,</if> <if test="delFlag != null ">del_flag,</if> <if test="remark != null ">remark,</if> <if test="remark != null ">remark,</if> <if test="alarmMsg != null and alarmMsg != ''">alarm_msg,</if> </trim> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="orderName != null and orderName != ''">#{orderName},</if> <if test="orderName != null and orderName != ''">#{orderName},</if> Loading @@ -33,6 +34,7 @@ <if test="sendUserIds != null and sendUserIds != ''">#{sendUserIds},</if> <if test="sendUserIds != null and sendUserIds != ''">#{sendUserIds},</if> <if test="delFlag != null ">#{delFlag},</if> <if test="delFlag != null ">#{delFlag},</if> <if test="remark != null ">#{remark},</if> <if test="remark != null ">#{remark},</if> <if test="alarmMsg != null and alarmMsg != ''">#{alarmMsg},</if> </trim> </trim> </insert> </insert> Loading