From 3a28a6820725c2f0b31c15a1700ae16f8b37883d Mon Sep 17 00:00:00 2001 From: zjh <15615273395@163.com> Date: Tue, 23 Dec 2025 10:22:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9:=E6=9D=83=E9=99=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/UserPermissionGetter.java | 16 +++++++++------- .../config/BusinessDatabase.java | 2 +- .../pojo/view/TodoAndReportView.java | 9 ++------- .../service/ParameterService.java | 5 ----- .../impl/BenchmarkingReportServiceImpl.java | 16 ++++++++++++++-- .../service/impl/ParameterServiceImpl.java | 10 ---------- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/xdap/self_development/common/UserPermissionGetter.java b/src/main/java/com/xdap/self_development/common/UserPermissionGetter.java index 0086d7d..844fad6 100644 --- a/src/main/java/com/xdap/self_development/common/UserPermissionGetter.java +++ b/src/main/java/com/xdap/self_development/common/UserPermissionGetter.java @@ -23,18 +23,19 @@ public class UserPermissionGetter { private RuntimeAppContextService runtimeAppContextService; - // 获取子系统下的参数权限 + // 获取子系统下的零部件权限 public List getParamPermissions(String subsystem, String userId) { Set result = new HashSet<>(); try { - // 获取用户权限 + // 获取用户所有权限 Map> collected = modelRoleService.selectPersByUser(userId) .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); + // 获取用户在当前子系统拥有的零部件权限 if (collected.containsKey(subsystem)) { result.addAll(collected.get(subsystem) - .stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); + .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet())); } - // 获取用户所在部门权限 + // 获取用户所在部门在当前子系统拥有的零部件权限 List deptIds = businessDatabase.getBusinessDatabase() .eq("user_id", userId).doQuery(XdapDeptUsers.class) .stream().map(XdapDeptUsers::getDepartmentId).collect(Collectors.toList()); @@ -43,11 +44,12 @@ public class UserPermissionGetter { .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); if (collected1.containsKey(subsystem)) { result.addAll(collected1.get(subsystem) - .stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); + .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet())); } } } catch (Exception e) { log.error(e.getMessage()); + return new ArrayList<>(); } return new ArrayList<>(result); } @@ -61,7 +63,7 @@ public class UserPermissionGetter { .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); for (String subsystem : collected.keySet()) { result.addAll(collected.get(subsystem) - .stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); + .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet())); } // 获取用户所在部门权限 List deptIds = businessDatabase.getBusinessDatabase() @@ -72,7 +74,7 @@ public class UserPermissionGetter { .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); for (String subsystem : collected1.keySet()) { result.addAll(collected1.get(subsystem) - .stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); + .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet())); } } } catch (Exception e) { diff --git a/src/main/java/com/xdap/self_development/config/BusinessDatabase.java b/src/main/java/com/xdap/self_development/config/BusinessDatabase.java index 2d2bc16..b1693f8 100644 --- a/src/main/java/com/xdap/self_development/config/BusinessDatabase.java +++ b/src/main/java/com/xdap/self_development/config/BusinessDatabase.java @@ -24,6 +24,6 @@ public class BusinessDatabase { @Bean public MpaasQuery getTCDatabase() { - return queryFactory.buildFromDatasource(DatasourceConstant.XDAP_MYSQL_PREFIX + tenantId); + return queryFactory.buildFromDatasource("yc_lrs_test_relsult"); } } diff --git a/src/main/java/com/xdap/self_development/pojo/view/TodoAndReportView.java b/src/main/java/com/xdap/self_development/pojo/view/TodoAndReportView.java index c14c836..45975c9 100644 --- a/src/main/java/com/xdap/self_development/pojo/view/TodoAndReportView.java +++ b/src/main/java/com/xdap/self_development/pojo/view/TodoAndReportView.java @@ -8,17 +8,12 @@ import lombok.Data; import java.sql.Timestamp; @SQLQuery(value = { - @SQL(view = "getAllReportApprovalByParts", - sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and br.subsystem = #subsystem and br.parts_name in (#partsName) ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"), - @SQL(view = "getAllReportApprovalBySub", - sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and br.subsystem = #subsystem ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"), - @SQL(view = "getAllReportApproval", - sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC") + @SQL(view = "getAllReport", + sql = "SELECT br.id AS \"reportId\", br.* FROM yfsjglpt_model_benchmarking_report br WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC") }) @Data public class TodoAndReportView { private String reportId; - private String flowId; private String title; private String manufacturerName; diff --git a/src/main/java/com/xdap/self_development/service/ParameterService.java b/src/main/java/com/xdap/self_development/service/ParameterService.java index d73193c..67a9c40 100644 --- a/src/main/java/com/xdap/self_development/service/ParameterService.java +++ b/src/main/java/com/xdap/self_development/service/ParameterService.java @@ -4,15 +4,10 @@ import com.xdap.self_development.common.MyPageResult; import com.xdap.self_development.controller.form.ParameterPageForm; import com.xdap.self_development.controller.form.UpdateParameterForm; import com.xdap.self_development.pojo.Parameter; -import com.xdap.self_development.pojo.view.ParametersView; import com.xdap.self_development.pojo.view.TemplateInfoView; -import java.util.List; - public interface ParameterService { MyPageResult getParameterByCondition(ParameterPageForm form); TemplateInfoView maintenanceParameters(UpdateParameterForm form); - - List getAllParameters(String subsystem); } diff --git a/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java index ebc0248..053f633 100644 --- a/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/BenchmarkingReportServiceImpl.java @@ -135,7 +135,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService public PageQueryResult getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) { PageQueryResult result = bd.getBusinessDatabase() .viewQueryMode(true) - .view("getAllReportApproval") + .view("getAllReport") .setVar("title", form.getTitle()) .setVar("manufacturerName", form.getManufacturerName()) .setVar("modelName", form.getModelName()) @@ -172,6 +172,13 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService .eq("id", form.getReportId()) .doQueryFirst(BenchmarkingReport.class); + ApprovalFlow approvalFlow = bd.getBusinessDatabase() + .eq("template_id", report.getId()) + .doQueryFirst(ApprovalFlow.class); + if (approvalFlow != null && Objects.equals(approvalFlow.getFlowStatus(), "APPROVING")) { + throw new CommonException("该报告正在审批中,请勿重复发起审批"); + } + ApprovalFlow flow = new ApprovalFlow(); flow.setTemplateId(report.getId()); flow.setCurrentNode("PROOFREAD"); @@ -186,6 +193,11 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService flow.setExplanation(form.getExplanation()); bd.getBusinessDatabase().doInsert(flow); + bd.getBusinessDatabase() + .eq("id", report.getId()) + .update("status", "APPROVING") + .doUpdate(BenchmarkingReport.class); + List list = new ArrayList<>(); for (String person : form.getProofreadUsers()) { TodoTaskPojo todoTask = new TodoTaskPojo(); @@ -288,7 +300,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService ApprovalFlowView approvalFlowView = new ApprovalFlowView(); ApprovalFlow flow = bd.getBusinessDatabase() .eq("id", flowId) - .eq("flow_type", 1) + .eq("flow_type", 2) .doQueryFirst(ApprovalFlow.class); if (flowId == null || flowId.isEmpty() || flow == null) { diff --git a/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java b/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java index dbcb2ac..b106031 100644 --- a/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java +++ b/src/main/java/com/xdap/self_development/service/impl/ParameterServiceImpl.java @@ -12,7 +12,6 @@ import com.xdap.self_development.pojo.Parameter; import com.xdap.self_development.pojo.RevisionRecord; import com.xdap.self_development.pojo.Template; import com.xdap.self_development.pojo.TemplateAndParameter; -import com.xdap.self_development.pojo.view.ParametersView; import com.xdap.self_development.pojo.view.TemplateInfoView; import com.xdap.self_development.service.ParameterService; import com.xdap.self_development.utils.FormulaValidator; @@ -163,15 +162,6 @@ public class ParameterServiceImpl implements ParameterService { } } - @Override - public List getAllParameters(String subsystem) { - return bd.getBusinessDatabase() - .viewQueryMode(true) - .view("getAllParameters") - .setVar("subsystem", subsystem) - .doQuery(ParametersView.class); - } - private TemplateBenchmark getTemplateBenchmark(String templateRowId) { // 基准模板(用户选择的要比较的版本) Template baseTemplate = bd.getBusinessDatabase()