认证清单-关联平台件

This commit is contained in:
zhn
2023-09-21 13:36:44 +08:00
parent a8507c3210
commit 9ca563bc67
@@ -6857,7 +6857,6 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
*/
@Override
public void listPlatform(Map<String,Object> params) {
String cut = (String) params.get("cut");//
String ids = (String) params.get("ids");//认证清单id
String projectLibraryIds = (String) params.get("projectLibraryIds");//平台件项目id
@@ -6882,9 +6881,8 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
List<LawsInventoryPlatformEO> lawsInventoryPlatformEOS = new ArrayList<>();
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) {
Map<String,Object> map = new HashMap<>();
List<ProjectLawsInventoryEO> projectLawsInventoryEOS = new ArrayList<>();
//类别
String category = projectCertificationInventoryEO.getCategory();
//检验项目
@@ -6896,52 +6894,170 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
//责任领域
String dutyTerritory = projectCertificationInventoryEO.getDutyTerritory();
for (ProjectCertificationInventoryEO certificationInventoryEO : certificationInventoryEOS) {
List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseList.stream()
.filter(e -> certificationInventoryEO.getProjectLibraryId().equals(e.getId())).collect(Collectors.toList());
//平台件项目库中的认证清单的配置项为平台件项目名称
String configItemTemp = "";
if(!libraryBaseList.isEmpty()){
//配置项
configItemTemp = libraryBaseList.get(0).getProjectNameId();
List<ProjectCertificationInventoryEO> result = new ArrayList<>();
//如果车型项目库中的配置项为空或为标配时不去匹配直接关联
if(StringUtils.isBlank(configItem) || "标配".equals(configItem)){
if(!certificationInventoryEOS.isEmpty()){
result = setData(certificationInventoryEOS, projectCertificationInventoryEOList, projectCertificationInventoryEO);
}
//类别
String categoryTemp = certificationInventoryEO.getCategory();
//检验项目
String inspectionItemTemp = certificationInventoryEO.getInspectionItem();
//编号
String serialNumberTemp = certificationInventoryEO.getSerialNumber();
//责任领域
String dutyTerritoryTemp = certificationInventoryEO.getDutyTerritory();
}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(StringUtils.isBlank(configItem) || "标配".equals(configItem)){
//如果车型项目库中的配置项为空或为标配时直接将平台件信息添加到关联表
setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO);
}else if(StringUtils.isNotBlank(configItem) && !"标配".equals(configItem)){
//如果车型项目库中的配置项不为空且不为标配时如果车型项目库认证清单的配置项与平台件认证清单的配置项不一致则不再匹配
//如果一致则用类别检验项目编号责任领域去做匹配
if(configItem.equals(configItemTemp)
&& category.equals(categoryTemp)
&& inspectionItem.equals(inspectionItemTemp)
&& serialNumber.equals(serialNumberTemp)
&& dutyTerritory.equals(dutyTerritoryTemp)){
setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO);
projectCertificationInventoryEOS.add(certificationInventoryEOS.get(i));
}
}
if(!projectCertificationInventoryEOS.isEmpty()){
result = setData(certificationInventoryEOS, projectCertificationInventoryEOS, projectCertificationInventoryEO);
this.saveOrUpdateBatch(result);
}
}
}
if(!lawsInventoryPlatformEOS.isEmpty()){
lawsInventoryPlatformEOService.saveBatch(lawsInventoryPlatformEOS);
}
}
private void setData(List<LawsInventoryPlatformEO> lawsInventoryPlatformEOS, ProjectCertificationInventoryEO projectCertificationInventoryEO, ProjectCertificationInventoryEO certificationInventoryEO) {
LawsInventoryPlatformEO inventoryPlatformEO = new LawsInventoryPlatformEO();
inventoryPlatformEO.setCreateTime(new Date());
inventoryPlatformEO.setUpdateTime(new Date());
inventoryPlatformEO.setLawsInventoryId(projectCertificationInventoryEO.getId());
inventoryPlatformEO.setPlatformLawsInventoryId(certificationInventoryEO.getId());
lawsInventoryPlatformEOS.add(inventoryPlatformEO);
private List<ProjectCertificationInventoryEO> setData(List<ProjectCertificationInventoryEO> certificationInventoryEOS,
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList,
ProjectCertificationInventoryEO projectCertificationInventoryEO) {
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOS = new ArrayList<>();
//设置平台件认证清单数据
setProjectCertificationInventoryEO(certificationInventoryEOS.get(0), projectCertificationInventoryEO);
projectCertificationInventoryEOS.add(projectCertificationInventoryEO);
//如果车型项目库中的配置项为空或为标配时不去匹配直接关联此时一对多一指的是车型库认证清单多指的是平台件认证清单
//一条车型库认证清单对应3条平台件认证清单此时需要复制两条项目库认证清单将这两条认证清单中的交付物模板到生产企业名称
//的字段值替换为平台件认证清单的数据原有的那条认证清单这部分数据也需要替换
for (int i = 1; i < certificationInventoryEOS.size(); i++) {
ProjectCertificationInventoryEO certificationInventoryEO = new ProjectCertificationInventoryEO();
BeanUtils.copyProperties(projectCertificationInventoryEO,certificationInventoryEO);
certificationInventoryEO.setId(UUID.randomUUID().toString().replace("-",""));
//设置平台件认证清单数据
setProjectCertificationInventoryEO(certificationInventoryEOS.get(i), certificationInventoryEO);
projectCertificationInventoryEOS.add(certificationInventoryEO);
}
return projectCertificationInventoryEOS;
}
private void setProjectCertificationInventoryEO(ProjectCertificationInventoryEO certificationInventoryEO, ProjectCertificationInventoryEO projectCertificationInventoryEO) {
//交付物模板-deliverableTemplate
projectCertificationInventoryEO.setDeliverableTemplate(certificationInventoryEO.getDeliverableTemplate());
//交付物类型-deliverableType
projectCertificationInventoryEO.setDeliverableType(certificationInventoryEO.getDeliverableType());
//交付结果-deliveryResult
projectCertificationInventoryEO.setDeliveryResult(certificationInventoryEO.getDeliveryResult());
//截止日期-endTime
projectCertificationInventoryEO.setEndTime(certificationInventoryEO.getEndTime());
//流程状态-flowStatus
projectCertificationInventoryEO.setFlowStatus(certificationInventoryEO.getFlowStatus());
//报告编号-reportNumber
projectCertificationInventoryEO.setReportNumber(certificationInventoryEO.getReportNumber());
//产品型号-productModel
projectCertificationInventoryEO.setProductModel(certificationInventoryEO.getProductModel());
//生产企业名称-productionEnterpriseName
projectCertificationInventoryEO.setProductionEnterpriseName(certificationInventoryEO.getProductionEnterpriseName());
}
// public void listPlatform(Map<String,Object> params) {
// String cut = (String) params.get("cut");//
// String ids = (String) params.get("ids");//认证清单id
// String projectLibraryIds = (String) params.get("projectLibraryIds");//平台件项目id
//
// //认证清单数据
// LambdaQueryWrapper<ProjectCertificationInventoryEO> wrapper = new LambdaQueryWrapper<>();
// wrapper.in(ProjectCertificationInventoryEO::getId,Arrays.asList(ids.split(",")));
// List<ProjectCertificationInventoryEO> certificationInventoryEOList = this.list(wrapper);
//
// //平台件项目对应的认证清单数据
// LambdaQueryWrapper<ProjectCertificationInventoryEO> wrapper1 = new LambdaQueryWrapper<>();
// 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<>();
//
// for (ProjectCertificationInventoryEO projectCertificationInventoryEO : certificationInventoryEOList) {
// Map<String,Object> map = new HashMap<>();
// List<ProjectLawsInventoryEO> projectLawsInventoryEOS = new ArrayList<>();
// //类别
// String category = projectCertificationInventoryEO.getCategory();
// //检验项目
// String inspectionItem = projectCertificationInventoryEO.getInspectionItem();
// //配置项
// String configItem = projectCertificationInventoryEO.getConfigItem();
// //编号
// String serialNumber = projectCertificationInventoryEO.getSerialNumber();
// //责任领域
// String dutyTerritory = projectCertificationInventoryEO.getDutyTerritory();
//
// for (ProjectCertificationInventoryEO certificationInventoryEO : certificationInventoryEOS) {
// List<ProjectLibraryBase> libraryBaseList = projectLibraryBaseList.stream()
// .filter(e -> certificationInventoryEO.getProjectLibraryId().equals(e.getId())).collect(Collectors.toList());
// //平台件项目库中的认证清单的配置项为平台件项目名称
// String configItemTemp = "";
// if(!libraryBaseList.isEmpty()){
// //配置项
// configItemTemp = libraryBaseList.get(0).getProjectNameId();
// }
// //类别
// String categoryTemp = certificationInventoryEO.getCategory();
// //检验项目
// String inspectionItemTemp = certificationInventoryEO.getInspectionItem();
// //编号
// String serialNumberTemp = certificationInventoryEO.getSerialNumber();
// //责任领域
// String dutyTerritoryTemp = certificationInventoryEO.getDutyTerritory();
//
// if(StringUtils.isBlank(configItem) || "标配".equals(configItem)){
// //如果车型项目库中的配置项为空或为标配时直接将平台件信息添加到关联表
// setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO);
// }else if(StringUtils.isNotBlank(configItem) && !"标配".equals(configItem)){
// //如果车型项目库中的配置项不为空且不为标配时如果车型项目库认证清单的配置项与平台件认证清单的配置项不一致则不再匹配
// //如果一致则用类别检验项目编号责任领域去做匹配
// if(configItem.equals(configItemTemp)
// && category.equals(categoryTemp)
// && inspectionItem.equals(inspectionItemTemp)
// && serialNumber.equals(serialNumberTemp)
// && dutyTerritory.equals(dutyTerritoryTemp)){
// setData(lawsInventoryPlatformEOS, projectCertificationInventoryEO, certificationInventoryEO);
// }
// }
// }
// }
// if(!lawsInventoryPlatformEOS.isEmpty()){
// lawsInventoryPlatformEOService.saveBatch(lawsInventoryPlatformEOS);
// }
// }
}