物资类型管理--对4级层级节点进行数据处理
This commit is contained in:
parent
398c450268
commit
e85219e6f5
|
|
@ -65,9 +65,9 @@ public class TypeController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 根据物资类型ID查询所属下拉列表
|
||||
* 根据物资类型ID查询子级下拉列表 --不进行递归穿透
|
||||
*/
|
||||
@ApiOperation(value = "根据物资类型ID查询所属下拉列表")
|
||||
@ApiOperation(value = "根据物资类型ID-查询子级下拉列表")
|
||||
@RequiresPermissions("ma:type:list")
|
||||
@GetMapping("/selectMaTypeListByTypeId")
|
||||
public AjaxResult selectMaTypeListByTypeId(@NotNull(message = "物资类型ID不能为空") Long typeId) {
|
||||
|
|
|
|||
|
|
@ -99,10 +99,61 @@ public class TypeServiceImpl implements ITypeService {
|
|||
@Override
|
||||
public List<MaTypeListVo> selectTypeListAndParent(Type type) {
|
||||
// 如果是顶级节点,则查询所有子节点
|
||||
if (type != null && "0".equals(type.getLevel())) {
|
||||
if (type != null && type.getLevel() != null && "0".equals(type.getLevel())) {
|
||||
type.setLevel(null);
|
||||
}
|
||||
return typeMapper.selectTypeListAndParent(type);
|
||||
|
||||
// 拿到数据要处理一下上级信息
|
||||
List<MaTypeListVo> maTypeListVos;
|
||||
try {
|
||||
maTypeListVos = typeMapper.selectTypeListAndParent(type);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
// 检查Mapper集合
|
||||
if (maTypeListVos == null || maTypeListVos.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
for (MaTypeListVo maTypeListVo : maTypeListVos) {
|
||||
// ------------ 检查 -----------
|
||||
|
||||
// object对象是空的,忽略处理
|
||||
if (maTypeListVo == null) {
|
||||
continue;
|
||||
}
|
||||
// 没有上级就不需要处理,或者level等级不清晰的也不进行处理
|
||||
if (maTypeListVo.getParentId() == null || maTypeListVo.getLevel() == null) {
|
||||
continue;
|
||||
}
|
||||
// 1级节点已经是顶级,无上级,所以不需要处理
|
||||
if ("1".equals(maTypeListVo.getLevel())) {
|
||||
continue;
|
||||
}
|
||||
// ------------ 检查结束 -----------
|
||||
|
||||
|
||||
// 进行数据处理
|
||||
switch (maTypeListVo.getLevel()) {
|
||||
case "2":
|
||||
// 二级节点父级是一级节点,所以要拿到父节点名称,并赋值至ONE_LEVEL_NAME字段
|
||||
maTypeListVo.setParentOneLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName());
|
||||
break;
|
||||
case "3":
|
||||
// 三级节点父级是二级节点和一级节点, 要把祖父类型名称放入一级字段,把父类型名称存入二级字段
|
||||
maTypeListVo.setParentOneLevelName(maTypeListVo.getParentTwoLevelName() == null ? "" : maTypeListVo.getParentTwoLevelName());
|
||||
maTypeListVo.setParentTwoLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName());
|
||||
break;
|
||||
case "4":
|
||||
// 四级节点父级是三级节点和二级节点和一级节点, 要把祖父类型名称放入一级字段,把父类型名称存入二级字段,子类型名称存入三级字段
|
||||
// 但因为4级节点内循环3次,已按顺序处理,所以此处无需处理
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return maTypeListVos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT
|
||||
a.*, -- 当前层级的所有字段
|
||||
b.type_name AS parentThreeLevelName, -- 父层级名称
|
||||
|
||||
c.type_name AS parentTwoLevelName, -- 祖父层级名称
|
||||
d.type_name AS parentOneLevelName -- 曾祖父层级名称
|
||||
FROM
|
||||
|
|
@ -288,17 +289,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getListByTypeName" resultMap="TypeResult">
|
||||
select DISTINCT m.type_id, m.type_name, m.parent_id, m.manage_type,
|
||||
m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.level, m.rated_load, m.test_load,
|
||||
m.holding_time, m.warn_num,
|
||||
mtk.user_id keeperUserId,
|
||||
mpi.prop_name, m.del_flag, m.create_by, m.create_time,
|
||||
m.remark, m.fac_model as facModel,m.intelligent_code
|
||||
from ma_type m
|
||||
left join ma_prop_set mps on m.type_id = mps.type_id
|
||||
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
|
||||
left join ma_type_keeper mtk on m.type_id = mtk.type_id
|
||||
where m.parent_id = #{typeId} and m.del_flag = '0'
|
||||
select DISTINCT
|
||||
m.type_id, m.type_name, m.parent_id, m.manage_type,
|
||||
m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.level, m.rated_load, m.test_load,
|
||||
m.holding_time, m.warn_num,
|
||||
mtk.user_id keeperUserId,
|
||||
mpi.prop_name, m.del_flag, m.create_by, m.create_time,
|
||||
m.remark, m.fac_model as facModel,m.intelligent_code
|
||||
from
|
||||
ma_type m
|
||||
left join
|
||||
ma_prop_set mps on m.type_id = mps.type_id
|
||||
left join
|
||||
ma_prop_info mpi on mps.prop_id = mpi.prop_id
|
||||
left join
|
||||
ma_type_keeper mtk on m.type_id = mtk.type_id
|
||||
where
|
||||
m.parent_id = #{typeId} and m.del_flag = '0'
|
||||
<if test="typeName != null and typeName !=''">
|
||||
AND type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
|
|
@ -307,22 +314,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectMaTypeListByHouseId" resultType="com.bonus.material.ma.vo.MaTypeSelectVo">
|
||||
select
|
||||
wh_house_set.type_id AS typeId,
|
||||
mt.type_name AS typeName,
|
||||
mt.parent_id AS parentId,
|
||||
mt.level
|
||||
mt.type_name AS typeName,mt.parent_id AS parentId,mt.level
|
||||
from
|
||||
wh_house_set
|
||||
left join ma_type mt on wh_house_set.type_id = mt.type_id
|
||||
left join
|
||||
ma_type mt on wh_house_set.type_id = mt.type_id
|
||||
where
|
||||
wh_house_set.house_id = #{mouseId} and wh_house_set.del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="getMaTypeSelectVoListByParentId" resultType="com.bonus.material.ma.vo.MaTypeSelectVo">
|
||||
select
|
||||
type_id,
|
||||
type_name,
|
||||
parent_id,
|
||||
level
|
||||
type_id,type_name,parent_id,level
|
||||
from
|
||||
ma_type
|
||||
where
|
||||
|
|
|
|||
Loading…
Reference in New Issue