wms新增物料base_material_info模块
parent
fe41ac0388
commit
2c1c2ff7ad
@ -0,0 +1,114 @@
|
||||
package org.dromara.wms.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.wms.domain.BaseMaterialInfo;
|
||||
import org.dromara.wms.domain.bo.BaseMaterialInfoBo;
|
||||
import org.dromara.wms.domain.vo.BaseMaterialInfoVo;
|
||||
import org.dromara.wms.service.IBaseMaterialInfoService;
|
||||
import org.dromara.wms.utils.BarcodePrintUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 物料信息
|
||||
* 前端访问路由地址为:/mes/baseMaterialInfo
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/baseMaterialInfo")
|
||||
public class BaseMaterialInfoController extends BaseController {
|
||||
|
||||
private final IBaseMaterialInfoService baseMaterialInfoService;
|
||||
|
||||
/**
|
||||
* 查询物料信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BaseMaterialInfoVo> list(BaseMaterialInfoBo bo, PageQuery pageQuery) {
|
||||
return baseMaterialInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出物料信息列表
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:export")
|
||||
@Log(title = "物料信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BaseMaterialInfoBo bo, HttpServletResponse response) {
|
||||
List<BaseMaterialInfoVo> list = baseMaterialInfoService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "物料信息", BaseMaterialInfoVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物料信息详细信息
|
||||
*
|
||||
* @param materialId 主键
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:query")
|
||||
@GetMapping("/{materialId}")
|
||||
public R<BaseMaterialInfoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long materialId) {
|
||||
return R.ok(baseMaterialInfoService.queryById(materialId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:add")
|
||||
@Log(title = "物料信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BaseMaterialInfoBo bo) {
|
||||
return toAjax(baseMaterialInfoService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料信息
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:edit")
|
||||
@Log(title = "物料信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BaseMaterialInfoBo bo) {
|
||||
return toAjax(baseMaterialInfoService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料信息
|
||||
*
|
||||
* @param materialIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("mes:baseMaterialInfo:remove")
|
||||
@Log(title = "物料信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{materialIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] materialIds) {
|
||||
return toAjax(baseMaterialInfoService.deleteWithValidByIds(List.of(materialIds), true));
|
||||
}
|
||||
|
||||
@GetMapping("materialList")
|
||||
public R<List<BaseMaterialInfoVo>> materialList(BaseMaterialInfo materialInfo){
|
||||
// BarcodePrintUtils.print();
|
||||
return R.ok(baseMaterialInfoService.materialList(materialInfo));
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.wms.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.wms.domain.BaseMaterialInfo;
|
||||
import org.dromara.wms.domain.vo.BaseMaterialInfoVo;
|
||||
|
||||
/**
|
||||
* 物料信息Mapper接口
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
public interface BaseMaterialInfoMapper extends BaseMapperPlus<BaseMaterialInfo, BaseMaterialInfoVo> {
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package org.dromara.wms.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.wms.domain.BaseMaterialInfo;
|
||||
import org.dromara.wms.domain.bo.BaseMaterialInfoBo;
|
||||
import org.dromara.wms.domain.vo.BaseMaterialInfoVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料信息Service接口
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
public interface IBaseMaterialInfoService {
|
||||
|
||||
/**
|
||||
* 查询物料信息
|
||||
*
|
||||
* @param materialId 主键
|
||||
* @return 物料信息
|
||||
*/
|
||||
BaseMaterialInfoVo queryById(Long materialId);
|
||||
|
||||
/**
|
||||
* 分页查询物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物料信息分页列表
|
||||
*/
|
||||
TableDataInfo<BaseMaterialInfoVo> queryPageList(BaseMaterialInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料信息列表
|
||||
*/
|
||||
List<BaseMaterialInfoVo> queryList(BaseMaterialInfoBo bo);
|
||||
|
||||
/**
|
||||
* 新增物料信息
|
||||
*
|
||||
* @param bo 物料信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(BaseMaterialInfoBo bo);
|
||||
|
||||
/**
|
||||
* 修改物料信息
|
||||
*
|
||||
* @param bo 物料信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(BaseMaterialInfoBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
|
||||
List<BaseMaterialInfoVo> materialList(BaseMaterialInfo materialInfo);
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
package org.dromara.wms.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.wms.domain.BaseMaterialInfo;
|
||||
import org.dromara.wms.domain.bo.BaseMaterialInfoBo;
|
||||
import org.dromara.wms.domain.vo.BaseMaterialInfoVo;
|
||||
import org.dromara.wms.mapper.BaseMaterialInfoMapper;
|
||||
import org.dromara.wms.service.IBaseMaterialInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 物料信息Service业务层处理
|
||||
*
|
||||
* @author zangch
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService {
|
||||
|
||||
private final BaseMaterialInfoMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询物料信息
|
||||
*
|
||||
* @param materialId 主键
|
||||
* @return 物料信息
|
||||
*/
|
||||
@Override
|
||||
public BaseMaterialInfoVo queryById(Long materialId){
|
||||
return baseMapper.selectVoById(materialId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物料信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<BaseMaterialInfoVo> queryPageList(BaseMaterialInfoBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BaseMaterialInfo> lqw = buildQueryWrapper(bo);
|
||||
Page<BaseMaterialInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<BaseMaterialInfoVo> queryList(BaseMaterialInfoBo bo) {
|
||||
LambdaQueryWrapper<BaseMaterialInfo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BaseMaterialInfo> buildQueryWrapper(BaseMaterialInfoBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<BaseMaterialInfo> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getMaterialId() != null, BaseMaterialInfo::getMaterialId, bo.getMaterialId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getErpId()), BaseMaterialInfo::getErpId, bo.getErpId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCode()), BaseMaterialInfo::getMaterialCode, bo.getMaterialCode());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOldMaterialCode()), BaseMaterialInfo::getOldMaterialCode, bo.getOldMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), BaseMaterialInfo::getMaterialName, bo.getMaterialName());
|
||||
lqw.eq(bo.getMaterialTypeId() != null, BaseMaterialInfo::getMaterialTypeId, bo.getMaterialTypeId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCategories()), BaseMaterialInfo::getMaterialCategories, bo.getMaterialCategories());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialSubclass()), BaseMaterialInfo::getMaterialSubclass, bo.getMaterialSubclass());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBatchFlag()), BaseMaterialInfo::getBatchFlag, bo.getBatchFlag());
|
||||
lqw.eq(bo.getBatchAmount() != null, BaseMaterialInfo::getBatchAmount, bo.getBatchAmount());
|
||||
lqw.eq(bo.getMaterialUnitId() != null, BaseMaterialInfo::getMaterialUnitId, bo.getMaterialUnitId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialUnit()), BaseMaterialInfo::getMaterialUnit, bo.getMaterialUnit());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialMatkl()), BaseMaterialInfo::getMaterialMatkl, bo.getMaterialMatkl());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialSpec()), BaseMaterialInfo::getMaterialSpec, bo.getMaterialSpec());
|
||||
lqw.eq(bo.getNetWeight() != null, BaseMaterialInfo::getNetWeight, bo.getNetWeight());
|
||||
lqw.eq(bo.getGrossWeight() != null, BaseMaterialInfo::getGrossWeight, bo.getGrossWeight());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAlwaysFlag()), BaseMaterialInfo::getAlwaysFlag, bo.getAlwaysFlag());
|
||||
lqw.eq(bo.getFactoryId() != null, BaseMaterialInfo::getFactoryId, bo.getFactoryId());
|
||||
lqw.eq(bo.getCreateOrgId() != null, BaseMaterialInfo::getCreateOrgId, bo.getCreateOrgId());
|
||||
lqw.eq(bo.getUseOrgId() != null, BaseMaterialInfo::getUseOrgId, bo.getUseOrgId());
|
||||
lqw.eq(bo.getProdLineId() != null, BaseMaterialInfo::getProdLineId, bo.getProdLineId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getActiveFlag()), BaseMaterialInfo::getActiveFlag, bo.getActiveFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDeletedFlag()), BaseMaterialInfo::getDeletedFlag, bo.getDeletedFlag());
|
||||
lqw.eq(bo.getPurchasePriceUnitId() != null, BaseMaterialInfo::getPurchasePriceUnitId, bo.getPurchasePriceUnitId());
|
||||
lqw.between(params.get("beginApproveDate") != null && params.get("endApproveDate") != null,
|
||||
BaseMaterialInfo::getApproveDate ,params.get("beginApproveDate"), params.get("endApproveDate"));
|
||||
lqw.eq(bo.getErpModifyDate() != null, BaseMaterialInfo::getErpModifyDate, bo.getErpModifyDate());
|
||||
lqw.eq(bo.getMaxStockAmount() != null, BaseMaterialInfo::getMaxStockAmount, bo.getMaxStockAmount());
|
||||
lqw.eq(bo.getMinStockAmount() != null, BaseMaterialInfo::getMinStockAmount, bo.getMinStockAmount());
|
||||
lqw.eq(bo.getSafeStockAmount() != null, BaseMaterialInfo::getSafeStockAmount, bo.getSafeStockAmount());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getApplyFlag()), BaseMaterialInfo::getApplyFlag, bo.getApplyFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialClassfication()), BaseMaterialInfo::getMaterialClassfication, bo.getMaterialClassfication());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAutoOutstockFlag()), BaseMaterialInfo::getAutoOutstockFlag, bo.getAutoOutstockFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAccessoriesFlag()), BaseMaterialInfo::getAccessoriesFlag, bo.getAccessoriesFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLowValueConsumableFlag()), BaseMaterialInfo::getLowValueConsumableFlag, bo.getLowValueConsumableFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBrand()), BaseMaterialInfo::getBrand, bo.getBrand());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPlyrating()), BaseMaterialInfo::getPlyrating, bo.getPlyrating());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPattern()), BaseMaterialInfo::getPattern, bo.getPattern());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSpeedLevel()), BaseMaterialInfo::getSpeedLevel, bo.getSpeedLevel());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLoad()), BaseMaterialInfo::getLoad, bo.getLoad());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTireMarkings()), BaseMaterialInfo::getTireMarkings, bo.getTireMarkings());
|
||||
lqw.eq(bo.getMinParkingTime() != null, BaseMaterialInfo::getMinParkingTime, bo.getMinParkingTime());
|
||||
lqw.eq(bo.getMaxParkingTime() != null, BaseMaterialInfo::getMaxParkingTime, bo.getMaxParkingTime());
|
||||
lqw.eq(bo.getStandardWeight() != null, BaseMaterialInfo::getStandardWeight, bo.getStandardWeight());
|
||||
lqw.eq(bo.getWeightUpperLimit() != null, BaseMaterialInfo::getWeightUpperLimit, bo.getWeightUpperLimit());
|
||||
lqw.eq(bo.getWeightLowerLimit() != null, BaseMaterialInfo::getWeightLowerLimit, bo.getWeightLowerLimit());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInnerTubeFlag()), BaseMaterialInfo::getInnerTubeFlag, bo.getInnerTubeFlag());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSaleType()), BaseMaterialInfo::getSaleType, bo.getSaleType());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料信息
|
||||
*
|
||||
* @param bo 物料信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(BaseMaterialInfoBo bo) {
|
||||
BaseMaterialInfo add = MapstructUtils.convert(bo, BaseMaterialInfo.class);
|
||||
validEntityBeforeSave(add);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料信息
|
||||
*
|
||||
* @param bo 物料信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(BaseMaterialInfoBo bo) {
|
||||
BaseMaterialInfo update = MapstructUtils.convert(bo, BaseMaterialInfo.class);
|
||||
validEntityBeforeSave(update);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(BaseMaterialInfo entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseMaterialInfoVo> materialList(BaseMaterialInfo materialInfo) {
|
||||
LambdaQueryWrapper<BaseMaterialInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BaseMaterialInfo::getMaterialCategories,materialInfo.getMaterialCategories());
|
||||
return baseMapper.selectVoList(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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.BaseMaterialInfoMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue