wms新增物料wms_inventory模块

master
maxw@mesnac.com 2 weeks ago
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,98 @@
package org.dromara.wms.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.math.BigDecimal;
import java.util.Date;
/**
* wms_inventory
*
* @author LionLi
* @date 2025-01-07
*/
@Data
@TableName("wms_inventory")
public class WmsInventory{
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(type = IdType.AUTO)
private Long inventoryId;
/**
*
*/
private String batchCode;
/**
* id
*/
private Long materialId;
/**
*
*/
private String locationCode;
/**
*
*/
private Long materialCategories;
/**
*
*/
private BigDecimal inventoryQty;
/**
* 01
*/
private String lockState;
/**
* 001
*/
private String inventoryStatus;
/**
* ID
*/
private Long storeId;
/**
* id
*/
private String tenantId;
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
@TableField(exist = false)
private String warehouseCode;//字段映射
}

@ -0,0 +1,80 @@
package org.dromara.wms.domain.bo;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import org.dromara.wms.domain.WmsInventory;
import java.math.BigDecimal;
/**
* wms_inventory
*
* @author LionLi
* @date 2025-01-07
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = WmsInventory.class, reverseConvertGenerate = false)
public class WmsInventoryBo extends BaseEntity {
/**
*
*/
@NotNull(message = "表主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long inventoryId;
/**
*
*/
@NotBlank(message = "批次码不能为空", groups = { AddGroup.class, EditGroup.class })
private String batchCode;
/**
* id
*/
@NotNull(message = "物料id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long materialId;
/**
*
*/
@NotBlank(message = "库位编码不能为空", groups = { AddGroup.class, EditGroup.class })
private String locationCode;
/**
*
*/
@NotNull(message = "物料大类不能为空", groups = { AddGroup.class, EditGroup.class })
private Long materialCategories;
/**
*
*/
@NotNull(message = "库存数量不能为空", groups = { AddGroup.class, EditGroup.class })
private BigDecimal inventoryQty;
/**
* 01
*/
@NotBlank(message = "锁定状态0未锁定1锁定不能为空", groups = { AddGroup.class, EditGroup.class })
private String lockState;
/**
* 001
*/
@NotBlank(message = "库存状态0库存归01正常不能为空", groups = { AddGroup.class, EditGroup.class })
private String inventoryStatus;
/**
* ID
*/
@NotNull(message = "仓库ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long storeId;
private String tenantId;
}

@ -0,0 +1,117 @@
package org.dromara.wms.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.wms.domain.WmsInventory;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* wms_inventory
*
* @author LionLi
* @date 2025-01-07
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = WmsInventory.class)
public class WmsInventoryVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "表主键")
private Long inventoryId;
/**
*
*/
@ExcelProperty(value = "批次码")
private String batchCode;
/**
* id
*/
@ExcelProperty(value = "物料id")
private Long materialId;
/**
*
*/
@ExcelProperty(value = "库位编码")
private String locationCode;
/**
*
*/
@ExcelProperty(value = "物料大类")
private Long materialCategories;
/**
*
*/
@ExcelProperty(value = "库存数量")
private BigDecimal inventoryQty;
/**
* 01
*/
@ExcelProperty(value = "锁定状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=未锁定1锁定")
private String lockState;
/**
* 001
*/
@ExcelProperty(value = "库存状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=库存归01正常")
private String inventoryStatus;
/**
* ID
*/
@ExcelProperty(value = "仓库ID")
private Long storeId;
/**
* id
*/
private String tenantId;
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
private String warehouseCode;//字段映射
}

@ -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…
Cancel
Save