Browse Source

bug 修复

thing_master
xiachao 1 year ago
parent
commit
e533d8c02e
  1. 10
      modules/report-analysis/src/main/java/com/thing/carbon/energyloss/dto/EnergyLossReportParam.java
  2. 16
      modules/report-analysis/src/main/java/com/thing/carbon/energyloss/service/impl/EnergyLossServiceImpl.java

10
modules/report-analysis/src/main/java/com/thing/carbon/energyloss/dto/EnergyLossReportParam.java

@ -34,4 +34,14 @@ public class EnergyLossReportParam implements Serializable {
@Schema(description = "配置类型 例如:监控分析配置,用量分析配置") @Schema(description = "配置类型 例如:监控分析配置,用量分析配置")
private String configType; private String configType;
public String getAttrCodeType(){
if(this.thingAttrCodeType.equals("date")){
return "hh";
}
if(this.thingAttrCodeType.equals("month")){
return "dd";
}
return "mm";
}
} }

16
modules/report-analysis/src/main/java/com/thing/carbon/energyloss/service/impl/EnergyLossServiceImpl.java

@ -15,6 +15,7 @@ import com.thing.thing.context.service.ThingManageContextService;
import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO; import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -66,7 +67,8 @@ public class EnergyLossServiceImpl implements EnergyLossService {
.eq(IotThingSourceEntity::getRootId, rootId) .eq(IotThingSourceEntity::getRootId, rootId)
.eq(IotThingSourceEntity::getConfigType, param.getConfigType()) .eq(IotThingSourceEntity::getConfigType, param.getConfigType())
.eq(IotThingSourceEntity::getThingAttrGroup,labelGroupName) .eq(IotThingSourceEntity::getThingAttrGroup,labelGroupName)
.eq(IotThingSourceEntity::getStartStatus,"0"));
.eq(IotThingSourceEntity::getStartStatus,"0")
.eq(IotThingSourceEntity::getThingAttrCodeType,param.getAttrCodeType()));
String key=null; String key=null;
if (CollectionUtil.isNotEmpty(iotThingSourceEntities)){ if (CollectionUtil.isNotEmpty(iotThingSourceEntities)){
key = iotThingSourceEntities.get(0).getThingAttrCode(); key = iotThingSourceEntities.get(0).getThingAttrCode();
@ -80,8 +82,8 @@ public class EnergyLossServiceImpl implements EnergyLossService {
} }
//获取物 对应时间的能耗值 //获取物 对应时间的能耗值
Map<String, BigDecimal> codeAndValueMap = new HashMap<>();
List<TsKvDTO> dataList = tsKvService.findTsKvByMultiMap(multiMap, beginTs, endTs, Boolean.FALSE); List<TsKvDTO> dataList = tsKvService.findTsKvByMultiMap(multiMap, beginTs, endTs, Boolean.FALSE);
Map<String, BigDecimal> codeAndValueMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(dataList)){ if (CollectionUtil.isNotEmpty(dataList)){
codeAndValueMap = dataList.stream() codeAndValueMap = dataList.stream()
.filter(dto -> dto.getVal() != null && !dto.getVal().isEmpty()) .filter(dto -> dto.getVal() != null && !dto.getVal().isEmpty())
@ -226,8 +228,8 @@ public class EnergyLossServiceImpl implements EnergyLossService {
dto.setCurrentValue(currentValue); dto.setCurrentValue(currentValue);
List<EnergyLossDTO> children = buildEnergyLossDTOListRecursive(fromIdMap,data.getToId(),codeAndValueMap); List<EnergyLossDTO> children = buildEnergyLossDTOListRecursive(fromIdMap,data.getToId(),codeAndValueMap);
if(ObjectUtils.isNotEmpty(children)){
dto.setChilds(children); dto.setChilds(children);
BigDecimal lastValue = children.stream() BigDecimal lastValue = children.stream()
.map(EnergyLossDTO::getCurrentValue) .map(EnergyLossDTO::getCurrentValue)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
@ -239,6 +241,14 @@ public class EnergyLossServiceImpl implements EnergyLossService {
dto.setDifferenceValue(differenceValue); dto.setDifferenceValue(differenceValue);
dto.setPercentValue(percentValue); dto.setPercentValue(percentValue);
dtos.add(dto); dtos.add(dto);
}else {
dto.setLastValue(BigDecimal.ZERO);
dto.setChilds(new ArrayList<>());
dto.setDifferenceValue(BigDecimal.ZERO);
dto.setPercentValue(BigDecimal.ZERO);
dtos.add(dto);
}
} }
return dtos; return dtos;
} }

Loading…
Cancel
Save