wms新增物料wms_outstock_order模块
parent
2d647456d4
commit
7767674518
@ -0,0 +1,106 @@
|
||||
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.bo.WmsOutstockOrderBo;
|
||||
import org.dromara.wms.domain.vo.WmsOutstockOrderVo;
|
||||
import org.dromara.wms.service.IWmsOutstockOrderService;
|
||||
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/outstockOrder
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/outstockOrder")
|
||||
public class WmsOutstockOrderController extends BaseController {
|
||||
|
||||
private final IWmsOutstockOrderService wmsOutstockOrderService;
|
||||
|
||||
/**
|
||||
* 查询出库单列表
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsOutstockOrderVo> list(WmsOutstockOrderBo bo, PageQuery pageQuery) {
|
||||
return wmsOutstockOrderService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出出库单列表
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:export")
|
||||
@Log(title = "出库单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsOutstockOrderBo bo, HttpServletResponse response) {
|
||||
List<WmsOutstockOrderVo> list = wmsOutstockOrderService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "出库单", WmsOutstockOrderVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取出库单详细信息
|
||||
*
|
||||
* @param outstockId 主键
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:query")
|
||||
@GetMapping("/{outstockId}")
|
||||
public R<WmsOutstockOrderVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long outstockId) {
|
||||
return R.ok(wmsOutstockOrderService.queryById(outstockId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增出库单
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:add")
|
||||
@Log(title = "出库单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsOutstockOrderBo bo) {
|
||||
return toAjax(wmsOutstockOrderService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改出库单
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:edit")
|
||||
@Log(title = "出库单", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsOutstockOrderBo bo) {
|
||||
return toAjax(wmsOutstockOrderService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除出库单
|
||||
*
|
||||
* @param outstockIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:outstockOrder:remove")
|
||||
@Log(title = "出库单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{outstockIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] outstockIds) {
|
||||
return toAjax(wmsOutstockOrderService.deleteWithValidByIds(List.of(outstockIds), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
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 com.ibm.icu.math.BigDecimal;
|
||||
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.WmsOutstockDetail;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 出库单-物料视图对象 wms_outstock_detail
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = WmsOutstockDetail.class)
|
||||
public class WmsOutstockDetailVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 表主键
|
||||
*/
|
||||
@ExcelProperty(value = "表主键")
|
||||
private Long outstockDetailId;
|
||||
|
||||
/**
|
||||
* 出库单号
|
||||
*/
|
||||
@ExcelProperty(value = "出库单号")
|
||||
private String outstockCode;
|
||||
|
||||
/**
|
||||
* 出库单 主键
|
||||
*/
|
||||
@ExcelProperty(value = "出库单 主键")
|
||||
private Long outstockId;
|
||||
|
||||
/**
|
||||
* 物料id
|
||||
*/
|
||||
@ExcelProperty(value = "物料id")
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 出库数量
|
||||
*/
|
||||
@ExcelProperty(value = "出库数量")
|
||||
private BigDecimal outstockQty;
|
||||
|
||||
/**
|
||||
* 物料大类
|
||||
*/
|
||||
@ExcelProperty(value = "物料大类")
|
||||
private String materialCategories;
|
||||
/**
|
||||
* 租户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 materialCode;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.wms.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.wms.domain.WmsOutstockOrder;
|
||||
import org.dromara.wms.domain.vo.WmsOutstockOrderVo;
|
||||
|
||||
/**
|
||||
* 出库单Mapper接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface WmsOutstockOrderMapper extends BaseMapperPlus<WmsOutstockOrder, WmsOutstockOrderVo> {
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
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.bo.WmsOutstockOrderBo;
|
||||
import org.dromara.wms.domain.vo.WmsOutstockOrderVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出库单Service接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
public interface IWmsOutstockOrderService {
|
||||
|
||||
/**
|
||||
* 查询出库单
|
||||
*
|
||||
* @param outstockId 主键
|
||||
* @return 出库单
|
||||
*/
|
||||
WmsOutstockOrderVo queryById(Long outstockId);
|
||||
|
||||
/**
|
||||
* 分页查询出库单列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 出库单分页列表
|
||||
*/
|
||||
TableDataInfo<WmsOutstockOrderVo> queryPageList(WmsOutstockOrderBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的出库单列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 出库单列表
|
||||
*/
|
||||
List<WmsOutstockOrderVo> queryList(WmsOutstockOrderBo bo);
|
||||
|
||||
/**
|
||||
* 新增出库单
|
||||
*
|
||||
* @param bo 出库单
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(WmsOutstockOrderBo bo);
|
||||
|
||||
/**
|
||||
* 修改出库单
|
||||
*
|
||||
* @param bo 出库单
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(WmsOutstockOrderBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除出库单信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
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.WmsOutstockOrder;
|
||||
import org.dromara.wms.domain.bo.WmsOutstockOrderBo;
|
||||
import org.dromara.wms.domain.vo.WmsOutstockOrderVo;
|
||||
import org.dromara.wms.mapper.WmsInstockOrderMapper;
|
||||
import org.dromara.wms.mapper.WmsOutstockOrderMapper;
|
||||
import org.dromara.wms.service.IWmsOutstockOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 出库单Service业务层处理
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsOutstockOrderServiceImpl implements IWmsOutstockOrderService {
|
||||
|
||||
private final WmsOutstockOrderMapper baseMapper;
|
||||
private static final AtomicInteger sequence = new AtomicInteger(999);
|
||||
public static Integer nextSequence() {
|
||||
return sequence.incrementAndGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出库单
|
||||
*
|
||||
* @param outstockId 主键
|
||||
* @return 出库单
|
||||
*/
|
||||
@Override
|
||||
public WmsOutstockOrderVo queryById(Long outstockId){
|
||||
return baseMapper.selectVoById(outstockId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询出库单列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 出库单分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<WmsOutstockOrderVo> queryPageList(WmsOutstockOrderBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsOutstockOrder> lqw = buildQueryWrapper(bo);
|
||||
lqw.orderByDesc(WmsOutstockOrder::getCreateTime);
|
||||
Page<WmsOutstockOrderVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的出库单列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 出库单列表
|
||||
*/
|
||||
@Override
|
||||
public List<WmsOutstockOrderVo> queryList(WmsOutstockOrderBo bo) {
|
||||
LambdaQueryWrapper<WmsOutstockOrder> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WmsOutstockOrder> buildQueryWrapper(WmsOutstockOrderBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WmsOutstockOrder> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getOutstockId() != null, WmsOutstockOrder::getOutstockId, bo.getOutstockId());
|
||||
lqw.eq(bo.getWarehouseId() != null, WmsOutstockOrder::getWarehouseId, bo.getWarehouseId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOutstockCode()), WmsOutstockOrder::getOutstockCode, bo.getOutstockCode());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOutstockType()), WmsOutstockOrder::getOutstockType, bo.getOutstockType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCategories()), WmsOutstockOrder::getMaterialCategories, bo.getMaterialCategories());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOrderType()), WmsOutstockOrder::getOrderType, bo.getOrderType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOrderNo()), WmsOutstockOrder::getOrderNo, bo.getOrderNo());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAuditBy()), WmsOutstockOrder::getAuditBy, bo.getAuditBy());
|
||||
lqw.eq(bo.getAuditTime() != null, WmsOutstockOrder::getAuditTime, bo.getAuditTime());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAuditStatus()), WmsOutstockOrder::getAuditStatus, bo.getAuditStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAuditComments()), WmsOutstockOrder::getAuditComments, bo.getAuditComments());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增出库单
|
||||
*
|
||||
* @param bo 出库单
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(WmsOutstockOrderBo bo) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHssmm");
|
||||
String orderDate = format.format(date);
|
||||
String order = "OU";
|
||||
String orderLast="";
|
||||
Integer value = nextSequence();
|
||||
if (value.toString().length()==4){
|
||||
sequence.set(1);
|
||||
orderLast = generateOrder(sequence.get());
|
||||
}else {
|
||||
orderLast = generateOrder(value);
|
||||
}
|
||||
String outStockOrder = order + orderDate + orderLast;
|
||||
WmsOutstockOrder add = MapstructUtils.convert(bo, WmsOutstockOrder.class);
|
||||
validEntityBeforeSave(add);
|
||||
add.setOutstockCode(outStockOrder);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setOutstockId(add.getOutstockId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
public String generateOrder(Integer value){
|
||||
if (value.toString().length()<3){
|
||||
String fixedLengthString = String.format("%03d", value);
|
||||
return fixedLengthString;
|
||||
}else if (value.toString().length()==3){
|
||||
return value.toString();
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改出库单
|
||||
*
|
||||
* @param bo 出库单
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(WmsOutstockOrderBo bo) {
|
||||
WmsOutstockOrder update = MapstructUtils.convert(bo, WmsOutstockOrder.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(WmsOutstockOrder 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.WmsOutstockOrderMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue