diff --git a/src/main/java/com/example/zxweb/controller/GatewayController.java b/src/main/java/com/example/zxweb/controller/GatewayController.java index a85a2f9..db97643 100644 --- a/src/main/java/com/example/zxweb/controller/GatewayController.java +++ b/src/main/java/com/example/zxweb/controller/GatewayController.java @@ -1,5 +1,6 @@ package com.example.zxweb.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.zxweb.common.api.vo.Result; 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.Arrays; import java.util.List; +import java.util.stream.Collectors; /** * @Description @@ -38,10 +40,24 @@ public class GatewayController { @GetMapping(value = "/celueListQuery") public Result celueListQuery(QueryCelueListVO queryCelueListVO){ String devid = queryCelueListVO.getDevid(); + Integer pageNum = queryCelueListVO.getPageNum(); + Integer pageSize = queryCelueListVO.getPageSize(); AssertUtils.notEmpty(devid,"请输入-[devid]"); String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", devid,devid); JSONObject requestBody = JSONObject.parseObject(format); JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody); + JSONObject data = requestBody.getJSONObject("data"); + if (!data.isEmpty()) { + JSONObject outputData = data.getJSONObject("outputData"); + if (!outputData.isEmpty()) { + List list = outputData.getJSONArray("list").toJavaList(JSONObject.class); + List 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); } diff --git a/src/main/java/com/example/zxweb/vo/QueryCelueListVO.java b/src/main/java/com/example/zxweb/vo/QueryCelueListVO.java index d382fd8..62f5dbb 100644 --- a/src/main/java/com/example/zxweb/vo/QueryCelueListVO.java +++ b/src/main/java/com/example/zxweb/vo/QueryCelueListVO.java @@ -15,7 +15,7 @@ public class QueryCelueListVO implements Serializable { @ApiModelProperty(value = "设备id") private String devid; @ApiModelProperty(value = "页数") - private Integer pageNo=1; + private Integer pageNum=1; @ApiModelProperty(value = "分页大小") private Integer pageSize=10; }