| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.constant.Constants; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.mapper.WaveMapper; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vincent.rsf.server.manager.utils.LocManageUtil; |
| | | import com.vincent.rsf.server.manager.utils.OptimalAlgorithmUtil; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R publicTask(Map<String, Object> map, Long loginUserId) { |
| | | List<WaveItem> itemParams = (List<WaveItem>) map.get("waveItem"); |
| | | List<WaveItem> itemParams = JSONArray.parseArray(JSON.toJSONString(map.get("waveItem")), WaveItem.class); |
| | | if (Objects.isNull(itemParams) || itemParams.isEmpty()) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | |
| | | if (items.isEmpty()) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | |
| | | for (int i = 0; i < items.size(); i++) { |
| | | List<LocItem> locItems = LocManageUtil.getEfficiencyFirstItemList(items.get(i).getMatnrCode(), items.get(i).getSplrBatch(), items.get(i).getAnfme()); |
| | | items.get(i).setStockLocs(JSONArray.toJSONString(locItems)).setStockQty(items.get(i).getAnfme()); |
| | | } |
| | | /**生成出库任务*/ |
| | | try { |
| | | generateOutTask(items, loginUserId, waves); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | throw new CoolException("出库任务生成失败!!!"); |
| | | log.error("UNK", e); |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | return null; |
| | | |
| | | if (!waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_ING.val) |
| | | .in(WaveItem::getId, waveItems))) { |
| | | throw new CoolException("下发执行异常,请稍候重试!"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (WaveItem param : itemParams) { |
| | | String locs = param.getStockLocs(); |
| | | List<LocItem> locItems = JSONArray.parseArray(locs, LocItem.class); |
| | | if (locItems.isEmpty()) { |
| | | continue; |
| | | } |
| | | 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) |
| | | .eq(StringUtils.isNotBlank(param.getFieldsIndex()), LocItem::getFieldsIndex, param.getFieldsIndex()) |
| | | .eq(LocItem::getMatnrCode, param.getMatnrCode())); |
| | | if (items.isEmpty()) { |
| | | throw new CoolException("库存信息有变,请取消当前波次,生新生成新的波次!!"); |
| | | } |
| | | /***将有货有的明细信息存放到库位信息中*/ |
| | | for (int i = 0; i < items.size(); i++) { |
| | | items.get(i) |
| | | for (int i = 0; i < locItems.size(); i++) { |
| | | locItems.get(i) |
| | | .setSourceId(param.getWaveId()) |
| | | .setSourceCode(param.getWaveCode()) |
| | | .setSource(param.getId()); |
| | | } |
| | | locItemList.addAll(items); |
| | | locItemList.addAll(locItems); |
| | | } |
| | | if (locItemList.isEmpty()) { |
| | | throw new CoolException("没有合适库位!!"); |
| | |
| | | throw new CoolException("库位不存在!!"); |
| | | } |
| | | |
| | | List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSourceId, wave.getId())); |
| | | if (items.isEmpty()) { |
| | | throw new CoolException("波次任务已生成,不能重复生成!!"); |
| | | } |
| | | |
| | | // List<TaskItem> items = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSourceId, wave.getId())); |
| | | // if (!items.isEmpty()) { |
| | | // throw new CoolException("波次任务已生成,不能重复生成!!"); |
| | | // } |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskType(TaskType.TASK_TYPE_OUT.type) |
| | | .setTaskStatus(TaskStsType.GENERATE_OUT.id) |
| | | .setResource(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val) |
| | | .setBarcode(loc.getBarcode()) |
| | | .setOrgLoc(loc.getCode()) |
| | | .setSort(Constants.TASK_SORT_DEFAULT_VALUE) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId) |
| | | .setTargSite(wave.getTargSite()); |
| | |
| | | TaskItem taskItem = new TaskItem(); |
| | | BeanUtils.copyProperties(item, taskItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .setAnfme(waveItem.getAnfme()) |
| | | .setAnfme(item.getAnfme()) |
| | | .setId(null) |
| | | .setSourceCode(wave.getCode()) |
| | | .setSourceId(wave.getId()) |
| | |
| | | taskItems.forEach(item -> { |
| | | boolean update = waveItemService.update(new LambdaUpdateWrapper<WaveItem>() |
| | | .eq(WaveItem::getId, item.getSource()) |
| | | .set(WaveItem::getExceStatus, AsnExceStatus) |
| | | .set(WaveItem::getExceStatus, WaveItemExceStatus.WAVE_EXCE_STATUS_SEED.val) |
| | | .set(WaveItem::getWorkQty, item.getAnfme())); |
| | | if (!update) { |
| | | throw new CoolException("波次执行数量修改失败!!"); |