rfid扫描出的数据成功的写入数据库

注掉code写文件的逻辑
nanjing-yancao-rfid
LAPTOP-S9HJSOEB\昊天 3 years ago
parent f88f2d128a
commit 4eb9ad1895

@ -632,10 +632,10 @@ public class PlcService {
Thread.sleep(1000*configProperties.getRfid().getScanTime()); Thread.sleep(1000*configProperties.getRfid().getScanTime());
Set<String> tags = RFIDStop(plcCmdInfo); Set<String> tags = RFIDStop(plcCmdInfo);
if(tags!= null && tags.size()>0 && tags.contains(wmsTrayCode)){ if(tags!= null && tags.size()>0 && tags.contains(wmsTrayCode)){
trayCode = ""; trayCode = wmsTrayCode;
trayCheck = Boolean.TRUE; trayCheck = Boolean.TRUE;
}else { }else {
trayCode = "未识别"; trayCode = "";
trayCheck = Boolean.FALSE; trayCheck = Boolean.FALSE;
log.warn("sick ocr error:{}",trayCode); log.warn("sick ocr error:{}",trayCode);
} }

@ -1,5 +1,6 @@
package com.zhehekeji.web.service.RFID; package com.zhehekeji.web.service.RFID;
import com.baomidou.mybatisplus.extension.api.R;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -46,6 +47,7 @@ public class RFIDSocket {
return tags; return tags;
} }
public RFIDSocket(String ip,int port){ public RFIDSocket(String ip,int port){
socket = new Socket(); socket = new Socket();
os = null; os = null;
@ -103,11 +105,13 @@ public class RFIDSocket {
while (buffer.size()> 0){ while (buffer.size()> 0){
String code = readTag(); String code = readTag();
if(code != null){ if(code != null){
if(!tags.contains(code)) // 写入log
/*if(!tags.contains(code))
{ {
fw.write(code+"\n"); fw.write(code+"\n");
fw.flush(); fw.flush();
} }*/
System.out.println(code);
tags.add(code); tags.add(code);
} }
} }
@ -236,7 +240,8 @@ public class RFIDSocket {
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
RFIDSocket rfid = new RFIDSocket("10.43.26.124",4001); RFIDSocket rfid = new RFIDSocket("10.43.26.124",4001);
file = new File("F:\\Leaper\\Programs\\Java\\backend-duoji-monitor\\logs\\code.txt"); file = new File("D:\\code.txt");
file.createNewFile();
fw = new FileWriter(file, true); fw = new FileWriter(file, true);
fw.write("\n"); fw.write("\n");
rfid.startCheck(); rfid.startCheck();

Loading…
Cancel
Save