修改:常用参数确实导致的空列表问题

This commit is contained in:
zjh 2025-12-25 15:52:33 +08:00
parent 54d8a3e2e1
commit d8c331f7d6
4 changed files with 81 additions and 70 deletions

View File

@ -11,7 +11,7 @@ import java.sql.Timestamp;
@SQLQuery(value = { @SQLQuery(value = {
@SQL(view = "getReportById", @SQL(view = "getReportById",
sql = "SELECT ymbr.series, ymbr.id, ymbr.title, ymbr.manufacturer_name, ymbr.model_name, ymbr.module , ymbr.manufacturer_abbreviation, ymbr.model_abbreviation, ymbr.product_number, ymbr.plate, ymbr.platform , ymbr.market_segment, ymbr.project_name, ymbr.project_number, ymbr.upload_time, ymbr.file_path , ymbr.status, xu.username AS create_by FROM yfsjglpt_model_benchmarking_report ymbr LEFT JOIN xdap_users xu ON xu.id = ymbr.create_by where ymbr.id = #reportId") sql = "SELECT ymbr.series, ymbr.id, ymbr.title, ymbr.manufacturer_name, ymbr.model_name, ymbr.module , ymbr.manufacturer_abbreviation, ymbr.model_abbreviation, ymbr.product_number, ymbr.plate, ymbr.platform , ymbr.market_segment, ymbr.project_name, ymbr.project_number, ymbr.upload_time, ymbr.file_path , ymbr.status, ymbr.file_name, xu.username AS create_by FROM yfsjglpt_model_benchmarking_report ymbr LEFT JOIN xdap_users xu ON xu.id = ymbr.create_by where ymbr.id = #reportId")
}) })
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data

View File

@ -198,12 +198,13 @@ public class CommonParameterServiceImpl implements CommonParameterService {
private List<ModelCommon> convertToModelCommonList( private List<ModelCommon> convertToModelCommonList(
List<ModelCommonParameters> paramsList, List<CommonParameter> commonParameters List<ModelCommonParameters> paramsList, List<CommonParameter> commonParameters
) { ) {
if (paramsList == null || paramsList.isEmpty()) { Map<String, List<ModelCommonParameters>> groupedByCommonId = new HashMap<>();
return new ArrayList<>(); if (paramsList != null && !paramsList.isEmpty()) {
groupedByCommonId = paramsList.stream()
.filter(param -> param.getCommonId() != null) // 过滤掉 commonId null 的参数
.collect(Collectors.groupingBy(ModelCommonParameters::getCommonId));
} }
Map<String, List<ModelCommonParameters>> groupedByCommonId = paramsList.stream()
.filter(param -> param.getCommonId() != null) // 过滤掉 commonId null 的参数
.collect(Collectors.groupingBy(ModelCommonParameters::getCommonId));
List<ModelCommon> result = new ArrayList<>(); List<ModelCommon> result = new ArrayList<>();
for (CommonParameter commonParameter : commonParameters) { for (CommonParameter commonParameter : commonParameters) {
String commonId = commonParameter.getId(); String commonId = commonParameter.getId();
@ -211,35 +212,37 @@ public class CommonParameterServiceImpl implements CommonParameterService {
continue; continue;
} }
List<ModelCommonParameters> commonParams = groupedByCommonId.get(commonId); List<ModelCommonParameters> commonParams = groupedByCommonId.get(commonId);
if (commonParams == null || commonParams.isEmpty()) {
continue;
}
ModelCommon modelCommon = new ModelCommon(); ModelCommon modelCommon = new ModelCommon();
modelCommon.setCommonName(commonParameter.getCommonName()); modelCommon.setCommonName(commonParameter.getCommonName());
modelCommon.setCommonId(commonId); modelCommon.setCommonId(commonId);
Map<String, List<ModelCommonParameters>> groupedBySubsystem = commonParams.stream()
.filter(param -> param.getSubsystemName() != null) // 过滤掉 subsystemName null 的参数 if (commonParams == null || commonParams.isEmpty()) {
.collect(Collectors.groupingBy(ModelCommonParameters::getSubsystemName)); // 即使没有参数也返回一个空的子系统列表
if (groupedBySubsystem.isEmpty()) { modelCommon.setSubsystems(new ArrayList<>());
continue; } else {
Map<String, List<ModelCommonParameters>> groupedBySubsystem = commonParams.stream()
.filter(param -> param.getSubsystemName() != null) // 过滤掉 subsystemName null 的参数
.collect(Collectors.groupingBy(ModelCommonParameters::getSubsystemName));
List<ModelCommonItem> items = new ArrayList<>();
for (Map.Entry<String, List<ModelCommonParameters>> subsystemEntry : groupedBySubsystem.entrySet()) {
ModelCommonItem item = new ModelCommonItem();
item.setSubsystem(subsystemEntry.getKey());
List<ParametersView> parameters = subsystemEntry.getValue().stream()
.map(param -> new ParametersView(
param.getParameterId(),
param.getParameterName(),
param.getParameterType(),
param.getSubsystemName(),
param.getPartsName()
))
.collect(Collectors.toList());
item.setParameters(parameters);
items.add(item);
}
modelCommon.setSubsystems(items);
} }
List<ModelCommonItem> items = new ArrayList<>();
for (Map.Entry<String, List<ModelCommonParameters>> subsystemEntry : groupedBySubsystem.entrySet()) {
ModelCommonItem item = new ModelCommonItem();
item.setSubsystem(subsystemEntry.getKey());
List<ParametersView> parameters = subsystemEntry.getValue().stream()
.map(param -> new ParametersView(
param.getParameterId(),
param.getParameterName(),
param.getParameterType(),
param.getSubsystemName(),
param.getPartsName()
))
.collect(Collectors.toList());
item.setParameters(parameters);
items.add(item);
}
modelCommon.setSubsystems(items);
result.add(modelCommon); result.add(modelCommon);
} }
return result; return result;

View File

@ -83,45 +83,45 @@ public class TemplateServiceImpl implements TemplateService {
.doQueryFirst(Template.class); .doQueryFirst(Template.class);
if (template != null) { if (template != null) {
if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) { // if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
List<Long> sorted = bd.getBusinessDatabase() // List<Long> sorted = bd.getBusinessDatabase()
.groupBy("order_num") // .groupBy("order_num")
.orderBy("order_num", "desc") // .orderBy("order_num", "desc")
.doQuery(Template.class) // .doQuery(Template.class)
.stream().map(Template::getOrderNum) // .stream().map(Template::getOrderNum)
.collect(Collectors.toList()); // .collect(Collectors.toList());
//
Long num = sorted.get(form.getOrderNum() - 1); // Long num = sorted.get(form.getOrderNum() - 1);
if (num == null) { // if (num == null) {
num = sorted.get(sorted.size() - 1); // num = sorted.get(sorted.size() - 1);
} // }
//
List<String> originalTemplateId = bd.getBusinessDatabase() // List<String> originalTemplateId = bd.getBusinessDatabase()
.eq("order_num", template.getOrderNum()) // .eq("order_num", template.getOrderNum())
.doQuery(Template.class).stream().map(Template::getId) // .doQuery(Template.class).stream().map(Template::getId)
.collect(Collectors.toList()); // .collect(Collectors.toList());
List<String> updateTemplateId = bd.getBusinessDatabase() // List<String> updateTemplateId = bd.getBusinessDatabase()
.eq("order_num", num) // .eq("order_num", num)
.doQuery(Template.class).stream().map(Template::getId) // .doQuery(Template.class).stream().map(Template::getId)
.collect(Collectors.toList()); // .collect(Collectors.toList());
//
if (updateTemplateId.isEmpty()) { // if (updateTemplateId.isEmpty()) {
bd.getBusinessDatabase() // bd.getBusinessDatabase()
.in("id", originalTemplateId) // .in("id", originalTemplateId)
.update("order_num", System.currentTimeMillis()) // .update("order_num", System.currentTimeMillis())
.doUpdate(Template.class); // .doUpdate(Template.class);
} else { // } else {
bd.getBusinessDatabase() // bd.getBusinessDatabase()
.in("id", updateTemplateId) // .in("id", updateTemplateId)
.update("order_num", template.getOrderNum()) // .update("order_num", template.getOrderNum())
.doUpdate(Template.class); // .doUpdate(Template.class);
bd.getBusinessDatabase() // bd.getBusinessDatabase()
.in("id", originalTemplateId) // .in("id", originalTemplateId)
.update("order_num", num) // .update("order_num", num)
.doUpdate(Template.class); // .doUpdate(Template.class);
} // }
return; // return;
} // }
throw new CommonException("不可修改为已有模板"); throw new CommonException("不可修改为已有模板");
} }

View File

@ -385,6 +385,14 @@ FROM yfsjglpt_model_approval_record;
DELETE DELETE
FROM yfsjglpt_model_responsible_person; FROM yfsjglpt_model_responsible_person;
DELETE
FROM yfsjglpt_model_common_parameters;
DELETE
FROM yfsjglpt_common_parameter;
DELETE
FROM yfsjglpt_analysis_common_parameters;
delete delete