release-20260330 - 修改为手机开门,不扫码。

This commit is contained in:
2026-03-30 10:58:00 +08:00
parent 0d5c4af3a6
commit c0b011c098
13 changed files with 260 additions and 96 deletions

View File

@@ -1,37 +1,81 @@
package com.sv.intergration.impl;
import Net.PC15.Command.CommandDetial;
import Net.PC15.Command.INCommand;
import Net.PC15.Command.INCommandResult;
import Net.PC15.Connector.ConnectorAllocator;
import Net.PC15.Connector.ConnectorDetial;
import Net.PC15.Connector.E_ControllerType;
import Net.PC15.Connector.INConnectorEvent;
import Net.PC15.Connector.TCPClient.TCPClientDetial;
import Net.PC15.Data.INData;
import Net.PC15.FC8800.Command.Door.OpenDoor;
import Net.PC15.FC8800.Command.Door.Parameter.OpenDoor_Parameter;
import Net.PC15.FC8800.FC8800Identity;
import com.sv.intergration.DoorService;
import com.sv.netty.config.NettyConstant;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import com.sv.netty.utils.JsonUtils;
public class OldDoorService implements DoorService {
private static INConnectorEvent listener;
static {
listener = new INConnectorEvent() {
@Override
public void CommandCompleteEvent(INCommand inCommand, INCommandResult inCommandResult) {
logger.info("CommandCompleteEvent open door success");
}
@Override
public void CommandProcessEvent(INCommand inCommand) {
logger.info("CommandProcessEvent open door ...");
}
@Override
public void ConnectorErrorEvent(INCommand inCommand, boolean b) {
logger.info("CommandProcessEvent open door ... the bool is " + b);
}
@Override
public void ConnectorErrorEvent(ConnectorDetial connectorDetial) {
logger.error("ConnectorErrorEvent open door error");
}
@Override
public void CommandTimeout(INCommand inCommand) {
logger.error("CommandTimeout open door time out");
}
@Override
public void PasswordErrorEvent(INCommand inCommand) {
logger.error("PasswordErrorEvent open door password error");
}
@Override
public void ChecksumErrorEvent(INCommand inCommand) {
logger.error("ChecksumErrorEvent open door error");
}
@Override
public void WatchEvent(ConnectorDetial connectorDetial, INData inData) {
logger.error("WatchEvent open door ...");
}
};
}
@Override
public void enterOpenDoor() {
opendoor(1);
openDoor(1);
}
@Override
public void outOpenDoor() {
opendoor(2);
openDoor(2);
}
private void opendoor(int doorSn) {
private void openDoor(int doorSn) {
try {
// 1. 先检查网络连通性Java 层)
if (!isNetworkReachable("192.168.1.150", 8000, 2000)) {
throw new RuntimeException("net socket error: 192.168.1.150:8000");
}
ConnectorAllocator connector = ConnectorAllocator.GetAllocator();
TCPClientDetial tcpClientDetial = new TCPClientDetial("192.168.1.150", Integer.valueOf("8000"));
connector.GetCommandCount(tcpClientDetial);
@@ -39,29 +83,16 @@ public class OldDoorService implements DoorService {
CommandDetial detial = new CommandDetial();
detial.Connector = tcpClientDetial;
String clientSn = System.getProperty(NettyConstant.VENUE_CLIENT_SN);
// detial.Identity = new FC8800Identity("MC-5824T23014127", "12345678", E_ControllerType.FC8900);
detial.Identity = new FC8800Identity(clientSn, "12345678", E_ControllerType.FC8900);
OpenDoor_Parameter openDoorParameter = new OpenDoor_Parameter(detial);
openDoorParameter.Door.SetDoor(doorSn, 1);
for (int i = 0; i < 3; i++) {
logger.info("{} times to try...", i + 1);
boolean connected = connector.IsForciblyConnect(tcpClientDetial);
if (connected) {
logger.info("[{}] connected");
break;
}
logger.warn("[{}] times to try, trying", i + 1);
Thread.sleep(1000); // 等待 1 秒后重试
}
OpenDoor openDoor = new OpenDoor(openDoorParameter);
boolean command = connector.AddCommand(openDoor);
if (!command) {
logger.error("sn-{} door open command exec fail",doorSn);
}
connector.AddListener(listener);
System.out.println(connector.IsRelease());
if (openDoor.getIsTimeout()) {
logger.info("----sn-{} open door timeout ----",doorSn);
}
@@ -70,15 +101,4 @@ public class OldDoorService implements DoorService {
}
}
// 网络连通性检查Java 层)
private boolean isNetworkReachable(String host, int port, int timeoutMs) {
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(host, port), timeoutMs);
return true;
} catch (IOException e) {
logger.error("net link error: {}:{} - {}", host, port, e.getMessage());
return false;
}
}
}