feat:看板强制登出功能
This commit is contained in:
@@ -925,16 +925,22 @@ public class HandheldServiceImpl implements HandheldService {
|
|||||||
if (StrUtil.isNotEmpty(json.getString("device_code"))) {
|
if (StrUtil.isNotEmpty(json.getString("device_code"))) {
|
||||||
Object deviceLogin = redisUtils.get("mobile:" + json.getString("device_code"));
|
Object deviceLogin = redisUtils.get("mobile:" + json.getString("device_code"));
|
||||||
if (deviceLogin != null) {
|
if (deviceLogin != null) {
|
||||||
throw new BadRequestException("当前设备工序已经登陆,无法继续选择");
|
// 检查是否需要强制登出
|
||||||
} else {
|
Boolean forceLogout = json.getBoolean("force_logout");
|
||||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
if (Boolean.TRUE.equals(forceLogout)) {
|
||||||
Param isInvokeConnector = sysParamService.findByCode(GeneralDefinition.HANDHELD_LOGIN_TIME);
|
// 强制登出,清除redis中的key
|
||||||
int loginTime = 3;
|
redisUtils.del("mobile:" + json.getString("device_code"));
|
||||||
if (ObjectUtil.isNotEmpty(isInvokeConnector)) {
|
} else {
|
||||||
loginTime = Integer.parseInt(isInvokeConnector.getValue());
|
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"));
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(json.getString("device_code"));
|
||||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||||
|
|||||||
@@ -109,8 +109,42 @@ export default {
|
|||||||
this.show = false
|
this.show = false
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
this.$router.push('/produceScreen/1')
|
this.$router.push('/produceScreen/1')
|
||||||
}).catch(() => {
|
}).catch(error => {
|
||||||
this.disabled = false
|
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(() => {
|
||||||
|
// 用户取消,不做任何操作
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user