Commit f3b25e48 by gdj

优化新增机场,同时新增飞机。

parent a73a94fa
......@@ -758,7 +758,7 @@ public class DeviceServiceImpl implements IDeviceService {
// sn码不重复
List<DeviceEntity> dbDroneList = mapper.selectList(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, droneDeviceSn));
if (!CollectionUtils.isEmpty(dbDroneList)) {
throw new RuntimeException("deviceSn is already exit");
throw new RuntimeException("droneSn is already exit");
}
}
......@@ -816,7 +816,7 @@ public class DeviceServiceImpl implements IDeviceService {
List<DeviceEntity> snList = this.mapper.selectList(deviceSnQueryWrapper);
if (!CollectionUtils.isEmpty(snList)) {
throw new RuntimeException("deviceSn is already exit");
throw new RuntimeException("droneSn is already exit");
}
updateEntity.setDeviceSn(drone.getDeviceSn());
......@@ -861,7 +861,7 @@ public class DeviceServiceImpl implements IDeviceService {
// sn码不重复
List<DeviceEntity> dbDeviceList = mapper.selectList(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, dockSn));
if (!CollectionUtils.isEmpty(dbDeviceList)) {
throw new RuntimeException("deviceSn is already exit");
throw new RuntimeException("dockSn is already exit");
}
}
......@@ -876,6 +876,43 @@ public class DeviceServiceImpl implements IDeviceService {
// 飞机绑定了其他设备
// 飞机不存在? 新建飞机?
if (drone == null) {
DeviceEntity newDrone = new DeviceEntity();
newDrone.setDeviceSn(droneSn);
newDrone.setWorkspaceId(dock.getWorkspaceId());
// 飞机型号
DeviceDTO children = dock.getChildren();
// 飞机名称
newDrone.setNickname(children.getNickname());
newDrone.setDeviceName(children.getDeviceName());
newDrone.setDomain(children.getDomain().getDomain());
newDrone.setDeviceType(children.getType().getType());
newDrone.setSubType(children.getSubType().getSubType());
newDrone.setCreateTime(System.currentTimeMillis());
newDrone.setUpdateTime(System.currentTimeMillis());
newDrone.setBoundStatus(true);
newDrone.setBoundTime(System.currentTimeMillis());
int droneInsert = mapper.insert(newDrone);
} else {
// 飞机存在
if (StringUtils.hasText(drone.getWorkspaceId())) {
throw new RuntimeException("The current drone has been bound");
}
// 绑定无人机
LambdaUpdateWrapper<DeviceEntity> updateDroneWrapper = new LambdaUpdateWrapper<>();
updateDroneWrapper.set(DeviceEntity::getWorkspaceId, dock.getWorkspaceId());
updateDroneWrapper.eq(DeviceEntity::getDeviceSn, droneSn);
int updateDroneInt = mapper.update(new DeviceEntity(), updateDroneWrapper);
}
}
addDockEntity.setWorkspaceId(dock.getWorkspaceId());
......@@ -905,6 +942,8 @@ public class DeviceServiceImpl implements IDeviceService {
// bound_time bigint
// bound_status The status when the device is bound to the workspace. 1: bound; 0: not bound;
addDockEntity.setBoundStatus(true);
addDockEntity.setBoundTime(System.currentTimeMillis());
// device_desc
// url_normal The icon displayed on the remote control.
// url_select The icon displayed on the remote control when it is selected.
......@@ -936,7 +975,7 @@ public class DeviceServiceImpl implements IDeviceService {
List<DeviceEntity> snList = this.mapper.selectList(deviceSnQueryWrapper);
if (!CollectionUtils.isEmpty(snList)) {
throw new RuntimeException("deviceSn is already exit");
throw new RuntimeException("dockSn is already exit");
}
updateEntity.setDeviceSn(dock.getDeviceSn());
......
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