虚拟设备id生成修改
parent
f676fbb5ed
commit
49888930f9
|
@ -34,6 +34,11 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct</artifactId>
|
<artifactId>mapstruct</artifactId>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import cc.iotkit.data.model.TbVirtualDeviceMapping;
|
||||||
import cc.iotkit.data.model.VirtualDeviceMapper;
|
import cc.iotkit.data.model.VirtualDeviceMapper;
|
||||||
import cc.iotkit.model.Paging;
|
import cc.iotkit.model.Paging;
|
||||||
import cc.iotkit.model.device.VirtualDevice;
|
import cc.iotkit.model.device.VirtualDevice;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
@ -26,7 +27,6 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Primary
|
@Primary
|
||||||
|
@ -88,7 +88,7 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData {
|
||||||
@Transactional
|
@Transactional
|
||||||
public VirtualDevice save(VirtualDevice data) {
|
public VirtualDevice save(VirtualDevice data) {
|
||||||
if (StringUtils.isBlank(data.getId())) {
|
if (StringUtils.isBlank(data.getId())) {
|
||||||
data.setId(UUID.randomUUID().toString());
|
data.setId(IdUtil.simpleUUID());
|
||||||
data.setCreateAt(System.currentTimeMillis());
|
data.setCreateAt(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
virtualDeviceRepository.save(VirtualDeviceMapper.M.toVo(data));
|
virtualDeviceRepository.save(VirtualDeviceMapper.M.toVo(data));
|
||||||
|
@ -97,7 +97,7 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData {
|
||||||
virtualDeviceMappingRepository.deleteByVirtualId(data.getId());
|
virtualDeviceMappingRepository.deleteByVirtualId(data.getId());
|
||||||
virtualDeviceMappingRepository.saveAllAndFlush(
|
virtualDeviceMappingRepository.saveAllAndFlush(
|
||||||
data.getDevices().stream().map(d -> new TbVirtualDeviceMapping(
|
data.getDevices().stream().map(d -> new TbVirtualDeviceMapping(
|
||||||
UUID.randomUUID().toString(),
|
IdUtil.simpleUUID(),
|
||||||
data.getId(),
|
data.getId(),
|
||||||
d
|
d
|
||||||
)).collect(Collectors.toList())
|
)).collect(Collectors.toList())
|
||||||
|
|
Loading…
Reference in New Issue