| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.enums.MatLocType; |
| | | import com.zy.api.enums.MatType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.FindLocNoAttributeVo; |
| | |
| | | throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | |
| | | BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误:容器码不存在!!"); |
| | | } |
| | | if (container.getMixMax() < detlDtos.size()) { |
| | | throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | } |
| | | // BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | // if (Objects.isNull(container)) { |
| | | // throw new CoolException("数据错误:容器码不存在!!"); |
| | | // } |
| | | // if (container.getMixMax() < detlDtos.size()) { |
| | | // throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | // } |
| | | //还可以放入多少种物料 |
| | | Integer suplus = container.getMixMax(); |
| | | // Integer suplus = container.getMixMax(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | BeanUtils.copyProperties(mat, waitPakin); |
| | | waitPakin.setOrderNo(detlDto.getOrderNo()); // 单据编号 |
| | | waitPakin.setType(param.getType()); |
| | | waitPakin.setOrderId(detlDto.getOrderId()); |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | public R callAgvMove(AgvCallParams params, Long userId) { |
| | | @Transactional |
| | | public synchronized R callAgvMove(AgvCallParams params, Long userId) { |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | throw new CoolException("源站点不能为空!!"); |
| | | } |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type)); |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("area_id",basAreas.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | // .eq("loc_no", params.getTarSite()) |
| | |
| | | throw new CoolException("请检查目标库位是否闲置中!!"); |
| | | } |
| | | |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId); |
| | | try { |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId); |
| | | }catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R OutCallAgv(AgvCallParams params, Long userId) { |
| | | /**获取入库最早的一条数据**/ |
| | | LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type) |
| | | .eq("frozen", 0) |
| | | .orderDesc(Arrays.asList("sort", "first_time")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | if (Objects.isNull(locCaches)) { |
| | | .orderDesc(Arrays.asList("sort", "first_time"))); |
| | | |
| | | if (locCaches.isEmpty()) { |
| | | throw new CoolException("暂无满足需求库位!"); |
| | | } |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点正在执行任务!!"); |
| | | |
| | | for (LocCache locCache : locCaches) { |
| | | //获取缓存区信息 |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type)); |
| | | if (Objects.isNull(basAreas)) { |
| | | throw new CoolException("库区不存在!!"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("loc_no", locCache.getLocNo())); |
| | | if (Objects.isNull(locDetls) || locDetls.isEmpty()) { |
| | | throw new CoolException("库存明细不存在!!"); |
| | | } |
| | | |
| | | Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set)); |
| | | if (Objects.isNull(matList) || matList.isEmpty()) { |
| | | throw new CoolException("物料库不存在该物料!!"); |
| | | } |
| | | Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | if (!longs.isEmpty() && longs.size() > 1) { |
| | | throw new CoolException("物料类型不一致,请检查数据是否正确!!"); |
| | | } |
| | | |
| | | Mat mat = matList.stream().findFirst().get(); |
| | | |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .eq("ctn_type", mat.getTagId()) |
| | | .eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(station)) { |
| | | continue; |
| | | } |
| | | |
| | | /**生成缓存区出库任务*/ |
| | | generateCacheOutTask(station, locCache, userId); |
| | | |
| | | /**生成立库出库任务*/ |
| | | generateCRNOutTask(station, locCache, userId); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /**生成缓存区出库任务*/ |
| | | generateCacheOutTask(station, locCaches, userId); |
| | | |
| | | /**生成立库出库任务*/ |
| | | generateCRNOutTask(station, locCaches, userId); |
| | | |
| | | return R.ok(); |
| | | return R.error("未找到与站点类型匹配的库存"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new CoolException("站点信息不存在!!"); |
| | | } |
| | | |
| | | |
| | | |
| | | List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | |
| | | throw new CoolException("库存明细不存在!!"); |
| | | } |
| | | |
| | | Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set)); |
| | | if (Objects.isNull(matList) || matList.isEmpty()) { |
| | | throw new CoolException("物料库不存在该物料!!"); |
| | | } |
| | | Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | if (!longs.isEmpty() && longs.size() > 1) { |
| | | throw new CoolException("物料类型不一致,请检查数据是否正确!!"); |
| | | } |
| | | // Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | // List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set)); |
| | | // |
| | | // if (Objects.isNull(matList) || matList.isEmpty()) { |
| | | // throw new CoolException("物料库不存在该物料!!"); |
| | | // } |
| | | // Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | // if (!longs.isEmpty() && longs.size() > 1) { |
| | | // throw new CoolException("物料类型不一致,请检查数据是否正确!!"); |
| | | // } |
| | | |
| | | //获取立库区信息 |
| | | BasAreas one = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_CRN.type)); |
| | |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(11L) // 工作状态:11.生成出库ID |
| | | .setIoType(loc.getLocSts().equals("D") ? 110 : 103) // 入出库状态: 11.库格移载 |
| | | .setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setFullPlt(loc.getLocSts().equals("D") ? "N" : "Y") // 满板:Y |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | List<TaskDetl> taskDetls = new ArrayList<>(); |
| | | pakins.forEach(pakin -> { |
| | | for (WaitPakin pakin :pakins){ |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(pakin, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | | wrkDetl.setId(null).setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setOrderNo(pakin.getOrderNo()) |
| | | .setAnfme(pakin.getAnfme()) |
| | |
| | | .setModel(pakin.getModel()) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | taskDetls.add(wrkDetl); |
| | | }); |
| | | if (!taskDetlService.insert(wrkDetl)){ |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | //保存工作档明细 |
| | | if (!taskDetlService.insertBatch(taskDetls)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | pakins.forEach(pakin -> { |
| | | |
| | | for (WaitPakin pakin : pakins){ |
| | | pakin.setIoStatus("Y"); |
| | | }); |
| | | |
| | | if (!waitPakinService.updateBatchById(pakins)) { |
| | | throw new CoolException("更新组托信息失败"); |
| | | if (!waitPakinService.updateById(pakin)) { |
| | | throw new CoolException("更新组托信息失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约 |