Commit 973e1684 authored by 梁光意's avatar 梁光意

重新开发实时数据接口

parent 62d4f26b
......@@ -67,6 +67,9 @@ public class BaseRestController {
@Value("${dc_client.interfaces.variableHistoryStatus}")
protected String variableHistoryStatus;
@Value("${dc_client.interfaces.realTimeVariableDataList}")
protected String realTimeVariableDataList;
// @Value("${dc_client.interfaces.historyCurve}")
// protected String historyCurve;
......
......@@ -182,4 +182,15 @@ public class VariableController extends BaseRestController{
return variableService.historyStatus(dcClientHost+variableHistoryStatus,deviceId,variableCode,startTime,endTime,currentUser);
});
}
@PostMapping("/real-time/data")
@ApiOperation("获取实时数据")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<Map<String,List<Object>>> listRealTimeVariableData(HttpServletRequest request,@PathVariable String appId,
@RequestBody RealTimeVariableDataDTO variableDTO) {
return call(() -> {
CurrentUser currentUser = getCurrentUser(request);
return variableService.listRealTimeVariableData(dcClientHost+realTimeVariableDataList,variableDTO, currentUser);
});
}
}
package com.syc.slm.slmbi.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author: guangyi-liang
* @date: 2021/5/13
*/
@Data
public class RealTimeVariableDataDTO {
@ApiModelProperty(value = "最近的时间个数", required = true)
private Integer limit;
/* @ApiModelProperty(value = "(如果x轴为变量直接填yyyy-MM-dd HH:mm:ss)请填时间格式如(yyyy-MM-dd HH:mm:ss)", required = true)
private String format;*/
@ApiModelProperty(value = "变量信息", required = true)
private List<VariableSearchDTO> variableSearchList;
}
......@@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode;
@Data
@ApiModel(value = "变量DTO")
@EqualsAndHashCode(callSuper=false)
public class VariableSearchDTO extends QueryPageDTO{
public class VariableSearchDTO{
@ApiModelProperty(value = "所属设备")
private String deviceId;
......
......@@ -95,4 +95,13 @@ public interface VariableService {
* @return
*/
// Map<String,List<Map<String,Object>>> getVariableHistoryCurve(VariableHistoryCurveDataDTO variableDTO, CurrentUser currentUser,String uri);
/**
* 查询实时数据
* @param uri 请求url
* @param variableDTO 请求参数
* @param user 当前用户
* @return 返回值
*/
Map<String,List<Object>> listRealTimeVariableData(@NonNull String uri, RealTimeVariableDataDTO variableDTO,CurrentUser user);
}
......@@ -327,7 +327,32 @@ public class VariableServiceImpl implements VariableService {
return result.detach();
}
// @Override
@Override
public Map<String,List<Object>> listRealTimeVariableData(@NonNull String uri, RealTimeVariableDataDTO variableDTO, CurrentUser user) {
this.judgeSearchList(variableDTO.getVariableSearchList());
Map<String, String> uriVariables = Maps.newHashMap();
uriVariables.put("appId",user.getAppId());
R<Map<String,List<Object>>> result = RestTemplateUtils.post(uri,variableDTO,new TypeToken<R<Map<String,List<Object>>>>() {}.getType(), uriVariables);
return result.detach();
}
private void judgeSearchList(List<VariableSearchDTO> variableSearchList){
if(CollectionUtils.isEmpty(variableSearchList)){
throw new SysException("请传入变量");
}else{
if(variableSearchList.stream().anyMatch(x -> StringUtils.isBlank(x.getDeviceId()))){
throw new SysException("设备ID不能为空");
}
if(variableSearchList.stream().anyMatch(x -> StringUtils.isBlank(x.getVariableId()))){
throw new SysException("变量ID不能为空");
}
if(variableSearchList.stream().anyMatch(x -> StringUtils.isBlank(x.getVariableName()))){
throw new SysException("变量名称不能为空");
}
}
}
// @Override
// public Map<String,List<Map<String,Object>>> getVariableHistoryCurve(VariableHistoryCurveDataDTO variableDTO, CurrentUser user,String uri) {
// if(CollectionUtils.isEmpty(variableDTO.getVariableSearchList())){
// throw new SysException("请传入变量");
......
......@@ -62,6 +62,7 @@ dc_client:
# variableRealTimeDataList: /{appId}/variables/real-time?deviceId={deviceId}&endTime={endTime}&startTime={startTime}&variableCode={variableCode}&variableId={variableId}&format={format}
variableCodeHistoryList: /{appId}/variables/variableCode/history
variableAllDataList: /{appId}/variables/all/data
realTimeVariableDataList: /{appId}/variables/real-time/data
filedValue : /{appId}/business/{tableName}/{filed}/filed-value?current={current}&size={size}&name={name} #/{appId}/business/{tableName}/{filed}/filed-value?current={current}&size={size}&name={name}
send : /{appId}/variables/monitor/device/commands
variableStatus : /{appId}/variables/{deviceId}/{variableCode}/status
......
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