main
周文涛 2 years ago
parent d6f5ca97f7
commit 60e8fcdc90

@ -1,5 +1,6 @@
package com.example.zxweb.controller; package com.example.zxweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.zxweb.common.api.vo.Result; import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.common.constant.enums.IotApiEnum; import com.example.zxweb.common.constant.enums.IotApiEnum;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Description * @Description
@ -38,10 +40,24 @@ public class GatewayController {
@GetMapping(value = "/celueListQuery") @GetMapping(value = "/celueListQuery")
public Result<?> celueListQuery(QueryCelueListVO queryCelueListVO){ public Result<?> celueListQuery(QueryCelueListVO queryCelueListVO){
String devid = queryCelueListVO.getDevid(); String devid = queryCelueListVO.getDevid();
Integer pageNum = queryCelueListVO.getPageNum();
Integer pageSize = queryCelueListVO.getPageSize();
AssertUtils.notEmpty(devid,"请输入-[devid]"); AssertUtils.notEmpty(devid,"请输入-[devid]");
String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", devid,devid); String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", devid,devid);
JSONObject requestBody = JSONObject.parseObject(format); JSONObject requestBody = JSONObject.parseObject(format);
JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody); JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody);
JSONObject data = requestBody.getJSONObject("data");
if (!data.isEmpty()) {
JSONObject outputData = data.getJSONObject("outputData");
if (!outputData.isEmpty()) {
List<JSONObject> list = outputData.getJSONArray("list").toJavaList(JSONObject.class);
List<JSONObject> subList = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
outputData.put("list",subList);
outputData.put("total",list.size());
data.put("outputData",outputData);
requestBody.put("data",data);
}
}
return jsonObjectToResult(responseBody); return jsonObjectToResult(responseBody);
} }

@ -15,7 +15,7 @@ public class QueryCelueListVO implements Serializable {
@ApiModelProperty(value = "设备id") @ApiModelProperty(value = "设备id")
private String devid; private String devid;
@ApiModelProperty(value = "页数") @ApiModelProperty(value = "页数")
private Integer pageNo=1; private Integer pageNum=1;
@ApiModelProperty(value = "分页大小") @ApiModelProperty(value = "分页大小")
private Integer pageSize=10; private Integer pageSize=10;
} }

Loading…
Cancel
Save