htr commited on
Commit
d781d0d
·
1 Parent(s): b9a58b3

Signed-off-by: htr <[email protected]>

src/main/java/com/example/demo/DemoApplication.java CHANGED
@@ -136,7 +136,7 @@ public class DemoApplication {
136
  return "ok";
137
  }
138
 
139
- @RequestMapping(value = "/updateInfo", method = RequestMethod.POST)
140
  @ResponseBody
141
  public String updateInfo(
142
  @RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException, Exception {
@@ -209,19 +209,6 @@ public class DemoApplication {
209
  return "not-ok";
210
  }
211
 
212
- @GetMapping("createSocketapi")
213
- public String createSocketApi(@RequestParam(value = "id", required = true) String id) throws Exception {
214
- String output = "";
215
- List<SessionEntity> ss = Tqtk.listSession;
216
- for (int i = 0; i < ss.size(); ++i) {
217
- if (id.equals(ss.get(i).getUserId())) {
218
- Worker.createSocketApi(ss.get(i));
219
- return "ok";
220
- }
221
- }
222
- return "not-ok";
223
- }
224
-
225
  @GetMapping("setSessionId")
226
  public String setSessionId(@RequestParam(value = "id", required = true) String id,
227
  @RequestParam(value = "session", required = true) String session) throws Exception {
 
136
  return "ok";
137
  }
138
 
139
+ @RequestMapping(value = "/updateInfo", method = RequestMethod.GET)
140
  @ResponseBody
141
  public String updateInfo(
142
  @RequestParam(value = "id", required = true) String id) throws IOException, UnknownHostException, InterruptedException, Exception {
 
209
  return "not-ok";
210
  }
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  @GetMapping("setSessionId")
213
  public String setSessionId(@RequestParam(value = "id", required = true) String id,
214
  @RequestParam(value = "session", required = true) String session) throws Exception {
src/main/java/tqtk/Entity/SessionEntity.java CHANGED
@@ -12,6 +12,7 @@ import java.net.InetSocketAddress;
12
  import java.net.Socket;
13
  import java.util.List;
14
  import java.util.ArrayList;
 
15
  /**
16
  *
17
  * @author Alex
@@ -27,19 +28,37 @@ public class SessionEntity {
27
  @JsonProperty("UserId")
28
  String UserId;
29
  @JsonProperty("ItemIds")
30
- List<String> ItemIds= new ArrayList();
31
  @JsonProperty("HeroIds")
32
- List<String> HeroIds= new ArrayList();
33
  @JsonProperty("BuildingIds")
34
- List<String> BuildingIds= new ArrayList();
35
  @JsonProperty("SkillIds")
36
  List<String> SkillIds = new ArrayList();
 
 
37
 
38
  private Socket socket;
39
  private boolean isConnected;
40
  private String stringName;
41
  private Socket socketApi;
42
- private Socket socketTN;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  public String getIp() {
45
  return Ip;
@@ -81,8 +100,6 @@ public class SessionEntity {
81
  this.ItemIds = ItemIds;
82
  }
83
 
84
-
85
-
86
  public List<String> getHeroIds() {
87
  return HeroIds;
88
  }
@@ -107,15 +124,6 @@ public class SessionEntity {
107
  this.SkillIds = SkillIds;
108
  }
109
 
110
-
111
-
112
- public Socket getSocketTN() {
113
- return socketTN;
114
- }
115
-
116
- public void setSocketTN(Socket socketTN) {
117
- this.socketTN = socketTN;
118
- }
119
 
120
  public Socket getSocketApi() {
121
  return socketApi;
@@ -133,7 +141,6 @@ public class SessionEntity {
133
  this.stringName = stringName;
134
  }
135
 
136
-
137
  public SessionEntity() {
138
  }
139
 
@@ -143,7 +150,6 @@ public class SessionEntity {
143
  this.socket.connect(new InetSocketAddress(InetAddress.getByName(Ip), Integer.parseInt(Port)), 7000);
144
  }
145
 
146
-
147
  public boolean isIsConnected() {
148
  return isConnected;
149
  }
 
12
  import java.net.Socket;
13
  import java.util.List;
14
  import java.util.ArrayList;
15
+
16
  /**
17
  *
18
  * @author Alex
 
28
  @JsonProperty("UserId")
29
  String UserId;
30
  @JsonProperty("ItemIds")
31
+ List<String> ItemIds = new ArrayList();
32
  @JsonProperty("HeroIds")
33
+ List<String> HeroIds = new ArrayList();
34
  @JsonProperty("BuildingIds")
35
+ List<String> BuildingIds = new ArrayList();
36
  @JsonProperty("SkillIds")
37
  List<String> SkillIds = new ArrayList();
38
+ @JsonProperty("LinhThuKoHa")
39
+ List<String> LinhThuKoHa = new ArrayList();
40
 
41
  private Socket socket;
42
  private boolean isConnected;
43
  private String stringName;
44
  private Socket socketApi;
45
+ private Socket socketNuoiLinhThu;
46
+
47
+ public Socket getSocketNuoiLinhThu() {
48
+ return socketNuoiLinhThu;
49
+ }
50
+
51
+ public void setSocketNuoiLinhThu(Socket socketNuoiLinhThu) {
52
+ this.socketNuoiLinhThu = socketNuoiLinhThu;
53
+ }
54
+
55
+ public List<String> getLinhThuKoHa() {
56
+ return LinhThuKoHa;
57
+ }
58
+
59
+ public void setLinhThuKoHa(List<String> LinhThuKoHa) {
60
+ this.LinhThuKoHa = LinhThuKoHa;
61
+ }
62
 
63
  public String getIp() {
64
  return Ip;
 
100
  this.ItemIds = ItemIds;
101
  }
102
 
 
 
103
  public List<String> getHeroIds() {
104
  return HeroIds;
105
  }
 
124
  this.SkillIds = SkillIds;
125
  }
126
 
 
 
 
 
 
 
 
 
 
127
 
128
  public Socket getSocketApi() {
129
  return socketApi;
 
141
  this.stringName = stringName;
142
  }
143
 
 
144
  public SessionEntity() {
145
  }
146
 
 
150
  this.socket.connect(new InetSocketAddress(InetAddress.getByName(Ip), Integer.parseInt(Port)), 7000);
151
  }
152
 
 
153
  public boolean isIsConnected() {
154
  return isConnected;
155
  }
src/main/java/tqtk/Utils/Util.java CHANGED
@@ -496,7 +496,7 @@ public class Util {
496
  //window
497
  // String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
498
  //heroku
499
- String x = "/" + file_name;
500
  try {
501
  return Doc_file_kieu_txt.readFile(x);
502
  } catch (Exception e) {
 
496
  //window
497
  // String x = "D:\\7-Project\\Java\\1. Netbean\\2. nghien-cuu\\TQTK\\runshell\\cauhoi\\"+file_name;
498
  //heroku
499
+ String x = file_name;
500
  try {
501
  return Doc_file_kieu_txt.readFile(x);
502
  } catch (Exception e) {
src/main/java/tqtk/XuLy/Worker.java CHANGED
@@ -1,3 +1,4 @@
 
1
  package tqtk.XuLy;
2
 
3
  import com.fasterxml.jackson.core.type.TypeReference;
@@ -25,10 +26,13 @@ import tqtk.XuLy.login.LayThongTinSession;
25
  import static tqtk.XuLy.XuLyPacket.GuiPacket;
26
  import static tqtk.XuLy.XuLyPacket.GuiPacketTN;
27
  import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQ;
 
 
28
  import tqtk.exception.JsonException;
29
  import java.io.*;
30
  import java.util.*;
31
  import java.util.Collections;
 
32
  /**
33
  *
34
  * @author Alex
@@ -90,6 +94,27 @@ public class Worker extends Thread {
90
 
91
  }
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  public void LuyenTuong() {
94
  List<String> list1 = new ArrayList<>();
95
  list1.add(0, "0");
@@ -683,6 +708,10 @@ public class Worker extends Thread {
683
  List<String> list1 = new ArrayList<>();
684
  list1.add(0, "17");
685
  list1.add(1, "1");
 
 
 
 
686
  try {
687
 
688
  Tqtk.sendMessage("nhan thuong " + ss.getUserId());
@@ -725,10 +754,14 @@ public class Worker extends Thread {
725
  // ki ten
726
  Thread.sleep(2000);
727
  GuiPacket(ss, "60701", null);
728
- Thread.sleep(5000);
729
  GuiPacket(ss, "60702", null);
730
- Thread.sleep(5000);
731
  GuiPacket(ss, "60703", null);
 
 
 
 
732
 
733
  } catch (Exception e) {
734
  System.out.println("NhanThuong " + ss.getUserId() + e.getMessage());
@@ -811,6 +844,58 @@ public class Worker extends Thread {
811
 
812
  }
813
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
  public void ThuThue() {
815
  // danh quan doan vu van thi toc
816
  List<String> list1 = new ArrayList<>();
@@ -820,7 +905,8 @@ public class Worker extends Thread {
820
  list2.add(0, "0");
821
 
822
  try {
823
- StringBuilder rs1 = GuiPacket(ss, "12401", list1);
 
824
  Thread.sleep(5000);
825
  if (rs1 != null) {
826
  try {
@@ -846,7 +932,7 @@ public class Worker extends Thread {
846
  String optdisc1 = (String) carMap1.get("optdisc1");
847
  String optdisc2 = (String) carMap1.get("optdisc2");
848
 
849
- List<String> cauhoi = Util.docFileCauHoiThuThue("thu_thue_dan_tam.txt");
850
 
851
  for (String item : cauhoi) {
852
  if (optdisc1.contains(item)) {
@@ -873,6 +959,10 @@ public class Worker extends Thread {
873
  }
874
 
875
  }
 
 
 
 
876
  } catch (Exception ex) {
877
  if (!(ex instanceof JsonException)) {
878
  System.out.println("loi qd " + ss.getUserId() + ex.getMessage());
@@ -1121,14 +1211,12 @@ public class Worker extends Thread {
1121
  throw new JsonException();
1122
  }
1123
  } else {
1124
- dangNhapLayThongTin();
1125
- GuiPacketDeLogin();
1126
  }
1127
  } catch (Exception ex) {
1128
  if (!(ex instanceof JsonException)) {
1129
  System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
1130
- dangNhapLayThongTin();
1131
- GuiPacketDeLogin();
1132
  } else {
1133
  System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
1134
  }
@@ -1212,14 +1300,12 @@ public class Worker extends Thread {
1212
  throw new JsonException();
1213
  }
1214
  } else {
1215
- dangNhapLayThongTin();
1216
- GuiPacketDeLogin();
1217
  }
1218
  } catch (Exception ex) {
1219
  if (!(ex instanceof JsonException)) {
1220
  System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
1221
- dangNhapLayThongTin();
1222
- GuiPacketDeLogin();
1223
  } else {
1224
  System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
1225
  }
@@ -1259,9 +1345,9 @@ public class Worker extends Thread {
1259
  mer.add(merchantid);
1260
  }
1261
  }
1262
- System.out.println("UyPhai " + ss.getUserId() + " "+ mer.get(mer.size() - 1).toString());
1263
  Collections.sort(mer);
1264
- list1.set(0, mer.get(mer.size() - 1).toString());
1265
  GuiPacket(ss, "40102", list1);
1266
  Thread.sleep(4000);
1267
  GuiPacket(ss, "40103", null);
@@ -1272,8 +1358,7 @@ public class Worker extends Thread {
1272
  } catch (Exception ex) {
1273
  if (!(ex instanceof JsonException)) {
1274
  System.out.println("UyPhai " + ss.getUserId() + ex.getMessage());
1275
- dangNhapLayThongTin();
1276
- GuiPacketDeLogin();
1277
  } else {
1278
  System.out.println("UyPhai json " + ss.getUserId() + ex.getMessage());
1279
  }
@@ -1296,14 +1381,14 @@ public class Worker extends Thread {
1296
  StringBuilder rs = GuiPacket(ss, "62007", list1);
1297
  Thread.sleep(5000);
1298
  if (rs != null) {
1299
- if (!rs.toString().contains("掘削中です")) {
1300
- Tqtk.sendMessage("gian khoan " + ss.getUserId());
1301
  // bat dau khoan
1302
- GuiPacket(ss, "62006", list2);
 
 
 
1303
  }
1304
- } else {
1305
-
1306
- }
1307
 
1308
  } catch (Exception ex) {
1309
  System.out.println(ex.getMessage());
@@ -1330,28 +1415,37 @@ public class Worker extends Thread {
1330
  ss.setSocket(socket);
1331
  }
1332
 
 
 
 
 
 
 
 
 
 
1333
  public void taoSocketTruyNa() throws Exception {
1334
  Socket socket = new Socket();
1335
  socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
1336
- if (ss.getSocketTN() != null) {
1337
- ss.getSocketTN().close();
1338
  }
1339
- ss.setSocketTN(socket);
1340
  }
1341
 
1342
  public void CapNhatThongTin() throws IOException, UnknownHostException, InterruptedException, Exception {
1343
  try {
1344
  Thread.sleep(5000);
1345
  String rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1346
-
1347
- tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "12400", null);
1348
-
1349
- List<String> list1 = new ArrayList<>();
1350
- list1.add(0, "1");
1351
- GuiPacket(ss, "12200", list1);
1352
- list1 = null;
1353
-
1354
- rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1355
  if (rs1 != null && rs1 != "") {
1356
  try {
1357
  String[] temp = rs1.toString().split("");
@@ -1378,13 +1472,11 @@ public class Worker extends Thread {
1378
  throw new JsonException();
1379
  }
1380
  }
1381
-
1382
-
1383
  } catch (Exception ex) {
1384
  if (!(ex instanceof JsonException)) {
1385
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1386
- dangNhapLayThongTin();
1387
- GuiPacketDeLogin();
1388
  } else {
1389
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1390
  }
@@ -1392,21 +1484,69 @@ public class Worker extends Thread {
1392
  }
1393
 
1394
  }
1395
-
1396
-
1397
- public static void StaticCapNhatThongTin(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398
  try {
1399
  Thread.sleep(5000);
1400
  String rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1401
-
1402
- tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "12400", null);
1403
-
1404
- List<String> list1 = new ArrayList<>();
1405
- list1.add(0, "1");
1406
- GuiPacket(ss, "12200", list1);
1407
- list1 = null;
1408
-
1409
- rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1410
  } catch (Exception ex) {
1411
  if (!(ex instanceof JsonException)) {
1412
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
@@ -1483,8 +1623,7 @@ public class Worker extends Thread {
1483
  } catch (Exception ex) {
1484
  if (!(ex instanceof JsonException)) {
1485
  System.out.println("cho den " + ss.getUserId() + ex.getMessage());
1486
- dangNhapLayThongTin();
1487
- GuiPacketDeLogin();
1488
  } else {
1489
  System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
1490
  }
@@ -1493,6 +1632,7 @@ public class Worker extends Thread {
1493
 
1494
  }
1495
 
 
1496
  public void MuaRuong() throws IOException, UnknownHostException, InterruptedException, Exception {
1497
  List<String> list1 = new ArrayList<>();
1498
  list1.add(0, "3");
@@ -1555,8 +1695,7 @@ public class Worker extends Thread {
1555
  } catch (Exception ex) {
1556
  if (!(ex instanceof JsonException)) {
1557
  System.out.println("cho den " + ss.getUserId() + ex.getMessage());
1558
- dangNhapLayThongTin();
1559
- GuiPacketDeLogin();
1560
  } else {
1561
  System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
1562
  }
@@ -1564,6 +1703,90 @@ public class Worker extends Thread {
1564
  }
1565
 
1566
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1567
 
1568
  public static void createSocket(SessionEntity session) throws Exception {
1569
  Socket socket = new Socket();
@@ -1574,24 +1797,56 @@ public class Worker extends Thread {
1574
  } catch (Exception e) {
1575
  }
1576
  session.setSocket(socket);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1577
 
1578
-
1579
- try {
1580
- GuiPacketKhongKQ(session, "10100", null);
1581
- // packet cap nhat thong tin lien tuc tu server
1582
- Thread.sleep(5000);
1583
- StaticCapNhatThongTin(session);
1584
- Thread.sleep(5000);
1585
- GuiPacketKhongKQ(session, "52103", null);
1586
- Thread.sleep(5000);
1587
- GuiPacketKhongKQ(session, "10108", null);
1588
- Thread.sleep(5000);
1589
- GuiPacketKhongKQ(session, "20101", null);
1590
- Thread.sleep(5000);
1591
- List<String> list1 = new ArrayList<>();
1592
- list1.add(0, "1");
1593
- StringBuilder rs1 = GuiPacket(session, "12200", list1);
1594
- list1 = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
1595
  } catch (Exception e) {
1596
  }
1597
 
@@ -1624,15 +1879,15 @@ public class Worker extends Thread {
1624
  try {
1625
  dangNhapLayThongTin();
1626
  GuiPacketDeLogin();
 
1627
  while (true) {
1628
  try {
1629
  //if (!ss.getUserId().equals("2301230011011923")) {
1630
  // TruyNa2();
1631
  //}
1632
-
1633
 
1634
  MuaLinh();
1635
-
1636
  NangItem();
1637
  LuyenTuong();
1638
  NangNha();
@@ -1640,7 +1895,7 @@ public class Worker extends Thread {
1640
  NhanThuong();
1641
  GianKhoan();
1642
  // FarmDoLv60();
1643
- // ThuThue();
1644
 
1645
  ChiemMo();
1646
  ChiemRuong();
 
1
+
2
  package tqtk.XuLy;
3
 
4
  import com.fasterxml.jackson.core.type.TypeReference;
 
26
  import static tqtk.XuLy.XuLyPacket.GuiPacket;
27
  import static tqtk.XuLy.XuLyPacket.GuiPacketTN;
28
  import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQ;
29
+ import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQLinhThu;
30
+ import static tqtk.XuLy.XuLyPacket.GuiPacketLinhThu;
31
  import tqtk.exception.JsonException;
32
  import java.io.*;
33
  import java.util.*;
34
  import java.util.Collections;
35
+
36
  /**
37
  *
38
  * @author Alex
 
94
 
95
  }
96
 
97
+ public void GuiPacketDeLogin2(SessionEntity ss) throws InterruptedException, IOException, Exception {
98
+ // packet duy tri dang nhap , neu muon truy cap vao 1 acc tu` nhieu noi thi , phai co'
99
+ // 1 noi dang nhap truoc roi , luc nay se ko can chay packet 10100
100
+ // Thread.sleep(5000);
101
+ // packet cap nhat thong tin lien tuc tu server
102
+ Thread.sleep(5000);
103
+ GuiPacketKhongKQLinhThu(ss, "11102", null);
104
+ Thread.sleep(5000);
105
+ GuiPacketKhongKQLinhThu(ss, "52103", null);
106
+ Thread.sleep(5000);
107
+ GuiPacketKhongKQLinhThu(ss, "10108", null);
108
+ Thread.sleep(5000);
109
+ GuiPacketKhongKQLinhThu(ss, "20101", null);
110
+ Thread.sleep(5000);
111
+ List<String> list1 = new ArrayList<>();
112
+ list1.add(0, "1");
113
+ StringBuilder rs1 = GuiPacketLinhThu(ss, "12200", list1);
114
+ list1 = null;
115
+
116
+ }
117
+
118
  public void LuyenTuong() {
119
  List<String> list1 = new ArrayList<>();
120
  list1.add(0, "0");
 
708
  List<String> list1 = new ArrayList<>();
709
  list1.add(0, "17");
710
  list1.add(1, "1");
711
+
712
+ List<String> list2 = new ArrayList<>();
713
+ list2.add(0, "1");
714
+
715
  try {
716
 
717
  Tqtk.sendMessage("nhan thuong " + ss.getUserId());
 
754
  // ki ten
755
  Thread.sleep(2000);
756
  GuiPacket(ss, "60701", null);
757
+ Thread.sleep(2000);
758
  GuiPacket(ss, "60702", null);
759
+ Thread.sleep(2000);
760
  GuiPacket(ss, "60703", null);
761
+
762
+ // quay so
763
+ Thread.sleep(2000);
764
+ GuiPacket(ss, "64002", list2);
765
 
766
  } catch (Exception e) {
767
  System.out.println("NhanThuong " + ss.getUserId() + e.getMessage());
 
844
 
845
  }
846
 
847
+ public boolean CheckThuThue() {
848
+ // danh quan doan vu van thi toc
849
+
850
+ try {
851
+ StringBuilder rs1 = GuiPacket(ss, "12400", null);
852
+ Thread.sleep(5000);
853
+ if (rs1 != null) {
854
+ try {
855
+ String[] temp = rs1.toString().split("");
856
+
857
+ ObjectMapper mapper = new ObjectMapper();
858
+ Map<String, Object> carMap = null;
859
+ int h = 0;
860
+ for (String string : temp) {
861
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
862
+ });
863
+ h = (int) carMap.get("h");
864
+ if (h == Integer.parseInt("12400")) {
865
+ break;
866
+ }
867
+ }
868
+ if(carMap == null){
869
+ return false;
870
+ }
871
+ Map<String, Object> carMap1 = (Map<String, Object>) ((Map<String, Object>) carMap.get("m")).get("imposedto");
872
+
873
+
874
+
875
+ if (carMap1 != null) {
876
+ Integer imposenum = (Integer) carMap1.get("imposenum");
877
+ if(imposenum>38){
878
+ return true;
879
+ }
880
+ return false;
881
+ }
882
+ } catch (Exception e) {
883
+ throw new JsonException();
884
+ }
885
+
886
+ }
887
+ return false;
888
+ } catch (Exception ex) {
889
+ if (!(ex instanceof JsonException)) {
890
+ System.out.println("loi qd " + ss.getUserId() + ex.getMessage());
891
+ } else {
892
+ System.out.println("loi qd json" + ss.getUserId() + ex.getMessage());
893
+ }
894
+ return false;
895
+ }
896
+ }
897
+
898
+
899
  public void ThuThue() {
900
  // danh quan doan vu van thi toc
901
  List<String> list1 = new ArrayList<>();
 
905
  list2.add(0, "0");
906
 
907
  try {
908
+ if(CheckThuThue()){
909
+ StringBuilder rs1 = GuiPacket(ss, "12401", list1);
910
  Thread.sleep(5000);
911
  if (rs1 != null) {
912
  try {
 
932
  String optdisc1 = (String) carMap1.get("optdisc1");
933
  String optdisc2 = (String) carMap1.get("optdisc2");
934
 
935
+ List<String> cauhoi = Util.docFileCauHoiThuThue("user.properties");
936
 
937
  for (String item : cauhoi) {
938
  if (optdisc1.contains(item)) {
 
959
  }
960
 
961
  }
962
+
963
+
964
+ }
965
+
966
  } catch (Exception ex) {
967
  if (!(ex instanceof JsonException)) {
968
  System.out.println("loi qd " + ss.getUserId() + ex.getMessage());
 
1211
  throw new JsonException();
1212
  }
1213
  } else {
1214
+
 
1215
  }
1216
  } catch (Exception ex) {
1217
  if (!(ex instanceof JsonException)) {
1218
  System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
1219
+
 
1220
  } else {
1221
  System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
1222
  }
 
1300
  throw new JsonException();
1301
  }
1302
  } else {
1303
+
 
1304
  }
1305
  } catch (Exception ex) {
1306
  if (!(ex instanceof JsonException)) {
1307
  System.out.println("NangItem " + ss.getUserId() + ex.getMessage());
1308
+
 
1309
  } else {
1310
  System.out.println("NangItem json " + ss.getUserId() + ex.getMessage());
1311
  }
 
1345
  mer.add(merchantid);
1346
  }
1347
  }
1348
+ System.out.println("UyPhai " + ss.getUserId() + " " + mer.get(mer.size() - 1).toString());
1349
  Collections.sort(mer);
1350
+ list1.set(0, mer.get(mer.size() - 1).toString());
1351
  GuiPacket(ss, "40102", list1);
1352
  Thread.sleep(4000);
1353
  GuiPacket(ss, "40103", null);
 
1358
  } catch (Exception ex) {
1359
  if (!(ex instanceof JsonException)) {
1360
  System.out.println("UyPhai " + ss.getUserId() + ex.getMessage());
1361
+
 
1362
  } else {
1363
  System.out.println("UyPhai json " + ss.getUserId() + ex.getMessage());
1364
  }
 
1381
  StringBuilder rs = GuiPacket(ss, "62007", list1);
1382
  Thread.sleep(5000);
1383
  if (rs != null) {
1384
+ Tqtk.sendMessage("gian khoan " + ss.getUserId());
 
1385
  // bat dau khoan
1386
+ GuiPacket(ss, "62006", list2);
1387
+
1388
+ if (!rs.toString().contains("掘削中です")) {
1389
+
1390
  }
1391
+ }
 
 
1392
 
1393
  } catch (Exception ex) {
1394
  System.out.println(ex.getMessage());
 
1415
  ss.setSocket(socket);
1416
  }
1417
 
1418
+ public void dangNhapLayThongTin2(SessionEntity ss) throws Exception {
1419
+ Socket socket = new Socket();
1420
+ socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
1421
+ if (ss.getSocketNuoiLinhThu() != null) {
1422
+ ss.getSocketNuoiLinhThu().close();
1423
+ }
1424
+ ss.setSocketNuoiLinhThu(socket);
1425
+ }
1426
+
1427
  public void taoSocketTruyNa() throws Exception {
1428
  Socket socket = new Socket();
1429
  socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
1430
+ if (ss.getSocket() != null) {
1431
+ ss.getSocket().close();
1432
  }
1433
+ ss.setSocket(socket);
1434
  }
1435
 
1436
  public void CapNhatThongTin() throws IOException, UnknownHostException, InterruptedException, Exception {
1437
  try {
1438
  Thread.sleep(5000);
1439
  String rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1440
+
1441
+ tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "12400", null);
1442
+
1443
+ List<String> list1 = new ArrayList<>();
1444
+ list1.add(0, "1");
1445
+ GuiPacket(ss, "12200", list1);
1446
+ list1 = null;
1447
+
1448
+ rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1449
  if (rs1 != null && rs1 != "") {
1450
  try {
1451
  String[] temp = rs1.toString().split("");
 
1472
  throw new JsonException();
1473
  }
1474
  }
1475
+
 
1476
  } catch (Exception ex) {
1477
  if (!(ex instanceof JsonException)) {
1478
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1479
+
 
1480
  } else {
1481
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1482
  }
 
1484
  }
1485
 
1486
  }
1487
+
1488
+ public void CapNhatThongTin2() throws IOException, UnknownHostException, InterruptedException, Exception {
1489
+ try {
1490
+ Thread.sleep(5000);
1491
+ GuiPacketKhongKQLinhThu(ss, "11102", null);
1492
+
1493
+ GuiPacketKhongKQLinhThu(ss, "12400", null);
1494
+
1495
+ List<String> list1 = new ArrayList<>();
1496
+ list1.add(0, "1");
1497
+ GuiPacketKhongKQLinhThu(ss, "12200", list1);
1498
+ list1 = null;
1499
+
1500
+ GuiPacketKhongKQLinhThu(ss, "11102", null);
1501
+
1502
+ } catch (Exception ex) {
1503
+ if (!(ex instanceof JsonException)) {
1504
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1505
+ } else {
1506
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1507
+ }
1508
+
1509
+ }
1510
+
1511
+ }
1512
+
1513
+ public static void StaticCapNhatThongTin(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
1514
  try {
1515
  Thread.sleep(5000);
1516
  String rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1517
+
1518
+ tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "12400", null);
1519
+
1520
+ List<String> list1 = new ArrayList<>();
1521
+ list1.add(0, "1");
1522
+ GuiPacket(ss, "12200", list1);
1523
+ list1 = null;
1524
+
1525
+ rs1 = tqtk.XuLy.XuLyPacket.GuiPacket1(ss, "11102", null);
1526
+ } catch (Exception ex) {
1527
+ if (!(ex instanceof JsonException)) {
1528
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1529
+ } else {
1530
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
1531
+ }
1532
+
1533
+ }
1534
+
1535
+ }
1536
+
1537
+ public static void StaticCapNhatThongTinLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
1538
+ try {
1539
+ Thread.sleep(5000);
1540
+ GuiPacketLinhThu(ss, "11102", null);
1541
+
1542
+ GuiPacketLinhThu(ss, "12400", null);
1543
+
1544
+ List<String> list1 = new ArrayList<>();
1545
+ list1.add(0, "1");
1546
+ GuiPacketLinhThu(ss, "12200", list1);
1547
+ list1 = null;
1548
+
1549
+ GuiPacketLinhThu(ss, "11102", null);
1550
  } catch (Exception ex) {
1551
  if (!(ex instanceof JsonException)) {
1552
  System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
 
1623
  } catch (Exception ex) {
1624
  if (!(ex instanceof JsonException)) {
1625
  System.out.println("cho den " + ss.getUserId() + ex.getMessage());
1626
+
 
1627
  } else {
1628
  System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
1629
  }
 
1632
 
1633
  }
1634
 
1635
+
1636
  public void MuaRuong() throws IOException, UnknownHostException, InterruptedException, Exception {
1637
  List<String> list1 = new ArrayList<>();
1638
  list1.add(0, "3");
 
1695
  } catch (Exception ex) {
1696
  if (!(ex instanceof JsonException)) {
1697
  System.out.println("cho den " + ss.getUserId() + ex.getMessage());
1698
+
 
1699
  } else {
1700
  System.out.println("cho den json " + ss.getUserId() + ex.getMessage());
1701
  }
 
1703
  }
1704
 
1705
  }
1706
+
1707
+
1708
+ public void NangHaLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
1709
+ List<String> list1 = new ArrayList<>();
1710
+ list1.add(0, "0");
1711
+ list1.add(1, "0");
1712
+ list1.add(2, "40");
1713
+
1714
+ List<String> list2 = new ArrayList<>();
1715
+ list2.add(0, "0");
1716
+ list2.add(1, "0");
1717
+ try {
1718
+ Thread.sleep(5000);
1719
+ StringBuilder rs1 = GuiPacket(ss, "49101", list1);
1720
+ if (rs1 != null && rs1.toString() != "") {
1721
+ try {
1722
+ String[] temp = rs1.toString().split("");
1723
+
1724
+ ObjectMapper mapper = new ObjectMapper();
1725
+ Map<String, Object> carMap = null;
1726
+ int h = 0;
1727
+ for (String string : temp) {
1728
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
1729
+ });
1730
+ h = (int) carMap.get("h");
1731
+ if (h == Integer.parseInt("49101")) {
1732
+ break;
1733
+ }
1734
+ }
1735
+
1736
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("formationguardequipdto");
1737
+
1738
+ if (carMap1 == null) {
1739
+ return;
1740
+ }
1741
+ System.out.println("setup linh thu");
1742
+ Object Magic = (Object) ((Map<String, Object>) carMap.get("m")).get("magic");
1743
+ String[] tmp = Magic.toString().split(",");
1744
+ String sMagic = "";
1745
+
1746
+ int lv = 0;
1747
+ int lvmagic = 0;
1748
+ Integer storeid = 0;
1749
+
1750
+ for (Object object : carMap1) {
1751
+ storeid = (Integer) ((Map<Object, Object>) object).get("storeid");
1752
+ lvmagic = (Integer) ((Map<Object, Object>) object).get("equiplevel");
1753
+ sMagic = tmp[lvmagic - 1];
1754
+ lvmagic = Integer.parseInt(sMagic);
1755
+ if (lvmagic > 75) {
1756
+ list1.set(0, Integer.toString(storeid));
1757
+ list1.set(2, sMagic);
1758
+ list2.set(0, Integer.toString(storeid));
1759
+ if (storeid != null && ss != null) {
1760
+ System.out.println("nang linh thu " + ss.getUserId());
1761
+ // nang
1762
+ GuiPacket(ss, "49105", list1);
1763
+ Thread.sleep(5000);
1764
+ // ha
1765
+ if (ss.getLinhThuKoHa().contains(storeid.toString())) {
1766
+ break;
1767
+ }
1768
+ GuiPacket(ss, "49106", list2);
1769
+ Thread.sleep(5000);
1770
+
1771
+ }
1772
+ }
1773
+
1774
+ }
1775
+ } catch (Exception e) {
1776
+ throw new JsonException();
1777
+ }
1778
+ }
1779
+ } catch (Exception ex) {
1780
+ if (!(ex instanceof JsonException)) {
1781
+ System.out.println("NangItem " + ss.getStringName() + ex.getMessage());
1782
+ } else {
1783
+ System.out.println("NangItem json " + ss.getStringName() + ex.getMessage());
1784
+ }
1785
+
1786
+ }
1787
+
1788
+ }
1789
+
1790
 
1791
  public static void createSocket(SessionEntity session) throws Exception {
1792
  Socket socket = new Socket();
 
1797
  } catch (Exception e) {
1798
  }
1799
  session.setSocket(socket);
1800
+
1801
+ try {
1802
+ GuiPacketKhongKQ(session, "10100", null);
1803
+ // packet cap nhat thong tin lien tuc tu server
1804
+ Thread.sleep(5000);
1805
+ StaticCapNhatThongTin(session);
1806
+ Thread.sleep(5000);
1807
+ GuiPacketKhongKQ(session, "52103", null);
1808
+ Thread.sleep(5000);
1809
+ GuiPacketKhongKQ(session, "10108", null);
1810
+ Thread.sleep(5000);
1811
+ GuiPacketKhongKQ(session, "20101", null);
1812
+ Thread.sleep(5000);
1813
+ List<String> list1 = new ArrayList<>();
1814
+ list1.add(0, "1");
1815
+ StringBuilder rs1 = GuiPacket(session, "12200", list1);
1816
+ list1 = null;
1817
+ } catch (Exception e) {
1818
+ }
1819
 
1820
+
1821
+ }
1822
+
1823
+
1824
+ public static void createSocketLinhThu(SessionEntity session) throws Exception {
1825
+ Socket socket = new Socket();
1826
+ socket.connect(new InetSocketAddress(InetAddress.getByName(session.getIp()), Integer.parseInt(session.getPort())), 7000);
1827
+ socket.setSoTimeout(350000);
1828
+ try {
1829
+ session.getSocketNuoiLinhThu().close();
1830
+ } catch (Exception e) {
1831
+ }
1832
+ session.setSocketNuoiLinhThu(socket);
1833
+
1834
+ try {
1835
+
1836
+ // packet cap nhat thong tin lien tuc tu server
1837
+ Thread.sleep(5000);
1838
+ StaticCapNhatThongTinLinhThu(session);
1839
+ Thread.sleep(5000);
1840
+ GuiPacketKhongKQLinhThu(session, "52103", null);
1841
+ Thread.sleep(5000);
1842
+ GuiPacketKhongKQLinhThu(session, "10108", null);
1843
+ Thread.sleep(5000);
1844
+ GuiPacketKhongKQLinhThu(session, "20101", null);
1845
+ Thread.sleep(5000);
1846
+ List<String> list1 = new ArrayList<>();
1847
+ list1.add(0, "1");
1848
+ StringBuilder rs1 = GuiPacketLinhThu(session, "12200", list1);
1849
+ list1 = null;
1850
  } catch (Exception e) {
1851
  }
1852
 
 
1879
  try {
1880
  dangNhapLayThongTin();
1881
  GuiPacketDeLogin();
1882
+
1883
  while (true) {
1884
  try {
1885
  //if (!ss.getUserId().equals("2301230011011923")) {
1886
  // TruyNa2();
1887
  //}
 
1888
 
1889
  MuaLinh();
1890
+ NangHaLinhThu(ss);
1891
  NangItem();
1892
  LuyenTuong();
1893
  NangNha();
 
1895
  NhanThuong();
1896
  GianKhoan();
1897
  // FarmDoLv60();
1898
+ ThuThue();
1899
 
1900
  ChiemMo();
1901
  ChiemRuong();
src/main/java/tqtk/XuLy/WorkerLinhThu.java ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package tqtk.XuLy;
2
+
3
+ import com.fasterxml.jackson.core.type.TypeReference;
4
+ import com.fasterxml.jackson.databind.ObjectMapper;
5
+ import java.io.IOException;
6
+ import java.net.InetAddress;
7
+ import java.net.InetSocketAddress;
8
+ import java.net.Socket;
9
+ import java.net.UnknownHostException;
10
+ import java.nio.charset.StandardCharsets;
11
+ import java.util.ArrayList;
12
+ import java.util.LinkedHashMap;
13
+ import java.util.List;
14
+ import java.util.Map;
15
+ import java.util.logging.Level;
16
+ import java.util.logging.Logger;
17
+ import tqtk.Entity.Barrack;
18
+ import tqtk.Entity.Hero;
19
+ import tqtk.Entity.TruyNa;
20
+ import tqtk.Entity.JsonObject;
21
+ import tqtk.Entity.SessionEntity;
22
+ import tqtk.Tqtk;
23
+ import tqtk.Utils.Util;
24
+ import tqtk.XuLy.login.LayThongTinSession;
25
+ import static tqtk.XuLy.XuLyPacket.GuiPacket;
26
+ import static tqtk.XuLy.XuLyPacket.GuiPacketTN;
27
+ import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQ;
28
+ import static tqtk.XuLy.XuLyPacket.GuiPacketKhongKQLinhThu;
29
+ import static tqtk.XuLy.XuLyPacket.GuiPacketLinhThu;
30
+ import tqtk.exception.JsonException;
31
+ import java.io.*;
32
+ import java.util.*;
33
+ import java.util.Collections;
34
+
35
+ /**
36
+ *
37
+ * @author Alex
38
+ */
39
+ public class WorkerLinhThu extends Thread {
40
+
41
+ SessionEntity ss;
42
+
43
+ public SessionEntity getSs() {
44
+ return ss;
45
+ }
46
+
47
+ public void setSs(SessionEntity ss) {
48
+ this.ss = ss;
49
+ }
50
+
51
+ public WorkerLinhThu(SessionEntity ss) {
52
+
53
+ this.ss = ss;
54
+ }
55
+
56
+ public void GuiPacketDeLogin2(SessionEntity ss) throws InterruptedException, IOException, Exception {
57
+ // packet duy tri dang nhap , neu muon truy cap vao 1 acc tu` nhieu noi thi , phai co'
58
+ // 1 noi dang nhap truoc roi , luc nay se ko can chay packet 10100
59
+ // Thread.sleep(5000);
60
+ // packet cap nhat thong tin lien tuc tu server
61
+ Thread.sleep(5000);
62
+ CapNhatThongTin2();
63
+ Thread.sleep(5000);
64
+ GuiPacketKhongKQLinhThu(ss, "52103", null);
65
+ Thread.sleep(5000);
66
+ GuiPacketKhongKQLinhThu(ss, "10108", null);
67
+ Thread.sleep(5000);
68
+ GuiPacketKhongKQLinhThu(ss, "20101", null);
69
+ Thread.sleep(5000);
70
+ List<String> list1 = new ArrayList<>();
71
+ list1.add(0, "1");
72
+ StringBuilder rs1 = GuiPacketLinhThu(ss, "12200", list1);
73
+ list1 = null;
74
+
75
+ }
76
+
77
+ public void dangNhapLayThongTin2(SessionEntity ss) throws Exception {
78
+ Socket socket = new Socket();
79
+ socket.setSoTimeout(9999999);
80
+ socket.connect(new InetSocketAddress(InetAddress.getByName(ss.getIp()), Integer.parseInt(ss.getPort())), 7000);
81
+ if (ss.getSocketNuoiLinhThu() != null) {
82
+ ss.getSocketNuoiLinhThu().close();
83
+ }
84
+ ss.setSocketNuoiLinhThu(socket);
85
+ }
86
+
87
+ public void CapNhatThongTin2() throws IOException, UnknownHostException, InterruptedException, Exception {
88
+ try {
89
+ Thread.sleep(5000);
90
+ StringBuilder rs1 = GuiPacketLinhThu(ss, "11102", null);
91
+ } catch (Exception ex) {
92
+ if (!(ex instanceof JsonException)) {
93
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
94
+ } else {
95
+ System.out.println("CapNhatThongTin " + ss.getUserId() + ex.getMessage());
96
+ }
97
+
98
+ }
99
+
100
+ }
101
+
102
+ public void ChoDen() throws IOException, UnknownHostException, InterruptedException, Exception {
103
+ List<String> list1 = new ArrayList<>();
104
+ list1.add(0, "0");
105
+ list1.add(1, "0");
106
+ list1.add(2, "0");
107
+ list1.add(3, "0");
108
+ try {
109
+ Thread.sleep(5000);
110
+ StringBuilder rs1 = GuiPacketLinhThu(ss, "48116", list1);
111
+
112
+ } catch (Exception ex) {
113
+ if (!(ex instanceof JsonException)) {
114
+ System.out.println("cho den " + ss.getStringName() + ex.getMessage());
115
+
116
+ } else {
117
+ System.out.println("cho den json " + ss.getStringName() + ex.getMessage());
118
+ }
119
+
120
+ }
121
+
122
+ }
123
+
124
+ public void NangHaLinhThu(SessionEntity ss) throws IOException, UnknownHostException, InterruptedException, Exception {
125
+ List<String> list1 = new ArrayList<>();
126
+ list1.add(0, "0");
127
+ list1.add(1, "0");
128
+ list1.add(2, "40");
129
+
130
+ List<String> list2 = new ArrayList<>();
131
+ list2.add(0, "0");
132
+ list2.add(1, "0");
133
+ try {
134
+ Thread.sleep(5000);
135
+ StringBuilder rs1 = GuiPacketLinhThu(ss, "49101", list1);
136
+ if (rs1 != null && rs1.toString() != "") {
137
+ try {
138
+ String[] temp = rs1.toString().split("");
139
+
140
+ ObjectMapper mapper = new ObjectMapper();
141
+ Map<String, Object> carMap = null;
142
+ int h = 0;
143
+ for (String string : temp) {
144
+ carMap = mapper.readValue(string, new TypeReference<Map<String, Object>>() {
145
+ });
146
+ h = (int) carMap.get("h");
147
+ if (h == Integer.parseInt("49101")) {
148
+ break;
149
+ }
150
+ }
151
+
152
+ List<Object> carMap1 = (List<Object>) ((Map<String, Object>) carMap.get("m")).get("formationguardequipdto");
153
+
154
+ if (carMap1 == null) {
155
+ return;
156
+ }
157
+ System.out.println("setup linh thu");
158
+ Object Magic = (Object) ((Map<String, Object>) carMap.get("m")).get("magic");
159
+ String[] tmp = Magic.toString().split(",");
160
+ String sMagic = "";
161
+
162
+ int lv = 0;
163
+ int lvmagic = 0;
164
+ Integer storeid = 0;
165
+
166
+ for (Object object : carMap1) {
167
+ storeid = (Integer) ((Map<Object, Object>) object).get("storeid");
168
+ lvmagic = (Integer) ((Map<Object, Object>) object).get("equiplevel");
169
+ sMagic = tmp[lvmagic - 1];
170
+ lvmagic = Integer.parseInt(sMagic);
171
+ if (lvmagic > 75) {
172
+ list1.set(0, Integer.toString(storeid));
173
+ list1.set(2, sMagic);
174
+ list2.set(0, Integer.toString(storeid));
175
+ if (storeid != null && ss != null) {
176
+ System.out.println("nang linh thu " + ss.getUserId());
177
+ // nang
178
+ GuiPacketLinhThu(ss, "49105", list1);
179
+ Thread.sleep(10000);
180
+ // ha
181
+ if (ss.getLinhThuKoHa().contains(storeid.toString())) {
182
+ break;
183
+ }
184
+ GuiPacketLinhThu(ss, "49106", list2);
185
+ Thread.sleep(10000);
186
+
187
+ }
188
+ }
189
+
190
+ }
191
+ } catch (Exception e) {
192
+ throw new JsonException();
193
+ }
194
+ }
195
+ } catch (Exception ex) {
196
+ if (!(ex instanceof JsonException)) {
197
+ System.out.println("NangItem " + ss.getStringName() + ex.getMessage());
198
+ } else {
199
+ System.out.println("NangItem json " + ss.getStringName() + ex.getMessage());
200
+ }
201
+
202
+ }
203
+
204
+ }
205
+
206
+ @Override
207
+ public void run() {
208
+ try {
209
+ dangNhapLayThongTin2(ss);
210
+ GuiPacketDeLogin2(ss);
211
+ while (true) {
212
+ try {
213
+ ChoDen();
214
+ Thread.sleep(10000);
215
+ NangHaLinhThu(ss);
216
+ Thread.sleep(10000);
217
+ CapNhatThongTin2();
218
+ Thread.sleep(10000);
219
+
220
+ } catch (Exception ex) {
221
+ System.out.println("all lthu " + ss.getUserId() + ex.getMessage());
222
+ }
223
+ }
224
+ } catch (Exception ex) {
225
+ System.out.println("all lthu " + ss.getUserId() + ex.getMessage());
226
+ }
227
+ }
228
+
229
+ }
src/main/java/tqtk/XuLy/XuLyPacket.java CHANGED
@@ -36,9 +36,30 @@ public class XuLyPacket {
36
  wr.write(message);
37
  wr.flush();
38
  } catch (Exception e) {
39
- System.out.println(e.getMessage());
40
  // if (e.getMessage().contains("socket write error")) {
41
- ss.resetSocket();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  // }
43
  }
44
 
@@ -70,14 +91,51 @@ public class XuLyPacket {
70
  }
71
  return rp;
72
  } catch (Exception e) {
73
- System.out.println(e.getMessage());
74
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  return null;
77
  }
78
 
79
  }
80
 
 
81
  public static String GuiPacketHTTP(SessionEntity ss, String message) throws UnknownHostException, IOException, InterruptedException {
82
  BufferedWriter wr = null;
83
  StringBuilder rp = null;
@@ -289,14 +347,14 @@ public class XuLyPacket {
289
  try {
290
  message = Util.TaoMsg(code, list, ss);
291
  Thread.sleep(3 * 1000);
292
- wr = new BufferedWriter(new OutputStreamWriter(ss.getSocketTN().getOutputStream(), "UTF8"));
293
  wr.write(message);
294
  wr.flush();
295
 
296
- if (ss.getSocketTN().isConnected()) {
297
  Thread.sleep(3 * 1000);
298
- InputStream instr = ss.getSocketTN().getInputStream();
299
- int buffSize = ss.getSocketTN().getReceiveBufferSize();
300
  if (buffSize > 0) {
301
  byte[] buff = new byte[buffSize];
302
  int ret_read = instr.read(buff);
 
36
  wr.write(message);
37
  wr.flush();
38
  } catch (Exception e) {
39
+ System.out.println("GuiPacketKhongKQ "+e.getMessage());
40
  // if (e.getMessage().contains("socket write error")) {
41
+ try {
42
+ //tqtk.XuLy.Worker.createSocket(ss);
43
+ } catch (Exception e1) {}
44
+ // }
45
+ }
46
+
47
+ }
48
+
49
+ public static void GuiPacketKhongKQLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
50
+ BufferedWriter wr = null;
51
+ try {
52
+ String message = Util.TaoMsg(code, list, ss);
53
+ Thread.sleep(2 * 1000);
54
+ wr = new BufferedWriter(new OutputStreamWriter(ss.getSocketNuoiLinhThu().getOutputStream(), "UTF8"));
55
+ wr.write(message);
56
+ wr.flush();
57
+ } catch (Exception e) {
58
+ System.out.println("GuiPacketKhongKQLinhThu "+e.getMessage());
59
+ // if (e.getMessage().contains("socket write error")) {
60
+ try {
61
+ //tqtk.XuLy.Worker.createSocket(ss);
62
+ } catch (Exception e1) {}
63
  // }
64
  }
65
 
 
91
  }
92
  return rp;
93
  } catch (Exception e) {
94
+ try {
95
+ //tqtk.XuLy.Worker.createSocket(ss);
96
+ } catch (Exception e1) {}
97
+ return null;
98
+ }
99
+
100
+ }
101
+
102
+ public static StringBuilder GuiPacketLinhThu(SessionEntity ss, String code, List<String> list) throws UnknownHostException, IOException, InterruptedException {
103
+ BufferedWriter wr = null;
104
+ StringBuilder rp = null;
105
+ String message = "";
106
+ try {
107
+ message = Util.TaoMsg(code, list, ss);
108
+ Thread.sleep(3 * 1000);
109
+ wr = new BufferedWriter(new OutputStreamWriter(ss.getSocketNuoiLinhThu().getOutputStream(), "UTF8"));
110
+ wr.write(message);
111
+ wr.flush();
112
+
113
+ rp = new StringBuilder("");
114
+ if (ss.getSocketNuoiLinhThu().isConnected()) {
115
+ Thread.sleep(3 * 1000);
116
+ InputStream instr = ss.getSocketNuoiLinhThu().getInputStream();
117
+ int buffSize = ss.getSocketNuoiLinhThu().getReceiveBufferSize();
118
+ if (buffSize > 0) {
119
+ byte[] buff = new byte[buffSize];
120
+ int ret_read = instr.read(buff);
121
+ if (ret_read != -1) {
122
+ rp.append(new String(buff, 0, ret_read));
123
+ }
124
+ }
125
+ }
126
+ return rp;
127
+ } catch (Exception e) {
128
+ System.out.println("GuiPacketLinhThu "+e.getMessage());
129
+ try {
130
+ //tqtk.XuLy.Worker.createSocket(ss);
131
+ } catch (Exception e1) {}
132
 
133
  return null;
134
  }
135
 
136
  }
137
 
138
+
139
  public static String GuiPacketHTTP(SessionEntity ss, String message) throws UnknownHostException, IOException, InterruptedException {
140
  BufferedWriter wr = null;
141
  StringBuilder rp = null;
 
347
  try {
348
  message = Util.TaoMsg(code, list, ss);
349
  Thread.sleep(3 * 1000);
350
+ wr = new BufferedWriter(new OutputStreamWriter(ss.getSocket().getOutputStream(), "UTF8"));
351
  wr.write(message);
352
  wr.flush();
353
 
354
+ if (ss.getSocket().isConnected()) {
355
  Thread.sleep(3 * 1000);
356
+ InputStream instr = ss.getSocket().getInputStream();
357
+ int buffSize = ss.getSocket().getReceiveBufferSize();
358
  if (buffSize > 0) {
359
  byte[] buff = new byte[buffSize];
360
  int ret_read = instr.read(buff);
src/main/resources/application.properties CHANGED
@@ -4,7 +4,7 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialec
4
  spring.jpa.hibernate.ddl-auto=update
5
  spring.jpa.hibernate.show-sql=true
6
 
7
- spring.datasource.url=jdbc:postgresql://dpg-cf82kq6n6mplr40r4p5g-a.singapore-postgres.render.com:5432/pgtest_1y8z
8
- spring.datasource.username=pgtest_1y8z_user
9
- spring.datasource.password=L97pbnHfex5lEg0qOuPUwwiZnvR8qdHA
10
- spring.datasource.driver-class-name=org.postgresql.Driver
 
4
  spring.jpa.hibernate.ddl-auto=update
5
  spring.jpa.hibernate.show-sql=true
6
 
7
+ spring.datasource.url=jdbc:postgresql://dpg-ch4givpn852hpi3144tg-a.singapore-postgres.render.com:5432/test_3ff6
8
+ spring.datasource.username=test_3ff6_user
9
+ spring.datasource.password=QwKqYo57zAPII3h1TFHBOIbxonGPJuIo
10
+ spring.datasource.driver-class-name=org.postgresql.Driver