commit
bd8903a6dd
|
@ -13,8 +13,6 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
|
@ -101,11 +99,49 @@
|
|||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-manager</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<mapstruct-plus.version>1.3.4</mapstruct-plus.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source> <!-- depending on your project -->
|
||||
<target>${java.version}</target> <!-- depending on your project -->
|
||||
<encoding>utf8</encoding>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>io.github.linpeilie</groupId>
|
||||
<artifactId>mapstruct-plus-processor</artifactId>
|
||||
<version>${mapstruct-plus.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
<!-- other annotation processors -->
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -5,6 +5,7 @@ import cc.iotkit.model.InvokeResult;
|
|||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiSetDeviceServicePropertyBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
import cc.iotkit.openapi.service.OpenBaseService;
|
||||
import cc.iotkit.openapi.service.OpenDeviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -57,7 +58,7 @@ public class OpenDeviceController {
|
|||
|
||||
@ApiOperation("查询指定设备的属性快照")
|
||||
@PostMapping("/v1/queryDevicePropertyStatus")
|
||||
public Map<String, Object> getDevicePropertyStatus(@RequestBody @Validated Request<OpenapiDeviceBo> bo) {
|
||||
return openDeviceService.getDetail(bo.getData()).getProperty();
|
||||
public OpenDevicePropertyVo getDevicePropertyStatus(@RequestBody @Validated Request<OpenapiDeviceBo> bo) {
|
||||
return openDeviceService.getDevicePropertyStatus(bo.getData());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package cc.iotkit.openapi.dto.vo;
|
||||
|
||||
import cc.iotkit.model.product.ProductModel;
|
||||
import cc.iotkit.model.product.ThingModel;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel(value = "OpenDevicePropertyVo")
|
||||
@Data
|
||||
@AutoMapper(target = ThingModel.class)
|
||||
public class OpenDevicePropertyVo {
|
||||
|
||||
@ApiModelProperty(value="设备属性")
|
||||
private Map<String, Object> property = new HashMap<>();
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "模型内容")
|
||||
private ThingModel.Model model;
|
||||
|
||||
@ApiModelProperty(value = "产品key")
|
||||
private String productKey;
|
||||
}
|
|
@ -2,6 +2,7 @@ package cc.iotkit.openapi.service;
|
|||
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -22,4 +23,6 @@ public interface OpenDeviceService {
|
|||
* 设备属性设置
|
||||
*/
|
||||
String setProperty(String productKey, String deviceName, Map<String, Object> properties);
|
||||
|
||||
OpenDevicePropertyVo getDevicePropertyStatus(OpenapiDeviceBo data);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,18 @@ package cc.iotkit.openapi.service.impl;
|
|||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.DeviceUtil;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
import cc.iotkit.data.manager.IThingModelData;
|
||||
import cc.iotkit.manager.dto.vo.thingmodel.ThingModelVo;
|
||||
import cc.iotkit.manager.service.DeviceService;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||
import cc.iotkit.model.product.Product;
|
||||
import cc.iotkit.model.product.ThingModel;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
import cc.iotkit.openapi.service.OpenDeviceService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -32,6 +37,10 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
|
|||
@Qualifier("productDataCache")
|
||||
private IProductData productData;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("thingModelDataCache")
|
||||
private IThingModelData thingModelData;
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
|
@ -98,5 +107,16 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
|
|||
return deviceService.setProperty(deviceRepetition.getDeviceId(), args, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpenDevicePropertyVo getDevicePropertyStatus(OpenapiDeviceBo bo) {
|
||||
ThingModel thingModel = thingModelData.findByProductKey(bo.getProductKey());
|
||||
OpenDevicePropertyVo propertyVo = MapstructUtils.convert(thingModel, OpenDevicePropertyVo.class);
|
||||
DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(bo.getProductKey(), bo.getDeviceName());
|
||||
if (propertyVo != null){
|
||||
propertyVo.setProperty(deviceInfoData.getProperties(deviceInfo.getDeviceId()));
|
||||
}
|
||||
return propertyVo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue