Merge pull request '完善产品中的需求规格功能开发' (#758) from otto/microservices:product_refact into product_refact

This commit is contained in:
otto 2024-12-12 09:09:28 +08:00
commit acfda75cf3
3 changed files with 28 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.pms.product.domain.vo.*;
import com.microservices.pms.product.service.IPmsProductRequirementService;
import com.microservices.pms.project.domain.PmsProject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -123,6 +124,16 @@ public class ProductReqSpecsController extends BaseController {
return toAjax(pmsProductRequirementService.activePlan(productReqSpecsActivePlanVo));
}
/**
* 纳入计划时可选择项目列表
*/
@ApiOperation(value = "纳入计划时可选择项目列表")
@RequiresPermissions("pms:pmsProduct:show")
@GetMapping("/{productIdentifier}/projectList")
public List<PmsProject> projectList(@PathVariable("productIdentifier") String productIdentifier) {
return pmsProductRequirementService.selectReqSpecsProjectList(productIdentifier);
}
/**
* 查询需求规格状态列表
*/

View File

@ -5,6 +5,7 @@ import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.pms.product.domain.PmsProductRequirement;
import com.microservices.pms.product.domain.enums.ProductReqStatus;
import com.microservices.pms.product.domain.vo.*;
import com.microservices.pms.project.domain.PmsProject;
import java.util.List;
@ -128,4 +129,6 @@ public interface IPmsProductRequirementService
JSONObject selectReqSpecsAssociatedPlanData(Long reqSpecsId);
void updateReqSpecsStatusByProjectReqId(Long projectReqId, ProductReqStatus productReqStatus);
List<PmsProject> selectReqSpecsProjectList(String productIdentifier);
}

View File

@ -539,7 +539,11 @@ public class PmsProductRequirementServiceImpl implements IPmsProductRequirementS
if (!ProductReqStatus.REVIEWED_REQ_SPECS.getKey().equals(reqSpecs.getStatus())) {
throw new ServiceException("仅已评审状态的需求规格才能纳入计划");
}
PmsProject project = pmsProjectService.selectAndCheckPmsProjectById(productReqSpecsActivePlanVo.getProjectId());
List<PmsProject> pmsProjectList = selectReqSpecsProjectList(reqSpecs.getPmsProductIdentifier());
if (pmsProjectList == null
|| pmsProjectList.stream().noneMatch(x -> x.getId().equals(productReqSpecsActivePlanVo.getProjectId()))) {
throw new ServiceException("需求规格纳入计划时请选择关联了当前产品的项目");
}
List<String> forgeFileIdentifierList = null;
if (StringUtils.isNotEmpty(reqSpecs.getFileIdentifiers())) {
// 需求规格文件上传至forge
@ -550,7 +554,7 @@ public class PmsProductRequirementServiceImpl implements IPmsProductRequirementS
PmsProjectIssuesInputVo pmsProjectIssuesInputVo = productReqSpecsActivePlanVo.toPmsProjectIssuesInputVo(reqSpecs, forgeFileIdentifierList);
JSONObject projectIssue = pmsProjectIssuesService.insertPmsProjectIssues(pmsProjectIssuesInputVo);
reqSpecs.setPmsProjectId(project.getId());
reqSpecs.setPmsProjectId(productReqSpecsActivePlanVo.getId());
reqSpecs.setProjectReqId(projectIssue.getLong("id"));
reqSpecs.setStatus(ProductReqStatus.PLANNED_REQ_SPECS.getKey());
int success = updateRequirement(reqSpecs, reqSpecs.getPmsProductIdentifier());
@ -604,6 +608,14 @@ public class PmsProductRequirementServiceImpl implements IPmsProductRequirementS
updateRequirement(pmsProductRequirement, pmsProductRequirement.getPmsProductIdentifier());
}
@Override
public List<PmsProject> selectReqSpecsProjectList(String productIdentifier) {
PmsProduct pmsProduct = pmsProductService.selectPmsProductByIdentifier(productIdentifier);
PmsProject pmsProjectSearch = new PmsProject();
pmsProjectSearch.setPmsProductId(pmsProduct.getId());
return pmsProjectService.selectPmsProjectList(pmsProjectSearch);
}
private ProductReqSpecsDetailVo toProductReqSpecsDetailVo(PmsProductRequirement pmsProductRequirement) {
ProductReqSpecsDataVo productReqSpecsDataVo = toProductReqSpecsDataVo(pmsProductRequirement, null);
ProductReqSpecsDetailVo productReqSpecsDetailVo = productReqSpecsDataVo.toProductReqSpecsDetailVo();