fix(手表设备): 手表绑定时校验只能绑定本单位人员

新增单位编码前6位匹配校验,禁止跨单位绑定手表;
同时将"该设备已绑定该员工"改为"该设备已被绑定"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wanghao
2026-03-27 15:48:55 +08:00
co-authored by Claude Sonnet 4.6
parent a43806c4e9
commit 2e90ec71cc
@@ -293,8 +293,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 +332,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());