1.1. 审核采购入库单
1.1.1. 审核流程(需要事务管理)
- 判断入库单是否存在,是否可以审核等
- 修改状态,审核人,审核时间
- 在循环外面更新仓库总金额、当前数量
- 添加或者更新即时库存表
1.1.2. 代码实现
@Service
public class StockincomebillServiceImpl extends BaseServiceImplimplements IStockincomebillService {@Autowiredprivate IProductStockService productStockService;@Autowiredprivate IDepotService depotService;// 审核入库单功能(需要事务管理)@Override@Transactionalpublic 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);// 添加或者更新即时库存ProductStockString jpql = "select o from ProductStock o where o.depot=? and o.product=?";List items = bill.getItems();for (Stockincomebillitem billItem : items) {Product product = billItem.getProduct();List list = findByJpql(jpql, depot, product);if (list.size() == 0) {// 添加ProductStock productStock = new ProductStock();// 小计
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!