Merge remote-tracking branch 'origin/dev_20230912_Platform' into dev_20230912_Platform

This commit is contained in:
zyx.net
2023-10-09 14:11:05 +08:00
2 changed files with 261 additions and 5 deletions
@@ -569,7 +569,7 @@ public class PlatformProjectLawsInventoryEOServiceImpl extends ServiceImpl<Platf
@Override
public void editById(ProjectLawsInventoryEO projectLawsInventoryEO) {
this.editService.editById(projectLawsInventoryEO);
this.editService.editByIdPlatform(projectLawsInventoryEO);
}
/**
@@ -14,8 +14,21 @@ import com.jero.modules.dummy.util.ListDiff;
import com.jero.modules.feishu.enums.TemplateInfoEnum2;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.project.entity.*;
import com.jero.modules.project.enums.*;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectLibraryRoleRelEO;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.entity.ProjectUserPermission;
import com.jero.modules.project.enums.ComplianceFlowStatusEnum;
import com.jero.modules.project.enums.InventoryAffirmNodeEnum;
import com.jero.modules.project.enums.JumpLinkEnum;
import com.jero.modules.project.enums.PermissionDescriptionEnum;
import com.jero.modules.project.enums.ProjectInventoryFieldEnum;
import com.jero.modules.project.enums.ProjectMessageEnum;
import com.jero.modules.project.enums.ProjectRoleEnum;
import com.jero.modules.project.enums.ProjectUserLocationEnum;
import com.jero.modules.project.enums.RoleRelModelTypeEnum;
import com.jero.modules.project.enums.TaskStatusEnum;
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
import com.jero.modules.project.service.IProjectLibraryRoleRelEOService;
import com.jero.modules.project.service.IProjectUserPermissionService;
@@ -43,14 +56,20 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -1248,6 +1267,243 @@ public class ProjectLawsInventoryEOEditServiceImpl {
throw new JeroBootException("该用户没有权限操作该数据!");
}
}
public void editByIdPlatform(ProjectLawsInventoryEO projectLawsInventoryEO) {
Date now = new Date();
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// boolean checkResult = checkData(projectLawsInventoryEO.getProjectLibraryId(), currentUser.getId(), projectLawsInventoryEO.getId());
// if (checkResult) {
QueryWrapper<ProjectLawsInventoryEO> oldPliQueryWrap = new QueryWrapper<>();
oldPliQueryWrap.lambda().eq(ProjectLawsInventoryEO::getId, projectLawsInventoryEO.getId());
List<ProjectLawsInventoryEO> oldPliEoList = projectLawsInventoryEOService.list(oldPliQueryWrap);
this.updateProjectLawsInventorySendMessage(projectLawsInventoryEO);
// 根据法规清单id获取该法规清单在待办中心的任务明细
List<String> oldPliEoIdList = oldPliEoList.stream().map(ProjectLawsInventoryEO::getId).distinct().collect(Collectors.toList());
QueryWrapper<ProcessInfoDetailEO> pidEoQueryWrap = new QueryWrapper<>();
pidEoQueryWrap.lambda().in(ProcessInfoDetailEO::getProjectLawsInventoryId, oldPliEoIdList);
List<ProcessInfoDetailEO> pidEoList = this.processInfoDetailEOService.list(pidEoQueryWrap);
if (CollectionUtils.isNotEmpty(pidEoList)) {
// 处理编辑法规工程师的逻辑
this.updateRegulationOwner(projectLawsInventoryEO, oldPliEoList, pidEoList);
// 处理编辑责任人的逻辑
this.updateDutyPerson(projectLawsInventoryEO, oldPliEoList, pidEoList);
}
// 处理修改设计或验证符合性截止日期的逻辑
this.updateDesignOrVerifyEndTime(projectLawsInventoryEO, oldPliEoList);
projectLawsInventoryEO.setUpdateTime(now);
ProjectLawsInventoryEO projectLawsInventoryEOCopy = SerializationUtils.clone(projectLawsInventoryEO);//复制
//更新log
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String username = sysUser.getUsername();
String contentLog = username + "编辑了清单中的“" + projectLawsInventoryEO.getSerialNumber() + "”:</br>";
String enContentLog = username + " edited the “" + projectLawsInventoryEO.getSerialNumber() + "” in the list:</br>";
List<ProjectLawsInventoryEO> infoEOList = new ArrayList<>();
infoEOList.add(projectLawsInventoryEO);
List<ProjectLawsInventoryEO> infoEOListCopy = new ArrayList<>();
infoEOListCopy.add(projectLawsInventoryEOCopy);
//查询数据库里原来的数据
QueryWrapper<ProjectLawsInventoryEO> queryWrapper = new QueryWrapper<>();
List<ProjectLawsInventoryEO> dataList = projectLawsInventoryEOService.list(queryWrapper.eq("id", projectLawsInventoryEO.getId()));
List<ProjectLawsInventoryEO> dataListCopy = DeepCopyListUtil.depCopy(dataList);
LambdaUpdateWrapper<ProjectLawsInventoryEO> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(ProjectLawsInventoryEO::getId, projectLawsInventoryEO.getId());
setDateNull(projectLawsInventoryEO, updateWrapper);
//保存
projectLawsInventoryEOService.update(projectLawsInventoryEO, updateWrapper);
// saveOrUpdate(projectLawsInventoryEO);
//获取编辑中的责任领域
List<String> dutyTerritoryList = new ArrayList<>();
dutyTerritoryList = Arrays.asList(projectLawsInventoryEO.getDutyTerritory().split(","));
dutyTerritoryList = dutyTerritoryList.stream().distinct().collect(Collectors.toList());
//获取当前的projectLibrartId
String projectLibrartId = projectLawsInventoryEO.getProjectLibraryId();
String cut = projectLawsInventoryEO.getCut();
Map<String, Object> params = new HashMap<>();
params.put("projectLibraryId", projectLibrartId);
params.put("userId", currentUser.getId());
params.put("modelType", RoleRelModelTypeEnum.LAWS_INVENTORY.getValue());
ProjectLibraryRoleRelEO projectLibraryRoleRelEO = projectLibraryRoleRelEOService.queryByProjectLibraryIdAndUserId(params);
String roleCode1 = projectLibraryRoleRelEO.getRoleCode();
//分别获取当前编辑中的设计符合性和认证符合性责任人
List<String> designDutyIdList = new ArrayList<>();
designDutyIdList = Arrays.asList(projectLawsInventoryEO.getDesignDutyId().split(","));
List<String> verifyDutyIdList = new ArrayList<>();
verifyDutyIdList = Arrays.asList(projectLawsInventoryEO.getVerifyDutyId().split(","));
//allDutyList 为法规工程师中验证符合性和确认符合中的责任人
List<String> allDutyList = new ArrayList<>();
allDutyList.addAll(designDutyIdList);
allDutyList.addAll(verifyDutyIdList);
allDutyList = allDutyList.stream().distinct().collect(Collectors.toList());
//获取相关责任领域下的和projectLibrartId的相关人员名单的信息
List<ProjectRelatedPersonnel> projectRelatedPersonnelList = projectRelatedPersonnelService.queryByProjectIdAndDutyTerritoy(projectLibrartId, dutyTerritoryList);
List<String> allList = new ArrayList<>();
List<String> enginnerList = new ArrayList<>();
List<String> lawEnginnerList = new ArrayList<>();
List<String> enginnerLawSetList = new ArrayList<>();
List<String> enginnerAttSetList = new ArrayList<>();
//根据相关人员名单获取的工程接口人
for (ProjectRelatedPersonnel relatedPersonnel : projectRelatedPersonnelList) {
String enginneringInterfacePerson = relatedPersonnel.getEngineeringInterfacePerson();
if (!StringUtils.isEmpty(enginneringInterfacePerson)) {
enginnerList = Arrays.stream(enginneringInterfacePerson.split(",")).collect(Collectors.toList());
allList.addAll(enginnerList);
}
}
//获取相关人员名单中的法规工程师
for (ProjectRelatedPersonnel relatedPersonnel : projectRelatedPersonnelList) {
String lawEngineer = relatedPersonnel.getLawEngineer();
if (!StringUtils.isEmpty(lawEngineer)) {
lawEnginnerList = Arrays.stream(lawEngineer.split(",")).collect(Collectors.toList());
allList.addAll(lawEnginnerList);
}
}
//获取相关人员名单中的工程接口-法规工程师设置
for (ProjectRelatedPersonnel relatedPersonnel : projectRelatedPersonnelList) {
String engineerLawSet = relatedPersonnel.getEngineerLawSet();
if (!StringUtils.isEmpty(engineerLawSet)) {
enginnerLawSetList = Arrays.stream(engineerLawSet.split(",")).collect(Collectors.toList());
allList.addAll(enginnerLawSetList);
}
}
//获取相关人员名单中的工程接口-认证工程师设置
for (ProjectRelatedPersonnel relatedPersonnel : projectRelatedPersonnelList) {
String engineerAttSet = relatedPersonnel.getEngineerAttSet();
if (!StringUtils.isEmpty(engineerAttSet)) {
enginnerAttSetList = Arrays.stream(engineerAttSet.split(",")).collect(Collectors.toList());
allList.addAll(enginnerAttSetList);
}
}
//获取当前项目库id的studio工程师和认证工程师
List<String> studionList = new ArrayList<>();
List<String> certificationEngineerList = new ArrayList<>();
List<ProjectLibraryBase> projectLibraryBases = projectLibraryBaseService.queryById(projectLibrartId, cut);
for (ProjectLibraryBase projectLibraryBase : projectLibraryBases) {
studionList.add(projectLibraryBase.getStudioEngineer());
String certificationEngineer = projectLibraryBase.getCertificationEngineer();
if (!StringUtils.isEmpty(certificationEngineer)) {
certificationEngineerList = Arrays.stream(certificationEngineer.split(",")).collect(Collectors.toList());
allList.addAll(certificationEngineerList);
}
}
allList = allList.stream().filter(all -> {
return StringUtils.isNotBlank(all);
}).distinct().collect(Collectors.toList());
/*
for(String all : allList){
if(all.equals("")){
allList.remove(all);
}
}
*/
//遍历所有人alllist中是否包含责任人,如果包含不用操作
//-------如果不包含,再去判断当前用户的角色是studio法规还是认证
for (ProjectRelatedPersonnel relatedPersonnel : projectRelatedPersonnelList) {
if (allList.size() > 0) {
for (String allDuty : allDutyList) {
String dutyPerson = allDuty;
if (StringUtils.isNotEmpty(dutyPerson) && !allList.contains(dutyPerson) && StringUtils.isNotEmpty(roleCode1)) {
if (roleCode1.equals(com.jero.modules.project.enums.ProjectRoleEnum.STUDIO_ENGINEER.getValue())) {
if (relatedPersonnel.getEngineeringInterfacePerson() != null) {
String engineeringInterfacePerson = dutyPerson + "," + relatedPersonnel.getEngineeringInterfacePerson();
relatedPersonnel.setEngineeringInterfacePerson(engineeringInterfacePerson);
} else {
relatedPersonnel.setEngineeringInterfacePerson(dutyPerson);
}
} else if (roleCode1.equals(com.jero.modules.project.enums.ProjectRoleEnum.REGULATI_ENGINEER.getValue())) {
if (relatedPersonnel.getEngineerLawSet() != null) {
String engineerLawSet = dutyPerson + "," + relatedPersonnel.getEngineerLawSet();
relatedPersonnel.setEngineerLawSet(engineerLawSet);
} else {
relatedPersonnel.setEngineerLawSet(dutyPerson);
}
} else if (roleCode1.equals(com.jero.modules.project.enums.ProjectRoleEnum.HOMOLOGATION_ENGINEER.getValue())) {
if (relatedPersonnel.getEngineerAttSet() != null) {
String engineerAttSet = dutyPerson + "," + relatedPersonnel.getEngineerAttSet();
relatedPersonnel.setEngineerAttSet(engineerAttSet);
} else {
relatedPersonnel.setEngineerAttSet(dutyPerson);
}
}
}
}
}
}
this.projectRelatedPersonnelService.updateBatchById(projectRelatedPersonnelList);
//翻译-中文
translateData(infoEOList);
translateData(dataList);
//翻译-英文
translateDataToEn(infoEOListCopy);
translateDataToEn(dataListCopy);
//比对不同字段
Map<String, String> infoDiff = ListDiff.compareObject(dataList.get(0), projectLawsInventoryEO);
Map<String, String> infoDiffEn = ListDiff.compareObject(dataListCopy.get(0), projectLawsInventoryEOCopy);
//设置更新log
setContentLog(infoDiff, contentLog, infoDiffEn, enContentLog, projectLawsInventoryEO.getProjectLibraryId());
//验证用户是否是该法规上级 项目库的studio 如果是则同步更新流程
int roleCode = projectLawsInventoryEOService.checkUserRole(projectLawsInventoryEO.getProjectLibraryId(), currentUser.getId(), "");
if (StringUtils.equals(String.valueOf(roleCode), ProjectRoleEnum.STUDIO_ENGINEER.getValue())) {
//更新流程信息
projectLawsInventoryEOService.updateFlowInfo(projectLawsInventoryEO);
}
//设置权限 先删后加
List<ProjectUserPermission> adds = new ArrayList<>();
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getRegulationOwnerId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getRegulationOwnerId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_REGULATION.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getHomologationEngineerId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getHomologationEngineerId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_HOMOLOGATION.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getEngineeringInterfacePerson())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getEngineeringInterfacePerson(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_INTERFACE.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getDesignInitiatorId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getDesignInitiatorId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_DESIGN_INITIATOR.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getDesignDutyId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getDesignDutyId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_DESIGN_DUTY.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getPrehomoInitiatorId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getPrehomoInitiatorId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_PREHOMO_INITIATOR.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getPrehomoDutyId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getPrehomoDutyId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_PREHOMO_DUTY.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getVerifyInitiatorId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getVerifyInitiatorId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_VERIFY_INITIATOR.getValue());
}
if (ObjectUtils.isNotEmpty(projectLawsInventoryEO.getVerifyDutyId())) {
setProjectLawsInventoryPermission(projectLawsInventoryEO.getVerifyDutyId(), projectLawsInventoryEO.getProjectLibraryId(), projectLawsInventoryEO.getId(), now, adds, ProjectUserLocationEnum.PROJECT_LAWS_INVENTORY_VERIFY_DUTY.getValue());
}
if (ObjectUtils.isNotEmpty(adds)) {
projectUserPermissionService.saveBatch(adds);
}
// }
// else {
// throw new JeroBootException("该用户没有权限操作该数据!");
// }
}
/**
* 发送消息