feat(制品库功能完善): 产品库不提供直接上传产品操作,文档需要从知识库中选取
产品库上传文档逻辑优化: 1. 上传产品文档仅需传递文档id,通过文档id查找文档 2. 限制文档类型仅允许为文档类型或附件类型
This commit is contained in:
parent
b316db25f3
commit
39f20b0041
|
|
@ -18,7 +18,7 @@ import java.util.Date;
|
|||
@Data
|
||||
public class PmsDocumentDetailVo
|
||||
{
|
||||
|
||||
private Long id;
|
||||
/** 文档名称 */
|
||||
@ApiModelProperty(value = "文档名称")
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
|||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryComponentService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryService;
|
||||
|
|
@ -123,11 +122,10 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@ApiOperation(value = "上传产品库制品")
|
||||
public AjaxResult uploadProductAsset(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String name,
|
||||
@Valid @RequestBody ComponentRawInputVo componentRawInputVo) {
|
||||
componentRawInputVo.setRepoName(name);
|
||||
componentRawInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
componentRawInputVo.setFormat(ProductLibraryRepositoriesFormatEnum.PRODUCT.getKey());
|
||||
return toAjax(pmsProductLibraryService.uploadProductAsset(componentRawInputVo));
|
||||
@Valid @RequestBody ProductComponentInputVo productComponentInputVo) {
|
||||
productComponentInputVo.setProductRepoName(name);
|
||||
productComponentInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
return toAjax(pmsProductLibraryService.uploadProductAsset(productComponentInputVo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.microservices.pms.productLibrary.domain.vo;
|
||||
|
||||
import com.microservices.common.core.utils.bean.BeanUtils;
|
||||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 制品Raw输入对象
|
||||
*
|
||||
* @author otto
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("产品制品输入对象")
|
||||
public class ProductComponentInputVo {
|
||||
@ApiModelProperty(value = "产品库标识", hidden = true)
|
||||
private String productRepoName;
|
||||
@ApiModelProperty(value = "组织标识", hidden = true)
|
||||
private String enterpriseIdentifier;
|
||||
@ApiModelProperty(value = "制品格式", hidden = true)
|
||||
private String format = ProductLibraryRepositoriesFormatEnum.PRODUCT.getKey();
|
||||
@ApiModelProperty(value = "制品版本")
|
||||
@NotBlank(message = "制品版本不能为空")
|
||||
private String version;
|
||||
@ApiModelProperty(value = "文档列表")
|
||||
@Size(min = 1, message = "最少上传一个文档")
|
||||
@Valid
|
||||
private List<Long> docList;
|
||||
@ApiModelProperty(value = "目录:上传文件的目录(例如/path/to/files/)")
|
||||
@NotNull(message = "目录不能为空")
|
||||
private String directory;
|
||||
|
||||
public ComponentRawInputVo toComponentRawInputVo(List<AssetRawInputVo> assetList) {
|
||||
ComponentRawInputVo target = new ComponentRawInputVo();
|
||||
BeanUtils.copyProperties(this, target);
|
||||
target.setRepoName(productRepoName);
|
||||
target.setAssetList(assetList);
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -95,10 +95,10 @@ public interface IPmsProductLibraryService {
|
|||
/**
|
||||
* 上传产品库制品
|
||||
*
|
||||
* @param componentRawInputVo 产品库制品输入对象
|
||||
* @param productComponentInputVo 产品库制品输入对象
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean uploadProductAsset(ComponentRawInputVo componentRawInputVo);
|
||||
Boolean uploadProductAsset(ProductComponentInputVo productComponentInputVo);
|
||||
|
||||
GenericsTableDataInfo<DocResultVo> selectDocList(DocSearchVo docSearchVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.microservices.common.core.utils.StringUtils;
|
|||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.pms.document.domain.vo.PmsDocumentDetailVo;
|
||||
import com.microservices.pms.document.domain.vo.PmsDocumentVo;
|
||||
import com.microservices.pms.document.service.IPmsDocumentService;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
|
|
@ -37,6 +38,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -166,28 +168,29 @@ public class PmsProductLibraryServiceImpl implements IPmsProductLibraryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean uploadProductAsset(ComponentRawInputVo componentRawInputVo) {
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryRepositoriesService.getPmsProductLibraryRepositories(
|
||||
ProductLibraryRepositoriesFormatEnum.isProduct(componentRawInputVo.getFormat()),
|
||||
componentRawInputVo.getEnterpriseIdentifier(),
|
||||
componentRawInputVo.getRepoName(),
|
||||
componentRawInputVo.getSnapshotName());
|
||||
public Boolean uploadProductAsset(ProductComponentInputVo productComponentInputVo) {
|
||||
PmsProductLibraryRepositories repo =
|
||||
selectPmsProductLibraryByName(productComponentInputVo.getEnterpriseIdentifier(), productComponentInputVo.getProductRepoName());
|
||||
|
||||
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(componentRawInputVo.getEnterpriseIdentifier());
|
||||
for (AssetRawInputVo assetRawInputVo : componentRawInputVo.getAssetList()) {
|
||||
if (!StringUtils.isNumeric(assetRawInputVo.getAssetIdentifier())) {
|
||||
throw new ServiceException("制品标识格式错误,产品库的制品标识应该为文档Id(制品文件名称[%s])", assetRawInputVo.getFilename());
|
||||
List<AssetRawInputVo> assetList = new ArrayList<>();
|
||||
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(productComponentInputVo.getEnterpriseIdentifier());
|
||||
for (Long docId : productComponentInputVo.getDocList()) {
|
||||
PmsDocumentDetailVo pmsDocument = pmsDocumentService.selectPmsDocumentDetailVoByIdAndEnterpriseId(docId, pmsEnterprise.getId());
|
||||
if (Objects.equals(pmsDocument.getDocType(), 1) || Objects.equals(pmsDocument.getDocType(), 4)) {
|
||||
throw new ServiceException("产品库文档类型仅允许为文档类型或附件类型(文档Id[%s])", pmsDocument.getId());
|
||||
}
|
||||
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent =
|
||||
pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(repo.getId(), assetRawInputVo.getAssetIdentifier());
|
||||
pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(repo.getId(), String.valueOf(docId));
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
throw new ServiceException("产品库已存在该文档,请勿重复上传(文档文件名称[%s])", assetRawInputVo.getFilename());
|
||||
throw new ServiceException("产品库已存在该文档,请勿重复上传(文档文件名称[%s])", pmsDocument.getName());
|
||||
}
|
||||
pmsDocumentService.selectPmsDocumentDetailVoByIdAndEnterpriseId(Long.parseLong(assetRawInputVo.getAssetIdentifier()), pmsEnterprise.getId());
|
||||
AssetRawInputVo assetRawInputVo = new AssetRawInputVo();
|
||||
assetRawInputVo.setFilename(pmsDocument.getName());
|
||||
assetRawInputVo.setAssetIdentifier(String.valueOf(pmsDocument.getId()));
|
||||
assetRawInputVo.setFileIdentifier(pmsDocument.getAttachmentIdentifier());
|
||||
assetList.add(assetRawInputVo);
|
||||
}
|
||||
|
||||
return pmsProductLibraryComponentService.insertRawComponent(componentRawInputVo);
|
||||
return pmsProductLibraryComponentService.insertRawComponent(productComponentInputVo.toComponentRawInputVo(assetList));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue