66924 认证清单-新增、调取增加唯一校验,与当前项目库法规清单法规编号对比校验。

This commit is contained in:
wangzhijiang
2023-03-27 16:08:19 +08:00
parent 1c084fffa1
commit eafadad14f
2 changed files with 135 additions and 15 deletions
@@ -226,4 +226,12 @@ public interface IProjectCertificationInventoryEOService extends IService<Projec
* @param userInfoList
*/
void sendMessageByTemplateId(List<ProjectCertificationInventoryEO> projectCertificationInventoryEOS,String templeteId,List<String> userIdList,List<SysUser> userInfoList);
/**
* 数据唯一校验。
* @param projectCertificationInventoryEOList
* @param cut
* @return
*/
List<ProjectCertificationInventoryEO> dataUniqueCheck(List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList, String cut,List<String> result);
}
@@ -128,6 +128,8 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
private BussDocumentLibraryEOMapper bussDocumentLibraryEOMapper;
@Autowired
private IProjectUserPermissionService projectUserPermissionService;
@Autowired
private IProjectLawsInventoryEOService projectLawsInventoryEOService;
@Value(value = "${jero.backUrl}")
@@ -292,12 +294,20 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
@Override
public Result<?> batchAdd(JSONObject json) {
String cut = json.getString("cut");
List<String> 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<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
ProjectCertificationInventoryEO projectCertificationInventoryEO = null;
@@ -310,13 +320,15 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
projectCertificationInventoryEO.setFlowStatus(CertificationInventoryFlowStatusEnum.LIST_TO_BE_RELEASED.getValue());
projectCertificationInventoryEOList.add(projectCertificationInventoryEO);
}
// 处理提示信息, 类别+检验项目+配置项+编号+责任领域 作为唯一检验
List<ProjectCertificationInventoryEO> 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<ProjectCertificationInventoryLogEO> 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<Proj
}catch (Exception ex){
throw new JeroBootException("添加失败!");
}
return Result.OK("添加成功!");
return Result.OK(result);
}
@Override
@@ -477,6 +489,61 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
}
}
/**
* 处理提示信息
* @param projectCertificationInventoryEOList
* @param cut
* @param result
*/
@Override
public List<ProjectCertificationInventoryEO> dataUniqueCheck(List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList, String cut,List<String> result) {
List<ProjectCertificationInventoryEO> pciSaveList = new ArrayList<>();
List<ProjectCertificationInventoryEO> allDataList = this.list();
// 重复数据数组
List<ProjectCertificationInventoryEO> 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<ProjectCertificationInventoryEO> datas, String cut) {
if(CollectionUtils.isNotEmpty(datas)){
@@ -2585,6 +2652,14 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
@Override
public Result<?> callAdd(JSONObject json) {
String cut = json.getString("cut");
List<String> 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<Proj
List<AuthDummyInventoryInfoEO> authDummyInventoryInfoEOList = this.authDummyInventoryInfoEOService.list(authDummyInfoQueryWrap);
if(CollectionUtils.isNotEmpty(authDummyInventoryInfoEOList)){
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
for (AuthDummyInventoryInfoEO authDummyInventoryInfoEO : authDummyInventoryInfoEOList) {
ProjectCertificationInventoryEO projectCertificationInventoryEOTemp = new ProjectCertificationInventoryEO();
BeanUtils.copyProperties(authDummyInventoryInfoEO,projectCertificationInventoryEOTemp);
QueryWrapper<ProjectLawsInventoryEO> lawsInventoryEOQueryWrap = new QueryWrapper<>();
lawsInventoryEOQueryWrap.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId);
List<ProjectLawsInventoryEO> 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<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = new ArrayList<>();
List<String> noSerialNumberList = new ArrayList<>();
for (AuthDummyInventoryInfoEO authDummyInventoryInfoEO : authDummyInventoryInfoEOList) {
if(CollectionUtils.isEmpty(projectLawsInventoryEOList)){
break;
}
// 根据选择调取的数据法规编号,跟当前项目中 法规清单数据法规编号对比,如果有,则加入,如果没有,则不加入。
List<ProjectLawsInventoryEO> 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<ProjectCertificationInventoryEO> saveDataList = this.dataUniqueCheck(projectCertificationInventoryEOList, cut, result);
this.saveBatch(saveDataList);
Date now = new Date();
//设置权限 先删后加
List<ProjectUserPermission> 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<Proj
}
}
return Result.OK("调取成功!");
return Result.OK(result);
}
/**