Merge pull request 'feat(制品库优化): 获取制品列表时若制品来源于流水线需展示相关信息' (#814) from otto/microservices:product_refact into product_refact
This commit is contained in:
commit
5d05da7d03
|
|
@ -129,7 +129,7 @@ public class PmsProductLibraryComponent extends BaseEntity {
|
||||||
this.setIdentifier(composeIds[1]);
|
this.setIdentifier(composeIds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setAttributes(JSONObject.toJSONString(nexusAssetVo));
|
// this.setAttributes(JSONObject.toJSONString(nexusAssetVo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentMavenInputVo toComponentMavenInputVo(PmsProductLibraryRepositories snapshotRepo) {
|
public ComponentMavenInputVo toComponentMavenInputVo(PmsProductLibraryRepositories snapshotRepo) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class ComponentRawInputVo {
|
||||||
@ApiModelProperty(value = "目录:上传文件的目录(例如/path/to/files/)")
|
@ApiModelProperty(value = "目录:上传文件的目录(例如/path/to/files/)")
|
||||||
@NotNull(message = "目录不能为空")
|
@NotNull(message = "目录不能为空")
|
||||||
private String directory;
|
private String directory;
|
||||||
@ApiModelProperty(value = "来源类型(流水线传pipeline,同时在attributes字段中传pipelineName,例如:{'pipeline':'持续集成流水线'})")
|
@ApiModelProperty(value = "来源类型(流水线传pipeline,同时在attributes字段中传pipelineName,例如:{'pipelineName':'持续集成流水线'})")
|
||||||
private String fromType = "common";
|
private String fromType = "common";
|
||||||
|
|
||||||
public String getNexusRepoName() {
|
public String getNexusRepoName() {
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,7 @@ public class NexusResultDataVo {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "默认文件夹")
|
@ApiModelProperty(value = "默认文件夹")
|
||||||
private String defaultDir;
|
private String defaultDir;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "制品来源标签")
|
||||||
|
private String fromTag;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,4 +107,12 @@ public interface PmsProductLibraryComponentMapper {
|
||||||
* @return 制品
|
* @return 制品
|
||||||
*/
|
*/
|
||||||
PmsProductLibraryComponent selectPmsProductLibraryComponentByIdentifier(@Param("repoId") Long repoId, @Param("identifier") String identifier);
|
PmsProductLibraryComponent selectPmsProductLibraryComponentByIdentifier(@Param("repoId") Long repoId, @Param("identifier") String identifier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过assetId列表查询来自流水线的制品
|
||||||
|
*
|
||||||
|
* @param assetIdList assetId列表
|
||||||
|
* @return 来自流水线的制品
|
||||||
|
*/
|
||||||
|
List<PmsProductLibraryComponent> selectComponentListFromPipelineByAssetIdList(@Param("assetIdList") List<String> assetIdList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.microservices.pms.productLibrary.service.impl;
|
package com.microservices.pms.productLibrary.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.microservices.common.core.constant.CacheConstants;
|
import com.microservices.common.core.constant.CacheConstants;
|
||||||
|
|
@ -28,6 +29,7 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -37,6 +39,8 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 制品库-制品Service业务层处理
|
* 制品库-制品Service业务层处理
|
||||||
|
|
@ -66,6 +70,8 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
||||||
private IPmsProductLibraryAsyncService pmsProductLibraryAsyncService;
|
private IPmsProductLibraryAsyncService pmsProductLibraryAsyncService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private DefaultErrorAttributes errorAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询制品库-制品
|
* 查询制品库-制品
|
||||||
|
|
@ -93,12 +99,49 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
||||||
componentSearchVo.setRepositoryName(pmsProductLibraryRepositories.getNexusRepositoriesName());
|
componentSearchVo.setRepositoryName(pmsProductLibraryRepositories.getNexusRepositoriesName());
|
||||||
|
|
||||||
NexusComponentSearchVo<ComponentSearchVo> nexusComponentSearchVo = NexusComponentSearchVo.toRead(componentSearchVo, nexusRequestHelper.getNexusTid());
|
NexusComponentSearchVo<ComponentSearchVo> nexusComponentSearchVo = NexusComponentSearchVo.toRead(componentSearchVo, nexusRequestHelper.getNexusTid());
|
||||||
return nexusRequestHelper.doRequestToJavaObjectList(
|
NexusComponentResultVo<List<NexusResultDataVo>> resultVo = nexusRequestHelper.doRequestToJavaObjectList(
|
||||||
NexusRequestUrl.DO_OPERATION(),
|
NexusRequestUrl.DO_OPERATION(),
|
||||||
JSONObject.from(nexusComponentSearchVo),
|
JSONObject.from(nexusComponentSearchVo),
|
||||||
NexusComponentResultVo.class,
|
NexusComponentResultVo.class,
|
||||||
NexusResultDataVo.class
|
NexusResultDataVo.class
|
||||||
);
|
);
|
||||||
|
if (resultVo.getResult() != null) {
|
||||||
|
List<NexusResultDataVo> dataList = resultVo.getResult().getData();
|
||||||
|
// 提取assetId列表,从数据库中查询来源于流水线的制品
|
||||||
|
List<String> assetIdList = dataList.stream().map(NexusResultDataVo::getAssetId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
if (!assetIdList.isEmpty()) {
|
||||||
|
List<PmsProductLibraryComponent> pmsProductLibraryComponentList = pmsProductLibraryComponentMapper.selectComponentListFromPipelineByAssetIdList(assetIdList);
|
||||||
|
if (!pmsProductLibraryComponentList.isEmpty()) {
|
||||||
|
dataList.forEach(x -> {
|
||||||
|
if (x.getAssetId() != null) {
|
||||||
|
PmsProductLibraryComponent pipelineComponent =
|
||||||
|
pmsProductLibraryComponentList.stream().filter(component -> x.getAssetId().equals(component.getIdentifier())).findFirst().orElse(null);
|
||||||
|
if (pipelineComponent != null) {
|
||||||
|
String attributes = pipelineComponent.getAttributes();
|
||||||
|
if (JSON.isValid(attributes)) {
|
||||||
|
JSONObject attributesJson = JSONObject.parseObject(attributes);
|
||||||
|
|
||||||
|
String repository = attributesJson.getString("repository");
|
||||||
|
String repositoryDes = null;
|
||||||
|
if (StringUtils.isNotEmpty(repository)) {
|
||||||
|
repositoryDes = String.format("【%s】仓库的", repository);
|
||||||
|
}
|
||||||
|
String pipelineName = attributesJson.getString("pipelineName");
|
||||||
|
String pipelineNameDes = null;
|
||||||
|
if (StringUtils.isNotEmpty(pipelineName)) {
|
||||||
|
pipelineNameDes = String.format("【%s】", pipelineName);
|
||||||
|
}
|
||||||
|
String fromTag = String.format("由%s%s流水线生成", repositoryDes, pipelineNameDes);
|
||||||
|
x.setFromTag(fromTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -487,6 +530,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
||||||
success += insertPmsProductLibraryComponent(pmsProductLibraryComponent);
|
success += insertPmsProductLibraryComponent(pmsProductLibraryComponent);
|
||||||
pmsProductLibraryComponents.set(i, pmsProductLibraryComponent);
|
pmsProductLibraryComponents.set(i, pmsProductLibraryComponent);
|
||||||
}
|
}
|
||||||
|
pmsProductLibraryAsyncService.syncNexusMavenRepoComponent(repo, pmsProductLibraryComponents);
|
||||||
return success > 0;
|
return success > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,14 @@
|
||||||
where repo_id = #{repoId}
|
where repo_id = #{repoId}
|
||||||
and identifier = #{identifier}
|
and identifier = #{identifier}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectComponentListFromPipelineByAssetIdList" resultMap="PmsProductLibraryComponentResult">
|
||||||
|
<include refid="selectPmsProductLibraryComponentVo"/>
|
||||||
|
where identifier in
|
||||||
|
<foreach item="assetId" collection="assetIdList" open="(" separator="," close=")">
|
||||||
|
#{assetId}
|
||||||
|
</foreach>
|
||||||
|
and from_type='pipeline'
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertPmsProductLibraryComponent" parameterType="PmsProductLibraryComponent" useGeneratedKeys="true"
|
<insert id="insertPmsProductLibraryComponent" parameterType="PmsProductLibraryComponent" useGeneratedKeys="true"
|
||||||
keyProperty="id">
|
keyProperty="id">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue