From 8878705305f99421224b238bf6aedc7277014f92 Mon Sep 17 00:00:00 2001 From: QuShuailong Date: Sat, 8 Apr 2023 10:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=AF=BB=E5=88=B0=E7=9A=84=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E6=A0=87=E7=AD=BE=E5=AD=98=E6=94=BE=E5=88=B0code.text?= =?UTF-8?q?=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zhehekeji/web/service/PlcCmdInfo.java | 2 +- .../web/service/RFID/RFIDSocket.java | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java b/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java index 051893f..c77aa6b 100644 --- a/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java +++ b/web/src/main/java/com/zhehekeji/web/service/PlcCmdInfo.java @@ -97,7 +97,7 @@ public class PlcCmdInfo { } } - //针对单双伸货架 单身的是空,双伸且为外侧为 Out + //针对单双伸货架 单伸的是空,双伸且为外侧为 Out public String getInOutStr(int times){ if (times <= 2) { return separation1 == 1 ? "" : "-Out"; diff --git a/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java b/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java index 8e33031..d70b81e 100644 --- a/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java +++ b/web/src/main/java/com/zhehekeji/web/service/RFID/RFIDSocket.java @@ -4,6 +4,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import java.io.*; + import java.net.InetSocketAddress; import java.net.Socket; import java.util.*; @@ -30,6 +31,10 @@ public class RFIDSocket { private int index; + private static File file; + + private static FileWriter fw; + /** * 读到的所有code标签 */ @@ -53,8 +58,6 @@ public class RFIDSocket { log.error("RFIDSocket time out,ip:{},info:{}",ip,e); close(); - - } } @@ -80,7 +83,6 @@ public class RFIDSocket { log.error("disconnect"); } if(i == -1){ - break; } int count = 0; @@ -101,6 +103,11 @@ public class RFIDSocket { while (buffer.size()> 0){ String code = readTag(); if(code != null){ + if(!tags.contains(code)) + { + fw.write(code+"\n"); + fw.flush(); + } tags.add(code); } } @@ -228,11 +235,22 @@ public class RFIDSocket { } public static void main(String[] args) throws IOException, InterruptedException { - RFIDSocket rfid = new RFIDSocket("172.16.0.220",4001); + RFIDSocket rfid = new RFIDSocket("10.43.26.124",4001); + file = new File("F:\\Leaper\\Programs\\Java\\backend-duoji-monitor\\logs\\code.txt"); + fw = new FileWriter(file, true); + fw.write("\n"); rfid.startCheck(); rfid.readData(); - Thread.sleep(30000); + Thread.sleep(1000*30000); rfid.close(); System.out.println(rfid.getTags()); +// fw.write("\n"); +// fw.flush(); +// for(String tag : rfid.getTags()) +// { +// fw.write(tag+"\n"); +// fw.flush(); +// } + fw.close(); } }