子系统列表排序

This commit is contained in:
ys.git 2025-12-11 09:26:55 +08:00
parent c16633143e
commit 88ebc877a1
9 changed files with 210 additions and 13 deletions

View File

@ -55,6 +55,7 @@ public class UserPermissionGetter {
// 获取全部参数权限 // 获取全部参数权限
public List<String> getParamPermissions() { public List<String> getParamPermissions() {
String currentUserId = runtimeAppContextService.getCurrentUserId(); String currentUserId = runtimeAppContextService.getCurrentUserId();
// String currentUserId = "1232";
Set<String> result = new HashSet<>(); Set<String> result = new HashSet<>();
try { try {
// 获取用户权限 // 获取用户权限

View File

@ -0,0 +1,25 @@
package com.xdap.self_development.controller;
import com.definesys.mpaas.common.http.Response;
import com.xdap.self_development.controller.request.AnalysisRequest;
import com.xdap.self_development.pojo.view.AnalysisModelParamterView;
import com.xdap.self_development.service.AnalysisCommonParametersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@RestController
@RequestMapping("/custom/analysis")
public class AnalysisCommonController {
@Autowired
AnalysisCommonParametersService analysisCommonParametersService;
//机型常用返回机型数据
@PostMapping("/selectModelParamByCommon")
public Response selectModelParamByCommon(@RequestBody AnalysisRequest analysisRequest) {
ArrayList<AnalysisModelParamterView> lists = analysisCommonParametersService.selectModelParamByCommon(analysisRequest);
return Response.ok().data(lists);
}
}

View File

@ -0,0 +1,30 @@
package com.xdap.self_development.controller.request;
import com.definesys.mpaas.query.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 待办事项表
* </p>
*
* @author Lys111
* @since 2025-11-18
*/
@Data
public class AnalysisRequest{
/**
* 机型列表
*/
private List<String> modelIds;
//常用参数id
private String commonId;
}

View File

@ -33,6 +33,7 @@ public class Template extends MpaasBasePojo {
private Timestamp createdTime; private Timestamp createdTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Timestamp publishedTime; private Timestamp publishedTime;
private Integer orderNum;
private String createBy; private String createBy;
public Template(String templateName, Integer version, String status, Timestamp createdTime, Timestamp publishedTime, String createBy) { public Template(String templateName, Integer version, String status, Timestamp createdTime, Timestamp publishedTime, String createBy) {

View File

@ -0,0 +1,13 @@
package com.xdap.self_development.pojo.view;
import com.xdap.self_development.pojo.EngineParamDetailPojo;
import lombok.Data;
import java.util.List;
@Data
public class AnalysisModelParamterView {
String modelID;
String modelName;
List<EngineParamDetailPojo> pojos;
}

View File

@ -1,14 +1,18 @@
package com.xdap.self_development.service; package com.xdap.self_development.service;
import com.xdap.self_development.controller.request.AnalysisRequest;
import com.xdap.self_development.controller.request.ApprovalNodeRequest; import com.xdap.self_development.controller.request.ApprovalNodeRequest;
import com.xdap.self_development.pojo.dto.ActivitiDataAndRecordDTO; import com.xdap.self_development.pojo.dto.ActivitiDataAndRecordDTO;
import com.xdap.self_development.pojo.dto.ActivitiDataDTO; import com.xdap.self_development.pojo.dto.ActivitiDataDTO;
import com.xdap.self_development.pojo.dto.HandleApprovalDTO; import com.xdap.self_development.pojo.dto.HandleApprovalDTO;
import com.xdap.self_development.pojo.dto.ShowActivitiDTO; import com.xdap.self_development.pojo.dto.ShowActivitiDTO;
import com.xdap.self_development.pojo.view.AnalysisModelParamterView;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public interface AnalysisCommonParametersService { public interface AnalysisCommonParametersService {
//查询常用参数返回机型数据 //查询常用参数返回机型数据
ArrayList<AnalysisModelParamterView> selectModelParamByCommon(AnalysisRequest analysisRequest);
} }

View File

@ -0,0 +1,74 @@
package com.xdap.self_development.service.impl;
import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
import com.xdap.api.moudle.user.pojo.XdapUsers;
import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.request.AnalysisRequest;
import com.xdap.self_development.controller.request.ModelRolesRequest;
import com.xdap.self_development.controller.request.RolePerJoinRequest;
import com.xdap.self_development.controller.request.UserRoleBindingRequest;
import com.xdap.self_development.enums.ParamPermissionEnum;
import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.pojo.*;
import com.xdap.self_development.pojo.dto.PageResultDTO;
import com.xdap.self_development.pojo.view.AnalysisModelParamterView;
import com.xdap.self_development.pojo.view.MenuParamView;
import com.xdap.self_development.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class AnalysisCommonParametersServiceImpl implements AnalysisCommonParametersService {
@Autowired
BusinessDatabase businessDatabase;
@Autowired
EngineParamDetailService engineParamDetailService;
@Autowired
DataEntryEngineModelService dataEntryEngineModelService;
@Override
public ArrayList<AnalysisModelParamterView> selectModelParamByCommon(AnalysisRequest analysisRequest) {
if (ObjectUtils.isEmpty(analysisRequest.getModelIds()) || ObjectUtils.isEmpty(analysisRequest) || ObjectUtils.isEmpty(analysisRequest.getCommonId())) {
log.warn("analysisRequest is empty");
return null;
}
List<ModelCommonParameters> commons = businessDatabase.getBusinessDatabase()
.eq("common_id", analysisRequest.getCommonId())
.doQuery(ModelCommonParameters.class);
List<String> paramIds = commons.stream().map(x -> x.getParameterId()).collect(Collectors.toList());
if (ObjectUtils.isEmpty(paramIds)) {
return null;
}
ArrayList<AnalysisModelParamterView> analysisModelParamterViews = new ArrayList<>();
//查找每个机型的参数并且根据常用筛选
for (String modelId : analysisRequest.getModelIds()) {
List<EngineParamDetailPojo> pojoListAll = new ArrayList<>();
List<EngineParamDetailPojo> pojoList = engineParamDetailService.selectByModelNewVersion(modelId);
List<EngineParamDetailPojo> pojos = pojoList.stream()
.filter(x -> paramIds.contains(x.getParameterId())).collect(Collectors.toList());
if (ObjectUtils.isNotEmpty(pojos)) {
pojoListAll.addAll(pojos);
}
AnalysisModelParamterView analysisModelParamterView = new AnalysisModelParamterView();
DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(modelId);
analysisModelParamterView.setModelID(modelId);
analysisModelParamterView.setModelName(ObjectUtils.isEmpty(dataEntryEngineModelPojo.getModelName())?"":dataEntryEngineModelPojo.getModelName());
analysisModelParamterView.setPojos(pojoListAll);
analysisModelParamterViews.add(analysisModelParamterView);
}
return analysisModelParamterViews;
}
}

View File

@ -6,10 +6,10 @@ import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.definesys.mpaas.query.MpaasQueryFactory; import com.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.api.moudle.user.pojo.XdapUsers; import com.xdap.api.moudle.user.pojo.XdapUsers;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.controller.request.EngineParamDetailExcel; import com.xdap.self_development.controller.request.EngineParamDetailExcel;
import com.xdap.self_development.controller.request.EngineParamDetailRequest; import com.xdap.self_development.controller.request.EngineParamDetailRequest;
import com.xdap.self_development.enums.CurrentNodeEnum; import com.xdap.self_development.enums.CurrentNodeEnum;
import com.xdap.self_development.enums.DistributeStatusEnum;
import com.xdap.self_development.enums.ParamOperation; import com.xdap.self_development.enums.ParamOperation;
import com.xdap.self_development.enums.ParamValueVersionEnum; import com.xdap.self_development.enums.ParamValueVersionEnum;
import com.xdap.self_development.exception.ExcelImportException; import com.xdap.self_development.exception.ExcelImportException;
@ -53,6 +53,8 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
private XdapDeptUsersService xdapDeptUsersService; private XdapDeptUsersService xdapDeptUsersService;
@Autowired @Autowired
private ResponsiblePerService responsiblePerService; private ResponsiblePerService responsiblePerService;
@Autowired
UserPermissionGetter userPermissionGetter;
private Integer versionNumber = 0; private Integer versionNumber = 0;
private String createdBy = "Excel导入"; private String createdBy = "Excel导入";
@ -67,15 +69,52 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
@Override @Override
public Map<String, List<String>> selectParamList(String modelProName) { public Map<String, List<String>> selectParamList(String modelProName) {
List<Parameter> parameters = selectAllByNewVersion(); List<Parameter> parameters = selectAllByNewVersion();
List<Template> templates =
sw.buildFromDatasource("xdap_app_223770822127386625")
.eq("status", "COMPLETE")
.doQuery(Template.class);
if (ObjectUtils.isEmpty(templates)) {
throw new RuntimeException("未找到未找到已发布的参数模板");
}
//查找每个模板最新版本
Map<String, Template> latestTemplateMap = templates.stream()
// 按模板ID分组
.collect(Collectors.groupingBy(
Template::getTemplateName,
// 每组内按版本号降序取第一个最新版本
Collectors.collectingAndThen(
Collectors.maxBy(Comparator.comparingInt(Template::getVersion)),
Optional::get
)
));
ArrayList<Template> templatesMax = new ArrayList<>(latestTemplateMap.values());
Map<String, Integer> systemOrderMap = templatesMax.stream()
.collect(Collectors.toMap(
Template::getTemplateName, // key: 子系统编码
Template::getOrderNum, // value: 排序号
(oldValue, newValue) -> oldValue
));
Map<String, List<String>> collect = parameters.stream() Map<String, List<String>> collect = parameters.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
Parameter::getSubsystemName, Parameter::getSubsystemName,
Collectors.mapping( Collectors.mapping(
Parameter::getParameterType, // 提取 id 字段 Parameter::getParameterType, // 提取 TYPE 字段
Collectors.toList() Collectors.toList()
) )
)); ));
return collect; Map<String, List<String>> sortedCollect2 = collect.entrySet().stream()
.sorted(Comparator.comparing(entry ->
systemOrderMap.getOrDefault(entry.getKey(), Integer.MAX_VALUE)
))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(oldValue, newValue) -> oldValue,
LinkedHashMap::new // 保持顺序
));
return sortedCollect2;
} }
@ -173,7 +212,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
String engineModelID = engineParamDetailRequest.getEngineModelID(); String engineModelID = engineParamDetailRequest.getEngineModelID();
List<String> subsystemTypes = engineParamDetailRequest.getSubsystemTypes(); List<String> subsystemTypes = engineParamDetailRequest.getSubsystemTypes();
if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes) ) { if (ObjectUtils.isEmpty(engineModelID) || ObjectUtils.isEmpty(subsystemTypes)) {
throw new RuntimeException("传入参数为空,请检查"); throw new RuntimeException("传入参数为空,请检查");
} }
List<EngineParamDetailPojo> detailPojos = new ArrayList<>(); List<EngineParamDetailPojo> detailPojos = new ArrayList<>();
@ -213,12 +252,21 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
.eq("parameter_type", type) .eq("parameter_type", type)
.doQuery(EngineParamDetailPojo.class)); .doQuery(EngineParamDetailPojo.class));
} else { } else {
detailPojos.addAll(sw.buildFromDatasource("xdap_app_223770822127386625") List<EngineParamDetailPojo> pojoList = sw.buildFromDatasource("xdap_app_223770822127386625")
.eq("engine_model_id", engineModelID) .eq("engine_model_id", engineModelID)
.eq("version_status", code) .eq("version_status", code)
.eq("subsystem_name", subsystem) .eq("subsystem_name", subsystem)
.eq("parameter_type", type) .eq("parameter_type", type)
.doQuery(EngineParamDetailPojo.class)); .doQuery(EngineParamDetailPojo.class);
//判断当前用户是否有参数权限
List<String> parameterIds = userPermissionGetter.getParamPermissions();
for (String parameterId : parameterIds) {
List<EngineParamDetailPojo> pojos = pojoList.stream().filter(x -> x.getParameterId().equals(parameterId))
.collect(Collectors.toList());
if (ObjectUtils.isNotEmpty(pojos)) {
detailPojos.addAll(pojos);
}
}
} }
} }
@ -307,7 +355,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
.update("is_delete", 1) .update("is_delete", 1)
.update("last_update_date", new Date()) .update("last_update_date", new Date())
.eq("owner_id", filledBy) .eq("owner_id", filledBy)
.eq("current_node","数据维护") .eq("current_node", "数据维护")
.doUpdate(TodoTaskPojo.class); .doUpdate(TodoTaskPojo.class);
//应该不会有新增参数 要不然还要给参数绑定部门责任人填写人 //应该不会有新增参数 要不然还要给参数绑定部门责任人填写人
@ -321,7 +369,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
// //
// insertDetails.add(ei); // insertDetails.add(ei);
} }
// //
// //
//// ----------------------------------------------------- //// -----------------------------------------------------

View File

@ -149,8 +149,9 @@ public class ModelRoleServiceImpl implements ModelRoleService {
List<MenuParamView> paramViews = new ArrayList<>(); List<MenuParamView> paramViews = new ArrayList<>();
for (ModelDepUserRolePojo userOrDep : userOrDeps) { for (ModelDepUserRolePojo userOrDep : userOrDeps) {
List<MenuParamView> views = selectPersByRole(userOrDep.getRoleId()); List<MenuParamView> views = selectPersByRole(userOrDep.getRoleId());
paramViews.addAll(views); if (ObjectUtils.isNotEmpty(views)) {
paramViews.addAll(views);
}
} }
return paramViews; return paramViews;
} }
@ -231,7 +232,7 @@ public class ModelRoleServiceImpl implements ModelRoleService {
businessDatabase.getBusinessDatabase() businessDatabase.getBusinessDatabase()
.update("is_enable", 0) .update("is_enable", 0)
.eq("role_id", roleId) .eq("role_id", roleId)
.eq("is_dep",isDept) .eq("is_dep", isDept)
.doUpdate(ModelDepUserRolePojo.class); .doUpdate(ModelDepUserRolePojo.class);
} }
for (String userOrDeptId : userRoleBindingRequest.getUserOrDeptIds()) { for (String userOrDeptId : userRoleBindingRequest.getUserOrDeptIds()) {
@ -274,7 +275,7 @@ public class ModelRoleServiceImpl implements ModelRoleService {
for (ModelDepUserRolePojo userRolePojo : userList) { for (ModelDepUserRolePojo userRolePojo : userList) {
String userId = userRolePojo.getUserOrDep(); String userId = userRolePojo.getUserOrDep();
XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId); XdapUsers xdapUsers = xdapDeptUsersService.selectUserByID(userId);
stringsUser.add(xdapUsers.getUsername()+"-"+xdapUsers.getAccount()); stringsUser.add(xdapUsers.getUsername() + "-" + xdapUsers.getAccount());
} }
map.put("人员", stringsUser); map.put("人员", stringsUser);
return map; return map;