| | |
| | | // } |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, param.getTransferStationNo())); |
| | | if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | throw new CoolException("站点不存在或站点不处于空库状态!!"); |
| | | if (Objects.isNull(station) || (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type) && !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_D.type)) ) { |
| | | throw new CoolException("站点不存在或站点不处于空库、空板状态!!"); |
| | | } |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(station.getStationName())); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | throw new CoolException("库位规则未知"); |
| | | } |
| | | WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId()); |
| | | if (Cools.isEmpty(warehouseArea)) { |
| | | throw new CoolException("未找到所属库区信息"); |
| | | } |
| | | StringBuilder errorBuilder = new StringBuilder(); |
| | | List<Long> areaTypeList = LocUtils.getAreaTypeList(station.getStationName()); |
| | | for (Long areaType : areaTypeList) { |
| | | if (errorBuilder.length() > 0) { |
| | | errorBuilder.append(","); |
| | | } |
| | | errorBuilder.append("路径ID:"); |
| | | errorBuilder.append(areaType); |
| | | DeviceBind deviceBind = deviceBindService.getById(areaType); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | errorBuilder.append("库位规则未知"); |
| | | continue; |
| | | // throw new CoolException("库位规则未知"); |
| | | } |
| | | WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId()); |
| | | if (Cools.isEmpty(warehouseArea)) { |
| | | errorBuilder.append("未找到所属库区信息"); |
| | | continue; |
| | | // throw new CoolException("未找到所属库区信息"); |
| | | } |
| | | |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, station.getStationName()) |
| | | .eq(DeviceSite::getAreaIdEnd, warehouseArea.getId()) |
| | | .eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPITY_IN.type).last("limit 1")); |
| | | if (Cools.isEmpty(deviceSite)) { |
| | | errorBuilder.append("无可用路径"); |
| | | continue; |
| | | // throw new CoolException("无可用路径!!"); |
| | | } |
| | | |
| | | // BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>() |
| | | // .eq(BasContainer::getCode, param.getContainerNo())); |
| | | // if (Objects.isNull(container)) { |
| | | // throw new CoolException("容器未维护入库,请维护后再操作!!"); |
| | | // } |
| | | //验证基础信息 |
| | | checkStaStatus(param.getContainerNo(), param.getTransferStationNo()); |
| | | /**获取库位*/ |
| | | String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null); |
| | | if (Cools.isEmpty(targetLoc)) { |
| | | throw new CoolException("该站点对应库区未找到库位"); |
| | | } |
| | | //验证基础信息 |
| | | checkStaStatus(param.getContainerNo(), param.getTransferStationNo()); |
| | | /**获取库位*/ |
| | | String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null); |
| | | if (Cools.isEmpty(targetLoc)) { |
| | | errorBuilder.append("该站点对应库区未找到库位"); |
| | | continue; |
| | | // throw new CoolException("该站点对应库区未找到库位"); |
| | | } |
| | | |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!"); |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setTaskType(TaskType.TASK_TYPE_EMPITY_IN.type) |
| | | .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)//lsh待修改 |
| | | .setTargLoc(targetLoc) |
| | | .setOrgSite(station.getStationName()) |
| | | .setBarcode(param.getContainerNo()) |
| | | .setTargSite(station.getStationName()) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId); |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!"); |
| | | } |
| | | BasStation stationCode = basStationService.getById(deviceSite.getDeviceCode()); |
| | | String stationName = stationCode.getStationName(); |
| | | if (Cools.isEmpty(stationCode)) { |
| | | stationName = station.getStationName(); |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setTaskType(TaskType.TASK_TYPE_EMPITY_IN.type) |
| | | .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)//lsh待修改 |
| | | .setTargLoc(targetLoc) |
| | | .setOrgSite(station.getStationName()) |
| | | .setBarcode(param.getContainerNo()) |
| | | .setTargSite(stationName) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId); |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | } |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, param.getContainerNo()))) { |
| | | throw new CoolException("库位预约失败!!"); |
| | | } |
| | | return R.ok("任务生成完毕!"); |
| | | } |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, param.getContainerNo()))) { |
| | | throw new CoolException("库位预约失败!!"); |
| | | return R.error(errorBuilder.toString()).add(errorBuilder.toString()); |
| | | } |
| | | |
| | | @Override |
| | | public R checkAgvStation(PdaGeneralParam param, Long loginUserId) { |
| | | if (Cools.isEmpty(param.getTransferStationNo())) { |
| | | return R.error("无参数"); |
| | | } |
| | | return R.ok("任务生成完毕!"); |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationId, param.getTransferStationNo())); |
| | | if (Cools.isEmpty(basStation)) { |
| | | return R.error("未找到匹配站点"); |
| | | } |
| | | return R.ok(basStation); |
| | | } |
| | | |
| | | } |