物资配置管理--右侧物资配置列表

This commit is contained in:
syruan 2024-10-16 15:58:45 +08:00
parent 3d26950c99
commit e33c93d51e
17 changed files with 329 additions and 35 deletions

View File

@ -0,0 +1,23 @@
package com.bonus.material.ma;
import lombok.Data;
import lombok.ToString;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.ma
* @CreateTime: 2024-10-16 15:50
* @Description: 物资类型配置请求封装DTO
*/
@Data
@ToString
public class MaTypeConfigDto implements java.io.Serializable {
private Long id;
private Long typeId;
private Long userId;
}

View File

@ -3,9 +3,17 @@ package com.bonus.material.ma.controller;
import com.bonus.common.biz.domain.TreeSelect;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.ma.MaTypeConfigDto;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.ma.domain.TypeKeeper;
import com.bonus.material.ma.domain.TypeRepair;
import com.bonus.material.ma.service.ITypeKeeperService;
import com.bonus.material.ma.service.ITypeRepairService;
import com.bonus.material.ma.service.ITypeService;
import com.bonus.material.ma.vo.MaTypeConfigVo;
import com.bonus.material.ma.vo.MaTypeListVo;
import com.google.common.collect.ImmutableList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -15,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author : 阮世耀
@ -40,6 +49,75 @@ public class MaTypeConfigController extends BaseController {
@Resource
private ITypeRepairService typeRepairService;
// 物资类型Service
@Resource
private ITypeService typeService;
/**
* 查询物资类型配置右侧列表
*/
@ApiOperation(value = "查询物资类型配置右侧列表")
@RequiresPermissions("ma:typeConfig:list")
@GetMapping("/getMaTypeConfigList")
public AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto) {
// 1.把所有物资类型查出来
List<MaTypeConfigVo> list = typeService.selectThreeFourLevelTypeListAndParent(new Type());
// 2.把维修配置信息查出来
List<TypeRepair> typeRepairList = typeRepairService.selectTypeRepairListAndUserName(new TypeRepair());
// 3.把库管配置信息查出来
List<TypeKeeper> typeKeeperList = typeKeeperService.selectTypeKeeperListAndUserName(new TypeKeeper());
// ------------------- 开启数据处理 ---------------------
// 4.1 先循环维修配置信息
for (TypeRepair typeRepair : typeRepairList) {
// 4.循环维修配置信息把维修员信息设置到物资类型配置信息中
for (MaTypeConfigVo maTypeConfigVo1 : list) {
// 5.判断当前维修配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id
if (typeRepair.getTypeId().equals(maTypeConfigVo1.getTypeId())) {
// 6.如果相等把维修员信息设置到物资类型配置信息中
maTypeConfigVo1.setRepairUserId(typeRepair.getUserId());
maTypeConfigVo1.setRepairUserName(typeRepair.getUserName());
}
}
}
// 4.2 再循环库管配置信息
for (TypeKeeper typeKeeper : typeKeeperList) {
// 4.2循环库管配置信息把库管员信息设置到物资类型配置信息中
for (MaTypeConfigVo maTypeConfigVo1 : list) {
// 5.判断当前库管配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id
if (typeKeeper.getTypeId().equals(maTypeConfigVo1.getTypeId())) {
// 6.如果相等把库管员信息设置到物资类型配置信息中
maTypeConfigVo1.setKeeperUserId(typeKeeper.getUserId());
maTypeConfigVo1.setKeeperUserName(typeKeeper.getUserName());
}
}
}
// ------------------- 数据过滤开始 ---------------------
if (maTypeConfigDto != null) {
// 1.根据库管员或维修员用户id过滤数据
if (maTypeConfigDto.getUserId() != null && maTypeConfigDto.getUserId() != 0L) {
List<MaTypeConfigVo> filterCollected = list.stream().
filter(maTypeConfigVo -> maTypeConfigVo.getKeeperUserId().equals(maTypeConfigDto.getUserId())
||
maTypeConfigVo.getRepairUserId().equals(maTypeConfigDto.getUserId()
))
.collect(Collectors.toList());
return success(filterCollected);
}
}
// ------------------- 数据过滤结束 ---------------------
// -------------------- 数据处理结束 ---------------------
return success(list);
}
/**
* 查询物资配置左侧组织人员树-tree
*/
@ -47,7 +125,8 @@ public class MaTypeConfigController extends BaseController {
@RequiresPermissions("ma:typeConfig:list")
@GetMapping("/getDeptUserTree")
public AjaxResult getDeptUserTree() {
// ---------- 模拟人员Tree数据 --------------
// ---------- 模拟人员Tree数据 ---------------
// 1.创建一个TreeSelect集合用于外层放组织部门--公司级
List<TreeSelect> treeSelectList1 = new ArrayList<>();
@ -55,20 +134,19 @@ public class MaTypeConfigController extends BaseController {
TreeSelect treeSelect2 = new TreeSelect(2L, "输电分公司", 1, null);
TreeSelect treeSelect3 = new TreeSelect(5L, "变电分公司", 1, null);
// 给公司级部门添加子部门
// 2.创建一个TreeSelect集合用于外层放组织部门--部门级
// 2. 给公司级部门添加子部门 创建TreeSelect集合存放组织部门--部门级
TreeSelect treeSelect01 = new TreeSelect(11L, "物流库管一班", 2, 1L);
TreeSelect treeSelect02 = new TreeSelect(12L, "物流库管二班", 2, 1L);
TreeSelect treeSelect03 = new TreeSelect(13L, "宏源库管一班", 2, 5L);
// 3. 创建部门人员
TreeSelect treeSelect001 = new TreeSelect(111L, "王小明", 3, 11L);
TreeSelect treeSelect002 = new TreeSelect(112L, "张小三", 3, 11L);
treeSelect01.setChildren(Arrays.asList(treeSelect001, treeSelect002));
TreeSelect treeSelect02 = new TreeSelect(12L, "物流库管二班", 2, 1L);
treeSelect1.setChildren(Arrays.asList(treeSelect01, treeSelect02));
TreeSelect treeSelect03 = new TreeSelect(13L, "宏源库管一班", 2, 5L);
TreeSelect treeSelect003 = new TreeSelect(113L, "李四", 3, 12L);
// 4. 把子部门人员添加到子部门中
treeSelect01.setChildren(Arrays.asList(treeSelect001, treeSelect002));
treeSelect1.setChildren(Arrays.asList(treeSelect01, treeSelect02));
treeSelect03.setChildren(ImmutableList.of(treeSelect003));
treeSelect3.setChildren(Collections.singletonList(treeSelect03));
@ -76,6 +154,9 @@ public class MaTypeConfigController extends BaseController {
treeSelectList1.add(treeSelect1);
treeSelectList1.add(treeSelect2);
treeSelectList1.add(treeSelect3);
// -------------- 模拟人员Tree数据结束 ------------------
return success(treeSelectList1);
}

View File

@ -4,7 +4,6 @@ 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 com.bonus.common.log.enums.OperaType;
@ -49,7 +48,7 @@ public class TypeController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(MaTypeListVo type) {
startPage();
List<MaTypeListVo> list = typeService.selectTypeListAndParent(type);
List<MaTypeListVo> list = typeService.selectTypeListAndParentInfo(type);
return getDataTable(list);
}

View File

@ -3,21 +3,20 @@ package com.bonus.material.ma.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
/**
* 维修班机具配置对象 ma_type_repair
*
* @author xsheng
* @date 2024-09-27
*
* @author syruan
*/
@EqualsAndHashCode(callSuper = false)
@Data
@ToString
public class TypeRepair extends BaseEntity
{
public class TypeRepair extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
@ -31,6 +30,9 @@ public class TypeRepair extends BaseEntity
@ApiModelProperty(value = "用户")
private Long userId;
@ApiModelProperty(value = "用户姓名")
private String userName;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
@ApiModelProperty(value = "数据所属组织")

View File

@ -25,6 +25,11 @@ public interface TypeKeeperMapper {
*/
List<TypeKeeper> selectTypeKeeperList(TypeKeeper typeKeeper);
/**
* 查询库管员配置列表-并关联查询用户名称
*/
List<TypeKeeper> selectTypeKeeperListAndUserName(TypeKeeper typeKeeper);
/**
* 新增库管员配置
*

View File

@ -2,6 +2,7 @@ package com.bonus.material.ma.mapper;
import java.util.List;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.ma.vo.MaTypeConfigVo;
import com.bonus.material.ma.vo.MaTypeListVo;
import com.bonus.material.ma.vo.MaTypeSelectVo;
import org.apache.ibatis.annotations.Mapper;
@ -66,6 +67,20 @@ public interface TypeMapper {
List<MaTypeListVo> selectTypeListAndParent(Type typeListVo);
/**
* 查询四级物资类型列表 -- 并且查询当前节点的父级节点名称
* @param type
* @return
*/
List<MaTypeConfigVo> selectFourLevelTypeListAndParent(Type type);
/**
* 查询三级物资类型列表 -- 并且查询当前节点的父级节点名称
* @param type
* @return
*/
List<MaTypeConfigVo> selectThreeLevelTypeListAndParent(Type type);
/**
* 新增物资类型
*

View File

@ -9,15 +9,14 @@ import com.bonus.material.ma.domain.TypeRepair;
* @author xsheng
* @date 2024-09-27
*/
public interface TypeRepairMapper
{
public interface TypeRepairMapper {
/**
* 查询维修班机具配置
*
* @param ID 维修班机具配置主键
* @return 维修班机具配置
*/
public TypeRepair selectTypeRepairByID(Long ID);
TypeRepair selectTypeRepairByID(Long ID);
/**
* 查询维修班机具配置列表
@ -25,7 +24,12 @@ public interface TypeRepairMapper
* @param typeRepair 维修班机具配置
* @return 维修班机具配置集合
*/
public List<TypeRepair> selectTypeRepairList(TypeRepair typeRepair);
List<TypeRepair> selectTypeRepairList(TypeRepair typeRepair);
/**
* 查询配置列表并关联查询用户姓名
*/
List<TypeRepair> selectTypeRepairListAndUserName(TypeRepair typeRepair);
/**
* 新增维修班机具配置
@ -33,7 +37,7 @@ public interface TypeRepairMapper
* @param typeRepair 维修班机具配置
* @return 结果
*/
public int insertTypeRepair(TypeRepair typeRepair);
int insertTypeRepair(TypeRepair typeRepair);
/**
* 修改维修班机具配置
@ -41,7 +45,7 @@ public interface TypeRepairMapper
* @param typeRepair 维修班机具配置
* @return 结果
*/
public int updateTypeRepair(TypeRepair typeRepair);
int updateTypeRepair(TypeRepair typeRepair);
/**
* 删除维修班机具配置
@ -49,7 +53,7 @@ public interface TypeRepairMapper
* @param ID 维修班机具配置主键
* @return 结果
*/
public int deleteTypeRepairByID(Long ID);
int deleteTypeRepairByID(Long ID);
/**
* 批量删除维修班机具配置
@ -57,5 +61,5 @@ public interface TypeRepairMapper
* @param IDs 需要删除的数据主键集合
* @return 结果
*/
public int deleteTypeRepairByIDs(Long[] IDs);
int deleteTypeRepairByIDs(Long[] IDs);
}

View File

@ -23,6 +23,11 @@ public interface ITypeKeeperService {
*/
List<TypeKeeper> selectTypeKeeperList(TypeKeeper typeKeeper);
/**
* 查询库管员配置列表-并关联查询用户名称
*/
List<TypeKeeper> selectTypeKeeperListAndUserName(TypeKeeper typeKeeper);
/**
* 新增库管员配置
*

View File

@ -9,8 +9,7 @@ import com.bonus.material.ma.domain.TypeRepair;
* @author xsheng
* @date 2024-09-27
*/
public interface ITypeRepairService
{
public interface ITypeRepairService {
/**
* 查询维修班机具配置
*
@ -27,6 +26,11 @@ public interface ITypeRepairService
*/
public List<TypeRepair> selectTypeRepairList(TypeRepair typeRepair);
/**
* 查询配置列表并关联查询用户姓名
*/
List<TypeRepair> selectTypeRepairListAndUserName(TypeRepair typeRepair);
/**
* 新增维修班机具配置
*

View File

@ -4,6 +4,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.MaTypeConfigVo;
import com.bonus.material.ma.vo.MaTypeListVo;
import com.bonus.material.ma.vo.MaTypeSelectVo;
@ -40,7 +41,14 @@ public interface ITypeService {
*/
List<Type> selectTypeList(Type type);
List<MaTypeListVo> selectTypeListAndParent(Type type);
List<MaTypeListVo> selectTypeListAndParentInfo(Type type);
/**
* 查询4级加3级的所有物资类型携带父级信息
* @param type 参数
*/
List<MaTypeConfigVo> selectThreeFourLevelTypeListAndParent(Type type);
/**
* 新增物资类型

View File

@ -11,8 +11,7 @@ import com.bonus.material.ma.service.ITypeKeeperService;
/**
* 库管员配置Service业务层处理
*
* @author xsheng
* @date 2024-09-27
* @author syruan
*/
@Service
public class TypeKeeperServiceImpl implements ITypeKeeperService {
@ -42,6 +41,16 @@ public class TypeKeeperServiceImpl implements ITypeKeeperService {
return typeKeeperMapper.selectTypeKeeperList(typeKeeper);
}
/**
* 查询库管员配置列表-并关联查询用户名称
*
* @param typeKeeper 查询条件
*/
@Override
public List<TypeKeeper> selectTypeKeeperListAndUserName(TypeKeeper typeKeeper) {
return typeKeeperMapper.selectTypeKeeperListAndUserName(typeKeeper);
}
/**
* 新增库管员配置
*

View File

@ -44,6 +44,16 @@ public class TypeRepairServiceImpl implements ITypeRepairService
return typeRepairMapper.selectTypeRepairList(typeRepair);
}
/**
* 查询配置列表并关联查询用户姓名
*
* @param typeRepair
*/
@Override
public List<TypeRepair> selectTypeRepairListAndUserName(TypeRepair typeRepair) {
return typeRepairMapper.selectTypeRepairListAndUserName(typeRepair);
}
/**
* 新增维修班机具配置
*

View File

@ -9,6 +9,7 @@ import com.bonus.common.biz.domain.TreeSelect;
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.MaTypeConfigVo;
import com.bonus.material.ma.vo.MaTypeListVo;
import com.bonus.material.ma.vo.MaTypeSelectVo;
import org.springframework.stereotype.Service;
@ -97,7 +98,7 @@ public class TypeServiceImpl implements ITypeService {
* @return 物资类型管理
*/
@Override
public List<MaTypeListVo> selectTypeListAndParent(Type type) {
public List<MaTypeListVo> selectTypeListAndParentInfo(Type type) {
// 如果是顶级节点则查询所有子节点
if (type != null && type.getLevel() != null && "0".equals(type.getLevel())) {
type.setLevel(null);
@ -156,6 +157,32 @@ public class TypeServiceImpl implements ITypeService {
return maTypeListVos;
}
/**
* 查询4级加3级的所有物资类型携带父级信息
*
* @param type 参数
*/
@Override
public List<MaTypeConfigVo> selectThreeFourLevelTypeListAndParent(Type type) {
List<MaTypeConfigVo> fourLevelTypeList = typeMapper.selectFourLevelTypeListAndParent(type);
if (fourLevelTypeList != null && !fourLevelTypeList.isEmpty()) {
List<MaTypeConfigVo> threeLevelTypeList = typeMapper.selectThreeLevelTypeListAndParent(type);
if (threeLevelTypeList != null && !threeLevelTypeList.isEmpty()) {
// 循环把三级节点放入fourLevelTypeList集合中
for (MaTypeConfigVo threeLevelType : threeLevelTypeList) {
// 循环把三级节点放入fourLevelTypeList集合中
for (MaTypeConfigVo fourLevelType : fourLevelTypeList) {
// 如果三级节点的父级id和四级节点的id相同则把三级节点放入四级节点的children集合中
if (threeLevelType.getParentId().equals(fourLevelType.getTypeId())) {
fourLevelType.getChildren().add(threeLevelType);
}
}
}
}
}
return fourLevelTypeList;
}
/**
* 新增物资类型管理
*

View File

@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
@ -13,7 +16,7 @@ import lombok.ToString;
*/
@Data
@ToString
public class MaTypeConfigVo {
public class MaTypeConfigVo implements java.io.Serializable {
@ApiModelProperty(value = "配置id")
private Long id;
@ -24,8 +27,17 @@ public class MaTypeConfigVo {
@ApiModelProperty(value = "物资类型名称")
private String typeName;
@ApiModelProperty(value = "父级id")
private Long parentId;
@ApiModelProperty(value = "物资仓库id")
private Long houseId;
@ApiModelProperty(value = "物资仓库名称")
private String houseName;
@ApiModelProperty(value = "库管员id")
private String keeperUserId;
private Long keeperUserId;
@ApiModelProperty(value = "库管员姓名")
private String keeperUserName;
@ -36,4 +48,22 @@ public class MaTypeConfigVo {
@ApiModelProperty(value = "维修员姓名")
private String repairUserName;
private String parentOneLevelName;
private String parentTwoLevelName;
private String parentThreeLevelName;
private String parentFourLevelName;
@ApiModelProperty(value = "请求API时调用参数--左侧Tree用户ID")
private Long userId;
@ApiModelProperty(value = "请求API时调用参数--左侧Tree层级")
private String level;
@ApiModelProperty(value = "子节点")
private List<MaTypeConfigVo> children = new ArrayList<>();
}

View File

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ID" column="ID" />
<result property="typeId" column="type_id" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="companyId" column="company_id" />
@ -68,4 +69,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{ID}
</foreach>
</delete>
<select id="selectTypeKeeperListAndUserName" resultMap="TypeKeeperResult">
select
tk.ID, tk.type_id, tk.user_id, tk.create_time, tk.update_time, tk.company_id, u.user_name
from
ma_type_keeper tk
left join
sys_user u on tk.user_id = u.user_id
<where>
<if test="userId != null "> and tk.user_id = #{userId}</if>
<if test="companyId != null "> and tk.company_id = #{companyId}</if>
</where>
</select>
</mapper>

View File

@ -70,6 +70,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="parentFourLevelName" column="parentOneLevelName" />
</resultMap>
<resultMap type="com.bonus.material.ma.vo.MaTypeConfigVo" id="MaTypeConfigVoResult">
<result property="typeId" column="type_id" />
<result property="typeName" column="type_name" />
<result property="parentId" column="parent_id" />
<result property="level" column="level" />
<result property="parentOneLevelName" column="parentFourLevelName" />
<result property="parentTwoLevelName" column="parentThreeLevelName" />
<result property="parentThreeLevelName" column="parentTwoLevelName" />
<result property="parentFourLevelName" column="parentOneLevelName" />
</resultMap>
<sql id="selectTypeVo">
select
type_id, type_name, parent_id, storage_num, type_code, model_code, unit_id, manage_type, lease_price,
@ -331,4 +342,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where
parent_id = #{typeId} and del_flag = 0
</select>
<select id="selectFourLevelTypeListAndParent" resultMap="MaTypeConfigVoResult">
SELECT
a.*, -- 当前层级的所有字段
a.type_name AS parentFourLevelName, -- 当前层级名称
b.type_name AS parentThreeLevelName, -- 父层级名称
c.type_name AS parentTwoLevelName, -- 祖父层级名称
d.type_name AS parentOneLevelName -- 曾祖父层级名称
FROM
ma_type a
LEFT JOIN
ma_type b ON a.parent_id = b.type_id and b.del_flag = '0' -- 第一层,父类型
LEFT JOIN
ma_type c ON b.parent_id = c.type_id and c.del_flag = '0' -- 第二层,祖父类型
LEFT JOIN
ma_type d ON c.parent_id = d.type_id and d.del_flag = '0' -- 第三层,曾祖父类型
WHERE
a.del_flag = 0 AND a.`level` = '4'
</select>
<select id="selectThreeLevelTypeListAndParent" resultMap="MaTypeConfigVoResult">
SELECT
a.*,
a.type_name AS parentThreeLevelName,
b.type_name AS parentTwoLevelName, -- 父类型名称
c.type_name AS parentOneLevelName, -- 祖父类型名称
NULL AS parentFourLevelName
FROM
ma_type a
LEFT JOIN
ma_type b ON a.parent_id = b.type_id -- 第一层,父类型
LEFT JOIN
ma_type c ON b.parent_id = c.type_id -- 第二层,祖父类型
WHERE
a.del_flag = 0 AND a.`level` = '3'
</select>
</mapper>

View File

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ID" column="ID" />
<result property="typeId" column="type_id" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="companyId" column="company_id" />
@ -69,4 +70,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{ID}
</foreach>
</delete>
<select id="selectTypeRepairListAndUserName" resultMap="TypeRepairResult">
select
m.type_id, su.nick_name as user_name, m.create_time
from
ma_type_keeper mtk
left join
ma_type m ON m.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
</select>
</mapper>