From db576395617232b8526ff59cbb29014437af7c8c Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 17 十二月 2024 16:00:46 +0800 Subject: [PATCH] # --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java | 3 + zy-acs-fake/src/main/java/com/zy/acs/fake/domain/DynamicNode.java | 8 ++++ zy-acs-manager/src/main/java/com/zy/acs/manager/core/DemoController.java | 19 +++++++-- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/domain/DynamicNode.java | 7 +++ zy-acs-manager/src/main/resources/agv.py | 15 ++++++- zy-acs-fake/src/main/java/com/zy/acs/fake/service/MapService.java | 11 ++++- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java | 10 ++++- 7 files changed, 61 insertions(+), 12 deletions(-) diff --git a/zy-acs-fake/src/main/java/com/zy/acs/fake/domain/DynamicNode.java b/zy-acs-fake/src/main/java/com/zy/acs/fake/domain/DynamicNode.java index 2335cff..eced99a 100644 --- a/zy-acs-fake/src/main/java/com/zy/acs/fake/domain/DynamicNode.java +++ b/zy-acs-fake/src/main/java/com/zy/acs/fake/domain/DynamicNode.java @@ -16,6 +16,8 @@ private Integer serial = -1; + private long time = 0; + public DynamicNode() {} public DynamicNode(String vehicle) { @@ -27,4 +29,10 @@ this.serial = serial; } + public DynamicNode(String vehicle, Integer serial, long time) { + this.vehicle = vehicle; + this.serial = serial; + this.time = time; + } + } diff --git a/zy-acs-fake/src/main/java/com/zy/acs/fake/service/MapService.java b/zy-acs-fake/src/main/java/com/zy/acs/fake/service/MapService.java index 6228265..a737504 100644 --- a/zy-acs-fake/src/main/java/com/zy/acs/fake/service/MapService.java +++ b/zy-acs-fake/src/main/java/com/zy/acs/fake/service/MapService.java @@ -110,16 +110,21 @@ DynamicNode dynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; - Integer serial = dynamicNode.getSerial(); + long time = dynamicNode.getTime(); List<String> resetCodeList = new ArrayList<>(); for (int i = 0; i < dynamicMatrix.length; i++) { for (int j = 0; j < dynamicMatrix[i].length; j++) { + + if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } + DynamicNode node = dynamicMatrix[i][j]; - if (node.getVehicle().equals(agvNo) && node.getSerial() < serial) { - resetCodeList.add(codeMatrix[i][j]); + if (node.getVehicle().equals(agvNo)) { + if (node.getSerial() < serial || node.getTime() != time) { + resetCodeList.add(codeMatrix[i][j]); + } } } } diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/DemoController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/DemoController.java index 4f26862..3100ec2 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/DemoController.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/DemoController.java @@ -17,11 +17,9 @@ import com.zy.acs.manager.system.controller.BaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.util.Collections; import java.util.List; /** @@ -130,4 +128,17 @@ return R.ok(); } + // http://localhost:8088/demo/auto/go/patrol?count=10 + @GetMapping("/auto/go/patrol") + public R autoGoPatrol(@RequestParam(required = false, defaultValue = "5") Integer count) { + List<Agv> list = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); + Collections.shuffle(list); + List<Agv> agvs = list.subList(0, count); + int result = 0; + for (Agv agv : agvs) { + patrolService.startupPatrol(agv.getUuid()); + result++; + } + return R.ok().add(result); + } } diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java index aa8bb1c..dbda04c 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java @@ -204,14 +204,20 @@ Integer serial = dynamicNode.getSerial(); + long time = dynamicNode.getTime(); List<String> resetCodeList = new ArrayList<>(); for (int i = 0; i < dynamicMatrix.length; i++) { for (int j = 0; j < dynamicMatrix[i].length; j++) { + + if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } + DynamicNode node = dynamicMatrix[i][j]; - if (node.getVehicle().equals(agvNo) && node.getSerial() < serial) { - resetCodeList.add(codeMatrix[i][j]); + if (node.getVehicle().equals(agvNo)) { + if (node.getSerial() < serial || node.getTime() != time) { + resetCodeList.add(codeMatrix[i][j]); + } } } } diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java index 711e78a..5411381 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/MapDataDispatcher.java @@ -447,10 +447,11 @@ if (Cools.isEmpty(codeList, vehicle)) { return; } + long time = System.currentTimeMillis() / 1000; int serial = 1; for (String code : codeList) { int[] node = getCodeMatrixIdx(lev, code); - dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial); + dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial, time); serial++; } } else { diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/domain/DynamicNode.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/domain/DynamicNode.java index 7b46e3a..30e3d1f 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/domain/DynamicNode.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/astart/domain/DynamicNode.java @@ -16,6 +16,8 @@ private Integer serial = -1; + private long time = 0; + public DynamicNode() {} public DynamicNode(String vehicle) { @@ -27,4 +29,9 @@ this.serial = serial; } + public DynamicNode(String vehicle, Integer serial, long time) { + this.vehicle = vehicle; + this.serial = serial; + this.time = time; + } } diff --git a/zy-acs-manager/src/main/resources/agv.py b/zy-acs-manager/src/main/resources/agv.py index 2634411..245bb6e 100644 --- a/zy-acs-manager/src/main/resources/agv.py +++ b/zy-acs-manager/src/main/resources/agv.py @@ -97,9 +97,20 @@ # 灏� dynamicMatrix 杞崲涓� numpy 缁撴瀯鍖栨暟缁� def convert_to_structured_array(dynamicMatrix): # 瀹氫箟缁撴瀯鍖栨暟缁勭殑 dtype - dtype = [('serial', int), ('vehicle', 'U2')] + dtype = [('serial', int), ('vehicle', 'U2'), ('time', int)] + + # 纭繚姣忎釜瀛楀吀鍖呭惈鎵�鏈夊瓧娈� + structured_list = [] + for row in dynamicMatrix: + for d in row: + # 鎻愬彇瀛楁锛岀‘淇� 'time' 瀛樺湪锛屽惁鍒欒缃负榛樿鍊硷紙渚嬪 0.0锛� + serial = d.get('serial', 0) + vehicle = d.get('vehicle', '0') + time_val = d.get('time', 0) + structured_list.append((serial, vehicle, time_val)) + # 灏嗗祵濂楃殑鍒楄〃杞崲涓虹粨鏋勫寲鏁扮粍 - structured_array = np.array([tuple(d.values()) for row in dynamicMatrix for d in row], dtype=dtype) + structured_array = np.array(structured_list, dtype=dtype) # 閲嶅涓哄師濮嬬殑浜岀淮褰㈢姸 return structured_array.reshape(len(dynamicMatrix), -1) -- Gitblit v1.9.1