fix:插件上传、下行日志bug修复

V0.5.x
xiwa 2024-02-14 15:19:09 +08:00
parent 1fcf5035dc
commit 6361bb399c
3 changed files with 11 additions and 6 deletions

View File

@ -79,7 +79,7 @@
<dependency> <dependency>
<groupId>org.jooq</groupId> <groupId>org.jooq</groupId>
<artifactId>jooq</artifactId> <artifactId>jooq</artifactId>
<version>3.14.15</version>Fv <version>3.14.15</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -54,7 +54,7 @@ public class PluginServiceImpl implements IPluginService {
} }
String pluginId = plugin.getPluginId(); String pluginId = plugin.getPluginId();
if (!file.getName().contains(pluginId)) { if (pluginId!=null && !file.getOriginalFilename().contains(pluginId)) {
throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, "文件名与原插件id不匹配"); throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, "文件名与原插件id不匹配");
} }

View File

@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
/** /**
* *
@ -123,7 +124,7 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
.build(); .build();
//调用插件设备服务接口 //调用插件设备服务接口
result = deviceService.serviceInvoke(action); result = deviceService.serviceInvoke(action);
publish(service, result.getCode()); publish(service, deviceInfo.getDeviceId(), result.getCode());
} else if (ThingService.TYPE_PROPERTY.equals(type)) { } else if (ThingService.TYPE_PROPERTY.equals(type)) {
if ("set".equals(identifier)) { if ("set".equals(identifier)) {
if (!(service.getParams() instanceof Map)) { if (!(service.getParams() instanceof Map)) {
@ -139,7 +140,7 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
.build(); .build();
//调用插件设备服务接口 //调用插件设备服务接口
result = deviceService.propertySet(action); result = deviceService.propertySet(action);
publish(service, result.getCode()); publish(service, deviceInfo.getDeviceId(), result.getCode());
} else if ("get".equals(identifier)) { } else if ("get".equals(identifier)) {
//属性获取 //属性获取
PropertyGet action = PropertyGet.builder() PropertyGet action = PropertyGet.builder()
@ -150,7 +151,7 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
.build(); .build();
//调用插件设备服务接口 //调用插件设备服务接口
result = deviceService.propertyGet(action); result = deviceService.propertyGet(action);
publish(service, result.getCode()); publish(service, deviceInfo.getDeviceId(), result.getCode());
} }
} }
@ -159,9 +160,11 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
} }
} }
private void publish(ThingService<?> service, int code) { private void publish(ThingService<?> service, String deviceId, int code) {
//产生下发消息作为下行日志保存 //产生下发消息作为下行日志保存
ThingModelMessage message = ThingModelMessage.builder() ThingModelMessage message = ThingModelMessage.builder()
.id(UUID.randomUUID().toString())
.deviceId(deviceId)
.mid(service.getMid()) .mid(service.getMid())
.productKey(service.getProductKey()) .productKey(service.getProductKey())
.deviceName(service.getDeviceName()) .deviceName(service.getDeviceName())
@ -169,6 +172,8 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
.type(service.getType()) .type(service.getType())
.data(service.getParams()) .data(service.getParams())
.code(code) .code(code)
.occurred(System.currentTimeMillis())
.time(System.currentTimeMillis())
.build(); .build();
producer.publish(Constants.THING_MODEL_MESSAGE_TOPIC, message); producer.publish(Constants.THING_MODEL_MESSAGE_TOPIC, message);