更新权限管理和问卷相关功能
This commit is contained in:
parent
b2dad013ab
commit
e1a5e76be6
|
|
@ -558,6 +558,7 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
|
||||
/**
|
||||
* 计算单选题得分
|
||||
* 对于问卷,直接使用选项的分值,不检查是否是正确答案
|
||||
*/
|
||||
private BigDecimal calculateRadioScore(PsyQuestionnaireAnswerDetail detail, Set<Long> correctOptionIds,
|
||||
BigDecimal itemScore, List<PsyQuestionnaireOption> allOptions)
|
||||
|
|
@ -567,9 +568,6 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 如果选中的是正确答案,得满分
|
||||
if (correctOptionIds.contains(detail.getOptionId()))
|
||||
{
|
||||
// 查找选中选项的分值
|
||||
PsyQuestionnaireOption selectedOption = allOptions.stream()
|
||||
.filter(opt -> opt.getOptionId().equals(detail.getOptionId()))
|
||||
|
|
@ -578,8 +576,13 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
|
||||
if (selectedOption != null && selectedOption.getOptionScore() != null)
|
||||
{
|
||||
// 直接返回选项的分值
|
||||
return selectedOption.getOptionScore();
|
||||
}
|
||||
|
||||
// 如果选项没有设置分值,检查是否是正确答案
|
||||
if (correctOptionIds.contains(detail.getOptionId()))
|
||||
{
|
||||
return itemScore;
|
||||
}
|
||||
|
||||
|
|
@ -657,6 +660,7 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
|
||||
/**
|
||||
* 计算判断题得分
|
||||
* 对于问卷,直接使用选项的分值,不检查是否是正确答案
|
||||
*/
|
||||
private BigDecimal calculateBooleanScore(PsyQuestionnaireAnswerDetail detail, Set<Long> correctOptionIds,
|
||||
BigDecimal itemScore, List<PsyQuestionnaireOption> allOptions)
|
||||
|
|
@ -666,9 +670,6 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 如果选中的是正确答案,得满分
|
||||
if (correctOptionIds.contains(detail.getOptionId()))
|
||||
{
|
||||
// 查找选中选项的分值
|
||||
PsyQuestionnaireOption selectedOption = allOptions.stream()
|
||||
.filter(opt -> opt.getOptionId().equals(detail.getOptionId()))
|
||||
|
|
@ -677,8 +678,13 @@ public class PsyQuestionnaireAnswerServiceImpl implements IPsyQuestionnaireAnswe
|
|||
|
||||
if (selectedOption != null && selectedOption.getOptionScore() != null)
|
||||
{
|
||||
// 直接返回选项的分值
|
||||
return selectedOption.getOptionScore();
|
||||
}
|
||||
|
||||
// 如果选项没有设置分值,检查是否是正确答案
|
||||
if (correctOptionIds.contains(detail.getOptionId()))
|
||||
{
|
||||
return itemScore;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import com.ddnai.system.service.psychology.IPsyWarningRuleService;
|
|||
import com.ddnai.system.service.psychology.IPsyWarningService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 危机预警 服务层实现
|
||||
|
|
@ -28,6 +30,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
@Service
|
||||
public class PsyWarningServiceImpl implements IPsyWarningService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PsyWarningServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private PsyWarningMapper warningMapper;
|
||||
|
||||
|
|
@ -122,8 +126,10 @@ public class PsyWarningServiceImpl implements IPsyWarningService
|
|||
List<PsyWarningRule> rules = warningRuleService.selectEnabledWarningRuleListByScaleId(assessment.getScaleId());
|
||||
if (rules == null || rules.isEmpty())
|
||||
{
|
||||
log.warn("没有找到启用的预警规则 - 测评ID: {}, 量表ID: {}", assessmentId, assessment.getScaleId());
|
||||
return 0; // 没有预警规则,不创建预警
|
||||
}
|
||||
log.info("找到启用的预警规则 - 测评ID: {}, 量表ID: {}, 规则数量: {}", assessmentId, assessment.getScaleId(), rules.size());
|
||||
|
||||
// 4. 先检查并自动解除该用户的旧预警(基于新的测评分数)
|
||||
checkAndAutoRelieveWarnings(assessment, factorScores, rules);
|
||||
|
|
@ -169,27 +175,49 @@ public class PsyWarningServiceImpl implements IPsyWarningService
|
|||
BigDecimal totalScore = assessment.getTotalScore();
|
||||
if (totalScore != null)
|
||||
{
|
||||
log.info("检查总分预警 - 测评ID: {}, 总分: {}, 规则数量: {}", assessmentId, totalScore, rules.size());
|
||||
for (PsyWarningRule rule : rules)
|
||||
{
|
||||
// 只处理总分配置(factorId为null的规则)
|
||||
if (rule.getFactorId() != null)
|
||||
{
|
||||
log.debug("跳过因子规则 - 规则ID: {}, 因子ID: {}", rule.getRuleId(), rule.getFactorId());
|
||||
continue; // 跳过因子规则
|
||||
}
|
||||
|
||||
log.info("检查总分规则 - 规则ID: {}, 规则名称: {}, 分值范围: {} - {}",
|
||||
rule.getRuleId(), rule.getRuleName(), rule.getScoreMin(), rule.getScoreMax());
|
||||
|
||||
// 检查分值范围
|
||||
if (matchScoreRule(totalScore, null, rule))
|
||||
boolean matched = matchScoreRule(totalScore, null, rule);
|
||||
log.info("分值匹配结果 - 规则ID: {}, 总分: {}, 匹配: {}", rule.getRuleId(), totalScore, matched);
|
||||
|
||||
if (matched)
|
||||
{
|
||||
PsyWarning warning = createWarning(assessment, rule, totalScore, null);
|
||||
if (warning != null)
|
||||
{
|
||||
insertWarning(warning);
|
||||
int insertResult = insertWarning(warning);
|
||||
if (insertResult > 0)
|
||||
{
|
||||
warningCount++;
|
||||
log.info("创建预警成功 - 预警ID: {}, 规则ID: {}, 总分: {}",
|
||||
warning.getWarningId(), rule.getRuleId(), totalScore);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.error("创建预警失败 - 规则ID: {}, 总分: {}", rule.getRuleId(), totalScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("测评总分为空,无法检查总分预警 - 测评ID: {}", assessmentId);
|
||||
}
|
||||
|
||||
log.info("预警检查完成 - 测评ID: {}, 创建预警数量: {}", assessmentId, warningCount);
|
||||
return warningCount;
|
||||
}
|
||||
|
||||
|
|
@ -233,8 +261,8 @@ public class PsyWarningServiceImpl implements IPsyWarningService
|
|||
percentileMatch = percentile.compareTo(rule.getPercentileMax()) <= 0;
|
||||
}
|
||||
|
||||
// 如果规则设置了百分位,优先使用百分位;否则使用分值
|
||||
if (rule.getPercentileMin() != null || rule.getPercentileMax() != null)
|
||||
// 如果规则设置了百分位且提供了百分位值,优先使用百分位;否则使用分值
|
||||
if (percentile != null && (rule.getPercentileMin() != null || rule.getPercentileMax() != null))
|
||||
{
|
||||
return percentileMatch;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,4 +176,3 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
<el-option
|
||||
v-for="user in userList"
|
||||
:key="user.userId"
|
||||
:label="user.userName"
|
||||
:value="user.userId">
|
||||
:label="user.nickName ? `${user.nickName}(${user.userName})` : user.userName"
|
||||
:value="Number(user.userId)">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
|
@ -101,8 +101,8 @@
|
|||
<el-option
|
||||
v-for="user in userList"
|
||||
:key="user.userId"
|
||||
:label="user.userName"
|
||||
:value="user.userId">
|
||||
:label="user.nickName ? `${user.nickName}(${user.userName})` : user.userName"
|
||||
:value="Number(user.userId)">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
|
@ -220,8 +220,11 @@ export default {
|
|||
},
|
||||
/** 加载用户列表 */
|
||||
loadUsers() {
|
||||
listUser({ status: '0' }).then(response => {
|
||||
this.userList = response.rows || [];
|
||||
listUser({ status: '0', pageNum: 1, pageSize: 1000 }).then(response => {
|
||||
this.userList = (response.rows || []).map(user => ({
|
||||
...user,
|
||||
userId: Number(user.userId) // 确保userId是数字类型
|
||||
}));
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
|
|
@ -272,7 +275,13 @@ export default {
|
|||
this.reset();
|
||||
const permissionId = row.permissionId || this.ids[0];
|
||||
getPermission(permissionId).then(response => {
|
||||
this.form = response.data;
|
||||
const data = response.data || {};
|
||||
// 确保userId类型正确(转换为数字或undefined)
|
||||
this.form = {
|
||||
...data,
|
||||
userId: data.userId ? Number(data.userId) : undefined,
|
||||
scaleId: data.scaleId ? Number(data.scaleId) : undefined
|
||||
};
|
||||
this.open = true;
|
||||
this.title = "修改量表权限";
|
||||
});
|
||||
|
|
@ -281,14 +290,21 @@ export default {
|
|||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
// 准备提交数据,确保类型正确
|
||||
const submitData = {
|
||||
...this.form,
|
||||
userId: this.form.userId ? Number(this.form.userId) : null,
|
||||
scaleId: this.form.scaleId ? Number(this.form.scaleId) : undefined
|
||||
};
|
||||
|
||||
if (this.form.permissionId != undefined) {
|
||||
updatePermission(this.form).then(response => {
|
||||
updatePermission(submitData).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addPermission(this.form).then(response => {
|
||||
addPermission(submitData).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user