Commit 5a103c76 authored by wangjinjing's avatar wangjinjing

去掉延迟50s

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