Commit 8c4d1044 authored by AfirSraftGarrier's avatar AfirSraftGarrier

增加设备使用记录

parent 0f54fe57
......@@ -14,6 +14,7 @@ import iot.sixiang.license.event.EventPublisher;
import iot.sixiang.license.event.ForwardClientRequestEvent;
import iot.sixiang.license.idreader.Safety;
import iot.sixiang.license.model.SessionContext;
import iot.sixiang.license.service.PmsUseService;
import iot.sixiang.license.util.CommonUtil;
import iot.sixiang.license.util.HexUtil;
import iot.sixiang.license.util.SpringUtil;
......@@ -21,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.net.InetSocketAddress;
@Component
......@@ -31,6 +33,8 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
EventPublisher eventPublisher;
@Autowired
Safety safety;
@Resource
private PmsUseService pmsUseService;
public DeviceServerHandler() {
super();
......@@ -129,13 +133,17 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
String channelId = channel.id().asLongText();
if (license) {
// 创建一条使用记录
int useLogId = pmsUseService.createUseLog(sn);
if (useLogId <= 0) {
log.info("创建使用日志不成功...");
return false;
}
SessionContext session = new SessionContext();
session.setRemoteIp(remoteIp);
session.setRemotePort(remotePort);
session.setAppId(appId);
session.setSn(sn);
session.setUseLogId(useLogId);
session.setChannelId(channelId);
session.setClientChannel(channel);
session.setAuthStatus(true);
......
......@@ -11,6 +11,7 @@ public class SessionContext {
private String appId;
private String appKey;
private String sn;
private int useLogId;// 使用日志标识
private boolean authStatus;//授权验证状态
private int status;//当前状态,0 offline,1 online
private String online;//上线时间
......
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