| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private AdjDetlService adjDetlService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(Integer staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId, Long hostId) { |
| | | Date now = new Date(); |
| | | // 合并同类项 |
| | |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setHostId(hostId); |
| | | wrkDetl.setWrkMastId(wrkMast.getId()); |
| | | if (!wrkDetlService.save(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(Integer staNo, TaskDto taskDto, Long userId, Long hostId) { |
| | | Date now = new Date(); |
| | | List<LocDto> locDtos = taskDto.getLocDtos(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { |
| | | throw new CoolException("订单出库异常,请联系管理员"); |
| | | } |
| | | } |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, taskDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | // 获取路径 |
| | | int ioType = taskDto.isAll() ? 101 : 103; |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.getOne(new LambdaQueryWrapper<StaDesc>().eq(StaDesc::getTypeNo, ioType).eq(StaDesc::getDeviceStn, staNo).eq(StaDesc::getHostId, hostId)); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(101L); // 工作状态:101.生成出库 |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setSourceStaNo(staDesc.getDeviceStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(String.valueOf(userId)); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(String.valueOf(userId)); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setHostId(hostId); |
| | | if (!wrkMastService.save(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderNo, locDto.getOrderNo()) |
| | | .eq(Order::getHostId, hostId)); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), null); |
| | | } |
| | | LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch(), hostId); |
| | | if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) { |
| | | throw new CoolException(locDto.getLocNo() + "库位中" + locDto.getMatnr() + "商品库存不足!"); |
| | | } |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(orderDetl); |
| | | wrkDetl.setZpallet(wrkMast.getBarcode()); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setBatch(locDto.getBatch()); |
| | | wrkDetl.setOrderNo(locDto.getOrderNo()); |
| | | wrkDetl.setAnfme(locDto.getAnfme()); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setHostId(hostId); |
| | | wrkDetl.setWrkMastId(wrkMast.getId()); |
| | | if (!wrkDetlService.save(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 修改订单明细 |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), hostId, orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId, hostId); |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, taskDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void adjustLocDetl(LocDetlAdjustParam param, Long userId, Long hostId) { |
| | | param.integrate(); |
| | | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, param.getLocNo()).eq(LocMast::getHostId, hostId)); |
| | |
| | | throw new CoolException("更新库位状态失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void locMove(String sourceLocNo, String locNo, Long userId, Long hostId) { |
| | | LocMast sourceLoc = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, sourceLocNo) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getLocNo, sourceLocNo) |
| | | .eq(LocDetl::getHostId, hostId)); |
| | | if (Cools.isEmpty(sourceLoc)){ |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, locNo) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | if (Cools.isEmpty(loc)){ |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | | // throw new CoolException("移转库位属于不同堆垛机"); todo:luxiaotao |
| | | } |
| | | Date now = new Date(); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(101L); // 工作状态:101.生成出库任务 |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setSourceLocNo(sourceLocNo); // 源库位 |
| | | wrkMast.setLocNo(locNo); // 目标库位 |
| | | wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setAppeUser(String.valueOf(userId)); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(String.valueOf(userId)); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setHostId(hostId); |
| | | boolean res = wrkMastService.save(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setHostId(hostId); |
| | | wrkDetl.setWrkMastId(wrkMast.getId()); |
| | | if (!wrkDetlService.save(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | | if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiUser(userId); |
| | | sourceLoc.setModiTime(now); |
| | | if (!locMastService.updateById(sourceLoc)){ |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(sourceLoc.getLocNo() + "源库位出库失败,状态:"+sourceLoc.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(now); |
| | | loc.setModiUser(userId); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:"+loc.getLocSts$()); |
| | | } |
| | | } |
| | | } |