添加判空

This commit is contained in:
zhn
2023-09-21 14:27:45 +08:00
parent 37473c03f1
commit ea804a0ce8
@@ -6870,75 +6870,77 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
wrapper1.in(ProjectCertificationInventoryEO::getProjectLibraryId,Arrays.asList(projectLibraryIds.split(",")));
List<ProjectCertificationInventoryEO> certificationInventoryEOS = this.list(wrapper1);
//平台件项目信息
List<ProjectLibraryBase> projectLibraryBaseList = new ArrayList<>();
if(!certificationInventoryEOList.isEmpty()){
List<String> projectIdList = certificationInventoryEOS.stream().map(ProjectCertificationInventoryEO::getProjectLibraryId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<ProjectLibraryBase> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.in(ProjectLibraryBase::getId,projectIdList);
projectLibraryBaseList = projectLibraryBaseService.list(wrapper2);
}
List<LawsInventoryPlatformEO> lawsInventoryPlatformEOS = new ArrayList<>();
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) {
//类别
String category = projectCertificationInventoryEO.getCategory();
//检验项目
String inspectionItem = projectCertificationInventoryEO.getInspectionItem();
//配置项
String configItem = projectCertificationInventoryEO.getConfigItem();
//编号
String serialNumber = projectCertificationInventoryEO.getSerialNumber();
//责任领域
String dutyTerritory = projectCertificationInventoryEO.getDutyTerritory();
List<ProjectCertificationInventoryEO> result = new ArrayList<>();
//如果车型项目库中的配置项为空或为标配时不去匹配直接关联
if(StringUtils.isBlank(configItem) || "标配".equals(configItem)){
if(!certificationInventoryEOS.isEmpty()){
result = setData(certificationInventoryEOS, projectCertificationInventoryEO);
}
}else if(StringUtils.isNotBlank(configItem) && !"标配".equals(configItem)){
//如果车型项目库中的配置项不为空且不为标配时如果车型项目库认证清单的配置项与平台件认证清单的配置项不一致则不再匹配
//如果一致则用类别检验项目编号责任领域去做匹配
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOS = new ArrayList<>();
for (int i = 0; i < certificationInventoryEOS.size(); i++) {
int finalI = i;
List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseList.stream()
.filter(e -> certificationInventoryEOS.get(finalI).getProjectLibraryId().equals(e.getId())).collect(Collectors.toList());
//平台件项目库中的认证清单的配置项为平台件项目名称
String configItemTemp = "";
if(!libraryBaseList.isEmpty()){
//配置项
configItemTemp = libraryBaseList.get(0).getProjectNameId();
}
//类别
String categoryTemp = certificationInventoryEOS.get(i).getCategory();
//检验项目
String inspectionItemTemp = certificationInventoryEOS.get(i).getInspectionItem();
//编号
String serialNumberTemp = certificationInventoryEOS.get(i).getSerialNumber();
//责任领域
String dutyTerritoryTemp = certificationInventoryEOS.get(i).getDutyTerritory();
if(configItem.equals(configItemTemp)
&& category.equals(categoryTemp)
&& inspectionItem.equals(inspectionItemTemp)
&& serialNumber.equals(serialNumberTemp)
&& dutyTerritory.equals(dutyTerritoryTemp)){
projectCertificationInventoryEOS.add(certificationInventoryEOS.get(i));
}
}
if(!projectCertificationInventoryEOS.isEmpty()){
result = setData(projectCertificationInventoryEOS, projectCertificationInventoryEO);
}
if(!certificationInventoryEOS.isEmpty()){
//平台件项目信息
List<ProjectLibraryBase> projectLibraryBaseList = new ArrayList<>();
if(!certificationInventoryEOList.isEmpty()){
List<String> projectIdList = certificationInventoryEOS.stream().map(ProjectCertificationInventoryEO::getProjectLibraryId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<ProjectLibraryBase> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.in(ProjectLibraryBase::getId,projectIdList);
projectLibraryBaseList = projectLibraryBaseService.list(wrapper2);
}
if(!result.isEmpty()){
this.saveOrUpdateBatch(result);
List<LawsInventoryPlatformEO> lawsInventoryPlatformEOS = new ArrayList<>();
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) {
//类别
String category = projectCertificationInventoryEO.getCategory();
//检验项目
String inspectionItem = projectCertificationInventoryEO.getInspectionItem();
//配置项
String configItem = projectCertificationInventoryEO.getConfigItem();
//编号
String serialNumber = projectCertificationInventoryEO.getSerialNumber();
//责任领域
String dutyTerritory = projectCertificationInventoryEO.getDutyTerritory();
List<ProjectCertificationInventoryEO> result = new ArrayList<>();
//如果车型项目库中的配置项为空或为标配时不去匹配直接关联
if(StringUtils.isBlank(configItem) || "标配".equals(configItem)){
if(!certificationInventoryEOS.isEmpty()){
result = setData(certificationInventoryEOS, projectCertificationInventoryEO);
}
}else if(StringUtils.isNotBlank(configItem) && !"标配".equals(configItem)){
//如果车型项目库中的配置项不为空且不为标配时如果车型项目库认证清单的配置项与平台件认证清单的配置项不一致则不再匹配
//如果一致则用类别检验项目编号责任领域去做匹配
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOS = new ArrayList<>();
for (int i = 0; i < certificationInventoryEOS.size(); i++) {
int finalI = i;
List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseList.stream()
.filter(e -> certificationInventoryEOS.get(finalI).getProjectLibraryId().equals(e.getId())).collect(Collectors.toList());
//平台件项目库中的认证清单的配置项为平台件项目名称
String configItemTemp = "";
if(!libraryBaseList.isEmpty()){
//配置项
configItemTemp = libraryBaseList.get(0).getProjectNameId();
}
//类别
String categoryTemp = certificationInventoryEOS.get(i).getCategory();
//检验项目
String inspectionItemTemp = certificationInventoryEOS.get(i).getInspectionItem();
//编号
String serialNumberTemp = certificationInventoryEOS.get(i).getSerialNumber();
//责任领域
String dutyTerritoryTemp = certificationInventoryEOS.get(i).getDutyTerritory();
if(configItem.equals(configItemTemp)
&& category.equals(categoryTemp)
&& inspectionItem.equals(inspectionItemTemp)
&& serialNumber.equals(serialNumberTemp)
&& dutyTerritory.equals(dutyTerritoryTemp)){
projectCertificationInventoryEOS.add(certificationInventoryEOS.get(i));
}
}
if(!projectCertificationInventoryEOS.isEmpty()){
result = setData(projectCertificationInventoryEOS, projectCertificationInventoryEO);
}
}
if(!result.isEmpty()){
this.saveOrUpdateBatch(result);
}
}
}
}