作者 王勇

添加总条数和当前的条数

@@ -95,7 +95,7 @@ public class NmsController { @@ -95,7 +95,7 @@ public class NmsController {
95 String sid = request.getHeader("Authorization"); 95 String sid = request.getHeader("Authorization");
96 log.info("token的值:" + sid); 96 log.info("token的值:" + sid);
97 final String startTime = sdf.format(new Date()); 97 final String startTime = sdf.format(new Date());
98 - String resultStart = JSON.toJSONString(new ResultWs("数据开始获取,开始时间:" + startTime)); 98 + String resultStart = JSON.toJSONString(new ResultWs("数据开始获取"));
99 sendMsgByWebsocket(resultStart, sid); 99 sendMsgByWebsocket(resultStart, sid);
100 ResultJson resultJson = new ResultJson(); 100 ResultJson resultJson = new ResultJson();
101 101
@@ -107,6 +107,10 @@ public class NmsController { @@ -107,6 +107,10 @@ public class NmsController {
107 resultExitData.setFlightNo(flightNo); 107 resultExitData.setFlightNo(flightNo);
108 List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData); 108 List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData);
109 System.out.println("长度为:" + resultList.size()); 109 System.out.println("长度为:" + resultList.size());
  110 + ResultWs resultTotal = new ResultWs("一共" + resultList.size() + "条数据", resultList.size());
  111 + String resultTotalJs = JSON.toJSONString(resultTotal, SerializerFeature.DisableCircularReferenceDetect);
  112 + sendMsgByWebsocket(resultTotalJs, sid);
  113 +
110 //控制index,查询数据的时候,保证索引的位置不出错 114 //控制index,查询数据的时候,保证索引的位置不出错
111 int index = 0; 115 int index = 0;
112 try { 116 try {
@@ -124,7 +128,7 @@ public class NmsController { @@ -124,7 +128,7 @@ public class NmsController {
124 resultList.set(i, result); 128 resultList.set(i, result);
125 129
126 int temp = i + index; 130 int temp = i + index;
127 - ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201"); 131 + ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
128 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect); 132 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
129 133
130 sendMsgByWebsocket(resultJs, sid); 134 sendMsgByWebsocket(resultJs, sid);
@@ -143,7 +147,7 @@ public class NmsController { @@ -143,7 +147,7 @@ public class NmsController {
143 result = threadJob(resultList.get(i + index), latch, threadPool); 147 result = threadJob(resultList.get(i + index), latch, threadPool);
144 148
145 int temp = i + index; 149 int temp = i + index;
146 - ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201"); 150 + ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
147 151
148 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect); 152 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
149 sendMsgByWebsocket(resultJs, sid); 153 sendMsgByWebsocket(resultJs, sid);
@@ -163,7 +167,7 @@ public class NmsController { @@ -163,7 +167,7 @@ public class NmsController {
163 result = threadJob(resultList.get(i), latch, threadPool); 167 result = threadJob(resultList.get(i), latch, threadPool);
164 168
165 resultList.set(i, result); 169 resultList.set(i, result);
166 - ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201"); 170 + ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201", i, resultList.size());
167 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect); 171 String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
168 172
169 sendMsgByWebsocket(resultJs, sid); 173 sendMsgByWebsocket(resultJs, sid);
@@ -178,7 +182,7 @@ public class NmsController { @@ -178,7 +182,7 @@ public class NmsController {
178 final String endTime = sdf.format(new Date()); 182 final String endTime = sdf.format(new Date());
179 System.out.println("出港信息,获取完毕,index的值为:" + index); 183 System.out.println("出港信息,获取完毕,index的值为:" + index);
180 System.out.println("结束时间:" + endTime); 184 System.out.println("结束时间:" + endTime);
181 - String resultJs = JSON.toJSONString(new ResultWs("获取数据,结束时间:" + endTime, resultList, "200")); 185 + String resultJs = JSON.toJSONString(new ResultWs("获取数据,完成", resultList, "200", resultList.size(), resultList.size()));
182 sendMsgByWebsocket(resultJs, sid); 186 sendMsgByWebsocket(resultJs, sid);
183 resultJson.setCode("200"); 187 resultJson.setCode("200");
184 resultJson.setData(resultList); 188 resultJson.setData(resultList);
@@ -16,16 +16,54 @@ public class ResultWs<T> implements Serializable { @@ -16,16 +16,54 @@ public class ResultWs<T> implements Serializable {
16 16
17 String sid; 17 String sid;
18 18
  19 + /**
  20 + * 响应消息
  21 + */
19 String message; 22 String message;
20 23
  24 + /**
  25 + * 响应数据
  26 + */
21 T data; 27 T data;
22 28
  29 + public ResultWs(String message, T data, String status, int currentNum, int totalNum) {
  30 + this.message = message;
  31 + this.data = data;
  32 + this.status = status;
  33 + this.currentNum = currentNum;
  34 + this.totalNum = totalNum;
  35 + }
23 36
  37 + /**
  38 + * 当前是第几条
  39 + */
  40 + int currentNum;
  41 +
  42 + /**
  43 + * 总条数
  44 + */
  45 + int totalNum;
  46 +
  47 + /**
  48 + * 状态
  49 + */
24 String status; 50 String status;
25 51
26 public ResultWs() { 52 public ResultWs() {
27 } 53 }
28 54
  55 + public ResultWs(String message, int totalNum) {
  56 + this.message = message;
  57 + this.totalNum = totalNum;
  58 + }
  59 +
  60 + public ResultWs(String message, String status, int currentNum, int totalNum) {
  61 + this.message = message;
  62 + this.status = status;
  63 + this.currentNum = currentNum;
  64 + this.totalNum = totalNum;
  65 + }
  66 +
29 public ResultWs(String message, String status) { 67 public ResultWs(String message, String status) {
30 this.message = message; 68 this.message = message;
31 this.status = status; 69 this.status = status;