-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStoreThread.java
66 lines (53 loc) · 1.61 KB
/
StoreThread.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package finalServer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.stream.Collector.Characteristics;
public class StoreThread extends Thread {
Socket client;
BufferedReader br;
PrintWriter pw;
StoreThread(Socket s){
this.client=s;
try {
br = new BufferedReader(new InputStreamReader(client.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void run(){
String info;
try {
while(true){
info=br.readLine();
analysis(info); //分析数据
System.out.println("服务器从仓库收到信息:"+info);
}
} catch (IOException e) {
//与客户端连接失败
e.printStackTrace();
//break;
} }
//info=boolean,price,name,sex,age,id#medicine,count-..
private void analysis(String info) {
String str[]=info.split("#");
String property[]=str[0].split(",");
if(property[0].equals("true")){
String Minfo[]=str[1].split("-");
for(String s:Minfo){
String m[]=s.split(",");
SQLOperate.declineMedicineCount(m[0], Integer.parseInt(m[1]));
}
System.out.println(ChargeThread.allPatient.get(property[5]).department);
Server.sendMessageToPresident(); //发送更新信息给院长
Server.sendMessageToAdmin(); //发送更新信息给管理员
ChargeThread.allPatient.remove(property[5]);
//ChargeThread.patientDepart.remove(property[5]);
}
}
}