模板审核状态和流程模糊查询修改

This commit is contained in:
zjh 2025-12-05 14:45:52 +08:00
parent f3266cdca8
commit 92a7a6a854
3 changed files with 11 additions and 13 deletions

View File

@ -6,7 +6,7 @@ import lombok.Data;
@SQLQuery(value = { @SQLQuery(value = {
@SQL(view = "getParameterAndChange", @SQL(view = "getParameterAndChange",
sql = "SELECT p.*, r.modify_details FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY parameter_id ORDER BY create_time DESC) AS rn FROM yfsjglpt_model_revision_record ) r LEFT JOIN yfsjglpt_model_parameter p ON r.parameter_id = p.id WHERE r.rn = 1 and r.template_id = #templateId") sql = "SELECT p.*, r.modify_details FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY parameter_id ORDER BY create_time DESC) AS rn FROM yfsjglpt_model_revision_record ) r LEFT JOIN yfsjglpt_model_parameter p ON r.parameter_id = p.id WHERE r.rn = 1 and r.template_id = #templateId order by r.create_time desc ")
}) })
@Data @Data
public class TemplateChangeView { public class TemplateChangeView {

View File

@ -13,7 +13,7 @@ import java.util.List;
@SQL(view = "getApprovalByUserIdAndIds", @SQL(view = "getApprovalByUserIdAndIds",
sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id WHERE t.template_name like CONCAT('%',#templateName, '%') and t.status like CONCAT('%',#status, '%') and af.flow_type = 1 and af.id NOT IN (#ids) AND af.create_by = #createBy"), sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id WHERE t.template_name like CONCAT('%',#templateName, '%') and t.status like CONCAT('%',#status, '%') and af.flow_type = 1 and af.id NOT IN (#ids) AND af.create_by = #createBy"),
@SQL(view = "getTodoAndTemplate", @SQL(view = "getTodoAndTemplate",
sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id LEFT JOIN xdap_users xu ON xu.id = create_by WHERE t.template_name LIKE CONCAT('%', #templateName, '%') AND t.status LIKE CONCAT('%', #status, '%') AND t.created_time LIKE CONCAT('%', #createdTime, '%') AND xu.username LIKE CONCAT('%', #username, '%') AND af.flow_type = 1 AND af.id IN (#ids)") sql = "SELECT af.id AS \"flowId\", t.id AS \"templateId\", t.template_name AS \"templateName\", t.version AS \"version\", t.status AS \"status\" , af.create_by AS \"createBy\" , xu.username AS \"username\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_template t ON af.template_id = t.id LEFT JOIN xdap_users xu ON xu.id = af.create_by WHERE t.template_name LIKE CONCAT('%', #templateName, '%') AND t.status LIKE CONCAT('%', #status, '%') AND DATE(af.created_time) = #createdTime AND xu.username LIKE CONCAT('%', #username, '%') AND af.flow_type = 1 AND (af.id IN (#ids) OR af.create_by = #createBy)")
}) })
@Data @Data
public class TodoAndTemplateView { public class TodoAndTemplateView {
@ -24,6 +24,7 @@ public class TodoAndTemplateView {
private String status; private String status;
private String createBy; private String createBy;
private String currentUsers; private String currentUsers;
private String username;
private List<ApprovalXdapUsers> currentApprovers; private List<ApprovalXdapUsers> currentApprovers;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp createdTime; private Timestamp createdTime;

View File

@ -113,21 +113,19 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
@Transactional @Transactional
public List<TodoAndTemplateView> getApprovalList(ApprovalListForm form) { public List<TodoAndTemplateView> getApprovalList(ApprovalListForm form) {
List<TodoAndTemplateView> approvalList = new ArrayList<>(); List<TodoAndTemplateView> approvalList = new ArrayList<>();
Set<String> flowIds = new HashSet<>(); Set<String> flowIds = new HashSet<>(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getUserId())));
flowIds.add(form.getUserId());
flowIds.addAll(Objects.requireNonNull(redisTemplate.opsForSet().members(TODO_PREFIX + form.getUserId())));
List<String> ids = new ArrayList<>(flowIds); List<String> ids = new ArrayList<>(flowIds);
List<TodoAndTemplateView> todoList =bd.getBusinessDatabase() List<TodoAndTemplateView> todoList =bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("getTodoAndTemplate") .view("getTodoAndTemplate")
.setVar("ids", ids) .setVar("ids", ids)
.setVar("createBy", form.getUserId())
.setVar("templateName", form.getTemplateName()) .setVar("templateName", form.getTemplateName())
.setVar("status", form.getStatus()) .setVar("status", form.getStatus())
.setVar("createdTime", form.getCreateDate()) .setVar("createdTime", form.getCreateDate())
.setVar("username", form.getUsername()) .setVar("username",form.getUsername())
.doQuery(TodoAndTemplateView.class); .doQuery(TodoAndTemplateView.class);
setCurrentApprovers(approvalList, todoList); setCurrentApprovers(approvalList, todoList);
return approvalList; return approvalList;
} }
@ -144,10 +142,6 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
item.setCurrentApprovers(approvalXdapUsers); item.setCurrentApprovers(approvalXdapUsers);
item.setCurrentUsers(null); item.setCurrentUsers(null);
} }
ApprovalXdapUsers approvalXdapUser = bd.getBusinessDatabase()
.eq("id", item.getCreateBy())
.doQueryFirst(ApprovalXdapUsers.class);
item.setCreateBy(approvalXdapUser == null ? item.getCreateBy() : approvalXdapUser.getUsername());
}); });
approvalList.addAll(todoAndTemplateViews); approvalList.addAll(todoAndTemplateViews);
} }
@ -215,9 +209,11 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
// 处理驳回逻辑 // 处理驳回逻辑
if ("REJECT".equals(request.getResult())) { if ("REJECT".equals(request.getResult())) {
// 审批人退回
cancelProcess(flow, "REJECTED"); cancelProcess(flow, "REJECTED");
return; return;
} else if ("RETURN".equals(request.getResult())) { } else if ("RETURN".equals(request.getResult())) {
// 申请人撤回
cancelProcess(flow, "RETURNED"); cancelProcess(flow, "RETURNED");
return; return;
} }
@ -354,16 +350,17 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
} }
private void cancelProcess(ApprovalFlow flow, String status) { private void cancelProcess(ApprovalFlow flow, String status) {
// 更新流程状态
flow.setFlowStatus(status); flow.setFlowStatus(status);
bd.getBusinessDatabase() bd.getBusinessDatabase()
.rowid("id", flow.getRowId()) .rowid("id", flow.getRowId())
.update("status", flow.getFlowStatus()) .update("status", flow.getFlowStatus())
.doUpdate(ApprovalFlow.class); .doUpdate(ApprovalFlow.class);
// 更新模板状态 // 更新模板状态(重新打回草稿状态)
Template template = bd.getBusinessDatabase() Template template = bd.getBusinessDatabase()
.eq("id", flow.getTemplateId()) .eq("id", flow.getTemplateId())
.doQueryFirst(Template.class); .doQueryFirst(Template.class);
template.setStatus(status); template.setStatus("DRAFT");
bd.getBusinessDatabase() bd.getBusinessDatabase()
.rowid("id", template.getRowId()) .rowid("id", template.getRowId())
.update("status", template.getStatus()) .update("status", template.getStatus())