|
|
@@ -4,11 +4,15 @@ import com.jeeplus.common.persistence.Page;
|
|
|
import com.jeeplus.common.service.CrudService;
|
|
|
import com.jeeplus.common.utils.IdGen;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBaseAuditRecordDao;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBaseDynamicInfoDao;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBaseDynamicValueInfoDao;
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBasePointDetailDao;
|
|
|
+import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBasePointRuleDao;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBaseShareInfoDao;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.dao.WorkKnowledgeBaseTreeInfoDao;
|
|
|
import com.jeeplus.modules.WorkKnowledgeBase.entity.*;
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
import com.jeeplus.modules.sys.entity.Workattachment;
|
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
@@ -17,9 +21,12 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 知识库-文件信息 Service
|
|
|
@@ -33,6 +40,29 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
/** 附件标识(attachmentFlag),进行隔离不同业务的附件 */
|
|
|
private static final String ATTACHMENT_FLAG = "199";
|
|
|
|
|
|
+ /** 审核状态常量:草稿 */
|
|
|
+ public static final String AUDIT_STATUS_DRAFT = "0";
|
|
|
+ /** 审核状态常量:未审核 */
|
|
|
+ public static final String AUDIT_STATUS_PENDING = "1";
|
|
|
+ /** 审核状态常量:审核中 */
|
|
|
+ public static final String AUDIT_STATUS_AUDITING = "2";
|
|
|
+ /** 审核状态常量:审核未通过 */
|
|
|
+ public static final String AUDIT_STATUS_REJECTED = "4";
|
|
|
+ /** 审核状态常量:审核通过 */
|
|
|
+ public static final String AUDIT_STATUS_PASSED = "5";
|
|
|
+
|
|
|
+ /** 审核通过所需人数 */
|
|
|
+ public static final int AUDIT_PASS_REQUIRED = 3;
|
|
|
+
|
|
|
+ /** 积分规则类型:创建数据积分 */
|
|
|
+ private static final Integer POINT_RULE_CREATE = 1;
|
|
|
+ /** 积分规则类型:审核通过积分 */
|
|
|
+ private static final Integer POINT_RULE_AUDIT = 2;
|
|
|
+ /** 积分明细变动类型:创建加分 */
|
|
|
+ private static final Integer POINT_CHANGE_CREATE = 1;
|
|
|
+ /** 积分明细变动类型:审核加分 */
|
|
|
+ private static final Integer POINT_CHANGE_AUDIT = 2;
|
|
|
+
|
|
|
@Autowired
|
|
|
private WorkKnowledgeBaseDynamicInfoDao dynamicInfoDao;
|
|
|
|
|
|
@@ -43,8 +73,17 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
private WorkKnowledgeBaseTreeInfoDao treeInfoDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private WorkKnowledgeBaseAuditRecordDao auditRecordDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private WorkattachmentService workattachmentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WorkKnowledgeBasePointDetailDao pointDetailDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkKnowledgeBasePointRuleDao pointRuleDao;
|
|
|
+
|
|
|
/**
|
|
|
* 根据文件id加载附件列表(编辑表单回显用)
|
|
|
*/
|
|
|
@@ -108,6 +147,16 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
|
// 处理附件url
|
|
|
workattachmentService.attachmentManageByUrlOnWorkKnowledgeBaseShare(list);
|
|
|
+
|
|
|
+ // 标记当前登录用户是否已对列表中的文件审核过
|
|
|
+ String currentUserId = UserUtils.getUser().getId();
|
|
|
+ List<String> auditedIds = auditRecordDao.findAuditedFileIdsByUserId(currentUserId);
|
|
|
+ Set<String> auditedIdSet = new HashSet<>(auditedIds);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ Object fileId = map.get("id");
|
|
|
+ map.put("currentUserAudited", fileId != null && auditedIdSet.contains(fileId.toString()));
|
|
|
+ }
|
|
|
+
|
|
|
page.setList(list);
|
|
|
} else {
|
|
|
page.setList(new ArrayList<>());
|
|
|
@@ -147,6 +196,41 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // ========== 审核状态自动判定逻辑 ==========
|
|
|
+ // 根据附件有无自动赋值 audit_status:无文件->草稿0,有文件->未审核 1
|
|
|
+ // 审核未通过重新编辑保存时也按此规则处理
|
|
|
+ boolean hasValidAttachment = hasValidAttachment(attachments);
|
|
|
+ // 编辑时,若前端未提交附件列表(用户未更换文件),回查DB已有附件进行判定
|
|
|
+ if (!isNew && (attachments == null || attachments.isEmpty()) && StringUtils.isNotBlank(shareInfo.getId())) {
|
|
|
+ List<Workattachment> existingAttachments = findAttachmentsByFileId(shareInfo.getId());
|
|
|
+ hasValidAttachment = hasValidAttachment(existingAttachments);
|
|
|
+ }
|
|
|
+ if (isNew) {
|
|
|
+ // 新增:无文件草稿0,有文件未审核 1
|
|
|
+ shareInfo.setAuditStatus(hasValidAttachment ? AUDIT_STATUS_PENDING : AUDIT_STATUS_DRAFT);
|
|
|
+ shareInfo.setAuditPassCount(0);
|
|
|
+ shareInfo.setAuditRejectCount(0);
|
|
|
+ // 有附件时记录提交审核人为当前登录人,同时初始化本轮审核起始时间
|
|
|
+ if (hasValidAttachment) {
|
|
|
+ shareInfo.setSubmitAuditUserId(UserUtils.getUser().getId());
|
|
|
+ shareInfo.setAuditStartDate(new Date());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 编辑:仅当状态为草稿(0)或审核未通过(4)时允许重新判定
|
|
|
+ String currentStatus = shareInfo.getAuditStatus();
|
|
|
+ if (currentStatus != null && (currentStatus.equals(AUDIT_STATUS_DRAFT) || currentStatus.equals(AUDIT_STATUS_REJECTED))) {
|
|
|
+ shareInfo.setAuditStatus(hasValidAttachment ? AUDIT_STATUS_PENDING : AUDIT_STATUS_DRAFT);
|
|
|
+ shareInfo.setAuditPassCount(0);
|
|
|
+ shareInfo.setAuditRejectCount(0);
|
|
|
+ // 重新提交时更新提交审核人为当前登录人,并刷新本轮审核起始时间(历史审核记录依靠该时间隔离)
|
|
|
+ if (hasValidAttachment) {
|
|
|
+ shareInfo.setSubmitAuditUserId(UserUtils.getUser().getId());
|
|
|
+ shareInfo.setAuditStartDate(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 审核中(2)和审核通过(5)不允许编辑,由Controller层校验
|
|
|
+ }
|
|
|
+
|
|
|
if (isNew) {
|
|
|
shareInfo.setId(IdGen.uuid());
|
|
|
shareInfo.preInsert();
|
|
|
@@ -199,6 +283,288 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 判断附件列表中是否存在有效(未删除的)附件
|
|
|
+ */
|
|
|
+ private boolean hasValidAttachment(List<Workattachment> attachments) {
|
|
|
+ if (attachments == null || attachments.isEmpty()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (Workattachment attachment : attachments) {
|
|
|
+ if (attachment.getId() != null
|
|
|
+ && Workattachment.DEL_FLAG_NORMAL.equals(attachment.getDelFlag())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起审核:未审核(1) -> 审核中(2),清空通过/驳回统计
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void submitAudit(String fileId) {
|
|
|
+ WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new RuntimeException("文件记录不存在");
|
|
|
+ }
|
|
|
+ if (entity.getAuditStatus() == null || entity.getAuditStatus() != AUDIT_STATUS_PENDING) {
|
|
|
+ throw new RuntimeException("当前状态不允许发起审核");
|
|
|
+ }
|
|
|
+ entity.setAuditStatus(AUDIT_STATUS_AUDITING);
|
|
|
+ entity.setAuditPassCount(0);
|
|
|
+ entity.setAuditRejectCount(0);
|
|
|
+ // 刷新本轮审核起始时间
|
|
|
+ entity.setAuditStartDate(new Date());
|
|
|
+ entity.preUpdate();
|
|
|
+ dao.updateAuditStatus(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核通过操作
|
|
|
+ * 规则:本轮三人通过即成功(仅统计 audit_start_date 之后的记录,隔离历史数据)
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void auditPass(String fileId, String auditUserId, String auditOpinion) {
|
|
|
+ WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new RuntimeException("文件记录不存在");
|
|
|
+ }
|
|
|
+ if (entity.getAuditStatus() == null || entity.getAuditStatus() == AUDIT_STATUS_REJECTED || entity.getAuditStatus() == AUDIT_STATUS_PASSED) {
|
|
|
+ throw new RuntimeException("当前状态不允许审核");
|
|
|
+ }
|
|
|
+ // 禁止审核自己提交的文件
|
|
|
+ if (auditUserId.equals(entity.getSubmitAuditUserId())) {
|
|
|
+ throw new RuntimeException("不允许审核自己提交的文件");
|
|
|
+ }
|
|
|
+ // 检查本轮是否已审核过(按 audit_start_date 过滤,避免历史记录干扰)
|
|
|
+ Date startTime = entity.getAuditStartDate();
|
|
|
+ if (auditRecordDao.countByFileIdAndUserIdSinceTime(fileId, auditUserId, startTime) > 0) {
|
|
|
+ throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
|
+ }
|
|
|
+ // 保存审核记录
|
|
|
+ WorkKnowledgeBaseAuditRecord record = new WorkKnowledgeBaseAuditRecord();
|
|
|
+ record.setFileId(fileId);
|
|
|
+ record.setAuditUserId(auditUserId);
|
|
|
+ record.setAuditResult(1); // 1:通过
|
|
|
+ record.setAuditOpinion(auditOpinion);
|
|
|
+ record.setId(IdGen.uuid());
|
|
|
+ record.setAuditTime(new java.util.Date());
|
|
|
+ record.preInsert();
|
|
|
+ auditRecordDao.insert(record);
|
|
|
+
|
|
|
+ // 更新通过计数(仅统计本轮)
|
|
|
+ int passCount = auditRecordDao.countPassByFileIdSinceTime(fileId, startTime);
|
|
|
+ entity.setAuditPassCount(passCount);
|
|
|
+ entity.setAuditRejectCount(auditRecordDao.countRejectByFileIdSinceTime(fileId, startTime));
|
|
|
+
|
|
|
+ // 判定:本轮累计3人通过则审核通过;否则进入审核中状态(一旦有人开始审核,状态即变为2)
|
|
|
+ if (passCount >= AUDIT_PASS_REQUIRED) {
|
|
|
+ entity.setAuditStatus(AUDIT_STATUS_PASSED);
|
|
|
+ entity.preUpdate();
|
|
|
+ dao.updateAuditStatus(entity);
|
|
|
+ // 本轮审核通过:为提交审核人及本轮三位审核人写入积分明细
|
|
|
+ grantPointsOnAuditPassed(entity, startTime);
|
|
|
+ } else {
|
|
|
+ entity.setAuditStatus(AUDIT_STATUS_AUDITING);
|
|
|
+ entity.preUpdate();
|
|
|
+ dao.updateAuditStatus(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核驳回操作
|
|
|
+ * 规则:一票驳回直接审核失败;历史记录依靠 audit_start_date 隔离,无需逻辑删除
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void auditReject(String fileId, String auditUserId, String auditOpinion) {
|
|
|
+ WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new RuntimeException("文件记录不存在");
|
|
|
+ }
|
|
|
+ if (entity.getAuditStatus() == null || entity.getAuditStatus() == AUDIT_STATUS_REJECTED || entity.getAuditStatus() == AUDIT_STATUS_PASSED) {
|
|
|
+ throw new RuntimeException("当前状态不允许审核");
|
|
|
+ }
|
|
|
+ // 禁止审核自己提交的文件
|
|
|
+ if (auditUserId.equals(entity.getSubmitAuditUserId())) {
|
|
|
+ throw new RuntimeException("不允许审核自己提交的文件");
|
|
|
+ }
|
|
|
+ // 检查本轮是否已审核过
|
|
|
+ Date startTime = entity.getAuditStartDate();
|
|
|
+ if (auditRecordDao.countByFileIdAndUserIdSinceTime(fileId, auditUserId, startTime) > 0) {
|
|
|
+ throw new RuntimeException("您已审核过该文件,不可重复审核");
|
|
|
+ }
|
|
|
+ // 保存审核记录
|
|
|
+ WorkKnowledgeBaseAuditRecord record = new WorkKnowledgeBaseAuditRecord();
|
|
|
+ record.setFileId(fileId);
|
|
|
+ record.setAuditUserId(auditUserId);
|
|
|
+ record.setAuditResult(2); // 2:驳回
|
|
|
+ record.setAuditOpinion(auditOpinion);
|
|
|
+ record.setId(IdGen.uuid());
|
|
|
+ record.setAuditTime(new java.util.Date());
|
|
|
+ record.preInsert();
|
|
|
+ auditRecordDao.insert(record);
|
|
|
+
|
|
|
+ // 一票驳回直接变为审核未通过(历史记录保留,重新提交后 audit_start_date 刷新自动隔离)
|
|
|
+ entity.setAuditStatus(AUDIT_STATUS_REJECTED);
|
|
|
+ entity.setAuditPassCount(auditRecordDao.countPassByFileIdSinceTime(fileId, startTime));
|
|
|
+ entity.setAuditRejectCount(auditRecordDao.countRejectByFileIdSinceTime(fileId, startTime));
|
|
|
+ entity.preUpdate();
|
|
|
+ dao.updateAuditStatus(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 撤回审核:审核中(1/2) -> 草稿(0)
|
|
|
+ * 仅提交审核人或管理员可撤回。历史记录依靠 audit_start_date 隔离,无需逻辑删除
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void withdrawAudit(String fileId) {
|
|
|
+ WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
+ if (entity == null) {
|
|
|
+ throw new RuntimeException("文件记录不存在");
|
|
|
+ }
|
|
|
+ if (entity.getAuditStatus() == null || entity.getAuditStatus() == AUDIT_STATUS_REJECTED || entity.getAuditStatus() == AUDIT_STATUS_PASSED) {
|
|
|
+ throw new RuntimeException("当前状态不允许撤回");
|
|
|
+ }
|
|
|
+ // 校验权限:仅提交审核人或管理员可撤回
|
|
|
+ User currentUser = UserUtils.getUser();
|
|
|
+ if (!currentUser.isAdmin() && !UserUtils.isManager()
|
|
|
+ && !currentUser.getId().equals(entity.getSubmitAuditUserId())) {
|
|
|
+ throw new RuntimeException("您没有权限撤回该审核");
|
|
|
+ }
|
|
|
+ entity.setAuditStatus(AUDIT_STATUS_DRAFT);
|
|
|
+ entity.setAuditPassCount(0);
|
|
|
+ entity.setAuditRejectCount(0);
|
|
|
+ entity.preUpdate();
|
|
|
+ dao.updateAuditStatus(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前用户是否可以编辑指定文件
|
|
|
+ */
|
|
|
+ public boolean canEdit(WorkKnowledgeBaseShareInfo entity) {
|
|
|
+ if (entity == null || entity.getAuditStatus() == null) return true;
|
|
|
+ String status = entity.getAuditStatus();
|
|
|
+ User currentUser = UserUtils.getUser();
|
|
|
+ boolean isAdmin = currentUser.isAdmin() || UserUtils.isManager();
|
|
|
+
|
|
|
+ switch (status) {
|
|
|
+ case "0": // 草稿:所有用户可修改
|
|
|
+ case "1": // 未审核:所有用户可修改
|
|
|
+ case "4": // 审核未通过:所有用户可修改
|
|
|
+ return true;
|
|
|
+ case "2": // 审核中:全员禁止修改
|
|
|
+ return false;
|
|
|
+ case "5": // 审核通过:仅管理员可修改
|
|
|
+ return isAdmin;
|
|
|
+ default:
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前用户是否可以删除指定文件
|
|
|
+ */
|
|
|
+ public boolean canDelete(WorkKnowledgeBaseShareInfo entity) {
|
|
|
+ // 删除权限与编辑权限逻辑一致
|
|
|
+ return canEdit(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前用户是否可以撤回审核
|
|
|
+ */
|
|
|
+ public boolean canWithdraw(WorkKnowledgeBaseShareInfo entity) {
|
|
|
+ if (entity == null || entity.getAuditStatus() == null) return false;
|
|
|
+ if (entity.getAuditStatus() != AUDIT_STATUS_PENDING && entity.getAuditStatus() != AUDIT_STATUS_AUDITING) return false;
|
|
|
+ User currentUser = UserUtils.getUser();
|
|
|
+ return currentUser.isAdmin() || UserUtils.isManager()
|
|
|
+ || currentUser.getId().equals(entity.getSubmitAuditUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前用户是否可以审核(通过/驳回)该文件
|
|
|
+ */
|
|
|
+ public boolean canAudit(WorkKnowledgeBaseShareInfo entity) {
|
|
|
+ if (entity == null || entity.getAuditStatus() == null) return false;
|
|
|
+ if (entity.getAuditStatus() != AUDIT_STATUS_PENDING && entity.getAuditStatus() != AUDIT_STATUS_AUDITING) return false;
|
|
|
+ String currentUserId = UserUtils.getUser().getId();
|
|
|
+ // 提交审核人不可审核自己的文件
|
|
|
+ if (currentUserId.equals(entity.getSubmitAuditUserId())) return false;
|
|
|
+ // 本轮未审核过的用户可审核(按 audit_start_date 隔离历史记录)
|
|
|
+ return auditRecordDao.countByFileIdAndUserIdSinceTime(entity.getId(), currentUserId, entity.getAuditStartDate()) == 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前用户是否可以发起审核
|
|
|
+ */
|
|
|
+ public boolean canSubmitAudit(WorkKnowledgeBaseShareInfo entity) {
|
|
|
+ if (entity == null || entity.getAuditStatus() == null) return false;
|
|
|
+ return entity.getAuditStatus() == AUDIT_STATUS_PENDING
|
|
|
+ || entity.getAuditStatus() == AUDIT_STATUS_REJECTED;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据文件id查询本轮审核记录列表(详情页仅展示 audit_start_date 之后的记录,驳回后历史记录不可见)
|
|
|
+ */
|
|
|
+ public List<WorkKnowledgeBaseAuditRecord> findAuditRecordsByFileId(String fileId) {
|
|
|
+ WorkKnowledgeBaseShareInfo entity = dao.get(fileId);
|
|
|
+ Date startTime = entity != null ? entity.getAuditStartDate() : null;
|
|
|
+ return auditRecordDao.findByFileIdSinceTime(fileId, startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本轮审核通过后发放积分:
|
|
|
+ * 1、为提交审核人(submit_audit_user_id)发放创建积分(change_type=1)
|
|
|
+ * 2、为本轮三位审核人(audit_time >= audit_start_date 且 audit_result=1)各发放审核积分(change_type=2)
|
|
|
+ * 积分值读取 work_knowledge_base_point_rule 中对应 status=1 的启用规则
|
|
|
+ */
|
|
|
+ private void grantPointsOnAuditPassed(WorkKnowledgeBaseShareInfo entity, Date startTime) {
|
|
|
+ if (entity == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String shareId = entity.getId();
|
|
|
+ // 1、提交审核人获得创建积分
|
|
|
+ String submitUserId = entity.getSubmitAuditUserId();
|
|
|
+ if (StringUtils.isNotBlank(submitUserId)) {
|
|
|
+ WorkKnowledgeBasePointRule createRule = pointRuleDao.findByRuleType(POINT_RULE_CREATE);
|
|
|
+ if (createRule != null && createRule.getPointValue() != null && createRule.getPointValue() > 0) {
|
|
|
+ insertPointDetail(submitUserId, shareId, POINT_CHANGE_CREATE, createRule.getPointValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2、本轮三位审核人各获得审核积分(仅统计 audit_result=1 且 audit_time >= startTime)
|
|
|
+ WorkKnowledgeBasePointRule auditRule = pointRuleDao.findByRuleType(POINT_RULE_AUDIT);
|
|
|
+ if (auditRule == null || auditRule.getPointValue() == null || auditRule.getPointValue() <= 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, auditRule.getPointValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 插入一条积分明细记录
|
|
|
+ */
|
|
|
+ private void insertPointDetail(String userId, String shareId, Integer changeType, Integer point) {
|
|
|
+ WorkKnowledgeBasePointDetail detail = new WorkKnowledgeBasePointDetail();
|
|
|
+ detail.setId(IdGen.uuid());
|
|
|
+ detail.setUserId(userId);
|
|
|
+ detail.setShareId(shareId);
|
|
|
+ detail.setChangeType(changeType);
|
|
|
+ detail.setPoint(point);
|
|
|
+ detail.preInsert();
|
|
|
+ pointDetailDao.insert(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 逻辑删除文件(含动态字段值)
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|