物资类型管理--树形新增0级仓库配置
This commit is contained in:
parent
a11b03b12e
commit
0b694fe72a
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Integer> parentIds = typeService.selectParentId(typeId, level);
|
||||
List<Type> 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<TreeSelect> maTypeList = typeService.getMaTypeTree(typeName, parentId);
|
||||
return AjaxResult.success(maTypeList);
|
||||
// 2.查询所有的仓库配置
|
||||
List<WhHouseSet> whHouseSets = houseSetService.selectListByMaType(null);
|
||||
// 2.1 定义最终接口返回集合
|
||||
List<TreeSelect> 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<TreeSelect> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,16 @@ public interface TypeMapper {
|
|||
*/
|
||||
Type selectTypeByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 根据level层级和typeID 查询父级ID
|
||||
* @param typeId 物资类型主键
|
||||
* @param level 类型层级
|
||||
*/
|
||||
List<Integer> selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level);
|
||||
|
||||
|
||||
List<Type> getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName);
|
||||
|
||||
/**
|
||||
* 物资类型树形结构
|
||||
* @param level 排除层级
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ public interface ITypeService {
|
|||
*/
|
||||
Type selectTypeByTypeId(Long typeId);
|
||||
|
||||
List<Integer> selectParentId(Long typeId, Integer level);
|
||||
|
||||
List<Type> getListByParentId(Long typeId, String typeName);
|
||||
|
||||
/**
|
||||
* 查询物资类型列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,22 @@ public class TypeServiceImpl implements ITypeService {
|
|||
return typeMapper.selectTypeByTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> selectParentId(Long typeId, Integer level) {
|
||||
return typeMapper.selectParentId(typeId, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组织树parent_id查询结果
|
||||
*
|
||||
* @param typeId 父级id
|
||||
* @param typeName 名称筛选
|
||||
*/
|
||||
@Override
|
||||
public List<Type> getListByParentId(Long typeId, String typeName) {
|
||||
return typeMapper.getListByParentId(typeId, typeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物资类型管理列表
|
||||
*
|
||||
|
|
@ -128,13 +144,17 @@ public class TypeServiceImpl implements ITypeService {
|
|||
@Override
|
||||
public List<TreeSelect> getMaTypeTree(String typeName, String parentId) {
|
||||
List<Type> maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL);
|
||||
List<Type> treeSelectList = buildMaTypeTree(maTypes);
|
||||
List<Type> builtMaTypeList = buildMaTypeTree(maTypes);
|
||||
|
||||
// 如果没有查询到那么返回空
|
||||
return treeSelectList.stream()
|
||||
List<TreeSelect> treeSelectList = builtMaTypeList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::convertToTreeSelect)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询顶级节点的仓库配置信息
|
||||
|
||||
// 如果没有查询到那么返回空
|
||||
return treeSelectList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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<WhHouseInfo> list = whHouseInfoService.selectWhHouseInfoList(whHouseInfo);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TreeSelect> treeSelectList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,14 @@ public interface WhHouseSetMapper
|
|||
* @param whHouseSet 仓库货架配置
|
||||
* @return 仓库货架配置集合
|
||||
*/
|
||||
public List<WhHouseSet> selectWhHouseSetList(WhHouseSet whHouseSet);
|
||||
List<WhHouseSet> selectWhHouseSetList(WhHouseSet whHouseSet);
|
||||
|
||||
|
||||
/**
|
||||
* 根据物资类型id查询机具列表
|
||||
* @param typeId 物资类型id
|
||||
*/
|
||||
List<WhHouseSet> selectListByMaType(Long typeId);
|
||||
|
||||
/**
|
||||
* 新增仓库货架配置
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public interface IWhHouseSetService
|
|||
*/
|
||||
public List<WhHouseSet> selectWhHouseSetList(WhHouseSet whHouseSet);
|
||||
|
||||
List<WhHouseSet> selectListByMaType(Long typeId);
|
||||
|
||||
/**
|
||||
* 新增仓库货架配置
|
||||
*
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@ public class WhHouseSetServiceImpl implements IWhHouseSetService
|
|||
return whHouseSetMapper.selectWhHouseSetList(whHouseSet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<WhHouseSet> selectListByMaType(Long typeId) {
|
||||
return whHouseSetMapper.selectListByMaType(typeId);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* 新增仓库货架配置
|
||||
*
|
||||
|
|
|
|||
|
|
@ -250,7 +250,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectTypeListAndParent" resultMap="MaTypeListVoResult">
|
||||
SELECT
|
||||
a.*, -- 当前层级的所有字段
|
||||
a.type_name AS parentFourLevelName, -- 当前层级名称
|
||||
b.type_name AS parentThreeLevelName, -- 父层级名称
|
||||
c.type_name AS parentTwoLevelName, -- 祖父层级名称
|
||||
d.type_name AS parentOneLevelName -- 曾祖父层级名称
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<resultMap type="com.bonus.material.warehouse.domain.WhHouseSet" id="WhHouseSetResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="houseId" column="house_id" />
|
||||
<result property="houseName" column="house_name" />
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="maId" column="ma_id" />
|
||||
<result property="num" column="num" />
|
||||
|
|
@ -111,4 +112,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectListByMaType" resultMap="WhHouseSetResult">
|
||||
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
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue