feat(wms): 物料大类管理功能由字典改为数据库表
- 添加物料大类信息相关实体类、BO、VO等 - 实现物料大类信息的增删改查功能 - 更新相关领域对象,将物料大类从字典改为数据库表关联 - 优化查询性能,使用MPJ插件进行关联查询master
parent
7f85222d6a
commit
c39d251112
@ -0,0 +1,17 @@
|
|||||||
|
package org.dromara.wms.mapper;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
import org.dromara.wms.domain.BaseMaterialCategory;
|
||||||
|
import org.dromara.wms.domain.vo.BaseMaterialCategoryVo;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料大类信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author xins
|
||||||
|
* @date 2025-02-21
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface BaseMaterialCategoryMapper extends BaseMapperPlus<BaseMaterialCategory, BaseMaterialCategoryVo> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package org.dromara.wms.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.yulichang.toolkit.JoinWrappers;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.wms.domain.BaseMaterialCategory;
|
||||||
|
import org.dromara.wms.domain.bo.BaseMaterialCategoryBo;
|
||||||
|
import org.dromara.wms.domain.vo.BaseMaterialCategoryVo;
|
||||||
|
import org.dromara.wms.mapper.BaseMaterialCategoryMapper;
|
||||||
|
import org.dromara.wms.service.IBaseMaterialCategoryService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料大类信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xins
|
||||||
|
* @date 2025-02-21
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class BaseMaterialCategoryServiceImpl implements IBaseMaterialCategoryService {
|
||||||
|
|
||||||
|
private final BaseMaterialCategoryMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询物料大类信息
|
||||||
|
*
|
||||||
|
* @param materialCategoryId 主键
|
||||||
|
* @return 物料大类信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BaseMaterialCategoryVo queryById(Long materialCategoryId){
|
||||||
|
return baseMapper.selectVoById(materialCategoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询物料大类信息列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 物料大类信息分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<BaseMaterialCategoryVo> queryPageList(BaseMaterialCategoryBo bo, PageQuery pageQuery) {
|
||||||
|
MPJLambdaWrapper<BaseMaterialCategory> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<BaseMaterialCategoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的物料大类信息列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 物料大类信息列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BaseMaterialCategoryVo> queryList(BaseMaterialCategoryBo bo) {
|
||||||
|
MPJLambdaWrapper<BaseMaterialCategory> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MPJLambdaWrapper<BaseMaterialCategory> buildQueryWrapper(BaseMaterialCategoryBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
MPJLambdaWrapper<BaseMaterialCategory> lqw = JoinWrappers.lambda(BaseMaterialCategory.class)
|
||||||
|
.selectAll(BaseMaterialCategory.class)
|
||||||
|
.eq(bo.getMaterialCategoryId() != null, BaseMaterialCategory::getMaterialCategoryId, bo.getMaterialCategoryId())
|
||||||
|
.eq(StringUtils.isNotBlank(bo.getMaterialCategoryCode()), BaseMaterialCategory::getMaterialCategoryCode, bo.getMaterialCategoryCode())
|
||||||
|
.like(StringUtils.isNotBlank(bo.getMaterialCategoryName()), BaseMaterialCategory::getMaterialCategoryName, bo.getMaterialCategoryName())
|
||||||
|
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), BaseMaterialCategory::getActiveFlag, bo.getActiveFlag())
|
||||||
|
.orderByDesc(BaseMaterialCategory::getCreateTime);
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增物料大类信息
|
||||||
|
*
|
||||||
|
* @param bo 物料大类信息
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(BaseMaterialCategoryBo bo) {
|
||||||
|
BaseMaterialCategory add = MapstructUtils.convert(bo, BaseMaterialCategory.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setMaterialCategoryId(add.getMaterialCategoryId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改物料大类信息
|
||||||
|
*
|
||||||
|
* @param bo 物料大类信息
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(BaseMaterialCategoryBo bo) {
|
||||||
|
BaseMaterialCategory update = MapstructUtils.convert(bo, BaseMaterialCategory.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(BaseMaterialCategory entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除物料大类信息信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.dromara.wms.mapper.BaseMaterialCategoryMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue