|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R WarehouseOut(CombParam combParam, Long hostId) { | 
|---|
|  |  |  | //判断库位状态 | 
|---|
|  |  |  | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId)); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (combMat.getAnfme() > locDetl.getAnfme()){ | 
|---|
|  |  |  | return R.error("下架数量错误,超出库存数量"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Cools.isEmpty(combParam.getOrderNo())){ | 
|---|
|  |  |  | Order order = orderService.selectByNo(combParam.getOrderNo(), hostId); | 
|---|
|  |  |  | if (Cools.isEmpty(order)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (order.getSettle() == 1){ | 
|---|
|  |  |  | orderService.updateSettle(order.getId(), 2L, 9527L, hostId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(),hostId); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (orderDetl.getAnfme() < orderDetl.getWorkQty()+combMat.getAnfme()){ | 
|---|
|  |  |  | throw new CoolException("下架数量出错"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQtyByOrderNo(combParam.getOrderNo(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), hostId)) { | 
|---|
|  |  |  | throw new CoolException("修改单据明细工作数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细完成数量 | 
|---|
|  |  |  | if (!orderDetlService.increase(order.getId(), hostId, combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据明细完成数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单状态 作业中 ===>> 已完成 | 
|---|
|  |  |  | orderService.checkComplete(combParam.getOrderNo(), hostId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //处理库存信息 | 
|---|
|  |  |  | if (combMat.getAnfme().equals(locDetl.getAnfme())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new CoolException("更新库存数据出错"+e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Cools.isEmpty(combParam.getOrderNo())){ | 
|---|
|  |  |  | Order order = orderService.selectByNo(combParam.getOrderNo(), hostId); | 
|---|
|  |  |  | if (Cools.isEmpty(order)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(),hostId); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (orderDetl.getWorkQty() < orderDetl.getWorkQty()+combMat.getAnfme()){ | 
|---|
|  |  |  | throw new CoolException("下架数量出错"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQtyByOrderNo(combParam.getOrderNo(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), hostId)) { | 
|---|
|  |  |  | throw new CoolException("修改单据明细工作数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细完成数量 | 
|---|
|  |  |  | if (!orderDetlService.increase(order.getId(), hostId, combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据明细完成数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单状态 作业中 ===>> 已完成 | 
|---|
|  |  |  | orderService.checkComplete(combParam.getOrderNo(), hostId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|