作者 王勇

添加总条数和当前的条数

... ... @@ -95,7 +95,7 @@ public class NmsController {
String sid = request.getHeader("Authorization");
log.info("token的值:" + sid);
final String startTime = sdf.format(new Date());
String resultStart = JSON.toJSONString(new ResultWs("数据开始获取,开始时间:" + startTime));
String resultStart = JSON.toJSONString(new ResultWs("数据开始获取"));
sendMsgByWebsocket(resultStart, sid);
ResultJson resultJson = new ResultJson();
... ... @@ -107,6 +107,10 @@ public class NmsController {
resultExitData.setFlightNo(flightNo);
List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData);
System.out.println("长度为:" + resultList.size());
ResultWs resultTotal = new ResultWs("一共" + resultList.size() + "条数据", resultList.size());
String resultTotalJs = JSON.toJSONString(resultTotal, SerializerFeature.DisableCircularReferenceDetect);
sendMsgByWebsocket(resultTotalJs, sid);
//控制index,查询数据的时候,保证索引的位置不出错
int index = 0;
try {
... ... @@ -124,7 +128,7 @@ public class NmsController {
resultList.set(i, result);
int temp = i + index;
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201");
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
sendMsgByWebsocket(resultJs, sid);
... ... @@ -143,7 +147,7 @@ public class NmsController {
result = threadJob(resultList.get(i + index), latch, threadPool);
int temp = i + index;
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201");
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
sendMsgByWebsocket(resultJs, sid);
... ... @@ -163,7 +167,7 @@ public class NmsController {
result = threadJob(resultList.get(i), latch, threadPool);
resultList.set(i, result);
ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201");
ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201", i, resultList.size());
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
sendMsgByWebsocket(resultJs, sid);
... ... @@ -178,7 +182,7 @@ public class NmsController {
final String endTime = sdf.format(new Date());
System.out.println("出港信息,获取完毕,index的值为:" + index);
System.out.println("结束时间:" + endTime);
String resultJs = JSON.toJSONString(new ResultWs("获取数据,结束时间:" + endTime, resultList, "200"));
String resultJs = JSON.toJSONString(new ResultWs("获取数据,完成", resultList, "200", resultList.size(), resultList.size()));
sendMsgByWebsocket(resultJs, sid);
resultJson.setCode("200");
resultJson.setData(resultList);
... ...
... ... @@ -16,16 +16,54 @@ public class ResultWs<T> implements Serializable {
String sid;
/**
* 响应消息
*/
String message;
/**
* 响应数据
*/
T data;
public ResultWs(String message, T data, String status, int currentNum, int totalNum) {
this.message = message;
this.data = data;
this.status = status;
this.currentNum = currentNum;
this.totalNum = totalNum;
}
/**
* 当前是第几条
*/
int currentNum;
/**
* 总条数
*/
int totalNum;
/**
* 状态
*/
String status;
public ResultWs() {
}
public ResultWs(String message, int totalNum) {
this.message = message;
this.totalNum = totalNum;
}
public ResultWs(String message, String status, int currentNum, int totalNum) {
this.message = message;
this.status = status;
this.currentNum = currentNum;
this.totalNum = totalNum;
}
public ResultWs(String message, String status) {
this.message = message;
this.status = status;
... ...