Commit c95c3992 authored by lin's avatar lin

bi接口

parent dae1d392
......@@ -89,7 +89,7 @@ public class VariableController extends BaseRestController{
@GetMapping("/real-time")
@ApiOperation("获取变量实时数据")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<List<Map<String,Object>>> getVariableRealTimeDataList(HttpServletRequest request,@PathVariable String appId,
public R<List<Map<String,List<Map<String,Object>>>>> getVariableRealTimeDataList(HttpServletRequest request,@PathVariable String appId,
VariableRealTimeDTO variableDTO) {
return call(() -> {
CurrentUser currentUser = getCurrentUser(request);
......
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
/**
* slm-bi
* 实时变量DTO
......@@ -15,14 +17,17 @@ import lombok.Data;
public class VariableRealTimeDTO {
@ApiModelProperty(value = "所属设备", required = true)
private String deviceId;
@ApiModelProperty(value = "变量id", required = true)
private String variableId;
@ApiModelProperty(value = "变量Code", required = true)
private String variableCode;
// @ApiModelProperty(value = "变量id", required = true)
// private String variableId;
// @ApiModelProperty(value = "变量Code", required = true)
// private String variableCode;
@ApiModelProperty(value = "开始时间(时间戳)",required = true)
private String startTime;
@ApiModelProperty(value = "结束时间(时间戳)", required = true)
private String endTime;
@ApiModelProperty(value = "请填时间格式如(yyyy-MM-dd HH:mm:ss)", required = true)
private String format;
@ApiModelProperty(value = "key 为变量id value 为变量名称", required = true)
Map<String,String> variables;
}
......@@ -47,7 +47,7 @@ public interface VariableService {
* @param user
* @return
*/
List<Map<String,Object>> getVariableRealTimeDataList(@NonNull String uri,VariableRealTimeDTO variableDTO,CurrentUser user);
List<Map<String,List<Map<String,Object>>>> getVariableRealTimeDataList(@NonNull String uri,VariableRealTimeDTO variableDTO,CurrentUser user);
/**
* 获取历史数据
......
......@@ -119,15 +119,19 @@ public class VariableServiceImpl implements VariableService {
}
@Override
public List<Map<String,Object>> getVariableRealTimeDataList(@NonNull String uri,VariableRealTimeDTO variableDTO,CurrentUser user) {
public List<Map<String,List<Map<String,Object>>>> getVariableRealTimeDataList(@NonNull String uri,VariableRealTimeDTO variableDTO,CurrentUser user) {
if(StringUtils.isBlank(uri)){
throw new SysException("请传入uri");
}
if(StringUtils.isBlank(variableDTO.getDeviceId())){
throw new SysException("请传入设备id");
}
if(StringUtils.isBlank(variableDTO.getVariableCode())){
throw new SysException("请传入变量code");
if(CollectionUtils.isEmpty(variableDTO.getVariables())){
throw new SysException("请传入变量");
}else{
if(variableDTO.getVariables().values().stream().anyMatch(StringUtils::isBlank)) {
throw new SysException("变量名字不能为空");
}
}
if(StringUtils.isBlank(variableDTO.getEndTime())){
throw new SysException("请传入结束时间");
......@@ -140,7 +144,7 @@ public class VariableServiceImpl implements VariableService {
}
Map<String, String> uriVariables =SlmConstants.gson.fromJson(SlmConstants.gson.toJson(variableDTO),new TypeToken<Map<String,String>>(){}.getType());
uriVariables.put("appId",user.getAppId());
R<List<Map<String,Object>>> result = RestTemplateUtils.get(uri, new TypeToken< R<List<Map<String,Object>>>>() {}.getType(), uriVariables);
R<List<Map<String,List<Map<String,Object>>>>> result = RestTemplateUtils.get(uri, new TypeToken< R<List<Map<String,List<Map<String,Object>>>>>>() {}.getType(), uriVariables);
return result.detach();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment