| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | if (Cools.isEmpty(param.getPalletBarcode())) { |
| | | throw new CoolException("托盘码不能为空!!"); |
| | | } |
| | | if (Cools.isEmpty(param.getPalletSta())) { |
| | | throw new CoolException("操作站点不能为空!!"); |
| | | } |
| | | |
| | | checkPalletBarcodeAvailable(param.getPalletBarcode()); |
| | | |
| | |
| | | .setAnfme(1.0) |
| | | .setOrderItems(Collections.singletonList(buildOrderItem(param, matnr, nowMillis, nowSeconds).setBarcode(param.getPalletBarcode()))); |
| | | syncOrder.setStationId(param.getPalletSta()); |
| | | receiveMsgService.syncCheckOrder(Collections.singletonList(syncOrder), loginUserId); |
| | | |
| | | R r = receiveMsgService.syncCheckOrder(Collections.singletonList(syncOrder), loginUserId); |
| | | if (!Objects.isNull(r) && Objects.equals(String.valueOf(r.get("code")), "200")) { |
| | | autoCallAgvInTask(param, loginUserId); |
| | | } |
| | | return R.ok(Cools.add("orderNo", orderNo).add("palletBarcode", param.getPalletBarcode())); |
| | | } |
| | | |
| | | private void autoCallAgvInTask(AgvBindAndInTParam param, Long loginUserId) { |
| | | CompletableFuture.runAsync(() -> { |
| | | int retry = 0; |
| | | while (retry < 5) { |
| | | retry++; |
| | | try { |
| | | Thread.sleep(1000); |
| | | WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getBarcode, param.getPalletBarcode()) |
| | | .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val) |
| | | .last("limit 1")); |
| | | if (Objects.isNull(waitPakin)) { |
| | | continue; |
| | | } |
| | | |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, param.getPalletSta()) |
| | | .last("limit 1")); |
| | | if (Objects.isNull(basStation)) { |
| | | return; |
| | | } |
| | | // if (Objects.isNull(basStation) || Objects.isNull(basStation.getArea())) { |
| | | // return; |
| | | // } |
| | | |
| | | WaitPakinParam waitPakinPda = new WaitPakinParam() |
| | | .setBarcode(param.getPalletBarcode()) |
| | | .setStaNo(param.getPalletSta()) |
| | | .setArea(param.getArea()); |
| | | AGVInTaskStart(waitPakinPda, loginUserId); |
| | | return; |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private SyncOrdersItem buildOrderItem(AgvBindAndInTParam param, Matnr matnr, long uniqueSeed, long nowSeconds) { |
| | | String suffix = String.valueOf(uniqueSeed); |
| | | String batch = LocalDateTime.ofInstant(Instant.ofEpochSecond(nowSeconds), ZoneId.systemDefault()) |