| | |
| | | String wrkCode = null; |
| | | //TODO 如果机台号不为空,判断当前机台与当前出库库位是否在同一库区或同一台堆垛机(相同站点) |
| | | //TODO 1. 如果是同一台堆垛机,生成移库(出库)任务 2. 如果不是,生成出库任务,再生成入库任务 |
| | | //TODO 另一种方案,不管是否当前巷道,统一出库,再入库 |
| | | if (!Objects.isNull(deviceNo)) { |
| | | BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>() |
| | | .eq("status", 1) |
| | | .eq("dev_no", deviceNo)); |
| | | if (Objects.isNull(basDevice)) { |
| | | throw new CoolException("机台信息不存在或已禁用!!"); |
| | | } |
| | | List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>().eq("dev_no", basDevice.getDevNo())); |
| | | if (Objects.isNull(binds) || binds.isEmpty()) { |
| | | throw new CoolException("台机未绑定工作站台!!"); |
| | | } |
| | | Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet()); |
| | | wrkCode = wrkCode + "-1"; |
| | | // BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>() |
| | | // .eq("status", 1) |
| | | // .eq("dev_no", deviceNo)); |
| | | // if (Objects.isNull(basDevice)) { |
| | | // throw new CoolException("机台信息不存在或已禁用!!"); |
| | | // } |
| | | // List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>().eq("dev_no", basDevice.getDevNo())); |
| | | // if (Objects.isNull(binds) || binds.isEmpty()) { |
| | | // throw new CoolException("台机未绑定工作站台!!"); |
| | | // } |
| | | // Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet()); |
| | | // |
| | | // LocMast mast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // .in("loc_no", locs) |
| | | // .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | // .eq("dev_no", basDevice.getDevNo()) |
| | | // .orderAsc(Arrays.asList("loc_no")) |
| | | // .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | // |
| | | // if (Objects.isNull(mast)) { |
| | | // throw new CoolException("当前机台,无可用工作台!!"); |
| | | // } |
| | | // //相同表示在同一个巷道 |
| | | // if (mast.getCrnNo().equals(locMast.getCrnNo())) { |
| | | // |
| | | // } else { |
| | | // wrkCode = wrkCode + "-1"; |
| | | // |
| | | // } |
| | | generateOutStock(taskDto, userId, workNo, wrkCode, now, ioType, locMast, staDesc, deviceNo); |
| | | |
| | | LocMast mast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .in("loc_no", locs) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .eq("dev_no", basDevice.getDevNo()) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | |
| | | if (Objects.isNull(mast)) { |
| | | throw new CoolException("当前机台,无可用工作台!!"); |
| | | } |
| | | //相同表示在同一个巷道 |
| | | if (mast.getCrnNo().equals(locMast.getCrnNo())) { |
| | | |
| | | } else { |
| | | wrkCode = wrkCode + "-1"; |
| | | |
| | | } |
| | | } else { |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | //用于工作站,任务分解 |
| | | wrkMast.setWrkCode(wrkCode); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:" + taskDto.getLocNo()); |
| | | generateOutStock(taskDto, userId, workNo, wrkCode, now, ioType, locMast, staDesc, null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成出库任务 |
| | | * |
| | | * @param taskDto |
| | | * @param userId |
| | | * @param workNo |
| | | * @param wrkCode |
| | | * @param now |
| | | * @param ioType |
| | | * @param locMast |
| | | * @param staDesc |
| | | * @author Ryan |
| | | * @date 2026/1/9 20:16 |
| | | */ |
| | | private void generateOutStock(TaskDto taskDto, Long userId, int workNo, String wrkCode, Date now, int ioType, LocMast locMast, StaDesc staDesc, String deviceNo) { |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | //用于工作站,任务分解 |
| | | wrkMast.setWrkCode(wrkCode); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:" + taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { |
| | | continue; |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { |
| | | continue; |
| | | } |
| | | // OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(), locDto.getBrand() |
| | | , locDto.getStandby1(), locDto.getStandby2(), locDto.getStandby3(), locDto.getBoxType1(), locDto.getBoxType2(), locDto.getBoxType3()); |
| | | OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(), locDto.getBrand() |
| | | , locDto.getStandby1(), locDto.getStandby2(), locDto.getStandby3(), locDto.getBoxType1(), locDto.getBoxType2(), locDto.getBoxType3()); |
| | | // if (orderDetl == null) { |
| | | //// orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | // orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | // |
| | | // } |
| | | 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); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | 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); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | // // 修改订单明细 |
| | | // if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | // throw new CoolException("修改订单明细数量失败"); |
| | | // } |
| | | // orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.FALSE, orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3() |
| | | , locDto.getAnfme()); |
| | | OrderInAndOutUtil.updateOrder(Boolean.FALSE, orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | 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() + "库位不是在库状态"); |
| | | } |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.FALSE, orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3() |
| | | , locDto.getAnfme()); |
| | | OrderInAndOutUtil.updateOrder(Boolean.FALSE, orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | |
| | | //todo 判断设备号,生成入库任务 |
| | | if (!Objects.isNull(deviceNo)) { |
| | | genInStock(wrkMast, deviceNo, userId); |
| | | } |
| | | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | 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 |
| | |
| | | /** |
| | | * 生成出库匹配的工作站入库任务 |
| | | * |
| | | * @param staNo |
| | | * @param taskDto |
| | | * @param outMast |
| | | * @param deviceNo |
| | | * @param deviceNo |
| | | * @param userId |
| | | * @author Ryan |
| | | * @date 2026/1/9 17:39 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void genInStock(BasDevp staNo, TaskDto taskDto, String deviceNo, Long userId) { |
| | | public void genInStock(WrkMast outMast, String deviceNo, Long userId) { |
| | | if (Objects.isNull(deviceNo)) { |
| | | throw new CoolException("机台号不能为空!!"); |
| | | } |
| | |
| | | if (Objects.isNull(locMasts)) { |
| | | throw new CoolException("当前机台,无可用工作台!!"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(),1); |
| | | |
| | | WrkMast wrkMast = new WrkMast(); |
| | | StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), findLocNoAttributeVo, locTypeDto); |
| | | int workNo = dto.getWorkNo(); |
| | | // int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |