feat(产品库优化): 产品库应当区分文档与制品
产品库打包支持打包所有文件、打包软件包和打包文档 关联Issue:https://pm.gitlink.org.cn/Gitlink/projects/228/demand/124517 Signed-off-by: OTTO <731554297@qq.com>
This commit is contained in:
parent
366118bca0
commit
b6e5742188
|
|
@ -1,5 +1,7 @@
|
|||
package com.microservices.pms.enums;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
|
|
@ -12,6 +14,7 @@ import lombok.Getter;
|
|||
@Getter
|
||||
@ApiModel("产品库制品路径前缀")
|
||||
public enum ProductLibraryComponentPathEnum {
|
||||
ALL("_All", "所有"),
|
||||
SOFTWARE("Software", "软件包"),
|
||||
DOC("Document", "文档");
|
||||
|
||||
|
|
@ -63,4 +66,49 @@ public enum ProductLibraryComponentPathEnum {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getPackagedFileJson(String node, String packagedFileIdentifiersJson, String fileIdentifier) {
|
||||
JSONObject packagedFileIdentifiersJsonObj;
|
||||
if (StringUtils.isNotEmpty(packagedFileIdentifiersJson) && JSON.isValid(packagedFileIdentifiersJson)) {
|
||||
packagedFileIdentifiersJsonObj = JSONObject.parseObject(packagedFileIdentifiersJson);
|
||||
} else {
|
||||
packagedFileIdentifiersJsonObj = new JSONObject();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(node)) {
|
||||
if (SOFTWARE.key.equals(node)) {
|
||||
packagedFileIdentifiersJsonObj.put(SOFTWARE.key, fileIdentifier);
|
||||
return packagedFileIdentifiersJsonObj.toJSONString();
|
||||
}
|
||||
if (DOC.key.equals(node)) {
|
||||
packagedFileIdentifiersJsonObj.put(DOC.key, fileIdentifier);
|
||||
return packagedFileIdentifiersJsonObj.toJSONString();
|
||||
}
|
||||
}
|
||||
packagedFileIdentifiersJsonObj.put(ALL.key, fileIdentifier);
|
||||
return packagedFileIdentifiersJsonObj.toJSONString();
|
||||
}
|
||||
|
||||
public static String getPackagedFileIdentifierFromJson(String node, JSONObject packagedFileIdentifiersJsonObj) {
|
||||
if (StringUtils.isNotEmpty(node)) {
|
||||
if (SOFTWARE.key.equals(node)) {
|
||||
return packagedFileIdentifiersJsonObj.getString(SOFTWARE.key);
|
||||
}
|
||||
if (DOC.key.equals(node)) {
|
||||
return packagedFileIdentifiersJsonObj.getString(DOC.key);
|
||||
}
|
||||
}
|
||||
return packagedFileIdentifiersJsonObj.getString(ALL.key);
|
||||
}
|
||||
|
||||
public static String getPackagedFileTag(String node) {
|
||||
if (StringUtils.isNotEmpty(node)) {
|
||||
if (SOFTWARE.key.equals(node)) {
|
||||
return "(" + SOFTWARE.name + ")";
|
||||
}
|
||||
if (DOC.key.equals(node)) {
|
||||
return "(" + DOC.name + ")";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@GetMapping("/byRepoName/{repoName}")
|
||||
@ApiOperation(value = "获取产品库详情")
|
||||
public GenericsAjaxResult<PmsProductLibraryDataVo> getByRepoName(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String repoName) {
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String repoName) {
|
||||
return GenericsAjaxResult.success(pmsProductLibraryService.selectPmsProductLibraryDataByName(enterpriseIdentifier, repoName));
|
||||
}
|
||||
|
||||
|
|
@ -243,9 +243,9 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@GetMapping("/{productRepoName}/{repoName}/keyComponent/list")
|
||||
@ApiOperation(value = "制品库查询关键制品列表")
|
||||
public GenericsAjaxResult<NexusComponentResultVo<List<NexusResultDataVo>>> keyComponentList(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable("productRepoName") String productRepoName,
|
||||
@ApiParam(value = "制品库标识", required = true) @PathVariable("repoName") String repoName,
|
||||
@Valid ComponentSearchVo componentSearchVo) {
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable("productRepoName") String productRepoName,
|
||||
@ApiParam(value = "制品库标识", required = true) @PathVariable("repoName") String repoName,
|
||||
@Valid ComponentSearchVo componentSearchVo) {
|
||||
componentSearchVo.setRepositoryName(repoName);
|
||||
componentSearchVo.setProductRepoName(productRepoName);
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> result =
|
||||
|
|
@ -325,7 +325,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@ApiOperation(value = "产品库打包")
|
||||
public AjaxResult packagedProduct(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String productRepoName,
|
||||
@ApiParam(value = "打包节点(Software:打包软件包;Document:打包文档;不传或传其他值:打包所有)") @RequestParam String node) {
|
||||
@ApiParam(value = "打包节点(Software:打包软件包;Document:打包文档;不传或传其他值:打包所有)") @RequestParam(required = false) String node) {
|
||||
return toAjax(pmsProductLibraryService.packagedProduct(enterpriseIdentifier, productRepoName, node));
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +336,8 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@GetMapping("/packaged/{productRepoName}")
|
||||
@ApiOperation(value = "获取产品库打包下载地址")
|
||||
public GenericsAjaxResult<ProductPackagedResultVo> getPackagedProduct(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String productRepoName) {
|
||||
return pmsProductLibraryService.getPackagedProduct(enterpriseIdentifier, productRepoName);
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String productRepoName,
|
||||
@ApiParam(value = "打包节点(Software:打包软件包;Document:打包文档;不传或传其他值:打包所有)") @RequestParam(required = false) String node) {
|
||||
return pmsProductLibraryService.getPackagedProduct(enterpriseIdentifier, productRepoName, node);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ public class PmsProductLibraryRepositories extends BaseEntity {
|
|||
private String snapshotName;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "打包的文件标识")
|
||||
private String packagedFileIdentifier;
|
||||
@ApiModelProperty(value = "打包的文件标识(JSON对象)")
|
||||
private String packagedFileIdentifiersJson;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "关联产品标识")
|
||||
|
|
|
|||
|
|
@ -88,9 +88,10 @@ public interface IPmsProductLibraryService {
|
|||
*
|
||||
* @param enterpriseIdentifier 企业标识
|
||||
* @param productRepoName 产品库名称
|
||||
* @param node
|
||||
* @return 产品库打包对象
|
||||
*/
|
||||
GenericsAjaxResult<ProductPackagedResultVo> getPackagedProduct(String enterpriseIdentifier, String productRepoName);
|
||||
GenericsAjaxResult<ProductPackagedResultVo> getPackagedProduct(String enterpriseIdentifier, String productRepoName, String node);
|
||||
|
||||
/**
|
||||
* 上传产品库制品
|
||||
|
|
|
|||
|
|
@ -220,12 +220,12 @@ public class PmsProductLibraryAsyncServiceImpl implements IPmsProductLibraryAsyn
|
|||
String fileIdentifier = FeignUtils.getReturnData(
|
||||
remoteFileService.packagedFile(
|
||||
packagedStructure,
|
||||
String.format("product-%s-%s", productRepo.getAlias(), DateUtils.dateTimeNow()),
|
||||
String.format("product-%s-%s%s", productRepo.getAlias(), DateUtils.dateTimeNow(), ProductLibraryComponentPathEnum.getPackagedFileTag(node)),
|
||||
"pms",
|
||||
productRepo.getPmsEnterpriseIdentifier() + "/productLibrary",
|
||||
SecurityConstants.INNER)
|
||||
);
|
||||
productRepo.setPackagedFileIdentifier(fileIdentifier);
|
||||
productRepo.setPackagedFileIdentifiersJson(ProductLibraryComponentPathEnum.getPackagedFileJson(node, productRepo.getPackagedFileIdentifiersJson(), fileIdentifier));
|
||||
pmsProductLibraryService.updatePmsProductLibrary(productRepo);
|
||||
} finally {
|
||||
pmsProductLibraryRepositoriesService.unlockRepository(productRepo.getPmsEnterpriseIdentifier(), productRepo.getId());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.microservices.pms.productLibrary.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.constant.CacheConstants;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
|
|
@ -188,37 +189,44 @@ public class PmsProductLibraryServiceImpl implements IPmsProductLibraryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public GenericsAjaxResult<ProductPackagedResultVo> getPackagedProduct(String enterpriseIdentifier, String productRepoName) {
|
||||
public GenericsAjaxResult<ProductPackagedResultVo> getPackagedProduct(String enterpriseIdentifier, String productRepoName, String node) {
|
||||
ProductPackagedResultVo productPackagedResultVo = new ProductPackagedResultVo();
|
||||
PmsProductLibraryRepositories productLibraryRepositories = selectPmsProductLibraryByName(enterpriseIdentifier, productRepoName);
|
||||
String packagedFileIdentifier = productLibraryRepositories.getPackagedFileIdentifier();
|
||||
String packagedFileIdentifiersJson = productLibraryRepositories.getPackagedFileIdentifiersJson();
|
||||
if (StringUtils.isEmpty(packagedFileIdentifiersJson) || !JSON.isValid(packagedFileIdentifiersJson)) {
|
||||
productPackagedResultVo.setIsPackaged(false);
|
||||
return GenericsAjaxResult.success(productPackagedResultVo);
|
||||
}
|
||||
|
||||
JSONObject packagedFileIdentifiersJsonObj = JSONObject.parseObject(packagedFileIdentifiersJson);
|
||||
String packagedFileIdentifier = ProductLibraryComponentPathEnum.getPackagedFileIdentifierFromJson(node, packagedFileIdentifiersJsonObj);
|
||||
if (StringUtils.isEmpty(packagedFileIdentifier)) {
|
||||
productPackagedResultVo.setIsPackaged(false);
|
||||
} else {
|
||||
productPackagedResultVo.setIsPackaged(true);
|
||||
Integer isFinish = redisService.getCacheObject(CacheConstants.getPackageFileIsFinish(packagedFileIdentifier));
|
||||
if (isFinish != null) {
|
||||
redisService.deleteObject(CacheConstants.getPackageFileIsFinish(packagedFileIdentifier));
|
||||
}
|
||||
// 键值不存在或键值为1,代表打包成功,通过远程接口获取文件信息
|
||||
if (isFinish == null || isFinish == 1) {
|
||||
SysFileInfo sysFileInfo = null;
|
||||
try {
|
||||
sysFileInfo = FeignUtils.getReturnData(
|
||||
remoteFileService.getFileByFileIdentifier(packagedFileIdentifier, SecurityConstants.INNER)
|
||||
);
|
||||
} catch (ServiceException e) {
|
||||
log.error("获取打包文件失败:{}", e.getMessage());
|
||||
return packageError(productLibraryRepositories, productPackagedResultVo);
|
||||
}
|
||||
if (sysFileInfo != null) {
|
||||
productPackagedResultVo.setDownloadUrl(sysFileInfo.getDownloadUrl());
|
||||
productPackagedResultVo.setFileName(sysFileInfo.getFileOriginName());
|
||||
}
|
||||
} else if (isFinish == -1) {
|
||||
// 键值为-1,代表打包失败,需要重新打包
|
||||
return GenericsAjaxResult.success(productPackagedResultVo);
|
||||
}
|
||||
productPackagedResultVo.setIsPackaged(true);
|
||||
Integer isFinish = redisService.getCacheObject(CacheConstants.getPackageFileIsFinish(packagedFileIdentifier));
|
||||
if (isFinish != null) {
|
||||
redisService.deleteObject(CacheConstants.getPackageFileIsFinish(packagedFileIdentifier));
|
||||
}
|
||||
// 键值不存在或键值为1,代表打包成功,通过远程接口获取文件信息
|
||||
if (isFinish == null || isFinish == 1) {
|
||||
SysFileInfo sysFileInfo = null;
|
||||
try {
|
||||
sysFileInfo = FeignUtils.getReturnData(
|
||||
remoteFileService.getFileByFileIdentifier(packagedFileIdentifier, SecurityConstants.INNER)
|
||||
);
|
||||
} catch (ServiceException e) {
|
||||
log.error("获取打包文件失败:{}", e.getMessage());
|
||||
return packageError(productLibraryRepositories, productPackagedResultVo);
|
||||
}
|
||||
if (sysFileInfo != null) {
|
||||
productPackagedResultVo.setDownloadUrl(sysFileInfo.getDownloadUrl());
|
||||
productPackagedResultVo.setFileName(sysFileInfo.getFileOriginName());
|
||||
}
|
||||
} else if (isFinish == -1) {
|
||||
// 键值为-1,代表打包失败,需要重新打包
|
||||
return packageError(productLibraryRepositories, productPackagedResultVo);
|
||||
}
|
||||
return GenericsAjaxResult.success(productPackagedResultVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<result property="snapshotName" column="snapshot_name"/>
|
||||
<result property="format" column="format"/>
|
||||
<result property="pmsEnterpriseIdentifier" column="enterprise_identifier"/>
|
||||
<result property="packagedFileIdentifier" column="packaged_file_identifier"/>
|
||||
<result property="packagedFileIdentifiersJson" column="packaged_file_identifiers_json"/>
|
||||
<result property="productIdentifier" column="product_identifier"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="tag" column="tag"/>
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
pplr.alias,
|
||||
pplr.snapshot_name,
|
||||
pplr.format,
|
||||
pplr.packaged_file_identifier,
|
||||
pplr.packaged_file_identifiers_json,
|
||||
pplr.product_identifier,
|
||||
pplr.version,
|
||||
pplr.tag,
|
||||
|
|
@ -187,7 +187,7 @@
|
|||
<if test="attributes != null">attributes,</if>
|
||||
<if test="alias != null">alias,</if>
|
||||
<if test="snapshotName != null">snapshot_name,</if>
|
||||
<if test="packagedFileIdentifier != null">packaged_file_identifier,</if>
|
||||
<if test="packagedFileIdentifiersJson != null">packaged_file_identifiers_json,</if>
|
||||
<if test="format != null">format,</if>
|
||||
<if test="productIdentifier != null">product_identifier,</if>
|
||||
<if test="version != null">version,</if>
|
||||
|
|
@ -207,7 +207,7 @@
|
|||
<if test="attributes != null">#{attributes},</if>
|
||||
<if test="alias != null">#{alias},</if>
|
||||
<if test="snapshotName != null">#{snapshotName},</if>
|
||||
<if test="packagedFileIdentifier != null">#{packagedFileIdentifier},</if>
|
||||
<if test="packagedFileIdentifiersJson != null">#{packagedFileIdentifiersJson},</if>
|
||||
<if test="format != null">#{format},</if>
|
||||
<if test="productIdentifier != null">#{productIdentifier},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
|
|
@ -231,7 +231,9 @@
|
|||
<if test="attributes != null">attributes = #{attributes},</if>
|
||||
<if test="alias != null">alias = #{alias},</if>
|
||||
<if test="snapshotName != null">snapshot_name = #{snapshotName},</if>
|
||||
<if test="packagedFileIdentifier != null">packaged_file_identifier = #{packagedFileIdentifier},</if>
|
||||
<if test="packagedFileIdentifiersJson != null">packaged_file_identifiers_json =
|
||||
#{packagedFileIdentifiersJson},
|
||||
</if>
|
||||
<if test="format != null">format = #{format},</if>
|
||||
<if test="productIdentifier != null">product_identifier = #{productIdentifier},</if>
|
||||
<if test="version != null">version = #{version},</if>
|
||||
|
|
@ -239,9 +241,9 @@
|
|||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="setProductLibraryPackagedFileIdentifierNull">
|
||||
<update id="setProductLibrarypackagedFileIdentifiersJsonNull">
|
||||
update pms_product_library_repositories
|
||||
set packaged_file_identifier = null
|
||||
set packaged_file_identifiers_json = null
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue