| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | if (Objects.isNull(itemParams) || itemParams.isEmpty()) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | List<WaveItem> items = JSONArray.parseArray(JSONArray.toJSONString(itemParams), WaveItem.class); |
| | | String waveId = map.get("wave").toString(); |
| | | Wave waves = this.getById(Long.parseLong(waveId)); |
| | | if (Objects.isNull(waves)) { |
| | | throw new CoolException("波次数据不存在!!"); |
| | | } |
| | | List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>().eq(WaveItem::getWaveId, waves.getId())); |
| | | List<WaveItem> waveItems = waveItemService.list(new LambdaQueryWrapper<WaveItem>() |
| | | .eq(WaveItem::getWaveId, waves.getId()) |
| | | .apply("anfme > work_qty")); |
| | | if (waveItems.isEmpty()) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | /**生成出库任务*/ |
| | | try { |
| | | generateOutTask(waveItems, loginUserId, waves); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new CoolException("出库任务生成失败!!!"); |
| | | } |
| | | List<Long> orderIds = waveItems.stream().map(WaveItem::getOrderId).collect(Collectors.toList()); |
| | | /**修改出库单状态*/ |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>() |
| | | .set(AsnOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val) |
| | | .in(AsnOrder::getId, orderIds))) { |
| | | throw new CoolException("出库单据状态修改失败!!"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 选择波次明细下发任务 |
| | | * @param map |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R waveToTask(Map<String, Object> map, Long loginUserId) { |
| | | if (Objects.isNull(map.get("waveItem"))) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | String waveId = map.get("wave").toString(); |
| | | Wave waves = this.getById(Long.parseLong(waveId)); |
| | | if (Objects.isNull(waves)) { |
| | | throw new CoolException("波次数据不存在!!"); |
| | | } |
| | | List<Long> waveItems = JSONArray.parseArray(JSON.toJSONString(map.get("waveItem")), Long.class); |
| | | if (waveItems.isEmpty()) { |
| | | throw new CoolException("波次明细不能为空!!"); |
| | | } |
| | | List<WaveItem> items = waveItemService.listByIds(waveItems); |
| | | if (items.isEmpty()) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | /**生成出库任务*/ |
| | |
| | | log.error(e.getMessage()); |
| | | throw new CoolException("出库任务生成失败!!!"); |
| | | } |
| | | //TODO 1. 根据波次明细生成出库任务 |
| | | // 2. 根据物料SKU寻找符合物料库位 {1. 根据物料编码,批次,动态字段 查询符合的库位,再根据库位中物料的数量选择最适合的库位 2. 判断当前订单是全拖出库还是拣料入库} |
| | | // 3. 修改主单、波次执行数量 |
| | | // 4. 判断全仓出库或拣料出库 |
| | | List<Long> orderIds = waveItems.stream().map(WaveItem::getOrderId).collect(Collectors.toList()); |
| | | /**修改出库单状态*/ |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>() |
| | | .set(AsnOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val) |
| | | .in(AsnOrder::getId, orderIds))) { |
| | | throw new CoolException("出库单据状态修改失败!!"); |
| | | } |
| | | return R.ok(); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | List<Long> list = locItems.stream().map(LocItem::getLocId).collect(Collectors.toList()); |
| | | /**根据供应商批次,物料码, 动态字段查询指定的物料库存信息*/ |
| | | //TODO 这里需要要根据波次规则查找库存信息 |
| | | List<LocItem> items = locItemService.list(new LambdaQueryWrapper<LocItem>() |
| | | .eq(LocItem::getSplrBatch, param.getSplrBatch()) |
| | | .in(LocItem::getLocId, list) |
| | |
| | | List<LocItem> locItems = listMap.get(key); |
| | | LocItem item1 = locItems.stream().findFirst().get(); |
| | | WaveItem waveItem = waveItemService.getById(item1.getSource()); |
| | | if (null == waveItem || Objects.isNull(waveItem)) { |
| | | if (Objects.isNull(waveItem)) { |
| | | throw new CoolException("数据错误:波次明细不存在!!"); |
| | | } |
| | | //TODO 当前任务完成后,通过定时事件判断是全盘出库,还是拣料再入库 |
| | |
| | | taskItems.forEach(item -> { |
| | | boolean update = waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .eq(WaveItem::getId, item.getSource()) |
| | | .set(WaveItem::getExceStatus, AsnExceStatus) |
| | | .set(WaveItem::getWorkQty, item.getAnfme())); |
| | | if (!update) { |
| | | throw new CoolException("波次执行数量修改失败!!"); |