| | |
| | | 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; |
| | |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.enums.IoWorkType; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | |
| | | throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | // 还可以放入多少种物料 |
| | | Integer suplus = container.getMixMax(); |
| | | Double suplus = container.getMixMax(); |
| | | Date now = new Date(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | |
| | | if (v1.compareTo(stationDetl.getAnfme()) >= 0) { |
| | | if (!basStationDetlService.deleteById(stationDetl)) { |
| | | throw new CoolException("原始数据移除失败!"); |
| | | } |
| | | } |
| | | |
| | | List<BasStationDetl> stas = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>() |
| | | .eq("dev_no", stationDetl.getDevNo())); |
| | | if (Objects.isNull(stas) || stas.isEmpty()) { |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", stationDetl.getDevNo())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("数据错误,站点不存在!!"); |
| | | } |
| | | station.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | |
| | | BasDevp basDevp = devps.stream().findFirst().get(); |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMatnr)); |
| | | AtomicReference<Double> totalOut = new AtomicReference<>( |
| | | locDetls.stream().mapToDouble(LocDetl::getAnfme).sum()); |
| | | //获取查库存总数量 |
| | | AtomicReference<Double> totalOut = new AtomicReference<>(0.0); |
| | | listMap.forEach((matnr, detls) -> { |
| | | // 根据supId(供应商)分类,得到出库总数 |
| | | Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1)); |
| | | supIds.forEach((supId, sups) -> { |
| | | // 根据supId(供应商)分类,得到需要存放的总空库存数量 |
| | | Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum(); |
| | | AtomicReference<Double> itemed = new AtomicReference<>(0.0); |
| | | // 获取当前供应商+ 物料在库 |
| | | List<LocDetl> detlList = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("matnr", matnr) |
| | |
| | | Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | // 判断容器是否还可混放,及当前物料可放多少 |
| | | if (container.getMixMax() > sets.size()) { |
| | | int suplus = container.getMixMax() - sets.size(); |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | | Double v = mats.getUpQty() * suplus; |
| | | // 小于零 |
| | | if (sum.compareTo(v) <= 0) { |
| | | //余下最大可放数量 |
| | | 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); |
| | | // 可放下 |
| | | locMasts.add(locMast); |
| | | totalOut.set(Math.round((totalOut.get() - sum) * 10000) / 10000.0); |
| | | totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0); |
| | | } |
| | | } |
| | | }); |
| | |
| | | |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | // Set<String> matnrs = |
| | | // locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | // List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", |
| | | // matnrs)); |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId); |
| | | //TODO 细化区分,当前出库托盘是滞满足拣货数量 |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | |
| | | locMasts.add(locMast); |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.EMPTY_OUT.type, basDevp, userId); |
| | | } else { |
| | | // 生成堆垛机出库任务 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId); |
| | | // if (!locMasts.isEmpty()) { |
| | | // |
| | | // } |
| | | } |
| | | } |
| | | |