feat(iot): 支持按区域和设备类型查询配置

新增 getConfigByAreaIdAndRelationType 方法,用于跨设备获取配置场景。
例如:工牌设备需要获取该区域的信标配置。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-01-23 13:46:49 +08:00
parent e4d07a5306
commit 06ca3070cd
10 changed files with 1439 additions and 0 deletions

View File

@@ -54,6 +54,19 @@ public interface CleanOrderIntegrationConfigService {
*/
java.util.List<AreaDeviceConfigWrapper> getConfigsByAreaIdAndRelationType(Long areaId, String relationType);
/**
* 根据区域ID和关联类型查询单个配置
* <p>
* 用于跨设备获取配置的场景,例如:工牌设备需要获取该区域的信标配置
* <p>
* 注意:如果同一区域同一类型有多个设备配置,返回第一个
*
* @param areaId 区域ID
* @param relationType 关联类型TRAFFIC_COUNTER/BEACON/BADGE
* @return 集成配置包装器,如果不存在返回 null
*/
AreaDeviceConfigWrapper getConfigByAreaIdAndRelationType(Long areaId, String relationType);
/**
* 清除设备配置缓存
* <p>

View File

@@ -107,6 +107,24 @@ public class CleanOrderIntegrationConfigServiceImpl implements CleanOrderIntegra
.collect(Collectors.toList());
}
@Override
public AreaDeviceConfigWrapper getConfigByAreaIdAndRelationType(Long areaId, String relationType) {
log.debug("[CleanOrderConfig] 查询单个区域配置areaId={}, relationType={}", areaId, relationType);
List<OpsAreaDeviceRelationDO> relations = relationMapper.selectListByAreaIdAndRelationType(areaId, relationType);
if (relations.isEmpty()) {
return null;
}
// 返回第一个启用的配置
return relations.stream()
.filter(r -> r.getEnabled())
.findFirst()
.map(this::wrapConfig)
.orElse(null);
}
@Override
public AreaDeviceConfigWrapper getConfigWrapperByDeviceId(Long deviceId) {
log.debug("[CleanOrderConfig] 查询设备完整配置deviceId={}", deviceId);