设备添加初始化信息

This commit is contained in:
kerwincui
2022-06-05 13:17:46 +08:00
parent ed1401ccb8
commit ba128edd40

View File

@@ -426,13 +426,17 @@ public class DeviceServiceImpl implements IDeviceService {
device.setTenantId(sysUser.getUserId());
device.setTenantName(sysUser.getUserName());
device.setRssi(0);
// 随机经纬度
// 随机经纬度和地址
device.setNetworkIp("127.0.0.1");
if(device.getLongitude()==null || device.getLongitude().equals("")){
device.setLongitude(BigDecimal.valueOf(116.23-(Math.random()*15)));
}
if(device.getLatitude()==null || device.getLatitude().equals("")){
device.setLatitude(BigDecimal.valueOf(39.54-(Math.random()*15)));
}
if(device.getNetworkAddress()==null || device.getNetworkAddress().equals("")){
device.setNetworkAddress("中国");
}
Product product=productService.selectProductByProductId(device.getProductId());
device.setImgUrl(product.getImgUrl());
deviceMapper.insertDevice(device);