| | |
| | | } |
| | | |
| | | 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("更新目标站点状态失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0; |
| | | WrkDetl detl = new WrkDetl(); |
| | | detl.setOrderNo(stationDetl.getOrderNo()); |
| | | detl.setBoxType1(wrkDetl.getBoxType1()); |
| | | detl.setBoxType1(param.getBoxType1()); |
| | | detl.setZpallet(param.getBarcode()); |
| | | detl.setBarcode(param.getBarcode()); |
| | | detl.setThreeCode(combMat.getThreeCode()); |
| | |
| | | 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 { |
| | |
| | | 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())); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | if (Objects.isNull(combMat)) { |
| | | continue; |
| | | } |
| | | OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", combMat.getOrderNo())); |
| | | OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>() |
| | | .lt("settle", 4) |
| | | .eq("order_no", combMat.getOrderNo())); |
| | | if (Objects.isNull(order)) { |
| | | return R.error("为查询到订单,请确认是否为库口组托信息!!"); |
| | | return R.error("未查询到订单,请确认是否为库口组托信息!!"); |
| | | } |
| | | //入库 |
| | | OrderDetlPakin detlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | .eq("supp_code", combMat.getStandby1()) |
| | | .last("AND anfme != qty")); |
| | | |
| | | if (!Objects.isNull(detlPakin)) { |
| | | Double v = Math.round((detlPakin.getWorkQty() - combMat.getAnfme()) * 10000) / 10000.0; |
| | |
| | | throw new CoolException("订单明细更新失败!!"); |
| | | } |
| | | |
| | | if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("order_no", combMat.getOrderNo()) |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("站点数据删除失败!!"); |
| | | .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>() |
| | |
| | | } |
| | | } |
| | | } else { |
| | | throw new CoolException("订单明细绑定关系不存在!!"); |
| | | throw new CoolException("订单明细绑定关系不存在或已完成入库!!"); |
| | | } |
| | | } |
| | | return R.ok(); |