wms新增物料wms_inventory模块
parent
dcf6c749dd
commit
2d647456d4
@ -0,0 +1,116 @@
|
||||
package org.dromara.wms.controller;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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.WmsInventory;
|
||||
import org.dromara.wms.domain.bo.WmsInventoryBo;
|
||||
import org.dromara.wms.domain.vo.WmsInventoryVo;
|
||||
import org.dromara.wms.service.IWmsInventoryService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 物料库存
|
||||
* 前端访问路由地址为:/system/inventory
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/inventory")
|
||||
public class WmsInventoryController extends BaseController {
|
||||
|
||||
private final IWmsInventoryService wmsInventoryService;
|
||||
|
||||
/**
|
||||
* 查询物料库存列表
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsInventoryVo> list(WmsInventoryBo bo, PageQuery pageQuery) {
|
||||
return wmsInventoryService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出物料库存列表
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:export")
|
||||
@Log(title = "物料库存", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsInventoryBo bo, HttpServletResponse response) {
|
||||
List<WmsInventoryVo> list = wmsInventoryService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "物料库存", WmsInventoryVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物料库存详细信息
|
||||
*
|
||||
* @param inventoryId 主键
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:query")
|
||||
@GetMapping("/{inventoryId}")
|
||||
public R<WmsInventoryVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long inventoryId) {
|
||||
return R.ok(wmsInventoryService.queryById(inventoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料库存
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:add")
|
||||
@Log(title = "物料库存", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsInventoryBo bo) {
|
||||
return toAjax(wmsInventoryService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料库存
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:edit")
|
||||
@Log(title = "物料库存", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsInventoryBo bo) {
|
||||
return toAjax(wmsInventoryService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料库存
|
||||
*
|
||||
* @param inventoryIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:inventory:remove")
|
||||
@Log(title = "物料库存", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{inventoryIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] inventoryIds) {
|
||||
return toAjax(wmsInventoryService.deleteWithValidByIds(List.of(inventoryIds), true));
|
||||
}
|
||||
/**
|
||||
* 查询物料总数
|
||||
*/
|
||||
@GetMapping("materailCount")
|
||||
public R<BigDecimal> materailCount(WmsInventory materialId){
|
||||
BigDecimal bigDecimal = wmsInventoryService.materailCount(materialId);
|
||||
return R.ok(wmsInventoryService.materailCount(materialId));
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.dromara.wms.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.wms.domain.WmsInventory;
|
||||
import org.dromara.wms.domain.vo.WmsInventoryVo;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 物料库存Mapper接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
public interface WmsInventoryMapper extends BaseMapperPlus<WmsInventory, WmsInventoryVo> {
|
||||
|
||||
BigDecimal materailCount(@Param("entity") WmsInventory wmsInventory);
|
||||
}
|
@ -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.WmsInventory;
|
||||
import org.dromara.wms.domain.bo.WmsInventoryBo;
|
||||
import org.dromara.wms.domain.vo.WmsInventoryVo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料库存Service接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
public interface IWmsInventoryService {
|
||||
|
||||
/**
|
||||
* 查询物料库存
|
||||
*
|
||||
* @param inventoryId 主键
|
||||
* @return 物料库存
|
||||
*/
|
||||
WmsInventoryVo queryById(Long inventoryId);
|
||||
|
||||
/**
|
||||
* 分页查询物料库存列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物料库存分页列表
|
||||
*/
|
||||
TableDataInfo<WmsInventoryVo> queryPageList(WmsInventoryBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料库存列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料库存列表
|
||||
*/
|
||||
List<WmsInventoryVo> queryList(WmsInventoryBo bo);
|
||||
|
||||
/**
|
||||
* 新增物料库存
|
||||
*
|
||||
* @param bo 物料库存
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(WmsInventoryBo bo);
|
||||
|
||||
/**
|
||||
* 修改物料库存
|
||||
*
|
||||
* @param bo 物料库存
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(WmsInventoryBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料库存信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
BigDecimal materailCount(WmsInventory materialId);
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package org.dromara.wms.service.impl;
|
||||
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
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.WmsBaseWarehouse;
|
||||
import org.dromara.wms.domain.WmsConfiguration;
|
||||
import org.dromara.wms.domain.WmsInventory;
|
||||
import org.dromara.wms.domain.bo.WmsConfigurationBo;
|
||||
import org.dromara.wms.domain.bo.WmsInventoryBo;
|
||||
import org.dromara.wms.domain.vo.WmsInventoryVo;
|
||||
import org.dromara.wms.mapper.WmsInventoryMapper;
|
||||
import org.dromara.wms.service.IWmsInventoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 物料库存Service业务层处理
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-07
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsInventoryServiceImpl implements IWmsInventoryService {
|
||||
|
||||
private final WmsInventoryMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询物料库存
|
||||
*
|
||||
* @param inventoryId 主键
|
||||
* @return 物料库存
|
||||
*/
|
||||
@Override
|
||||
public WmsInventoryVo queryById(Long inventoryId){
|
||||
return baseMapper.selectVoById(inventoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询物料库存列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物料库存分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<WmsInventoryVo> queryPageList(WmsInventoryBo bo, PageQuery pageQuery) {
|
||||
// LambdaQueryWrapper<WmsInventory> lqw = buildQueryWrapper(bo);
|
||||
MPJLambdaWrapper<WmsInventory> lqw = buildJoinQueryWrapper(bo);
|
||||
lqw.orderByDesc(WmsInventory::getCreateTime);
|
||||
Page<WmsInventoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的物料库存列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物料库存列表
|
||||
*/
|
||||
@Override
|
||||
public List<WmsInventoryVo> queryList(WmsInventoryBo bo) {
|
||||
LambdaQueryWrapper<WmsInventory> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsInventory> buildQueryWrapper(WmsInventoryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WmsInventory> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getInventoryId() != null, WmsInventory::getInventoryId, bo.getInventoryId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBatchCode()), WmsInventory::getBatchCode, bo.getBatchCode());
|
||||
lqw.eq(bo.getMaterialId() != null, WmsInventory::getMaterialId, bo.getMaterialId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLocationCode()), WmsInventory::getLocationCode, bo.getLocationCode());
|
||||
lqw.eq(bo.getMaterialCategories() != null, WmsInventory::getMaterialCategories, bo.getMaterialCategories());
|
||||
lqw.eq(bo.getInventoryQty() != null, WmsInventory::getInventoryQty, bo.getInventoryQty());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLockState()), WmsInventory::getLockState, bo.getLockState());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInventoryStatus()), WmsInventory::getInventoryStatus, bo.getInventoryStatus());
|
||||
lqw.eq(bo.getStoreId() != null, WmsInventory::getStoreId, bo.getStoreId());
|
||||
return lqw;
|
||||
}
|
||||
private MPJLambdaWrapper<WmsInventory> buildJoinQueryWrapper(WmsInventoryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<WmsInventory> lqw = JoinWrappers.lambda(WmsInventory.class)
|
||||
.selectAll(WmsInventory.class)
|
||||
.select(WmsBaseWarehouse::getWarehouseCode)
|
||||
.leftJoin(WmsBaseWarehouse.class, WmsBaseWarehouse::getWarehouseId, WmsInventory::getStoreId);
|
||||
lqw.eq(bo.getInventoryId() != null, WmsInventory::getInventoryId, bo.getInventoryId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBatchCode()), WmsInventory::getBatchCode, bo.getBatchCode());
|
||||
lqw.eq(bo.getMaterialId() != null, WmsInventory::getMaterialId, bo.getMaterialId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLocationCode()), WmsInventory::getLocationCode, bo.getLocationCode());
|
||||
lqw.eq(bo.getMaterialCategories() != null, WmsInventory::getMaterialCategories, bo.getMaterialCategories());
|
||||
lqw.eq(bo.getInventoryQty() != null, WmsInventory::getInventoryQty, bo.getInventoryQty());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLockState()), WmsInventory::getLockState, bo.getLockState());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInventoryStatus()), WmsInventory::getInventoryStatus, bo.getInventoryStatus());
|
||||
lqw.eq(bo.getStoreId() != null, WmsInventory::getStoreId, bo.getStoreId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物料库存
|
||||
*
|
||||
* @param bo 物料库存
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(WmsInventoryBo bo) {
|
||||
WmsInventory add = MapstructUtils.convert(bo, WmsInventory.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setInventoryId(add.getInventoryId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物料库存
|
||||
*
|
||||
* @param bo 物料库存
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(WmsInventoryBo bo) {
|
||||
WmsInventory update = MapstructUtils.convert(bo, WmsInventory.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(WmsInventory entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal materailCount(WmsInventory wmsInventory) {
|
||||
return baseMapper.materailCount(wmsInventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除物料库存信息
|
||||
*
|
||||
* @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,16 @@
|
||||
<?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.WmsInventoryMapper">
|
||||
|
||||
<select id="materailCount" resultType="java.math.BigDecimal"
|
||||
parameterType="org.dromara.wms.domain.WmsInventory">
|
||||
SELECT
|
||||
ISNULL(SUM(x.inventory_qty),0)
|
||||
FROM
|
||||
hwmom.dbo.wms_inventory x
|
||||
where
|
||||
x.material_id = #{entity.materialId}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue