diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java index fc39260b..30a74855 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeSelect.java @@ -46,4 +46,11 @@ public class TreeSelect implements Serializable { this.children = children; } + public TreeSelect(Long id, String label, Integer level, Long parentId) { + this.id = id; + this.label = label; + this.level = level; + this.parentId = parentId; + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java index 68d63bc9..652a4acf 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java @@ -33,8 +33,8 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "机具设备管理接口") @RestController @RequestMapping("/ma_machine") -public class MachineController extends BaseController -{ +public class MachineController extends BaseController { + @Autowired private IMachineService machineService; 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 ab0e2f54..13530590 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 @@ -1,12 +1,18 @@ package com.bonus.material.ma.controller; +import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; + +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.warehouse.domain.WhHouseSet; +import com.bonus.material.warehouse.service.IWhHouseSetService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -31,6 +37,9 @@ public class TypeController extends BaseController { @Resource private ITypeService typeService; + @Resource + private IWhHouseSetService houseSetService; + /** * 查询物资类型管理列表 */ @@ -43,6 +52,26 @@ public class TypeController extends BaseController { return getDataTable(list); } + /** + * 根据左列表类型id查询右表格 + * + * @param typeId + * @return + */ + @ApiOperation(value = "根据左列表类型id查询右表格") + @GetMapping("/getListByMaType") + public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) { + List parentIds = typeService.selectParentId(typeId, level); + List listByMaType = new ArrayList<>(); + for (Integer parentId : parentIds) { + listByMaType.addAll(typeService.getListByParentId(parentId.longValue(), typeName)); + } +// Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); +// Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); +// return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType)); + return null; + } + /** * 物资类型下拉树 */ @@ -50,8 +79,29 @@ public class TypeController extends BaseController { @RequiresPermissions("ma:type:list") @GetMapping("/getMaTypeTreeSelect") public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { + // 1.顶级节点及子节点数据全部查询完毕 List maTypeList = typeService.getMaTypeTree(typeName, parentId); - return AjaxResult.success(maTypeList); + // 2.查询所有的仓库配置 + List whHouseSets = houseSetService.selectListByMaType(null); + // 2.1 定义最终接口返回集合 + List treeSelectResultList = new ArrayList<>(); + // 3.遍历所有配置关联 + for (WhHouseSet whHouseSet : whHouseSets) { + Long typeId = whHouseSet.getTypeId(); + if (typeId == null) {continue;} + // 构造函数定义0级Tree对象 + TreeSelect thisTree = new TreeSelect(whHouseSet.getId(),whHouseSet.getHouseName(),0,null); + // 定义1级列表,并循环push相应的1级节点 + List oneLevelTreeList = new ArrayList<>(); + for (TreeSelect treeSelect : maTypeList) { + if (treeSelect.getId().equals(typeId)) { + oneLevelTreeList.add(treeSelect); + } + } + thisTree.setChildren(oneLevelTreeList); + 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 835c6cb1..c09519bd 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 @@ -20,6 +20,16 @@ public interface TypeMapper { */ Type selectTypeByTypeId(Long typeId); + /** + * 根据level层级和typeID 查询父级ID + * @param typeId 物资类型主键 + * @param level 类型层级 + */ + List selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level); + + + List getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName); + /** * 物资类型树形结构 * @param level 排除层级 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 fd03bea3..85cb89b2 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 @@ -19,6 +19,10 @@ public interface ITypeService { */ Type selectTypeByTypeId(Long typeId); + List selectParentId(Long typeId, Integer level); + + 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 0803cd37..f401dc0a 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 @@ -42,6 +42,22 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.selectTypeByTypeId(typeId); } + @Override + public List selectParentId(Long typeId, Integer level) { + return typeMapper.selectParentId(typeId, level); + } + + /** + * 根据组织树parent_id查询结果 + * + * @param typeId 父级id + * @param typeName 名称筛选 + */ + @Override + public List getListByParentId(Long typeId, String typeName) { + return typeMapper.getListByParentId(typeId, typeName); + } + /** * 查询物资类型管理列表 * @@ -128,13 +144,17 @@ public class TypeServiceImpl implements ITypeService { @Override public List getMaTypeTree(String typeName, String parentId) { List maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL); - List treeSelectList = buildMaTypeTree(maTypes); + List builtMaTypeList = buildMaTypeTree(maTypes); - // 如果没有查询到那么返回空 - return treeSelectList.stream() + List treeSelectList = builtMaTypeList.stream() .filter(Objects::nonNull) .map(this::convertToTreeSelect) .collect(Collectors.toList()); + + // 查询顶级节点的仓库配置信息 + + // 如果没有查询到那么返回空 + return treeSelectList; } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java index 573f8ba4..a92c19b8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseInfoController.java @@ -67,7 +67,7 @@ public class WhHouseInfoController extends BaseController { @ApiOperation(value = "导出仓库管理列表") @PreventRepeatSubmit @RequiresPermissions("warehouse:info:export") - @SysLog(title = "仓库管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出仓库管理") + @SysLog(title = "仓库管理", businessType = OperaType.EXPORT, module = "仓储管理->导出仓库管理") @PostMapping("/export") public void export(HttpServletResponse response, WhHouseInfo whHouseInfo) { List list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java index 36e2f9ee..58f368e9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/controller/WhHouseSetController.java @@ -33,8 +33,8 @@ import com.bonus.common.core.web.page.TableDataInfo; @Api(tags = "仓库货架配置接口") @RestController @RequestMapping("/wh_house_set") -public class WhHouseSetController extends BaseController -{ +public class WhHouseSetController extends BaseController { + @Autowired private IWhHouseSetService whHouseSetService; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java index 848eae97..8cef9dd3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/domain/WhHouseSet.java @@ -1,11 +1,15 @@ package com.bonus.material.warehouse.domain; +import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; +import java.util.ArrayList; +import java.util.List; + /** * 仓库货架配置对象 wh_house_set * @@ -16,8 +20,8 @@ import com.bonus.common.core.web.domain.BaseEntity; @Data @ToString -public class WhHouseSet extends BaseEntity -{ +public class WhHouseSet extends BaseEntity { + private static final long serialVersionUID = 1L; /** 主键id */ @@ -28,6 +32,10 @@ public class WhHouseSet extends BaseEntity @ApiModelProperty(value = "仓库ID") private Long houseId; + @Excel(name = "仓库名称") + @ApiModelProperty(value = "仓库名称") + private String houseName; + /** 机具类型ID */ @Excel(name = "机具类型ID") @ApiModelProperty(value = "机具类型ID") @@ -65,5 +73,9 @@ public class WhHouseSet extends BaseEntity @ApiModelProperty(value = "货架编号") private String shelfNum; + /** + * 仓库下物资树 + */ + private List treeSelectList = new ArrayList<>(); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java index 6d29a8cd..128dae9f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/mapper/WhHouseSetMapper.java @@ -25,7 +25,14 @@ public interface WhHouseSetMapper * @param whHouseSet 仓库货架配置 * @return 仓库货架配置集合 */ - public List selectWhHouseSetList(WhHouseSet whHouseSet); + List selectWhHouseSetList(WhHouseSet whHouseSet); + + + /** + * 根据物资类型id查询机具列表 + * @param typeId 物资类型id + */ + List selectListByMaType(Long typeId); /** * 新增仓库货架配置 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java index 099d74f6..0d384784 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/IWhHouseSetService.java @@ -27,6 +27,8 @@ public interface IWhHouseSetService */ public List selectWhHouseSetList(WhHouseSet whHouseSet); + List selectListByMaType(Long typeId); + /** * 新增仓库货架配置 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java index 9e77c606..dff1857a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/warehouse/service/impl/WhHouseSetServiceImpl.java @@ -44,6 +44,14 @@ public class WhHouseSetServiceImpl implements IWhHouseSetService return whHouseSetMapper.selectWhHouseSetList(whHouseSet); } + + @Override + public List selectListByMaType(Long typeId) { + return whHouseSetMapper.selectListByMaType(typeId); + } + ; + + /** * 新增仓库货架配置 * 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 69e6fd13..5bc1997e 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 @@ -250,7 +250,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + SELECT + mhs.house_id, mhs.type_id, mhs.ma_id, mhs.num, mhs.status, mhs.dept_id, mhs.del_flag, + mhs.create_by, mhs.create_time, mhs.update_by,mhs.update_time,mhs.remark,mhs.company_id,mhi.house_name + from wh_house_set mhs + left join ma_type mt on mt.type_id = mhs.type_id + left join ma_type mt1 on mt.parent_id = mt1.type_id + left join ma_type mt2 on mt1.parent_id = mt2.type_id + left join wh_house_info mhi on mhs.house_id = mhi.house_id + \ No newline at end of file