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

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 = {
@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)
@Data

View File

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

View File

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

View File

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