| | |
| | | // List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), matnrs.get(0), null, null,locTypeDto); |
| | | if (Cools.isEmpty(dto)){ |
| | | throw new CoolException("查询库位失败!!==》startupFullPutStore ==》 commonService.getLocNo"); |
| | | throw new CoolException("response.query_loc_failed"); |
| | | } |
| | | // 生成工作号 |
| | | int workNo = dto.getWorkNo(); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | throw new CoolException("response.save_work_master_failed"); |
| | | } |
| | | // 生成工作档明细 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | throw new CoolException("更新源站失败"); |
| | | throw new CoolException("response.update_source_station_failed"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | throw new CoolException("response.change_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException("response.target_loc_occupied"); |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { |
| | | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount(),paramLocDetl.getBarcode())) { |
| | | LocDetl one = locDetlService.selectItemCarton(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(),paramLocDetl.getBarcode()); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | } else { |
| | | throw new CoolException("库存不存在"); |
| | | throw new CoolException("response.stock_not_exist"); |
| | | } |
| | | } |
| | | /** |
| | |
| | | LocGroupOrder currentGroup = locGroupAscOrder.stream() |
| | | .filter(g -> g.getRowList().contains(locMast.getRow1())) |
| | | .findFirst() |
| | | .orElseThrow(() -> new CoolException("当前排不在任何出库优先分组中,无法进行深库位检查: row=" + locMast.getRow1())); |
| | | .orElseThrow(() -> new CoolException("response.current_row_not_in_priority_group")); |
| | | |
| | | List<Integer> orderedRows = currentGroup.getRowList(); |
| | | |
| | |
| | | |
| | | // 前方有货(F状态) |
| | | if ("F".equals(prevLoc.getLocSts())) { |
| | | throw new CoolException(locNo + " 的前方位置 " + prevLoc.getLocNo() + " 有货,禁止出库"); |
| | | throw new CoolException("response.front_loc_has_goods_forbid_out"); |
| | | } |
| | | |
| | | // 前方有入库任务(假设 io_type=100 为入库,根据实际调整) |
| | |
| | | ); |
| | | |
| | | if (frontTask != null) { |
| | | throw new CoolException(locNo + " 的前方位置 " + prevLoc.getLocNo() + " 存在入库任务,禁止出库"); |
| | | throw new CoolException("response.front_loc_has_in_task_forbid_out"); |
| | | } |
| | | } |
| | | |
| | | if (!foundSelf) { |
| | | throw new CoolException("分组内未找到目标库位,请检查数据一致性: " + locNo); |
| | | throw new CoolException("response.target_loc_not_found_in_group"); |
| | | } |
| | | } |
| | | private boolean isInNormalRule(LocMast lm) { |
| | |
| | | ); |
| | | |
| | | if (allSelectedMasts.size() != locNos.size()) { |
| | | throw new CoolException("部分选中库位不存在或数据异常"); |
| | | throw new CoolException("response.selected_loc_not_exist_or_error"); |
| | | } |
| | | |
| | | // 2. 区分正常库位(需要严格深库位检查)与补充库位 |
| | |
| | | allMasts.addAll(supplementMasts); |
| | | |
| | | if (allMasts.isEmpty()) { |
| | | throw new CoolException("没有有效的出库库位"); |
| | | throw new CoolException("response.no_valid_out_loc"); |
| | | } |
| | | |
| | | // 5. 统一按排号(row)倒序排序(高排先出) |
| | |
| | | dto = dtos.stream() |
| | | .filter(d -> d.getLocNo().equals(locNo)) |
| | | .findFirst() |
| | | .orElseThrow(() -> new CoolException("找不到对应的出库明细:" + locNo)); |
| | | .orElseThrow(() -> new CoolException("response.out_detail_not_found")); |
| | | // 生成工作档 |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | locSts = ioType != 101? "R" : "P"; |
| | | locSts = ioType != 101? "P" : "R"; |
| | | // 生成工作档明细(保留原逻辑) |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { |
| | |
| | | } |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(detlDto.getLocDetl()); |
| | | wrkDetl.setOrderNo(""); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | throw new CoolException("response.save_work_detail_failed"); |
| | | } |
| | | } |
| | | }else{ |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no",locNo)); |
| | |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | throw new CoolException("response.save_work_detail_failed"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,库位:" + locNo); |
| | | throw new CoolException("response.save_work_master_failed_loc|" + locNo); |
| | | } |
| | | |
| | | if(locMastNew != null){ |
| | |
| | | locMastNew.setModiUser(userId); |
| | | locMastNew.setModiTime(now); |
| | | if (!locMastService.updateById(locMastNew)) { |
| | | throw new CoolException("更新库位状态失败,库位:" + locNo); |
| | | throw new CoolException("response.update_loc_status_failed_loc|" + locNo); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位状态异常,非空板状态:" + locNo); |
| | | throw new CoolException("response.loc_status_error_not_empty|" + locNo); |
| | | } |
| | | } |
| | | // 更新库位状态 |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:" + locNo); |
| | | } |
| | | } else { |
| | | throw new CoolException(locNo + " 库位不是在库状态"); |
| | | throw new CoolException("response.reserve_loc_status_failed|" + locNo); |
| | | } |
| | | } else { |
| | | throw new CoolException("response.loc_not_in_store|" + locNo); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | List<LocDto> locDtos = taskDto.getLocDtos(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { |
| | | throw new CoolException("订单出库异常,请联系管理员"); |
| | | throw new CoolException("response.order_out_error_contact_admin"); |
| | | } |
| | | } |
| | | // 获取库位 |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("response.save_work_master_failed_out_loc|" + taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | Order order = orderService.selectByNo(locDto.getOrderNo()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), locDto.getBatch(),locDto.getBarcode()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | orderDetl = orderDetlService.selectItem(order.getId(), locDto.getMatnr(), null,locDto.getBarcode()); |
| | | } |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(orderDetl); |
| | |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | throw new CoolException("response.save_work_detail_failed"); |
| | | } |
| | | // 修改订单明细 |
| | | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme(),locDto.getBarcode())) { |
| | | throw new CoolException("response.update_order_detail_qty_failed"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("response.reserve_loc_status_failed_loc|" + taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | | throw new CoolException("response.loc_not_in_store_status|" + taskDto.getLocNo()); |
| | | } |
| | | } |
| | | |
| | |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | throw new CoolException("response.save_work_master_failed"); |
| | | } |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | throw new CoolException("更新源站失败"); |
| | | throw new CoolException("response.update_source_station_failed"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | throw new CoolException("response.change_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException("response.target_loc_occupied|" + dto.getLocNo()); |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | |
| | | ); |
| | | |
| | | if (selectedMasts.size() != selectedLocNos.size()) { |
| | | return LockingCheckResultParam.fail("部分选中库位不存在或数据异常"); |
| | | return LockingCheckResultParam.fail("response.selected_loc_invalid_or_missing"); |
| | | } |
| | | |
| | | // 2. 按分组聚合选中的库位(支持多分组) |
| | |
| | | LocGroupOrder group = locGroupAscOrder.stream() |
| | | .filter(g -> g.getRowList().contains(lm.getRow1())) |
| | | .findFirst() |
| | | .orElseThrow(() -> new CoolException("排不在出库分组配置中: row=" + lm.getRow1())); |
| | | .orElseThrow(() -> new CoolException("response.row_not_in_group_config|" + lm.getRow1())); |
| | | |
| | | groupSelected.computeIfAbsent(group, k -> new ArrayList<>()).add(lm); |
| | | } |
| | |
| | | |
| | | // 检查是否重复或无效 |
| | | if (selectedRows.size() != selected.size()) { |
| | | return LockingCheckResultParam.fail("选中库位存在重复或无效排"); |
| | | return LockingCheckResultParam.fail("response.selected_loc_duplicate_or_invalid_row"); |
| | | } |
| | | |
| | | int minIndex = fullRows.indexOf(selectedRows.get(0)); |
| | |
| | | // 1. 必须是连续段(无缺口) |
| | | if (maxIndex - minIndex + 1 != selectedRows.size()) { |
| | | return LockingCheckResultParam.fail( |
| | | "选中排必须连续,无缺口。从 " + fullRows.get(minIndex) + " 到 " + fullRows.get(maxIndex) |
| | | "response.selected_rows_must_be_continuous|" + fullRows.get(minIndex) + "|" + fullRows.get(maxIndex) |
| | | ); |
| | | } |
| | | |
| | |
| | | // 4. 至少有一侧清空才允许出库(修改:放宽,如果两侧都堵,返回特定错误码或继续) |
| | | if (!leftClear && !rightClear) { |
| | | return LockingCheckResultParam.fail( |
| | | "选中段 " + fullRows.get(minIndex) + "~" + fullRows.get(maxIndex) + |
| | | " 两侧前方都有空板/故障,无法出库(正序或倒序方向都堵塞)" |
| | | "response.both_sides_blocked|" + fullRows.get(minIndex) + "|" + fullRows.get(maxIndex) |
| | | ); |
| | | } |
| | | |
| | | // 5. 选中段内所有库位必须是 D 状态 |
| | | for (LocMast lm : selected) { |
| | | if (!"D".equals(lm.getLocSts())) { |
| | | return LockingCheckResultParam.fail("选中库位非空板状态: " + lm.getLocNo()); |
| | | return LockingCheckResultParam.fail("response.selected_loc_not_empty_status|" + lm.getLocNo()); |
| | | } |
| | | } |
| | | |
| | |
| | | LocGroupOrder group = locGroupAscOrder.stream() |
| | | .filter(g -> g.getRowList().contains(normalMasts.get(0).getRow1())) |
| | | .findFirst() |
| | | .orElseThrow(() -> new CoolException("分组异常")); |
| | | .orElseThrow(() -> new CoolException("response.group_exception")); |
| | | |
| | | List<Integer> fullRows = group.getRowList(); |
| | | |
| | |
| | | @Transactional |
| | | public void emptyPlateOut(EmptyPlateOutParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getOutSite())) { |
| | | throw new CoolException("站点不存在"); |
| | | throw new CoolException("response.site_not_exist"); |
| | | } |
| | | |
| | | // 使用出库专用分组配置 |
| | |
| | | ); |
| | | |
| | | if (selectedMasts.size() != param.getLocNos().size()) { |
| | | throw new CoolException("部分选中库位不存在或数据异常"); |
| | | throw new CoolException("response.selected_loc_abnormal"); |
| | | } |
| | | |
| | | // 2. 区分正常分组内的库位 和 需要补充的库位(规则外的) |
| | |
| | | |
| | | if (!checkResult.isSuccess()) { |
| | | String errMsg = checkResult.getErrorMessage(); |
| | | if (errMsg.contains("两侧前方都有空板/故障")) { |
| | | if (errMsg.contains("response.both_sides_blocked")) { |
| | | // 两侧都堵 → 进入补齐逻辑 |
| | | supplementBothSidesBlocked(normalMasts, locGroupAscOrder, supplementMasts, isLeftSideSupplement); |
| | | } else { |
| | |
| | | allMasts.addAll(supplementMasts); |
| | | |
| | | if (allMasts.isEmpty()) { |
| | | throw new CoolException("没有有效的空板库位可出库"); |
| | | throw new CoolException("response.no_valid_empty_pallet_loc"); |
| | | } |
| | | |
| | | // 5. 统一按 row → bay → lev 排序(从小到大) |
| | |
| | | Integer sourceStaNo = staDesc != null ? staDesc.getCrnStn() : null; |
| | | |
| | | if (Cools.isEmpty(sourceStaNo)) { |
| | | throw new CoolException("检索源站失败,库位:" + locNo); |
| | | throw new CoolException("response.query_source_station_failed_loc|" + locNo); |
| | | } |
| | | |
| | | // 计算优先级(示例:补充的优先级稍低) |
| | |
| | | } |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,库位:" + locNo); |
| | | throw new CoolException("response.save_work_master_failed_loc|" + locNo); |
| | | } |
| | | |
| | | if(locMastNew != null){ |
| | |
| | | locMastNew.setModiUser(userId); |
| | | locMastNew.setModiTime(now); |
| | | if (!locMastService.updateById(locMastNew)) { |
| | | throw new CoolException("更新库位状态失败,库位:" + locNo); |
| | | throw new CoolException("response.update_loc_status_failed_loc|" + locNo); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位状态异常,非空板状态:" + locNo); |
| | | throw new CoolException("response.loc_status_error_not_empty|" + locNo); |
| | | } |
| | | } |
| | | |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败,库位:" + locNo); |
| | | throw new CoolException("response.update_loc_status_failed_loc|" + locNo); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位状态异常,非空板状态:" + locNo); |
| | | throw new CoolException("response.loc_status_error_not_empty|" + locNo); |
| | | } |
| | | } |
| | | } |
| | |
| | | public WrkMast emptyPlateOut(EmptyPlateOutParam param) { |
| | | WrkMast wrkMast = new WrkMast(); |
| | | if (Cools.isEmpty(param.getOutSite())) { |
| | | throw new CoolException("站点不存在"); |
| | | throw new CoolException("response.site_not_exist"); |
| | | } |
| | | for (String locNo : param.getLocNos()) { |
| | | // 获取工作号 |
| | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo+"库位不存在"); |
| | | throw new CoolException("response.loc_not_exist|" + locNo); |
| | | } |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | Integer sourceStaNo = staDesc.getCrnStn(); |
| | | if (Cools.isEmpty(sourceStaNo)) { |
| | | throw new CoolException("检索源站失败"); |
| | | throw new CoolException("response.query_source_station_failed"); |
| | | } |
| | | Date now = new Date(); |
| | | // 保存工作档 |
| | |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(1L); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setMemo("生成自动空板出库"); |
| | | wrkMast.setMemo("response.memo_auto_empty_pallet_out"); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | throw new CoolException("response.save_work_master_failed"); |
| | | } |
| | | // 更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")){ |
| | |
| | | locMast.setModiUser(1L); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败"); |
| | | throw new CoolException("response.update_loc_status_failed_simple"); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { |
| | | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount(),paramLocDetl.getBarcode())) { |
| | | LocDetl one = locDetlService.selectItemCarton(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(),paramLocDetl.getBarcode()); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | throw new CoolException("response.selected_loc_status_error|" + locMast.getLocNo() + "," + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | throw new CoolException("response.loc_material_not_exist"); |
| | | } |
| | | } |
| | | |
| | |
| | | LocMast sourceLoc = locMastService.selectById(sourceLocNo); |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); |
| | | if (Cools.isEmpty(sourceLoc)){ |
| | | throw new CoolException("未找到库位"); |
| | | throw new CoolException("response.loc_not_found"); |
| | | } |
| | | LocMast loc = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(loc)){ |
| | | throw new CoolException("未找到库位"); |
| | | throw new CoolException("response.loc_not_found"); |
| | | } |
| | | if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))){ |
| | | throw new CoolException("库位状态已改变"); |
| | | throw new CoolException("response.loc_status_changed"); |
| | | } |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | | throw new CoolException("移转库位属于不同堆垛机"); |
| | | throw new CoolException("response.transfer_loc_diff_crn"); |
| | | } |
| | | Date now = new Date(); |
| | | // 获取工作号 |
| | |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | throw new CoolException("response.save_work_master_failed_simple"); |
| | | } |
| | | // 工作档明细保存 |
| | | for (LocDetl locDetl : locDetls) { |
| | |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | throw new CoolException("response.save_work_detail_failed"); |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | |
| | | sourceLoc.setModiUser(userId); |
| | | sourceLoc.setModiTime(now); |
| | | if (!locMastService.updateById(sourceLoc)){ |
| | | throw new CoolException("更新源库位状态失败"); |
| | | throw new CoolException("response.update_source_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败,状态:"+sourceLoc.getLocSts$()); |
| | | throw new CoolException("response.source_loc_out_failed_status|" + sourceLoc.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | |
| | | loc.setModiTime(now); |
| | | loc.setModiUser(userId); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | throw new CoolException("response.update_target_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:"+loc.getLocSts$()); |
| | | throw new CoolException("response.transfer_failed_target_loc_status|" + loc.getLocSts$()); |
| | | } |
| | | } |
| | | |
| | |
| | | public void completeWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | throw new CoolException("response.work_master_not_exist|" + workNo); |
| | | } |
| | | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | throw new CoolException("response.work_master_completed"); |
| | | } |
| | | // 出库 |
| | | if (wrkMast.getIoType() > 100) { |
| | |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | // 完成操作人员记录 |
| | | wrkMast.setManuType("手动完成"); |
| | | wrkMast.setManuType("response.manu_complete"); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("修改工作档失败"); |
| | | throw new CoolException("response.update_work_master_failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | param.integrate(); |
| | | LocMast locMast = locMastService.selectById(param.getLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("库位不存在"); |
| | | throw new CoolException("response.loc_not_exist_simple"); |
| | | } |
| | | if (!(locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O"))) { |
| | | throw new CoolException("当前库位不可调整!库位状态:" + locMast.getLocSts$()); |
| | | throw new CoolException("response.loc_not_adjustable|" + locMast.getLocSts$()); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | |
| | | if (!locDetl.getAnfme().equals(adjust.getCount())) { |
| | | // todo 盘点记录 |
| | | // 修改库存 |
| | | if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { |
| | | throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败"); |
| | | if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBarcode())) { |
| | | throw new CoolException("response.update_stock_qty_failed|" + locDetl.getLocNo() + "," + locDetl.getMatnr() + "," + locDetl.getBatch()); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | |
| | | // 删除库存 |
| | | for (LocDetl locDetl : locDetls) { |
| | | // todo 盘点记录 |
| | | if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { |
| | | throw new CoolException("删除" + locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号库存明细失败"); |
| | | if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBarcode())) { |
| | | throw new CoolException("response.delete_stock_detail_failed|" + locDetl.getLocNo() + "," + locDetl.getMatnr() + "," + locDetl.getBatch()); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | |
| | | locDetl.setAppeUser(userId); |
| | | locDetl.setAppeTime(now); |
| | | if (!locDetlService.insert(locDetl)) { |
| | | throw new CoolException("添加" + locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号库存明细失败"); |
| | | throw new CoolException("response.add_stock_detail_failed|" + locDetl.getLocNo() + "," + locDetl.getMatnr() + "," + locDetl.getBatch()); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败"); |
| | | throw new CoolException("response.update_loc_status_failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | Date now = new Date(); |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | throw new CoolException("response.work_master_not_exist|" + workNo); |
| | | } |
| | | String locNo = ""; // 待修改目标库位 |
| | | String locSts = ""; // 待修改目标库位状态 |
| | |
| | | // 库位转移:源库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,源库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("response.cancel_transfer_failed_source_not_exist|" + wrkMast.getSourceLocNo()); |
| | | } |
| | | locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F"); |
| | | locMast.setModiTime(now); |
| | |
| | | // 库位转移:目标库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,目标库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("response.cancel_transfer_failed_target_not_exist|" + wrkMast.getLocNo()); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(now); |
| | |
| | | locMastService.updateById(locMast); |
| | | } |
| | | } else { |
| | | throw new CoolException("当前工作状态无法取消"); |
| | | throw new CoolException("response.work_status_cannot_cancel"); |
| | | } |
| | | |
| | | //取消入库工作档时,查询组托表,如果有将状态改为待处理 |
| | |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { |
| | | if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | throw new CoolException("response.order_data_rollback_failed"); |
| | | } |
| | | |
| | | //修改订单主表状态,没有作业数量时才可以修改 |
| | |
| | | order.setUpdateTime(now); |
| | | } |
| | | if(!orderService.update(order,new EntityWrapper<Order>().eq("order_no",wrkDetl.getOrderNo()))){ |
| | | throw new CoolException("修改订单状态失败"); |
| | | throw new CoolException("response.update_order_status_failed"); |
| | | } |
| | | } |
| | | } |
| | |
| | | // } |
| | | |
| | | // 取消操作人员记录 |
| | | wrkMast.setManuType("手动取消"); |
| | | wrkMast.setManuType("response.manu_cancel"); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("取消工作档失败"); |
| | | throw new CoolException("response.cancel_work_master_failed"); |
| | | } |
| | | // 保存工作主档历史档 |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作历史档失败, workNo = " + wrkMast.getWrkNo()); |
| | | throw new CoolException("response.save_work_log_failed|" + wrkMast.getWrkNo()); |
| | | } |
| | | // 删除工作主档 |
| | | boolean wrkMastRes = wrkMastService.deleteById(wrkMast); |
| | |
| | | // 修改库位状态 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); |
| | | throw new CoolException("response.cancel_work_master_failed_loc_not_exist|" + locNo); |
| | | } |
| | | locMast.setLocSts(locSts); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | boolean locMastRes = locMastService.updateById(locMast); |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | throw new CoolException("response.save_data_failed"); |
| | | } |
| | | |
| | | //wms取消任务 同时调用wcs任务取消接口通知wcs |
| | |
| | | flag = true; |
| | | }else { |
| | | log.error("wms取消任务下发wcs失败--->url:{};request:{};response:{}", url+"/"+cancel, JSON.toJSONString(wrkCancel), response); |
| | | throw new CoolException("wms取消任务下发wcs失败"); |
| | | throw new CoolException("response.wms_cancel_task_wcs_failed"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("fail", e); |
| | |
| | | public void pickWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | throw new CoolException("response.work_master_not_exist|" + workNo); |
| | | } |
| | | // 入出库类型判断 |
| | | if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { |
| | | throw new CoolException("当前入出库类型无法进行操作"); |
| | | throw new CoolException("response.io_type_cannot_operate"); |
| | | } |
| | | // 工作状态判断 |
| | | if (wrkMast.getWrkSts() < 11 || wrkMast.getWrkSts() == 15) { |
| | | throw new CoolException("当前工作状态无法进行操作"); |
| | | throw new CoolException("response.work_status_cannot_operate"); |
| | | } |
| | | // 保存工作明细档历史档 |
| | | // if (!wrkDetlLogService.save(wrkMast.getWrkNo())) { |
| | |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | throw new CoolException("response.save_work_master_log_failed"); |
| | | } |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("入库路径不存在"); |
| | | throw new CoolException("response.in_route_not_exist"); |
| | | } |
| | | Date now = new Date(); |
| | | // 堆垛机站点(目标站) |
| | |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | throw new CoolException("response.update_work_master_status_failed"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | throw new CoolException("response.update_loc_status_failed"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public StartupDto createWaitPainWrkMastStart(List<WaitPakin> list, Long userId) { |
| | | if (Cools.isEmpty(list)) { |
| | | throw new CoolException("入库通知档不能为空"); |
| | | throw new CoolException("response.wait_pakin_empty"); |
| | | } |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | locTypeDto.setLocType1((short) 1); |
| | |
| | | public String dealPreHaveStart(Integer wrkNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(wrkNo); |
| | | if (wrkMast == null) { |
| | | throw new CoolException("任务已失效"); |
| | | throw new CoolException("response.task_invalid"); |
| | | } |
| | | String locNo = wrkMast.getLocNo(); |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | |
| | | } |
| | | |
| | | if (targetLoc == null) { |
| | | throw new CoolException("操作失败,当前仓库找不到空库位"); |
| | | throw new CoolException("response.no_empty_loc_found"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | // 修改工作档 |
| | | StaDesc staDesc = staDescService.queryCrnStn(targetLoc.getCrnNo()); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("入库路径不存在"); |
| | | throw new CoolException("response.in_route_not_exist"); |
| | | } |
| | | wrkMast.setWrkSts(2L); |
| | | wrkMast.setLocNo(targetLoc.getLocNo()); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setPreHave("N"); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("修改工作档失败"); |
| | | throw new CoolException("response.update_work_master_failed"); |
| | | } |
| | | // 修改库位状态 O ===>>> S |
| | | if (targetLoc.getLocSts().equals("O")){ |
| | |
| | | targetLoc.setModiUser(userId); |
| | | targetLoc.setModiTime(now); |
| | | if (!locMastService.updateById(targetLoc)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | throw new CoolException("response.update_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException(targetLoc.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException("response.target_loc_occupied|" + targetLoc.getLocNo()); |
| | | } |
| | | // 禁用异常库位 |
| | | // locMast.setLocSts("X"); // X.禁用 |
| | |
| | | public void turnMatLocDetl(EmptyPlateOutParam param, Long userId) { |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("id", param.getMatId())); |
| | | if (Cools.isEmpty(mat)){ |
| | | throw new CoolException("目标库位商品编码有误!"); |
| | | throw new CoolException("response.target_loc_mat_error"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getLocDetls().get(0).getMatnr())); |
| | | if (Cools.isEmpty(locDetls) || locDetls.size()<1){ |
| | | throw new CoolException("待修改商品无库存,无需修改! 品号:"+param.getLocDetls().get(0).getMatnr()); |
| | | throw new CoolException("response.mat_no_stock_no_need_update|" + param.getLocDetls().get(0).getMatnr()); |
| | | } |
| | | try { |
| | | locDetlService.updateMatTurn(param.getLocDetls().get(0).getMatnr(),mat.getMatnr()); |
| | | }catch (Exception e){ |
| | | throw new CoolException("对数据库修改出错!"); |
| | | throw new CoolException("response.db_update_error"); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | // 保存调整记录 |