| | |
| | | import zy.cloud.wms.manager.entity.LocDetl; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.Pakout; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | import zy.cloud.wms.manager.service.PakoutService; |
| | | import zy.cloud.wms.manager.service.PriorService; |
| | | import zy.cloud.wms.manager.service.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private PakoutService pakoutService; |
| | | @Autowired |
| | | private PriorService priorService; |
| | | private CustOrderService custOrderService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | |
| | | if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | | return; |
| | | } |
| | | // 检查库存是否足够 |
| | | locDetlService.checkLocDetlCount(dto.getNumber()); |
| | | Date now = new Date(); |
| | | for (CustOrder custOrder : dto.getCustOrders()) { |
| | | // 判断物料是否存在 |
| | |
| | | pakout.setNodeId(locDetl.getNodeId()); |
| | | pakout.setWrkNo(String.valueOf(snowflakeIdWorker.nextId())); |
| | | VersionUtils.setPakout(pakout, mat); |
| | | // pakout.setDocId(custOrder.getBTypeId()); |
| | | pakout.setDocNum(custOrder.getNumber()); // 单据编号 |
| | | pakout.setCreateTime(now); |
| | | pakout.setUpdateTime(now); |
| | | pakout.setStatus(1); |
| | | if (!pakoutService.insert(pakout)) { |
| | | throw new CoolException("保存出库通知单失败"); |
| | | } |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued>=locDetl.getAnfme()?locDetl.getAnfme():issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | if (issued>=locDetl.getAnfme()) { |
| | | // 删除库存明细 |
| | | if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | throw new CoolException("删除库存明细失败"); |
| | | } |
| | | } else { |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | } |
| | | } |
| | | // 剩余待出货位递减 |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 修改单据状态 |
| | | if (!custOrderService.updateStatus(custOrder.getNumber(), 2)) { |
| | | throw new CoolException("修改单据状态失败"); |
| | | } |
| | | } |
| | | } |
| | | |