Commit 1d1a1f06 authored by yzm's avatar yzm

mqtt西复线服务解决id 重复问题

parent 8e42ad9e
......@@ -26,7 +26,6 @@ import sun.net.www.protocol.ftp.FtpURLConnection;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -95,7 +94,7 @@ public class TraffController {
@Autowired
FLVCacheService flvCacheService;
Long eightHour=25200000L;
Long eightHour = 25200000L;
// @Autowired
// private SimpMessagingTemplate template;
......@@ -103,7 +102,7 @@ public class TraffController {
@Autowired
MQTTSubsribe mQTTSubsribe;
String manualStatus="0";
String manualStatus = "0";
private static final String TYPE = "TRAFFIC_INCIDENT_ALARM";
ScheduledExecutorService schedulepool = Executors.newScheduledThreadPool(5); //创
......@@ -129,13 +128,12 @@ public class TraffController {
@PostConstruct
public void init() {
//查询素有videowbbh
List<String> sbbhlist= sbtdspsrMapper.selectAllWbbh();
List<String> sbbhlist = sbtdspsrMapper.selectAllWbbh();
mQTTSubsribe.subscribe(sbbhlist);
}
@PostMapping("/alarmevent")
public ResultObj rece(@RequestBody Alarm trffClientMessage) {
// log.info("alarmevent--------------"+trffClientMessage.toString());
if (!TYPE.equals(trffClientMessage.getType())) {
return ResultObj.error(ResponseEnum.E_1002.getCode(), "type类型不正确");
}
......@@ -148,15 +146,12 @@ public class TraffController {
return ResultObj.error(ResponseEnum.E_1004.getCode(), "incident_type值不能为空");
}
//加8个小时兼容算法
log.info("trffClientMessage ts===="+trffClientMessage.getTs());
log.info("trffClientMessage nowtime======="+new Date().getTime());
Long current=new Date().getTime()-Long.valueOf(trffClientMessage.getTs());
log.info("current.longValue()>=eightHour.longValue()======"+(current.longValue()>=eightHour.longValue()));
if(current.longValue()>=eightHour.longValue())
{
Long current = new Date().getTime() - Long.valueOf(trffClientMessage.getTs());
log.info("current.longValue()>=eightHour.longValue()======" + (current.longValue() >= eightHour.longValue()));
if (current.longValue() >= eightHour.longValue()) {
//系统时间小于8小时
Long lontime=Long.valueOf(trffClientMessage.getTs())+28800000L;
log.info("trffClientMessage lontime====="+lontime);
Long lontime = Long.valueOf(trffClientMessage.getTs()) + 28800000L;
log.info("trffClientMessage lontime=====" + lontime);
trffClientMessage.setTs(String.valueOf(lontime));
}
......@@ -166,18 +161,8 @@ public class TraffController {
log.info("video_id值异常 值为:" + videoId);
return ResultObj.error(ResponseEnum.E_1002.getCode(), "video_id值异常 值为:" + videoId);
}
String sbbh="";
int tdbh=0;
// if( videoId.contains("_") && videoId.split("_").length == 2) {
// String[] sbAndTd = videoId.split("_");
// sbbh = sbAndTd[0];
// tdbh = Integer.valueOf(sbAndTd[1]) + 1;
// }
// else {
sbbh=videoId;
tdbh=0;
// }
String sbbh = videoId;
int tdbh = 0;
List<Sbtdspsr> sbtdspsrs = sbtdspsrMapper.selectBySbbh(sbbh, tdbh);
if (sbtdspsrs.isEmpty()) {
log.info("设备为:" + sbbh + ",通道为:" + tdbh + "未录入(备案)");
......@@ -188,41 +173,24 @@ public class TraffController {
log.info("设备为:" + sbbh + ",通道为:" + tdbh + "配置的行政区划" + xzbh + "不合规");
return ResultObj.error(ResponseEnum.E_1002.getCode(), "设备为:" + sbbh + ",通道为:" + tdbh + "配置的行政区划不合规");
}
trffClientMessage.setDept(xzbh);
//判断是否需要手动筛选
manualStatus=traffAlarmRecordMapper.seletManualStatus();
log.info("是否手动推送 manualStatus"+manualStatus);
if(manualStatus.equalsIgnoreCase("0")) {
log.info("send to gaoxin");
//手动 推送给高信
webSocket.GroupSending(JsonUtil.beanToString(trffClientMessage));
}
try { // 清空redis中的部分旧数据
// importService.cleanCache();
// 将参数result中的部分数据存入redis中,并把格式校验成功的数据发布至对应频道中
// importService.cacheAndPublish(JsonUtil.beanToString(trffClientMessage));
sendevent(trffClientMessage,sbtdspsrs.get(0).getWbbh());
sendevent(trffClientMessage, sbtdspsrs.get(0).getWbbh());
} catch (Exception e) {
log.error("MessageController receive putData error:" + e.toString());
}
return ResultObj.ok(trffClientMessage);
}
public void sendevent(Alarm trffClientMessage,String wbbh) {
public void sendevent(Alarm trffClientMessage, String wbbh) {
Traffalarmrecord traffAlarmRecord = new Traffalarmrecord();
traffAlarmRecord.setAreaid(Long.valueOf(trffClientMessage.getDept()));
traffAlarmRecord.setRecordtype(trffClientMessage.getIncident_type().toLowerCase());
traffAlarmRecord.setRecordtime(DateUtils.getDateString(new Date(Long.valueOf(trffClientMessage.getTs()))));
Integer channelid=Integer.valueOf(0);
traffAlarmRecord.setFdid(trffClientMessage.getVideo_id());
channelid=0;
traffAlarmRecord.setChannelid(channelid);
traffAlarmRecord.setFdid(trffClientMessage.getVideo_id());
traffAlarmRecord.setChannelid(0);
traffAlarmRecord.setVideourlfrom(trffClientMessage.getVideo_record_url());
traffAlarmRecord.setCreatetime(DateUtils.getDateString(new Date()));
traffAlarmRecord.setObjlable(trffClientMessage.getObjLabel());
......@@ -249,30 +217,23 @@ public class TraffController {
traffAlarmRecord.setCheckstatus(9);
}
int recordid = traffAlarmRecordMapper.selectmax();
traffAlarmRecord.setRecordid((long) (recordid));
//发送给前端
Map map = new HashMap();
if (manualStatus.equalsIgnoreCase("1")) {
map.put("type", "recordalarm");
traffAlarmRecord.setManualstatus(0);
if(manualStatus.equalsIgnoreCase("1")) {
map.put("type", "recordalarm");
traffAlarmRecord.setManualstatus(0);
}else {
} else {
map.put("type", "alarm");
traffAlarmRecord.setManualstatus(1);
}
map.put("data", trffClientMessage);
map.put("recordid", recordid);
webSocket.GroupSending(JsonUtil.beanToString(map));
traffAlarmRecord.setProcessstatus("0");
log.info(traffAlarmRecord.getRecordtime());
log.info("JSONUtil.toJsonStr 告警记录数据插入:{}",JSONUtil.toJsonStr(traffAlarmRecord));
log.info("JSON.toJSONString 告警记录数据插入:{}",JSON.toJSONString(traffAlarmRecord));
traffAlarmRecordMapper.inserTraffAlarmRecord(traffAlarmRecord);
map.put("data", trffClientMessage);
map.put("recordid", traffAlarmRecord.getRecordid());
webSocket.GroupSending(JsonUtil.beanToString(map));
try {
String basepath = "gstraff/" + traffAlarmRecord.getFdid() + (traffAlarmRecord.getChannelid() < 10 ? "0" + traffAlarmRecord.getChannelid() : traffAlarmRecord.getChannelid()) + "/" + DateUtils.formatCurrDayNoSign();
Map<String, Object> transferRecordMap = new HashMap<>();
......@@ -289,104 +250,72 @@ public class TraffController {
if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
}
//如果监控视频为空,延时加载重新获取
if (null == recordBak.getVideopath() || "".equalsIgnoreCase(recordBak.getVideopath())) {
if (null!=transferRecordMap.get("videopath")&&
!"".equals(transferRecordMap.get("videopath").toString())&&
( null == recordBak.getVideopath()
|| "".equalsIgnoreCase(recordBak.getVideopath()))
) {
String pname = DateUtils.formatCurrDayNoSign() + traffAlarmRecord.getRecordid() + "_video";
String fileName = pname + ".mp4";
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + fileName;
log.info("send to mqtt video is not empty");
//只更新监控
schedulepool.schedule(() -> {
for (String key : transferRecordMap.keySet()) {
if (key.equals("videopath")) {
final String url = transferRecordMap.get(key).toString();
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
//延迟连接
connection.setReadTimeout(2000);
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", "");
String fileName = pname + ".mp4";
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + fileName;
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
log.info("url:", url, " --- " + "key:", key);
boolean r = FTPUtil.uploadFile(ftp, basepath, fileName, inputStream);
if (r) traffAlarmRecord.setVideopath(ftputl);
//只更新监控
if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
log.info("send to mqtt video is not empty");
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
// //推送给第三方
// if(!manualStatus.equalsIgnoreCase("1")) {
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
// log.info("send to guangda:HTTP_OK" + obj.toString());
// }
}
}
else {
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
log.info("send to mqtt video is empty");
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
final String url = transferRecordMap.get("videopath").toString();
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
//延迟连接
connection.setReadTimeout(2000);
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
log.info("url:", url);
boolean r = FTPUtil.uploadFile(ftp, basepath, fileName, inputStream);
if (r) {
log.info("video:{} upload success:", ftputl);
traffAlarmRecord.setVideopath(ftputl);
if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
}
} catch (IOException e) {
System.out.println(e.toString());
log.error(e.toString());
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
return 0;
}
} else {
log.info("video:{} upload fail:", ftputl);
}
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
} catch (IOException e) {
log.error(e.toString());
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
return 0;
}
return 1;
}, 50, TimeUnit.SECONDS); //等待50秒钟执行
} else {
//需要先过滤,过滤结束后推送给第三方
// if(!manualStatus.equalsIgnoreCase("1")) {
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
// log.info("send to guangda novideopath --->response message" + obj.toString());
// }
}
traffAlarmRecord.setPushdesc("推送结束");
traffAlarmRecord.setPushstatus(0);
traffAlarmRecordMapper.updatePushEvent(traffAlarmRecord);
} catch (Exception e) {
log.error("alarm fail :" + e.toString());
log.error("alarmevent error :" + e.toString());
}
}
public static void main(String args[]) {
long a =1624377806000l;
Date date =new Date(a);
System.out.println(date);
}
private void sendtomqtt(Alarm trffClientMessage, String wbbh, Traffalarmrecord traffAlarmRecord) {
if(null==wbbh || "".equals(wbbh))
{
if (null == wbbh || "".equals(wbbh)) {
log.info("设备为:" + traffAlarmRecord.getFdid() + ",wbbh" + " is empty");
}
else {//mqtt 推送给第三方
} else {//mqtt 推送给第三方
MqttAlarm mqttalarm = new MqttAlarm();
//查询事件类型mqtt 对应的编号
String mqttbh = traffAlarmRecordMapper.seletmqttbh(trffClientMessage.getIncident_type());
mqttalarm.setAlarmTime(traffAlarmRecord.getRecordtime());
mqttalarm.setCompanyId("66211");
//设置图片
mqttalarm.setImagePath(traffAlarmRecord.getImg1path()==null?"":ftpServiceUrl+"?location="+traffAlarmRecord.getImg1path().replace("ftp://"+ftppath+"/",""));
mqttalarm.setVideoPath(traffAlarmRecord.getVideopath()==null?"":ftpServiceUrl+"?location="+traffAlarmRecord.getVideopath().replace("ftp://"+ftppath+"/",""));
mqttalarm.setImagePath(traffAlarmRecord.getImg1path() == null ? "" : ftpServiceUrl + "?location=" + traffAlarmRecord.getImg1path().replace("ftp://" + ftppath + "/", ""));
mqttalarm.setVideoPath(traffAlarmRecord.getVideopath() == null ? "" : ftpServiceUrl + "?location=" + traffAlarmRecord.getVideopath().replace("ftp://" + ftppath + "/", ""));
mqttalarm.setDeviceId(wbbh);
if (null != trffClientMessage.getObj_location()) {
mqttalarm.setX(trffClientMessage.getObj_location().get("x") == null ? null : trffClientMessage.getObj_location().get("x").toString());
......@@ -395,8 +324,7 @@ public class TraffController {
mqttalarm.setHeight(trffClientMessage.getObj_location().get("height") == null ? null : trffClientMessage.getObj_location().get("height").toString());
}
mqttalarm.setEventTypeId(mqttbh);
log.info("JSONUtil mqtt data:{}", JSON.toJSONString(mqttalarm));
log.info("mqtt data:{}"+ JSON.toJSONString(mqttalarm));
log.info("mqtt data:{}" + JSON.toJSONString(mqttalarm));
mQTTSubsribe.publishMessage("event/" + wbbh + "/videoEvent", JSON.toJSONString(mqttalarm));
}
......@@ -408,7 +336,7 @@ public class TraffController {
rateLimiter = rateLimiterMap.get(videoId);
} else {
RateLimiter value = RateLimiter.create(rate);
rateLimiter = rateLimiterMap.putIfAbsent(videoId, value);
rateLimiter = rateLimiterMap.putIfAbsent(videoId, value);
if (rateLimiter == null) {
rateLimiter = value;
}
......@@ -422,15 +350,14 @@ public class TraffController {
public ResultObj traffflow(@RequestBody Vehicles vehicles) {
if ("TRAFFIC_STATISTICS_VEHICLES".equalsIgnoreCase(vehicles.getType())) {
String sbbh="";
int tdbh=0;
if(vehicles.getVideo_id().contains("_") && vehicles.getVideo_id().split("_").length == 2) {
String sbbh = "";
int tdbh = 0;
if (vehicles.getVideo_id().contains("_") && vehicles.getVideo_id().split("_").length == 2) {
String[] sbAndTd = vehicles.getVideo_id().split("_");
sbbh = sbAndTd[0];
tdbh = Integer.valueOf(sbAndTd[1]) + 1;
}
else {
sbbh=vehicles.getVideo_id();
sbbh = sbAndTd[0];
tdbh = Integer.valueOf(sbAndTd[1]) + 1;
} else {
sbbh = vehicles.getVideo_id();
}
//重置videoid
vehicles.setVideo_id(sbbh + "_" + tdbh);
......@@ -446,8 +373,6 @@ public class TraffController {
v.setClassification_confidence(detail.getClassification_confidence());
v.setVideo_id(vehicles.getVideo_id());
traffFlowService.saveTraffFlowDetail(v);
}
//查询近五分钟的车流量,当天车流量websocket 直接推送过去
// log.info("fivevehivle");
......@@ -469,7 +394,6 @@ public class TraffController {
}
//获取flv地址
@GetMapping("/getflv/{videoid}")
public String getflv(@PathVariable("videoid") String videoid) {
......@@ -516,7 +440,7 @@ public class TraffController {
v.setCreate_time(new Date(Long.valueOf(vehicles.getTs())));
v.setType(detail.getType());
v.setDirection(detail.getDirection());
v.setRuleTag(detail.getDirection().longValue()<=ldir.longValue()?"1":"2");
v.setRuleTag(detail.getDirection().longValue() <= ldir.longValue() ? "1" : "2");
v.setClassification_confidence(detail.getClassification_confidence());
v.setVideo_id(vehicles.getVideo_id());
result = traffFlowService.saveTraffFlowDetail(v);
......@@ -531,42 +455,42 @@ public class TraffController {
//车流量推送
@GetMapping("/sendtouser/{recordid}")
@ResponseBody
public Integer sendtouser(@PathVariable("recordid") String recordid) {
public Integer sendtouser(@PathVariable("recordid") String recordid) {
//查询该信息
Traffalarmrecord traffalarmrecord = traffAlarmRecordMapper.selectByPrimaryKey(recordid);
if(traffalarmrecord==null) return 0;
Alarm alarm=new Alarm();
Base64Encoder base64Encoder=new Base64Encoder();
alarm.setTs(Long.toString(traffalarmrecord.getRecordtime()==null?new Date().getTime():DateUtils.Parsedate(traffalarmrecord.getRecordtime()).getTime()));
alarm.setDept(traffalarmrecord.getAreaid()==null?null:Long.toString(traffalarmrecord.getAreaid()));
alarm.setVideo_id(traffalarmrecord.getFdid()+"_"+traffalarmrecord.getChannelid());
if (traffalarmrecord == null) return 0;
Alarm alarm = new Alarm();
Base64Encoder base64Encoder = new Base64Encoder();
alarm.setTs(Long.toString(traffalarmrecord.getRecordtime() == null ? new Date().getTime() : DateUtils.Parsedate(traffalarmrecord.getRecordtime()).getTime()));
alarm.setDept(traffalarmrecord.getAreaid() == null ? null : Long.toString(traffalarmrecord.getAreaid()));
alarm.setVideo_id(traffalarmrecord.getFdid() + "_" + traffalarmrecord.getChannelid());
alarm.setIncident_type(traffalarmrecord.getRecordtype());
List<String> strImgs=new ArrayList<>();
if(traffalarmrecord.getImg1path() != null ){
byte[] Img=FTPUtil.getFtpPicBytes(traffalarmrecord.getImg1path());
strImgs.add(Img!=null?base64Encoder.encode(Img) : null);
List<String> strImgs = new ArrayList<>();
if (traffalarmrecord.getImg1path() != null) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg1path());
strImgs.add(Img != null ? base64Encoder.encode(Img) : null);
}
if(traffalarmrecord.getImg2path() != null ){
byte[] Img=FTPUtil.getFtpPicBytes(traffalarmrecord.getImg2path());
strImgs.add(Img!= null ? base64Encoder.encode(Img) : null);
if (traffalarmrecord.getImg2path() != null) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg2path());
strImgs.add(Img != null ? base64Encoder.encode(Img) : null);
}
if(traffalarmrecord.getImg3path() != null ) {
if (traffalarmrecord.getImg3path() != null) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg3path());
strImgs.add(Img != null ? base64Encoder.encode(Img) : null);
}
if(traffalarmrecord.getImg4path() != null ) {
if (traffalarmrecord.getImg4path() != null) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg4path());
strImgs.add(Img != null ? base64Encoder.encode(Img) : null);
}
if(traffalarmrecord.getImg5path() != null ) {
if (traffalarmrecord.getImg5path() != null) {
byte[] Img = FTPUtil.getFtpPicBytes(traffalarmrecord.getImg5path());
strImgs.add(Img != null ? base64Encoder.encode(Img) : null);
}
alarm.setImg_base64(strImgs);
Map map=new HashMap();
Map map = new HashMap();
//websocket 推送给客户
map.put("type", "alarm");
map.put("data", alarm);
......@@ -585,7 +509,7 @@ public class TraffController {
}
}catch (Exception ex){
} catch (Exception ex) {
log.info("send to guangda novideopath --->response error" + ex.toString());
return 1;
......@@ -593,21 +517,19 @@ public class TraffController {
}
}
//车流量推送
@GetMapping("/test")
@ResponseBody
public void test() {
String manualStatus=traffAlarmRecordMapper.seletManualStatus();
Alarm alarm=new Alarm();
String manualStatus = traffAlarmRecordMapper.seletManualStatus();
Alarm alarm = new Alarm();
alarm.setVideo_id("33_65_230_156_554_fbXdTkVe98u_ecvs_0");
alarm.setIncident_type("NO_MOTOR_BAN");
String str="iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAB1UlEQVRIS5WVjTEEQRBG30WACBABGSACLgJEgAicCBABIkAEiIAMkAERUG9remtua2Z3rquuam935nvTPf0zY9y2gENgH/B5Ny3/AL6AV+A5PReVZhV9xS6Bk/RdEUVzE7qXXtwDVyVQCaDoNeC3m/T7qRxkHThPvz9gnrzqlw8Bi3RyTyyoJjzkCTJcO8ApoEed5QAF74CHLDRDofwOShA9PgYOwpMAGPN34A04Grl3T6kZ/5KFJ5vAthEIgC4pLGgsLFMAoWp8pktfCFh6MZG2LQAlPLDpvS3ALDBrNhoutRUQh54LcJNhGYt9ONYKcH1XiAJ80CVTdMpWATwB6wIsEKswALpnupZsLE1dfwsorKl3WAP0hTKgCDcFTeeSWQc5YF+APcaXLSGKSq/1sBzah6h7GCmefNMqgP6SV0nTVsBSmq5SaK2A6AxdFi1V3kSxtQDMNPtal5l5s/Oy7SF2wlo/EmBIvbOS+f4ldQVBfbNzsR3Sj7p3UYG4yZBGKuaQELeLqtVNwGG6xUzwo9PJTGgxwY/p5HpYHDghJN0TrqVxaXXWQAqfpQH1nfrZ0uyuFUw+awUJcGNsVjjC9Ts2u6cqMgowhpH/IwGE2fxK99GH9R91mncY+HKoHAAAAABJRU5ErkJggg==";
List arrlist=new ArrayList();
String str = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAB1UlEQVRIS5WVjTEEQRBG30WACBABGSACLgJEgAicCBABIkAEiIAMkAERUG9remtua2Z3rquuam935nvTPf0zY9y2gENgH/B5Ny3/AL6AV+A5PReVZhV9xS6Bk/RdEUVzE7qXXtwDVyVQCaDoNeC3m/T7qRxkHThPvz9gnrzqlw8Bi3RyTyyoJjzkCTJcO8ApoEed5QAF74CHLDRDofwOShA9PgYOwpMAGPN34A04Grl3T6kZ/5KFJ5vAthEIgC4pLGgsLFMAoWp8pktfCFh6MZG2LQAlPLDpvS3ALDBrNhoutRUQh54LcJNhGYt9ONYKcH1XiAJ80CVTdMpWATwB6wIsEKswALpnupZsLE1dfwsorKl3WAP0hTKgCDcFTeeSWQc5YF+APcaXLSGKSq/1sBzah6h7GCmefNMqgP6SV0nTVsBSmq5SaK2A6AxdFi1V3kSxtQDMNPtal5l5s/Oy7SF2wlo/EmBIvbOS+f4ldQVBfbNzsR3Sj7p3UYG4yZBGKuaQELeLqtVNwGG6xUzwo9PJTGgxwY/p5HpYHDghJN0TrqVxaXXWQAqfpQH1nfrZ0uyuFUw+awUJcGNsVjjC9Ts2u6cqMgowhpH/IwGE2fxK99GH9R91mncY+HKoHAAAAABJRU5ErkJggg==";
List arrlist = new ArrayList();
arrlist.add(str);
arrlist.add(str);
arrlist.add(str);
......@@ -616,12 +538,12 @@ public class TraffController {
alarm.setImg_base64(arrlist);
alarm.setTs("1345677777");
alarm.setType("TRAFFIC_INCIDENT_ALARM");
Map map=new HashMap();
Map map = new HashMap();
map.put("type", "alarm");
map.put("data", alarm);
map.put("recordid", "33448");
webSocket.GroupSending(JsonUtil.beanToString(map));
Traffalarmrecord traffAlarmRecord=new Traffalarmrecord();
Traffalarmrecord traffAlarmRecord = new Traffalarmrecord();
traffAlarmRecord.setRecordid(Long.parseLong("33448"));
traffAlarmRecord.setChannelid(new Integer(1));
traffAlarmRecord.setFdid("20200305112042989");
......@@ -631,7 +553,7 @@ public class TraffController {
map.put("recordid", "33449");
webSocket.GroupSending(JsonUtil.beanToString(map));
Traffalarmrecord traffAlarmRecord2=new Traffalarmrecord();
Traffalarmrecord traffAlarmRecord2 = new Traffalarmrecord();
traffAlarmRecord2.setRecordid(Long.parseLong("33449"));
traffAlarmRecord2.setChannelid(new Integer(1));
traffAlarmRecord2.setFdid("20200305112042989");
......@@ -644,7 +566,7 @@ public class TraffController {
@GetMapping("/testevent")
@ResponseBody
public void testevent() {
String json="{"+
String json = "{" +
" \"type\": \"TRAFFIC_INCIDENT_ALARM\"," +
" \"id\": \"d9a2b0f0-f0cf-49b9-9b64-3da86a122afa\"," +
" \"video_id\": \"201809180950119121_0\"," +
......@@ -667,7 +589,7 @@ public class TraffController {
" \"img_base64\": [\"d0xEMHcFAESwdwaUjWDqB6/1Qw4LapAiSICVTOFWsGT0sgt\"]\n" +
" }";
MqttAlarm alarm=new MqttAlarm();
MqttAlarm alarm = new MqttAlarm();
alarm.setHeight("0.7");
alarm.setWidth("0.7");
......@@ -679,7 +601,7 @@ public class TraffController {
long startTime = System.currentTimeMillis();
//ftp://reader:reader@33.50.1.22:21/
//ftp.host=33.65.219.103:21:hzjt:1qaz2wsx
String ftpPath="ftp://"+ftppath+"/"+location;
String ftpPath = "ftp://" + ftppath + "/" + location;
FileInputStream hFile = null;
OutputStream toClient = null;
InputStream inputStream = null;
......@@ -727,7 +649,7 @@ public class TraffController {
PrintWriter out = response.getWriter();
out.write("无法打开图片!");
out.flush();
log.info("ftpagent error "+ftpUrl+e.toString());
log.info("ftpagent error " + ftpUrl + e.toString());
} finally {
if (bis != null) {
bis.close();
......
......@@ -95,8 +95,8 @@ public class Receiver {
/* 9:免审 */
traffAlarmRecord.setCheckstatus(9);
}
int recordid = traffAlarmRecordMapper.selectmax();
traffAlarmRecord.setRecordid((long)(recordid+1));
//int recordid = traffAlarmRecordMapper.selectmax();
//traffAlarmRecord.setRecordid((long)(recordid+1));
traffAlarmRecord.setProcessstatus("0");
traffAlarmRecord.setAreaid(Long.valueOf(trffClientMessage.getDept()));
traffAlarmRecord.setRecordtype(trffClientMessage.getIncident_type().toLowerCase());
......@@ -137,7 +137,7 @@ public class Receiver {
connection.setReadTimeout(2000);
connection.setConnectTimeout(3000);
connection.setRequestMethod("GET");
String pname = DateUtils.formatCurrDayNoSign() + "_" + recordid + "_0000_" + key.replace("path", "");
String pname = DateUtils.formatCurrDayNoSign() + "_" + traffAlarmRecord.getFdid() +"_"+ traffAlarmRecord.getRecordid() + key.replace("path", "");
String fileName = pname + ".mp4";
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + fileName;
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
......
......@@ -14,9 +14,9 @@ public class DateUtils {
public static String getDateString(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
log.info("date timezone:{}",formatter.getTimeZone()) ;
// log.info("date timezone:{}",formatter.getTimeZone()) ;
formatter.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
log.info("date timezone:{}",formatter.getTimeZone()) ;
// log.info("date timezone:{}",formatter.getTimeZone()) ;
String dateString = formatter.format(date);
return dateString ;
}
......
......@@ -6,7 +6,7 @@
set retrytime= sysdate,
retrycount= retrycount+1
<trim prefix="," suffixOverrides=",">
<if test="img1path!=null">img1path=#{img1path},</if>
<!--<if test="img1path!=null">img1path=#{img1path},</if>-->
<if test="img2path!=null">img2path=#{img2path},</if>
<if test="img3path!=null">img3path=#{img3path},</if>
<if test="img4path!=null">img4path=#{img4path},</if>
......@@ -26,6 +26,9 @@
</update>
<insert id="inserTraffAlarmRecord">
<selectKey keyProperty="recordid" resultType="Long" order="BEFORE">
select nvl(max(recordid),0)+1 from traffalarmrecord
</selectKey>
insert into traffalarmrecord
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="recordid != null">recordid,</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment