mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-24 05:57:49 +08:00
[1078] 增加状态变化通知和位置事件
This commit is contained in:
parent
d7f5e7d771
commit
c90836261a
@ -6,13 +6,13 @@ import lombok.Setter;
|
|||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册事件
|
* 设备更新事件
|
||||||
*/
|
*/
|
||||||
public class RegisterEvent extends ApplicationEvent {
|
public class DeviceUpdateEvent extends ApplicationEvent {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public RegisterEvent(Object source) {
|
public DeviceUpdateEvent(Object source) {
|
||||||
super(source);
|
super(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
27
src/main/java/com/genersoft/iot/vmp/jt1078/event/JTPositionEvent.java
Executable file
27
src/main/java/com/genersoft/iot/vmp/jt1078/event/JTPositionEvent.java
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
package com.genersoft.iot.vmp.jt1078.event;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.bean.JTPositionBaseInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备更新事件
|
||||||
|
*/
|
||||||
|
public class JTPositionEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public JTPositionEvent(Object source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private JTPositionBaseInfo positionInfo;
|
||||||
|
}
|
||||||
@ -2,8 +2,6 @@ package com.genersoft.iot.vmp.jt1078.event.eventListener;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
||||||
import com.genersoft.iot.vmp.jt1078.event.ConnectChangeEvent;
|
import com.genersoft.iot.vmp.jt1078.event.ConnectChangeEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.event.RegisterEvent;
|
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.request.J0003;
|
|
||||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.jt1078.proc.request;
|
|||||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
||||||
import com.genersoft.iot.vmp.jt1078.event.RegisterEvent;
|
import com.genersoft.iot.vmp.jt1078.event.DeviceUpdateEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8100;
|
import com.genersoft.iot.vmp.jt1078.proc.response.J8100;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||||
@ -13,8 +13,6 @@ import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
|||||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -33,6 +31,7 @@ import java.util.UUID;
|
|||||||
public class J0100 extends Re {
|
public class J0100 extends Re {
|
||||||
|
|
||||||
private JTDevice device;
|
private JTDevice device;
|
||||||
|
private JTDevice deviceForUpdate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||||
@ -87,33 +86,32 @@ public class J0100 extends Re {
|
|||||||
J8100 j8100 = new J8100();
|
J8100 j8100 = new J8100();
|
||||||
j8100.setRespNo(header.getSn());
|
j8100.setRespNo(header.getSn());
|
||||||
// 从数据库判断这个设备是否合法
|
// 从数据库判断这个设备是否合法
|
||||||
JTDevice deviceInDb = service.getDevice(header.getPhoneNumber());
|
deviceForUpdate = service.getDevice(header.getPhoneNumber());
|
||||||
if (deviceInDb != null) {
|
if (deviceForUpdate != null) {
|
||||||
j8100.setResult(J8100.SUCCESS);
|
j8100.setResult(J8100.SUCCESS);
|
||||||
String authenticationCode = UUID.randomUUID().toString();
|
String authenticationCode = UUID.randomUUID().toString();
|
||||||
j8100.setCode(authenticationCode);
|
j8100.setCode(authenticationCode);
|
||||||
deviceInDb.setAuthenticationCode(authenticationCode);
|
deviceForUpdate.setAuthenticationCode(authenticationCode);
|
||||||
deviceInDb.setStatus(true);
|
deviceForUpdate.setStatus(true);
|
||||||
deviceInDb.setProvinceId(device.getProvinceId());
|
deviceForUpdate.setProvinceId(device.getProvinceId());
|
||||||
deviceInDb.setRegisterTime(DateUtil.getNow());
|
deviceForUpdate.setRegisterTime(DateUtil.getNow());
|
||||||
CivilCodePo provinceCivilCodePo = CivilCodeUtil.INSTANCE.get(device.getProvinceId());
|
CivilCodePo provinceCivilCodePo = CivilCodeUtil.INSTANCE.get(device.getProvinceId());
|
||||||
if (provinceCivilCodePo != null) {
|
if (provinceCivilCodePo != null) {
|
||||||
deviceInDb.setProvinceText(provinceCivilCodePo.getName());
|
deviceForUpdate.setProvinceText(provinceCivilCodePo.getName());
|
||||||
}
|
}
|
||||||
deviceInDb.setCityId(device.getCityId());
|
deviceForUpdate.setCityId(device.getCityId());
|
||||||
CivilCodePo cityCivilCodePo = CivilCodeUtil.INSTANCE.get(device.getProvinceId() +
|
CivilCodePo cityCivilCodePo = CivilCodeUtil.INSTANCE.get(device.getProvinceId() +
|
||||||
String.format("%04d", Integer.parseInt(device.getCityId())));
|
String.format("%04d", Integer.parseInt(device.getCityId())));
|
||||||
if (cityCivilCodePo != null) {
|
if (cityCivilCodePo != null) {
|
||||||
deviceInDb.setCityText(cityCivilCodePo.getName());
|
deviceForUpdate.setCityText(cityCivilCodePo.getName());
|
||||||
}
|
}
|
||||||
deviceInDb.setModel(device.getModel());
|
deviceForUpdate.setModel(device.getModel());
|
||||||
deviceInDb.setMakerId(device.getMakerId());
|
deviceForUpdate.setMakerId(device.getMakerId());
|
||||||
deviceInDb.setTerminalId(device.getTerminalId());
|
deviceForUpdate.setTerminalId(device.getTerminalId());
|
||||||
// TODO 支持直接展示车牌颜色的描述
|
// TODO 支持直接展示车牌颜色的描述
|
||||||
deviceInDb.setPlateColor(device.getPlateColor());
|
deviceForUpdate.setPlateColor(device.getPlateColor());
|
||||||
deviceInDb.setPlateNo(device.getPlateNo());
|
deviceForUpdate.setPlateNo(device.getPlateNo());
|
||||||
service.updateDevice(deviceInDb);
|
log.info("[JT-注册成功] 设备: {}", deviceForUpdate);
|
||||||
log.info("[JT-注册成功] 设备: {}", deviceInDb);
|
|
||||||
}else {
|
}else {
|
||||||
log.info("[JT-注册失败] 未授权设备: {}", header.getPhoneNumber());
|
log.info("[JT-注册失败] 未授权设备: {}", header.getPhoneNumber());
|
||||||
j8100.setResult(J8100.FAIL);
|
j8100.setResult(J8100.FAIL);
|
||||||
@ -127,8 +125,8 @@ public class J0100 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationEvent getEvent() {
|
public ApplicationEvent getEvent() {
|
||||||
RegisterEvent registerEvent = new RegisterEvent(this);
|
DeviceUpdateEvent registerEvent = new DeviceUpdateEvent(this);
|
||||||
registerEvent.setDevice(device);
|
registerEvent.setDevice(deviceForUpdate);
|
||||||
return registerEvent;
|
return registerEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.jt1078.proc.request;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.DeviceUpdateEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||||
@ -25,6 +26,7 @@ import java.nio.charset.Charset;
|
|||||||
public class J0102 extends Re {
|
public class J0102 extends Re {
|
||||||
|
|
||||||
private String authenticationCode;
|
private String authenticationCode;
|
||||||
|
private JTDevice deviceForUpdate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||||
@ -49,7 +51,8 @@ public class J0102 extends Re {
|
|||||||
}else {
|
}else {
|
||||||
j8001.setResult(J8001.SUCCESS);
|
j8001.setResult(J8001.SUCCESS);
|
||||||
if (!device.isStatus()) {
|
if (!device.isStatus()) {
|
||||||
device.setStatus(true);
|
deviceForUpdate = device;
|
||||||
|
deviceForUpdate.setStatus(true);
|
||||||
service.updateDevice(device);
|
service.updateDevice(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +61,9 @@ public class J0102 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationEvent getEvent() {
|
public ApplicationEvent getEvent() {
|
||||||
return null;
|
DeviceUpdateEvent registerEvent = new DeviceUpdateEvent(this);
|
||||||
|
registerEvent.setDevice(deviceForUpdate);
|
||||||
|
return registerEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.jt1078.proc.request;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.DeviceUpdateEvent;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.JTPositionEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||||
@ -25,12 +27,12 @@ public class J0201 extends Re {
|
|||||||
|
|
||||||
private final static Logger log = LoggerFactory.getLogger(J0100.class);
|
private final static Logger log = LoggerFactory.getLogger(J0100.class);
|
||||||
private JTPositionBaseInfo positionInfo;
|
private JTPositionBaseInfo positionInfo;
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||||
|
phoneNumber = header.getPhoneNumber();
|
||||||
int respNo = buf.readUnsignedShort();
|
int respNo = buf.readUnsignedShort();
|
||||||
|
|
||||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||||
log.info("[JT-位置信息查询应答]: {}", positionInfo);
|
log.info("[JT-位置信息查询应答]: {}", positionInfo);
|
||||||
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0201", (long) respNo, positionInfo);
|
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0201", (long) respNo, positionInfo);
|
||||||
@ -39,24 +41,21 @@ public class J0201 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||||
JTDevice deviceInDb = service.getDevice(header.getPhoneNumber());
|
|
||||||
J8001 j8001 = new J8001();
|
J8001 j8001 = new J8001();
|
||||||
j8001.setRespNo(header.getSn());
|
j8001.setRespNo(header.getSn());
|
||||||
j8001.setRespId(header.getMsgId());
|
j8001.setRespId(header.getMsgId());
|
||||||
if (deviceInDb == null) {
|
j8001.setResult(J8001.SUCCESS);
|
||||||
j8001.setResult(J8001.FAIL);
|
|
||||||
}else {
|
|
||||||
// TODO 优化为发送异步事件,定时读取队列写入数据库
|
|
||||||
deviceInDb.setLongitude(positionInfo.getLongitude());
|
|
||||||
deviceInDb.setLatitude(positionInfo.getLatitude());
|
|
||||||
service.updateDevice(deviceInDb);
|
|
||||||
j8001.setResult(J8001.SUCCESS);
|
|
||||||
}
|
|
||||||
return j8001;
|
return j8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationEvent getEvent() {
|
public ApplicationEvent getEvent() {
|
||||||
return null;
|
if (positionInfo == null || phoneNumber == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JTPositionEvent registerEvent = new JTPositionEvent(this);
|
||||||
|
registerEvent.setPhoneNumber(phoneNumber);
|
||||||
|
registerEvent.setPositionInfo(positionInfo);
|
||||||
|
return registerEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.jt1078.proc.request;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.JTPositionEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||||
@ -23,9 +24,11 @@ import org.springframework.context.ApplicationEvent;
|
|||||||
public class J0500 extends Re {
|
public class J0500 extends Re {
|
||||||
|
|
||||||
private JTPositionBaseInfo positionInfo;
|
private JTPositionBaseInfo positionInfo;
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||||
|
phoneNumber = header.getPhoneNumber();
|
||||||
int respNo = buf.readUnsignedShort();
|
int respNo = buf.readUnsignedShort();
|
||||||
positionInfo = JTPositionBaseInfo.decode(buf);
|
positionInfo = JTPositionBaseInfo.decode(buf);
|
||||||
log.info("[车辆控制应答] {}", header.getPhoneNumber());
|
log.info("[车辆控制应答] {}", header.getPhoneNumber());
|
||||||
@ -35,24 +38,21 @@ public class J0500 extends Re {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||||
JTDevice deviceInDb = service.getDevice(header.getPhoneNumber());
|
|
||||||
J8001 j8001 = new J8001();
|
J8001 j8001 = new J8001();
|
||||||
j8001.setRespNo(header.getSn());
|
j8001.setRespNo(header.getSn());
|
||||||
j8001.setRespId(header.getMsgId());
|
j8001.setRespId(header.getMsgId());
|
||||||
if (deviceInDb == null) {
|
j8001.setResult(J8001.SUCCESS);
|
||||||
j8001.setResult(J8001.FAIL);
|
|
||||||
}else {
|
|
||||||
// TODO 优化为发送异步事件,定时读取队列写入数据库
|
|
||||||
deviceInDb.setLongitude(positionInfo.getLongitude());
|
|
||||||
deviceInDb.setLatitude(positionInfo.getLatitude());
|
|
||||||
service.updateDevice(deviceInDb);
|
|
||||||
j8001.setResult(J8001.SUCCESS);
|
|
||||||
}
|
|
||||||
return j8001;
|
return j8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationEvent getEvent() {
|
public ApplicationEvent getEvent() {
|
||||||
return null;
|
if (positionInfo == null || phoneNumber == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JTPositionEvent registerEvent = new JTPositionEvent(this);
|
||||||
|
registerEvent.setPhoneNumber(phoneNumber);
|
||||||
|
registerEvent.setPositionInfo(positionInfo);
|
||||||
|
return registerEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class J0901 extends Re {
|
|||||||
J8001 j8001 = new J8001();
|
J8001 j8001 = new J8001();
|
||||||
j8001.setRespNo(header.getSn());
|
j8001.setRespNo(header.getSn());
|
||||||
j8001.setRespId(header.getMsgId());
|
j8001.setRespId(header.getMsgId());
|
||||||
return null;
|
return j8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -9,16 +9,15 @@ import com.genersoft.iot.vmp.conf.ftpServer.FtpSetting;
|
|||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
import com.genersoft.iot.vmp.conf.ftpServer.UserManager;
|
import com.genersoft.iot.vmp.conf.ftpServer.UserManager;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
|
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.config.JTAloneChanel;
|
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.config.JTChannelListParam;
|
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.config.JTChannelParam;
|
|
||||||
import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
|
import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
|
||||||
import com.genersoft.iot.vmp.jt1078.dao.JTChannelMapper;
|
import com.genersoft.iot.vmp.jt1078.dao.JTChannelMapper;
|
||||||
import com.genersoft.iot.vmp.jt1078.dao.JTTerminalMapper;
|
import com.genersoft.iot.vmp.jt1078.dao.JTTerminalMapper;
|
||||||
import com.genersoft.iot.vmp.jt1078.event.RegisterEvent;
|
import com.genersoft.iot.vmp.jt1078.event.DeviceUpdateEvent;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.JTPositionEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
||||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||||
import com.genersoft.iot.vmp.jt1078.session.FtpDownloadManager;
|
import com.genersoft.iot.vmp.jt1078.session.FtpDownloadManager;
|
||||||
@ -43,13 +42,13 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.SynchronousQueue;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -88,6 +87,33 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FtpDownloadManager downloadManager;
|
private FtpDownloadManager downloadManager;
|
||||||
|
|
||||||
|
// 服务启动后五分钟内没有尽量连接的设备设置为离线
|
||||||
|
@PostConstruct
|
||||||
|
public void init(){
|
||||||
|
// 检查session与在线终端是是否对应 不对应则设置终端离线
|
||||||
|
List<JTDevice> deviceList = jtDeviceMapper.getDeviceList(null, true);
|
||||||
|
if (deviceList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (JTDevice device : deviceList) {
|
||||||
|
Session session = SessionManager.INSTANCE.get(device.getPhoneNumber());
|
||||||
|
if (session == null) {
|
||||||
|
device.setStatus(false);
|
||||||
|
// 通道发送状态变化通知
|
||||||
|
List<JTChannel> jtChannels = jtChannelMapper.selectAll(device.getId(), null);
|
||||||
|
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||||
|
for (JTChannel jtChannel : jtChannels) {
|
||||||
|
if (jtChannel.getGbId() > 0) {
|
||||||
|
jtChannel.setGbStatus("OFF");
|
||||||
|
channelList.add(jtChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
channelService.updateStatus(channelList);
|
||||||
|
updateDevice(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流到来的处理
|
* 流到来的处理
|
||||||
*/
|
*/
|
||||||
@ -107,26 +133,37 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备注册的通知
|
* 设备更新的通知
|
||||||
*/
|
*/
|
||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onApplicationEvent(RegisterEvent event) {
|
public void onApplicationEvent(DeviceUpdateEvent event) {
|
||||||
// 首次注册设备根据终端参数获取
|
JTDevice device = event.getDevice();
|
||||||
// JTDevice device = event.getDevice();
|
if (device == null || device.getPhoneNumber() == null) {
|
||||||
// List<JTChannel> channelList = jtChannelMapper.selectAllByDevicePhoneNumber(device.getPhoneNumber());
|
return;
|
||||||
// if (!channelList.isEmpty()) {
|
}
|
||||||
// return;
|
JTDevice deviceInDb = getDevice(event.getDevice().getPhoneNumber());
|
||||||
// }
|
if (deviceInDb.isStatus() != device.isStatus()) {
|
||||||
// JTDeviceConfig jtDeviceConfig = queryConfig(device.getPhoneNumber(), null);
|
// 通道发送状态变化通知
|
||||||
// JTChannelParam channelParam = jtDeviceConfig.getChannelParam();
|
List<JTChannel> jtChannels = jtChannelMapper.selectAll(deviceInDb.getId(), null);
|
||||||
// if (channelParam != null && channelParam.getJtAloneChanelList() != null && !channelParam.getJtAloneChanelList().isEmpty()) {
|
List<CommonGBChannel> channelList = new ArrayList<>();
|
||||||
// // 写入通道
|
for (JTChannel jtChannel : jtChannels) {
|
||||||
// List<JTAloneChanel> jtAloneChanelList = channelParam.getJtAloneChanelList();
|
if (jtChannel.getGbId() > 0) {
|
||||||
// for (JTAloneChanel jtAloneChanel : jtAloneChanelList) {
|
jtChannel.setGbStatus("OFF");
|
||||||
//
|
channelList.add(jtChannel);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
channelService.updateStatus(channelList);
|
||||||
|
}
|
||||||
|
updateDevice(event.getDevice());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 位置更新的通知
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@EventListener
|
||||||
|
public void onApplicationEvent(JTPositionEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -333,6 +333,13 @@ export function queryMediaData(data) {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function setPhoneBook(data) {
|
||||||
|
return request({
|
||||||
|
method: 'post',
|
||||||
|
url: '/api/jt1078/set-phone-book',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
export function shooting(data) {
|
export function shooting(data) {
|
||||||
return request({
|
return request({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|||||||
@ -42,7 +42,6 @@ import {
|
|||||||
stopCruise,
|
stopCruise,
|
||||||
stopScan,
|
stopScan,
|
||||||
wiper,
|
wiper,
|
||||||
getAllForMap,
|
|
||||||
stopPlayChannel,
|
stopPlayChannel,
|
||||||
queryRecord,
|
queryRecord,
|
||||||
playback,
|
playback,
|
||||||
@ -493,16 +492,6 @@ const actions = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getAllForMap({ commit }, params) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
getAllForMap(params).then(response => {
|
|
||||||
const { data } = response
|
|
||||||
resolve(data)
|
|
||||||
}).catch(error => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
queryRecord({ commit }, params) {
|
queryRecord({ commit }, params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
queryRecord(params).then(response => {
|
queryRecord(params).then(response => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user