feat:看板强制登出功能

This commit is contained in:
2026-06-12 18:02:41 +08:00
parent c76b06cdcb
commit 8219355b92
2 changed files with 49 additions and 9 deletions

View File

@@ -925,16 +925,22 @@ public class HandheldServiceImpl implements HandheldService {
if (StrUtil.isNotEmpty(json.getString("device_code"))) {
Object deviceLogin = redisUtils.get("mobile:" + json.getString("device_code"));
if (deviceLogin != null) {
throw new BadRequestException("当前设备工序已经登陆,无法继续选择");
} else {
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
Param isInvokeConnector = sysParamService.findByCode(GeneralDefinition.HANDHELD_LOGIN_TIME);
int loginTime = 3;
if (ObjectUtil.isNotEmpty(isInvokeConnector)) {
loginTime = Integer.parseInt(isInvokeConnector.getValue());
// 检查是否需要强制登出
Boolean forceLogout = json.getBoolean("force_logout");
if (Boolean.TRUE.equals(forceLogout)) {
// 强制登出清除redis中的key
redisUtils.del("mobile:" + json.getString("device_code"));
} else {
throw new BadRequestException("当前设备工序已经登陆,无法继续选择");
}
redisUtils.set("mobile:" + json.getString("device_code"), json.getString("device_code"), loginTime, TimeUnit.HOURS);
}
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
Param isInvokeConnector = sysParamService.findByCode(GeneralDefinition.HANDHELD_LOGIN_TIME);
int loginTime = 3;
if (ObjectUtil.isNotEmpty(isInvokeConnector)) {
loginTime = Integer.parseInt(isInvokeConnector.getValue());
}
redisUtils.set("mobile:" + json.getString("device_code"), json.getString("device_code"), loginTime, TimeUnit.HOURS);
}
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(json.getString("device_code"));
if (ObjectUtil.isNotEmpty(schBasePoint)) {

View File

@@ -109,8 +109,42 @@ export default {
this.show = false
this.disabled = false
this.$router.push('/produceScreen/1')
}).catch(() => {
}).catch(error => {
this.disabled = false
// 尝试从多个位置获取错误信息
let errorMsg = ''
if (error.response && error.response.data) {
if (error.response.data.msg) {
errorMsg = error.response.data.msg
} else if (error.response.data.message) {
errorMsg = error.response.data.message
} else if (error.response.data.error) {
errorMsg = error.response.data.error
}
} else if (error.message) {
errorMsg = error.message
}
console.log('Extracted error message:', errorMsg)
if (errorMsg === '当前设备工序已经登陆,无法继续选择') {
this.$confirm('用户当前设备工序已经登陆,是否强制登出?', '确认操作', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
}).then(() => {
// 用户确认,强制登出并重新登录
crudProduceScreen.deviceInLogin({ device_code: this.value, force_logout: true }).then(res => {
res.username = this.username
this.$store.dispatch('addScreenData', JSON.stringify(res))
this.show = false
this.disabled = false
this.$router.push('/produceScreen/1')
}).catch(() => {
// 强制登出登录失败
})
}).catch(() => {
// 用户取消,不做任何操作
})
}
})
}
}