|
|
@ -230,7 +230,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<TsKvDTO> getSequenceAttr(String entityCode, String attrs, Long startTime, Long endTime) { |
|
|
|
|
|
|
|
|
public PageData<TsKvDTO> getSequenceAttr(String entityCode, String attrs, Long startTime, Long endTime,Integer page,Integer limit) { |
|
|
Optional<ModelDetailDTO> optional = findByCode(entityCode); |
|
|
Optional<ModelDetailDTO> optional = findByCode(entityCode); |
|
|
if (optional.isEmpty()) { |
|
|
if (optional.isEmpty()) { |
|
|
return null; |
|
|
return null; |
|
|
@ -240,13 +240,13 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
if (StringUtils.isNotBlank(attrs)) { |
|
|
if (StringUtils.isNotBlank(attrs)) { |
|
|
attrList.addAll(Arrays.stream(attrs.split(",")).distinct().toList()); |
|
|
attrList.addAll(Arrays.stream(attrs.split(",")).distinct().toList()); |
|
|
} |
|
|
} |
|
|
List<TsKvDTO> tskvList; |
|
|
|
|
|
|
|
|
PageData<TsKvDTO> tskvList; |
|
|
// 有时间参数:查历史值 |
|
|
// 有时间参数:查历史值 |
|
|
if (!Objects.isNull(startTime) && !Objects.isNull(endTime) && CollectionUtils.isNotEmpty(attrList)) { |
|
|
if (!Objects.isNull(startTime) && !Objects.isNull(endTime) && CollectionUtils.isNotEmpty(attrList)) { |
|
|
tskvList = tsKvService.findTsKvByCodeAndAttrs(entityCode, attrList, startTime, endTime, false); |
|
|
|
|
|
|
|
|
tskvList = tsKvService.findPageTsKvByCodeAndAttrs(entityCode, attrList, startTime, endTime, false,page, limit); |
|
|
} else { |
|
|
} else { |
|
|
// 没有时间参数:查最新值 |
|
|
// 没有时间参数:查最新值 |
|
|
tskvList = tsKvService.findLatestByCodeAndAttrs(entityCode, attrList, false); |
|
|
|
|
|
|
|
|
tskvList = tsKvService.findPageTsKvByCodeAndAttrs(entityCode, attrList, null,null, false,page, limit); |
|
|
} |
|
|
} |
|
|
return tskvList; |
|
|
return tskvList; |
|
|
} |
|
|
} |
|
|
@ -292,7 +292,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(code), dto.getTenantCodes()); |
|
|
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(code), dto.getTenantCodes()); |
|
|
Optional<ModelDetailDTO> optional = findByCode(code); |
|
|
Optional<ModelDetailDTO> optional = findByCode(code); |
|
|
if (optional.isEmpty()) { |
|
|
if (optional.isEmpty()) { |
|
|
IotThingModelEntity modelEntity = buildIotThingModelEntity(code, dto.getRemark(), (long) CollectionUtils.size(entitiesList), null, dto.getGateway()); |
|
|
|
|
|
|
|
|
IotThingModelEntity modelEntity = buildIotThingModelEntity(code, dto.getRemark(), (long) CollectionUtils.size(entitiesList), null, dto.getGateway(),dto.getRealType()); |
|
|
mapper.insert(modelEntity); |
|
|
mapper.insert(modelEntity); |
|
|
} else { |
|
|
} else { |
|
|
updateModelAuthNumByCodes(Collections.singletonList(code)); |
|
|
updateModelAuthNumByCodes(Collections.singletonList(code)); |
|
|
@ -314,7 +314,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
//更新分配企业情况:如果是原先或者没有则不做分配相关工作,如果存在新增的分配情况则做分配 |
|
|
//更新分配企业情况:如果是原先或者没有则不做分配相关工作,如果存在新增的分配情况则做分配 |
|
|
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(modelDTO.getCode()), dto.getTenantCodes()); |
|
|
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(modelDTO.getCode()), dto.getTenantCodes()); |
|
|
IotThingModelEntity iotThingModelEntity = buildIotThingModelEntity(modelDTO.getCode(), dto.getRemark(), |
|
|
IotThingModelEntity iotThingModelEntity = buildIotThingModelEntity(modelDTO.getCode(), dto.getRemark(), |
|
|
(long) CollectionUtils.size(entitiesList), modelDTO.getToken(), gateway); |
|
|
|
|
|
|
|
|
(long) CollectionUtils.size(entitiesList), modelDTO.getToken(), gateway,dto.getRealType()); |
|
|
iotThingModelEntity.setId(modelDTO.getId()); |
|
|
iotThingModelEntity.setId(modelDTO.getId()); |
|
|
mapper.update(iotThingModelEntity, true); |
|
|
mapper.update(iotThingModelEntity, true); |
|
|
//更新缓存 |
|
|
//更新缓存 |
|
|
@ -408,7 +408,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IotThingModelEntity buildIotThingModelEntity(String code, String remark, Long authNum, String token, String gateWay) { |
|
|
|
|
|
|
|
|
private IotThingModelEntity buildIotThingModelEntity(String code, String remark, Long authNum, String token, String gateWay,String realType) { |
|
|
IotThingModelEntity iotThingModelEntity = new IotThingModelEntity(); |
|
|
IotThingModelEntity iotThingModelEntity = new IotThingModelEntity(); |
|
|
iotThingModelEntity.setCode(code); |
|
|
iotThingModelEntity.setCode(code); |
|
|
iotThingModelEntity.setRemark(remark); |
|
|
iotThingModelEntity.setRemark(remark); |
|
|
@ -418,7 +418,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe |
|
|
iotThingModelEntity.setStatus(ThingStatus.NOT_CONNECTED.getCode()); |
|
|
iotThingModelEntity.setStatus(ThingStatus.NOT_CONNECTED.getCode()); |
|
|
iotThingModelEntity.setOrigin(QueueOriginType.MQTT_CLIENT.name()); |
|
|
iotThingModelEntity.setOrigin(QueueOriginType.MQTT_CLIENT.name()); |
|
|
iotThingModelEntity.setStatusTs(DateTimeUtils.getCurrentTime()); |
|
|
iotThingModelEntity.setStatusTs(DateTimeUtils.getCurrentTime()); |
|
|
iotThingModelEntity.setRealType(ThingRealType.INVENTED.getValue()); |
|
|
|
|
|
|
|
|
iotThingModelEntity.setRealType(StringUtils.isBlank(realType) ? ThingRealType.INVENTED.getValue(): realType); |
|
|
iotThingModelEntity.setGateway(gateWay); |
|
|
iotThingModelEntity.setGateway(gateWay); |
|
|
return iotThingModelEntity; |
|
|
return iotThingModelEntity; |
|
|
} |
|
|
} |
|
|
|