手表绑定增加只能绑定本单位验证

This commit is contained in:
wanghao
2026-03-27 10:58:40 +08:00
parent 7aa25f5f3a
commit fc347944a0
@@ -151,7 +151,6 @@ public class WatchDeviceServiceImpl extends ServiceImpl<WatchDeviceMapper, Watch
private AsyncTaskExecutor asyncTaskExecutor; private AsyncTaskExecutor asyncTaskExecutor;
private RequestAttributes requestAttributes = null; private RequestAttributes requestAttributes = null;
private final ToolExportHandler toolExportHandler = new ToolExportHandler(); private final ToolExportHandler toolExportHandler = new ToolExportHandler();
@Autowired @Autowired
@@ -293,8 +292,18 @@ public class WatchDeviceServiceImpl extends ServiceImpl<WatchDeviceMapper, Watch
if (watchDevice == null) { if (watchDevice == null) {
return Result.error("该监测工具不存在"); return Result.error("该监测工具不存在");
} }
// 新增手表只能绑定给本单位的人
LoginUser userById = sysBaseAPI.getUserById(dto.getBindUserId());
if (userById.getOrgCode() == null || dto.getOrgCode() == null ||
userById.getOrgCode().length() < 6 || dto.getOrgCode().length() < 6 ||
!userById.getOrgCode().substring(0, 6).equals(dto.getOrgCode().substring(0, 6))) {
return Result.error("手表只能绑定给本单位人员");
}
if (isDeviceAlreadyBound(watchDevice, dto)) { if (isDeviceAlreadyBound(watchDevice, dto)) {
return Result.error("该设备已绑定该员工"); return Result.error("该设备已绑定");
} }
// 查询员工是否有绑定 // 查询员工是否有绑定
List<WatchDevice> deviceByUserIdList = getDeviceByUserId(dto.getBindUserId()); List<WatchDevice> deviceByUserIdList = getDeviceByUserId(dto.getBindUserId());
@@ -322,7 +331,6 @@ public class WatchDeviceServiceImpl extends ServiceImpl<WatchDeviceMapper, Watch
// 初始化开关数据 // 初始化开关数据
unbindUserAndInitDeviceSwitch(dto); unbindUserAndInitDeviceSwitch(dto);
} }
LoginUser userById = sysBaseAPI.getUserById(dto.getBindUserId());
// 此处修改 只有是职工的是才赋值单位信息 // 此处修改 只有是职工的是才赋值单位信息
if (dto.getIsEmployee()) { if (dto.getIsEmployee()) {
SysDepart inDepart = sysCache.getDepartByOrgCode(userById.getOrgCode()); SysDepart inDepart = sysCache.getDepartByOrgCode(userById.getOrgCode());