|
@@ -96,6 +96,9 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
private WorkKnowledgeExpertDao expertDao;
|
|
private WorkKnowledgeExpertDao expertDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private WorkKnowledgeExpertService expertService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private WorkKnowledgePointCategoryDao categoryDao;
|
|
private WorkKnowledgePointCategoryDao categoryDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -255,10 +258,17 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
|
|
|
|
|
// 判断是否为问答答疑分类
|
|
// 判断是否为问答答疑分类
|
|
|
boolean isQaCategory = false;
|
|
boolean isQaCategory = false;
|
|
|
|
|
+ boolean isTypicalCase = false; // 是否为典型案例分类
|
|
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(shareInfo.getTreeNodeId())) {
|
|
if (StringUtils.isNotBlank(shareInfo.getTreeNodeId())) {
|
|
|
WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(shareInfo.getTreeNodeId());
|
|
WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(shareInfo.getTreeNodeId());
|
|
|
- if (treeInfo != null && "问答答疑".equals(treeInfo.getTreeName())) {
|
|
|
|
|
- isQaCategory = true;
|
|
|
|
|
|
|
+ if (treeInfo != null) {
|
|
|
|
|
+ if ("问答答疑".equals(treeInfo.getTreeName())) {
|
|
|
|
|
+ isQaCategory = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("典型案例".equals(treeInfo.getTreeName())) {
|
|
|
|
|
+ isTypicalCase = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -277,6 +287,7 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
// 问答分类不需要设置submitAuditUserId和auditStartDate
|
|
// 问答分类不需要设置submitAuditUserId和auditStartDate
|
|
|
} else {
|
|
} else {
|
|
|
// ========== 非问答分类:走原有审核流程 ==========
|
|
// ========== 非问答分类:走原有审核流程 ==========
|
|
|
|
|
+ // 典型案例分类也走正常审核流程,根据有无附件判断状态
|
|
|
if (isNew) {
|
|
if (isNew) {
|
|
|
// 新增:无文件草稿0,有文件未审核 1
|
|
// 新增:无文件草稿0,有文件未审核 1
|
|
|
shareInfo.setAuditStatus(hasValidAttachment ? AUDIT_STATUS_PENDING : AUDIT_STATUS_DRAFT);
|
|
shareInfo.setAuditStatus(hasValidAttachment ? AUDIT_STATUS_PENDING : AUDIT_STATUS_DRAFT);
|
|
@@ -415,15 +426,43 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 查询treeName,判断是否需要评分
|
|
|
|
|
|
|
+ // 查询treeName,判断是否需要评分以及审核权限
|
|
|
boolean needsScore = false;
|
|
boolean needsScore = false;
|
|
|
|
|
+ boolean isTypicalCaseOriginal = false; // 典型案例(原创)
|
|
|
|
|
+ boolean isTypicalCaseReprint = false; // 典型案例(转载)
|
|
|
|
|
+
|
|
|
if (StringUtils.isNotBlank(entity.getTreeNodeId())) {
|
|
if (StringUtils.isNotBlank(entity.getTreeNodeId())) {
|
|
|
WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(entity.getTreeNodeId());
|
|
WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(entity.getTreeNodeId());
|
|
|
- if (treeInfo != null && ("技术总结".equals(treeInfo.getTreeName()) || "培训心得".equals(treeInfo.getTreeName()))) {
|
|
|
|
|
- needsScore = true;
|
|
|
|
|
- // 验证评分必填
|
|
|
|
|
- if (score == null) {
|
|
|
|
|
- throw new RuntimeException("请输入评分分数");
|
|
|
|
|
|
|
+ if (treeInfo != null) {
|
|
|
|
|
+ String treeName = treeInfo.getTreeName();
|
|
|
|
|
+
|
|
|
|
|
+ // 技术总结/培训心得:需要评分
|
|
|
|
|
+ if ("技术总结".equals(treeName) || "培训心得".equals(treeName)) {
|
|
|
|
|
+ needsScore = true;
|
|
|
|
|
+ // 验证评分必填
|
|
|
|
|
+ if (score == null) {
|
|
|
|
|
+ throw new RuntimeException("请输入评分分数");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 典型案例分类:根据contentAttribute区分
|
|
|
|
|
+ if ("典型案例".equals(treeName)) {
|
|
|
|
|
+ if ("0".equals(entity.getContentAttribute())) {
|
|
|
|
|
+ // 典型案例(原创):需要专家审核,使用评分机制
|
|
|
|
|
+ isTypicalCaseOriginal = true;
|
|
|
|
|
+ needsScore = true;
|
|
|
|
|
+ // 校验当前用户是否为专家
|
|
|
|
|
+ boolean isExpert = expertService.isUserBound(auditUserId);
|
|
|
|
|
+ if (!isExpert) {
|
|
|
|
|
+ throw new RuntimeException("典型案例(原创)只有专家可以审核");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (score == null) {
|
|
|
|
|
+ throw new RuntimeException("请输入评分分数");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if ("1".equals(entity.getContentAttribute())) {
|
|
|
|
|
+ // 典型案例(转载):所有人可审核,使用固定分值
|
|
|
|
|
+ isTypicalCaseReprint = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -451,7 +490,13 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
entity.preUpdate();
|
|
entity.preUpdate();
|
|
|
dao.updateAuditStatus(entity);
|
|
dao.updateAuditStatus(entity);
|
|
|
// 本轮审核通过:根据分类类型执行不同的积分发放逻辑
|
|
// 本轮审核通过:根据分类类型执行不同的积分发放逻辑
|
|
|
- if (needsScore) {
|
|
|
|
|
|
|
+ if (isTypicalCaseReprint) {
|
|
|
|
|
+ // 典型案例(转载):使用"典型案例(转载)"分类的固定分值
|
|
|
|
|
+ grantPointsForTypicalCaseReprint(entity, startTime);
|
|
|
|
|
+ } else if (isTypicalCaseOriginal) {
|
|
|
|
|
+ // 典型案例(原创):使用"典型案例(原创)"分类的评分平均分
|
|
|
|
|
+ grantPointsWithScoreForTypicalCaseOriginal(entity, startTime);
|
|
|
|
|
+ } else if (needsScore) {
|
|
|
// 技术总结/培训心得:使用评分平均分
|
|
// 技术总结/培训心得:使用评分平均分
|
|
|
grantPointsWithScore(entity, startTime);
|
|
grantPointsWithScore(entity, startTime);
|
|
|
} else {
|
|
} else {
|
|
@@ -584,6 +629,24 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
String currentUserId = UserUtils.getUser().getId();
|
|
String currentUserId = UserUtils.getUser().getId();
|
|
|
// 提交审核人不可审核自己的文件
|
|
// 提交审核人不可审核自己的文件
|
|
|
if (currentUserId.equals(entity.getSubmitAuditUserId())) return false;
|
|
if (currentUserId.equals(entity.getSubmitAuditUserId())) return false;
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否为典型案例(原创),只有专家可以审核
|
|
|
|
|
+ boolean isTypicalCaseOriginal = false;
|
|
|
|
|
+ if (StringUtils.isNotBlank(entity.getTreeNodeId())) {
|
|
|
|
|
+ WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(entity.getTreeNodeId());
|
|
|
|
|
+ if (treeInfo != null && "典型案例".equals(treeInfo.getTreeName()) && "0".equals(entity.getContentAttribute())) {
|
|
|
|
|
+ isTypicalCaseOriginal = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 典型案例(原创):只有专家可以审核
|
|
|
|
|
+ if (isTypicalCaseOriginal) {
|
|
|
|
|
+ boolean isExpert = expertService.isUserBound(currentUserId);
|
|
|
|
|
+ if (!isExpert) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 本轮未审核过的用户可审核(按 audit_start_date 隔离历史记录)
|
|
// 本轮未审核过的用户可审核(按 audit_start_date 隔离历史记录)
|
|
|
return auditRecordDao.countByFileIdAndUserIdSinceTime(entity.getId(), currentUserId, entity.getAuditStartDate()) == 0;
|
|
return auditRecordDao.countByFileIdAndUserIdSinceTime(entity.getId(), currentUserId, entity.getAuditStartDate()) == 0;
|
|
|
}
|
|
}
|
|
@@ -688,6 +751,75 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 典型案例(原创)分类的积分发放逻辑:创建人获得评分平均分,审核人获得固定审核积分
|
|
|
|
|
+ * 使用“典型案例(原创)”分类对应的积分规则
|
|
|
|
|
+ */
|
|
|
|
|
+ private void grantPointsWithScoreForTypicalCaseOriginal(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
|
|
+ if (entity == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String shareId = entity.getId();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询“典型案例(原创)”分类对应的积分规则
|
|
|
|
|
+ List<WorkKnowledgePointCategory> categories = findCategoriesByName("典型案例(原创)");
|
|
|
|
|
+ if (categories == null || categories.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String categoryId = categories.get(0).getId();
|
|
|
|
|
+ // 查询该分类下rule_type=1(创建积分)的规则
|
|
|
|
|
+ WorkKnowledgeBasePointRule createRule = pointRuleDao.findByCategoryIdAndRuleType(categoryId, "1");
|
|
|
|
|
+ // 查询该分类下rule_type=2(审核积分)的规则
|
|
|
|
|
+ WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByCategoryIdAndRuleType(categoryId, "2");
|
|
|
|
|
+
|
|
|
|
|
+ // 计算专家评分的平均分(仅用于创建人)
|
|
|
|
|
+ Integer averageScore = null;
|
|
|
|
|
+ List<WorkKnowledgeBaseAuditRecord> records = auditRecordDao.findByFileIdSinceTime(shareId, startTime);
|
|
|
|
|
+ if (records != null && !records.isEmpty()) {
|
|
|
|
|
+ int totalScore = 0;
|
|
|
|
|
+ int scoreCount = 0;
|
|
|
|
|
+ for (WorkKnowledgeBaseAuditRecord record : records) {
|
|
|
|
|
+ if (record.getAuditResult() != null && record.getAuditResult() == 1
|
|
|
|
|
+ && record.getScore() != null) {
|
|
|
|
|
+ totalScore += record.getScore();
|
|
|
|
|
+ scoreCount++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (scoreCount > 0) {
|
|
|
|
|
+ averageScore = Math.round((float) totalScore / scoreCount);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 1、提交审核人获得创建积分(使用平均分)
|
|
|
|
|
+ String submitUserId = entity.getSubmitAuditUserId();
|
|
|
|
|
+ if (StringUtils.isNotBlank(submitUserId) && averageScore != null && createRule != null) {
|
|
|
|
|
+ insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, categoryId, createRule.getId(), averageScore);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2、本轮审核人各获得审核积分(使用固定审核积分值)
|
|
|
|
|
+ if (records == null || records.isEmpty() || auditRule == null || StringUtils.isBlank(auditRule.getPointValue())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer auditPointValue = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ auditPointValue = Integer.parseInt(auditRule.getPointValue());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (auditPointValue <= 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<String> grantedUserIds = new HashSet<>();
|
|
|
|
|
+ for (WorkKnowledgeBaseAuditRecord record : records) {
|
|
|
|
|
+ if (record.getAuditResult() != null && record.getAuditResult() == 1
|
|
|
|
|
+ && StringUtils.isNotBlank(record.getAuditUserId())
|
|
|
|
|
+ && grantedUserIds.add(record.getAuditUserId())) {
|
|
|
|
|
+ insertPointDetail(record.getAuditUserId(), shareId, POINT_CHANGE_AUDIT, categoryId, auditRule.getId(), auditPointValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 其他分类的积分发放逻辑:使用固定积分值
|
|
* 其他分类的积分发放逻辑:使用固定积分值
|
|
@@ -744,6 +876,68 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 典型案例(转载)分类的积分发放逻辑:使用固定分值,所有人可审核
|
|
|
|
|
+ */
|
|
|
|
|
+ private void grantPointsForTypicalCaseReprint(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
|
|
+ if (entity == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String shareId = entity.getId();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询“典型案例(转载)”分类对应的积分规则
|
|
|
|
|
+ List<WorkKnowledgePointCategory> categories = findCategoriesByName("典型案例(转载)");
|
|
|
|
|
+ if (categories == null || categories.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String categoryId = categories.get(0).getId();
|
|
|
|
|
+ // 查询该分类下rule_type=1(创建积分)的规则
|
|
|
|
|
+ WorkKnowledgeBasePointRule createRule = pointRuleDao.findByCategoryIdAndRuleType(categoryId, "1");
|
|
|
|
|
+ // 查询该分类下rule_type=2(审核积分)的规则
|
|
|
|
|
+ WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByCategoryIdAndRuleType(categoryId, "2");
|
|
|
|
|
+
|
|
|
|
|
+ // 1、提交审核人获得创建积分(使用固定值)
|
|
|
|
|
+ String submitUserId = entity.getSubmitAuditUserId();
|
|
|
|
|
+ if (StringUtils.isNotBlank(submitUserId) && createRule != null && StringUtils.isNotBlank(createRule.getPointValue())) {
|
|
|
|
|
+ Integer createPoint = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ createPoint = Integer.parseInt(createRule.getPointValue());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ createPoint = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (createPoint != null && createPoint > 0) {
|
|
|
|
|
+ insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, categoryId, createRule.getId(), createPoint);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2、本轮三位审核人各获得审核积分(使用固定值)
|
|
|
|
|
+ if (auditRule == null || StringUtils.isBlank(auditRule.getPointValue())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer auditPointValue = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ auditPointValue = Integer.parseInt(auditRule.getPointValue());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (auditPointValue <= 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<WorkKnowledgeBaseAuditRecord> records = auditRecordDao.findByFileIdSinceTime(shareId, startTime);
|
|
|
|
|
+ if (records == null || records.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<String> grantedUserIds = new HashSet<>();
|
|
|
|
|
+ for (WorkKnowledgeBaseAuditRecord record : records) {
|
|
|
|
|
+ if (record.getAuditResult() != null && record.getAuditResult() == 1
|
|
|
|
|
+ && StringUtils.isNotBlank(record.getAuditUserId())
|
|
|
|
|
+ && grantedUserIds.add(record.getAuditUserId())) {
|
|
|
|
|
+ insertPointDetail(record.getAuditUserId(), shareId, POINT_CHANGE_AUDIT, categoryId, auditRule.getId(), auditPointValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 插入一条积分明细记录
|
|
* 插入一条积分明细记录
|
|
|
*/
|
|
*/
|
|
|
private void insertPointDetail(String userId, String shareId, Integer changeType, String categoryId, String ruleId, Integer point) {
|
|
private void insertPointDetail(String userId, String shareId, Integer changeType, String categoryId, String ruleId, Integer point) {
|