main
周文涛 2 years ago
parent 448c49d735
commit d6f5ca97f7

@ -0,0 +1,12 @@
package com.example.zxweb.common.constant;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/12 11:35
*/
public interface DevConstant {
class gateway{
private String gateway_5lhyslqh="0cefafd2a2ca";
}
}

@ -5,13 +5,19 @@ import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.common.constant.enums.IotApiEnum; import com.example.zxweb.common.constant.enums.IotApiEnum;
import com.example.zxweb.utils.AssertUtils; import com.example.zxweb.utils.AssertUtils;
import com.example.zxweb.utils.IotUtils; import com.example.zxweb.utils.IotUtils;
import com.example.zxweb.vo.QueryCelueListVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* @Description * @Description
* @Author ZhouWenTao * @Author ZhouWenTao
@ -22,17 +28,34 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@Api(tags = "网关设备管理") @Api(tags = "网关设备管理")
public class GatewayController { public class GatewayController {
//网关设备
private static final List<String> gatewayDevIdList=new ArrayList<>(Arrays.asList("0cefafd605f7","0cefafd295a4"));
/** /**
* *
* @param devid id * @param queryCelueListVO
* @return * @return
*/ */
@GetMapping(value = "/celueListQuery") @GetMapping(value = "/celueListQuery")
public Result<?> celueListQuery(@RequestParam(value = "devid")String devid){ public Result<?> celueListQuery(QueryCelueListVO queryCelueListVO){
String devid = queryCelueListVO.getDevid();
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);
return Result.OK(responseBody); return jsonObjectToResult(responseBody);
}
public static Result<?> jsonObjectToResult(JSONObject jsonObject) {
Integer code = jsonObject.getInteger("code");
String message = jsonObject.getString("message");
String data = jsonObject.getString("data");
if (code!=0) {
return Result.error(code, StringUtils.isEmpty(message)?data:message);
}
if (StringUtils.isEmpty(message)) {
return Result.OK(jsonObject.getJSONObject("data"));
}
return Result.OK(message);
} }
} }

@ -0,0 +1,21 @@
package com.example.zxweb.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/12 13:38
*/
@Data
public class QueryCelueListVO implements Serializable {
@ApiModelProperty(value = "设备id")
private String devid;
@ApiModelProperty(value = "页数")
private Integer pageNo=1;
@ApiModelProperty(value = "分页大小")
private Integer pageSize=10;
}
Loading…
Cancel
Save