From 2e3516d110942859e7ed110fe17d07f213b10b0d Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 6 Nov 2024 18:49:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/PartTypeController.java | 31 ++++++++++++++ .../ma/controller/TypeController.java | 9 +--- .../material/ma/mapper/PartTypeMapper.java | 10 +++++ .../material/ma/service/IPartTypeService.java | 5 +++ .../ma/service/impl/PartTypeServiceImpl.java | 10 +++++ .../mapper/material/ma/PartTypeMapper.xml | 42 +++++++++++++++++++ 6 files changed, 100 insertions(+), 7 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java index f986f9c7..a1c8e1a4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/PartTypeController.java @@ -1,12 +1,21 @@ package com.bonus.material.ma.controller; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.convert.Convert; +import com.bonus.common.biz.config.ListPagingUtil; +import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.ma.domain.vo.MaTypeVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.BooleanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -48,6 +57,28 @@ public class PartTypeController extends BaseController return partTypeService.selectPartTypeList(partType); } + /** + * 根据左列表类型id查询右表格 + * + * @param partType + * @return + */ + @ApiOperation(value = "根据左列表类型id查询右表格") + @GetMapping("/getListByPartType") + public AjaxResult getListByPartType(PartType partType) { + List parentIds = partTypeService.selectParentId(partType); + if (CollectionUtils.isEmpty(parentIds)) { + return AjaxResult.success(new ArrayList<>()); + } + List maTypeVos = new ArrayList<>(); + Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1); + Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10); + for (Integer parentId : parentIds) { + maTypeVos.addAll(partTypeService.getListByParentId(parentId.longValue(), partType)); + } + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, maTypeVos)); + } + @ApiOperation(value = "配件类型所属上级树") @RequiresPermissions("ma:type:query") @GetMapping("/getPartTree") 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 a259b412..407b4d45 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 @@ -79,16 +79,11 @@ public class TypeController extends BaseController { for (Integer parentId : parentIds) { maTypeVos.addAll(typeService.getListByParentId(parentId.longValue(), maTypeVo)); } - List updatedMaTypeVos = maTypeVos.stream() - .map(obj -> { - obj.setHouseId(maTypeVo.getHouseId()); - return obj; - }).collect(Collectors.toList()); if (BooleanUtils.isTrue(maTypeVo.getDisplayBindRelationship())) { - List finalMaTypeVos = typeService.getMyTypeAndBindUsers(updatedMaTypeVos); + List finalMaTypeVos = typeService.getMyTypeAndBindUsers(maTypeVos); return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, finalMaTypeVos)); } else { - return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, updatedMaTypeVos)); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, maTypeVos)); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java index d6c03b93..f8910016 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/PartTypeMapper.java @@ -4,6 +4,8 @@ import java.util.List; import com.bonus.common.biz.domain.TreeNode; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.ma.domain.vo.MaTypeVo; +import org.apache.ibatis.annotations.Param; /** * 配件类型管理Mapper接口 @@ -87,4 +89,12 @@ public interface PartTypeMapper * @return */ int selectPart(Long id); + + /** + * 根据level层级和typeID 查询父级ID + * @param partType + */ + List selectParentId(PartType partType); + + List getListByTypeName(@Param("paId") Long id, @Param("type") PartType partType); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java index 8255fc1a..0f99d4b5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IPartTypeService.java @@ -4,6 +4,7 @@ import java.util.List; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.ma.domain.PartType; +import com.bonus.material.ma.domain.vo.MaTypeVo; /** * 配件类型管理Service接口 @@ -66,4 +67,8 @@ public interface IPartTypeService * @return */ List getTypeList(PartType partType); + + List selectParentId(PartType partType); + + List getListByParentId(Long id, PartType type); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java index 020d6d6c..a7ad207e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/PartTypeServiceImpl.java @@ -10,6 +10,7 @@ import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.ma.domain.vo.MaTypeVo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -183,4 +184,13 @@ public class PartTypeServiceImpl implements IPartTypeService return partTypeMapper.getTypeList(partType); } + @Override + public List selectParentId(PartType partType) { + return partTypeMapper.selectParentId(partType); + } + + @Override + public List getListByParentId(Long id, PartType type) { + return partTypeMapper.getListByTypeName(id, type); + } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml index d77654a4..b253e837 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/PartTypeMapper.xml @@ -151,4 +151,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update ma_part_type set del_flag = '2' where pa_id = #{id} + + + \ No newline at end of file