| | |
| | | package com.vincent.rsf.server.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | |
| | | |
| | | List<CheckDiffItem> checkDiffItems = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getBarcode, barcode) |
| | | .eq(CheckDiffItem::getExceStatus, CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_INIT.val) |
| | | .eq(CheckDiffItem::getOrderCode, checkCode) |
| | | ); |
| | | if (checkDiffItems.isEmpty()) { |
| | |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | } |
| | | |
| | | |
| | | return R.ok(checkDiffItems); |
| | | } |
| | | |
| | |
| | | .setOrderType(OrderType.ORDER_CHECK.type) |
| | | .setSourceCode(diffItem.getOrderCode()) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type)) |
| | | .setAnfme(diffItem.getAnfme()) |
| | | .setAnfme(diffItem.getCheckQty()) |
| | | .setWorkQty(0.0) |
| | | .setBatch(diffItem.getBatch()) |
| | | .setMaktx(matnr.getName()) |
| | |
| | | throw new CoolException("新增盘点明细保存失败!!"); |
| | | } |
| | | |
| | | diffItem.setTaskItemId(taskItem.getId()); |
| | | diffItem.setTaskItemId(taskItem.getId()).setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | |
| | | if (!checkDiffItemService.updateById(diffItem)) { |
| | | throw new CoolException("明细修改失败!!"); |
| | |
| | | return R.error("数据错误,未找到差异单明细"); |
| | | } |
| | | diffItem.setCheckQty(ckDiffItem.getCheckQty()).setReason(ckDiffItem.getReason()).setMemo(ckDiffItem.getMemo()); |
| | | } |
| | | |
| | | diffItem.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | if (!checkDiffItemService.updateById(diffItem)) { |
| | | throw new CoolException("更新差异单明细失败"); |
| | | diffItem.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | if (!checkDiffItemService.updateById(diffItem)) { |
| | | throw new CoolException("更新差异单明细失败"); |
| | | } |
| | | |
| | | if (!taskItemService.update(new LambdaUpdateWrapper<TaskItem>() |
| | | .set(TaskItem::getAnfme, diffItem.getCheckQty()) |
| | | .eq(TaskItem::getId, diffItem.getTaskItemId()))) { |
| | | throw new CoolException("任务数量修改失败!!"); |
| | | } |
| | | } |
| | | // Double checkQty = Math.round((checkDiff.getCheckQty() + diffItem.getCheckQty()) * 10000) / 10000.0; |
| | | // checkDiff.setCheckQty(checkQty); |
| | | } |
| | | |
| | | List<CheckDiffItem> diffItems = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | |
| | | ; |
| | | return R.ok(checkDiffItem); |
| | | } |
| | | |
| | | @Override |
| | | public R getCheckTaskItemList2(String barcode) { |
| | | LambdaQueryWrapper<Task> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(Task::getBarcode, barcode); |
| | | Task task = taskService.getOne(lambdaQueryWrapper); |
| | | if (null == task) { |
| | | throw new CoolException("未找到容器号对应任务"); |
| | | } |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (Cools.isEmpty(taskItems)){ |
| | | throw new CoolException("未找到该容器码对应的任务明细"); |
| | | } |
| | | String sourceCode = taskItems.stream().findFirst().map(TaskItem::getSourceCode).orElse(null); |
| | | CheckDiff checkDiff = checkDiffService.getOne(new LambdaQueryWrapper<CheckDiff>().eq(CheckDiff::getOrderCode,sourceCode)); |
| | | if (null == checkDiff) { |
| | | return R.error("未找到盘点差异单"); |
| | | } |
| | | List<CheckDiffItem> checkDiffItems = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getBarcode, barcode) |
| | | .eq(CheckDiffItem::getExceStatus, CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_INIT.val) |
| | | .eq(CheckDiffItem::getOrderCode, sourceCode) |
| | | ); |
| | | if (checkDiffItems.isEmpty()) { |
| | | throw new CoolException("此条码不在当前盘点单中"); |
| | | } |
| | | |
| | | return R.ok(Cools.add("checkDiffItems",checkDiffItems).add("checkDiff",checkDiff)); |
| | | } |
| | | } |