Commit 0cf33171 authored by 梁光意's avatar 梁光意

修改业务字段统计类型

parent 1444bbdf
......@@ -48,7 +48,7 @@ public final class RestTemplateUtils {
log.info("GET请求,开始请求DC,uri是{},参数是{}",url,SlmConstants.gson.toJson(uriVariables));
HttpEntity<?> requestEntity = new HttpEntity<>(httpHeaders);
ResponseEntity<String> response = REST_TEMPLATE.exchange(url, HttpMethod.GET, requestEntity, String.class, uriVariables);
log.info("请求结果是=============:{}", response.getBody());
log.info("GET请求结果是=============:{}", response.getBody());
if (HttpStatus.OK.value() == response.getStatusCodeValue()) {
if (resultType.equals(String.class)) {
return (TResult)response.getBody();
......
......@@ -73,6 +73,9 @@ public class BaseRestController {
// @Value("${dc_client.interfaces.historyCurve}")
// protected String historyCurve;
@Value("${dc_client.interfaces.variableStatusRealTimeDataList}")
protected String variableStatusRealTimeDataList;
......
......@@ -193,4 +193,14 @@ public class VariableController extends BaseRestController{
return variableService.listRealTimeVariableData(dcClientHost+realTimeVariableDataList,variableDTO, currentUser);
});
}
@PostMapping("/status/real-time/data")
@ApiOperation("变量状态点实时数据(仪表盘和饼图专用)")
public R<Map<String,Map<String,Object>>> listVariableStatusRealTimeData(HttpServletRequest request,@PathVariable String appId,
@RequestBody List<VariableStatusRealTimeDataDTO> statusRealTimeDataList) {
return call(() -> {
CurrentUser currentUser = getCurrentUser(request);
return variableService.listVariableStatusRealTimeData(dcClientHost+variableStatusRealTimeDataList,statusRealTimeDataList,currentUser);
});
}
}
......@@ -10,7 +10,7 @@ import lombok.Data;
* @author : lin
* @date : 2021-04-19 19:36
**/
@ApiModel(value = "业务查询条件DTO")
@ApiModel(value = "业务查询条件以及key的DTO")
@Data
public class BusinessConditionDTO {
@ApiModelProperty(value = "区间配置字段", required = true)
......
......@@ -18,15 +18,15 @@ import java.util.Map;
public class BusinessDTO {
@ApiModelProperty(value = "查询表名", required = true)
private String table;
@ApiModelProperty(value = "纵轴变量", required = true)
private String y;
@ApiModelProperty(value = "横轴纬度", required = true)
@ApiModelProperty(value = "横轴变量", required = true)
private String x;
@ApiModelProperty(value = "横轴格式")
private String format;
@ApiModelProperty(value = "查询配置(如果为空不要调用后台)", required = true)
List<Map<String,List<BusinessConditionDTO>>> where;
@ApiModelProperty(value = "统计类型(平均值 avg ,合计值 sum, 最大值 max ,最小值 min,中位数 middle ,原值 original)", required = true)
private String statisticsType;
List<Map<String, List<BusinessConditionDTO>>> where;
@ApiModelProperty(value = "统计参数", required = true)
List<BusinessFieldStatisticsDTO> statisticsList;
}
package com.syc.slm.slmbi.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author: guangyi-liang
* @date: 2021/5/14
*/
@Data
@ApiModel(value = "字段统计DTO")
public class BusinessFieldStatisticsDTO {
@ApiModelProperty(value = "统计类型(平均值 avg ,合计值 sum, 最大值 max ,最小值 min,中位数 middle)", required = true)
private String statisticsType;
@ApiModelProperty(value = "纵轴变量", required = true)
private String field;
}
package com.syc.slm.slmbi.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author: guangyi-liang
* @date: 2021/5/14
*/
@Data
@ApiModel(value = "变量实时状态数据DTO(仪表盘和饼图专用)")
public class VariableStatusRealTimeDataDTO {
@ApiModelProperty(value = "所属设备")
private String deviceId;
@ApiModelProperty(value = "变量code,也就是变量name")
private String variableCode;
}
......@@ -104,4 +104,14 @@ public interface VariableService {
* @return 返回值
*/
Map<String,List<Object>> listRealTimeVariableData(@NonNull String uri, RealTimeVariableDataDTO variableDTO,CurrentUser user);
/**
* 批量查询实时状态数据
* @param uri 请求uri
* @param statusRealTimeDataList 请求条件
* @param user 当前用户
* @return key为设备ID,value中key为变量名称,vlaue是数据
*/
Map<String,Map<String,Object>> listVariableStatusRealTimeData(@NonNull String uri, List<VariableStatusRealTimeDataDTO> statusRealTimeDataList,CurrentUser user);
}
......@@ -82,15 +82,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
if(StringUtils.isBlank(dto.getTable())){
throw new SysException("请传入对应的表名");
}
if(StringUtils.isBlank(dto.getStatisticsType())){
if(CollectionUtils.isEmpty(dto.getStatisticsList())){
throw new SysException("请传入字段统计参数");
}else{
if(dto.getStatisticsList().stream().anyMatch(x -> StringUtils.isBlank(x.getField()))){
throw new SysException("y轴配置字段不能为空");
}
if(dto.getStatisticsList().stream().anyMatch(x -> StringUtils.isBlank(x.getStatisticsType()))){
throw new SysException("统计类型不能为空");
}
}
if(StringUtils.isBlank(dto.getX())){
throw new SysException("x轴维度不能为空");
}
if(StringUtils.isBlank(dto.getY())){
throw new SysException("y轴配置字段不能为空");
}
if(CollectionUtils.isEmpty(dto.getWhere())){
throw new SysException("where 条件不能为空");
}
......
......@@ -336,6 +336,24 @@ public class VariableServiceImpl implements VariableService {
return result.detach();
}
@Override
public Map<String, Map<String, Object>> listVariableStatusRealTimeData(@NonNull String uri, List<VariableStatusRealTimeDataDTO> statusRealTimeDataList, CurrentUser user) {
if(CollectionUtils.isEmpty(statusRealTimeDataList)){
throw new SysException("请传入变量");
}else{
if(statusRealTimeDataList.stream().anyMatch(x -> StringUtils.isBlank(x.getDeviceId()))){
throw new SysException("设备ID不能为空");
}
if(statusRealTimeDataList.stream().anyMatch(x -> StringUtils.isBlank(x.getVariableCode()))){
throw new SysException("变量Code不能为空");
}
}
Map<String, String> uriVariables = Maps.newHashMap();
uriVariables.put("appId",user.getAppId());
R<Map<String, Map<String, Object>>> result = RestTemplateUtils.post(uri,statusRealTimeDataList,new TypeToken<R<Map<String, Map<String, Object>>>>() {}.getType(), uriVariables);
return result.detach();
}
private void judgeSearchList(List<VariableSearchDTO> variableSearchList){
if(CollectionUtils.isEmpty(variableSearchList)){
throw new SysException("请传入变量");
......
......@@ -70,3 +70,4 @@ dc_client:
# historyCurve : /{appId}/variables/history-curve?deviceId={deviceId}&endTime={endTime}&startTime={startTime}&variableCode={variableCode}&variableId={variableId}&format={format}
# historyCurve : /{appId}/variables/history-curve
permissionCodeUrl : /{appId}/bi/permission/code
variableStatusRealTimeDataList: /{appId}/variables/status/real-time/data
\ No newline at end of file
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