| | |
| | | import com.vincent.rsf.server.api.service.WcsService; |
| | | import com.vincent.rsf.server.common.constant.Constants; |
| | | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; |
| | | import com.vincent.rsf.server.manager.controller.params.PakinItem; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void complateInTask(List<Task> tasks) throws Exception { |
| | | public void complateInTask(List<Task> tasks) { |
| | | AtomicBoolean success = new AtomicBoolean(false); |
| | | if (success.compareAndSet(false, true)) { |
| | | Long loginUserId = SystemAuthUtils.getLoginUserId(); |
| | | for (Task task : tasks) { |
| | | try { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | //1.入库 |
| | | complateInstock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | //53.拣料再入库 |
| | | //57.盘点再入库 |
| | | pickComplateInStock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | //移库 |
| | | moveInStock(task, loginUserId); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | //1.入库 |
| | | complateInstock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | //53.拣料再入库 |
| | | //57.盘点再入库 |
| | | pickComplateInStock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | //移库 |
| | | moveInStock(task, loginUserId); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param loginUserId |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void pickComplateInStock(Task task, Long loginUserId) throws Exception { |
| | | public void pickComplateInStock(Task task, Long loginUserId) { |
| | | if (Objects.isNull(task)) { |
| | | return; |
| | | } |
| | |
| | | locWorking.setAnfme(taskItem.getAnfme()); |
| | | } |
| | | BeanUtils.copyProperties(locWorking, locItem); |
| | | locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | locItem.setWorkQty(0.0).setQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | items.add(locItem); |
| | | } |
| | | |
| | |
| | | .setBarcode(task.getBarcode()) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id); |
| | | |
| | | TaskInParam param = new TaskInParam(); |
| | | param.setSourceStaNo(task.getTargSite()) |
| | | .setIoType(type) |
| | | .setLocType1(Integer.parseInt(loc.getType())); |
| | | // TaskInParam param = new TaskInParam(); |
| | | // param.setSourceStaNo(task.getTargSite()) |
| | | // .setIoType(type) |
| | | // .setLocType1(Integer.parseInt(loc.getType())); |
| | | //获取新库位 |
| | | InTaskMsgDto locInfo = wcsService.getLocNo(param); |
| | | // InTaskMsgDto locInfo = wcsService.getLocNo(param); |
| | | |
| | | if (Objects.isNull(locInfo)) { |
| | | throw new CoolException("获取库位失败!!"); |
| | | } |
| | | task.setTargLoc(locInfo.getLocNo()) |
| | | // if (Objects.isNull(locInfo)) { |
| | | // throw new CoolException("获取库位失败!!"); |
| | | // } |
| | | //希日上报物有情况,不需要获取新库位 |
| | | task.setTargLoc(task.getOrgLoc()) |
| | | .setOrgSite(task.getTargSite()); |
| | | |
| | | if (!this.updateById(task)) { |
| | |
| | | TaskItem taskItem = taskItems.stream().findFirst().get(); |
| | | taskItem.setMatnrId(working.getMatnrId()) |
| | | .setMaktx(working.getMaktx()) |
| | | .setMatnrId(working.getMatnrId()) |
| | | .setMatnrCode(working.getMatnrCode()) |
| | | .setSpec(working.getSpec()) |
| | | .setAnfme(working.getAnfme()) |
| | |
| | | List<LocItemWorking> workings = new ArrayList<>(); |
| | | List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | items.forEach(taskItem -> { |
| | | if (taskItem.getAnfme() > 0) { |
| | | LocItemWorking itemWorking = new LocItemWorking(); |
| | | BeanUtils.copyProperties(taskItem, itemWorking); |
| | | itemWorking.setTaskId(task.getId()) |
| | | .setQty(0.0) |
| | | .setLocId(loc1.getId()) |
| | | .setLocCode(loc1.getCode()); |
| | | workings.add(itemWorking); |
| | | } |
| | | LocItemWorking itemWorking = new LocItemWorking(); |
| | | BeanUtils.copyProperties(taskItem, itemWorking); |
| | | itemWorking.setTaskId(task.getId()) |
| | | .setQty(0.0) |
| | | .setLocId(loc1.getId()) |
| | | .setLocCode(loc1.getCode()); |
| | | workings.add(itemWorking); |
| | | }); |
| | | |
| | | if (!locItemWorkingService.saveBatch(workings)) { |
| | | throw new CoolException("临时库存更新失败!!"); |
| | | if (!workings.isEmpty()) { |
| | | if (!locItemWorkingService.saveBatch(workings)) { |
| | | throw new CoolException("临时库存更新失败!!"); |
| | | } |
| | | } |
| | | |
| | | loc1.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | |
| | | if (!locService.updateById(loc1)) { |
| | | throw new CoolException("库位预约入库失败!!"); |
| | | } |
| | | locService.updateById(loc1); |
| | | // if (!locService.updateById(loc1)) { |
| | | // throw new CoolException("库位预约入库失败!!"); |
| | | // } |
| | | return task; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateOutStock(Task task, Long loginUserId) throws Exception { |
| | | public void complateOutStock(Task task, Long loginUserId) { |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /**修改为库位状态为O.空库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .set(Loc::getBarcode, null) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()) |
| | | .eq(Loc::getId, loc.getId()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) { |
| | | /**修改为库位状态为S.预约入库,保留原有库位*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type) |
| | | .set(Loc::getBarcode, null) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()) |
| | | .eq(Loc::getId, loc.getId()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | } else { |
| | | /**修改为库位状态为O.空库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .set(Loc::getBarcode, null) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()) |
| | | .eq(Loc::getId, loc.getId()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | } |
| | | |
| | | if (!this.update(new LambdaUpdateWrapper<Task>() |
| | |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细不存在!!"); |
| | | } |
| | | try { |
| | | //更新库位明细 |
| | | saveLocItem(taskItems, task.getId(), loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException("库位明细更新失败!!"); |
| | | } |
| | | |
| | | //更新库位明细 |
| | | saveLocItem(taskItems, task.getId(), loginUserId); |
| | | |
| | | /**对任务明细按组拖明细进行分组*/ |
| | | Map<Long, List<TaskItem>> orderMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); |
| | |
| | | throw new CoolException("数据错误:组拖数据不存在,请联系管理员!!"); |
| | | } |
| | | List<TaskItem> items = orderMap.get(key); |
| | | try { |
| | | //保存库存明细 |
| | | saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId); |
| | | //移出收货区库存, 修改组托状态 |
| | | removeReceiptStock(pakinItem, loginUserId); |
| | | } catch (Exception e) { |
| | | logger.error("<UNK>", e); |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | //保存入出库明细 |
| | | saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId); |
| | | //移出收货区库存, 修改组托状态 |
| | | removeReceiptStock(pakinItem, loginUserId); |
| | | }); |
| | | |
| | | Set<Long> pkinItemIds = taskItems.stream().map(TaskItem::getSource).collect(Collectors.toSet()); |
| | | List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getId, pkinItemIds)); |
| | | if (pakinItems.isEmpty()) { |
| | | throw new CoolException("组托明细不存在!!"); |
| | | } |
| | | Set<Long> pakinIds = pakinItems.stream().map(WaitPakinItem::getPakinId).collect(Collectors.toSet()); |
| | | |
| | | if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | | .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val) |
| | | .set(WaitPakin::getUpdateBy, loginUserId) |
| | | .in(WaitPakin::getId, pakinIds))) { |
| | | throw new CoolException("组拖状态修改失败!!"); |
| | | } |
| | | |
| | | /**修改库位状态为F.在库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | |
| | | Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 1000000) / 1000000.0; |
| | | Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 1000000) / 1000000.0; |
| | | itemServiceOne.setWorkQty(workQty).setQty(qty); |
| | | |
| | | if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | | .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val) |
| | | .set(WaitPakin::getUpdateBy, loginUserId) |
| | | .eq(WaitPakin::getId, pakinItem.getPakinId()))) { |
| | | throw new CoolException("组拖状态修改失败!!"); |
| | | } |
| | | |
| | | if (qty.compareTo(itemServiceOne.getAnfme()) == 0.00) { |
| | | if (!warehouseAreasItemService.removeById(itemServiceOne.getId())) { |
| | |
| | | LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>() |
| | | .eq(LocItem::getMatnrId, taskItem.getMatnrId()) |
| | | .eq(LocItem::getLocId, loc.getId()) |
| | | .eq(StringUtils.isNoneBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch()) |
| | | .eq(StringUtils.isNoneBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex())); |
| | | .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch()) |
| | | .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex())); |
| | | if (Objects.isNull(locItem)) { |
| | | BeanUtils.copyProperties(taskItem, item); |
| | | item.setLocCode(loc.getCode()) |
| | |
| | | throw new CoolException("库位明细更新失败!!"); |
| | | } |
| | | } else { |
| | | locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 1000000) / 1000000.0) |
| | | .setUpdateTime(new Date()); |
| | | if (!locItemService.saveOrUpdate(locItem)) { |
| | | throw new CoolException("库位明细更新失败!!"); |
| | | } |
| | | logger.error("当前票号:" + locItem.getFieldsIndex() + " 已在库内,请检查后再操作!!"); |
| | | // throw new CoolException("当前票号已在库内,请检查后再操作!!"); |
| | | // locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 1000000) / 1000000.0) |
| | | // .setUpdateTime(new Date()); |
| | | // if (!locItemService.saveOrUpdate(locItem)) { |
| | | // throw new CoolException("库位明细更新失败!!"); |
| | | // } |
| | | } |
| | | }); |
| | | |