| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.common.model.OrderStoDto; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.CustOrder; |
| | | 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.*; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.service.CustOrderService; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | import zy.cloud.wms.manager.service.PakoutService; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | |
| | | private CustOrderService custOrderService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | @Transactional |
| | | public List<StoPreTab> stockOutPreview(OrderStoDto dto) { |
| | | if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | // 检查库存是否足够 |
| | | locDetlService.checkLocDetlCount(dto.getNumber()); |
| | | List<StoPreTab> result = new ArrayList<>(); |
| | | for (CustOrder custOrder : dto.getCustOrders()) { |
| | | // 判断物料是否存在 |
| | | Mat mat = matService.selectByMatnr(custOrder.getUserCode()); |
| | | if (null == mat) { |
| | | throw new CoolException(custOrder.getUserCode() + "物料尚未更新。" + custOrder.getNumber() +"单据因此中断!"); |
| | | } |
| | | // 查询存有当前物料的货位 |
| | | List<LocDetl> locDetls = locDetlService.findOfSort(mat.getMatnr()); |
| | | double issued = Optional.ofNullable(custOrder.getQty()).orElse(0.0D) ; |
| | | double anfme = issued; |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | // 视图对象 |
| | | StoPreTab tab = new StoPreTab(); |
| | | tab.setTitle(mat.getMatnr() + "(" + mat.getMaktx() + ")"); |
| | | tab.setMatnr(mat.getMatnr()); |
| | | tab.setMaktx(mat.getMaktx()); |
| | | tab.setAnfme(anfme); |
| | | |
| | | tab.setLocNo(locDetl.getLocNo()); |
| | | tab.setNodeId(locDetl.getNodeId()); |
| | | tab.setTotal(locDetl.getAnfme()); |
| | | tab.setReduce(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | tab.setRemQty(tab.getTotal() - tab.getReduce()); |
| | | tab.setPrior(locDetlService.isPrior(locDetl.getNodeId(), mat.getMatnr())); |
| | | tab.setPrior$(tab.getPrior()?"✔":"×"); |
| | | result.add(tab); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Transactional |
| | | public void stockOutProcess(OrderStoDto dto) { |
| | |
| | | throw new CoolException("保存出库通知单失败"); |
| | | } |
| | | if (issued>=locDetl.getAnfme()) { |
| | | // 删除库存明细 |
| | | if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | throw new CoolException("删除库存明细失败"); |
| | | } |
| | | // // 删除库存明细 |
| | | // if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | // throw new CoolException("删除库存明细失败"); |
| | | // } |
| | | } else { |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | } |
| | | // // 修改库存明细数量 |
| | | // if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | // throw new CoolException("修改库存明细数量失败"); |
| | | // } |
| | | } |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |