| | |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | throw new CoolException("更新目标站点状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | |
| | | throw new CoolException("数据错误,站点不存在!!"); |
| | | } |
| | | station.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | station.setBarcode(""); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | } |
| | |
| | | } |
| | | |
| | | station.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | station.setBarcode(""); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态修改失败!"); |
| | | } |
| | |
| | | generateCrnInTask(waitPakins, station, param.getLocType1(), userId); |
| | | } |
| | | |
| | | /** |
| | | * SO/EO 区组托 |
| | | * @author Ryan |
| | | * @date 2025/12/18 15:19 |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R collectionPakin(CollectionPakinParams params, Long userId) { |
| | |
| | | |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId); |
| | | //TODO 细化区分,当前出库托盘是滞满足拣货数量 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | //TODO 细化区分,当前出库托盘是满足拣货数量 |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId); |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } |
| | | } |
| | | |
| | |
| | | * 生成堆垛机出库任务 |
| | | * |
| | | * @param locMasts |
| | | * @param station |
| | | * @author Ryan |
| | | * @date 2025/12/6 14:44 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateTask(List<CrnTaskDetlDTO> locMasts, Integer ioType, BasDevp devp, Long userId) { |
| | | public void generateTask(List<CrnTaskDetlDTO> locMasts, Integer ioType, BasDevp devp, Long userId, BasStation station) { |
| | | Date now = new Date(); |
| | | |
| | | for (CrnTaskDetlDTO crnTaskDetlDTO : locMasts) { |
| | |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | //小松项目,缓存出库AGV站点,用于清空缓存区库存 |
| | | wrkMast.setPauseMk(station.getDevNo()); |
| | | // wrkMast.setAvgSta(station.getDevNo());; |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | |
| | | wrkDetl.setOrderNo(""); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setZpallet(null); |
| | | wrkDetl.setBarcode(null); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(11L) // 工作状态:11.生成出库ID |
| | | .setWrkSts(301L) // 工作状态:11.生成出库ID |
| | | .setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) { |
| | | List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); |
| | | if (Objects.isNull(pakins) || pakins.isEmpty()) { |
| | | throw new CoolException("组托信息不存在!!"); |
| | | } |
| | | |
| | | List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(1L) // 工作状态:11.生成出库ID |
| | | .setWrkSts(201L) // 工作状态:11.生成出库ID |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | for (WaitPakin pakin : pakins) { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(pakin, wrkDetl); |
| | | wrkDetl.setId(null).setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setOrderNo(pakin.getOrderNo()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setZpallet(pakin.getZpallet()) |
| | | .setBatch(pakin.getBatch()) |
| | | .setMatnr(pakin.getMatnr()) |
| | | .setMaktx(pakin.getMaktx()) |
| | | .setAppeUser(userId) |
| | | .setUnit(pakin.getUnit()) |
| | | .setModel(pakin.getModel()) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | if (!type.equals("agv_back")) { |
| | | List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); |
| | | if (Objects.isNull(pakins) || pakins.isEmpty()) { |
| | | throw new CoolException("组托信息不存在!!"); |
| | | } |
| | | |
| | | } |
| | | for (WaitPakin pakin : pakins) { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(pakin, wrkDetl); |
| | | wrkDetl.setId(null).setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setOrderNo(pakin.getOrderNo()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setZpallet(pakin.getZpallet()) |
| | | .setBatch(pakin.getBatch()) |
| | | .setMatnr(pakin.getMatnr()) |
| | | .setMaktx(pakin.getMaktx()) |
| | | .setAppeUser(userId) |
| | | .setUnit(pakin.getUnit()) |
| | | .setModel(pakin.getModel()) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | for (WaitPakin pakin : pakins) { |
| | | pakin.setIoStatus("Y"); |
| | | if (!waitPakinService.updateById(pakin)) { |
| | | throw new CoolException("更新组托信息失败"); |
| | | } |
| | | |
| | | for (WaitPakin pakin : pakins) { |
| | | pakin.setIoStatus("Y"); |
| | | if (!waitPakinService.updateById(pakin)) { |
| | | throw new CoolException("更新组托信息失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) { |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 呼叫AGV空台车返回 |
| | | * @author Ryan |
| | | * @date 2025/9/24 |
| | | * @param callAgvBackParam |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R agvCallback(AgvCallParams callAgvBackParam, Long userId) { |
| | | if (Objects.isNull(callAgvBackParam.getOrgSite())) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | |
| | | // 按当前查找库位顺序,查到一个后,不再往下查询 |
| | | LocCache locCache = findPriorityLocCache(); |
| | | |
| | | if (Objects.isNull(locCache)) { |
| | | return R.error("未查询到可用库位"); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", callAgvBackParam.getOrgSite())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | try { |
| | | //空台车回库 |
| | | generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | } |
| | | |
| | | return R.ok(locCache); |
| | | } |
| | | |
| | | /** |
| | | * 按优先级查找可用库位 |
| | | * 顺序:入库缓存区 -> SO区 -> EO区 |
| | | */ |
| | | private LocCache findPriorityLocCache() { |
| | | // 1. Try Inbound Cache Area |
| | | LocCache loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_IN_CACHE); |
| | | if (loc != null) return loc; |
| | | |
| | | // 2. Try SO Area |
| | | loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_SO); |
| | | if (loc != null) return loc; |
| | | |
| | | // 3. Try EO Area |
| | | loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_EO); |
| | | return loc; |
| | | } |
| | | |
| | | /** |
| | | * 根据区域类型查找可用库位 |
| | | */ |
| | | private LocCache findAvailableLocByAreaType(LocAreaType areaType) { |
| | | BasAreas area = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", areaType.type)); |
| | | if (area == null) { |
| | | return null; |
| | | } |
| | | return locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("area_id", area.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | } |
| | | } |