Browse Source

物模型分页

2024年8月9日09:41:59
thing_master
lishuai 1 year ago
parent
commit
2d3e3be6f3
  1. 4
      modules/thing/src/main/java/com/thing/thing/model/controller/IotThingModelController.java
  2. 2
      modules/thing/src/main/java/com/thing/thing/model/param/DistributeModelParam.java
  3. 2
      modules/thing/src/main/java/com/thing/thing/model/service/IotThingModelService.java
  4. 16
      modules/thing/src/main/java/com/thing/thing/model/service/impl/IotThingModelServiceImpl.java

4
modules/thing/src/main/java/com/thing/thing/model/controller/IotThingModelController.java

@ -151,8 +151,8 @@ public class IotThingModelController {
@Parameter(name = "endTime",description ="结束时间"),
@Parameter(name = "attrs",description ="属性编码集合")
})
public Result<List<TsKvDTO>> getSequenceAttr(String entityCode,String attrs,Long startTime,Long endTime) {
return new Result<List<TsKvDTO>>().ok(service.getSequenceAttr(entityCode,attrs,startTime,endTime));
public Result<PageData<TsKvDTO>> getSequenceAttr(String entityCode,String attrs,Long startTime,Long endTime,Integer page,Integer limit) {
return new Result<PageData<TsKvDTO>>().ok(service.getSequenceAttr(entityCode,attrs,startTime,endTime,page,limit));
}
@PostMapping("saveSequenceAttr")

2
modules/thing/src/main/java/com/thing/thing/model/param/DistributeModelParam.java

@ -28,6 +28,8 @@ public class DistributeModelParam implements Serializable {
private String code;
@Schema(description = "是否网关: 0否1是")
private String gateway;
@Schema(description = "租户内物存在类型,0虚拟 1真实")
private String realType;
@Schema(description = "备注说明")
private String remark;
@Schema(description = "物模型:分配租户编码(分配企业功能参数)")

2
modules/thing/src/main/java/com/thing/thing/model/service/IotThingModelService.java

@ -37,7 +37,7 @@ public interface IotThingModelService extends IBaseService<IotThingModelEntity>
Map<String, Object> status();
List<TsKvDTO> getSequenceAttr(String entityCode, String attrs, Long startTime, Long endTime);
PageData<TsKvDTO> getSequenceAttr(String entityCode, String attrs, Long startTime, Long endTime,Integer page,Integer limit);
List<TsKvDTO> latestData(String entityCode, String attrs, Long startTime, Long endTime);

16
modules/thing/src/main/java/com/thing/thing/model/service/impl/IotThingModelServiceImpl.java

@ -230,7 +230,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe
}
@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);
if (optional.isEmpty()) {
return null;
@ -240,13 +240,13 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe
if (StringUtils.isNotBlank(attrs)) {
attrList.addAll(Arrays.stream(attrs.split(",")).distinct().toList());
}
List<TsKvDTO> tskvList;
PageData<TsKvDTO> tskvList;
// 有时间参数查历史值
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 {
// 没有时间参数查最新值
tskvList = tsKvService.findLatestByCodeAndAttrs(entityCode, attrList, false);
tskvList = tsKvService.findPageTsKvByCodeAndAttrs(entityCode, attrList, null,null, false,page, limit);
}
return tskvList;
}
@ -292,7 +292,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(code), dto.getTenantCodes());
Optional<ModelDetailDTO> optional = findByCode(code);
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);
} else {
updateModelAuthNumByCodes(Collections.singletonList(code));
@ -314,7 +314,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe
//更新分配企业情况如果是原先或者没有则不做分配相关工作如果存在新增的分配情况则做分配
List<IotThingEntity> entitiesList = shareThingsToTenantCode(Collections.singletonList(modelDTO.getCode()), dto.getTenantCodes());
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());
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.setCode(code);
iotThingModelEntity.setRemark(remark);
@ -418,7 +418,7 @@ public class IotThingModelServiceImpl extends BaseServiceImpl<IotThingModelMappe
iotThingModelEntity.setStatus(ThingStatus.NOT_CONNECTED.getCode());
iotThingModelEntity.setOrigin(QueueOriginType.MQTT_CLIENT.name());
iotThingModelEntity.setStatusTs(DateTimeUtils.getCurrentTime());
iotThingModelEntity.setRealType(ThingRealType.INVENTED.getValue());
iotThingModelEntity.setRealType(StringUtils.isBlank(realType) ? ThingRealType.INVENTED.getValue(): realType);
iotThingModelEntity.setGateway(gateWay);
return iotThingModelEntity;
}

Loading…
Cancel
Save