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(); } }