Commit 5a103c76 authored by wangjinjing's avatar wangjinjing

去掉延迟50s

parent a11e7e9c
......@@ -102,7 +102,6 @@
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.3" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.38" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.12" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
......
......@@ -91,12 +91,6 @@
<artifactId>fastjson</artifactId>
<version>1.2.38</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
......
......@@ -137,7 +137,6 @@ public class TraffController {
@PostMapping({"/alarmevent"})
public ResultObj rece(@RequestBody Alarm trffClientMessage) {
// log.info("trffClientMessage:{}" ,JsonUtil.beanToString(trffClientMessage));
if (!TYPE.equals(trffClientMessage.getType())) {
return ResultObj.error(Integer.valueOf(ResponseEnum.E_1002.getCode()), "type类型不正确");
}
......@@ -200,6 +199,8 @@ public class TraffController {
traffAlarmRecord.setCreatetime(DateUtils.getDateString(new Date()));
traffAlarmRecord.setObjlable(trffClientMessage.getObjLabel());
traffAlarmRecord.setPushstatus(Integer.valueOf(9));
traffAlarmRecord.setProcessstatus("0");
traffAlarmRecord.setManualstatus(Integer.valueOf(1));
traffAlarmRecord.setChannelname(spr.getBz());
List<String> imgBase64List = trffClientMessage.getImg_base64();
String imgEnumHead = "IMG";
......@@ -221,14 +222,15 @@ public class TraffController {
traffAlarmRecord.setCheckstatus(Integer.valueOf(9));
}
Map<Object, Object> map = new HashMap<>();
if (this.manualStatus.equalsIgnoreCase("1")) {
map.put("type", "recordalarm");
traffAlarmRecord.setManualstatus(Integer.valueOf(0));
} else {
// if (this.manualStatus.equalsIgnoreCase("1")) {
// map.put("type", "recordalarm");
// traffAlarmRecord.setManualstatus(Integer.valueOf(0));
// } else {
//
//
// traffAlarmRecord.setManualstatus(Integer.valueOf(1));
// }
map.put("type", "alarm");
traffAlarmRecord.setManualstatus(Integer.valueOf(1));
}
//为了适配mqtt返回的处理状态,将状态设置为mqtt的事件主键
traffAlarmRecord.setEventid("66211"+UUIDUtils.createuuid());
this.traffAlarmRecordMapper.inserTraffAlarmRecord(traffAlarmRecord);
......@@ -245,23 +247,20 @@ public class TraffController {
traffAlarmRecord.setImg3path(recordBak.getImg3path());
traffAlarmRecord.setImg4path(recordBak.getImg4path());
traffAlarmRecord.setImg5path(recordBak.getImg5path());
traffAlarmRecord.setVideopath(recordBak.getVideopath());
String pname = DateUtils.formatCurrDayNoSign() + "_"+ traffAlarmRecord.getRecordid() + "_0000_video";
String fileName = pname + ".mp4";
String ftputl = FTPUtil.getFtpUrl(ftp) + basepath + "/" + fileName;
traffAlarmRecord.setVideopath(ftputl);
if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
}
//推送给高信
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
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(() -> {
String url = transferRecordMap.get("videopath").toString();
try {
HttpURLConnection connection = (HttpURLConnection) (new URL(url)).openConnection();
connection.setReadTimeout(2000);
......@@ -273,19 +272,22 @@ public class TraffController {
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) {
this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
}
// traffAlarmRecord.setVideopath(ftputl);
// if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
// this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
// }
}
} else {
log.info("video:{} upload fail:", ftputl);
traffAlarmRecord.setVideopath("");
this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
}
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
} catch (IOException e) {
log.error(e.toString());
sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
traffAlarmRecord.setVideopath("");
this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
// sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
return Integer.valueOf(0);
}
return Integer.valueOf(1);
......@@ -309,13 +311,13 @@ public class TraffController {
String mqttbh = this.traffAlarmRecordMapper.seletmqttbh(trffClientMessage.getIncident_type());
mqttalarm.setAlarmTime(traffAlarmRecord.getRecordtime());
mqttalarm.setCompanyId("66211");
mqttalarm.setEventid(traffAlarmRecord.getEventid());
// mqttalarm.setEventid(traffAlarmRecord.getEventid());
mqttalarm.setImagePath((traffAlarmRecord.getImg1path() == null) ? "" : (this.ftpServiceUrl + "?location=" + traffAlarmRecord.getImg1path().replace("ftp://" + this.ftppath + "/", "")));
mqttalarm.setVideoPath((traffAlarmRecord.getVideopath() == null) ? "" : (this.ftpServiceUrl + "?location=" + traffAlarmRecord.getVideopath().replace("ftp://" + this.ftppath + "/", "")));
mqttalarm.setDeviceId(wbbh);
log.info("mqtt data1:{}",JsonUtil.beanToString(mqttalarm));
//查询部门是否包含隧道
mqttalarm.setLocation(traffAlarmRecord.getChannelname()!=null&&traffAlarmRecord.getChannelname().contains("隧道")?2:1);
// mqttalarm.setLocation(traffAlarmRecord.getChannelname()!=null&&traffAlarmRecord.getChannelname().contains("隧道")?2:1);
if (null != trffClientMessage.getObj_location()) {
mqttalarm.setX(trffClientMessage.getObj_location().get("x") == null? null : (trffClientMessage.getObj_location().get("x")).toString());
mqttalarm.setY(trffClientMessage.getObj_location().get("y") == null ? null : (trffClientMessage.getObj_location().get("y")).toString());
......
package com.hzjt.domain;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class MqttAlarm {
private String deviceId;
private String eventTypeId;
......@@ -17,9 +11,9 @@ public class MqttAlarm {
private String width;
private String imagePath;
private String videoPath;
private String content;
private String eventid;
private int location;
// private String content;
// private String eventid;
// private int location;
public String getDeviceId() {
return deviceId;
......@@ -101,27 +95,27 @@ public class MqttAlarm {
this.videoPath = videoPath;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getEventid() {
return eventid;
}
public void setEventid(String eventid) {
this.eventid = eventid;
}
public int getLocation() {
return location;
}
public void setLocation(int location) {
this.location = location;
}
// public String getContent() {
// return content;
// }
//
// public void setContent(String content) {
// this.content = content;
// }
// public String getEventid() {
// return eventid;
// }
//
// public void setEventid(String eventid) {
// this.eventid = eventid;
// }
//
// public int getLocation() {
// return location;
// }
//
// public void setLocation(int location) {
// this.location = location;
// }
}
......@@ -16,9 +16,9 @@ public class DateUtils {
private static final Logger log = LoggerFactory.getLogger(DateUtils.class);
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 ;
}
......
#thymeleaf
server.port=8084
server.port=8089
spring.datasource.username=hzjt
spring.datasource.password=hzjt
......
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