mac 支持 /home 文件夹,无需特殊处理

client 调整,将中文去除掉
This commit is contained in:
2023-12-14 10:33:56 +08:00
parent 2aaff4b59e
commit 47327e8bf1
14 changed files with 29 additions and 27 deletions

View File

@@ -18,6 +18,6 @@ public class EnterClick implements ActionListener {
DoorService doorService = new OldDoorService();
doorService.enterOpenDoor();
// 开门
logger.error("开门成功");
logger.error("test open enter door success ");
}
}

View File

@@ -18,6 +18,6 @@ public class OutClick implements ActionListener {
DoorService doorService = new OldDoorService();
doorService.outOpenDoor();
// 开门
logger.error("开门成功");
logger.error("test out open door success ");
}
}

View File

@@ -21,7 +21,7 @@ public class TestCodeClick implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
logger.error("发送验证二维码消息=========" + barcode.getText());
logger.error("sending barcode msg to api =========" + barcode.getText());
ClientThread.getInstance().checkBarcode(barcode.getText());
}
}

View File

@@ -7,7 +7,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -30,11 +29,17 @@ public class LogService {
session.connect(3000);
}
ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp");
File file = new File("/home/venue/logs/common-default.log");
if (file.exists()) {
File file1 = new File("/home/venue/logs/common-default.log");
File file2 = new File("/home/venue/logs/common-error.log");
if (file1.exists() || file2.exists()) {
sftp.connect();
sftp.put(new FileInputStream(file), "/home/uploadlog/" + System.getProperty(NettyConstant.VENUE_CLIENT_SN) + "-" + sdf.format(new Date()) + "-client.log");
logger.info("上传日志成功");
if (file1.exists()){
sftp.put(new FileInputStream(file1), "/home/uploadlog/" + System.getProperty(NettyConstant.VENUE_CLIENT_SN) + "-" + sdf.format(new Date()) + "-client-common.log");
}
if (file2.exists()) {
sftp.put(new FileInputStream(file2), "/home/uploadlog/" + System.getProperty(NettyConstant.VENUE_CLIENT_SN) + "-" + sdf.format(new Date()) + "-client-error.log");
}
logger.info("upload logs success");
}
if (sftp != null) {
sftp.disconnect();
@@ -43,7 +48,7 @@ public class LogService {
session.disconnect();
}
}catch (Exception e){
logger.error("上传日志失败",e);
logger.error("upload log fail",e);
}
}

View File

@@ -65,7 +65,7 @@ public class MessageService {
DoorService doorService = new OldDoorService();
doorService.enterOpenDoor();
// 开门
logger.info("开门成功");
logger.info("open enter door success");
}
/**
@@ -75,7 +75,7 @@ public class MessageService {
DoorService doorService = new OldDoorService();
doorService.outOpenDoor();
// 开门
logger.info("开门成功");
logger.info("open out door success");
}
}

View File

@@ -30,7 +30,7 @@ public class OldDoorService implements DoorService {
OpenDoor openDoor = new OpenDoor(openDoorParameter);
boolean command = connector.AddCommand(openDoor);
if (!command) {
logger.error("入场开门命令执行失败");
logger.error("enter door open command exec fail");
}
if (openDoor.getIsTimeout()) {
logger.info("----in open door timeout ----");
@@ -57,7 +57,7 @@ public class OldDoorService implements DoorService {
OpenDoor openDoor = new OpenDoor(openDoorParameter);
boolean command = connector.AddCommand(openDoor);
if (!command) {
logger.error("出场开门命令执行失败");
logger.error("out door open command exec fail");
}
if (openDoor.getIsTimeout()) {
logger.info("----out open door timeout ----");

View File

@@ -52,7 +52,7 @@ public class ClientHandler extends SimpleChannelInboundHandler<String> {
*/
@Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
logger.info("接收服务器响应msg:[" + msg + "]");
logger.info("get server msg:[" + msg + "]");
VenueMessage message = JsonUtils.decode(msg, VenueMessage.class);
MessageService.getInstance().execute(message);
}

View File

@@ -84,7 +84,7 @@ public class ClientThread extends Thread{
}
}
}catch (Exception e) {
logger.error("链接失败,发送二维码失败",e);
logger.error("link netty server fail ,send barcode fail",e);
}
}
@@ -93,11 +93,11 @@ public class ClientThread extends Thread{
}
public void doConnect() {
logger.info("现在开始链接了");
logger.info("connecting");
if (closed) {
return;
}
logger.info("连接 = " + remoteHost + " " + remotePort);
logger.info("connect info = " + remoteHost + " " + remotePort);
future = bootstrap.connect(new InetSocketAddress(remoteHost, remotePort));
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture f) throws Exception {
@@ -106,9 +106,9 @@ public class ClientThread extends Thread{
public void run() {
if (!f.isSuccess()) {
doConnect();
logger.info("等待连接");
logger.info("waiting connection");
} else {
logger.info("已连接");
logger.info("connected!");
}
}
}, 2, TimeUnit.SECONDS);

View File

@@ -30,21 +30,21 @@ public class MessageHandler {
public static String checkBarcode(String barcode) {
String decrypt = AesUtil.decrypt(barcode);
if (decrypt == null) {
logger.error("二维码不合法" + barcode);
logger.error("barcode unable to decrypt" + barcode);
return null;
}
// 这个二维码是线下的二维码
if (!decrypt.startsWith("venue-")){
VenueBarCode venueBarCode = MakeCode.decodeCode(barcode);
if (venueBarCode == null) {
logger.error("二维码不合法" + barcode);
logger.error("user barcode can't not decodeCode" + barcode);
return null;
}
}
VenueMessage venueMessage = new VenueMessage();
venueMessage.setMessageType(MessageType.SCAN_CODE);
venueMessage.setMessage(barcode);
logger.info("核销二维码===" + barcode);
logger.info("use barcode to api ===" + barcode);
return EncodeMsg.INSTANCE.encode(venueMessage);
}

View File

@@ -21,7 +21,6 @@ public class ClientService {
public static void main(String[] args) throws IOException, InterruptedException {
File file = new File("/home/venue/client/venue.conf");
// File file = new File("/Users/limqhz/home/venue/client/venue.conf");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line = bufferedReader.readLine();