feat:应用端添加相关接口

V0.5.x
tangfudong 2024-04-07 16:00:23 +08:00
parent 71afcad7ff
commit ae85ef7a06
3 changed files with 22 additions and 9 deletions

View File

@ -4,7 +4,6 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.ReflectUtil; import cc.iotkit.common.utils.ReflectUtil;
import cc.iotkit.common.utils.StreamUtils;
import cc.iotkit.data.dao.*; import cc.iotkit.data.dao.*;
import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.data.manager.ICategoryData;
import cc.iotkit.data.manager.IDeviceInfoData; import cc.iotkit.data.manager.IDeviceInfoData;
@ -17,10 +16,7 @@ import cc.iotkit.model.device.message.DevicePropertyCache;
import cc.iotkit.model.product.Category; import cc.iotkit.model.product.Category;
import cc.iotkit.model.product.Product; import cc.iotkit.model.product.Product;
import cc.iotkit.model.stats.DataItem; import cc.iotkit.model.stats.DataItem;
import cc.iotkit.model.system.SysDept;
import cc.iotkit.model.system.SysUser;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQuery;
@ -41,8 +37,6 @@ import static cc.iotkit.data.model.QTbDeviceGroupMapping.tbDeviceGroupMapping;
import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo; import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo;
import static cc.iotkit.data.model.QTbDeviceSubUser.tbDeviceSubUser; import static cc.iotkit.data.model.QTbDeviceSubUser.tbDeviceSubUser;
import static cc.iotkit.data.model.QTbProduct.tbProduct; import static cc.iotkit.data.model.QTbProduct.tbProduct;
import static cc.iotkit.data.model.QTbSysDept.tbSysDept;
import static cc.iotkit.data.model.QTbSysUser.tbSysUser;
@Primary @Primary
@Service @Service
@ -485,8 +479,10 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
} }
private List<DeviceInfo> buildQuery(Predicate predicate) { private List<DeviceInfo> buildQuery(Predicate predicate) {
List<TbDeviceInfo> devices = jpaQueryFactory.select(Projections.bean(TbDeviceInfo.class, List<TbDeviceInfo> devices = jpaQueryFactory.select(Projections.bean(TbDeviceInfo.class,tbDeviceInfo.uid,
tbDeviceInfo.deviceId, tbDeviceInfo.deviceName, tbDeviceInfo.state )) tbDeviceInfo.deviceId, tbDeviceInfo.productKey,tbDeviceInfo.deviceName, tbDeviceInfo.state,tbDeviceInfo.createAt,
tbDeviceInfo.id,tbDeviceInfo.onlineTime,tbDeviceInfo.parentId,tbDeviceInfo.latitude,tbDeviceInfo.longitude,tbDeviceInfo.model,
tbDeviceInfo.offlineTime,tbDeviceInfo.secret))
.from(tbDeviceInfo) .from(tbDeviceInfo)
.where(predicate).fetch(); .where(predicate).fetch();
return MapstructUtils.convert(devices, DeviceInfo.class); return MapstructUtils.convert(devices, DeviceInfo.class);
@ -495,7 +491,8 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
private Predicate buildQueryCondition(DeviceInfo device) { private Predicate buildQueryCondition(DeviceInfo device) {
return PredicateBuilder.instance() return PredicateBuilder.instance()
.and(ObjectUtil.isNotNull(device.getId()), () -> tbDeviceInfo.id.eq(device.getId())) .and(ObjectUtil.isNotNull(device.getId()), () -> tbDeviceInfo.id.eq(device.getId()))
.and(ObjectUtil.isNotNull(device.getState().isOnline()), () -> tbDeviceInfo.state.eq(device.getState().isOnline() ? "online" : "offline")) .and(ObjectUtil.isNotNull(device.getDeviceName()), () -> tbDeviceInfo.deviceName.eq(device.getDeviceName()))
.and(ObjectUtil.isNotNull(device.getState()), () -> tbDeviceInfo.state.eq(device.getState().isOnline() ? "online" : "offline"))
.build(); .build();
} }

View File

@ -17,10 +17,12 @@ import cc.iotkit.common.enums.ErrCode;
import cc.iotkit.common.exception.BizException; import cc.iotkit.common.exception.BizException;
import cc.iotkit.common.satoken.utils.AuthUtil; import cc.iotkit.common.satoken.utils.AuthUtil;
import cc.iotkit.common.satoken.utils.LoginHelper; import cc.iotkit.common.satoken.utils.LoginHelper;
import cc.iotkit.common.thing.ThingModelMessage;
import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.data.manager.ICategoryData;
import cc.iotkit.data.manager.IDeviceInfoData; import cc.iotkit.data.manager.IDeviceInfoData;
import cc.iotkit.data.manager.IUserInfoData; import cc.iotkit.data.manager.IUserInfoData;
import cc.iotkit.manager.dto.bo.device.DeviceLogQueryBo;
import cc.iotkit.manager.dto.bo.device.ServiceInvokeBo; import cc.iotkit.manager.dto.bo.device.ServiceInvokeBo;
import cc.iotkit.manager.dto.bo.device.SetDeviceServicePorpertyBo; import cc.iotkit.manager.dto.bo.device.SetDeviceServicePorpertyBo;
import cc.iotkit.manager.dto.bo.ruleinfo.RuleInfoBo; import cc.iotkit.manager.dto.bo.ruleinfo.RuleInfoBo;
@ -93,6 +95,12 @@ public class SpaceDeviceController {
return null; return null;
} }
@ApiOperation("设备日志")
@PostMapping("/deviceLogs")
public Paging<ThingModelMessage> logs(@Validated @RequestBody PageRequest<DeviceLogQueryBo> request) {
return deviceServiceImpl.logs(request);
}
/** /**
* *
*/ */
@ -152,6 +160,7 @@ public class SpaceDeviceController {
.deviceId(sd.getDeviceId()) .deviceId(sd.getDeviceId())
.deviceName(device.getDeviceName()) .deviceName(device.getDeviceName())
.name(sd.getName()) .name(sd.getName())
.createTime(sd.getCreateTime())
.spaceId(sd.getSpaceId()) .spaceId(sd.getSpaceId())
.spaceName(space.getName()) .spaceName(space.getName())
.productKey(device.getProductKey()) .productKey(device.getProductKey())
@ -192,6 +201,7 @@ public class SpaceDeviceController {
List<FindDeviceVo> findDeviceVos = new ArrayList<>(); List<FindDeviceVo> findDeviceVos = new ArrayList<>();
DeviceInfo query=new DeviceInfo(); DeviceInfo query=new DeviceInfo();
query.setDeviceName(mac); query.setDeviceName(mac);
query.setState(null);
List<DeviceInfo> devices = deviceInfoData.findAllByCondition(query); List<DeviceInfo> devices = deviceInfoData.findAllByCondition(query);
if(devices == null){ if(devices == null){
return findDeviceVos; return findDeviceVos;

View File

@ -14,6 +14,7 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -85,6 +86,11 @@ public class SpaceDeviceVo {
*/ */
private String categoryName; private String categoryName;
/**
*
*/
private Date createTime;
/** /**
* *
*/ */