Merge pull request '产品固定模块开发' (#779) from otto/microservices:product_refact into product_refact

This commit is contained in:
otto 2024-12-18 15:23:49 +08:00
commit 1c3806ebf8
7 changed files with 85 additions and 9 deletions

View File

@ -83,6 +83,9 @@ public class PmsProductModule extends BaseEntity
@ApiModelProperty(value = "关联项目ID")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Long pmsProjectId;
@ApiModelProperty(value = "是否为固定模块")
private Boolean isFixedModule;
/**
* 子模块
*/

View File

@ -31,4 +31,7 @@ public class PmsProductModuleDataVo
/** 关联产品ID */
@ApiModelProperty(value = "关联产品ID")
private String pmsProductIdentifier;
@ApiModelProperty(value = "是否为固定模块")
private Boolean isFixedModule;
}

View File

@ -32,6 +32,11 @@ public class TreeSelect implements Serializable {
/** 层级 */
private Integer level;
/**
* 层级
*/
private Boolean isFixedModule = true;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
@ -51,5 +56,9 @@ public class TreeSelect implements Serializable {
this.children = pmsProductModule.getChildren().stream().map(x->new TreeSelect(x,this.level+1)).collect(Collectors.toList());
this.isLeaf= this.children.isEmpty();
if (pmsProductModule.getIsFixedModule() != null) {
this.isFixedModule = pmsProductModule.getIsFixedModule();
}
}
}

View File

@ -84,8 +84,10 @@ public interface IPmsProductModuleService
/**
* 同步产品模块到测试用例模块
*
* @param testcaseId 测试用例ID
* @param projectId 测试用例ID
* @return 是否成功
*/
boolean syncByProductModule(Long projectId);
int initProductModule(String productIdentifier);
}

View File

@ -27,7 +27,10 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -129,14 +132,16 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
}
checkParentModule(pmsProductModule, name);
checkNameDuplicates(pmsProductModule);
String currentUsername = SecurityUtils.getUsername();
Date now = DateUtils.getNowDate();
pmsProductModule.setCreateBy(currentUsername);
pmsProductModule.setCreateTime(now);
pmsProductModuleMapper.insertPmsProductModule(pmsProductModule);
insertModuleDatabase(pmsProductModule);
return pmsProductModule.getId();
}
private int insertModuleDatabase(PmsProductModule pmsProductModule) {
pmsProductModule.setCreateBy(SecurityUtils.getUsername());
pmsProductModule.setCreateTime(DateUtils.getNowDate());
return pmsProductModuleMapper.insertPmsProductModule(pmsProductModule);
}
/**
* 校验父模块是否正确
*/
@ -168,6 +173,9 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
throw new ServiceException("[%s]不允许进行操作", NO_MODULE);
}
PmsProductModule oldPmsProductModule = selectPmsProductModuleById(pmsProductModule.getId(), true);
if (oldPmsProductModule.getIsFixedModule()) {
throw new ServiceException("固定模块不允许进行操作");
}
String name;
// 当type为1时则取产品需求数量为2时取测试用例数量
if (PmsConstants.PRODUCT_TAG_AND_MODULE_TYPE.equals(oldPmsProductModule.getType())) {
@ -216,7 +224,9 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
public int deletePmsProductModuleById(Long id)
{
PmsProductModule oldPmsProductModule = selectPmsProductModuleById(id, true);
if (oldPmsProductModule.getIsFixedModule()) {
throw new ServiceException("固定模块不允许进行操作");
}
PmsProductModule pmsProductModuleSearch=new PmsProductModule();
pmsProductModuleSearch.setParentId(id);
List<PmsProductModule> pmsProductModuleChildList=pmsProductModuleMapper.selectPmsProductModuleList(pmsProductModuleSearch);
@ -314,6 +324,7 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
allPmsProductModule.setId(0L);
allPmsProductModule.setModuleName(ALL_MODULE);
allPmsProductModule.setNodeDataCount(allNodeDataCount);
allPmsProductModule.setIsFixedModule(pmsProductModule.getIsFixedModule());
moduleList.add(allPmsProductModule);
// 构建无所属模块
PmsProductModule noPmsProductModule = new PmsProductModule();
@ -383,6 +394,45 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
return true;
}
@Override
public int initProductModule(String productIdentifier) {
PmsProduct pmsProduct = pmsProductService.selectPmsProductByIdentifier(productIdentifier);
PmsProductModule pmsProductModule = new PmsProductModule();
pmsProductModule.setPmsProductIdentifier(pmsProduct.getProductIdentifier());
pmsProductModule.setIsFixedModule(true);
pmsProductModule.setType(PmsConstants.PRODUCT_TAG_AND_MODULE_TYPE);
int success = 0;
pmsProductModule.setModuleName("质量需求");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setParentId(pmsProductModule.getId());
pmsProductModule.setModuleName("适应性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("保密性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("安全性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("环境适应性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("可靠性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("可维护性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("可测试性");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setParentId(null);
pmsProductModule.setModuleName("计算机资源需求");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setParentId(pmsProductModule.getId());
pmsProductModule.setModuleName("硬件资源需求");
success += insertModuleDatabase(pmsProductModule);
pmsProductModule.setModuleName("软件资源需求");
success += insertModuleDatabase(pmsProductModule);
return success;
}
/**
* 通过递归复制树
*

View File

@ -135,6 +135,9 @@ public class PmsProductServiceImpl implements IPmsProductService
pmsProduct.setDeptId(pmsEnterprise.getDeptId());
pmsProductMapper.insertPmsProduct(pmsProduct);
// 新建产品时初始化固定模块
pmsProductModuleService.initProductModule(pmsProduct.getProductIdentifier());
return pmsProduct.getProductIdentifier();
}

View File

@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="requirementCount" column="requirementCount" />
<result property="type" column="type"/>
<result property="pmsProjectId" column="pms_project_id"/>
<result property="isFixedModule" column="is_fixed_module"/>
</resultMap>
<sql id="selectPmsProductModuleVo">
@ -32,7 +33,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_by,
del_flag,
type,
pms_project_id
pms_project_id,
is_fixed_module
from pms_product_module
</sql>
@ -49,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
, m.del_flag
, m.type
, m.pms_project_id
, m.is_fixed_module
,(
SELECT COUNT(*)
FROM pms_product_requirement r
@ -203,6 +206,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag,</if>
<if test="type != null">type,</if>
<if test="pmsProjectId != null">pms_project_id,</if>
<if test="isFixedModule != null">is_fixed_module,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
@ -216,6 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">#{delFlag},</if>
<if test="type != null">#{type},</if>
<if test="pmsProjectId != null">#{pmsProjectId},</if>
<if test="isFixedModule != null">#{isFixedModule},</if>
</trim>
</insert>
@ -233,6 +238,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="type != null">type = #{type},</if>
<if test="pmsProjectId != null">pms_project_id = #{pmsProjectId},</if>
<if test="isFixedModule != null">is_fixed_module = #{isFixedModule},</if>
</trim>
where id = #{id}
</update>