智能商贸—Day12—入库审核操作+库存预警定时调度+发送邮件

本文介绍了智能商贸系统中入库审核的详细流程,包括事务管理、状态更新等,并探讨了库存预警的目的与实现,如在pom.xml中添加jar文件,通过java.util.Timer或Quartz进行定时任务调度,以及如何设置邮件通知相关人员库存异常情况。
摘要由CSDN通过智能技术生成

1.1. 审核采购入库单

1.1.1. 审核流程(需要事务管理)

  1. 判断入库单是否存在,是否可以审核等
  2. 修改状态,审核人,审核时间
  3. 在循环外面更新仓库总金额、当前数量
  4. 添加或者更新即时库存表

1.1.2. 代码实现

@Service
public class StockincomebillServiceImpl extends BaseServiceImpl<Stockincomebill, Long>
    implements IStockincomebillService {
  @Autowired
  private IProductStockService productStockService;
  @Autowired
  private IDepotService depotService;

  // 审核入库单功能(需要事务管理)
  @Override
  @Transactional
  public void auding(Long billId, Employee auditor) {
    Stockincomebill bill = findOne(billId);
    if (bill == null) {
      throw new RuntimeException("此入库单不存在...");
    }
    // 0待审,1已审,-1作废
    if (bill.getStatus() == 1) {
      throw new RuntimeException("此入库单已经审核完成");
    }
    if (bill.getStatus() == -1) {
      throw new RuntimeException("此入库单已经作废");
    }
    // 入库单状态,审核人,审核时间
    bill.setStatus(1);
    bill.setAuditor(auditor);
    bill.setAuditorTime(new Date());
    // 显示更新一下
    save(bill);

    Depot depot = bill.getDepot();
    // 仓库总数量,总金额(循环的外面写)
    depot.setCurrentCapacity(depot.getCurrentCapacity().add(bill.getTotalNum()));
    depot.setTotalAmount(depot.getTotalAmount().add(bill.getTotalAmount()));
    depotService.save(depot);

    // 添加或者更新即时库存ProductStock
    String jpql = "select o from ProductStock o where o.depot=? and o.product=?";
    List<Stockincomebillitem> items = bill.getItems();
    for (Stockincomebillitem billItem : items) {
      Product product = billItem.getProduct();
      List<ProductStock> list = findByJpql(jpql, depot, product);
      if (list.size() == 0) {// 添加
	ProductStock productStock = new ProductStock();
	// 小计
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值