| | |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no", locDetl.getLocNo())); |
| | | if (!Objects.isNull(wrkMast1)) { |
| | | throw new CoolException("源库位已出库,请等待任务完成后,再执行!!"); |
| | | } |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:" + locDetl.getLocNo()); |
| | | } |
| | |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Transactional |
| | | public synchronized R callAgvMove(AgvCallParams params, Long userId) { |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | throw new CoolException("源站点不能为空!!"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R callEmptyCar(AgvCallParams params, Long userId) { |
| | | |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getOrgSite())); |
| | | |
| | | BasStation station1 = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(station1) || Objects.isNull(basAreas)) { |
| | | return R.error("目标站点或库区不存在,请联系管理!!"); |
| | | } |
| | | |
| | | List<String> list = Arrays.asList("SSX01", "SSX02", "SSX03", "SSX04", "SSX05", "SSX06", "SSX07", "SSX08", "SSX09", "SSX10"); |
| | | if (Long.parseLong(station1.getAreaId()) != basAreas.getId() && !list.contains(params.getTarSite())) { |
| | | return R.error("起始区和目标站点不在同一个库区,请重新操作!!"); |
| | | } |
| | | |
| | | List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | |
| | | } |
| | | generateCacheOutTask(station, locCaches.get(0), userId); |
| | | |
| | | // HIKApiDTO hikApiDTO =new HIKApiDTO() |
| | | // .setOrg(locCaches.get(0).getLocNo()) |
| | | // .setOrgType("05") |
| | | // .setTar(params.getTarSite()) |
| | | // .setTarType("05") |
| | | // .setTaskType("GT5") |
| | | // .setPriority("1") |
| | | // .setCtnrType("2") |
| | | // ; |
| | | // HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, |
| | | // HIKApiConstant.AGV_CALL_IN_PATH); |
| | | // if (!hikResultDTO.isSuccess()){ |
| | | // return R.error(hikResultDTO.getMessage()); |
| | | // } |
| | | |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite())); |
| | | if (Objects.isNull(basAreas)) { |
| | | return R.error("站点不存在,请检查站点是否输入正确!!"); |
| | | } |
| | | |
| | | List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>() |
| | | .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateSOEOInTask(String type, LocCache loc, String orgSite, String barcode, Long userId) { |
| | | List<BasStationDetl> basStationDetls = basStationDetlService |
| | | .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(basStationDetls) || basStationDetls.isEmpty()) { |
| | | throw new CoolException("站点信息不存在!!"); |
| | | } |
| | | |
| | | List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | for (BasStationDetl basStationDetl : basStationDetls) { |
| | | List<BasStationDetl> basStationDetls = basStationDetlService |
| | | .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite)); |
| | | basStationDetls.forEach(basStationDetl -> { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(basStationDetl, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | // 修改原站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) { |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标站点状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标站点状态失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) { |
| | | throw new CoolException("组托明细不能为空!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("wrk_sts", 14) |
| | | .eq("io_type", 104) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | throw new CoolException("任务档信息不存在!!"); |
| | | throw new CoolException("任务档信息不存在,请检查托盘:" + param.getBarcode() + "任务档是否已完成出库 !!"); |
| | | } |
| | | |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", combMat.getThreeCode())); |
| | | .eq(!Objects.isNull(combMat.getMatnr()), "matnr", combMat.getMatnr()) |
| | | .eq(!Objects.isNull(combMat.getThreeCode()), "three_code", combMat.getThreeCode())); |
| | | if (Objects.isNull(stationDetl)) { |
| | | throw new CoolException("明细内容不存在!!"); |
| | | } |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | .eq("supp_code", stationDetl.getSuppCode())); |
| | | |
| | | if (Objects.isNull(wrkDetl)) { |
| | | //TODO 新插入 |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", stationDetl.getMatnr()) |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | if (Objects.isNull(mat)) { |
| | | throw new CoolException("物料基础信息已不存在!!"); |
| | |
| | | detl.setAnfme(combMat.getAnfme()); |
| | | detl.setBarcode(wrkMast.getBarcode()); |
| | | detl.setZpallet(param.getBarcode()); |
| | | detl.setBoxType1(combMat.getBoxType1()); |
| | | detl.setBoxType1(param.getBoxType1()); |
| | | detl.setStandby1(combMat.getSuppCode()); |
| | | detl.setThreeCode(combMat.getThreeCode()); |
| | | detl.setAdjustQty(combMat.getAdjustQty()); |
| | |
| | | double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0; |
| | | WrkDetl detl = new WrkDetl(); |
| | | detl.setOrderNo(stationDetl.getOrderNo()); |
| | | detl.setBoxType1(combMat.getBoxType1()); |
| | | detl.setBoxType1(param.getBoxType1()); |
| | | detl.setZpallet(param.getBarcode()); |
| | | detl.setBarcode(param.getBarcode()); |
| | | detl.setThreeCode(combMat.getThreeCode()); |
| | |
| | | if (Cools.isEmpty(basStation)) { |
| | | throw new CoolException("请输入正确的站点号"); |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", params.getOrgBarcode())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | throw new CoolException("出库任务档信息不存在!!"); |
| | | } |
| | | |
| | | for (CollectionPakinParams.CombMat combMat : params.getCombMats()) { |
| | | if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) { |
| | | continue; |
| | |
| | | BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("dev_no", basStation.getDevNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("batch", combMat.getBatch()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch()) |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "standby1", combMat.getStandby1())); |
| | | |
| | | |
| | | Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>() |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_coode", combMat.getStandby1()); |
| | | //// .eq(!Objects.isNull(params.getBoxType1()), "boxType1", params.getBoxType1()) |
| | | // |
| | | // if (!Objects.isNull(params.getBoxType1())) { |
| | | // wrapper.eq("box_type1", params.getBoxType1()); |
| | | // } |
| | | |
| | | // WrkDetl wrkDetl = wrkDetlService.selectOne(wrapper); |
| | | |
| | | if (Cools.isEmpty(basStationDetl)) { |
| | | basStationDetl = new BasStationDetl(); |
| | | Mat mat = matService.selectByMatnr(combMat.getMatnr()); |
| | |
| | | .setBarcode(params.getTarBarcode()) |
| | | .setZpallet(params.getTarBarcode()) |
| | | .setBatch(combMat.getBatch()) |
| | | .setBoxType1(params.getBoxType1()) |
| | | .setSuppCode(combMat.getStandby1()) |
| | | .setStandby1(combMat.getStandby1()) |
| | | .setAnfme(combMat.getWorkQty().doubleValue()); |
| | | |
| | | // if (!Objects.isNull(wrkDetl) && !wrkDetl.getMatnr().equals(combMat.getMatnr())) { |
| | | // throw new CoolException("请检查隔层是否绑定正确!!"); |
| | | // } |
| | | if (!basStationDetlService.insert(basStationDetl)) { |
| | | throw new CoolException("插入明细失败"); |
| | | } |
| | | |
| | | } else { |
| | | BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty()); |
| | | basStationDetl.setAnfme(anfme.doubleValue()); |
| | |
| | | |
| | | @Override |
| | | public R collectionPakinView(CollectionPakinParams params) { |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(params.getOrgBarcode()); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException("未找到任务"); |
| | |
| | | |
| | | if (wrkMast.getIoType().equals(TaskIOType.ALL_OUT.type) |
| | | && wrkMast.getIoType().equals(TaskIOType.PICK_OUT.type)) { |
| | | throw new CoolException("人物类型错误"); |
| | | throw new CoolException("任务类型错误"); |
| | | } |
| | | |
| | | wrkDetlService.selectList(new EntityWrapper<WrkDetl>() |
| | | .eq(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr()) |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>() |
| | | .like(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq(!Objects.isNull(params.getBoxType1()), "box_type1", params.getBoxType1()) |
| | | .eq("wrk_no", wrkMast.getWrkNo())); |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | // List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | if (Cools.isEmpty(wrkDetls)) { |
| | | throw new CoolException("未找到任务明细"); |
| | | } |
| | |
| | | AtomicReference<Double> totalOut = new AtomicReference<>(0.0); |
| | | listMap.forEach((matnr, detls) -> { |
| | | Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1)); |
| | | supIds.forEach((supId, sups) -> { |
| | | for (String supId : supIds.keySet()) { |
| | | List<LocDetl> sups = supIds.get(supId); |
| | | // } |
| | | // supIds.forEach((supId, sups) -> { |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", supId) |
| | | .eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | | // 根据supId(供应商)分类,得到需要存放的总空库存数量 |
| | | Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum(); |
| | | AtomicReference<Double> itemed = new AtomicReference<>(0.0); |
| | |
| | | if (container.getMixMax() > sets.size()) { |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", supId) |
| | | .eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | | //余下最大可放数量 |
| | | Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0; |
| | | // 入库数量小于零且入库数量减去已计划出数量大于零() |
| | |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | // 获取当前供应商+ 物料在库 |
| | | LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId()); |
| | | if (Objects.isNull(notFullList)) { |
| | | continue; |
| | | } |
| | | BasContainer container = basContainerService |
| | | .selectOne(new EntityWrapper<BasContainer>().eq("barcode", notFullList.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误,容器不存在!!"); |
| | | } |
| | | List<LocDetl> adetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", notFullList.getLocNo())); |
| | | Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | List<LocDetl> locDtls = new ArrayList<>(); |
| | | // 判断容器是否还可混放,及当前物料可放多少 |
| | | if (container.getMixMax() > sets.size()) { |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | //余下最大可放数量 |
| | | Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0; |
| | | // 入库数量小于零且入库数量减去已计划出数量大于零() |
| | | if (sum.compareTo(v) <= 0 && sum.compareTo(itemed.get()) > 0) { |
| | | itemed.set(Math.round((itemed.get() + v) * 10000) / 10000.0); |
| | | // 可放下 |
| | | LocDetl locDetl = new LocDetl(); |
| | | BeanUtils.copyProperties(mats, locDetl); |
| | | locDetl.setLocNo(notFullList.getLocNo()); |
| | | locDetl.setAnfme(0.0); |
| | | locDetl.setMatnr(mats.getMatnr()); |
| | | locDetl.setZpallet(notFullList.getBarcode()); |
| | | locDetl.setSuppCode(mats.getSuppCode()); |
| | | locDetl.setMaktx(mats.getMaktx()); |
| | | locDtls.add(locDetl); |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(notFullList.getLocNo()).setLocDetlList(locDtls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | /**是否优先空板出库*/ |
| | |
| | | } |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>()); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } else { |
| | |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(locMast.getLocNo()); |
| | | // if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type) |
| | | // || locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) { |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:" + locMast.getLocNo()); |
| | | if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type) |
| | | || locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) { |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:" + locMast.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(locMast.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | // } else { |
| | | // throw new CoolException(locMast.getLocNo() + "库位不是在库状态"); |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId) |
| | | .setModiTime(new Date()); |
| | | |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | station.setLocSts("O"); // S.入库预约 |
| | | station.setLocSts("O"); |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo())); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO, String path) { |
| | |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | try { |
| | | //空台车回库 |
| | | generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | log.error(e.getMessage()); |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | return R.ok(locCache); |
| | |
| | | return R.error("台车编码不能为空!"); |
| | | } |
| | | List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>() |
| | | // .eq(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("zpallet", params.getCarBarcode())); |
| | | |
| | | taskDetls.forEach(taskDetl -> { |
| | |
| | | if (Objects.isNull(params.getTarSite())) { |
| | | return R.error("目标站点不能为空!!"); |
| | | } |
| | | BasStation devNo = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(devNo) || !devNo.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | return R.error("目标站点忙碌中!!"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locCache.getLocNo())); |
| | | if (Objects.isNull(locDetls) || locDetls.isEmpty()) { |
| | | return R.error("台车上没有对应明细信息!!"); |
| | | } |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | locDetls.forEach(locDetl -> { |
| | | OrderPakout orderPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>() |
| | | List<OrderPakout> orderPakouts = orderPakoutService.selectList(new EntityWrapper<OrderPakout>() |
| | | .eq("doc_type", 5) |
| | | .eq("number", locDetl.getOrderNo())); |
| | | if (!Objects.isNull(orderPakout)) { |
| | | if (Objects.isNull(orderPakouts) || orderPakouts.isEmpty()) { |
| | | throw new CoolException("单据信息不存在或已上报完成!!"); |
| | | } |
| | | for (OrderPakout orderPakout : orderPakouts) { |
| | | OrderDetlPakout orderDetl = orderDetlPakoutService.selectOne(new EntityWrapper<OrderDetlPakout>() |
| | | .eq("matnr", locDetl.getMatnr()) |
| | | .eq("supp_code", locDetl.getSuppCode()) |
| | | .eq("order_no", orderPakout.getOrderNo())); |
| | | if (Objects.isNull(orderDetl)) { |
| | | continue; |
| | | } |
| | | locDetl.setMemo(orderPakout.getShipCode()); |
| | | locDetl.setOrderNo(orderPakout.getOrderNo()); |
| | | } |
| | | OrderDetlPakout orderDetl = orderDetlPakoutService.selectOne(new EntityWrapper<OrderDetlPakout>() |
| | | .eq("matnr", locDetl.getMatnr()) |
| | | .eq("supp_code", locDetl.getSuppCode()) |
| | | .eq("order_no", orderPakout.getOrderNo())); |
| | | if (Objects.isNull(orderDetl)) { |
| | | throw new CoolException("订单明细不存在!!"); |
| | | } |
| | | |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | locDetl.getAnfme()); |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locCache.getFrozen()); |
| | | // List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().in("area_id", areaIds)); |
| | | // List<String> collect = basStations.stream().map(BasStation::getDevNo).collect(Collectors.toList()); |
| | | // locDto.setAgvStaNos(collect); |
| | | locDto.setAgvStaNo(params.getTarSite()); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | locDto.setSuppCode(orderDetl.getSuppCode()); |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | | locDto.setStandby2(orderDetl.getStandby2()); |
| | | locDto.setStandby3(orderDetl.getStandby3()); |
| | | locDto.setBoxType1(orderDetl.getBoxType1()); |
| | | locDto.setBoxType2(orderDetl.getBoxType2()); |
| | | locDto.setBoxType3(orderDetl.getBoxType3()); |
| | | locDtos.add(locDto); |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), locDetl.getAnfme()); |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locCache.getFrozen()); |
| | | locDto.setAgvStaNo(params.getTarSite()); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | locDto.setSuppCode(orderDetl.getSuppCode()); |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | | locDto.setStandby2(orderDetl.getStandby2()); |
| | | locDto.setStandby3(orderDetl.getStandby3()); |
| | | locDto.setBoxType1(orderDetl.getBoxType1()); |
| | | locDto.setBoxType2(orderDetl.getBoxType2()); |
| | | locDto.setBoxType3(orderDetl.getBoxType3()); |
| | | locDtos.add(locDto); |
| | | |
| | | } |
| | | // exist.add(locDetl.getLocNo()); |
| | | }); |
| | | |
| | | generateAgvTaskByTc(locDtos); |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取站点明细信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getStationInfos(AgvCallParams params) { |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | return R.error("站点不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("站点台车不能为空!!"); |
| | | } |
| | | // if (!Cools.isEmpty(params.getMatnr())) { |
| | | // return R.error("物料信息不能为空!!"); |
| | | // } |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .eq("dev_no", params.getOrgSite()) |
| | | .eq("barcode", params.getCarBarcode())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("台车与站点绑定关系不存在,请联系管理员!"); |
| | | } |
| | | List<BasStationDetl> stationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>() |
| | | .like(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("dev_no", station.getDevNo())); |
| | | if (!stationDetls.isEmpty()) { |
| | | return R.ok().add(stationDetls); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 站点物料解绑 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R unbindMatnr(CombParam params) { |
| | | if (Objects.isNull(params.getCombMats()) || params.getCombMats().isEmpty()) { |
| | | return R.error("明细不能为空!!"); |
| | | } |
| | | for (CombParam.CombMat combMat : params.getCombMats()) { |
| | | if (Objects.isNull(combMat)) { |
| | | continue; |
| | | } |
| | | OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>() |
| | | .lt("settle", 4) |
| | | .eq("order_no", combMat.getOrderNo())); |
| | | if (Objects.isNull(order)) { |
| | | return R.error("未查询到订单,请确认是否为库口组托信息!!"); |
| | | } |
| | | //入库 |
| | | OrderDetlPakin detlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()) |
| | | .last("AND anfme != qty")); |
| | | |
| | | if (!Objects.isNull(detlPakin)) { |
| | | Double v = Math.round((detlPakin.getWorkQty() - combMat.getAnfme()) * 10000) / 10000.0; |
| | | detlPakin.setWorkQty(v); |
| | | if (!orderDetlPakinService.update(detlPakin, new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("订单明细更新失败!!"); |
| | | } |
| | | |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(stationDetl)) { |
| | | if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("解绑失败,站点库存删除失败!"); |
| | | } |
| | | } |
| | | |
| | | 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("站点查询失败,请联系管理员!!"); |
| | | } |
| | | |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(locDetl)) { |
| | | if (!locDetlService.delete(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("解绑失败,缓冲库区库存删除失败!"); |
| | | } |
| | | } |
| | | |
| | | WaitPakin waitPakin = waitPakinService.selectOne(new EntityWrapper<WaitPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(waitPakin)) { |
| | | if (!waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("原组托档删除失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | throw new CoolException("订单明细绑定关系不存在或已完成入库!!"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateAgvTaskByTc(List<LocDto> locDtos) { |
| | | List<LocDto> locDtoArrayList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos){ |
| | | if (locDto.getFrozen()!=1 && locDto.getFrozenLoc()!=1){ |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.getFrozen() != 1 && locDto.getFrozenLoc() != 1) { |
| | | locDtoArrayList.add(locDto); |
| | | } |
| | | } |
| | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | if (locDto.isLack()) { |
| | | continue; |
| | | } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getAgvStaNo(), locDto); |
| | | if (TaskDto.hasAgv(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.findAgv(taskDtos, taskDto); |
| | |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .in("loc_sts", Arrays.asList(LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_O.type)) |
| | | .eq("dev_no", taskDto.getAgvStaNo())); |
| | | if (Objects.isNull(station)) { throw new CoolException("数据错误,站点不存在或已使用!!"); } |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("数据错误,站点不存在或已使用!!"); |
| | | } |
| | | workService.agvStockOut(station, taskDto, 9527L); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 确认捆包出库 |
| | |
| | | detl.setSupp(combMat.getSuppCode()); |
| | | if (!taskDetlService.update(detl, new EntityWrapper<TaskDetl>() |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("order_no", detl.getOrderNo()) |
| | | .eq("supp_code", detl.getSuppCode()) |
| | | .eq("wrk_no", task.getWrkNo()))) { |
| | | throw new CoolException("任务号信息更新失败!!"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | task.setWrkSts(TaskStatusType.AGV_INVENTORY_UPDATED_OUT.type); |
| | | if (!taskService.update(task, new EntityWrapper<Task>().eq("wrk_no", taskDetl.getWrkNo()))) { |
| | | throw new CoolException("任务信息更新失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | task.setWrkSts(TaskStatusType.AGV_INVENTORY_UPDATED_OUT.type); |
| | | if (!taskService.update(task, new EntityWrapper<Task>().eq("wrk_no", task.getWrkNo()))) { |
| | | throw new CoolException("任务信息更新失败!!"); |
| | | } |
| | | } |
| | | //TODO 比对实际出库数量和任务档数量是否相等,修改原任务档为53,生成新的入库任务 |
| | | |
| | | return R.ok("呼叫成功!!"); |
| | | } |
| | | |
| | |
| | | return R.error("没有可用空板!!"); |
| | | } |
| | | |
| | | locMast.setLocSts(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", locMast.getLocNo()))) { |
| | | throw new CoolException(locMast.getLocNo() + "出库预约失败!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no", locMast.getLocNo())); |
| | | if (!Objects.isNull(wrkMast1)) { |
| | | throw new CoolException("任务档已生成,请不要重复操作!!"); |
| | | } |
| | | int workNo = commonService.getWorkNo(0); |
| | | //TODO 生成并板出库任务 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setIoType(104); |
| | |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkDate(new Date()); |
| | | wrkMast.setWrkNo(commonService.getWorkNo(0)); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setTaskType("crn"); |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | |
| | | return R.ok().add(wrkMast); |
| | | } |
| | | |
| | | /** |
| | | * 获取出库台车所有信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getTcAllInfos(AgvCallParams params) { |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("台车码不能为空!!"); |
| | | } |
| | | // Task task = taskService.selectOne(new EntityWrapper<Task>().eq("barcode", params.getCarBarcode())); |
| | | // if (Objects.isNull(task)) { |
| | | // throw new CoolException("任务档不存在!!"); |
| | | // } |
| | | // if (Objects.isNull(task.getSourceLocNo())) { |
| | | // throw new CoolException("请检查任务类型是否属于出库捆绑!!"); |
| | | // } |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("barcode", params.getCarBarcode())); |
| | | if (Objects.isNull(locCache)) { |
| | | return R.error("当前台车不在缓冲库区!!"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locCache.getLocNo())); |
| | | if (!Objects.isNull(locDetls) && !locDetls.isEmpty()) { |
| | | locDetls.forEach(locDetl -> { |
| | | OrderPakout orderPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>() |
| | | .eq("number", locDetl.getOrderNo())); |
| | | if (!Objects.isNull(orderPakout)) { |
| | | locDetl.setMemo(orderPakout.getShipCode()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | try { |
| | | Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMemo)); |
| | | if (!Cools.isEmpty(params.getShipCode())) { |
| | | List<LocDetl> detlList = listMap.get(params.getShipCode()); |
| | | return R.ok().add(detlList); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | |
| | | return R.ok().add(locDetls); |
| | | // Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMemo)); |
| | | // if (!Objects.isNull(params.getShipCode())) { |
| | | // List<LocDetl> detlList = listMap.get(params.getShipCode()); |
| | | // return R.ok().add(detlList); |
| | | // } else { |
| | | // return R.ok().add(locDetls); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 生成移库任务 |
| | |
| | | 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); |
| | | // // 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; |
| | | } |
| | | |
| | |
| | | } |
| | | 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")); |
| | | .orderAsc(Arrays.asList("loc_no"))); |
| | | } |
| | | } |