From 0d3f737406aff50e93d2bf1b33ad49793118e0bf Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Tue, 15 Oct 2024 16:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86--=E6=96=B0=E5=A2=9E=E7=89=A9=E8=B5=84=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=9F=A5=E8=AF=A2=E6=A0=91=E7=8A=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 28 ++++++++++++++----- .../bonus/material/ma/mapper/TypeMapper.java | 10 ++++++- .../material/ma/service/ITypeService.java | 3 ++ .../ma/service/impl/TypeServiceImpl.java | 8 +++++- .../bonus/material/ma/vo/MaTypeSelectVo.java | 23 +++++++++++++++ .../mapper/material/ma/TypeMapper.xml | 15 +++++++++- 6 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java 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 13530590..9f46131d 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 @@ -4,13 +4,14 @@ import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; -import cn.hutool.core.convert.Convert; -import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import com.bonus.material.warehouse.domain.WhHouseSet; import com.bonus.material.warehouse.service.IWhHouseSetService; import io.swagger.annotations.Api; @@ -53,10 +54,20 @@ public class TypeController extends BaseController { } /** - * 根据左列表类型id查询右表格 - * - * @param typeId - * @return + * 根据物资仓库ID查询施工类型 + */ + @ApiOperation(value = "根据物资仓库ID查询施工类型") + @RequiresPermissions("ma:type:list") + @GetMapping("/selectMaTypeListByHouseId") + public AjaxResult selectMaTypeListByHouseId(@NotNull(message = "物资仓库ID不能为空") Long houseId) { + List list = typeService.selectMaTypeListByHouseId(houseId); + return success(list); + } + + /** + * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! + * TODO: 待完善 + * @param typeId 左列表类型id */ @ApiOperation(value = "根据左列表类型id查询右表格") @GetMapping("/getListByMaType") @@ -73,6 +84,7 @@ public class TypeController extends BaseController { } /** + * TODO : 后续优化代码逻辑 * 物资类型下拉树 */ @ApiOperation(value = "物资类型下拉树") @@ -98,7 +110,9 @@ public class TypeController extends BaseController { oneLevelTreeList.add(treeSelect); } } - thisTree.setChildren(oneLevelTreeList); + // 把处理后对应上的1级列表当作child存入0级Tree对象中 + thisTree.setChildren(!oneLevelTreeList.isEmpty() ? oneLevelTreeList : null); + // 最后把0级Tree对象存入Result返回集合中,返回给前端 treeSelectResultList.add(thisTree); } return AjaxResult.success(treeSelectResultList); 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 c09519bd..9496f448 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 @@ -3,6 +3,7 @@ package com.bonus.material.ma.mapper; import java.util.List; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -27,8 +28,15 @@ public interface TypeMapper { */ List selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level); + /** + * 根据物资仓库的ID查询物资类型列表 + * @param houseId 物资仓库ID + */ + List selectMaTypeListByHouseId(Long houseId); - List getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName); + List getListByTypeName(@Param("typeId") Long typeId, @Param("typeName") String typeName); + + List getMaTypeSelectVoListByParentId(@Param("typeId") Long typeId); /** * 物资类型树形结构 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 85cb89b2..807139ec 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 @@ -5,6 +5,7 @@ import java.util.List; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; /** * 物资类型Service接口 @@ -21,6 +22,8 @@ public interface ITypeService { List selectParentId(Long typeId, Integer level); + 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 f401dc0a..77f1ad92 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 @@ -10,6 +10,7 @@ import com.bonus.common.biz.enums.DataCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import com.bonus.material.ma.vo.MaTypeListVo; +import com.bonus.material.ma.vo.MaTypeSelectVo; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; @@ -47,6 +48,11 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectParentId(typeId, level); } + @Override + public List selectMaTypeListByHouseId(Long houseId) { + return typeMapper.selectMaTypeListByHouseId(houseId); + } + /** * 根据组织树parent_id查询结果 * @@ -55,7 +61,7 @@ public class TypeServiceImpl implements ITypeService { */ @Override public List getListByParentId(Long typeId, String typeName) { - return typeMapper.getListByParentId(typeId, typeName); + return typeMapper.getListByTypeName(typeId, typeName); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java new file mode 100644 index 00000000..2e247f91 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/vo/MaTypeSelectVo.java @@ -0,0 +1,23 @@ +package com.bonus.material.ma.vo; + +import lombok.Data; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.vo + * @CreateTime: 2024-10-15 15:39 + * @Description: 物资类型下拉框 + */ +@Data +public class MaTypeSelectVo { + + private Long typeId; + + private String typeName; + + private String parentId; + + private Integer level; + +} 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 5bc1997e..8fdd780b 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 @@ -287,7 +287,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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, @@ -303,4 +303,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND type_name like concat('%',#{typeName},'%') + + \ No newline at end of file