修改:权限修改

This commit is contained in:
zjh 2025-12-23 10:22:36 +08:00
parent 1ffa2ae9da
commit 3a28a68207
6 changed files with 26 additions and 32 deletions

View File

@ -23,18 +23,19 @@ public class UserPermissionGetter {
private RuntimeAppContextService runtimeAppContextService; private RuntimeAppContextService runtimeAppContextService;
// 获取子系统下的参数权限 // 获取子系统下的零部件权限
public List<String> getParamPermissions(String subsystem, String userId) { public List<String> getParamPermissions(String subsystem, String userId) {
Set<String> result = new HashSet<>(); Set<String> result = new HashSet<>();
try { try {
// 获取用户权限 // 获取用户所有权限
Map<String, List<MenuParamView>> collected = modelRoleService.selectPersByUser(userId) Map<String, List<MenuParamView>> collected = modelRoleService.selectPersByUser(userId)
.stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem));
// 获取用户在当前子系统拥有的零部件权限
if (collected.containsKey(subsystem)) { if (collected.containsKey(subsystem)) {
result.addAll(collected.get(subsystem) result.addAll(collected.get(subsystem)
.stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet()));
} }
// 获取用户所在部门权限 // 获取用户所在部门在当前子系统拥有的零部件权限
List<String> deptIds = businessDatabase.getBusinessDatabase() List<String> deptIds = businessDatabase.getBusinessDatabase()
.eq("user_id", userId).doQuery(XdapDeptUsers.class) .eq("user_id", userId).doQuery(XdapDeptUsers.class)
.stream().map(XdapDeptUsers::getDepartmentId).collect(Collectors.toList()); .stream().map(XdapDeptUsers::getDepartmentId).collect(Collectors.toList());
@ -43,11 +44,12 @@ public class UserPermissionGetter {
.stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem));
if (collected1.containsKey(subsystem)) { if (collected1.containsKey(subsystem)) {
result.addAll(collected1.get(subsystem) result.addAll(collected1.get(subsystem)
.stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet()));
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return new ArrayList<>();
} }
return new ArrayList<>(result); return new ArrayList<>(result);
} }
@ -61,7 +63,7 @@ public class UserPermissionGetter {
.stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem));
for (String subsystem : collected.keySet()) { for (String subsystem : collected.keySet()) {
result.addAll(collected.get(subsystem) result.addAll(collected.get(subsystem)
.stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet()));
} }
// 获取用户所在部门权限 // 获取用户所在部门权限
List<String> deptIds = businessDatabase.getBusinessDatabase() List<String> deptIds = businessDatabase.getBusinessDatabase()
@ -72,7 +74,7 @@ public class UserPermissionGetter {
.stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem)); .stream().collect(Collectors.groupingBy(MenuParamView::getSubsystem));
for (String subsystem : collected1.keySet()) { for (String subsystem : collected1.keySet()) {
result.addAll(collected1.get(subsystem) result.addAll(collected1.get(subsystem)
.stream().map(MenuParamView::getParameterId).collect(Collectors.toSet())); .stream().map(MenuParamView::getPartsName).collect(Collectors.toSet()));
} }
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -24,6 +24,6 @@ public class BusinessDatabase {
@Bean @Bean
public MpaasQuery getTCDatabase() { public MpaasQuery getTCDatabase() {
return queryFactory.buildFromDatasource(DatasourceConstant.XDAP_MYSQL_PREFIX + tenantId); return queryFactory.buildFromDatasource("yc_lrs_test_relsult");
} }
} }

View File

@ -8,17 +8,12 @@ import lombok.Data;
import java.sql.Timestamp; import java.sql.Timestamp;
@SQLQuery(value = { @SQLQuery(value = {
@SQL(view = "getAllReportApprovalByParts", @SQL(view = "getAllReport",
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 = "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")
@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")
}) })
@Data @Data
public class TodoAndReportView { public class TodoAndReportView {
private String reportId; private String reportId;
private String flowId;
private String title; private String title;
private String manufacturerName; private String manufacturerName;

View File

@ -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.ParameterPageForm;
import com.xdap.self_development.controller.form.UpdateParameterForm; import com.xdap.self_development.controller.form.UpdateParameterForm;
import com.xdap.self_development.pojo.Parameter; import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.view.ParametersView;
import com.xdap.self_development.pojo.view.TemplateInfoView; import com.xdap.self_development.pojo.view.TemplateInfoView;
import java.util.List;
public interface ParameterService { public interface ParameterService {
MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form); MyPageResult<Parameter> getParameterByCondition(ParameterPageForm form);
TemplateInfoView maintenanceParameters(UpdateParameterForm form); TemplateInfoView maintenanceParameters(UpdateParameterForm form);
List<ParametersView> getAllParameters(String subsystem);
} }

View File

@ -135,7 +135,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
public PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) { public PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
PageQueryResult<TodoAndReportView> result = bd.getBusinessDatabase() PageQueryResult<TodoAndReportView> result = bd.getBusinessDatabase()
.viewQueryMode(true) .viewQueryMode(true)
.view("getAllReportApproval") .view("getAllReport")
.setVar("title", form.getTitle()) .setVar("title", form.getTitle())
.setVar("manufacturerName", form.getManufacturerName()) .setVar("manufacturerName", form.getManufacturerName())
.setVar("modelName", form.getModelName()) .setVar("modelName", form.getModelName())
@ -172,6 +172,13 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
.eq("id", form.getReportId()) .eq("id", form.getReportId())
.doQueryFirst(BenchmarkingReport.class); .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(); ApprovalFlow flow = new ApprovalFlow();
flow.setTemplateId(report.getId()); flow.setTemplateId(report.getId());
flow.setCurrentNode("PROOFREAD"); flow.setCurrentNode("PROOFREAD");
@ -186,6 +193,11 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
flow.setExplanation(form.getExplanation()); flow.setExplanation(form.getExplanation());
bd.getBusinessDatabase().doInsert(flow); bd.getBusinessDatabase().doInsert(flow);
bd.getBusinessDatabase()
.eq("id", report.getId())
.update("status", "APPROVING")
.doUpdate(BenchmarkingReport.class);
List<TodoTaskPojo> list = new ArrayList<>(); List<TodoTaskPojo> list = new ArrayList<>();
for (String person : form.getProofreadUsers()) { for (String person : form.getProofreadUsers()) {
TodoTaskPojo todoTask = new TodoTaskPojo(); TodoTaskPojo todoTask = new TodoTaskPojo();
@ -288,7 +300,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
ApprovalFlowView approvalFlowView = new ApprovalFlowView(); ApprovalFlowView approvalFlowView = new ApprovalFlowView();
ApprovalFlow flow = bd.getBusinessDatabase() ApprovalFlow flow = bd.getBusinessDatabase()
.eq("id", flowId) .eq("id", flowId)
.eq("flow_type", 1) .eq("flow_type", 2)
.doQueryFirst(ApprovalFlow.class); .doQueryFirst(ApprovalFlow.class);
if (flowId == null || flowId.isEmpty() || flow == null) { if (flowId == null || flowId.isEmpty() || flow == null) {

View File

@ -12,7 +12,6 @@ import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.RevisionRecord; import com.xdap.self_development.pojo.RevisionRecord;
import com.xdap.self_development.pojo.Template; import com.xdap.self_development.pojo.Template;
import com.xdap.self_development.pojo.TemplateAndParameter; 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.pojo.view.TemplateInfoView;
import com.xdap.self_development.service.ParameterService; import com.xdap.self_development.service.ParameterService;
import com.xdap.self_development.utils.FormulaValidator; import com.xdap.self_development.utils.FormulaValidator;
@ -163,15 +162,6 @@ public class ParameterServiceImpl implements ParameterService {
} }
} }
@Override
public List<ParametersView> getAllParameters(String subsystem) {
return bd.getBusinessDatabase()
.viewQueryMode(true)
.view("getAllParameters")
.setVar("subsystem", subsystem)
.doQuery(ParametersView.class);
}
private TemplateBenchmark getTemplateBenchmark(String templateRowId) { private TemplateBenchmark getTemplateBenchmark(String templateRowId) {
// 基准模板用户选择的要比较的版本 // 基准模板用户选择的要比较的版本
Template baseTemplate = bd.getBusinessDatabase() Template baseTemplate = bd.getBusinessDatabase()