优化
This commit is contained in:
@@ -10,7 +10,7 @@ import com.ruoyi.schedule.plcRead.ddj.PlcDdj1Read;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdj2Read;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.common.domain.CustomThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.DdjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.monit.MonitoringThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1BothWayInSsjThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1BothWayOutSsjThread;
|
||||
@@ -23,6 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -42,7 +48,7 @@ public class ScheduleThread {
|
||||
public CustomThread<Floor2RoadWaySsjThread> floor2OutSsjCustomThread;
|
||||
public CustomThread<LineSsjThread> lineSsjCustomThread;
|
||||
public CustomThread<MonitoringThread> monitoringCustomThread;
|
||||
public CustomThread<Ddj1Thread> ddj1CustomThread;
|
||||
public CustomThread<DdjThread> ddj1CustomThread;
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
@Autowired
|
||||
@@ -89,8 +95,8 @@ public class ScheduleThread {
|
||||
Floor2RoadWaySsjThread floor2OutSsjThread = new Floor2RoadWaySsjThread();
|
||||
floor2OutSsjCustomThread = new CustomThread<Floor2RoadWaySsjThread>(new Thread(floor2OutSsjThread), floor2OutSsjThread);
|
||||
|
||||
Ddj1Thread ddj1Thread = new Ddj1Thread();
|
||||
ddj1CustomThread = new CustomThread<Ddj1Thread>(new Thread(ddj1Thread), ddj1Thread);
|
||||
DdjThread ddj1Thread = new DdjThread();
|
||||
ddj1CustomThread = new CustomThread<DdjThread>(new Thread(ddj1Thread), ddj1Thread);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,9 +154,9 @@ public class ScheduleThread {
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
monitoringCustomThread.thread.start();
|
||||
// floor1BothWayInSsjCustomThread.thread.start();
|
||||
// floor1BothWayOutSsjCustomThread.thread.start();
|
||||
// floor1SingleSsjCustomThread.thread.start();
|
||||
floor1BothWayInSsjCustomThread.thread.start();
|
||||
floor1BothWayOutSsjCustomThread.thread.start();
|
||||
floor1SingleSsjCustomThread.thread.start();
|
||||
floor2InSsjCustomThread.thread.start();
|
||||
lineSsjCustomThread.thread.start();
|
||||
floor2OutSsjCustomThread.thread.start();
|
||||
@@ -194,4 +200,75 @@ public class ScheduleThread {
|
||||
map.put("isRun2",isRun2);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Socket socket = new Socket();
|
||||
// OutputStream out = null;
|
||||
// InputStream in = null;
|
||||
// try {
|
||||
//// socket.connect(new InetSocketAddress("192.168.56.32", 2002), 1000);
|
||||
//// in = socket.getInputStream();
|
||||
//// out = socket.getOutputStream();
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
|
||||
// String code = sendWeight("192.168.56.33", 2002);
|
||||
// System.err.println(code);
|
||||
String pp = "MODEL:EX-1203 COLOR:9005 SERIAL:QT25C1879 V:220 Hz:50 PH:1 N.W.:207kg G.W.:238kg @:9781C52TQ$S0T0T0T3T0U7T0$7005280MA0A@";
|
||||
String ss = "MODEL:TR-360 COLOR:7016 SERIAL:QT25C1899 V:380 Hz:50 PH:3 N.W.:231kg G.W.:261kg @:9981C52TQ$S0T0U5RDS2S3S6T0T3T0U7T0$4105230IF0A@";
|
||||
System.err.println(pp);
|
||||
System.err.println(pp.length());
|
||||
System.err.println(ss.length());
|
||||
}
|
||||
|
||||
public static String sendWeight(String ip, int por) {
|
||||
|
||||
String zhi="";
|
||||
Socket socket = null;
|
||||
OutputStream os = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
//新建客户端并请求服务端的ip为localhost 端口为8088
|
||||
socket = new Socket(ip,por);
|
||||
// System.out.println("socket end ="+System.currentTimeMillis());
|
||||
//休眠3秒
|
||||
Thread.sleep(1000);
|
||||
char[] charArray = new char[500];
|
||||
//获取客户端发送的数据的输入流
|
||||
is = socket.getInputStream();
|
||||
//读取输入流
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
// System.out.println("read begin =" + System.currentTimeMillis());
|
||||
int readLength = inputStreamReader.read(charArray);
|
||||
System.out.println("readLength:"+readLength);
|
||||
if (readLength != -1) {
|
||||
String newString = new String(charArray, 0, readLength);
|
||||
// System.out.println("newString:"+newString+"长度"+newString.length());
|
||||
// newString=newString.replaceAll("\r|\n", "");
|
||||
// if(newString.length()==8&&!newString.equals("=0000000")){
|
||||
// newString=newString.substring(1,8);
|
||||
// newString=newString.replaceAll("^(0+)", "");
|
||||
// zhi=newString;
|
||||
// }
|
||||
zhi = newString;
|
||||
readLength = inputStreamReader.read(charArray);
|
||||
}
|
||||
// System.out.println("read end =" + System.currentTimeMillis());
|
||||
inputStreamReader.close();
|
||||
is.close();
|
||||
socket.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
socket.close();
|
||||
is.close();
|
||||
os.close();
|
||||
} catch (IOException e1)
|
||||
{ e1.printStackTrace(); }
|
||||
}
|
||||
|
||||
return zhi;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user