|
@@ -88,6 +88,9 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WorkKnowledgeExpertDao expertDao;
|
|
private WorkKnowledgeExpertDao expertDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgePointCategoryDao categoryDao;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据文件id加载附件列表(编辑表单回显用)
|
|
* 根据文件id加载附件列表(编辑表单回显用)
|
|
|
*/
|
|
*/
|
|
@@ -139,6 +142,19 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 根据分类名称查询分类列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgePointCategory> findCategoriesByName(String categoryName) {
|
|
|
|
|
+ if (StringUtils.isBlank(categoryName)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgePointCategory query =
|
|
|
|
|
+ new com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgePointCategory();
|
|
|
|
|
+ query.setCategoryName(categoryName);
|
|
|
|
|
+ return categoryDao.findList(query);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 动态列表分页查询(核心方法)
|
|
* 动态列表分页查询(核心方法)
|
|
|
* 使用 CASE WHEN + MAX + GROUP BY 行转列
|
|
* 使用 CASE WHEN + MAX + GROUP BY 行转列
|
|
|
* 动态字段查询条件使用 EXISTS 子查询
|
|
* 动态字段查询条件使用 EXISTS 子查询
|
|
@@ -345,7 +361,7 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
* 规则:本轮三人通过即成功(仅统计 audit_start_date 之后的记录,隔离历史数据)
|
|
* 规则:本轮三人通过即成功(仅统计 audit_start_date 之后的记录,隔离历史数据)
|
|
|
*/
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
@Transactional(readOnly = false)
|
|
|
- public void auditPass(String fileId, String auditUserId, String auditOpinion) {
|
|
|
|
|
|
|
+ public void auditPass(String fileId, String auditUserId, String auditOpinion, Integer score) {
|
|
|
WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
|
throw new RuntimeException("文件记录不存在");
|
|
throw new RuntimeException("文件记录不存在");
|
|
@@ -362,12 +378,27 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
if (auditRecordDao.countByFileIdAndUserIdSinceTime(fileId, auditUserId, startTime) > 0) {
|
|
if (auditRecordDao.countByFileIdAndUserIdSinceTime(fileId, auditUserId, startTime) > 0) {
|
|
|
throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 查询treeName,判断是否需要评分
|
|
|
|
|
+ boolean needsScore = false;
|
|
|
|
|
+ if (StringUtils.isNotBlank(entity.getTreeNodeId())) {
|
|
|
|
|
+ WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(entity.getTreeNodeId());
|
|
|
|
|
+ if (treeInfo != null && ("技术总结".equals(treeInfo.getTreeName()) || "培训心得".equals(treeInfo.getTreeName()))) {
|
|
|
|
|
+ needsScore = true;
|
|
|
|
|
+ // 验证评分必填
|
|
|
|
|
+ if (score == null) {
|
|
|
|
|
+ throw new RuntimeException("请输入评分分数");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 保存审核记录
|
|
// 保存审核记录
|
|
|
WorkKnowledgeBaseAuditRecord record = new WorkKnowledgeBaseAuditRecord();
|
|
WorkKnowledgeBaseAuditRecord record = new WorkKnowledgeBaseAuditRecord();
|
|
|
record.setFileId(fileId);
|
|
record.setFileId(fileId);
|
|
|
record.setAuditUserId(auditUserId);
|
|
record.setAuditUserId(auditUserId);
|
|
|
record.setAuditResult(1); // 1:通过
|
|
record.setAuditResult(1); // 1:通过
|
|
|
record.setAuditOpinion(auditOpinion);
|
|
record.setAuditOpinion(auditOpinion);
|
|
|
|
|
+ record.setScore(score); // 设置评分分数
|
|
|
record.setId(IdGen.uuid());
|
|
record.setId(IdGen.uuid());
|
|
|
record.setAuditTime(new java.util.Date());
|
|
record.setAuditTime(new java.util.Date());
|
|
|
record.preInsert();
|
|
record.preInsert();
|
|
@@ -383,8 +414,14 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
entity.setAuditStatus(AUDIT_STATUS_PASSED);
|
|
entity.setAuditStatus(AUDIT_STATUS_PASSED);
|
|
|
entity.preUpdate();
|
|
entity.preUpdate();
|
|
|
dao.updateAuditStatus(entity);
|
|
dao.updateAuditStatus(entity);
|
|
|
- // 本轮审核通过:为提交审核人及本轮三位审核人写入积分明细
|
|
|
|
|
- grantPointsOnAuditPassed(entity, startTime);
|
|
|
|
|
|
|
+ // 本轮审核通过:根据分类类型执行不同的积分发放逻辑
|
|
|
|
|
+ if (needsScore) {
|
|
|
|
|
+ // 技术总结/培训心得:使用评分平均分
|
|
|
|
|
+ grantPointsWithScore(entity, startTime);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他分类:使用固定积分值
|
|
|
|
|
+ grantPointsWithFixedValue(entity, startTime);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
entity.setAuditStatus(AUDIT_STATUS_AUDITING);
|
|
entity.setAuditStatus(AUDIT_STATUS_AUDITING);
|
|
|
entity.preUpdate();
|
|
entity.preUpdate();
|
|
@@ -537,14 +574,88 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
* 本轮审核通过后发放积分:
|
|
* 本轮审核通过后发放积分:
|
|
|
* 1、为提交审核人(submit_audit_user_id)发放创建积分(change_type=1)
|
|
* 1、为提交审核人(submit_audit_user_id)发放创建积分(change_type=1)
|
|
|
* 2、为本轮三位审核人(audit_time >= audit_start_date 且 audit_result=1)各发放审核积分(change_type=2)
|
|
* 2、为本轮三位审核人(audit_time >= audit_start_date 且 audit_result=1)各发放审核积分(change_type=2)
|
|
|
|
|
+ * 3、如果是技术总结/培训心得分类,使用三人评分的平均值作为积分值
|
|
|
* 积分值读取 work_knowledge_base_point_rule 中对应 status=1 的启用规则
|
|
* 积分值读取 work_knowledge_base_point_rule 中对应 status=1 的启用规则
|
|
|
*/
|
|
*/
|
|
|
- private void grantPointsOnAuditPassed(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 技术总结/培训心得分类的积分发放逻辑:创建人获得平均分,审核人获得固定审核积分
|
|
|
|
|
+ */
|
|
|
|
|
+ private void grantPointsWithScore(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
|
|
+ if (entity == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String shareId = entity.getId();
|
|
|
|
|
+
|
|
|
|
|
+ // 计算三人评分的平均分(仅用于创建人)
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, averageScore);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2、查询该分类对应的审核积分规则(rule_type=2)
|
|
|
|
|
+ Integer auditPointValue = null;
|
|
|
|
|
+ if (StringUtils.isNotBlank(entity.getTreeNodeId())) {
|
|
|
|
|
+ WorkKnowledgeBaseTreeInfo treeInfo = getTreeInfoById(entity.getTreeNodeId());
|
|
|
|
|
+ if (treeInfo != null) {
|
|
|
|
|
+ // 根据treeName查询分类表获取categoryId
|
|
|
|
|
+ List<WorkKnowledgePointCategory> categories = findCategoriesByName(treeInfo.getTreeName());
|
|
|
|
|
+ if (categories != null && !categories.isEmpty()) {
|
|
|
|
|
+ String categoryId = categories.get(0).getId();
|
|
|
|
|
+ // 查询该分类下rule_type=2(审核积分)的规则
|
|
|
|
|
+ WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByCategoryIdAndRuleType(categoryId, "2");
|
|
|
|
|
+ if (auditRule != null && StringUtils.isNotBlank(auditRule.getPointValue())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ auditPointValue = Integer.parseInt(auditRule.getPointValue());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ // 忽略无效值
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3、本轮三位审核人各获得审核积分(使用固定审核积分值)
|
|
|
|
|
+ if (records == null || records.isEmpty() || auditPointValue == null || 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, auditPointValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 其他分类的积分发放逻辑:使用固定积分值
|
|
|
|
|
+ */
|
|
|
|
|
+ private void grantPointsWithFixedValue(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
String shareId = entity.getId();
|
|
String shareId = entity.getId();
|
|
|
- // 1、提交审核人获得创建积分
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 1、提交审核人获得创建积分(使用固定值)
|
|
|
String submitUserId = entity.getSubmitAuditUserId();
|
|
String submitUserId = entity.getSubmitAuditUserId();
|
|
|
if (StringUtils.isNotBlank(submitUserId)) {
|
|
if (StringUtils.isNotBlank(submitUserId)) {
|
|
|
WorkKnowledgeBasePointRule createRule = pointRuleDao.findByRuleType(POINT_RULE_CREATE);
|
|
WorkKnowledgeBasePointRule createRule = pointRuleDao.findByRuleType(POINT_RULE_CREATE);
|
|
@@ -552,7 +663,8 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, Integer.parseInt(createRule.getPointValue()));
|
|
insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, Integer.parseInt(createRule.getPointValue()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 2、本轮三位审核人各获得审核积分(仅统计 audit_result=1 且 audit_time >= startTime)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 2、本轮三位审核人各获得审核积分(使用固定值)
|
|
|
WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByRuleType(POINT_RULE_AUDIT);
|
|
WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByRuleType(POINT_RULE_AUDIT);
|
|
|
if (auditRule == null || auditRule.getPointValue() == null || Integer.parseInt(auditRule.getPointValue()) <= 0) {
|
|
if (auditRule == null || auditRule.getPointValue() == null || Integer.parseInt(auditRule.getPointValue()) <= 0) {
|
|
|
return;
|
|
return;
|
|
@@ -563,7 +675,6 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
}
|
|
|
Set<String> grantedUserIds = new HashSet<>();
|
|
Set<String> grantedUserIds = new HashSet<>();
|
|
|
for (WorkKnowledgeBaseAuditRecord record : records) {
|
|
for (WorkKnowledgeBaseAuditRecord record : records) {
|
|
|
- // 只给本轮审核通过的人加分,同一人只加一次
|
|
|
|
|
if (record.getAuditResult() != null && record.getAuditResult() == 1
|
|
if (record.getAuditResult() != null && record.getAuditResult() == 1
|
|
|
&& StringUtils.isNotBlank(record.getAuditUserId())
|
|
&& StringUtils.isNotBlank(record.getAuditUserId())
|
|
|
&& grantedUserIds.add(record.getAuditUserId())) {
|
|
&& grantedUserIds.add(record.getAuditUserId())) {
|