| | |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.controller.params.*; |
| | | import com.vincent.rsf.server.api.entity.dto.*; |
| | | import com.vincent.rsf.server.api.entity.enums.OrderType; |
| | | import com.vincent.rsf.server.api.entity.enums.OrderWorkType; |
| | | import com.vincent.rsf.server.api.service.MobileService; |
| | | import com.vincent.rsf.server.common.config.ConfigProperties; |
| | |
| | | List<ReceiptDetlsDto> receipts = params.getReceipts(); |
| | | List<WarehouseAreasItem> allOrders = new ArrayList<>(); |
| | | |
| | | double receiptQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getReceiptQty).sum(); |
| | | Double receiptQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getReceiptQty).sum(); |
| | | |
| | | String asnCode = receipts.stream().findFirst().get().getAsnCode(); |
| | | |
| | |
| | | if (Objects.isNull(asnOrder)) { |
| | | throw new CoolException("数据错误:主单不存在!!"); |
| | | } |
| | | asnOrder.setQty(receiptQty); |
| | | /**收货数量累加,1. 会出超收情况 2. 会有收货不足情况*/ |
| | | Double rcptedQty = asnOrder.getQty() + receiptQty; |
| | | asnOrder.setQty(rcptedQty); |
| | | |
| | | if (!asnOrderMapper.updateById(asnOrder)) { |
| | | throw new CoolException("已收货数量修改失败!!"); |
| | |
| | | if (!warehouseAreasItemService.saveBatch(allOrders)) { |
| | | throw new CoolException("收货失败!!"); |
| | | } |
| | | |
| | | //获取采购数量 |
| | | double purQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getPurQty).sum(); |
| | | |
| | | BigDecimal subtract = BigDecimal.valueOf(receiptQty).subtract(BigDecimal.valueOf(purQty)); |
| | | //判断已收货数量是否小于等于采购数量 |
| | | if (subtract.compareTo(new BigDecimal("0.0")) <= 0) { |
| | | asnOrder.setRleStatus(Short.valueOf("1")); |
| | | //日志表操作 |
| | | operateOrderLogs(asnOrder); |
| | | } |
| | | |
| | | // //获取采购数量 |
| | | // double purQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getPurQty).sum(); |
| | | // |
| | | // BigDecimal subtract = BigDecimal.valueOf(receiptQty).subtract(BigDecimal.valueOf(purQty)); |
| | | // //判断已收货数量是否小于等于采购数量 |
| | | // if (subtract.compareTo(new BigDecimal("0.0")) <= 0) { |
| | | // asnOrder.setRleStatus(Short.valueOf("1")); |
| | | // //日志表操作 |
| | | // operateOrderLogs(asnOrder); |
| | | // } |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 删除原主单及明细,加入历史档 |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/19 19:53 |
| | | */ |
| | | private void operateOrderLogs(AsnOrder asnOrder) { |
| | | if (!asnOrderMapper.removeById(asnOrder.getId())) { |
| | | throw new CoolException("原单据删除失败!!"); |
| | | } |
| | | |
| | | AsnOrderLog orderLog = new AsnOrderLog(); |
| | | BeanUtils.copyProperties(asnOrder, orderLog); |
| | | orderLog.setAsnId(asnOrder.getId()); |
| | | |
| | | if (!asnOrderLogService.save(orderLog)) { |
| | | throw new CoolException("主单历史档添加失败!!"); |
| | | } |
| | | |
| | | List<AsnOrderItemLog> logs = new ArrayList<>(); |
| | | List<AsnOrderItem> items = asnOrderItemMapper.selectList(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, asnOrder.getId())); |
| | | items.forEach(item -> { |
| | | AsnOrderItemLog itemLog = new AsnOrderItemLog(); |
| | | BeanUtils.copyProperties(item, itemLog); |
| | | itemLog.setAsnItemId(itemLog.getId()) |
| | | .setAsnId(item.getAsnId()); |
| | | logs.add(itemLog); |
| | | }); |
| | | |
| | | if (!asnOrderItemLogService.saveBatch(logs)) { |
| | | throw new CoolException("通知单明细历史档保存失败!!"); |
| | | } |
| | | |
| | | if (asnOrderItemMapper.delete(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, asnOrder.getId())) < 1) { |
| | | throw new CoolException("原单据明细删除失败!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | throw new CoolException("单据明细不能为空!!"); |
| | | } |
| | | Long OrderId = params.getItemList().stream().findFirst().get().getAsnId(); |
| | | AsnOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getId, OrderId)); |
| | | /**获取平库订单*/ |
| | | AsnOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<AsnOrder>() |
| | | .eq(AsnOrder::getId, OrderId) |
| | | .eq(AsnOrder::getType, OrderType.ORDER_PLAT_IN.type)); |
| | | if (Objects.isNull(order)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | |
| | | throw new CoolException("拖盘任务不存在!!"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (!taskItems.isEmpty()) { |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("拖盘任务明细不存在!!"); |
| | | } |
| | | TaskQueueDto queueDto = new TaskQueueDto(); |