| | |
| | | } |
| | | List<Long> orderIds = waveItems.stream().map(WaveItem::getOrderId).collect(Collectors.toList()); |
| | | /**修改出库单状态*/ |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<WkOrder>() |
| | | .set(WkOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val) |
| | | .in(WkOrder::getId, orderIds))) { |
| | | throw new CoolException("出库单据状态修改失败!!"); |
| | | } |
| | | updateAsnOrders(orderIds, null, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val, null, "出库单据状态修改失败!!"); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | Double sum = taskItems.stream().mapToDouble(TaskItem::getAnfme).sum(); |
| | | Double v = Math.round((wave.getWorkQty() + sum) * 1000000) / 1000000.0; |
| | | if (wave.getAnfme().compareTo(v) == 0) { |
| | | if (!this.update(new LambdaUpdateWrapper<Wave>() |
| | | .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val) |
| | | .set(Wave::getWorkQty, v) |
| | | .set(Wave::getUpdateBy, loginUserId) |
| | | .set(Wave::getMemo, null) |
| | | .set(Wave::getUpdateTime, new Date()) |
| | | .eq(Wave::getId, wave.getId()))) { |
| | | throw new CoolException("波次状态修改失败!!"); |
| | | } |
| | | updateWaveSnapshot(wave, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val, v, loginUserId, null, "波次状态修改失败!!"); |
| | | } else { |
| | | if (!this.update(new LambdaUpdateWrapper<Wave>() |
| | | .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val) |
| | | .set(Wave::getWorkQty, v) |
| | | .set(Wave::getUpdateBy, loginUserId) |
| | | .set(Wave::getMemo, null) |
| | | .set(Wave::getUpdateTime, new Date()) |
| | | .eq(Wave::getId, wave.getId()))) { |
| | | throw new CoolException("波次状态修改失败!!"); |
| | | } |
| | | updateWaveSnapshot(wave, WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val, v, loginUserId, null, "波次状态修改失败!!"); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | |
| | | List<Long> orders = orderRelas.stream().map(WaveOrderRela::getOrderId).collect(Collectors.toList()); |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<WkOrder>() |
| | | .set(WkOrder::getWorkQty, 0.0) |
| | | .set(WkOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val) |
| | | .in(WkOrder::getId, orders))) { |
| | | throw new CoolException("单据更新失败!!"); |
| | | } |
| | | updateAsnOrders(orders, 0.0, AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val, null, "单据更新失败!!"); |
| | | |
| | | this.update(new LambdaUpdateWrapper<Wave>() |
| | | .eq(Wave::getId, id) |
| | | .set(Wave::getExceStatus, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val)); |
| | | updateWaveSnapshot(wave, WaveExceStatus.WAVE_EXCE_STATUS_TASK.val, null, null, null, "波次状态修改失败!!"); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private void updateWaveSnapshot(Wave wave, Short exceStatus, Double workQty, Long loginUserId, String memo, String errorMessage) { |
| | | Wave update = new Wave(); |
| | | update.setId(wave.getId()); |
| | | update.setVersion(wave.getVersion()); |
| | | update.setExceStatus(exceStatus); |
| | | update.setWorkQty(workQty); |
| | | update.setUpdateBy(loginUserId); |
| | | update.setMemo(memo); |
| | | update.setUpdateTime(loginUserId == null ? null : new Date()); |
| | | if (!this.updateById(update)) { |
| | | throw new CoolException(errorMessage); |
| | | } |
| | | wave.setExceStatus(exceStatus); |
| | | wave.setWorkQty(workQty); |
| | | wave.setUpdateBy(loginUserId); |
| | | if (loginUserId != null) { |
| | | wave.setUpdateTime(update.getUpdateTime()); |
| | | } |
| | | wave.setMemo(memo); |
| | | if (update.getVersion() != null) { |
| | | wave.setVersion(update.getVersion()); |
| | | } |
| | | } |
| | | |
| | | private void updateAsnOrders(List<Long> orderIds, Double workQty, Short exceStatus, Long loginUserId, String errorMessage) { |
| | | if (Cools.isEmpty(orderIds)) { |
| | | return; |
| | | } |
| | | List<WkOrder> orders = asnOrderService.listByIds(orderIds.stream().distinct().collect(Collectors.toList())); |
| | | for (WkOrder order : orders) { |
| | | WkOrder update = new WkOrder(); |
| | | update.setId(order.getId()); |
| | | update.setVersion(order.getVersion()); |
| | | if (workQty != null) { |
| | | update.setWorkQty(workQty); |
| | | } |
| | | update.setExceStatus(exceStatus); |
| | | if (loginUserId != null) { |
| | | update.setUpdateBy(loginUserId); |
| | | update.setUpdateTime(new Date()); |
| | | } |
| | | if (!asnOrderService.updateById(update)) { |
| | | throw new CoolException(errorMessage); |
| | | } |
| | | if (workQty != null) { |
| | | order.setWorkQty(workQty); |
| | | } |
| | | order.setExceStatus(exceStatus); |
| | | if (loginUserId != null) { |
| | | order.setUpdateBy(loginUserId); |
| | | order.setUpdateTime(update.getUpdateTime()); |
| | | } |
| | | if (update.getVersion() != null) { |
| | | order.setVersion(update.getVersion()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param |
| | | * @param loginUserId |