|
|
|
@ -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<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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|