| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stockPakout(PakoutParam param, Long userId) { |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | Node node = nodeService.selectByUuid(param.getNodeUuid()); |
| | | LocDetl locDetl = locDetlService.getLocDetl(node.getId(), mat.getMatnr()); |
| | | if (locDetl == null || locDetl.getAnfme() < param.getCount()) { |
| | | return R.error(mat.getMaktx() + "库存不足"); |
| | | } |
| | | Pakout pakout = new Pakout( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 任务号[非空] |
| | | 3L, // 工作状态 |
| | | null, // 托盘号 |
| | | param.getCount(), // 出库数量 |
| | | node.getId(), // 关联货位[非空] |
| | | node.getUuid(), // 货位[非空] |
| | | mat.getMatnr(), // 商品编码[非空] |
| | | null, // 商品名称 |
| | | null, // 名称 |
| | | null, // 尺码 |
| | | null, // 型号 |
| | | null, // 批号 |
| | | null, // 单位 |
| | | null, // SKC |
| | | null, // 单据类型 |
| | | null, // 单据编号 |
| | | null, // 客户名称 |
| | | null, // 品项数 |
| | | null, // 数量 |
| | | null, // 重量 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | new Date(), // 添加时间 |
| | | userId, // 修改人员 |
| | | new Date(), // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | VersionUtils.setPakout(pakout, mat); |
| | | // 保存出库通知单 |
| | | if (!pakoutService.insert(pakout)) { |
| | | throw new CoolException("保存出库通知单失败"); |
| | | } |
| | | if (param.getCount()>=locDetl.getAnfme()) { |
| | | // 删除库存明细 |
| | | if (!locDetlService.removeStock(node.getId(), mat.getMatnr())) { |
| | | throw new CoolException("删除库存明细失败"); |
| | | } |
| | | } else { |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(node.getId(), mat.getMatnr(), param.getCount())) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stockIn(StockInParam param, Long userId) { |
| | | Node node = nodeService.selectByUuid(param.getNodeId()); |
| | | if (node == null) { |
| | |
| | | } |
| | | } |
| | | // 直接增加库存 |
| | | LocDetl locDetl = locDetlService.getLocDetl(param.getNode_id(), param.getMatnr()); |
| | | if (locDetl == null) { |
| | | // 更新货位库存明细 |
| | | locDetl = new LocDetl(); |
| | | locDetl.setLocNo(node.getName()); |
| | | locDetl.setNodeId(node.getId()); |
| | | locDetl.setAnfme(anfme); |
| | | VersionUtils.setLocDetl(locDetl, mat); |
| | | locDetl.setStatus(1); |
| | | locDetl.setCreateBy(userId); |
| | | locDetl.setCreateTime(new Date()); |
| | | locDetl.setUpdateBy(userId); |
| | | locDetl.setUpdateTime(new Date()); |
| | | boolean insert = locDetlService.insert(locDetl); |
| | | if (!insert) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } else { |
| | | if (!locDetlService.incrementStock(node.getId(), param.getMatnr(), anfme)) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } |
| | | // LocDetl locDetl = locDetlService.getLocDetl(param.getNode_id(), param.getMatnr()); |
| | | // if (locDetl == null) { |
| | | // // 更新货位库存明细 |
| | | // locDetl = new LocDetl(); |
| | | // locDetl.setLocNo(node.getName()); |
| | | // locDetl.setNodeId(node.getId()); |
| | | // locDetl.setAnfme(anfme); |
| | | // VersionUtils.setLocDetl(locDetl, mat); |
| | | // locDetl.setStatus(1); |
| | | // locDetl.setCreateBy(userId); |
| | | // locDetl.setCreateTime(new Date()); |
| | | // locDetl.setUpdateBy(userId); |
| | | // locDetl.setUpdateTime(new Date()); |
| | | // boolean insert = locDetlService.insert(locDetl); |
| | | // if (!insert) { |
| | | // throw new CoolException("新增库存明细档失败"); |
| | | // } |
| | | // } else { |
| | | // if (!locDetlService.incrementStock(node.getId(), param.getMatnr(), anfme)) { |
| | | // throw new CoolException("新增库存明细档失败"); |
| | | // } |
| | | // } |
| | | |
| | | return R.ok("补仓成功,等待立库调拨"); |
| | | } |
| | |
| | | String docNum = null; |
| | | Long docId = null; |
| | | switch (check.getSettle()) { |
| | | case 1: // 盘盈 |
| | | docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 14L; // 报溢单 |
| | | case 1: // 盘盈 todo 前期用采购单上报 |
| | | // docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | // docId = 14L; // 报溢单 |
| | | docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 34L; // 采购单 |
| | | break; |
| | | case 2: // 盘亏 |
| | | docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |