From 49888930f9c1024157284deac7dd9a146cfe5016 Mon Sep 17 00:00:00 2001 From: xiwa Date: Thu, 1 Dec 2022 17:33:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E8=AE=BE=E5=A4=87id=E7=94=9F?= =?UTF-8?q?=E6=88=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iot-data/iot-rdb-data-service/pom.xml | 5 +++++ .../java/cc/iotkit/data/service/VirtualDeviceDataImpl.java | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/iot-data/iot-rdb-data-service/pom.xml b/iot-data/iot-rdb-data-service/pom.xml index 43199a34..b23ac2d2 100755 --- a/iot-data/iot-rdb-data-service/pom.xml +++ b/iot-data/iot-rdb-data-service/pom.xml @@ -34,6 +34,11 @@ commons-io + + cn.hutool + hutool-core + + org.mapstruct mapstruct diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java index 46f763b8..92cd4663 100755 --- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java +++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java @@ -17,6 +17,7 @@ import cc.iotkit.data.model.TbVirtualDeviceMapping; import cc.iotkit.data.model.VirtualDeviceMapper; import cc.iotkit.model.Paging; import cc.iotkit.model.device.VirtualDevice; +import cn.hutool.core.util.IdUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; @@ -26,7 +27,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.UUID; import java.util.stream.Collectors; @Primary @@ -88,7 +88,7 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { @Transactional public VirtualDevice save(VirtualDevice data) { if (StringUtils.isBlank(data.getId())) { - data.setId(UUID.randomUUID().toString()); + data.setId(IdUtil.simpleUUID()); data.setCreateAt(System.currentTimeMillis()); } virtualDeviceRepository.save(VirtualDeviceMapper.M.toVo(data)); @@ -97,7 +97,7 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { virtualDeviceMappingRepository.deleteByVirtualId(data.getId()); virtualDeviceMappingRepository.saveAllAndFlush( data.getDevices().stream().map(d -> new TbVirtualDeviceMapping( - UUID.randomUUID().toString(), + IdUtil.simpleUUID(), data.getId(), d )).collect(Collectors.toList())