|
|
@@ -0,0 +1,113 @@ |
|
|
|
package com.hz.pm.api.open.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hz.pm.api.common.model.constant.ExistsSqlConst; |
|
|
|
import com.hz.pm.api.common.util.BizDateUtil; |
|
|
|
import com.hz.pm.api.common.util.BizUtils; |
|
|
|
import com.hz.pm.api.open.model.po.ReviewPassProjectListPO; |
|
|
|
import com.hz.pm.api.open.model.vo.ReviewPassProjectInfoToMhVO; |
|
|
|
import com.hz.pm.api.open.model.vo.ReferSystemReplaceInfoToMhVO; |
|
|
|
import com.hz.pm.api.open.util.OpenApiCheckSignUtil; |
|
|
|
import com.hz.pm.api.projectlib.entity.MhSystemReplaceInfo; |
|
|
|
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; |
|
|
|
import com.hz.pm.api.projectlib.service.IMhSystemReplaceInfoService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* OpenApiProjectLibManage |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author WendyYang |
|
|
|
* @since 10:22 2024/11/7 |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class OpenApiProjectLibManage { |
|
|
|
|
|
|
|
private final OpenApiCheckSignUtil openApiCheckSignUtil; |
|
|
|
private final IProjectService projectService; |
|
|
|
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; |
|
|
|
private final IMhSystemReplaceInfoService mhSystemReplaceInfoService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取已复核通过的项目列表 |
|
|
|
* |
|
|
|
* @param po 参数 |
|
|
|
* @return 复核通过的项目 |
|
|
|
*/ |
|
|
|
public List<ReviewPassProjectInfoToMhVO> listReviewPassProject(ReviewPassProjectListPO po) { |
|
|
|
openApiCheckSignUtil.checkSign(po.getKey()); |
|
|
|
StringBuilder sql = new StringBuilder(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE) |
|
|
|
.append(" and npsc.event = 'PROJECT_REVIEW_PASS'"); |
|
|
|
if (po.getReviewPassTime() != null) { |
|
|
|
sql.append(String.format(" and npsc.create_on >= '%s'", BizDateUtil.toDateStr(po.getReviewPassTime()))); |
|
|
|
} |
|
|
|
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getProjectCode, Project::getProjectName, Project::getBuildOrgCode, Project::getBuildOrgName) |
|
|
|
.exists(sql.toString()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.notIn(Project::getStage, ProjectStatus.CHANGE.getCode(), ProjectStatus.STOPPED.getCode()) |
|
|
|
.orderByDesc(Project::getCreateOn); |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
if (projects.isEmpty()) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
List<String> projectCodes = CollUtils.fieldList(projects, Project::getProjectCode); |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = systemReplaceInfosService.listByProjectCodes(projectCodes); |
|
|
|
replaceInfos.removeIf(w -> StrUtil.isBlank(w.getSourceSystemId())); |
|
|
|
Map<String, List<MhSystemReplaceInfo>> replaceInfoMap; |
|
|
|
if (!replaceInfos.isEmpty()) { |
|
|
|
List<String> sourceSystemIds = CollUtils.fieldList(replaceInfos, ProjectGovSystemReplaceInfos::getSourceSystemId); |
|
|
|
List<MhSystemReplaceInfo> mhSystemReplaceInfos = mhSystemReplaceInfoService.listByIds(sourceSystemIds); |
|
|
|
Map<String, MhSystemReplaceInfo> mhReplaceInfoMap = CollUtils.listToMap(mhSystemReplaceInfos, MhSystemReplaceInfo::getId); |
|
|
|
replaceInfoMap = replaceInfos.stream() |
|
|
|
.filter(w -> mhReplaceInfoMap.containsKey(w.getSourceSystemId())) |
|
|
|
.collect(Collectors.groupingBy(ProjectGovSystemReplaceInfos::getProjectCode, |
|
|
|
Collectors.mapping(w -> mhReplaceInfoMap.get(w.getSourceSystemId()), Collectors.toList()))); |
|
|
|
} else { |
|
|
|
replaceInfoMap = Collections.emptyMap(); |
|
|
|
} |
|
|
|
|
|
|
|
return projects.stream().map(w -> { |
|
|
|
ReviewPassProjectInfoToMhVO item = new ReviewPassProjectInfoToMhVO(); |
|
|
|
item.setProjectCode(w.getProjectCode()); |
|
|
|
item.setProjectName(w.getProjectName()); |
|
|
|
item.setBuildOrgCode(w.getBuildOrgCode()); |
|
|
|
item.setBuildOrgName(w.getBuildOrgName()); |
|
|
|
List<MhSystemReplaceInfo> replaceInfoList = replaceInfoMap.get(w.getProjectCode()); |
|
|
|
if (replaceInfoList != null) { |
|
|
|
List<ReferSystemReplaceInfoToMhVO> referSystemList = CollUtils.convert(replaceInfoList, |
|
|
|
t -> ReferSystemReplaceInfoToMhVO.builder() |
|
|
|
.id(t.getId()) |
|
|
|
.buildOrgCode(t.getBuildOrgCode()) |
|
|
|
.buildOrgName(t.getBuildOrgName()) |
|
|
|
.systemName(t.getSourceName()) |
|
|
|
.alternativeName(t.getTargetName()) |
|
|
|
.alternativeType(t.getReplaceType()) |
|
|
|
.build()); |
|
|
|
item.setReferSystemList(referSystemList); |
|
|
|
} else { |
|
|
|
item.setReferSystemList(Collections.emptyList()); |
|
|
|
} |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |