修改:对标报告保存功能和其他功能调整 v1.0

This commit is contained in:
zjh 2025-12-18 11:06:20 +08:00
parent 39da3ad6fe
commit 8954dc49d8
8 changed files with 273 additions and 262 deletions

View File

@ -2,10 +2,7 @@ package com.xdap.self_development.controller;
import com.definesys.mpaas.common.http.Response;
import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
import com.xdap.self_development.controller.form.HandleApprovalRequest;
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.pojo.BenchmarkingReport;
import com.xdap.self_development.pojo.view.ApprovalFlowView;
@ -37,9 +34,9 @@ public class BenchmarkingReportController {
return Response.ok().data(fileUrl);
}
// 新增对标报告并发起审批
@PostMapping("/startReportApproval")
public Response startReportApproval(
// 保存对标报告
@PostMapping("/insertReport")
public Response saveReportApproval(
@Valid @RequestBody SaveBenchmarkingReportForm form,
BindingResult bindingResult
) {
@ -48,12 +45,21 @@ public class BenchmarkingReportController {
throw new CommonException(error.getDefaultMessage());
});
}
benchmarkingReportService.saveBenchmarkingReport(form);
benchmarkingReportService.insertReport(form);
return Response.ok().setMessage("保存成功");
}
// 修改对标报告并发起审批
@PostMapping("/restartReportApproval")
// 发起审批
@PostMapping("/startReportApproval")
public Response startReportApproval(
@Valid @RequestBody ApprovalPersonForm form
) {
benchmarkingReportService.startReportApproval(form);
return Response.ok().setMessage("保存成功");
}
// 修改对标报告
@PostMapping("/updateReport")
public Response restartReportApproval(
@Valid @RequestBody UpdateBenchmarkingReportForm form,
BindingResult bindingResult
@ -63,7 +69,7 @@ public class BenchmarkingReportController {
throw new CommonException(error.getDefaultMessage());
});
}
benchmarkingReportService.restartReportApproval(form);
benchmarkingReportService.updateReport(form);
return Response.ok().setMessage("重新提交成功");
}

View File

@ -1,5 +1,6 @@
package com.xdap.self_development.controller;
import com.alibaba.excel.EasyExcel;
import com.definesys.mpaas.common.http.Response;
import com.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.motor.entity.SnowflakeIdWorker;
@ -14,12 +15,14 @@ import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Slf4j
@RestController
@ -51,27 +54,57 @@ public class DeleteController {
return Response.ok().data(myResponse);
}
@GetMapping("/getTC")
public Response getTC(
@RequestParam String productNumber,
@RequestParam String partsName,
@RequestParam String parameterName
@PostMapping("/exportCompare")
public void exportTemplateCompare(
// @RequestBody CompareRequest request,
// HttpServletResponse response
) {
EnginePartsCollection enginePartsCollection = bd.getTCDatabase()
.eq("ztj", productNumber)
.eq("lbjmc", partsName)
.doQueryFirst(EnginePartsCollection.class);
if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) {
return Response.error("无法找到图号");
// try {
// // 1. 查询对比数据
// List<ParamCompareDTO> data = compareService.compareMultipleTemplates(
// request.getTemplateNames(),
// request.getQueryParams()
// );
//
// // 2. 设置响应头
// String fileName = "模板参数对比_" + System.currentTimeMillis() + ".xlsx";
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// response.setCharacterEncoding("utf-8");
// response.setHeader("Content-disposition",
// "attachment;filename*=utf-8''" + URLEncoder.encode(fileName, "UTF-8"));
//
// // 3. 动态生成表头
// List<List<String>> head = generateDynamicHeader(request.getTemplateNames());
//
// // 4. 使用EasyExcel写入数据
// EasyExcel.write(response.getOutputStream())
// .head(head) // 动态表头
// .sheet("参数对比")
// .doWrite(data);
//
// } catch (Exception e) {
// throw new RuntimeException("导出失败", e);
// }
}
ClassificationAttribute classificationAttribute = bd.getTCDatabase()
.eq("pitemId", enginePartsCollection.getLbjth())
.eq("idattrtbutehame", parameterName)
.doQueryFirst(ClassificationAttribute.class);
if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) {
String fieldvalue = classificationAttribute.getFieldvalue();
return Response.ok().data(fieldvalue);
/**
* 动态生成表头
*/
private List<List<String>> generateDynamicHeader(List<String> templateNames) {
List<List<String>> head = new ArrayList<>();
// 固定列
head.add(Collections.singletonList("参数名称"));
head.add(Collections.singletonList("参数编码"));
// 动态模板列
for (String templateName : templateNames) {
head.add(Collections.singletonList(templateName));
}
return Response.error("无法找到参数值");
// 差异标识列
head.add(Collections.singletonList("差异标识"));
return head;
}
}

View File

@ -0,0 +1,24 @@
package com.xdap.self_development.controller.form;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data
public class ApprovalPersonForm {
@NotEmpty(message = "报告不能为空")
private String reportId;
@NotEmpty(message = "校对人员不能为空")
private List<String> proofreadUsers;
@NotEmpty(message = "审核人员不能为空")
private List<String> reviewUsers;
private List<String> countersignUsers; // 可选
@NotEmpty(message = "批准人员不能为空")
private List<String> approveUsers;
private String explanation;
@NotEmpty(message = "创建者不能为空")
private String userId;
}

View File

@ -10,41 +10,20 @@ import java.util.List;
public class SaveBenchmarkingReportForm {
@NotBlank(message = "标题不能为空")
private String title;
@NotBlank(message = "厂家名称不能为空")
private String manufacturerName;
@NotBlank(message = "产品型号不能为空")
private String modelName;
@NotBlank(message = "厂家简称不能为空")
private String manufacturerAbbreviation;
@NotBlank(message = "产品型号简称不能为空")
private String modelAbbreviation;
@NotBlank(message = "产品编号不能为空")
private String productNumber;
@NotBlank(message = "模块不能为空")
private String module;
@NotBlank(message = "板块不能为空")
private String manufacturerAbbreviation;
private String modelAbbreviation;
private String productNumber;
private String plate;
@NotBlank(message = "平台不能为空")
private String platform;
@NotBlank(message = "系列不能为空")
private String series;
@NotBlank(message = "细分市场不能为空")
private String marketSegment;
@NotBlank(message = "项目名称不能为空")
private String projectName;
@NotBlank(message = "项目编号不能为空")
private String projectNumber;
private String fileUrl;
@NotEmpty(message = "校对人员不能为空")
private List<String> proofreadUsers;
@NotEmpty(message = "审核人员不能为空")
private List<String> reviewUsers;
private List<String> countersignUsers; // 可选
@NotEmpty(message = "批准人员不能为空")
private List<String> approveUsers;
@NotBlank(message = "发起人不能为空")
private String userId;
private String explanation;
private String fileUrl;
}

View File

@ -8,46 +8,25 @@ import java.util.List;
@Data
public class UpdateBenchmarkingReportForm {
@NotBlank(message = "原对标报告id不能为空")
@NotBlank(message = "原对标报告不能为空")
private String reportId;
@NotBlank(message = "标题不能为空")
private String title;
@NotBlank(message = "厂家名称不能为空")
private String manufacturerName;
@NotBlank(message = "产品型号不能为空")
private String modelName;
@NotBlank(message = "厂家简称不能为空")
private String manufacturerAbbreviation;
@NotBlank(message = "产品型号简称不能为空")
private String modelAbbreviation;
@NotBlank(message = "产品编号不能为空")
private String productNumber;
@NotBlank(message = "模块不能为空")
private String module;
@NotBlank(message = "板块不能为空")
private String plate;
@NotBlank(message = "平台不能为空")
private String platform;
@NotBlank(message = "系列不能为空")
private String series;
@NotBlank(message = "细分市场不能为空")
private String marketSegment;
@NotBlank(message = "项目名称不能为空")
private String projectName;
@NotBlank(message = "项目编号不能为空")
private String projectNumber;
private String fileUrl;
@NotEmpty(message = "校对人员不能为空")
private List<String> proofreadUsers;
@NotEmpty(message = "审核人员不能为空")
private List<String> reviewUsers;
private List<String> countersignUsers; // 可选
@NotEmpty(message = "批准人员不能为空")
private List<String> approveUsers;
@NotBlank(message = "发起人不能为空")
private String createBy;
private String explanation;
private String userId;
}

View File

@ -34,9 +34,9 @@ public class BenchmarkingReport extends MpaasBasePojo {
private String marketSegment;
private String projectName;
private String projectNumber;
private String createBy;
private Integer isDelete;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp uploadTime;
private String filePath;

View File

@ -1,10 +1,7 @@
package com.xdap.self_development.service;
import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
import com.xdap.self_development.controller.form.HandleApprovalRequest;
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.pojo.BenchmarkingReport;
import com.xdap.self_development.pojo.view.ApprovalFlowView;
import com.xdap.self_development.pojo.view.TodoAndReportView;
@ -17,9 +14,11 @@ import java.util.List;
public interface BenchmarkingReportService {
PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(@Valid BenchmarkingReportPageForm form);
void saveBenchmarkingReport(@Valid SaveBenchmarkingReportForm form);
void insertReport(@Valid SaveBenchmarkingReportForm form);
void restartReportApproval(@Valid UpdateBenchmarkingReportForm form);
void startReportApproval(ApprovalPersonForm form);
void updateReport(@Valid UpdateBenchmarkingReportForm form);
void handleReportApproval(@Valid HandleApprovalRequest request);

View File

@ -7,10 +7,7 @@ import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.runtime.service.RuntimeAppContextService;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
import com.xdap.self_development.controller.form.HandleApprovalRequest;
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.feign.ApaasMyTokenFeign;
import com.xdap.self_development.feign.dto.AppTokenDTO;
@ -37,6 +34,7 @@ import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
public class BenchmarkingReportServiceImpl implements BenchmarkingReportService {
@ -63,55 +61,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
private static final String FLOW_LOCK_PREFIX = "report:lock:";
private static final int FLOW_LOCK_EXPIRE_SECONDS = 15;
@Override
@Transactional(rollbackFor = CommonException.class)
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
BenchmarkingReport report = new BenchmarkingReport();
// 1. 创建对标报告并保存
BeanUtils.copyProperties(form, report);
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
report.setStatus("APPROVING");
report.setCreateBy(form.getUserId());
report.setIsDelete(0);
bd.getBusinessDatabase().doInsert(report);
// 2. 创建审批流程
ApprovalFlow flow = new ApprovalFlow();
flow.setTemplateId(report.getId());
flow.setCurrentNode("PROOFREAD");
flow.setFlowStatus("APPROVING");
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
flow.setCreateBy(form.getUserId());
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
flow.setFlowType(2); // 设置为报告审批流程
flow.setExplanation(form.getExplanation());
bd.getBusinessDatabase().doInsert(flow);
// 新增待办
List<TodoTaskPojo> list = new ArrayList<>();
for (String person : form.getProofreadUsers()) {
TodoTaskPojo todoTask = new TodoTaskPojo();
todoTask.setCreatedById(form.getUserId());
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getUserId()).getUsername());
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
todoTask.setDataType("-");
todoTask.setDocumentNo(flow.getId());
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
todoTask.setIsDelete(0);
todoTask.setModelId(report.getId());
todoTask.setModelName(report.getProjectName()+"对标报告");
todoTask.setProcessTitle("对标报告审核");
todoTask.setStatusCode(flow.getFlowStatus());
todoTask.setVersionNumber(1);
todoTask.setOwnerId(person);
list.add(todoTask);
}
bd.getBusinessDatabase().doBatchInsert(list);
}
private String getNodeName(String node) {
switch (node) {
case "PROOFREAD": return "校对";
@ -121,57 +70,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
}
}
@Override
public void restartReportApproval(UpdateBenchmarkingReportForm form) {
bd.getBusinessDatabase()
.eq("id", form.getReportId())
.update("is_delete", 1)
.doUpdate(BenchmarkingReport.class);
BenchmarkingReport report = new BenchmarkingReport();
BeanUtils.copyProperties(form, report);
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
report.setStatus("APPROVING");
report.setCreateBy(form.getCreateBy());
report.setIsDelete(0);
bd.getBusinessDatabase().doInsert(report);
ApprovalFlow flow = new ApprovalFlow();
flow.setTemplateId(report.getId());
flow.setCurrentNode("PROOFREAD");
flow.setFlowStatus("APPROVING");
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
flow.setCreateBy(form.getCreateBy());
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
flow.setFlowType(2); // 设置为报告审批流程
flow.setExplanation(form.getExplanation());
bd.getBusinessDatabase().doInsert(flow);
List<TodoTaskPojo> list = new ArrayList<>();
for (String person : form.getProofreadUsers()) {
TodoTaskPojo todoTask = new TodoTaskPojo();
todoTask.setCreatedById(form.getCreateBy());
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getCreateBy()).getUsername());
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
todoTask.setDataType("-");
todoTask.setDocumentNo(flow.getId());
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
todoTask.setIsDelete(0);
todoTask.setModelId(report.getId());
todoTask.setModelName(report.getProjectName()+"对标报告");
todoTask.setProcessTitle("对标报告审核");
todoTask.setStatusCode(flow.getFlowStatus());
todoTask.setVersionNumber(1);
todoTask.setOwnerId(person);
list.add(todoTask);
}
bd.getBusinessDatabase().doBatchInsert(list);
}
@Override
public String uploadFile(MultipartFile file, String userId) {
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
@ -245,6 +143,79 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
return result;
}
@Override
public void insertReport(SaveBenchmarkingReportForm form) {
BenchmarkingReport report = new BenchmarkingReport();
BeanUtils.copyProperties(form, report);
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
// 草稿状态
report.setStatus("DRAFT");
report.setCreateBy(form.getUserId());
report.setIsDelete(0);
bd.getBusinessDatabase().doInsert(report);
}
@Override
public void startReportApproval(ApprovalPersonForm form) {
BenchmarkingReport report = bd.getBusinessDatabase()
.eq("id", form.getReportId())
.doQueryFirst(BenchmarkingReport.class);
ApprovalFlow flow = new ApprovalFlow();
flow.setTemplateId(report.getId());
flow.setCurrentNode("PROOFREAD");
flow.setFlowStatus("APPROVING");
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
flow.setCreateBy(form.getUserId());
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
flow.setFlowType(2); // 设置为报告审批流程
flow.setExplanation(form.getExplanation());
bd.getBusinessDatabase().doInsert(flow);
List<TodoTaskPojo> list = new ArrayList<>();
for (String person : form.getProofreadUsers()) {
TodoTaskPojo todoTask = new TodoTaskPojo();
todoTask.setCreatedById(form.getUserId());
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getUserId()).getUsername());
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
todoTask.setDataType("-");
todoTask.setDocumentNo(flow.getId());
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
todoTask.setIsDelete(0);
todoTask.setModelId(report.getId());
todoTask.setModelName(report.getProjectName()+"对标报告");
todoTask.setProcessTitle("对标报告审核");
todoTask.setStatusCode(flow.getFlowStatus());
todoTask.setVersionNumber(1);
todoTask.setOwnerId(person);
list.add(todoTask);
}
bd.getBusinessDatabase().doBatchInsert(list);
}
@Override
public void updateReport(UpdateBenchmarkingReportForm form) {
BenchmarkingReport report = bd.getBusinessDatabase()
.eq("id", form.getReportId())
.doQueryFirst(BenchmarkingReport.class);
if (!Objects.equals(report.getStatus(), "DRAFT")) {
throw new CommonException("报告非草稿状态不可修改");
}
if (!Objects.equals(report.getCreateBy(), form.getUserId())) {
throw new CommonException("非创建者不能修改");
}
BeanUtils.copyProperties(form, report);
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
bd.getBusinessDatabase()
.eq("id", report.getId())
.doUpdate(report);
}
private void setCurrentApprovers(PageQueryResult<TodoAndReportView> result) {
result.getResult().forEach(item -> {
ApprovalXdapUsers approvalXdapUser = bd.getBusinessDatabase()
@ -308,77 +279,97 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
ApprovalFlowView approvalFlowView = new ApprovalFlowView();
ApprovalFlow flow = bd.getBusinessDatabase()
.eq("id", flowId)
.eq("flow_type", 2)
.eq("flow_type", 1)
.doQueryFirst(ApprovalFlow.class);
if (flow == null) {
return approvalFlowView;
}
approvalFlowView.setExplanation(flow.getExplanation());
List<ApprovalNodeView> proofread = getNodeList(flowId, "PROOFREAD");
if (proofread.isEmpty()) {
List<ApprovalNodeView> list = new ArrayList<>();
StringBuilder usernames = new StringBuilder();
JSON.parseArray(flow.getProofreadUsers()).toJavaList(String.class).forEach(id -> {
ApprovalXdapUsers user = bd.getBusinessDatabase()
.eq("id", id)
.doQueryFirst(ApprovalXdapUsers.class);
usernames.append(user.getUsername()).append(" ");
});
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
approvalNodeView.setNode("APPROVING");
approvalNodeView.setUserName(usernames.toString());
approvalNodeView.setResult("APPROVING");
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
list.add(approvalNodeView);
approvalFlowView.setProofreadNodes(list);
approvalFlowView.setReviewNodes(new ArrayList<>());
approvalFlowView.setApproveNodes(new ArrayList<>());
approvalFlowView.setFlowStatus(flow.getFlowStatus());
if (!"APPROVING".equals(flow.getFlowStatus())) {
setAllCompletedNodes(approvalFlowView, flow);
return approvalFlowView;
}
approvalFlowView.setProofreadNodes(proofread);
List<ApprovalNodeView> review = getNodeList(flowId, "REVIEW");
if (review.isEmpty()) {
List<ApprovalNodeView> list = new ArrayList<>();
StringBuilder usernames = new StringBuilder();
JSON.parseArray(flow.getReviewUsers()).toJavaList(String.class).forEach(id -> {
ApprovalXdapUsers user = bd.getBusinessDatabase()
.eq("id", id)
.doQueryFirst(ApprovalXdapUsers.class);
usernames.append(user.getUsername()).append(" ");
});
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
approvalNodeView.setNode("APPROVING");
approvalNodeView.setUserName(usernames.toString());
approvalNodeView.setResult("APPROVING");
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
list.add(approvalNodeView);
approvalFlowView.setReviewNodes(list);
approvalFlowView.setApproveNodes(new ArrayList<>());
approvalFlowView.setFlowStatus(flow.getFlowStatus());
processApprovalNodes(approvalFlowView, flow);
return approvalFlowView;
}
approvalFlowView.setReviewNodes(review);
List<ApprovalNodeView> approve = getNodeList(flowId, "APPROVE");
if (approve.isEmpty()) {
List<ApprovalNodeView> list = new ArrayList<>();
StringBuilder usernames = new StringBuilder();
JSON.parseArray(flow.getApproveUsers()).toJavaList(String.class).forEach(id -> {
ApprovalXdapUsers user = bd.getBusinessDatabase()
.eq("id", id)
.doQueryFirst(ApprovalXdapUsers.class);
usernames.append(user.getUsername()).append(" ");
});
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
approvalNodeView.setNode("APPROVING");
approvalNodeView.setUserName(usernames.toString());
approvalNodeView.setResult("APPROVING");
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
list.add(approvalNodeView);
approvalFlowView.setApproveNodes(list);
approvalFlowView.setFlowStatus(flow.getFlowStatus());
return approvalFlowView;
private void setAllCompletedNodes(ApprovalFlowView view, ApprovalFlow flow) {
view.setProofreadNodes(getNodeList(flow.getId(), "PROOFREAD"));
view.setReviewNodes(getNodeList(flow.getId(), "REVIEW"));
view.setApproveNodes(getNodeList(flow.getId(), "APPROVE"));
}
approvalFlowView.setApproveNodes(approve);
approvalFlowView.setFlowStatus(flow.getFlowStatus());
return approvalFlowView;
private void processApprovalNodes(ApprovalFlowView view, ApprovalFlow flow) {
// 处理校对节点
List<ApprovalNodeView> proofreadNodes = getNodeList(flow.getId(), "PROOFREAD");
if (proofreadNodes.isEmpty()) {
view.setProofreadNodes(createApprovingNode(flow.getProofreadUsers()));
view.setReviewNodes(new ArrayList<>());
view.setApproveNodes(new ArrayList<>());
return;
}
view.setProofreadNodes(proofreadNodes);
// 处理审核节点
List<ApprovalNodeView> reviewNodes = getNodeList(flow.getId(), "REVIEW");
if (reviewNodes.isEmpty()) {
view.setReviewNodes(createApprovingNode(flow.getReviewUsers()));
view.setApproveNodes(new ArrayList<>());
return;
}
view.setReviewNodes(reviewNodes);
List<ApprovalNodeView> approveNodes = getNodeList(flow.getId(), "APPROVE");
if (approveNodes.isEmpty()) {
view.setApproveNodes(createApprovingNode(flow.getApproveUsers()));
} else {
view.setApproveNodes(approveNodes);
}
}
private List<ApprovalNodeView> createApprovingNode(String userJsonArray) {
List<ApprovalNodeView> list = new ArrayList<>();
if (userJsonArray == null || userJsonArray.trim().isEmpty()) {
return list;
}
List<String> userIds = JSON.parseArray(userJsonArray).toJavaList(String.class);
if (userIds.isEmpty()) {
return list;
}
Map<String, ApprovalXdapUsers> usersMap = batchQueryUsers(userIds);
StringBuilder usernames = new StringBuilder();
for (String id : userIds) {
ApprovalXdapUsers user = usersMap.get(id);
if (user != null) {
usernames.append(user.getUsername()).append(" ");
}
}
if (usernames.length() > 0) {
ApprovalNodeView node = new ApprovalNodeView();
node.setNode("APPROVING");
node.setUserName(usernames.toString().trim());
node.setResult("APPROVING");
node.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
list.add(node);
}
return list;
}
private Map<String, ApprovalXdapUsers> batchQueryUsers(List<String> userIds) {
if (userIds == null || userIds.isEmpty()) {
return new HashMap<>();
}
List<ApprovalXdapUsers> users = bd.getBusinessDatabase()
.in("id", userIds)
.doQuery(ApprovalXdapUsers.class);
return users.stream()
.collect(Collectors.toMap(ApprovalXdapUsers::getId, user -> user));
}
private List<ApprovalNodeView> getNodeList(String flowId, String node) {