| | |
| | | |
| | | /** |
| | | * 库存出库生成出库任务 |
| | | * type: 空板出库 |
| | | * |
| | | * @param resouce |
| | | * @param map |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized void generateTaskEmpty(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception { |
| | | if (Objects.isNull(map.getSiteNo())) { |
| | | throw new CoolException("目标站点不能为空!"); |
| | | } |
| | | if (Objects.isNull(map.getOrgLoc())) { |
| | | throw new CoolException("源库位不能为空!"); |
| | | } |
| | | String siteNo = map.getSiteNo(); |
| | | Task task = new Task(); |
| | | Loc loc = locService.getById(Long.decode(map.getOrgLoc())); |
| | | logger.info("库位:>{}", loc.getCode()); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("数据错误:所选库存信息不存在!!"); |
| | | } |
| | | if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_D.type)) { |
| | | throw new CoolException("库位:" + loc.getCode() + ",不处于D.空板状态,不可执行R.出库预约操作!!"); |
| | | } |
| | | |
| | | loc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!locService.updateById(loc)) { |
| | | throw new CoolException("库位状态更新失败!!"); |
| | | } |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | task.setOrgLoc(loc.getCode()) |
| | | .setTaskCode(ruleCode) |
| | | .setResource(resouce) |
| | | .setTargSite(siteNo) |
| | | .setSort(Constants.TASK_SORT_DEFAULT_VALUE) |
| | | .setUpdateBy(loginUserId) |
| | | .setCreateBy(loginUserId) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(new Date()) |
| | | .setTaskStatus(TaskStsType.GENERATE_OUT.id) |
| | | .setBarcode(loc.getBarcode()) |
| | | .setMemo(map.getMemo()); |
| | | |
| | | if (map.getType().equals(Constants.TASK_TYPE_OUT_STOCK_EMPTY)) { |
| | | //空容器出库 |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()) |
| | | .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPITY_OUT.type)); |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不支持空容器出库!!"); |
| | | } |
| | | task.setTaskType(TaskType.TASK_TYPE_EMPITY_OUT.type).setWarehType(deviceSite.getDevice()); |
| | | } else { |
| | | throw new CoolException("空容器出库!!其他类型无效,进入类型:"+map.getType()); |
| | | } |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("任务创建失败!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 库存出库生成出库任务 |
| | | * type: check 盘点, stock: 库存出库 |
| | | * |
| | | * @param resouce |