|
|
|
@ -116,6 +116,20 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
.eq(IotThingSourceEntity::getTenantCode, UserContext.getRealTenantCode()), IotThingSourceDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<IotThingSourceDTO> findAllByFromIdAndThingIdAndConfigTypeAndAttrCodeAndAttrGroup(Long fromId, List<Long> thingIds, String configType, Long rootId, Collection<String> attrCodes, String attrGroup) { |
|
|
|
return mapper.selectListByQueryAs( |
|
|
|
new QueryWrapper() |
|
|
|
.eq(IotThingSourceEntity::getFromId, fromId, Objects::nonNull) |
|
|
|
.in(IotThingSourceEntity::getThingId, thingIds, CollectionUtil.isNotEmpty(thingIds)) |
|
|
|
.eq(IotThingSourceEntity::getConfigType, configType, StringUtils::isNotEmpty) |
|
|
|
.eq(IotThingSourceEntity::getRootId, rootId, Objects::nonNull) |
|
|
|
.in(IotThingSourceEntity::getThingAttrCode, attrCodes, CollectionUtil.isNotEmpty(attrCodes)) |
|
|
|
.eq(IotThingSourceEntity::getTenantCode, UserContext.getRealTenantCode()) |
|
|
|
.eq(IotThingSourceEntity::getThingAttrGroup, attrGroup,StringUtils.isNotBlank(attrGroup)) |
|
|
|
, IotThingSourceDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<IotThingSourceDTO> findAllByFromIdAndThingIdAndConfigType(List<Long> fromIds, List<Long> thingIds, String configType, List<Long> rootIds) { |
|
|
|
return mapper.selectListByQueryAs( |
|
|
|
@ -134,9 +148,9 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
|
|
|
|
@Override |
|
|
|
public void save(IotThingSourceDTO iotThingSourceDTO) { |
|
|
|
List<IotThingSourceDTO> iotThingSourceDTOS = findAllByFromIdAndThingIdAndConfigTypeAndAttrCode(iotThingSourceDTO.getFromId(), |
|
|
|
List<IotThingSourceDTO> iotThingSourceDTOS = findAllByFromIdAndThingIdAndConfigTypeAndAttrCodeAndAttrGroup(iotThingSourceDTO.getFromId(), |
|
|
|
Collections.singletonList(iotThingSourceDTO.getThingId()), iotThingSourceDTO.getConfigType(), iotThingSourceDTO.getRootId(), |
|
|
|
Collections.singletonList(iotThingSourceDTO.getThingAttrCode())); |
|
|
|
Collections.singletonList(iotThingSourceDTO.getThingAttrCode()), iotThingSourceDTO.getThingAttrGroup()); |
|
|
|
if (CollectionUtil.isNotEmpty(iotThingSourceDTOS)) { |
|
|
|
throw new SysException("同一个数据源下不允许重复添加相关属性数据:" + iotThingSourceDTO.getThingAttrCode()); |
|
|
|
} |
|
|
|
@ -167,7 +181,10 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
.setThingIcon(iotThingSourceDTO.getThingIcon()) |
|
|
|
.setThingSerial(iotThingSourceDTO.getThingSerial()) |
|
|
|
.setDataTreatingMark(iotThingSourceDTO.getDataTreatingMark()) |
|
|
|
.setDataDealConfig(iotThingSourceDTO.getDataDealConfig()); |
|
|
|
.setDataDealConfig(iotThingSourceDTO.getDataDealConfig()) |
|
|
|
.setThingAttrGroup(iotThingSourceDTO.getThingAttrGroup()) |
|
|
|
.setStartStatus(iotThingSourceDTO.getStartStatus()) |
|
|
|
; |
|
|
|
mapper.update(iotThingSourceEntity); |
|
|
|
} |
|
|
|
|
|
|
|
@ -280,7 +297,10 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
.setFromCode(entityDTO.getCode()) |
|
|
|
.setFromName(entityDTO.getName()) |
|
|
|
.setRemark(params.getRemark()) |
|
|
|
.setExtendData(params.getExtendData()); |
|
|
|
.setExtendData(params.getExtendData()) |
|
|
|
// .setThingAttrGroup(params.getThingAttrGroup()) |
|
|
|
// .setStartStatus(iotThingSourceDTO.getStartStatus()) |
|
|
|
; |
|
|
|
iotThingSourceEntity.setTenantCode(UserContext.getRealTenantCode()) |
|
|
|
.setCompanyId(UserContext.getRealTenantCode()) |
|
|
|
.setDeptId(UserContext.getRealTenantCode()); |
|
|
|
@ -533,6 +553,43 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
this.updateBatch(resList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<String> attrGroup() { |
|
|
|
List<String> strings = mapper.selectListByQueryAs(QueryWrapper.create() |
|
|
|
.select(IOT_THING_SOURCE_ENTITY.THING_ATTR_GROUP).eq(IotThingSourceEntity::getTenantCode, UserContext.getRealTenantCode()), String.class); |
|
|
|
if(CollectionUtils.isEmpty(strings)){ |
|
|
|
return Lists.newArrayList(); |
|
|
|
} |
|
|
|
return strings.stream().filter(s -> !StringUtils.isBlank(s)).distinct().collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<IotThingSourceDTO> attrGroupRootId(IotThingSourceReqDTO iotThingSourceDTO) { |
|
|
|
List<IotThingSourceRelationDTO> iotThingSourceRelationDTOList = iotThingSourceDTO.getIotThingSourceRelationDTOList(); |
|
|
|
if (CollectionUtil.isEmpty(iotThingSourceRelationDTOList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<Long> thingIds = iotThingSourceRelationDTOList.stream().map(IotThingSourceRelationDTO::getThingId).toList(); |
|
|
|
List<Long> rootIds = iotThingSourceRelationDTOList.stream().map(IotThingSourceRelationDTO::getRootId).distinct().toList(); |
|
|
|
|
|
|
|
List<IotThingSourceDTO> iotThingSourceDTOS = mapper.selectListByQueryAs(QueryWrapper.create() |
|
|
|
.in(IotThingSourceEntity::getFromId, thingIds, CollectionUtil.isNotEmpty(thingIds)) |
|
|
|
.in(IotThingSourceEntity::getRootId, rootIds, CollectionUtil.isNotEmpty(rootIds)) |
|
|
|
.eq(IotThingSourceEntity::getConfigType, iotThingSourceDTO.getConfigType()) |
|
|
|
.eq(IotThingSourceEntity::getThingAttrCodeType, iotThingSourceDTO.getThingAttrCodeType(), |
|
|
|
StringUtils.isNotBlank(iotThingSourceDTO.getThingAttrCodeType())) |
|
|
|
.eq(IotThingSourceEntity::getTenantCode, UserContext.getRealTenantCode()) |
|
|
|
.eq(IotThingSourceEntity::getStartStatus, "0") |
|
|
|
.orderBy(IotThingSourceEntity::getSort,true) |
|
|
|
, IotThingSourceDTO.class |
|
|
|
); |
|
|
|
// 根据 thingAttrGroup 去重 |
|
|
|
Set<String> seen = new LinkedHashSet<>(); |
|
|
|
return iotThingSourceDTOS.stream() |
|
|
|
.filter(dto -> StringUtils.isNotBlank(dto.getThingAttrGroup()) && seen.add(dto.getThingAttrGroup())) |
|
|
|
.toList(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 自定义函数去重 |
|
|
|
* |
|
|
|
|