Commit 609485a3 zshaohui

温湿度求平均值展示

1 个父辈 058a8325
......@@ -15,6 +15,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.kanban.rest.bean.HumiAndtemp;
import com.neotel.smfcore.core.kanban.rest.bean.dto.*;
import com.neotel.smfcore.core.kanban.rest.bean.mapstruct.BoxTaskMapper;
import com.neotel.smfcore.core.kanban.rest.bean.query.BoxTaskQueryCriter;
......@@ -52,6 +53,7 @@ import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j
......@@ -462,7 +464,18 @@ public class BoxKanbanController {
if (data != null){
String humiAndtempListStr = data.get("humiAndtempList");
if (StringUtils.isNotBlank(humiAndtempListStr)){
boxDto.setHumiAndtempList(JsonUtil.toList(humiAndtempListStr,Map.class));
List<HumiAndtemp> humiAndtempList = JsonUtil.toList(humiAndtempListStr, HumiAndtemp.class);
boxDto.setHumiAndtempList(humiAndtempList);
//得到温度平均值
Double humidityAgv = humiAndtempList.stream().collect(Collectors.averagingDouble(HumiAndtemp::getHumidity));
if (humidityAgv != null){
boxDto.setHumidity(humidityAgv + "");
}
//得到湿度平均值
Double temperatureAgv = humiAndtempList.stream().collect(Collectors.averagingDouble(HumiAndtemp::getTemperature));
if (temperatureAgv != null){
boxDto.setTemperature(temperatureAgv + "");
}
}
}
......@@ -497,7 +510,18 @@ public class BoxKanbanController {
if (data != null){
String humiAndtempListStr = data.get("humiAndtempList");
if (StringUtils.isNotBlank(humiAndtempListStr)){
boxDto.setHumiAndtempList(JsonUtil.toList(humiAndtempListStr,Map.class));
List<HumiAndtemp> humiAndtempList = JsonUtil.toList(humiAndtempListStr, HumiAndtemp.class);
boxDto.setHumiAndtempList(humiAndtempList);
//得到温度平均值
Double humidityAgv = humiAndtempList.stream().collect(Collectors.averagingDouble(HumiAndtemp::getHumidity));
if (humidityAgv != null){
boxDto.setHumidity(humidityAgv + "");
}
//得到湿度平均值
Double temperatureAgv = humiAndtempList.stream().collect(Collectors.averagingDouble(HumiAndtemp::getTemperature));
if (temperatureAgv != null){
boxDto.setTemperature(temperatureAgv + "");
}
}
}
......
package com.neotel.smfcore.core.kanban.rest.bean;
import lombok.Getter;
/**
* 温湿度
*/
@Getter
public class HumiAndtemp {
/**
* 设备id
*/
private String id;
/**
* 温度
*/
private Double humidity;
/**
* 湿度
*/
private Double temperature;
}
package com.neotel.smfcore.core.kanban.rest.bean.dto;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.kanban.rest.bean.HumiAndtemp;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import io.swagger.annotations.ApiModelProperty;
......@@ -82,5 +83,5 @@ public class BoxStatusDto {
private String inListName="";
@ApiModelProperty("温湿度列表")
private List<Map> humiAndtempList;
private List<HumiAndtemp> humiAndtempList;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!