From a542efc44d332bf391d1dca4fac117039615e3a0 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Fri, 18 Oct 2024 16:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B--=E5=85=AC?= =?UTF-8?q?=E7=94=A8=E8=A7=84=E6=A0=BC=E5=9E=8B=E5=8F=B7=E8=BF=9E=E5=8A=A8?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 14 ++++++ .../bonus/material/ma/mapper/TypeMapper.java | 3 ++ .../material/ma/service/ITypeService.java | 2 + .../ma/service/impl/TypeServiceImpl.java | 44 +++++++++++++++++++ .../mapper/material/ma/TypeMapper.xml | 21 +++++++++ 5 files changed, 84 insertions(+) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index e8571ea0..e6de4c5a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -74,6 +74,20 @@ public class TypeController extends BaseController { return success(list); } + /** + * 查询物资类型4级规格型号--前端联动式下拉框 + * + * @param typeId 规格型号 + */ + @ApiOperation(value = "获取物资类型连动式下拉框") + @GetMapping("/equipmentType") + public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, + @RequestParam(required = false) String typeName) { + List listByMaType = typeService.getEquipmentType(typeId, typeName); + return success(listByMaType); + } + + /** * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! * TODO: 待完善 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index 95d81f94..24004336 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -14,6 +14,9 @@ import org.apache.ibatis.annotations.Param; */ @Mapper public interface TypeMapper { + + List selectMaTypeList(String typeName); + /** * 查询物资类型 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 79548d23..728f0640 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -23,6 +23,8 @@ public interface ITypeService { List selectParentId(Long typeId, Integer level); + List getEquipmentType(Long typeId, String typeName); + List selectMaTypeListByHouseId(Long houseId); List getListByParentId(Long typeId, String typeName); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 9224ab63..0a2efe27 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -48,6 +48,31 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectParentId(typeId, level); } + /** + * 查询物资类型四级树--前端联动式下拉框 + * @param typeId 类型id + * @param typeName 类型名称 + */ + @Override + public List getEquipmentType(Long typeId, String typeName) { + List maTypes = typeMapper.selectMaTypeList(""); + List list = new ArrayList<>(); + for (Type maType : maTypes) { + if (maType.getParentId() == 0) { + list.add(maType); + } + } + //根据父节点获取对应的儿子节点 + for (Type maType : list) { + List child = getChild(maTypes, maType.getTypeId()); + maType.setChildren(child); + } + return list; + } + + + + @Override public List selectMaTypeListByHouseId(Long houseId) { return typeMapper.selectMaTypeListByHouseId(houseId); @@ -272,6 +297,25 @@ public class TypeServiceImpl implements ITypeService { return new TreeSelect(type.getTypeId(), type.getTypeName(),Integer.valueOf(type.getLevel()),type.getParentId(), children); } + /** + * 递归调用获取子级 + * @param list 集合 + * @param parentId 父级id + */ + public List getChild(List list, Long parentId) { + List childList = new ArrayList(); + for (Type maType : list) { + Long typeId = maType.getTypeId(); + Long pid = maType.getParentId(); + if (parentId.equals(pid)) { + List childLists = getChild(list, typeId); + maType.setChildren(childLists); + childList.add(maType); + } + } + return childList; + } + /** * 构建前端所需要树结构 * diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 022953d4..9a70c583 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -408,4 +408,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE a.del_flag = 0 AND a.`level` = '3' + + \ No newline at end of file