| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | if (null == task) { |
| | | throw new CoolException("数据错误,未找到容器码对应盘点任务"); |
| | | } |
| | | for (CheckDiffItem checkDiffItem : params.getCheckDiffItems()) { |
| | | for (CheckDiffItem ckDiffItem : params.getCheckDiffItems()) { |
| | | CheckDiffItem diffItem = new CheckDiffItem(); |
| | | if (Objects.isNull(checkDiffItem.getId())) { |
| | | BeanUtils.copyProperties(checkDiffItem, diffItem); |
| | | diffItem.setCheckId(params.getCheckId()); |
| | | if (Objects.isNull(ckDiffItem.getId())) { |
| | | BeanUtils.copyProperties(ckDiffItem, diffItem); |
| | | diffItem.setCheckId(params.getCheckId()) |
| | | .setOrderCode(checkDiff.getOrderCode()) |
| | | .setTaskId(task.getId()) |
| | | .setBarcode(task.getBarcode()) |
| | | .setAnfme(ckDiffItem.getCheckQty()); |
| | | |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, diffItem.getMatnrCode())); |
| | | if (Objects.isNull(matnr)) { |
| | |
| | | BeanUtils.copyProperties(diffItem, diffItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .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()) |
| | |
| | | if (!taskItemService.save(taskItem)) { |
| | | throw new CoolException("新增盘点明细保存失败!!"); |
| | | } |
| | | |
| | | diffItem.setTaskItemId(taskItem.getId()).setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | |
| | | if (!checkDiffItemService.updateById(diffItem)) { |
| | | throw new CoolException("明细修改失败!!"); |
| | | } |
| | | } else { |
| | | diffItem = checkDiffItemService.getById(checkDiffItem.getId()); |
| | | diffItem = checkDiffItemService.getById(ckDiffItem.getId()); |
| | | if (null == diffItem) { |
| | | return R.error("数据错误,未找到差异单明细"); |
| | | } |
| | | } |
| | | diffItem.setCheckQty(ckDiffItem.getCheckQty()).setReason(ckDiffItem.getReason()).setMemo(ckDiffItem.getMemo()); |
| | | |
| | | checkDiffItem.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | if (!checkDiffItemService.updateById(checkDiffItem)) { |
| | | 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() + checkDiffItem.getCheckQty()) * 10000) / 10000.0; |
| | | checkDiff.setCheckQty(checkQty); |
| | | } |
| | | checkDiff.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | |
| | | List<CheckDiffItem> diffItems = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getCheckId, checkDiff.getId())); |
| | | if (diffItems.isEmpty()) { |
| | | throw new CoolException("盘点差异单明细不存在!!"); |
| | | } |
| | | Double sum = diffItems.stream().mapToDouble(CheckDiffItem::getCheckQty).sum(); |
| | | checkDiff.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val).setCheckQty(sum); |
| | | if (!checkDiffService.updateById(checkDiff)) { |
| | | throw new CoolException("更新差异单失败"); |
| | | } |
| | |
| | | return R.error("物料码为空"); |
| | | } |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, matnrCode)); |
| | | if (null == matnr){ |
| | | return R.error("未找到编码对应的明细"); |
| | | } |
| | | CheckDiffItem checkDiffItem = new CheckDiffItem() |
| | | .setMatnrCode(matnr.getCode()) |
| | | .setMaktx(matnr.getName()) |