Commit 071631c8 by gdj

fix dock add method

parent 3ee33604
...@@ -1137,12 +1137,51 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity> ...@@ -1137,12 +1137,51 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
String dockSn = dock.getDeviceSn(); String dockSn = dock.getDeviceSn();
boolean isUpdateDock = false;
if (StringUtils.hasText(dockSn)) { if (StringUtils.hasText(dockSn)) {
// sn码不重复 // sn码不重复
List<DeviceEntity> dbDeviceList = mapper.selectList(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, dockSn)); List<DeviceEntity> dbDockList = mapper.selectList(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn, dockSn));
if (!CollectionUtils.isEmpty(dbDeviceList)) { if (!CollectionUtils.isEmpty(dbDockList)) {
if (dbDockList.size() != 1) {
throw new RuntimeException("dockSn is already exit"); throw new RuntimeException("dockSn is already exit");
} }
DeviceEntity dbDock = dbDockList.get(0);
if (StringUtils.hasText(dbDock.getWorkspaceId())) {
throw new RuntimeException("dockSn is already exit");
}
// 修改当前机场数据
DeviceEntity updateDock = new DeviceEntity();
updateDock.setId(dbDock.getId());
updateDock.setWorkspaceId(dock.getWorkspaceId());
updateDock.setOrgId(StringUtils.hasText(dock.getOrgId()) ? dock.getOrgId() : getOrgId());
updateDock.setNickname(dock.getNickname());
// 类型
updateDock.setDomain(dock.getDomain().getDomain());
updateDock.setDeviceType(dock.getType().getType());
updateDock.setSubType(dock.getSubType().getSubType());
updateDock.setBoundStatus(true);
updateDock.setBoundTime(System.currentTimeMillis());
boolean updateById = this.updateById(updateDock);
// 增加 机场和团队的关联关系
DeviceOrgEntity deviceOrgEntity = new DeviceOrgEntity();
deviceOrgEntity.setWorkspaceId(updateDock.getWorkspaceId());
deviceOrgEntity.setOrgId(StringUtils.hasText(dock.getOrgId()) ? dock.getOrgId() : getOrgId());
deviceOrgEntity.setDeviceSn(updateDock.getDeviceSn());
deviceOrgEntity.setDeviceId(dbDock.getId());
deviceOrgEntity.setIsShared(0);
deviceOrgEntity.setCreatorId(getUserId());
deviceOrgEntity.setCreatorName(getUsername());
deviceOrgEntity.setCreateTime(System.currentTimeMillis());
deviceOrgEntity.setUpdaterId(getUserId());
deviceOrgEntity.setUpdaterName(getUsername());
deviceOrgEntity.setUpdateTime(System.currentTimeMillis());
boolean deviceOrgSaveRes = deviceOrgService.save(deviceOrgEntity);
isUpdateDock = true;
}
} }
// 机场还需要绑定 飞机 // 机场还需要绑定 飞机
...@@ -1238,6 +1277,9 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity> ...@@ -1238,6 +1277,9 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
} }
} }
if (isUpdateDock) {
return true;
}
addDockEntity.setWorkspaceId(dock.getWorkspaceId()); addDockEntity.setWorkspaceId(dock.getWorkspaceId());
addDockEntity.setOrgId(StringUtils.hasText(dock.getOrgId()) ? dock.getOrgId() : getOrgId()); addDockEntity.setOrgId(StringUtils.hasText(dock.getOrgId()) ? dock.getOrgId() : getOrgId());
// 机场sn // 机场sn
......
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