入库订单(组合关系、主从表)模型

该博客介绍了入库订单的数据库模型,包括仓库、入库订单、入库订单明细和即时库存四张表。重点讲解了入库订单的组合关系以及测试保存过程,涉及仓库经理的审核流程,强调了事务管理的重要性。此外,还提到了库存预警的实现,通过添加相关jar文件并配置任务调度,实现了库存预警功能,并引入了邮件通知的配置和测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一共涉及到4张表,仓库,入库订单.入库订单明细,即时库存

1.仓库实体类

@Entity
@Table(name="depot")
public class Depot extends BaseDomain {
   
   

    private String name;
    private BigDecimal maxCapacity;// 最大数量,参考值
    private BigDecimal currentCapacity;;// 当前数量,参考值
    private BigDecimal totalAmount;// 当前仓库里面的产品值多少钱

2.入库订单:组合关系的一方

@Entity
@Table(name="stockincomebill")
public class Stockincomebill extends BaseDomain {
   
   

    private Date vdate;// 交易时间
    private BigDecimal totalAmount; //总金额
    private BigDecimal totalNum;//总数量
    private Date inputTime = new Date();//录入时间
    private Date auditorTime;//审核时间
    /**
     * 0待审,1已审,-1作废
     */
    private Integer status = 0; //审核状态 默认未审
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "supplier_id")
    private Supplier supplier;// 供应商 多对一,非空

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "auditor_id")
    private Employee auditor;//  审核员 多对一,可以为空

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "inputUser_id")
    private Employee inputUser;// 录入员 多对一,非空

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "keeper_id")
    private Employee keeper;//  仓管员 多对一,非空

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "depot_id")
    private Depot depot;//  仓库编号 多对一,非空
    // 一般组合关系使用List
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bill", fetch = FetchType.LAZY, orphanRemoval = true)
    private List<Stockincomebillitem> items = new ArrayList<Stockincomebillitem>();

3.入库订单明细:组合关系的多方

@Entity
@Table(name="stockincomebillitem")
public class Stockincomebillitem extends BaseDomain {
   
   


    private BigDecimal price;
    private BigDecimal num;
    private BigDecimal amount;
    private String descs;
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "product_id")
    private Product product;//产品  多对一,非空

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "bill_id")
    private Stockincomebill bill;// 组合关系,非空

4.即时库存


    private BigDecimal num;// 当前仓库的产品的数量
    private BigDecimal amount;// 当前仓库的产品的小计
    private BigDecimal price;// 当前仓库的产品的价格
    private Date incomedate;// 入库时间
    private Boolean warning = true;// 库存过多,过少自动发出库存预警
    private BigDecimal topnum = new BigDecimal(100);// 最大库存量
    private BigDecimal bottomnum = new BigDecimal(50);// 最小库存量

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id")
    private Product product;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="depot_id")
    private Depot depot;

**2 测试保存 **
跟单文员(仓库员)登录进销存系统,先录入入库订单进行保存
仓库经理登录,进行入库订单审核 ,这是分开的,现在保存还没有审核经理和时间

public class StockincomebillServiceTest extends BaseTest {
   
   

    @Autowired
    private IStockincomebillService stockincomebillService;

    
    @Test
    public void testName() throws Exception{
   
   
        //入库--进入stockincomebill 和stockincomeitem表 类似采购单保存
        //创建入库主单
        Stockincomebill bill = new Stockincomebill();

        Depot depot = new Depot();
        depot.setId(1L);
        bill.setDepot(depot)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值