Browse Source

物关系视图bug

2024年12月25日10:42:08
qingyuan_dev_new
lishuai 1 year ago
parent
commit
6f0c245a0d
  1. 3
      modules/dequeue/src/main/java/com/thing/queue/AbstractConsumerService.java
  2. 20
      modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/controller/EnergyUsageController.java
  3. 4
      modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/dto/EnergyUsageReqDTO.java
  4. 2
      modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/service/EnergyUsageFlowService.java
  5. 21
      modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/service/impl/EnergyUsageFlowServiceImpl.java
  6. 2
      modules/thing/src/main/java/com/thing/thing/dictRelation/service/IotThingDictRelationService.java
  7. 8
      modules/thing/src/main/java/com/thing/thing/dictRelation/service/impl/IotThingDictRelationServiceImpl.java
  8. 2
      modules/thing/src/main/java/com/thing/thing/entity/service/impl/IotThingEntityServiceImpl.java

3
modules/dequeue/src/main/java/com/thing/queue/AbstractConsumerService.java

@ -88,6 +88,9 @@ public abstract class AbstractConsumerService<N extends com.google.protobuf.Gene
// socket推送 // socket推送
applicationEventPublisher.publishEvent(new QueueSocketEvent(this, lastList)); applicationEventPublisher.publishEvent(new QueueSocketEvent(this, lastList));
// 模拟数据推送
applicationEventPublisher.publishEvent(new SimulateSocketEvent(this, lastList));
// 同步物模型物实体 // 同步物模型物实体
applicationEventPublisher.publishEvent(new QueueDeviceEvent(this, lastList)); applicationEventPublisher.publishEvent(new QueueDeviceEvent(this, lastList));
} }

20
modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/controller/EnergyUsageController.java

@ -15,17 +15,15 @@ import com.thing.common.core.web.response.Result;
import com.thing.device.analysisdata.dto.AnalysisDataRespDTO; import com.thing.device.analysisdata.dto.AnalysisDataRespDTO;
import com.thing.device.analysisdata.dto.ThingEnergyDictData; import com.thing.device.analysisdata.dto.ThingEnergyDictData;
import com.thing.thing.entity.dto.IotThingEntityDTO; import com.thing.thing.entity.dto.IotThingEntityDTO;
import com.thing.thing.entity.entity.IotThingEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -104,6 +102,20 @@ public class EnergyUsageController {
return new Result<EnergyUsageSummaryDTO>().ok(result); return new Result<EnergyUsageSummaryDTO>().ok(result);
} }
@PostMapping("flow/summary/all")
@Operation(summary="能流汇总数据")
@Parameters({
@Parameter(name = Constant.BEGIN_TIME, description = "开始时间"),
@Parameter(name = Constant.END_TIME, description = "结束时间"),
@Parameter(name = "thingId", description = "物id"),
@Parameter(name = "attrType", description = "属性类型"),
@Parameter(name = "energyVarietyId", description = "能源属性Id"),
})
public Result<List<EnergyUsageSummaryDTO>> getFlowSummaryAll(@RequestBody EnergyUsageReqDTO request) {
List<EnergyUsageSummaryDTO> list = energyUsageFlowService.getFlowSummaryAll(request);
return new Result<List<EnergyUsageSummaryDTO>>().ok(list);
}
/*------------------------------用能概况-----------------------------------*/ /*------------------------------用能概况-----------------------------------*/
@PostMapping("overview/variety/list") @PostMapping("overview/variety/list")

4
modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/dto/EnergyUsageReqDTO.java

@ -40,4 +40,8 @@ public class EnergyUsageReqDTO {
@Schema(description = "显示层级, 默认2级") @Schema(description = "显示层级, 默认2级")
private int depth = 2; private int depth = 2;
@Schema(description = "物id")
private Long thingId;
} }

2
modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/service/EnergyUsageFlowService.java

@ -13,4 +13,6 @@ public interface EnergyUsageFlowService {
List<CarbonEnergyVarietyDTO> energyVarietyList(CarbonEnergyVarietyReqDTO request); List<CarbonEnergyVarietyDTO> energyVarietyList(CarbonEnergyVarietyReqDTO request);
EnergyUsageSummaryDTO getFlowSummary(EnergyUsageReqDTO request); EnergyUsageSummaryDTO getFlowSummary(EnergyUsageReqDTO request);
List<EnergyUsageSummaryDTO> getFlowSummaryAll(EnergyUsageReqDTO request);
} }

21
modules/report-analysis/src/main/java/com/thing/carbon/energyrepory/service/impl/EnergyUsageFlowServiceImpl.java

@ -1,6 +1,7 @@
package com.thing.carbon.energyrepory.service.impl; package com.thing.carbon.energyrepory.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.thing.carbon.config.dto.CarbonEnergyVarietyDTO; import com.thing.carbon.config.dto.CarbonEnergyVarietyDTO;
import com.thing.carbon.config.dto.CarbonEnergyVarietyReqDTO; import com.thing.carbon.config.dto.CarbonEnergyVarietyReqDTO;
import com.thing.carbon.energyrepory.dto.EnergyUsageReqDTO; import com.thing.carbon.energyrepory.dto.EnergyUsageReqDTO;
@ -106,6 +107,26 @@ public class EnergyUsageFlowServiceImpl implements EnergyUsageFlowService {
return fatherSummary; return fatherSummary;
} }
@Override
public List<EnergyUsageSummaryDTO> getFlowSummaryAll(EnergyUsageReqDTO request) {
CarbonEnergyVarietyReqDTO varietyReqDTO = new CarbonEnergyVarietyReqDTO();
varietyReqDTO.setThingId(request.getThingId());
varietyReqDTO.setRootId(request.getRootId());
varietyReqDTO.setRootThingId(request.getRootThingId());
varietyReqDTO.setAttrType(request.getAttrType());
List<CarbonEnergyVarietyDTO> carbonEnergyVarietyDTOS = commonService.energyVarietyList(varietyReqDTO);
if(CollectionUtil.isEmpty(carbonEnergyVarietyDTOS)){
return null;
}
List<EnergyUsageSummaryDTO> summaryList = new ArrayList<>();
for (CarbonEnergyVarietyDTO carbonEnergyVarietyDTO : carbonEnergyVarietyDTOS) {
request.setEnergyVarietyId(carbonEnergyVarietyDTO.getId());
EnergyUsageSummaryDTO flowSummary = getFlowSummary(request);
summaryList.add(flowSummary);
}
return summaryList;
}
private ThingSortTreeDTO findSubTree(List<ThingSortTreeDTO> treeNodes, Long entityId, Long rootThingId) { private ThingSortTreeDTO findSubTree(List<ThingSortTreeDTO> treeNodes, Long entityId, Long rootThingId) {
for (ThingSortTreeDTO treeNode : treeNodes) { for (ThingSortTreeDTO treeNode : treeNodes) {
if (Objects.equals(treeNode.getEntityId(), entityId)) { if (Objects.equals(treeNode.getEntityId(), entityId)) {

2
modules/thing/src/main/java/com/thing/thing/dictRelation/service/IotThingDictRelationService.java

@ -44,6 +44,8 @@ public interface IotThingDictRelationService extends IBaseService<IotThingDictRe
IotThingDictRelationDTO findByIds(List<String> ids); IotThingDictRelationDTO findByIds(List<String> ids);
List<IotThingDictRelationDTO> findAllByEntityIdAndCodes(Long entityId, Collection<String> codes); List<IotThingDictRelationDTO> findAllByEntityIdAndCodes(Long entityId, Collection<String> codes);
List<IotThingDictRelationDTO> findAllByEntityIdsAndCode(List<Long> entityIds, String code);
/** 注意 多个物 有相同的属性code **/ /** 注意 多个物 有相同的属性code **/
List<IotThingDictRelationParamDTO> findAllByEntityIdsAndCodes(Collection<Long> entityIds, Collection<String> codes); List<IotThingDictRelationParamDTO> findAllByEntityIdsAndCodes(Collection<Long> entityIds, Collection<String> codes);
/** 此方法可以避免 有相同的属性code **/ /** 此方法可以避免 有相同的属性code **/

8
modules/thing/src/main/java/com/thing/thing/dictRelation/service/impl/IotThingDictRelationServiceImpl.java

@ -263,6 +263,14 @@ public class IotThingDictRelationServiceImpl extends BaseServiceImpl<IotThingDic
, IotThingDictRelationDTO.class); , IotThingDictRelationDTO.class);
} }
@Override
public List<IotThingDictRelationDTO> findAllByEntityIdsAndCode(List<Long> entityIds, String code) {
return mapper.selectListByQueryAs(new QueryWrapper()
.in(IotThingDictRelationEntity::getEntityId, entityIds)
.eq(IotThingDictRelationEntity::getCode, code)
, IotThingDictRelationDTO.class);
}
@Override @Override
public List<IotThingDictRelationParamDTO> findAllByEntityIdsAndCodes(Collection<Long> entityIds, Collection<String> codes) { public List<IotThingDictRelationParamDTO> findAllByEntityIdsAndCodes(Collection<Long> entityIds, Collection<String> codes) {
return mapper.selectListByQueryAs(new QueryWrapper() return mapper.selectListByQueryAs(new QueryWrapper()

2
modules/thing/src/main/java/com/thing/thing/entity/service/impl/IotThingEntityServiceImpl.java

@ -375,7 +375,7 @@ public class IotThingEntityServiceImpl extends BaseServiceImpl<IotThingEntityMap
public Optional<List<IotThingEntityDTO>> findByCodes(Collection<String> codes,Long tenantCode,boolean isEntity) { public Optional<List<IotThingEntityDTO>> findByCodes(Collection<String> codes,Long tenantCode,boolean isEntity) {
return Optional.ofNullable(mapper.selectListByQueryAs(QueryWrapper.create() return Optional.ofNullable(mapper.selectListByQueryAs(QueryWrapper.create()
.in(IotThingEntity::getCode, codes,CollectionUtils.isNotEmpty(codes)) .in(IotThingEntity::getCode, codes,CollectionUtils.isNotEmpty(codes))
.in(IotThingEntity::getTenantCode, tenantCode,!Objects.isNull(tenantCode))
.eq(IotThingEntity::getTenantCode, tenantCode,!Objects.isNull(tenantCode))
.eq(IotThingEntity::getTemplateMark,isEntity? "0":"1") .eq(IotThingEntity::getTemplateMark,isEntity? "0":"1")
,IotThingEntityDTO.class)); ,IotThingEntityDTO.class));
} }

Loading…
Cancel
Save