From eafadad14f0f669c8c4bd4c700fe36f8ebb5fcdc Mon Sep 17 00:00:00 2001 From: wangzhijiang Date: Mon, 27 Mar 2023 16:08:19 +0800 Subject: [PATCH] =?UTF-8?q?66924=20=E8=AE=A4=E8=AF=81=E6=B8=85=E5=8D=95-?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E8=B0=83=E5=8F=96=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E6=A0=A1=E9=AA=8C=EF=BC=8C=E4=B8=8E=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B9=E7=9B=AE=E5=BA=93=E6=B3=95=E8=A7=84=E6=B8=85?= =?UTF-8?q?=E5=8D=95=E6=B3=95=E8=A7=84=E7=BC=96=E5=8F=B7=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rojectCertificationInventoryEOService.java | 8 + ...ctCertificationInventoryEOServiceImpl.java | 142 ++++++++++++++++-- 2 files changed, 135 insertions(+), 15 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java index 3a6b6e9e9..a9011b79f 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/IProjectCertificationInventoryEOService.java @@ -226,4 +226,12 @@ public interface IProjectCertificationInventoryEOService extends IService projectCertificationInventoryEOS,String templeteId,List userIdList,List userInfoList); + + /** + * 数据唯一校验。 + * @param projectCertificationInventoryEOList + * @param cut + * @return + */ + List dataUniqueCheck(List projectCertificationInventoryEOList, String cut,List result); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java index 0d91c75d2..cc1ad52c3 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java @@ -128,6 +128,8 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl batchAdd(JSONObject json) { + String cut = json.getString("cut"); + List result = new ArrayList<>(); + if(StringUtils.equals(cut,CutEnum.CN.getValue())){ + result.add("添加成功!"); + }else { + result.add("Successfully added!"); + } try { String serialNumber = json.getString("serialNumber"); String wvtaId = json.getString("wvtaId"); String bussDocumentLibraryId = json.getString("bussDocumentLibraryId"); String projectLibraryId = json.getString("projectLibraryId"); + JSONArray dataList = json.getJSONArray("dataList"); List projectCertificationInventoryEOList = new ArrayList<>(); ProjectCertificationInventoryEO projectCertificationInventoryEO = null; @@ -310,13 +320,15 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl saveDataList = this.dataUniqueCheck(projectCertificationInventoryEOList,cut,result); - if(CollectionUtils.isNotEmpty(projectCertificationInventoryEOList)){ - this.saveBatch(projectCertificationInventoryEOList); + if(CollectionUtils.isNotEmpty(saveDataList)){ + this.saveBatch(saveDataList); LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); List projectCertificationInventoryLogEOList = new ArrayList<>(); - for (ProjectCertificationInventoryEO certificationInventoryEO : projectCertificationInventoryEOList) { + for (ProjectCertificationInventoryEO certificationInventoryEO : saveDataList) { StringBuilder contentCnSb = new StringBuilder(); contentCnSb.append("\"").append(currentUser.getUsername()).append("\"").append(" 添加了 "); contentCnSb.append("\"").append(certificationInventoryEO.getCategory()).append("\"").append(" "); @@ -343,7 +355,7 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl dataUniqueCheck(List projectCertificationInventoryEOList, String cut,List result) { + List pciSaveList = new ArrayList<>(); + + List allDataList = this.list(); + // 重复数据数组 + List duplicateDataList = allDataList.stream().filter(data -> { + boolean flag = false; + for (ProjectCertificationInventoryEO projectCertificationInventoryEO : projectCertificationInventoryEOList) { + boolean categoryFlag = StringUtils.equals(projectCertificationInventoryEO.getCategory(), data.getCategory()); + boolean inspectionItemFlag = StringUtils.equals(projectCertificationInventoryEO.getInspectionItem(), data.getInspectionItem()); + boolean configItemFlag = StringUtils.equals(projectCertificationInventoryEO.getConfigItem(), data.getConfigItem()); + boolean serialNumberFlag = StringUtils.equals(projectCertificationInventoryEO.getSerialNumber(), data.getSerialNumber()); + boolean dutyTerritoryFlag = StringUtils.equals(projectCertificationInventoryEO.getDutyTerritory(), data.getDutyTerritory()); + // 类别+检验项目+配置项+编号+责任领域 作为唯一检验 + if(categoryFlag && inspectionItemFlag && configItemFlag && serialNumberFlag && dutyTerritoryFlag){ + flag = true; + } + } + return flag; + }).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(duplicateDataList)){ + if (StringUtils.equals(cut, CutEnum.CN.getValue())) { + result.add("您所选的数据中包含当前项目中已包含的条目信息,已为您过滤添加。"); + }else { + result.add("The data you have selected contains item information already included in the current project, which has been filtered and added for you."); + } + } + + // 过滤重复的数据 + pciSaveList = projectCertificationInventoryEOList.stream().filter(pciEO -> { + boolean flag = true; + for (ProjectCertificationInventoryEO allData : allDataList) { + boolean categoryFlag = StringUtils.equals(pciEO.getCategory(), allData.getCategory()); + boolean inspectionItemFlag = StringUtils.equals(pciEO.getInspectionItem(), allData.getInspectionItem()); + boolean configItemFlag = StringUtils.equals(pciEO.getConfigItem(), allData.getConfigItem()); + boolean serialNumberFlag = StringUtils.equals(pciEO.getSerialNumber(), allData.getSerialNumber()); + boolean dutyTerritoryFlag = StringUtils.equals(pciEO.getDutyTerritory(), allData.getDutyTerritory()); + // 类别+检验项目+配置项+编号+责任领域 作为唯一检验 + if(categoryFlag && inspectionItemFlag && configItemFlag && serialNumberFlag && dutyTerritoryFlag){ + flag = false; + break; + } + } + return flag; + }).collect(Collectors.toList()); + return pciSaveList; + } + @Override public void importDisposeData(List datas, String cut) { if(CollectionUtils.isNotEmpty(datas)){ @@ -2585,6 +2652,14 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl callAdd(JSONObject json) { + String cut = json.getString("cut"); + List result = new ArrayList<>(); + if(StringUtils.equals(cut,CutEnum.CN.getValue())){ + result.add("调取成功!"); + }else { + result.add("Successfully retrieved!"); + } + String authDummyInventoryBaseId = json.getString("authDummyInventoryBaseId"); if(StringUtils.isEmpty(authDummyInventoryBaseId)){ throw new JeroBootException("请选择一个认证虚拟清单进行操作!"); @@ -2602,21 +2677,58 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl authDummyInventoryInfoEOList = this.authDummyInventoryInfoEOService.list(authDummyInfoQueryWrap); if(CollectionUtils.isNotEmpty(authDummyInventoryInfoEOList)){ - List projectCertificationInventoryEOList = new ArrayList<>(); - for (AuthDummyInventoryInfoEO authDummyInventoryInfoEO : authDummyInventoryInfoEOList) { - ProjectCertificationInventoryEO projectCertificationInventoryEOTemp = new ProjectCertificationInventoryEO(); - BeanUtils.copyProperties(authDummyInventoryInfoEO,projectCertificationInventoryEOTemp); + QueryWrapper lawsInventoryEOQueryWrap = new QueryWrapper<>(); + lawsInventoryEOQueryWrap.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId); + List projectLawsInventoryEOList = this.projectLawsInventoryEOService.list(lawsInventoryEOQueryWrap); - projectCertificationInventoryEOTemp.setId(UUID.randomUUID().toString().replace("-", "")); - projectCertificationInventoryEOTemp.setProjectLibraryId(projectLibraryId); - projectCertificationInventoryEOTemp.setFlowStatus(CertificationInventoryFlowStatusEnum.LIST_TO_BE_RELEASED.getValue()); - projectCertificationInventoryEOList.add(projectCertificationInventoryEOTemp); + List projectCertificationInventoryEOList = new ArrayList<>(); + + List noSerialNumberList = new ArrayList<>(); + + for (AuthDummyInventoryInfoEO authDummyInventoryInfoEO : authDummyInventoryInfoEOList) { + if(CollectionUtils.isEmpty(projectLawsInventoryEOList)){ + break; + } + + // 根据选择调取的数据法规编号,跟当前项目中 法规清单数据法规编号对比,如果有,则加入,如果没有,则不加入。 + List lawsInventoryEOListTemp = projectLawsInventoryEOList.stream().filter(lawsInventoryEO -> { + boolean flag = false; + if (StringUtils.equals(authDummyInventoryInfoEO.getSerialNumber(), lawsInventoryEO.getSerialNumber())) { + flag = true; + } + return flag; + }).collect(Collectors.toList()); + + if(CollectionUtils.isNotEmpty(lawsInventoryEOListTemp)){ + ProjectCertificationInventoryEO projectCertificationInventoryEOTemp = new ProjectCertificationInventoryEO(); + BeanUtils.copyProperties(authDummyInventoryInfoEO,projectCertificationInventoryEOTemp); + + projectCertificationInventoryEOTemp.setId(UUID.randomUUID().toString().replace("-", "")); + projectCertificationInventoryEOTemp.setProjectLibraryId(projectLibraryId); + projectCertificationInventoryEOTemp.setFlowStatus(CertificationInventoryFlowStatusEnum.LIST_TO_BE_RELEASED.getValue()); + projectCertificationInventoryEOList.add(projectCertificationInventoryEOTemp); + }else { + noSerialNumberList.add(authDummyInventoryInfoEO.getSerialNumber()); + } } - this.saveBatch(projectCertificationInventoryEOList); + + + if(CollectionUtils.isNotEmpty(noSerialNumberList)){ + // 判断调取的数据中,是否有 在当前项目库法规清单中 没有的编号 + if (StringUtils.equals(cut, CutEnum.CN.getValue())) { + result.add("您所选的数据中包含当前项目中不包含的法规编号信息,已为您过滤添加。"); + }else { + result.add("The data you have selected contains regulatory number information that is not included in the current project, and has been filtered and added for you."); + } + } + + List saveDataList = this.dataUniqueCheck(projectCertificationInventoryEOList, cut, result); + + this.saveBatch(saveDataList); Date now = new Date(); //设置权限 先删后加 List adds = new ArrayList<>(); - for (ProjectCertificationInventoryEO pci: projectCertificationInventoryEOList) { + for (ProjectCertificationInventoryEO pci: saveDataList) { if (ObjectUtils.isNotEmpty(pci.getSdt())) { setProjectCertificationInventoryPermission(pci.getSdt(), pci.getProjectLibraryId(), pci.getId(), now, adds, ProjectUserLocationEnum.PROJECT_CERTIFICATION_INVENTORY_SDT.getValue()); } @@ -2629,7 +2741,7 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl