Commit a083a7a5 authored by 赵啸非's avatar 赵啸非

设备列表导出优化

parent 90fee9b6
......@@ -56,7 +56,7 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
@Override
protected List<GetResponse> doPoll(long durationInMillis) {
List<GetResponse> result = queues.stream()
List<GetResponse> result = queues.parallelStream()
.map(queue -> {
try {
GetResponse getResponse = channel.basicGet(queue, true);
......
......@@ -113,7 +113,7 @@ public class DeviceApiController {
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp();
try {
DeviceEntity deviceEntity = checkDeviceExist(req);
DeviceEntity deviceEntity = checkDeviceExistAndCreate(req);
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()) {
throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT);
}
......@@ -659,6 +659,18 @@ public class DeviceApiController {
}
private DeviceEntity checkDeviceExist(DeviceReq req) {
if (ObjectUtils.isEmpty(req.getDeviceCode())) {
throw new AppException(DEVICE_CODE_IS_EMPTY, DEVICE_CODE_IS_EMPTY_CONTENT);
}
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (ObjectUtils.isEmpty(deviceEntity)) {
throw new AppException(DEVICE_NOT_EXIST, DEVICE_NOT_EXIST_CONTENT);
}
return deviceEntity;
}
private DeviceEntity checkDeviceExistAndCreate(DeviceReq req) {
if (ObjectUtils.isEmpty(req.getDeviceCode())) {
throw new AppException(DEVICE_CODE_IS_EMPTY, DEVICE_CODE_IS_EMPTY_CONTENT);
}
......@@ -678,4 +690,5 @@ public class DeviceApiController {
}
return deviceEntity;
}
}
......@@ -105,4 +105,7 @@ public interface ErrorCode {
public static final int DEVICE_CONFIG_IS_EMPTY = 1008;
public static final String DEVICE_CONFIG_IS_EMPTY_CONTENT = "设备创建,请完善设备配置信息!";
public static final int DEVICE_NOT_EXIST = 1009;
public static final String DEVICE_NOT_EXIST_CONTENT = "当前设备不存在!";
}
......@@ -136,7 +136,7 @@ Content-Type: application/json
Authorization: {{authToken}}
{
"deviceCode": "B02",
"deviceCode": "B03",
"action": "upload"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment