| | |
| | | @Autowired |
| | | private WaveItemService waveItemService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private OutStockService outStockService; |
| | | @Autowired |
| | | private WaveService waveService; |
| | | @Autowired |
| | | private WaveRuleServiceImpl waveRuleService; |
| | | @Autowired |
| | |
| | | if (Objects.isNull(itemParams) || itemParams.isEmpty()) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | String waveId = map.get("wave").toString(); |
| | | Wave waves = this.getById(Long.parseLong(waveId)); |
| | | // Wave waveId = (Wave) map.get("wave"); |
| | | Wave wave = JSON.parseObject(JSON.toJSONString(map.get("wave")), Wave.class); |
| | | Wave waves = this.getById(wave.getId()); |
| | | if (Objects.isNull(waves)) { |
| | | throw new CoolException("波次数据不存在!!"); |
| | | } |
| | |
| | | .setWaveId(item.getWaveId()); |
| | | params.add(locParams); |
| | | } |
| | | List<OrderOutItemDto> results = LocManageUtil.getOutOrderList(params, null,waves.getStationId()); |
| | | List<OrderOutItemDto> results = LocManageUtil.getOutOrderList(params, null,waves.getStationId(),waves.getLocCode()); |
| | | generateOutTask(results, loginUserId, waves); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | |
| | | } |
| | | 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(); |
| | | } |
| | | |
| | |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | List<Long> WaveIds = JSONArray.parseArray(JSON.toJSONString(map.get("ids")), Long.class); |
| | | List<Wave> waves = waveService.listByIds(WaveIds); |
| | | List<Wave> waves = this.listByIds(WaveIds); |
| | | if (Objects.isNull(waves)) { |
| | | throw new CoolException("数据错误: 波次不存在!!"); |
| | | } |
| | |
| | | .setWaveId(item.getWaveId()); |
| | | params.add(locParams); |
| | | } |
| | | List<OrderOutItemDto> results = LocManageUtil.getOutOrderList(params, waveRule,wave.getStationId()); |
| | | List<OrderOutItemDto> results = LocManageUtil.getOutOrderList(params, waveRule,wave.getStationId(),wave.getLocCode()); |
| | | if (results.isEmpty()) { |
| | | wave.setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | if (wave.getAnfme().compareTo(wave.getWorkQty()) == 0) { |
| | |
| | | wave.setExceStatus(WaveExceStatus.WAVE_EXCE_STATUS_EXCING.val); |
| | | } |
| | | wave.setMemo("-->库存不足"); |
| | | waveService.updateById(wave); |
| | | this.updateById(wave); |
| | | return R.ok(); |
| | | } |
| | | try { |
| | |
| | | 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 (!waveService.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 (!waveService.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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | private List<WaveItem> getLocs(List<WaveItem> waveItems) throws Exception { |
| | | //TODO 根据物料编码,批次,动态字段 查询符合的库位,再根据库位中物料的数量选择最适合的库位 |
| | | waveItems.forEach(waveItem -> { |
| | | List<LocItem> locItems = locItemService.list(new QueryWrapper<LocItem>() |
| | | LambdaQueryWrapper<LocItem> locItemLambdaQueryWrapper = new QueryWrapper<LocItem>() |
| | | .select("id", "loc_id", "loc_code", "order_id", "SUM(anfme) anfme", "SUM(qty) qty", "SUM(work_qty) work_qty", "splr_batch", "fields_index", "matnr_code") |
| | | .lambda() |
| | | .eq(LocItem::getMatnrCode, waveItem.getMatnrCode()) |
| | | .eq(LocItem::getSplrBatch, waveItem.getSplrBatch()) |
| | | .eq(StringUtils.isNotBlank(waveItem.getFieldsIndex()), LocItem::getFieldsIndex, waveItem.getFieldsIndex()) |
| | | .groupBy(LocItem::getMatnrCode, LocItem::getSplrBatch, LocItem::getFieldsIndex, LocItem::getId)); |
| | | .eq(StringUtils.isNotBlank(waveItem.getFieldsIndex()), LocItem::getFieldsIndex, waveItem.getFieldsIndex()); |
| | | Wave wave = this.getById(waveItem.getWaveId()); |
| | | if (!Cools.isEmpty(wave.getLocCode())) { |
| | | locItemLambdaQueryWrapper.eq(LocItem::getLocCode, wave.getLocCode()); |
| | | } |
| | | locItemLambdaQueryWrapper.groupBy(LocItem::getMatnrCode, LocItem::getSplrBatch, LocItem::getFieldsIndex, LocItem::getId); |
| | | List<LocItem> locItems = locItemService.list(locItemLambdaQueryWrapper); |
| | | List<Double> doubles1 = locItems.stream().map(LocItem::getAnfme).collect(Collectors.toList()); |
| | | double[] doubles = doubles1.stream().mapToDouble(Double::doubleValue).toArray(); |
| | | |