diff --git a/servo/src/main/java/com/yvan/workbench/controller/ApiController.java b/servo/src/main/java/com/yvan/workbench/controller/ApiController.java index 91e6a07..12d8d2a 100644 --- a/servo/src/main/java/com/yvan/workbench/controller/ApiController.java +++ b/servo/src/main/java/com/yvan/workbench/controller/ApiController.java @@ -3,6 +3,7 @@ package com.yvan.workbench.controller; import com.galaxis.rcs.common.entity.ApiTask; import com.galaxis.rcs.common.entity.LccBasLocation; import com.galaxis.rcs.inv.InvManager; +import com.google.common.collect.Sets; import com.querydsl.core.util.StringUtils; import com.yvan.entity.BasLocationVo; import com.yvan.logisticsModel.LogisticsRuntime; @@ -42,13 +43,25 @@ public class ApiController { private final static String projectUUID = "tw_zh"; private final static long envId = 13; - private final static String inPos = "504_506_0_0_0"; - private final static String outPos = "504_503_0_0_0"; + private final static String inPos = "150_0_0_0"; + private final static String outPos = "148_0_0_0"; // 礼品托盘 private final static String giftLpn = "GLPN"; // 礼品托盘位 - private final static String gifPos = "500_500_0_0_0"; + private final static String gifPos = "82_0_0_0"; + + private final static String cl2_gstore = "146_0_0_0"; + private final static String cl2_agvId = "200"; + private final static String cl2_agvLocCode = "AGV_200"; + private final static Set cl2_demoLocSet = Sets.newHashSet( + "155_0_1_0", "157_0_1_0", "159_0_1_0"); + + private final static String clx_gstore = "84_0_0_0"; + private final static String clx_agvId = "300"; + private final static String clx_agvLocCode = "AGV_300"; + private final static Set clx_demoLocSet = Sets.newHashSet( + "89_0_2_0", "162_0_2_0", "91_0_2_0", "93_0_2_0"); static final QueryDSL queryDSL = DaoFactory.getQueryDSL(); @@ -59,20 +72,17 @@ public class ApiController { private static void createCl2DemoTask() { if (cl2DemoTask != null) { if (cl2DemoTask.isAlive()) { + log.error("cl2 error 1"); return; } } cl2DemoTask = new Thread(() -> { - String gstore = "504_501_0_0_0"; - String agvId = "1"; - String agvLocCode = "AGV_1"; - Set demoLocSet = new HashSet<>(); - demoLocSet.add("rack1_0_1_0"); - demoLocSet.add("rack1_1_1_0"); - demoLocSet.add("rack1_2_1_0"); - demoLocSet.add("rack1_3_1_0"); - + String gstore = cl2_gstore; + String agvId = cl2_agvId; + String agvLocCode = cl2_agvLocCode; + Set demoLocSet = cl2_demoLocSet; + long loopCnt = 0; while (true) { // 查询是否有出库任务 @@ -88,6 +98,7 @@ public class ApiController { .fetchFirst(); if (!(cl2Running.get() || outTask != null || inTask != null)) { + log.error("cl2 error 2"); return; } @@ -110,6 +121,11 @@ public class ApiController { .where(lccInvLpn.qty.gt(0).and(lccInvLpn.envId.eq(envId)) ))).distinct().fetch(); + if(emptyLocList.size() <= 0){ + log.error("cl2 error 99, no empty pallet"); + return; + } + Set emptyLocSet = new HashSet<>(emptyLocList); // if (gInvCount <= 0) { @@ -135,6 +151,7 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(locCode)); R re = RcsController.agvUnload(params); if (!re.isSuccess()) { + log.error("cl2 error 3"); return; } if (outTask != null) { @@ -147,6 +164,7 @@ public class ApiController { re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("cl2 error 4"); return; } if (outTask != null) { @@ -169,6 +187,7 @@ public class ApiController { R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("cl2 error 5"); return; } if (inTask != null) { @@ -179,6 +198,7 @@ public class ApiController { re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("cl2 error 6"); return; } if (inTask != null) { @@ -200,6 +220,7 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(outPos)); R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("cl2 error 7"); return; } queryDSL.update(apiTask) @@ -210,6 +231,7 @@ public class ApiController { outTask.setLpn(lpn); re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("cl2 error 8"); return; } completeTask(outTask); @@ -223,10 +245,12 @@ public class ApiController { R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("cl2 error 9"); return; } re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("cl2 error 10"); return; } } else { @@ -238,10 +262,12 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(gstore)); R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("cl2 error 11"); return; } re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("cl2 error 12"); return; } @@ -249,6 +275,9 @@ public class ApiController { } Thread.sleep(1000); + loopCnt++; + log.info("cl2 loop cnt: {}", loopCnt); + } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -264,19 +293,18 @@ public class ApiController { private static void createClxDemoTask() { if (clxDemoTask != null) { if (clxDemoTask.isAlive()) { + log.error("clx error 0"); return; } } clxDemoTask = new Thread(() -> { - String gstore = "502_500_0_0_0"; - String agvId = "2"; - String agvLocCode = "AGV_2"; - Set demoLocSet = new HashSet<>(); - demoLocSet.add("rack1_0_2_0"); - demoLocSet.add("rack1_1_2_0"); - demoLocSet.add("rack1_2_2_0"); - demoLocSet.add("rack1_3_2_0"); + String gstore = clx_gstore; + String agvId = clx_agvId; + String agvLocCode = clx_agvLocCode; + Set demoLocSet = clx_demoLocSet; + long loopCnt = 0; + while (true) { // 查询是否有礼品出库任务 ApiTask outTask = queryDSL.select(apiTask).from(apiTask) @@ -290,6 +318,7 @@ public class ApiController { .and(apiTask.taskType.eq(3)).and(apiTask.taskStatus.in(0, 1))) .fetchFirst(); if (!(clxRunning.get() || outTask != null || inTask != null)) { + log.info("clx not running"); return; } @@ -341,6 +370,7 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(locCode)); R re = RcsController.agvUnload(params); if (!re.isSuccess()) { + log.error("clx error 3"); return; } if (outTask != null && aInvLpn.equals(giftLpn)) { @@ -351,6 +381,7 @@ public class ApiController { re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("clx error 1"); return; } if (outTask != null && aInvLpn.equals(giftLpn)) { @@ -373,6 +404,7 @@ public class ApiController { R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("clx error 2"); return; } queryDSL.update(apiTask) @@ -381,6 +413,7 @@ public class ApiController { re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("clx error 4"); return; } completeTask(inTask); @@ -397,6 +430,7 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(gifPos)); R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("clx error 5"); return; } queryDSL.update(apiTask) @@ -405,6 +439,7 @@ public class ApiController { re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("clx error 6"); return; } completeTask(outTask); @@ -418,10 +453,12 @@ public class ApiController { R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("clx error 10"); return; } re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("clx error 9"); return; } } else { @@ -434,10 +471,12 @@ public class ApiController { params.put("targetStoreLoc", locCodeToLoc(gstore)); R re = RcsController.agvCarry(params); if (!re.isSuccess()) { + log.error("clx error 8"); return; } re = RcsController.waitTaskFinish(params); if (!re.isSuccess()) { + log.error("clx error 7"); return; } @@ -445,6 +484,9 @@ public class ApiController { } Thread.sleep(1000); + loopCnt++; + log.info("clx loop cnt: {}", loopCnt); + } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -457,11 +499,7 @@ public class ApiController { public static String locCodeToLoc(String locCode) { - if (locCode.startsWith("rack")) { - return locCode.replaceAll("_", "/"); - } else { - return locCode.replaceAll("_0_0_0", ""); - } + return locCode; } public static RR in_bound(@RequestBody Map params) { diff --git a/servo/src/main/java/com/yvan/workbench/controller/RcsController.java b/servo/src/main/java/com/yvan/workbench/controller/RcsController.java index 623d6cd..7a1feb8 100644 --- a/servo/src/main/java/com/yvan/workbench/controller/RcsController.java +++ b/servo/src/main/java/com/yvan/workbench/controller/RcsController.java @@ -422,6 +422,9 @@ public class RcsController { Long envId = Conv.asLong(params.get("envId")); String agvId = Conv.asString(params.get("agvId")); RcsTaskOption option = new JsonWrapper((Map) params.get("option")).asObject(RcsTaskOption.class); + if (option == null) { + option = new RcsTaskOption(); + } if (Strings.isNullOrEmpty(projectUUID)) { return R.fail("projectUUID Must not be empty");